summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjoye <joye>2014-04-18 17:41:06 (GMT)
committerjoye <joye>2014-04-18 17:41:06 (GMT)
commita42c9243c09c908e0fdbe8eef5784b2fc5e22b39 (patch)
tree35a21142016c528895d20dd34055f69a39243c17
parent7b9b44184096a8a901ad0ec5a2dbc4aee5ebe538 (diff)
downloadblt-a42c9243c09c908e0fdbe8eef5784b2fc5e22b39.zip
blt-a42c9243c09c908e0fdbe8eef5784b2fc5e22b39.tar.gz
blt-a42c9243c09c908e0fdbe8eef5784b2fc5e22b39.tar.bz2
*** empty log message ***
-rw-r--r--src/bltGrAxis.C12
-rw-r--r--src/bltGrAxis.h9
-rw-r--r--src/bltGrAxisOp.C16
-rw-r--r--src/bltGrAxisOption.C8
-rw-r--r--src/bltGrElem.h11
-rw-r--r--src/bltGrElemBar.C14
-rw-r--r--src/bltGrElemLine.C4
-rw-r--r--src/bltGrElemOp.C82
-rw-r--r--src/bltGrElemOp.h1
-rw-r--r--src/bltGrElemOption.C6
-rw-r--r--src/bltGrHairs.h8
-rw-r--r--src/bltGrHairsOp.C16
-rw-r--r--src/bltGrLegd.C4
-rw-r--r--src/bltGrLegdOp.C24
-rw-r--r--src/bltGrMarker.h10
-rw-r--r--src/bltGrMarkerOp.C10
-rw-r--r--src/bltGrPen.h9
-rw-r--r--src/bltGrPenOp.C6
-rw-r--r--src/bltGrPenOp.h3
-rw-r--r--src/bltGrPenOption.C2
-rw-r--r--src/bltGrXAxisOp.C12
-rw-r--r--src/bltGraph.C67
-rw-r--r--src/bltGraph.h1
-rw-r--r--src/bltGraphOp.C20
24 files changed, 172 insertions, 183 deletions
diff --git a/src/bltGrAxis.C b/src/bltGrAxis.C
index 0c869fc..d347c65 100644
--- a/src/bltGrAxis.C
+++ b/src/bltGrAxis.C
@@ -329,7 +329,7 @@ int Axis::configure()
char msg[200];
sprintf_s(msg, 200,
"impossible axis limits (-min %g >= -max %g) for \"%s\"",
- ops->reqMin, ops->reqMax, name());
+ ops->reqMin, ops->reqMax, name_);
Tcl_AppendResult(graphPtr_->interp_, msg, NULL);
return TCL_ERROR;
}
@@ -342,7 +342,7 @@ int Axis::configure()
if ((!isnan(ops->reqMin)) && (ops->reqMin <= 0.0)) {
Tcl_AppendResult(graphPtr_->interp_,"bad logscale -min limit \"",
Blt_Dtoa(graphPtr_->interp_, ops->reqMin),
- "\" for axis \"", name(), "\"",
+ "\" for axis \"", name_, "\"",
NULL);
return TCL_ERROR;
}
@@ -1693,7 +1693,7 @@ void Axis::print(Blt_Ps ps)
if (ops->hide || !use_ || (flags & DELETE_PENDING))
return;
- Blt_Ps_Format(ps, "%% Axis \"%s\"\n", name());
+ Blt_Ps_Format(ps, "%% Axis \"%s\"\n", name_);
if (ops->normalBg)
Blt_Ps_Fill3DRectangle(ps, ops->normalBg, left_, top_,
right_ - left_, bottom_ - top_,
@@ -1748,16 +1748,16 @@ void Axis::printGrids(Blt_Ps ps)
if (ops->hide || !ops->showGrid || !use_ || (flags & DELETE_PENDING))
return;
- Blt_Ps_Format(ps, "%% Axis %s: grid line attributes\n", name());
+ Blt_Ps_Format(ps, "%% Axis %s: grid line attributes\n", name_);
Blt_Ps_XSetLineAttributes(ps, ops->major.color, ops->major.lineWidth,
&ops->major.dashes, CapButt, JoinMiter);
- Blt_Ps_Format(ps, "%% Axis %s: major grid line segments\n", name());
+ Blt_Ps_Format(ps, "%% Axis %s: major grid line segments\n", name_);
Blt_Ps_Draw2DSegments(ps, ops->major.segments, ops->major.nUsed);
if (ops->showGridMinor) {
Blt_Ps_XSetLineAttributes(ps, ops->minor.color, ops->minor.lineWidth,
&ops->minor.dashes, CapButt, JoinMiter);
- Blt_Ps_Format(ps, "%% Axis %s: minor grid line segments\n", name());
+ Blt_Ps_Format(ps, "%% Axis %s: minor grid line segments\n", name_);
Blt_Ps_Draw2DSegments(ps, ops->minor.segments, ops->minor.nUsed);
}
}
diff --git a/src/bltGrAxis.h b/src/bltGrAxis.h
index f698db7..31d0e57 100644
--- a/src/bltGrAxis.h
+++ b/src/bltGrAxis.h
@@ -147,13 +147,15 @@ typedef struct {
} AxisOptions;
class Axis {
+ protected:
+ Tk_OptionTable optionTable_;
+ void* ops_;
+
public:
Graph* graphPtr_;
ClassId classId_;
const char* name_;
const char* className_;
- Tk_OptionTable optionTable_;
- void* ops_;
int use_;
Tcl_HashEntry* hashPtr_;
@@ -215,9 +217,6 @@ class Axis {
Axis(Graph*, const char*, int, Tcl_HashEntry*);
virtual ~Axis();
- ClassId classId() {return classId_;}
- const char* name() {return name_;}
- const char* className() {return className_;}
Tk_OptionTable optionTable() {return optionTable_;}
void* ops() {return ops_;}
diff --git a/src/bltGrAxisOp.C b/src/bltGrAxisOp.C
index 5d0484c..237fca1 100644
--- a/src/bltGrAxisOp.C
+++ b/src/bltGrAxisOp.C
@@ -432,7 +432,7 @@ static int FocusOp(Tcl_Interp* interp, Graph* graphPtr,
Blt_SetFocusItem(graphPtr->bindTable_, graphPtr->focusPtr_, NULL);
if (graphPtr->focusPtr_)
- Tcl_SetStringObj(Tcl_GetObjResult(interp), graphPtr->focusPtr_->name(),-1);
+ Tcl_SetStringObj(Tcl_GetObjResult(interp), graphPtr->focusPtr_->name_,-1);
return TCL_OK;
}
@@ -444,13 +444,13 @@ static int GetOp(Tcl_Interp* interp, Graph* graphPtr,
// Report only on axes
if ((axisPtr) &&
- ((axisPtr->classId() == CID_AXIS_X) ||
- (axisPtr->classId() == CID_AXIS_Y) ||
- (axisPtr->classId() == CID_NONE))) {
+ ((axisPtr->classId_ == CID_AXIS_X) ||
+ (axisPtr->classId_ == CID_AXIS_Y) ||
+ (axisPtr->classId_ == CID_NONE))) {
char *string = Tcl_GetString(objv[3]);
if (!strcmp(string, "current"))
- Tcl_SetStringObj(Tcl_GetObjResult(interp), axisPtr->name(),-1);
+ Tcl_SetStringObj(Tcl_GetObjResult(interp), axisPtr->name_,-1);
else if (!strcmp(string, "detail"))
Tcl_SetStringObj(Tcl_GetObjResult(interp), axisPtr->detail_, -1);
}
@@ -499,7 +499,7 @@ static int NamesOp(Tcl_Interp* interp, Graph* graphPtr,
if (axisPtr->flags & DELETE_PENDING)
continue;
- Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewStringObj(axisPtr->name(), -1));
+ Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewStringObj(axisPtr->name_, -1));
}
}
else {
@@ -508,9 +508,9 @@ static int NamesOp(Tcl_Interp* interp, Graph* graphPtr,
Axis* axisPtr = (Axis*)Tcl_GetHashValue(hPtr);
for (int ii=3; ii<objc; ii++) {
const char *pattern = (const char*)Tcl_GetString(objv[ii]);
- if (Tcl_StringMatch(axisPtr->name(), pattern)) {
+ if (Tcl_StringMatch(axisPtr->name_, pattern)) {
Tcl_ListObjAppendElement(interp, listObjPtr,
- Tcl_NewStringObj(axisPtr->name(), -1));
+ Tcl_NewStringObj(axisPtr->name_, -1));
break;
}
}
diff --git a/src/bltGrAxisOption.C b/src/bltGrAxisOption.C
index d5b3a2b..279fa87 100644
--- a/src/bltGrAxisOption.C
+++ b/src/bltGrAxisOption.C
@@ -81,7 +81,7 @@ static Tcl_Obj* AxisGetProc(ClientData clientData, Tk_Window tkwin,
if (!axisPtr)
return Tcl_NewStringObj("", -1);
- return Tcl_NewStringObj(axisPtr->name(), -1);
+ return Tcl_NewStringObj(axisPtr->name_, -1);
};
static void AxisFreeProc(ClientData clientData, Tk_Window tkwin, char *ptr)
@@ -251,13 +251,13 @@ static int GetAxisByClass(Tcl_Interp* interp, Graph* graphPtr, Tcl_Obj *objPtr,
if (classId != CID_NONE) {
// Set the axis type on the first use of it.
- if ((axisPtr->refCount_ == 0) || (axisPtr->classId() == CID_NONE))
+ if ((axisPtr->refCount_ == 0) || (axisPtr->classId_ == CID_NONE))
axisPtr->setClass(classId);
- else if (axisPtr->classId() != classId) {
+ else if (axisPtr->classId_ != classId) {
Tcl_AppendResult(interp, "axis \"", Tcl_GetString(objPtr),
"\" is already in use on an opposite ",
- axisPtr->className(), "-axis",
+ axisPtr->className_, "-axis",
NULL);
return TCL_ERROR;
}
diff --git a/src/bltGrElem.h b/src/bltGrElem.h
index d6c2b15..744bc79 100644
--- a/src/bltGrElem.h
+++ b/src/bltGrElem.h
@@ -118,17 +118,17 @@ typedef struct {
class Element {
protected:
- Graph* graphPtr_;
- const char* name_;
Tk_OptionTable optionTable_;
void* ops_;
- Tcl_HashEntry* hashPtr_;
- int hide_;
double xRange_;
double yRange_;
public:
+ Graph* graphPtr_;
+ const char* name_;
+ Tcl_HashEntry* hashPtr_;
+ int hide_;
unsigned short row_;
unsigned short col_;
int *activeIndices_;
@@ -159,11 +159,8 @@ class Element {
virtual const char* className() =0;
virtual const char* typeName() =0;
- Graph* graphPtr() {return graphPtr_;}
- const char* name() {return name_;}
Tk_OptionTable optionTable() {return optionTable_;}
void* ops() {return ops_;}
- int hide() {return hide_;}
};
extern void Blt_FreeStylePalette (Blt_Chain stylePalette);
diff --git a/src/bltGrElemBar.C b/src/bltGrElemBar.C
index 05bf650..23932ca 100644
--- a/src/bltGrElemBar.C
+++ b/src/bltGrElemBar.C
@@ -319,7 +319,7 @@ void BarElement::map()
Tcl_HashTable *tablePtr = (Tcl_HashTable*)Tcl_GetHashValue(hPtr);
const char *name = (ops->groupName) ?
- ops->groupName : ops->axes.y->name();
+ ops->groupName : ops->axes.y->name_;
hPtr = Tcl_FindHashEntry(tablePtr, name);
if (hPtr) {
double slice, width, offset;
@@ -769,7 +769,7 @@ void BarElement::print(Blt_Ps ps)
return;
// Comment the PostScript to indicate the start of the element
- Blt_Ps_Format(ps, "\n%% Element \"%s\"\n\n", name());
+ Blt_Ps_Format(ps, "\n%% Element \"%s\"\n\n", name_);
int count = 0;
for (Blt_ChainLink link = Blt_Chain_FirstLink(ops->stylePalette); link;
@@ -819,7 +819,7 @@ void BarElement::printActive(Blt_Ps ps)
return;
BarPenOptions* penOps = (BarPenOptions*)penPtr->ops();
- Blt_Ps_Format(ps, "\n%% Active Element \"%s\"\n\n", name());
+ Blt_Ps_Format(ps, "\n%% Active Element \"%s\"\n\n", name_);
if (nActiveIndices_ > 0) {
if (flags & ACTIVE_PENDING)
@@ -1470,7 +1470,7 @@ void Blt_InitBarSetTable(Graph* graphPtr)
BarElement* bePtr = (BarElement*)Blt_Chain_GetValue(link);
BarElementOptions* ops = (BarElementOptions*)bePtr->ops();
- if ((bePtr->hide()) || (bePtr->classId() != CID_ELEM_BAR))
+ if ((bePtr->hide_) || (bePtr->classId() != CID_ELEM_BAR))
continue;
nSegs++;
@@ -1497,7 +1497,7 @@ void Blt_InitBarSetTable(Graph* graphPtr)
else
tablePtr = (Tcl_HashTable*)Tcl_GetHashValue(hPtr);
- name = (ops->groupName) ? ops->groupName : ops->axes.y->name();
+ name = (ops->groupName) ? ops->groupName : ops->axes.y->name_;
hPtr = Tcl_CreateHashEntry(tablePtr, name, &isNew);
if (isNew)
count = 1;
@@ -1589,7 +1589,7 @@ void Blt_ComputeBarStacks(Graph* graphPtr)
BarElement* bePtr = (BarElement*)Blt_Chain_GetValue(link);
BarElementOptions* ops = (BarElementOptions*)bePtr->ops();
- if ((bePtr->hide()) || (bePtr->classId() != CID_ELEM_BAR))
+ if ((bePtr->hide_) || (bePtr->classId() != CID_ELEM_BAR))
continue;
if (ops->coords.x && ops->coords.y) {
@@ -1607,7 +1607,7 @@ void Blt_ComputeBarStacks(Graph* graphPtr)
continue;
Tcl_HashTable *tablePtr = (Tcl_HashTable*)Tcl_GetHashValue(hPtr);
- name = (ops->groupName) ? ops->groupName : ops->axes.y->name();
+ name = (ops->groupName) ? ops->groupName : ops->axes.y->name_;
hPtr = Tcl_FindHashEntry(tablePtr, name);
if (!hPtr)
continue;
diff --git a/src/bltGrElemLine.C b/src/bltGrElemLine.C
index 1140936..43476d4 100644
--- a/src/bltGrElemLine.C
+++ b/src/bltGrElemLine.C
@@ -739,7 +739,7 @@ void LineElement::print(Blt_Ps ps)
if (hide_ || (flags & DELETE_PENDING))
return;
- Blt_Ps_Format(ps, "\n%% Element \"%s\"\n\n", name());
+ Blt_Ps_Format(ps, "\n%% Element \"%s\"\n\n", name_);
// Draw fill area
if (fillPts_) {
@@ -841,7 +841,7 @@ void LineElement::printActive(Blt_Ps ps)
return;
LinePenOptions* penOps = (LinePenOptions*)penPtr->ops();
- Blt_Ps_Format(ps, "\n%% Active Element \"%s\"\n\n", name());
+ Blt_Ps_Format(ps, "\n%% Active Element \"%s\"\n\n", name_);
int symbolSize = ScaleSymbol(penOps->symbol.size);
if (nActiveIndices_ > 0) {
diff --git a/src/bltGrElemOp.C b/src/bltGrElemOp.C
index d8050b0..bc99e8a 100644
--- a/src/bltGrElemOp.C
+++ b/src/bltGrElemOp.C
@@ -50,10 +50,10 @@ static int GetIndex(Tcl_Interp* interp, Element* elemPtr,
// Create
-static int ElementObjConfigure(Tcl_Interp* interp, Graph* graphPtr,
- Element* elemPtr,
- int objc, Tcl_Obj* const objv[])
+int ElementObjConfigure(Tcl_Interp* interp, Element* elemPtr,
+ int objc, Tcl_Obj* const objv[])
{
+ Graph* graphPtr = elemPtr->graphPtr_;
Tk_SavedOptions savedOptions;
int mask =0;
int error;
@@ -93,55 +93,9 @@ static int ElementObjConfigure(Tcl_Interp* interp, Graph* graphPtr,
}
}
-static int CreateElement(Graph* graphPtr, Tcl_Interp* interp, int objc,
- Tcl_Obj *const *objv, ClassId classId)
-{
- char *name = Tcl_GetString(objv[3]);
- if (name[0] == '-') {
- Tcl_AppendResult(interp, "name of element \"", name,
- "\" can't start with a '-'", NULL);
- return TCL_ERROR;
- }
-
- int isNew;
- Tcl_HashEntry* hPtr =
- Tcl_CreateHashEntry(&graphPtr->elements_.table, name, &isNew);
- if (!isNew) {
- Tcl_AppendResult(interp, "element \"", name,
- "\" already exists in \"", Tcl_GetString(objv[0]),
- "\"", NULL);
- return TCL_ERROR;
- }
-
- Element* elemPtr;
- switch (classId) {
- case CID_ELEM_BAR:
- elemPtr = new BarElement(graphPtr,name,hPtr);
- break;
- case CID_ELEM_LINE:
- elemPtr = new LineElement(graphPtr,name,hPtr);
- break;
- default:
- return TCL_ERROR;
- }
- if (!elemPtr)
- return TCL_ERROR;
-
- Tcl_SetHashValue(hPtr, elemPtr);
-
- if ((Tk_InitOptions(interp, (char*)elemPtr->ops(), elemPtr->optionTable(), graphPtr->tkwin_) != TCL_OK) || (ElementObjConfigure(interp, graphPtr, elemPtr, objc-4, objv+4) != TCL_OK)) {
- Blt_DestroyElement(elemPtr);
- return TCL_ERROR;
- }
-
- elemPtr->link = Blt_Chain_Append(graphPtr->elements_.displayList, elemPtr);
-
- return TCL_OK;
-}
-
void Blt_DestroyElement(Element* elemPtr)
{
- Graph* graphPtr = elemPtr->graphPtr();
+ Graph* graphPtr = elemPtr->graphPtr_;
Blt_DeleteBindings(graphPtr->bindTable_, elemPtr);
graphPtr->legend_->removeElement(elemPtr);
@@ -196,7 +150,7 @@ static int ConfigureOp(Graph* graphPtr, Tcl_Interp* interp,
return TCL_OK;
}
else
- return ElementObjConfigure(interp, graphPtr, elemPtr, objc-4, objv+4);
+ return ElementObjConfigure(interp, elemPtr, objc-4, objv+4);
}
// Ops
@@ -213,7 +167,7 @@ static int ActivateOp(Graph* graphPtr, Tcl_Interp* interp,
Element* elemPtr = (Element*)Tcl_GetHashValue(hPtr);
if (elemPtr->flags & ACTIVE)
Tcl_ListObjAppendElement(interp, listObjPtr,
- Tcl_NewStringObj(elemPtr->name(), -1));
+ Tcl_NewStringObj(elemPtr->name_, -1));
}
Tcl_SetObjResult(interp, listObjPtr);
@@ -299,7 +253,7 @@ static int ClosestOp(Graph* graphPtr, Tcl_Interp* interp,
if (graphPtr->getElement(objv[ii], &elemPtr) != TCL_OK)
return TCL_ERROR;
- if (elemPtr && !elemPtr->hide() &&
+ if (elemPtr && !elemPtr->hide_ &&
!(elemPtr->flags & (MAP_ITEM|DELETE_PENDING)))
elemPtr->closest();
}
@@ -313,7 +267,7 @@ static int ClosestOp(Graph* graphPtr, Tcl_Interp* interp,
for (Blt_ChainLink link=Blt_Chain_LastLink(graphPtr->elements_.displayList);
link != NULL; link = Blt_Chain_PrevLink(link)) {
Element* elemPtr = (Element*)Blt_Chain_GetValue(link);
- if (elemPtr && !elemPtr->hide() &&
+ if (elemPtr && !elemPtr->hide_ &&
!(elemPtr->flags & (MAP_ITEM|DELETE_PENDING)))
elemPtr->closest();
}
@@ -322,7 +276,7 @@ static int ClosestOp(Graph* graphPtr, Tcl_Interp* interp,
if (searchPtr->dist < (double)searchPtr->halo) {
Tcl_Obj* listObjPtr = Tcl_NewListObj(0, (Tcl_Obj **)NULL);
Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewStringObj("name", -1));
- Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewStringObj(searchPtr->elemPtr->name(), -1));
+ Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewStringObj(searchPtr->elemPtr->name_, -1));
Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewStringObj("index", -1));
Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewIntObj(searchPtr->index));
Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewStringObj("x", -1));
@@ -338,9 +292,9 @@ static int ClosestOp(Graph* graphPtr, Tcl_Interp* interp,
}
static int CreateOp(Graph* graphPtr, Tcl_Interp* interp,
- int objc, Tcl_Obj* const objv[], ClassId classId)
+ int objc, Tcl_Obj* const objv[])
{
- if (CreateElement(graphPtr, interp, objc, objv, classId) != TCL_OK)
+ if (graphPtr->createElement(objc, objv) != TCL_OK)
return TCL_ERROR;
Tcl_SetObjResult(interp, objv[3]);
@@ -401,7 +355,7 @@ static int GetOp(Graph* graphPtr, Tcl_Interp* interp,
if ((string[0] == 'c') && (strcmp(string, "current") == 0)) {
Element* elemPtr = (Element*)Blt_GetCurrentItem(graphPtr->bindTable_);
if ((elemPtr) && ((elemPtr->flags & DELETE_PENDING) == 0))
- Tcl_SetStringObj(Tcl_GetObjResult(interp), elemPtr->name(),-1);
+ Tcl_SetStringObj(Tcl_GetObjResult(interp), elemPtr->name_,-1);
}
return TCL_OK;
}
@@ -447,7 +401,7 @@ static int NamesOp(Graph* graphPtr, Tcl_Interp* interp,
Tcl_HashSearch iter;
for (Tcl_HashEntry *hPtr = Tcl_FirstHashEntry(&graphPtr->elements_.table, &iter); hPtr != NULL; hPtr = Tcl_NextHashEntry(&iter)) {
Element* elemPtr = (Element*)Tcl_GetHashValue(hPtr);
- Tcl_Obj *objPtr = Tcl_NewStringObj(elemPtr->name(), -1);
+ Tcl_Obj *objPtr = Tcl_NewStringObj(elemPtr->name_, -1);
Tcl_ListObjAppendElement(interp, listObjPtr, objPtr);
}
}
@@ -457,8 +411,8 @@ static int NamesOp(Graph* graphPtr, Tcl_Interp* interp,
Element* elemPtr = (Element*)Tcl_GetHashValue(hPtr);
for (int ii=3; ii<objc; ii++) {
- if (Tcl_StringMatch(elemPtr->name(),Tcl_GetString(objv[ii]))) {
- Tcl_Obj *objPtr = Tcl_NewStringObj(elemPtr->name(), -1);
+ if (Tcl_StringMatch(elemPtr->name_,Tcl_GetString(objv[ii]))) {
+ Tcl_Obj *objPtr = Tcl_NewStringObj(elemPtr->name_, -1);
Tcl_ListObjAppendElement(interp, listObjPtr, objPtr);
break;
}
@@ -576,7 +530,7 @@ typedef int (GraphElementProc)(Graph* graphPtr, Tcl_Interp* interp, int objc,
Tcl_Obj *const *objv);
int Blt_ElementOp(Graph* graphPtr, Tcl_Interp* interp,
- int objc, Tcl_Obj* const objv[], ClassId classId)
+ int objc, Tcl_Obj* const objv[])
{
void *ptr = Blt_GetOpFromObj(interp, numElemOps, elemOps, BLT_OP_ARG2,
objc, objv, 0);
@@ -584,7 +538,7 @@ int Blt_ElementOp(Graph* graphPtr, Tcl_Interp* interp,
return TCL_ERROR;
if (ptr == CreateOp)
- return CreateOp(graphPtr, interp, objc, objv, classId);
+ return CreateOp(graphPtr, interp, objc, objv);
else {
GraphElementProc* proc = (GraphElementProc*)ptr;
return (*proc)(graphPtr, interp, objc, objv);
@@ -599,7 +553,7 @@ static Tcl_Obj *DisplayListObj(Graph* graphPtr)
for (Blt_ChainLink link = Blt_Chain_FirstLink(graphPtr->elements_.displayList); link != NULL; link = Blt_Chain_NextLink(link)) {
Element* elemPtr = (Element*)Blt_Chain_GetValue(link);
- Tcl_Obj *objPtr = Tcl_NewStringObj(elemPtr->name(), -1);
+ Tcl_Obj *objPtr = Tcl_NewStringObj(elemPtr->name_, -1);
Tcl_ListObjAppendElement(graphPtr->interp_, listObjPtr, objPtr);
}
diff --git a/src/bltGrElemOp.h b/src/bltGrElemOp.h
index 58eb43f..62add9c 100644
--- a/src/bltGrElemOp.h
+++ b/src/bltGrElemOp.h
@@ -34,5 +34,6 @@ extern int ElementObjConfigure(Tcl_Interp* interp, Element* elemPtr,
int objc, Tcl_Obj* const objv[]);
extern int Blt_ElementOp(Graph* graphPtr, Tcl_Interp* interp, int objc,
Tcl_Obj* const objv[]);
+
extern void Blt_DestroyElement(Element* elemPtr);
#endif
diff --git a/src/bltGrElemOption.C b/src/bltGrElemOption.C
index 2f3c528..d4f0d7f 100644
--- a/src/bltGrElemOption.C
+++ b/src/bltGrElemOption.C
@@ -287,7 +287,7 @@ int StyleSetProc(ClientData clientData, Tcl_Interp* interp,
stylePtr->weight.min = (double)ii;
stylePtr->weight.max = (double)ii + 1.0;
stylePtr->weight.range = 1.0;
- if (GetPenStyleFromObj(interp, elemPtr->graphPtr(), objv[ii],
+ if (GetPenStyleFromObj(interp, elemPtr->graphPtr_, objv[ii],
elemPtr->classId(),
(PenStyle*)stylePtr) != TCL_OK) {
Blt_FreeStylePalette(stylePalette);
@@ -316,7 +316,7 @@ Tcl_Obj* StyleGetProc(ClientData clientData, Tk_Window tkwin,
for (Blt_ChainLink link = Blt_Chain_FirstLink(stylePalette); !link;
link = Blt_Chain_NextLink(link)) {
PenStyle *stylePtr = (PenStyle*)Blt_Chain_GetValue(link);
- ll[ii++] = Tcl_NewStringObj(stylePtr->penPtr->name(), -1);
+ ll[ii++] = Tcl_NewStringObj(stylePtr->penPtr->name_, -1);
ll[ii++] = Tcl_NewDoubleObj(stylePtr->weight.min);
ll[ii++] = Tcl_NewDoubleObj(stylePtr->weight.max);
}
@@ -426,7 +426,7 @@ static void VectorChangedProc(Tcl_Interp* interp, ClientData clientData,
}
Element* elemPtr = valuesPtr->elemPtr;
- Graph* graphPtr = elemPtr->graphPtr();
+ Graph* graphPtr = elemPtr->graphPtr_;
graphPtr->flags |= RESET_AXES;
elemPtr->flags |= MAP_ITEM;
if (elemPtr->link && !(elemPtr->flags & DELETE_PENDING)) {
diff --git a/src/bltGrHairs.h b/src/bltGrHairs.h
index 012060c..7b782c2 100644
--- a/src/bltGrHairs.h
+++ b/src/bltGrHairs.h
@@ -53,12 +53,13 @@ typedef struct {
class Crosshairs {
protected:
+ Tk_OptionTable optionTable_;
+ void* ops_;
+
GC gc_;
public:
Graph* graphPtr_;
- Tk_OptionTable optionTable_;
- void* ops_;
int visible_;
XSegment segArr_[2];
@@ -71,6 +72,9 @@ class Crosshairs {
void off();
void enable();
void disable();
+
+ Tk_OptionTable optionTable() {return optionTable_;}
+ void* ops() {return ops_;}
};
#endif
diff --git a/src/bltGrHairsOp.C b/src/bltGrHairsOp.C
index b769213..6327f83 100644
--- a/src/bltGrHairsOp.C
+++ b/src/bltGrHairsOp.C
@@ -48,7 +48,7 @@ static int CrosshairsObjConfigure(Tcl_Interp* interp, Graph* graphPtr,
for (error=0; error<=1; error++) {
if (!error) {
- if (Tk_SetOptions(interp, (char*)chPtr->ops_, chPtr->optionTable_,
+ if (Tk_SetOptions(interp, (char*)chPtr->ops(), chPtr->optionTable(),
objc, objv, graphPtr->tkwin_, &savedOptions, &mask)
!= TCL_OK)
continue;
@@ -86,8 +86,8 @@ static int CgetOp(Graph* graphPtr, Tcl_Interp* interp,
Crosshairs* chPtr = graphPtr->crosshairs_;
Tcl_Obj* objPtr = Tk_GetOptionValue(interp,
- (char*)chPtr->ops_,
- chPtr->optionTable_,
+ (char*)chPtr->ops(),
+ chPtr->optionTable(),
objv[3], graphPtr->tkwin_);
if (objPtr == NULL)
return TCL_ERROR;
@@ -101,8 +101,8 @@ static int ConfigureOp(Graph* graphPtr, Tcl_Interp* interp,
{
Crosshairs* chPtr = graphPtr->crosshairs_;
if (objc <= 4) {
- Tcl_Obj* objPtr = Tk_GetOptionInfo(interp, (char*)chPtr->ops_,
- chPtr->optionTable_,
+ Tcl_Obj* objPtr = Tk_GetOptionInfo(interp, (char*)chPtr->ops(),
+ chPtr->optionTable(),
(objc == 4) ? objv[3] : NULL,
graphPtr->tkwin_);
if (objPtr == NULL)
@@ -119,7 +119,7 @@ static int OnOp(Graph* graphPtr, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
Crosshairs *chPtr = graphPtr->crosshairs_;
- CrosshairsOptions* ops = (CrosshairsOptions*)chPtr->ops_;
+ CrosshairsOptions* ops = (CrosshairsOptions*)chPtr->ops();
if (ops->hide) {
chPtr->on();
@@ -132,7 +132,7 @@ static int OffOp(Graph* graphPtr, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
Crosshairs *chPtr = graphPtr->crosshairs_;
- CrosshairsOptions* ops = (CrosshairsOptions*)chPtr->ops_;
+ CrosshairsOptions* ops = (CrosshairsOptions*)chPtr->ops();
if (!ops->hide) {
chPtr->off();
@@ -145,7 +145,7 @@ static int ToggleOp(Graph* graphPtr, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
Crosshairs *chPtr = graphPtr->crosshairs_;
- CrosshairsOptions* ops = (CrosshairsOptions*)chPtr->ops_;
+ CrosshairsOptions* ops = (CrosshairsOptions*)chPtr->ops();
ops->hide = (ops->hide == 0);
if (ops->hide)
diff --git a/src/bltGrLegd.C b/src/bltGrLegd.C
index ef04361..e1c0e46 100644
--- a/src/bltGrLegd.C
+++ b/src/bltGrLegd.C
@@ -1009,7 +1009,7 @@ static int SelectionProc(ClientData clientData, int offset, char *buffer,
for (Blt_ChainLink link=Blt_Chain_FirstLink(legendPtr->selected_);
link; link = Blt_Chain_NextLink(link)) {
Element* elemPtr = (Element*)Blt_Chain_GetValue(link);
- Tcl_DStringAppend(&dString, elemPtr->name(), -1);
+ Tcl_DStringAppend(&dString, elemPtr->name_, -1);
Tcl_DStringAppend(&dString, "\n", -1);
}
}
@@ -1018,7 +1018,7 @@ static int SelectionProc(ClientData clientData, int offset, char *buffer,
link; link = Blt_Chain_NextLink(link)) {
Element* elemPtr = (Element*)Blt_Chain_GetValue(link);
if (legendPtr->entryIsSelected(elemPtr)) {
- Tcl_DStringAppend(&dString, elemPtr->name(), -1);
+ Tcl_DStringAppend(&dString, elemPtr->name_, -1);
Tcl_DStringAppend(&dString, "\n", -1);
}
}
diff --git a/src/bltGrLegdOp.C b/src/bltGrLegdOp.C
index 6676663..cd70ed6 100644
--- a/src/bltGrLegdOp.C
+++ b/src/bltGrLegdOp.C
@@ -143,9 +143,9 @@ static int ActivateOp(Graph* graphPtr, Tcl_Interp* interp,
for (link = Blt_Chain_FirstLink(graphPtr->elements_.displayList);
link != NULL; link = Blt_Chain_NextLink(link)) {
Element* elemPtr = (Element*)Blt_Chain_GetValue(link);
- if (Tcl_StringMatch(elemPtr->name(), pattern)) {
+ if (Tcl_StringMatch(elemPtr->name_, pattern)) {
fprintf(stderr, "legend %s(%s) %s is currently %d\n",
- string, pattern, elemPtr->name(),
+ string, pattern, elemPtr->name_,
(elemPtr->flags & LABEL_ACTIVE));
if (active) {
if ((elemPtr->flags & LABEL_ACTIVE) == 0) {
@@ -159,7 +159,7 @@ static int ActivateOp(Graph* graphPtr, Tcl_Interp* interp,
}
}
fprintf(stderr, "legend %s(%s) %s is now %d\n",
- string, pattern, elemPtr->name(),
+ string, pattern, elemPtr->name_,
(elemPtr->flags & LABEL_ACTIVE));
}
}
@@ -188,7 +188,7 @@ static int ActivateOp(Graph* graphPtr, Tcl_Interp* interp,
if (elemPtr->flags & LABEL_ACTIVE) {
Tcl_Obj *objPtr;
- objPtr = Tcl_NewStringObj(elemPtr->name(), -1);
+ objPtr = Tcl_NewStringObj(elemPtr->name_, -1);
Tcl_ListObjAppendElement(interp, listObjPtr, objPtr);
}
}
@@ -231,7 +231,7 @@ static int CurselectionOp(Graph* graphPtr, Tcl_Interp* interp,
for (link = Blt_Chain_FirstLink(legendPtr->selected_); link != NULL;
link = Blt_Chain_NextLink(link)) {
Element* elemPtr = (Element*)Blt_Chain_GetValue(link);
- Tcl_Obj *objPtr = Tcl_NewStringObj(elemPtr->name(), -1);
+ Tcl_Obj *objPtr = Tcl_NewStringObj(elemPtr->name_, -1);
Tcl_ListObjAppendElement(interp, listObjPtr, objPtr);
}
}
@@ -241,7 +241,7 @@ static int CurselectionOp(Graph* graphPtr, Tcl_Interp* interp,
Element* elemPtr = (Element*)Blt_Chain_GetValue(link);
if (legendPtr->entryIsSelected(elemPtr)) {
- Tcl_Obj *objPtr = Tcl_NewStringObj(elemPtr->name(), -1);
+ Tcl_Obj *objPtr = Tcl_NewStringObj(elemPtr->name_, -1);
Tcl_ListObjAppendElement(interp, listObjPtr, objPtr);
}
}
@@ -269,7 +269,7 @@ static int FocusOp(Graph* graphPtr, Tcl_Interp* interp,
graphPtr->legend_->eventuallyRedraw();
if (legendPtr->focusPtr_)
- Tcl_SetStringObj(Tcl_GetObjResult(interp),legendPtr->focusPtr_->name(),-1);
+ Tcl_SetStringObj(Tcl_GetObjResult(interp),legendPtr->focusPtr_->name_,-1);
return TCL_OK;
}
@@ -287,7 +287,7 @@ static int GetOp(Graph* graphPtr, Tcl_Interp* interp,
return TCL_ERROR;
if (elemPtr)
- Tcl_SetStringObj(Tcl_GetObjResult(interp), elemPtr->name(),-1);
+ Tcl_SetStringObj(Tcl_GetObjResult(interp), elemPtr->name_,-1);
}
return TCL_OK;
}
@@ -335,7 +335,7 @@ static int SelectionAnchorOp(Graph* graphPtr, Tcl_Interp* interp,
legendPtr->selAnchorPtr_ = elemPtr;
legendPtr->selMarkPtr_ = NULL;
if (elemPtr)
- Tcl_SetStringObj(Tcl_GetObjResult(interp), elemPtr->name(), -1);
+ Tcl_SetStringObj(Tcl_GetObjResult(interp), elemPtr->name_, -1);
graphPtr->legend_->eventuallyRedraw();
@@ -396,7 +396,7 @@ static int SelectionMarkOp(Graph* graphPtr, Tcl_Interp* interp,
legendPtr->flags &= ~SELECT_TOGGLE;
legendPtr->flags |= SELECT_SET;
legendPtr->selectRange(legendPtr->selAnchorPtr_, elemPtr);
- Tcl_SetStringObj(Tcl_GetObjResult(interp), elemPtr->name(), -1);
+ Tcl_SetStringObj(Tcl_GetObjResult(interp), elemPtr->name_, -1);
legendPtr->selMarkPtr_ = elemPtr;
graphPtr->legend_->eventuallyRedraw();
@@ -440,7 +440,7 @@ static int SelectionSetOp(Graph* graphPtr, Tcl_Interp* interp,
if (legendPtr->getElementFromObj(objv[4], &firstPtr) != TCL_OK)
return TCL_ERROR;
- if ((firstPtr->hide()) && ((legendPtr->flags & SELECT_CLEAR)==0)) {
+ if ((firstPtr->hide_) && ((legendPtr->flags & SELECT_CLEAR)==0)) {
Tcl_AppendResult(interp, "can't select hidden node \"",
Tcl_GetString(objv[4]), "\"", (char *)NULL);
return TCL_ERROR;
@@ -451,7 +451,7 @@ static int SelectionSetOp(Graph* graphPtr, Tcl_Interp* interp,
if (legendPtr->getElementFromObj(objv[5], &lastPtr) != TCL_OK)
return TCL_ERROR;
- if (lastPtr->hide() && ((legendPtr->flags & SELECT_CLEAR) == 0)) {
+ if (lastPtr->hide_ && ((legendPtr->flags & SELECT_CLEAR) == 0)) {
Tcl_AppendResult(interp, "can't select hidden node \"",
Tcl_GetString(objv[5]), "\"", (char *)NULL);
return TCL_ERROR;
diff --git a/src/bltGrMarker.h b/src/bltGrMarker.h
index 40a7c9f..6a01af2 100644
--- a/src/bltGrMarker.h
+++ b/src/bltGrMarker.h
@@ -60,14 +60,14 @@ namespace Blt {
class Marker {
protected:
- Graph* graphPtr_;
- const char *name_;
Tk_OptionTable optionTable_;
void* ops_;
- Tcl_HashEntry* hashPtr_;
- int clipped_;
public:
+ Graph* graphPtr_;
+ const char *name_;
+ Tcl_HashEntry* hashPtr_;
+ int clipped_;
Blt_ChainLink link;
unsigned int flags;
@@ -94,10 +94,8 @@ namespace Blt {
virtual const char* className() =0;
virtual const char* typeName() =0;
- const char* name() {return name_;}
Tk_OptionTable optionTable() {return optionTable_;}
void* ops() {return ops_;}
- int clipped() {return clipped_;}
};
};
diff --git a/src/bltGrMarkerOp.C b/src/bltGrMarkerOp.C
index 2f3d5d1..7528d69 100644
--- a/src/bltGrMarkerOp.C
+++ b/src/bltGrMarkerOp.C
@@ -313,7 +313,7 @@ static int FindOp(Graph* graphPtr, Tcl_Interp* interp,
if (markerPtr->regionIn(&extents, enclosed)) {
Tcl_Obj* objPtr = Tcl_GetObjResult(interp);
- Tcl_SetStringObj(objPtr, markerPtr->name(), -1);
+ Tcl_SetStringObj(objPtr, markerPtr->name_, -1);
return TCL_OK;
}
}
@@ -332,7 +332,7 @@ static int GetOp(Graph* graphPtr, Tcl_Interp* interp,
if (markerPtr == NULL)
return TCL_OK;
- Tcl_SetStringObj(Tcl_GetObjResult(interp), markerPtr->name(), -1);
+ Tcl_SetStringObj(Tcl_GetObjResult(interp), markerPtr->name_, -1);
}
return TCL_OK;
}
@@ -346,7 +346,7 @@ static int NamesOp(Graph* graphPtr, Tcl_Interp* interp,
link; link = Blt_Chain_NextLink(link)) {
Marker* markerPtr = (Marker*)Blt_Chain_GetValue(link);
Tcl_ListObjAppendElement(interp, listObjPtr,
- Tcl_NewStringObj(markerPtr->name(), -1));
+ Tcl_NewStringObj(markerPtr->name_, -1));
}
}
else {
@@ -355,9 +355,9 @@ static int NamesOp(Graph* graphPtr, Tcl_Interp* interp,
Marker* markerPtr = (Marker*)Blt_Chain_GetValue(link);
for (int ii = 3; ii<objc; ii++) {
const char* pattern = (const char*)Tcl_GetString(objv[ii]);
- if (Tcl_StringMatch(markerPtr->name(), pattern)) {
+ if (Tcl_StringMatch(markerPtr->name_, pattern)) {
Tcl_ListObjAppendElement(interp, listObjPtr,
- Tcl_NewStringObj(markerPtr->name(), -1));
+ Tcl_NewStringObj(markerPtr->name_, -1));
break;
}
}
diff --git a/src/bltGrPen.h b/src/bltGrPen.h
index c2648a1..538a563 100644
--- a/src/bltGrPen.h
+++ b/src/bltGrPen.h
@@ -51,14 +51,14 @@ typedef struct {
class Pen {
protected:
- Graph* graphPtr_;
- const char *name_;
Tk_OptionTable optionTable_;
void* ops_;
- int manageOptions_;
- Tcl_HashEntry *hashPtr_;
public:
+ Graph* graphPtr_;
+ const char *name_;
+ int manageOptions_;
+ Tcl_HashEntry *hashPtr_;
unsigned int flags;
int refCount;
@@ -71,7 +71,6 @@ class Pen {
virtual const char* className() =0;
virtual const char* typeName() =0;
- const char* name() {return name_;}
Tk_OptionTable optionTable() {return optionTable_;}
void* ops() {return ops_;}
diff --git a/src/bltGrPenOp.C b/src/bltGrPenOp.C
index 482996b..d65c9e5 100644
--- a/src/bltGrPenOp.C
+++ b/src/bltGrPenOp.C
@@ -163,7 +163,7 @@ static int NamesOp(Tcl_Interp* interp, Graph* graphPtr,
Pen* penPtr = (Pen*)Tcl_GetHashValue(hPtr);
if ((penPtr->flags & DELETE_PENDING) == 0)
Tcl_ListObjAppendElement(interp, listObjPtr,
- Tcl_NewStringObj(penPtr->name(), -1));
+ Tcl_NewStringObj(penPtr->name_, -1));
}
}
else {
@@ -174,9 +174,9 @@ static int NamesOp(Tcl_Interp* interp, Graph* graphPtr,
if ((penPtr->flags & DELETE_PENDING) == 0) {
for (int ii=3; ii<objc; ii++) {
char *pattern = Tcl_GetString(objv[ii]);
- if (Tcl_StringMatch(penPtr->name(), pattern)) {
+ if (Tcl_StringMatch(penPtr->name_, pattern)) {
Tcl_ListObjAppendElement(interp, listObjPtr,
- Tcl_NewStringObj(penPtr->name(), -1));
+ Tcl_NewStringObj(penPtr->name_, -1));
break;
}
}
diff --git a/src/bltGrPenOp.h b/src/bltGrPenOp.h
index c779c4f..7cf7377 100644
--- a/src/bltGrPenOp.h
+++ b/src/bltGrPenOp.h
@@ -32,7 +32,8 @@
extern int PenObjConfigure(Tcl_Interp* interp, Graph* graphPtr, Pen* penPtr,
int objc, Tcl_Obj* const objv[]);
-extern void Blt_FreePen(Pen* penPtr);
extern int Blt_PenOp(Graph* graphPtr, Tcl_Interp* interp, int objc,
Tcl_Obj* const objv[]);
+
+extern void Blt_FreePen(Pen* penPtr);
#endif
diff --git a/src/bltGrPenOption.C b/src/bltGrPenOption.C
index 13cd46a..bb13665 100644
--- a/src/bltGrPenOption.C
+++ b/src/bltGrPenOption.C
@@ -78,7 +78,7 @@ static Tcl_Obj* PenGetProc(ClientData clientData, Tk_Window tkwin,
if (!penPtr)
return Tcl_NewStringObj("", -1);
- return Tcl_NewStringObj(penPtr->name(), -1);
+ return Tcl_NewStringObj(penPtr->name_, -1);
};
static void PenFreeProc(ClientData clientData, Tk_Window tkwin, char *ptr)
diff --git a/src/bltGrXAxisOp.C b/src/bltGrXAxisOp.C
index b7001c7..f9fbd46 100644
--- a/src/bltGrXAxisOp.C
+++ b/src/bltGrXAxisOp.C
@@ -64,7 +64,7 @@ static int BindOp(Tcl_Interp* interp, Axis* axisPtr,
{
Graph* graphPtr = axisPtr->graphPtr_;
- return Blt_ConfigureBindingsFromObj(interp, graphPtr->bindTable_, graphPtr->axisTag(axisPtr->name()), objc-3, objv+3);
+ return Blt_ConfigureBindingsFromObj(interp, graphPtr->bindTable_, graphPtr->axisTag(axisPtr->name_), objc-3, objv+3);
}
static int UseOp(Tcl_Interp* interp, Axis* axisPtr,
@@ -82,7 +82,7 @@ static int UseOp(Tcl_Interp* interp, Axis* axisPtr,
link = Blt_Chain_NextLink(link)) {
Axis* axisPtr = (Axis*)Blt_Chain_GetValue(link);
Tcl_ListObjAppendElement(interp, listObjPtr,
- Tcl_NewStringObj(axisPtr->name(), -1));
+ Tcl_NewStringObj(axisPtr->name_, -1));
}
Tcl_SetObjResult(interp, listObjPtr);
return TCL_OK;
@@ -116,12 +116,12 @@ static int UseOp(Tcl_Interp* interp, Axis* axisPtr,
if (graphPtr->getAxis(axisObjv[i], &axisPtr) != TCL_OK)
return TCL_ERROR;
- if (axisPtr->classId() == CID_NONE)
+ if (axisPtr->classId_ == CID_NONE)
axisPtr->setClass(classId);
- else if (axisPtr->classId() != classId) {
+ else if (axisPtr->classId_ != classId) {
Tcl_AppendResult(interp, "wrong type axis \"",
- axisPtr->name(), "\": can't use ",
- axisPtr->className(), " type axis.", NULL);
+ axisPtr->name_, "\": can't use ",
+ axisPtr->className_, " type axis.", NULL);
return TCL_ERROR;
}
if (axisPtr->link) {
diff --git a/src/bltGraph.C b/src/bltGraph.C
index 4de7d4f..840884a 100644
--- a/src/bltGraph.C
+++ b/src/bltGraph.C
@@ -38,10 +38,12 @@ extern "C" {
#include "bltGrAxisOp.h"
#include "bltGrXAxisOp.h"
#include "bltGrPen.h"
-#include "bltGrPenOp.h"
#include "bltGrPenBar.h"
#include "bltGrPenLine.h"
+#include "bltGrPenOp.h"
#include "bltGrElem.h"
+#include "bltGrElemBar.h"
+#include "bltGrElemLine.h"
#include "bltGrElemOp.h"
#include "bltGrMarker.h"
#include "bltGrMarkerOp.h"
@@ -910,6 +912,51 @@ int Graph::getPen(Tcl_Obj* objPtr, Pen** penPtrPtr)
// Elements
+int Graph::createElement(int objc, Tcl_Obj* const objv[])
+{
+ char *name = Tcl_GetString(objv[3]);
+ if (name[0] == '-') {
+ Tcl_AppendResult(interp_, "name of element \"", name,
+ "\" can't start with a '-'", NULL);
+ return TCL_ERROR;
+ }
+
+ int isNew;
+ Tcl_HashEntry* hPtr =
+ Tcl_CreateHashEntry(&elements_.table, name, &isNew);
+ if (!isNew) {
+ Tcl_AppendResult(interp_, "element \"", name,
+ "\" already exists in \"", Tcl_GetString(objv[0]),
+ "\"", NULL);
+ return TCL_ERROR;
+ }
+
+ Element* elemPtr;
+ switch (classId_) {
+ case CID_ELEM_BAR:
+ elemPtr = new BarElement(this, name, hPtr);
+ break;
+ case CID_ELEM_LINE:
+ elemPtr = new LineElement(this, name, hPtr);
+ break;
+ default:
+ return TCL_ERROR;
+ }
+ if (!elemPtr)
+ return TCL_ERROR;
+
+ Tcl_SetHashValue(hPtr, elemPtr);
+
+ if ((Tk_InitOptions(interp_, (char*)elemPtr->ops(), elemPtr->optionTable(), tkwin_) != TCL_OK) || (ElementObjConfigure(interp_, elemPtr, objc-4, objv+4) != TCL_OK)) {
+ Blt_DestroyElement(elemPtr);
+ return TCL_ERROR;
+ }
+
+ elemPtr->link = Blt_Chain_Append(elements_.displayList, elemPtr);
+
+ return TCL_OK;
+}
+
void Graph::destroyElements()
{
Tcl_HashSearch iter;
@@ -1063,7 +1110,7 @@ void Graph::drawMarkers(Drawable drawable, int under)
Marker* markerPtr = (Marker*)Blt_Chain_GetValue(link);
MarkerOptions* mops = (MarkerOptions*)markerPtr->ops();
- if ((mops->drawUnder != under) || (markerPtr->clipped()) ||
+ if ((mops->drawUnder != under) || (markerPtr->clipped_) ||
(markerPtr->flags & DELETE_PENDING) || (mops->hide))
continue;
@@ -1089,7 +1136,7 @@ void Graph::printMarkers(Blt_Ps ps, int under)
if (isElementHidden(markerPtr))
continue;
- Blt_Ps_VarAppend(ps, "\n% Marker \"", markerPtr->name(),
+ Blt_Ps_VarAppend(ps, "\n% Marker \"", markerPtr->name_,
"\" is a ", markerPtr->className(), ".\n", (char*)NULL);
markerPtr->postscript(ps);
}
@@ -1133,7 +1180,7 @@ int Graph::isElementHidden(Marker* markerPtr)
Tcl_HashEntry *hPtr = Tcl_FindHashEntry(&elements_.table, mops->elemName);
if (hPtr) {
Element* elemPtr = (Element*)Tcl_GetHashValue(hPtr);
- if (!elemPtr->link || elemPtr->hide())
+ if (!elemPtr->link || elemPtr->hide_)
return 1;
}
}
@@ -1536,7 +1583,7 @@ void Blt_GraphTags(Blt_BindTable table, ClientData object, ClientData context,
case CID_ELEM_LINE:
{
Element* ptr = (Element*)object;
- Blt_List_Append(list,(const char*)graphPtr->elementTag(ptr->name()),0);
+ Blt_List_Append(list,(const char*)graphPtr->elementTag(ptr->name_),0);
Blt_List_Append(list,(const char*)graphPtr->elementTag(ptr->className()),0);
ElementOptions* ops = (ElementOptions*)ptr->ops();
for (const char** pp = ops->tags; *pp; pp++)
@@ -1547,8 +1594,8 @@ void Blt_GraphTags(Blt_BindTable table, ClientData object, ClientData context,
case CID_AXIS_Y:
{
Axis* ptr = (Axis*)object;
- Blt_List_Append(list,(const char*)graphPtr->axisTag(ptr->name()),0);
- Blt_List_Append(list,(const char*)graphPtr->axisTag(ptr->className()),0);
+ Blt_List_Append(list,(const char*)graphPtr->axisTag(ptr->name_),0);
+ Blt_List_Append(list,(const char*)graphPtr->axisTag(ptr->className_),0);
AxisOptions* ops = (AxisOptions*)ptr->ops();
for (const char** pp = ops->tags; *pp; pp++)
Blt_List_Append(list, (const char*)graphPtr->axisTag(*pp),0);
@@ -1561,7 +1608,7 @@ void Blt_GraphTags(Blt_BindTable table, ClientData object, ClientData context,
case CID_MARKER_WINDOW:
{
Marker* ptr = (Marker*)object;
- Blt_List_Append(list,(const char*)graphPtr->markerTag(ptr->name()),0);
+ Blt_List_Append(list,(const char*)graphPtr->markerTag(ptr->name_),0);
Blt_List_Append(list,(const char*)graphPtr->markerTag(ptr->className()),0);
MarkerOptions* ops = (MarkerOptions*)ptr->ops();
for (const char** pp = ops->tags; *pp; pp++)
@@ -1596,7 +1643,7 @@ static ClientData PickEntry(ClientData clientData, int x, int y,
(y >= exts.bottom) || (y < exts.top)) {
Axis* axisPtr = graphPtr->nearestAxis(x, y);
if (axisPtr) {
- *contextPtr = (ClientData)axisPtr->classId();
+ *contextPtr = (ClientData)axisPtr->classId_;
return axisPtr;
}
}
@@ -1622,7 +1669,7 @@ static ClientData PickEntry(ClientData clientData, int x, int y,
for (link = Blt_Chain_LastLink(graphPtr->elements_.displayList);
link != NULL; link = Blt_Chain_PrevLink(link)) {
elemPtr = (Element*)Blt_Chain_GetValue(link);
- if (elemPtr->hide() || (elemPtr->flags & MAP_ITEM))
+ if (elemPtr->hide_ || (elemPtr->flags & MAP_ITEM))
continue;
elemPtr->closest();
diff --git a/src/bltGraph.h b/src/bltGraph.h
index bbccc58..0edce6b 100644
--- a/src/bltGraph.h
+++ b/src/bltGraph.h
@@ -259,6 +259,7 @@ class Graph {
Blt::Marker* nearestMarker(int, int, int);
int isElementHidden(Blt::Marker*);
+ int createElement(int, Tcl_Obj* const []);
int getElement(Tcl_Obj*, Element**);
ClientData elementTag(const char*);
diff --git a/src/bltGraphOp.C b/src/bltGraphOp.C
index 54ad071..5fca07c 100644
--- a/src/bltGraphOp.C
+++ b/src/bltGraphOp.C
@@ -206,22 +206,10 @@ static int Y2AxisOp(Graph* graphPtr, Tcl_Interp* interp, int objc,
return Blt_XAxisOp(interp, graphPtr, margin, objc, objv);
}
-static int BarOp(Graph* graphPtr, Tcl_Interp* interp, int objc,
- Tcl_Obj* const objv[])
-{
- return Blt_ElementOp(graphPtr, interp, objc, objv, CID_ELEM_BAR);
-}
-
-static int LineOp(Graph* graphPtr, Tcl_Interp* interp, int objc,
- Tcl_Obj* const objv[])
-{
- return Blt_ElementOp(graphPtr, interp, objc, objv, CID_ELEM_LINE);
-}
-
static int ElementOp(Graph* graphPtr, Tcl_Interp* interp, int objc,
Tcl_Obj* const objv[])
{
- return Blt_ElementOp(graphPtr, interp, objc, objv, graphPtr->classId_);
+ return Blt_ElementOp(graphPtr, interp, objc, objv);
}
/*
@@ -399,7 +387,7 @@ static int TransformOp(Graph* graphPtr, Tcl_Interp* interp, int objc,
static Blt_OpSpec graphOps[] =
{
{"axis", 1, (void*)Blt_AxisOp, 2, 0, "oper ?args?",},
- {"bar", 2, (void*)BarOp, 2, 0, "oper ?args?",},
+ {"bar", 2, (void*)ElementOp, 2, 0, "oper ?args?",},
{"cget", 2, (void*)CgetOp, 3, 3, "option",},
{"configure", 2, (void*)ConfigureOp, 2, 0, "?option value?...",},
{"crosshairs", 2, (void*)Blt_CrosshairsOp, 2, 0, "oper ?args?",},
@@ -408,8 +396,8 @@ static Blt_OpSpec graphOps[] =
{"inside", 3, (void*)InsideOp, 4, 4, "winX winY",},
{"invtransform", 3, (void*)InvtransformOp, 4, 4, "winX winY",},
{"legend", 2, (void*)Blt_LegendOp, 2, 0, "oper ?args?",},
- {"line", 2, (void*)LineOp, 2, 0, "oper ?args?",},
- {"marker", 2, (void*)Blt::MarkerOp, 2, 0, "oper ?args?",},
+ {"line", 2, (void*)ElementOp, 2, 0, "oper ?args?",},
+ {"marker", 2, (void*)Blt::MarkerOp, 2, 0, "oper ?args?",},
{"pen", 2, (void*)Blt_PenOp, 2, 0, "oper ?args?",},
{"postscript", 2, (void*)Blt_PostScriptOp, 2, 0, "oper ?args?",},
{"transform", 1, (void*)TransformOp, 4, 4, "x y",},