summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjoye <joye>2014-04-02 21:05:40 (GMT)
committerjoye <joye>2014-04-02 21:05:40 (GMT)
commit8caa381d7de028759d2df259c629989adb568e30 (patch)
tree8b83e16eef3b7059883cd7bad63bcab2c284d4f6
parente58952262da1371d725aaf2c2996edeec8cdb8c5 (diff)
downloadblt-8caa381d7de028759d2df259c629989adb568e30.zip
blt-8caa381d7de028759d2df259c629989adb568e30.tar.gz
blt-8caa381d7de028759d2df259c629989adb568e30.tar.bz2
*** empty log message ***
-rw-r--r--src/bltChain.C14
-rw-r--r--src/bltGrAxis.C5
-rw-r--r--src/bltGrBind.C6
-rw-r--r--src/bltGrElem.C37
-rw-r--r--src/bltGrElem.h19
-rw-r--r--src/bltGrElemBar.C1101
-rw-r--r--src/bltGrElemBar.h34
-rw-r--r--src/bltGrElemLine.C1504
-rw-r--r--src/bltGrElemLine.h48
-rw-r--r--src/bltGrElemLineSpline.C18
-rw-r--r--src/bltGrElemOp.C13
-rw-r--r--src/bltGrElemOption.C9
-rw-r--r--src/bltGrHairs.C10
-rw-r--r--src/bltGrLegd.C138
-rw-r--r--src/bltGrMarker.C6
-rw-r--r--src/bltGrMarkerPolygon.C2
-rw-r--r--src/bltGrMisc.C12
-rw-r--r--src/bltGrPSOutput.C6
-rw-r--r--src/bltGrPen.h1
-rw-r--r--src/bltGrPenBar.C161
-rw-r--r--src/bltGrPenBar.h19
-rw-r--r--src/bltGrPenLine.C257
-rw-r--r--src/bltGrPenLine.h20
-rw-r--r--src/bltGrPenOp.C2
-rw-r--r--src/bltGraph.C11
-rw-r--r--src/bltInt.C2
-rw-r--r--src/bltNsUtil.C6
-rw-r--r--src/bltVecCmd.C10
-rw-r--r--src/bltVecMath.C4
-rw-r--r--src/bltVector.C6
30 files changed, 1732 insertions, 1749 deletions
diff --git a/src/bltChain.C b/src/bltChain.C
index 16e372d..d3f64c4 100644
--- a/src/bltChain.C
+++ b/src/bltChain.C
@@ -163,22 +163,22 @@ void Blt_Chain_UnlinkLink(Chain* chainPtr, ChainLink* linkPtr)
// Indicates if the link is actually remove from the chain
int unlinked;
- unlinked = FALSE;
+ unlinked = 0;
if (chainPtr->head == linkPtr) {
chainPtr->head = linkPtr->next;
- unlinked = TRUE;
+ unlinked = 1;
}
if (chainPtr->tail == linkPtr) {
chainPtr->tail = linkPtr->prev;
- unlinked = TRUE;
+ unlinked = 1;
}
if (linkPtr->next) {
linkPtr->next->prev = linkPtr->prev;
- unlinked = TRUE;
+ unlinked = 1;
}
if (linkPtr->prev) {
linkPtr->prev->next = linkPtr->next;
- unlinked = TRUE;
+ unlinked = 1;
}
if (unlinked) {
chainPtr->nLinks--;
@@ -250,8 +250,8 @@ int Blt_Chain_IsBefore(ChainLink* firstPtr, ChainLink* lastPtr)
{
for (ChainLink* linkPtr = firstPtr; linkPtr; linkPtr = linkPtr->next) {
if (linkPtr == lastPtr)
- return TRUE;
+ return 1;
}
- return FALSE;
+ return 0;
}
diff --git a/src/bltGrAxis.C b/src/bltGrAxis.C
index 578baf7..fa5f0d0 100644
--- a/src/bltGrAxis.C
+++ b/src/bltGrAxis.C
@@ -1776,9 +1776,10 @@ void Blt_ResetAxes(Graph* graphPtr)
Region2d exts;
Element* elemPtr = (Element*)Blt_Chain_GetValue(link);
+ ElementOptions* ops = (ElementOptions*)elemPtr->ops;
(*elemPtr->procsPtr->extentsProc) (elemPtr, &exts);
- GetDataLimits(elemPtr->axes.x, exts.left, exts.right);
- GetDataLimits(elemPtr->axes.y, exts.top, exts.bottom);
+ GetDataLimits(ops->axes.x, exts.left, exts.right);
+ GetDataLimits(ops->axes.y, exts.top, exts.bottom);
}
/*
* Step 3: Now that we know the range of data values for each axis,
diff --git a/src/bltGrBind.C b/src/bltGrBind.C
index d2fa15d..39932e5 100644
--- a/src/bltGrBind.C
+++ b/src/bltGrBind.C
@@ -189,7 +189,7 @@ static void PickCurrentItem(BindTable *bindPtr, XEvent *eventPtr)
bindPtr->pickEvent = *eventPtr;
}
}
- bindPtr->activePick = TRUE;
+ bindPtr->activePick = 1;
/*
* If this is a recursive call (there's already a partially completed call
@@ -427,10 +427,10 @@ int Blt_ConfigureBindingsFromObj(Tcl_Interp* interp, BindTable *bindPtr,
unsigned long mask;
if (command[0] == '+')
mask = Tk_CreateBinding(interp, bindPtr->bindingTable, item, seq,
- command + 1, TRUE);
+ command + 1, 1);
else
mask = Tk_CreateBinding(interp, bindPtr->bindingTable, item, seq,
- command, FALSE);
+ command, 0);
if (!mask)
return TCL_ERROR;
diff --git a/src/bltGrElem.C b/src/bltGrElem.C
index 4e314e8..8a1b972 100644
--- a/src/bltGrElem.C
+++ b/src/bltGrElem.C
@@ -33,42 +33,33 @@
PenStyle** Blt_StyleMap(Element* elemPtr)
{
- int i;
- int nWeights; /* Number of weights to be examined.
- * If there are more data points than
- * weights, they will default to the
- * normal pen. */
- Blt_ChainLink link;
- double *w; /* Weight vector */
- int nPoints;
+ ElementOptions* ops = (ElementOptions*)elemPtr->ops;
- nPoints = NUMBEROFPOINTS(elemPtr);
- nWeights = MIN(elemPtr->w ? elemPtr->w->nValues : 0, nPoints);
- w = elemPtr->w ? elemPtr->w->values : NULL;
- link = Blt_Chain_FirstLink(elemPtr->stylePalette);
+ int nPoints = NUMBEROFPOINTS(ops);
+ int nWeights = MIN(ops->w ? ops->w->nValues : 0, nPoints);
+ double* w = ops->w ? ops->w->values : NULL;
+ Blt_ChainLink link = Blt_Chain_FirstLink(ops->stylePalette);
PenStyle *stylePtr = (PenStyle*)Blt_Chain_GetValue(link);
- /*
- * Create a style mapping array (data point index to style),
- * initialized to the default style.
- */
+ // Create a style mapping array (data point index to style),
+ // initialized to the default style.
PenStyle **dataToStyle = (PenStyle**)malloc(nPoints * sizeof(PenStyle *));
- for (i = 0; i < nPoints; i++)
- dataToStyle[i] = stylePtr;
+ for (int ii=0; ii<nPoints; ii++)
+ dataToStyle[ii] = stylePtr;
- for (i = 0; i < nWeights; i++) {
- for (link = Blt_Chain_LastLink(elemPtr->stylePalette); link != NULL;
+ for (int ii=0; ii<nWeights; ii++) {
+ for (link = Blt_Chain_LastLink(ops->stylePalette); link != NULL;
link = Blt_Chain_PrevLink(link)) {
stylePtr = (PenStyle*)Blt_Chain_GetValue(link);
if (stylePtr->weight.range > 0.0) {
double norm;
- norm = (w[i] - stylePtr->weight.min) / stylePtr->weight.range;
+ norm = (w[ii] - stylePtr->weight.min) / stylePtr->weight.range;
if (((norm - 1.0) <= DBL_EPSILON) &&
(((1.0 - norm) - 1.0) <= DBL_EPSILON)) {
- dataToStyle[i] = stylePtr;
- break; /* Done: found range that matches. */
+ dataToStyle[ii] = stylePtr;
+ break;
}
}
}
diff --git a/src/bltGrElem.h b/src/bltGrElem.h
index 07ac242..637071e 100644
--- a/src/bltGrElem.h
+++ b/src/bltGrElem.h
@@ -121,6 +121,7 @@ typedef struct {
} ElementProcs;
typedef struct {
+ Element* elemPtr;
const char* label;
char** tags;
Axis2d axes;
@@ -135,7 +136,11 @@ typedef struct {
int hide;
int legendRelief;
Blt_Chain stylePalette;
-} ElemOptions;
+ Pen* builtinPenPtr;
+ Pen* activePenPtr;
+ Pen* normalPenPtr;
+ PenOptions builtinPen;
+} ElementOptions;
typedef struct _Element {
GraphObj obj;
@@ -144,26 +149,14 @@ typedef struct _Element {
Tcl_HashEntry *hashPtr;
void* ops;
- // Fields specific to elements
- const char *label;
unsigned short row;
unsigned short col;
- int legendRelief;
- Axis2d axes;
- ElemCoords coords;
- ElemValues* w;
int *activeIndices;
int nActiveIndices;
ElementProcs *procsPtr;
Tk_OptionTable optionTable;
- Pen *activePenPtr;
- Pen *normalPenPtr;
- Pen *builtinPenPtr;
- Blt_Chain stylePalette;
- int scaleSymbols;
double xRange;
double yRange;
- int state;
Blt_ChainLink link;
} Element;
diff --git a/src/bltGrElemBar.C b/src/bltGrElemBar.C
index 3b3a10a..dab0a49 100644
--- a/src/bltGrElemBar.C
+++ b/src/bltGrElemBar.C
@@ -100,107 +100,115 @@ extern Tk_ObjCustomOption yAxisObjOption;
static Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_CUSTOM, "-activepen", "activePen", "ActivePen",
- "activeBar", -1, Tk_Offset(BarElement, activePenPtr),
+ "activeBar", -1, Tk_Offset(BarElementOptions, activePenPtr),
TK_OPTION_NULL_OK, &barPenObjOption, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
- STD_NORMAL_FOREGROUND, -1, Tk_Offset(BarElement, builtinPen.fill),
+ STD_NORMAL_FOREGROUND, -1, Tk_Offset(BarElementOptions, builtinPen.fill),
TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_DOUBLE, "-barwidth", "barWidth", "BarWidth",
- 0, -1, Tk_Offset(BarElement, barWidth), 0, NULL, MAP_ITEM},
+ 0, -1, Tk_Offset(BarElementOptions, barWidth), 0, NULL, MAP_ITEM},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL, -1, 0, 0, "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, -1, 0, 0, "-background", 0},
{TK_OPTION_CUSTOM, "-bindtags", "bindTags", "BindTags",
- "all", -1, Tk_Offset(BarElement, obj.tags),
+ "all", -1, Tk_Offset(BarElementOptions, tags),
TK_OPTION_NULL_OK, &listObjOption, 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- STD_BORDERWIDTH, -1, Tk_Offset(BarElement, builtinPen.borderWidth),
+ STD_BORDERWIDTH, -1, Tk_Offset(BarElementOptions, builtinPen.borderWidth),
0, NULL, 0},
{TK_OPTION_SYNONYM, "-color", NULL, NULL, NULL, -1, 0, 0, "-background", 0},
{TK_OPTION_CUSTOM, "-data", "data", "Data",
- NULL, -1, Tk_Offset(BarElement, coords),
+ NULL, -1, Tk_Offset(BarElementOptions, coords),
TK_OPTION_NULL_OK, &pairsObjOption, MAP_ITEM},
{TK_OPTION_COLOR, "-errorbarcolor", "errorBarColor", "ErrorBarColor",
- NULL, -1, Tk_Offset(BarElement, builtinPen.errorBarColor),
+ NULL, -1, Tk_Offset(BarElementOptions, builtinPen.errorBarColor),
TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_PIXELS,"-errorbarwidth", "errorBarWidth", "ErrorBarWidth",
- "1", -1, Tk_Offset(BarElement, builtinPen.errorBarLineWidth), 0, NULL, 0},
+ "1", -1, Tk_Offset(BarElementOptions, builtinPen.errorBarLineWidth),
+ 0, NULL, 0},
{TK_OPTION_PIXELS, "-errorbarcap", "errorBarCap", "ErrorBarCap",
- "2", -1, Tk_Offset(BarElement, builtinPen.errorBarCapWidth), 0, NULL, 0},
+ "2", -1, Tk_Offset(BarElementOptions, builtinPen.errorBarCapWidth),
+ 0, NULL, 0},
{TK_OPTION_SYNONYM, "-fg", NULL, NULL, NULL, -1, 0, 0, "-foreground", 0},
{TK_OPTION_SYNONYM, "-fill", NULL, NULL, NULL, -1, 0, 0, "-background", 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- STD_NORMAL_FOREGROUND, -1, Tk_Offset(BarElement, builtinPen.outlineColor),
+ STD_NORMAL_FOREGROUND, -1,
+ Tk_Offset(BarElementOptions, builtinPen.outlineColor),
TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_BOOLEAN, "-hide", "hide", "Hide",
- "no", -1, Tk_Offset(BarElement, hide), 0, NULL, MAP_ITEM},
+ "no", -1, Tk_Offset(BarElementOptions, hide), 0, NULL, MAP_ITEM},
{TK_OPTION_STRING, "-label", "label", "Label",
- NULL, -1, Tk_Offset(BarElement, label), TK_OPTION_NULL_OK, NULL, MAP_ITEM},
+ NULL, -1, Tk_Offset(BarElementOptions, label),
+ TK_OPTION_NULL_OK, NULL, MAP_ITEM},
{TK_OPTION_RELIEF, "-legendrelief", "legendRelief", "LegendRelief",
- "flat", -1, Tk_Offset(BarElement, legendRelief), 0, NULL, 0},
+ "flat", -1, Tk_Offset(BarElementOptions, legendRelief), 0, NULL, 0},
{TK_OPTION_CUSTOM, "-mapx", "mapX", "MapX",
- "x", -1, Tk_Offset(BarElement, axes.x), 0, &xAxisObjOption, MAP_ITEM},
+ "x", -1, Tk_Offset(BarElementOptions, axes.x), 0, &xAxisObjOption, MAP_ITEM},
{TK_OPTION_CUSTOM, "-mapy", "mapY", "MapY",
- "y", -1, Tk_Offset(BarElement, axes.y), 0, &yAxisObjOption, MAP_ITEM},
+ "y", -1, Tk_Offset(BarElementOptions, axes.y), 0, &yAxisObjOption, MAP_ITEM},
{TK_OPTION_SYNONYM, "-outline", NULL, NULL, NULL, -1, 0, 0, "-foreground", 0},
{TK_OPTION_CUSTOM, "-pen", "pen", "Pen",
- NULL, -1, Tk_Offset(BarElement, normalPenPtr),
+ NULL, -1, Tk_Offset(BarElementOptions, normalPenPtr),
TK_OPTION_NULL_OK, &barPenObjOption},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- "raised", -1, Tk_Offset(BarElement, builtinPen.relief), 0, NULL, 0},
+ "raised", -1, Tk_Offset(BarElementOptions, builtinPen.relief), 0, NULL, 0},
{TK_OPTION_STRING_TABLE, "-showerrorbars", "showErrorBars", "ShowErrorBars",
- "both", -1, Tk_Offset(BarElement, builtinPen.errorBarShow),
+ "both", -1, Tk_Offset(BarElementOptions, builtinPen.errorBarShow),
0, &fillObjOption, 0},
{TK_OPTION_STRING_TABLE, "-showvalues", "showValues", "ShowValues",
- "none", -1, Tk_Offset(BarElement, builtinPen.valueShow),
+ "none", -1, Tk_Offset(BarElementOptions, builtinPen.valueShow),
0, &fillObjOption, 0},
{TK_OPTION_STRING, "-stack", "stack", "Stack",
- NULL, -1, Tk_Offset(BarElement, groupName), TK_OPTION_NULL_OK, NULL, 0},
+ NULL, -1, Tk_Offset(BarElementOptions, groupName),
+ TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_BITMAP, "-stipple", "stipple", "Stipple",
- NULL, -1, Tk_Offset(BarElement, builtinPen.stipple),
+ NULL, -1, Tk_Offset(BarElementOptions, builtinPen.stipple),
TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_CUSTOM, "-styles", "styles", "Styles",
- "", -1, Tk_Offset(BarElement, stylePalette), 0, &styleObjOption, 0},
+ "", -1, Tk_Offset(BarElementOptions, stylePalette), 0, &styleObjOption, 0},
{TK_OPTION_ANCHOR, "-valueanchor", "valueAnchor", "ValueAnchor",
- "s", -1, Tk_Offset(BarElement, builtinPen.valueStyle.anchor), 0, NULL, 0},
+ "s", -1, Tk_Offset(BarElementOptions, builtinPen.valueStyle.anchor),
+ 0, NULL, 0},
{TK_OPTION_COLOR, "-valuecolor", "valueColor", "ValueColor",
- STD_NORMAL_FOREGROUND, -1, Tk_Offset(BarElement,builtinPen.valueStyle.color),
+ STD_NORMAL_FOREGROUND, -1,
+ Tk_Offset(BarElementOptions,builtinPen.valueStyle.color),
0, NULL, 0},
{TK_OPTION_FONT, "-valuefont", "valueFont", "ValueFont",
- STD_FONT_SMALL, -1, Tk_Offset(BarElement, builtinPen.valueStyle.font),
+ STD_FONT_SMALL, -1, Tk_Offset(BarElementOptions, builtinPen.valueStyle.font),
0, NULL, 0},
{TK_OPTION_STRING, "-valueformat", "valueFormat", "ValueFormat",
- "%g", -1, Tk_Offset(BarElement, builtinPen.valueFormat),
+ "%g", -1, Tk_Offset(BarElementOptions, builtinPen.valueFormat),
TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_DOUBLE, "-valuerotate", "valueRotate", "ValueRotate",
- "0", -1, Tk_Offset(BarElement, builtinPen.valueStyle.angle), 0, NULL, 0},
+ "0", -1, Tk_Offset(BarElementOptions, builtinPen.valueStyle.angle),
+ 0, NULL, 0},
{TK_OPTION_CUSTOM, "-weights", "weights", "Weights",
- NULL, -1, Tk_Offset(BarElement, w),
+ NULL, -1, Tk_Offset(BarElementOptions, w),
TK_OPTION_NULL_OK, &valuesObjOption, MAP_ITEM},
{TK_OPTION_SYNONYM, "-x", NULL, NULL, NULL, -1, 0, 0, "-xdata", 0},
{TK_OPTION_CUSTOM, "-xdata", "xData", "XData",
- NULL, -1, Tk_Offset(BarElement, coords.x),
+ NULL, -1, Tk_Offset(BarElementOptions, coords.x),
TK_OPTION_NULL_OK, &valuesObjOption, MAP_ITEM},
{TK_OPTION_CUSTOM, "-xerror", "xError", "XError",
- NULL, -1, Tk_Offset(BarElement, xError),
+ NULL, -1, Tk_Offset(BarElementOptions, xError),
TK_OPTION_NULL_OK, &valuesObjOption, MAP_ITEM},
{TK_OPTION_CUSTOM, "-xhigh", "xHigh", "XHigh",
- NULL, -1, Tk_Offset(BarElement, xHigh),
+ NULL, -1, Tk_Offset(BarElementOptions, xHigh),
TK_OPTION_NULL_OK, &valuesObjOption, MAP_ITEM},
{TK_OPTION_CUSTOM, "-xlow", "xLow", "XLow",
- NULL, -1, Tk_Offset(BarElement, xLow),
+ NULL, -1, Tk_Offset(BarElementOptions, xLow),
TK_OPTION_NULL_OK, &valuesObjOption, MAP_ITEM},
{TK_OPTION_SYNONYM, "-y", NULL, NULL, NULL, -1, 0, 0, "-ydata", 0},
{TK_OPTION_CUSTOM, "-ydata", "yData", "YData",
- NULL, -1, Tk_Offset(BarElement, coords.y),
+ NULL, -1, Tk_Offset(BarElementOptions, coords.y),
TK_OPTION_NULL_OK, &valuesObjOption, MAP_ITEM},
{TK_OPTION_CUSTOM, "-yerror", "yError", "YError",
- NULL, -1, Tk_Offset(BarElement, yError),
+ NULL, -1, Tk_Offset(BarElementOptions, yError),
TK_OPTION_NULL_OK, &valuesObjOption, MAP_ITEM},
{TK_OPTION_CUSTOM, "-yhigh", "yHigh", "YHigh",
- NULL, -1, Tk_Offset(BarElement, yHigh),
+ NULL, -1, Tk_Offset(BarElementOptions, yHigh),
TK_OPTION_NULL_OK, &valuesObjOption, MAP_ITEM},
{TK_OPTION_CUSTOM, "-ylow", "yLow", "YLow",
- NULL, -1, Tk_Offset(BarElement, yLow),
+ NULL, -1, Tk_Offset(BarElementOptions, yLow),
TK_OPTION_NULL_OK, &valuesObjOption, MAP_ITEM},
{TK_OPTION_END, NULL, NULL, NULL, NULL, -1, 0, 0, NULL, 0}
};
@@ -209,65 +217,66 @@ static Tk_OptionSpec optionSpecs[] = {
Element* Blt_BarElement(Graph* graphPtr)
{
- BarElement* elemPtr = (BarElement*)calloc(1, sizeof(BarElement));
- elemPtr->ops = (BarElementOptions*)calloc(1, sizeof(BarElementOptions));
- elemPtr->procsPtr = &barProcs;
+ BarElement* bePtr = (BarElement*)calloc(1, sizeof(BarElement));
+ bePtr->ops = (BarElementOptions*)calloc(1, sizeof(BarElementOptions));
+ BarElementOptions* ops = (BarElementOptions*)bePtr->ops;
+ ops->elemPtr = (Element*)bePtr;
- elemPtr->builtinPenPtr = &elemPtr->builtinPen;
- elemPtr->builtinPen.ops =
- &(((BarElementOptions*)(elemPtr->ops))->builtinPenOps);
- elemPtr->builtinPen.manageOptions =0;
+ bePtr->procsPtr = &barProcs;
+ ops->builtinPenPtr = &bePtr->builtinPen;
+ bePtr->builtinPen.ops = &ops->builtinPen;
+ bePtr->builtinPen.manageOptions =0;
- InitBarPen(graphPtr, elemPtr->builtinPenPtr, "builtin");
- Tk_InitOptions(graphPtr->interp, (char*)elemPtr->builtinPenPtr,
- elemPtr->builtinPenPtr->optionTable, graphPtr->tkwin);
+ InitBarPen(graphPtr, &bePtr->builtinPen, "builtin");
+ Tk_InitOptions(graphPtr->interp, (char*)&(ops->builtinPen),
+ bePtr->builtinPen.optionTable, graphPtr->tkwin);
- elemPtr->optionTable = Tk_CreateOptionTable(graphPtr->interp, optionSpecs);
+ bePtr->optionTable = Tk_CreateOptionTable(graphPtr->interp, optionSpecs);
- return (Element*)elemPtr;
+ return (Element*)bePtr;
}
-static void DestroyBarProc(Graph* graphPtr, Element* basePtr)
+static void DestroyBarProc(Graph* graphPtr, Element* elemPtr)
{
- BarElement* elemPtr = (BarElement*)basePtr;
+ BarElement* bePtr = (BarElement*)elemPtr;
+ BarElementOptions* ops = (BarElementOptions*)bePtr->ops;
- DestroyBarPenProc(graphPtr, (Pen*)&elemPtr->builtinPen);
+ DestroyBarPenProc(graphPtr, (Pen*)&bePtr->builtinPen);
- if (elemPtr->activePenPtr)
- Blt_FreePen((Pen *)elemPtr->activePenPtr);
- if (elemPtr->normalPenPtr)
- Blt_FreePen((Pen *)elemPtr->normalPenPtr);
+ if (ops->activePenPtr)
+ Blt_FreePen((Pen*)ops->activePenPtr);
+ if (ops->normalPenPtr)
+ Blt_FreePen((Pen*)ops->normalPenPtr);
- ResetBar(elemPtr);
+ ResetBar(bePtr);
- if (elemPtr->stylePalette) {
- Blt_FreeStylePalette(elemPtr->stylePalette);
- Blt_Chain_Destroy(elemPtr->stylePalette);
+ if (ops->stylePalette) {
+ Blt_FreeStylePalette(ops->stylePalette);
+ Blt_Chain_Destroy(ops->stylePalette);
}
- if (elemPtr->activeIndices)
- free(elemPtr->activeIndices);
+ if (bePtr->activeIndices)
+ free(bePtr->activeIndices);
}
// Configure
-static int ConfigureBarProc(Graph* graphPtr, Element *basePtr)
+static int ConfigureBarProc(Graph* graphPtr, Element* elemPtr)
{
- BarElement* elemPtr = (BarElement *)basePtr;
- Blt_ChainLink link;
- BarStyle *stylePtr;
+ BarElement* bePtr = (BarElement*)elemPtr;
+ BarElementOptions* ops = (BarElementOptions*)bePtr->ops;
- if (ConfigureBarPenProc(graphPtr, (Pen*)&elemPtr->builtinPen)!= TCL_OK)
+ if (ConfigureBarPenProc(graphPtr, (Pen*)&bePtr->builtinPen)!= TCL_OK)
return TCL_ERROR;
// Point to the static normal pen if no external pens have been selected.
- link = Blt_Chain_FirstLink(elemPtr->stylePalette);
+ Blt_ChainLink link = Blt_Chain_FirstLink(ops->stylePalette);
if (!link) {
link = Blt_Chain_AllocLink(sizeof(BarStyle));
- Blt_Chain_LinkAfter(elemPtr->stylePalette, link, NULL);
+ Blt_Chain_LinkAfter(ops->stylePalette, link, NULL);
}
- stylePtr = (BarStyle*)Blt_Chain_GetValue(link);
- stylePtr->penPtr = NORMALPEN(elemPtr);
+ BarStyle* stylePtr = (BarStyle*)Blt_Chain_GetValue(link);
+ stylePtr->penPtr = NORMALPEN(ops);
return TCL_OK;
}
@@ -288,75 +297,67 @@ static void ResetStylePalette(Blt_Chain stylePalette)
static void CheckBarStacks(Graph* graphPtr, Axis2d *pairPtr,
double *minPtr, double *maxPtr)
{
- BarGroup *gp, *gend;
-
if ((graphPtr->barMode != BARS_STACKED) || (graphPtr->nBarGroups == 0))
return;
+ BarGroup *gp, *gend;
for (gp = graphPtr->barGroups, gend = gp + graphPtr->nBarGroups; gp < gend;
gp++) {
if ((gp->axes.x == pairPtr->x) && (gp->axes.y == pairPtr->y)) {
- /*
- * Check if any of the y-values (because of stacking) are greater
- * than the current limits of the graph.
- */
+
+ // Check if any of the y-values (because of stacking) are greater
+ // than the current limits of the graph.
if (gp->sum < 0.0f) {
- if (*minPtr > gp->sum) {
+ if (*minPtr > gp->sum)
*minPtr = gp->sum;
- }
- } else {
- if (*maxPtr < gp->sum) {
+ }
+ else {
+ if (*maxPtr < gp->sum)
*maxPtr = gp->sum;
- }
}
}
}
}
-static void GetBarExtentsProc(Element *basePtr, Region2d *regPtr)
+static void GetBarExtentsProc(Element* elemPtr, Region2d *regPtr)
{
- BarElement* elemPtr = (BarElement *)basePtr;
- Graph* graphPtr;
- double middle, barWidth;
- int nPoints;
+ BarElement* bePtr = (BarElement*)elemPtr;
+ BarElementOptions* ops = (BarElementOptions*)bePtr->ops;
- graphPtr = elemPtr->obj.graphPtr;
+ Graph* graphPtr = bePtr->obj.graphPtr;
regPtr->top = regPtr->left = DBL_MAX;
regPtr->bottom = regPtr->right = -DBL_MAX;
- if (!elemPtr->coords.x || !elemPtr->coords.y ||
- !elemPtr->coords.x->nValues || !elemPtr->coords.y->nValues)
+ if (!ops->coords.x || !ops->coords.y ||
+ !ops->coords.x->nValues || !ops->coords.y->nValues)
return;
- nPoints = NUMBEROFPOINTS(elemPtr);
- barWidth = graphPtr->barWidth;
- if (elemPtr->barWidth > 0.0f)
- barWidth = elemPtr->barWidth;
+ int nPoints = NUMBEROFPOINTS(ops);
+ double barWidth = graphPtr->barWidth;
+ if (ops->barWidth > 0.0f)
+ barWidth = ops->barWidth;
- middle = 0.5;
- regPtr->left = elemPtr->coords.x->min - middle;
- regPtr->right = elemPtr->coords.x->max + middle;
+ double middle = 0.5;
+ regPtr->left = ops->coords.x->min - middle;
+ regPtr->right = ops->coords.x->max + middle;
- regPtr->top = elemPtr->coords.y->min;
- regPtr->bottom = elemPtr->coords.y->max;
- if (regPtr->bottom < graphPtr->baseline) {
+ regPtr->top = ops->coords.y->min;
+ regPtr->bottom = ops->coords.y->max;
+ if (regPtr->bottom < graphPtr->baseline)
regPtr->bottom = graphPtr->baseline;
- }
// Handle stacked bar elements specially.
// If element is stacked, the sum of its ordinates may be outside the
// minimum/maximum limits of the element's data points.
if ((graphPtr->barMode == BARS_STACKED) && (graphPtr->nBarGroups > 0))
- CheckBarStacks(graphPtr, &elemPtr->axes, &regPtr->top, &regPtr->bottom);
+ CheckBarStacks(graphPtr, &ops->axes, &regPtr->top, &regPtr->bottom);
// Warning: You get what you deserve if the x-axis is logScale
- if (elemPtr->axes.x->logScale) {
- regPtr->left = Blt_FindElemValuesMinimum(elemPtr->coords.x, DBL_MIN) +
- middle;
- }
+ if (ops->axes.x->logScale)
+ regPtr->left = Blt_FindElemValuesMinimum(ops->coords.x, DBL_MIN) + middle;
// Fix y-min limits for barchart
- if (elemPtr->axes.y->logScale) {
+ if (ops->axes.y->logScale) {
if ((regPtr->top <= 0.0) || (regPtr->top > 1.0))
regPtr->top = 1.0;
}
@@ -366,15 +367,15 @@ static void GetBarExtentsProc(Element *basePtr, Region2d *regPtr)
}
// Correct the extents for error bars if they exist
- if (elemPtr->xError && (elemPtr->xError->nValues > 0)) {
- nPoints = MIN(elemPtr->xError->nValues, nPoints);
+ if (ops->xError && (ops->xError->nValues > 0)) {
+ nPoints = MIN(ops->xError->nValues, nPoints);
for (int ii=0; ii<nPoints; ii++) {
- double x = elemPtr->coords.x->values[ii] + elemPtr->xError->values[ii];
+ double x = ops->coords.x->values[ii] + ops->xError->values[ii];
if (x > regPtr->right)
regPtr->right = x;
- x = elemPtr->coords.x->values[ii] - elemPtr->xError->values[ii];
- if (elemPtr->axes.x->logScale) {
+ x = ops->coords.x->values[ii] - ops->xError->values[ii];
+ if (ops->axes.x->logScale) {
// Mirror negative values, instead of ignoring them
if (x < 0.0)
x = -x;
@@ -388,33 +389,33 @@ static void GetBarExtentsProc(Element *basePtr, Region2d *regPtr)
}
}
else {
- if ((elemPtr->xHigh) &&
- (elemPtr->xHigh->nValues > 0) &&
- (elemPtr->xHigh->max > regPtr->right))
- regPtr->right = elemPtr->xHigh->max;
+ if ((ops->xHigh) &&
+ (ops->xHigh->nValues > 0) &&
+ (ops->xHigh->max > regPtr->right))
+ regPtr->right = ops->xHigh->max;
- if (elemPtr->xLow && (elemPtr->xLow->nValues > 0)) {
+ if (ops->xLow && (ops->xLow->nValues > 0)) {
double left;
- if ((elemPtr->xLow->min <= 0.0) && (elemPtr->axes.x->logScale))
- left = Blt_FindElemValuesMinimum(elemPtr->xLow, DBL_MIN);
+ if ((ops->xLow->min <= 0.0) && (ops->axes.x->logScale))
+ left = Blt_FindElemValuesMinimum(ops->xLow, DBL_MIN);
else
- left = elemPtr->xLow->min;
+ left = ops->xLow->min;
if (left < regPtr->left)
regPtr->left = left;
}
}
- if (elemPtr->yError && (elemPtr->yError->nValues > 0)) {
- nPoints = MIN(elemPtr->yError->nValues, nPoints);
+ if (ops->yError && (ops->yError->nValues > 0)) {
+ nPoints = MIN(ops->yError->nValues, nPoints);
for (int ii=0; ii<nPoints; ii++) {
- double y = elemPtr->coords.y->values[ii] + elemPtr->yError->values[ii];
+ double y = ops->coords.y->values[ii] + ops->yError->values[ii];
if (y > regPtr->bottom)
regPtr->bottom = y;
- y = elemPtr->coords.y->values[ii] - elemPtr->yError->values[ii];
- if (elemPtr->axes.y->logScale) {
+ y = ops->coords.y->values[ii] - ops->yError->values[ii];
+ if (ops->axes.y->logScale) {
// Mirror negative values, instead of ignoring them
if (y < 0.0)
y = -y;
@@ -428,18 +429,18 @@ static void GetBarExtentsProc(Element *basePtr, Region2d *regPtr)
}
}
else {
- if ((elemPtr->yHigh) &&
- (elemPtr->yHigh->nValues > 0) &&
- (elemPtr->yHigh->max > regPtr->bottom))
- regPtr->bottom = elemPtr->yHigh->max;
+ if ((ops->yHigh) &&
+ (ops->yHigh->nValues > 0) &&
+ (ops->yHigh->max > regPtr->bottom))
+ regPtr->bottom = ops->yHigh->max;
- if (elemPtr->yLow && elemPtr->yLow->nValues > 0) {
+ if (ops->yLow && ops->yLow->nValues > 0) {
double top;
- if ((elemPtr->yLow->min <= 0.0) &&
- (elemPtr->axes.y->logScale))
- top = Blt_FindElemValuesMinimum(elemPtr->yLow, DBL_MIN);
+ if ((ops->yLow->min <= 0.0) &&
+ (ops->axes.y->logScale))
+ top = Blt_FindElemValuesMinimum(ops->yLow, DBL_MIN);
else
- top = elemPtr->yLow->min;
+ top = ops->yLow->min;
if (top < regPtr->top)
regPtr->top = top;
@@ -447,312 +448,308 @@ static void GetBarExtentsProc(Element *basePtr, Region2d *regPtr)
}
}
-static void ClosestBarProc(Graph* graphPtr, Element *basePtr)
+static void ClosestBarProc(Graph* graphPtr, Element* elemPtr)
{
- ClosestSearch* searchPtr = &graphPtr->search;
-
- BarElement* elemPtr = (BarElement *)basePtr;
- XRectangle *bp;
- double minDist;
- int imin;
- int i;
+ BarElement* bePtr = (BarElement*)elemPtr;
+ BarElementOptions* ops = (BarElementOptions*)bePtr->ops;
- minDist = searchPtr->dist;
- imin = 0;
+ ClosestSearch* searchPtr = &graphPtr->search;
+ double minDist = searchPtr->dist;
+ int imin = 0;
- for (bp = elemPtr->bars, i = 0; i < elemPtr->nBars; i++, bp++) {
- Point2d *pp, *pend;
- Point2d outline[5];
- double left, right, top, bottom;
-
+ int i;
+ XRectangle *bp;
+ for (bp = bePtr->bars, i = 0; i < bePtr->nBars; i++, bp++) {
if (PointInRectangle(bp, searchPtr->x, searchPtr->y)) {
- imin = elemPtr->barToData[i];
+ imin = bePtr->barToData[i];
minDist = 0.0;
break;
}
- left = bp->x, top = bp->y;
- right = (double)(bp->x + bp->width);
- bottom = (double)(bp->y + bp->height);
+ double left = bp->x;
+ double top = bp->y;
+ double right = (double)(bp->x + bp->width);
+ double bottom = (double)(bp->y + bp->height);
+
+ Point2d outline[5];
outline[4].x = outline[3].x = outline[0].x = left;
outline[4].y = outline[1].y = outline[0].y = top;
outline[2].x = outline[1].x = right;
outline[3].y = outline[2].y = bottom;
+ Point2d *pp, *pend;
for (pp = outline, pend = outline + 4; pp < pend; pp++) {
- Point2d t;
- double dist;
-
- t = Blt_GetProjection(searchPtr->x, searchPtr->y, pp, pp + 1);
- if (t.x > right) {
+ Point2d t = Blt_GetProjection(searchPtr->x, searchPtr->y, pp, pp + 1);
+ if (t.x > right)
t.x = right;
- } else if (t.x < left) {
+ else if (t.x < left)
t.x = left;
- }
- if (t.y > bottom) {
+
+ if (t.y > bottom)
t.y = bottom;
- } else if (t.y < top) {
+ else if (t.y < top)
t.y = top;
- }
- dist = hypot((t.x - searchPtr->x), (t.y - searchPtr->y));
+
+ double dist = hypot((t.x - searchPtr->x), (t.y - searchPtr->y));
if (dist < minDist) {
minDist = dist;
- imin = elemPtr->barToData[i];
+ imin = bePtr->barToData[i];
}
}
}
if (minDist < searchPtr->dist) {
- searchPtr->elemPtr = (Element *)elemPtr;
+ searchPtr->elemPtr = (Element*)bePtr;
searchPtr->dist = minDist;
searchPtr->index = imin;
searchPtr->point.x =
- elemPtr->coords.x ? (double)elemPtr->coords.x->values[imin] : 0;
+ ops->coords.x ? (double)ops->coords.x->values[imin] : 0;
searchPtr->point.y =
- elemPtr->coords.y ? (double)elemPtr->coords.y->values[imin] : 0;
+ ops->coords.y ? (double)ops->coords.y->values[imin] : 0;
}
}
-static void MergePens(BarElement* elemPtr, BarStyle **dataToStyle)
+static void MergePens(BarElement* bePtr, BarStyle **dataToStyle)
{
- if (Blt_Chain_GetLength(elemPtr->stylePalette) < 2) {
- Blt_ChainLink link = Blt_Chain_FirstLink(elemPtr->stylePalette);
+ BarElementOptions* ops = (BarElementOptions*)bePtr->ops;
+
+ if (Blt_Chain_GetLength(ops->stylePalette) < 2) {
+ Blt_ChainLink link = Blt_Chain_FirstLink(ops->stylePalette);
BarStyle *stylePtr = (BarStyle*)Blt_Chain_GetValue(link);
- stylePtr->nBars = elemPtr->nBars;
- stylePtr->bars = elemPtr->bars;
- stylePtr->symbolSize = elemPtr->bars->width / 2;
- stylePtr->xeb.length = elemPtr->xeb.length;
- stylePtr->xeb.segments = elemPtr->xeb.segments;
- stylePtr->yeb.length = elemPtr->yeb.length;
- stylePtr->yeb.segments = elemPtr->yeb.segments;
+ stylePtr->nBars = bePtr->nBars;
+ stylePtr->bars = bePtr->bars;
+ stylePtr->symbolSize = bePtr->bars->width / 2;
+ stylePtr->xeb.length = bePtr->xeb.length;
+ stylePtr->xeb.segments = bePtr->xeb.segments;
+ stylePtr->yeb.length = bePtr->yeb.length;
+ stylePtr->yeb.segments = bePtr->yeb.segments;
return;
}
// We have more than one style. Group bar segments of like pen styles
// together
- if (elemPtr->nBars > 0) {
+ if (bePtr->nBars > 0) {
Blt_ChainLink link;
XRectangle *bars, *bp;
int *ip, *barToData;
- bars = (XRectangle*)malloc(elemPtr->nBars * sizeof(XRectangle));
- barToData = (int*)malloc(elemPtr->nBars * sizeof(int));
+ bars = (XRectangle*)malloc(bePtr->nBars * sizeof(XRectangle));
+ barToData = (int*)malloc(bePtr->nBars * sizeof(int));
bp = bars, ip = barToData;
- for (link = Blt_Chain_FirstLink(elemPtr->stylePalette); link;
+ for (link = Blt_Chain_FirstLink(ops->stylePalette); link;
link = Blt_Chain_NextLink(link)) {
int i;
BarStyle *stylePtr = (BarStyle*)Blt_Chain_GetValue(link);
stylePtr->symbolSize = bp->width / 2;
stylePtr->bars = bp;
- for (i = 0; i < elemPtr->nBars; i++) {
+ for (i = 0; i < bePtr->nBars; i++) {
int iData;
- iData = elemPtr->barToData[i];
+ iData = bePtr->barToData[i];
if (dataToStyle[iData] == stylePtr) {
- *bp++ = elemPtr->bars[i];
+ *bp++ = bePtr->bars[i];
*ip++ = iData;
}
}
stylePtr->nBars = bp - stylePtr->bars;
}
- free(elemPtr->bars);
- free(elemPtr->barToData);
- elemPtr->bars = bars;
- elemPtr->barToData = barToData;
+ free(bePtr->bars);
+ free(bePtr->barToData);
+ bePtr->bars = bars;
+ bePtr->barToData = barToData;
}
- if (elemPtr->xeb.length > 0) {
+ if (bePtr->xeb.length > 0) {
Blt_ChainLink link;
Segment2d *sp;
int *ip;
Segment2d* bars =
- (Segment2d*)malloc(elemPtr->xeb.length * sizeof(Segment2d));
- int* map = (int*)malloc(elemPtr->xeb.length * sizeof(int));
+ (Segment2d*)malloc(bePtr->xeb.length * sizeof(Segment2d));
+ int* map = (int*)malloc(bePtr->xeb.length * sizeof(int));
sp = bars, ip = map;
- for (link = Blt_Chain_FirstLink(elemPtr->stylePalette);
+ for (link = Blt_Chain_FirstLink(ops->stylePalette);
link; link = Blt_Chain_NextLink(link)) {
int i;
BarStyle *stylePtr = (BarStyle*)Blt_Chain_GetValue(link);
stylePtr->xeb.segments = sp;
- for (i = 0; i < elemPtr->xeb.length; i++) {
+ for (i = 0; i < bePtr->xeb.length; i++) {
int iData;
- iData = elemPtr->xeb.map[i];
+ iData = bePtr->xeb.map[i];
if (dataToStyle[iData] == stylePtr) {
- *sp++ = elemPtr->xeb.segments[i];
+ *sp++ = bePtr->xeb.segments[i];
*ip++ = iData;
}
}
stylePtr->xeb.length = sp - stylePtr->xeb.segments;
}
- free(elemPtr->xeb.segments);
- elemPtr->xeb.segments = bars;
- free(elemPtr->xeb.map);
- elemPtr->xeb.map = map;
+ free(bePtr->xeb.segments);
+ bePtr->xeb.segments = bars;
+ free(bePtr->xeb.map);
+ bePtr->xeb.map = map;
}
- if (elemPtr->yeb.length > 0) {
+ if (bePtr->yeb.length > 0) {
Blt_ChainLink link;
Segment2d *sp;
int *ip;
Segment2d* bars =
- (Segment2d*)malloc(elemPtr->yeb.length * sizeof(Segment2d));
- int* map = (int*)malloc(elemPtr->yeb.length * sizeof(int));
+ (Segment2d*)malloc(bePtr->yeb.length * sizeof(Segment2d));
+ int* map = (int*)malloc(bePtr->yeb.length * sizeof(int));
sp = bars, ip = map;
- for (link = Blt_Chain_FirstLink(elemPtr->stylePalette); link;
+ for (link = Blt_Chain_FirstLink(ops->stylePalette); link;
link = Blt_Chain_NextLink(link)) {
int i;
BarStyle *stylePtr = (BarStyle*)Blt_Chain_GetValue(link);
stylePtr->yeb.segments = sp;
- for (i = 0; i < elemPtr->yeb.length; i++) {
+ for (i = 0; i < bePtr->yeb.length; i++) {
int iData;
- iData = elemPtr->yeb.map[i];
+ iData = bePtr->yeb.map[i];
if (dataToStyle[iData] == stylePtr) {
- *sp++ = elemPtr->yeb.segments[i];
+ *sp++ = bePtr->yeb.segments[i];
*ip++ = iData;
}
}
stylePtr->yeb.length = sp - stylePtr->yeb.segments;
}
- free(elemPtr->yeb.segments);
- elemPtr->yeb.segments = bars;
- free(elemPtr->yeb.map);
- elemPtr->yeb.map = map;
+ free(bePtr->yeb.segments);
+ bePtr->yeb.segments = bars;
+ free(bePtr->yeb.map);
+ bePtr->yeb.map = map;
}
}
-static void MapActiveBars(BarElement* elemPtr)
+static void MapActiveBars(BarElement* bePtr)
{
- if (elemPtr->activeRects) {
- free(elemPtr->activeRects);
- elemPtr->activeRects = NULL;
+ if (bePtr->activeRects) {
+ free(bePtr->activeRects);
+ bePtr->activeRects = NULL;
}
- if (elemPtr->activeToData) {
- free(elemPtr->activeToData);
- elemPtr->activeToData = NULL;
+ if (bePtr->activeToData) {
+ free(bePtr->activeToData);
+ bePtr->activeToData = NULL;
}
- elemPtr->nActive = 0;
+ bePtr->nActive = 0;
- if (elemPtr->nActiveIndices > 0) {
+ if (bePtr->nActiveIndices > 0) {
int i;
int count;
XRectangle *activeRects =
- (XRectangle*)malloc(sizeof(XRectangle) * elemPtr->nActiveIndices);
- int* activeToData = (int*)malloc(sizeof(int) * elemPtr->nActiveIndices);
+ (XRectangle*)malloc(sizeof(XRectangle) * bePtr->nActiveIndices);
+ int* activeToData = (int*)malloc(sizeof(int) * bePtr->nActiveIndices);
count = 0;
- for (i = 0; i < elemPtr->nBars; i++) {
+ for (i = 0; i < bePtr->nBars; i++) {
int *ip, *iend;
- for (ip = elemPtr->activeIndices,
- iend = ip + elemPtr->nActiveIndices; ip < iend; ip++) {
- if (elemPtr->barToData[i] == *ip) {
- activeRects[count] = elemPtr->bars[i];
+ for (ip = bePtr->activeIndices,
+ iend = ip + bePtr->nActiveIndices; ip < iend; ip++) {
+ if (bePtr->barToData[i] == *ip) {
+ activeRects[count] = bePtr->bars[i];
activeToData[count] = i;
count++;
}
}
}
- elemPtr->nActive = count;
- elemPtr->activeRects = activeRects;
- elemPtr->activeToData = activeToData;
+ bePtr->nActive = count;
+ bePtr->activeRects = activeRects;
+ bePtr->activeToData = activeToData;
}
- elemPtr->flags &= ~ACTIVE_PENDING;
+ bePtr->flags &= ~ACTIVE_PENDING;
}
-static void ResetBar(BarElement* elemPtr)
+static void ResetBar(BarElement* bePtr)
{
- ResetStylePalette(elemPtr->stylePalette);
+ BarElementOptions* ops = (BarElementOptions*)bePtr->ops;
- if (elemPtr->activeRects)
- free(elemPtr->activeRects);
+ ResetStylePalette(ops->stylePalette);
- if (elemPtr->activeToData)
- free(elemPtr->activeToData);
+ if (bePtr->activeRects)
+ free(bePtr->activeRects);
- if (elemPtr->xeb.segments)
- free(elemPtr->xeb.segments);
+ if (bePtr->activeToData)
+ free(bePtr->activeToData);
- if (elemPtr->xeb.map)
- free(elemPtr->xeb.map);
+ if (bePtr->xeb.segments)
+ free(bePtr->xeb.segments);
- if (elemPtr->yeb.segments)
- free(elemPtr->yeb.segments);
+ if (bePtr->xeb.map)
+ free(bePtr->xeb.map);
- if (elemPtr->yeb.map)
- free(elemPtr->yeb.map);
+ if (bePtr->yeb.segments)
+ free(bePtr->yeb.segments);
- if (elemPtr->bars)
- free(elemPtr->bars);
+ if (bePtr->yeb.map)
+ free(bePtr->yeb.map);
- if (elemPtr->barToData)
- free(elemPtr->barToData);
+ if (bePtr->bars)
+ free(bePtr->bars);
- elemPtr->activeToData = elemPtr->xeb.map = elemPtr->yeb.map =
- elemPtr->barToData = NULL;
- elemPtr->activeRects = elemPtr->bars = NULL;
- elemPtr->xeb.segments = elemPtr->yeb.segments = NULL;
- elemPtr->nActive = elemPtr->xeb.length = elemPtr->yeb.length =
- elemPtr->nBars = 0;
+ if (bePtr->barToData)
+ free(bePtr->barToData);
+
+ bePtr->activeToData = bePtr->xeb.map = bePtr->yeb.map =
+ bePtr->barToData = NULL;
+ bePtr->activeRects = NULL;
+ bePtr->bars = NULL;
+ bePtr->xeb.segments = NULL;
+ bePtr->yeb.segments = NULL;
+ bePtr->nActive = 0;
+ bePtr->xeb.length = 0;
+ bePtr->yeb.length = 0;
+ bePtr->nBars = 0;
}
-static void MapErrorBars(Graph* graphPtr, BarElement* elemPtr,
+static void MapErrorBars(Graph* graphPtr, BarElement* bePtr,
BarStyle **dataToStyle)
{
- int n, nPoints;
- Region2d reg;
+ BarElementOptions* ops = (BarElementOptions*)bePtr->ops;
+ Region2d reg;
Blt_GraphExtents(graphPtr, &reg);
- nPoints = NUMBEROFPOINTS(elemPtr);
- n =0;
- if (elemPtr->coords.x && elemPtr->coords.y) {
- if (elemPtr->xError && (elemPtr->xError->nValues > 0))
- n = MIN(elemPtr->xError->nValues, nPoints);
+ int nPoints = NUMBEROFPOINTS(ops);
+ int n =0;
+ if (ops->coords.x && ops->coords.y) {
+ if (ops->xError && (ops->xError->nValues > 0))
+ n = MIN(ops->xError->nValues, nPoints);
else
- if (elemPtr->xHigh && elemPtr->xLow)
- n = MIN3(elemPtr->xHigh->nValues, elemPtr->xLow->nValues, nPoints);
+ if (ops->xHigh && ops->xLow)
+ n = MIN3(ops->xHigh->nValues, ops->xLow->nValues, nPoints);
}
if (n > 0) {
- Segment2d *bars;
- Segment2d *segPtr;
- int *map;
- int *indexPtr;
- int i;
-
- segPtr = bars = (Segment2d*)malloc(n * 3 * sizeof(Segment2d));
- indexPtr = map = (int*)malloc(n * 3 * sizeof(int));
- for (i = 0; i < n; i++) {
- double x, y;
- double high, low;
- BarStyle *stylePtr;
+ Segment2d*bars = (Segment2d*)malloc(n * 3 * sizeof(Segment2d));
+ Segment2d* segPtr = bars;
+ int* map = (int*)malloc(n * 3 * sizeof(int));
+ int* indexPtr = map;
+
+ for (int ii=0; ii<n; ii++) {
+ double x = ops->coords.x->values[ii];
+ double y = ops->coords.y->values[ii];
+ BarStyle* stylePtr = dataToStyle[ii];
- x = elemPtr->coords.x->values[i];
- y = elemPtr->coords.y->values[i];
- stylePtr = dataToStyle[i];
+ double high, low;
if ((isfinite(x)) && (isfinite(y))) {
- if (elemPtr->xError->nValues > 0) {
- high = x + elemPtr->xError->values[i];
- low = x - elemPtr->xError->values[i];
+ if (ops->xError->nValues > 0) {
+ high = x + ops->xError->values[ii];
+ low = x - ops->xError->values[ii];
}
else {
- high = elemPtr->xHigh ? elemPtr->xHigh->values[i] : 0;
- low = elemPtr->xLow ? elemPtr->xLow->values[i] : 0;
+ high = ops->xHigh ? ops->xHigh->values[ii] : 0;
+ low = ops->xLow ? ops->xLow->values[ii] : 0;
}
if ((isfinite(high)) && (isfinite(low))) {
- Point2d p, q;
-
- p = Blt_Map2D(graphPtr, high, y, &elemPtr->axes);
- q = Blt_Map2D(graphPtr, low, y, &elemPtr->axes);
+ Point2d p = Blt_Map2D(graphPtr, high, y, &ops->axes);
+ Point2d q = Blt_Map2D(graphPtr, low, y, &ops->axes);
segPtr->p = p;
segPtr->q = q;
if (Blt_LineRectClip(&reg, &segPtr->p, &segPtr->q)) {
segPtr++;
- *indexPtr++ = i;
+ *indexPtr++ = ii;
}
/* Left cap */
segPtr->p.x = segPtr->q.x = p.x;
@@ -760,7 +757,7 @@ static void MapErrorBars(Graph* graphPtr, BarElement* elemPtr,
segPtr->q.y = p.y + stylePtr->errorBarCapWidth;
if (Blt_LineRectClip(&reg, &segPtr->p, &segPtr->q)) {
segPtr++;
- *indexPtr++ = i;
+ *indexPtr++ = ii;
}
/* Right cap */
segPtr->p.x = segPtr->q.x = q.x;
@@ -768,60 +765,53 @@ static void MapErrorBars(Graph* graphPtr, BarElement* elemPtr,
segPtr->q.y = q.y + stylePtr->errorBarCapWidth;
if (Blt_LineRectClip(&reg, &segPtr->p, &segPtr->q)) {
segPtr++;
- *indexPtr++ = i;
+ *indexPtr++ = ii;
}
}
}
}
- elemPtr->xeb.segments = bars;
- elemPtr->xeb.length = segPtr - bars;
- elemPtr->xeb.map = map;
+ bePtr->xeb.segments = bars;
+ bePtr->xeb.length = segPtr - bars;
+ bePtr->xeb.map = map;
}
n =0;
- if (elemPtr->coords.x && elemPtr->coords.y) {
- if (elemPtr->yError && (elemPtr->yError->nValues > 0))
- n = MIN(elemPtr->yError->nValues, nPoints);
+ if (ops->coords.x && ops->coords.y) {
+ if (ops->yError && (ops->yError->nValues > 0))
+ n = MIN(ops->yError->nValues, nPoints);
else
- if (elemPtr->yHigh && elemPtr->yLow)
- n = MIN3(elemPtr->yHigh->nValues, elemPtr->yLow->nValues, nPoints);
+ if (ops->yHigh && ops->yLow)
+ n = MIN3(ops->yHigh->nValues, ops->yLow->nValues, nPoints);
}
if (n > 0) {
- Segment2d *bars;
- Segment2d *segPtr;
- int *map;
- int *indexPtr;
- int i;
-
- segPtr = bars = (Segment2d*)malloc(n * 3 * sizeof(Segment2d));
- indexPtr = map = (int*)malloc(n * 3 * sizeof(int));
- for (i = 0; i < n; i++) {
- double x, y;
- double high, low;
- BarStyle *stylePtr;
+ Segment2d* bars = (Segment2d*)malloc(n * 3 * sizeof(Segment2d));
+ Segment2d* segPtr = bars;
+ int* map = (int*)malloc(n * 3 * sizeof(int));
+ int* indexPtr = map;
+
+ for (int ii=0; ii<n; ii++) {
+ double x = ops->coords.x->values[ii];
+ double y = ops->coords.y->values[ii];
+ BarStyle *stylePtr = dataToStyle[ii];
- x = elemPtr->coords.x->values[i];
- y = elemPtr->coords.y->values[i];
- stylePtr = dataToStyle[i];
+ double high, low;
if ((isfinite(x)) && (isfinite(y))) {
- if (elemPtr->yError->nValues > 0) {
- high = y + elemPtr->yError->values[i];
- low = y - elemPtr->yError->values[i];
+ if (ops->yError->nValues > 0) {
+ high = y + ops->yError->values[ii];
+ low = y - ops->yError->values[ii];
} else {
- high = elemPtr->yHigh->values[i];
- low = elemPtr->yLow->values[i];
+ high = ops->yHigh->values[ii];
+ low = ops->yLow->values[ii];
}
if ((isfinite(high)) && (isfinite(low))) {
- Point2d p, q;
-
- p = Blt_Map2D(graphPtr, x, high, &elemPtr->axes);
- q = Blt_Map2D(graphPtr, x, low, &elemPtr->axes);
+ Point2d p = Blt_Map2D(graphPtr, x, high, &ops->axes);
+ Point2d q = Blt_Map2D(graphPtr, x, low, &ops->axes);
segPtr->p = p;
segPtr->q = q;
if (Blt_LineRectClip(&reg, &segPtr->p, &segPtr->q)) {
segPtr++;
- *indexPtr++ = i;
+ *indexPtr++ = ii;
}
/* Top cap. */
segPtr->p.y = segPtr->q.y = p.y;
@@ -829,7 +819,7 @@ static void MapErrorBars(Graph* graphPtr, BarElement* elemPtr,
segPtr->q.x = p.x + stylePtr->errorBarCapWidth;
if (Blt_LineRectClip(&reg, &segPtr->p, &segPtr->q)) {
segPtr++;
- *indexPtr++ = i;
+ *indexPtr++ = ii;
}
/* Bottom cap. */
segPtr->p.y = segPtr->q.y = q.y;
@@ -837,49 +827,45 @@ static void MapErrorBars(Graph* graphPtr, BarElement* elemPtr,
segPtr->q.x = q.x + stylePtr->errorBarCapWidth;
if (Blt_LineRectClip(&reg, &segPtr->p, &segPtr->q)) {
segPtr++;
- *indexPtr++ = i;
+ *indexPtr++ = ii;
}
}
}
}
- elemPtr->yeb.segments = bars;
- elemPtr->yeb.length = segPtr - bars;
- elemPtr->yeb.map = map;
+ bePtr->yeb.segments = bars;
+ bePtr->yeb.length = segPtr - bars;
+ bePtr->yeb.map = map;
}
}
-static void MapBarProc(Graph* graphPtr, Element *basePtr)
+static void MapBarProc(Graph* graphPtr, Element* elemPtr)
{
- BarElement* elemPtr = (BarElement *)basePtr;
- BarStyle **dataToStyle;
- double *x, *y;
- double barWidth, barOffset;
- double baseline, ybot;
- int *barToData; /* Maps bars to data point indices */
- int invertBar;
- int nPoints, count;
- XRectangle *rp, *bars;
- int i;
- int size;
+ BarElement* bePtr = (BarElement*)elemPtr;
+ BarElementOptions* ops = (BarElementOptions*)bePtr->ops;
- ResetBar(elemPtr);
- if (!elemPtr->coords.x || !elemPtr->coords.y ||
- !elemPtr->coords.x->nValues || !elemPtr->coords.y->nValues)
+ ResetBar(bePtr);
+ if (!ops->coords.x || !ops->coords.y ||
+ !ops->coords.x->nValues || !ops->coords.y->nValues)
return;
- nPoints = NUMBEROFPOINTS(elemPtr);
+ int nPoints = NUMBEROFPOINTS(ops);
- barWidth = graphPtr->barWidth;
- barWidth = (elemPtr->barWidth > 0.0f) ? elemPtr->barWidth:graphPtr->barWidth;
- baseline = (elemPtr->axes.y->logScale) ? 0.0 : graphPtr->baseline;
- barOffset = barWidth * 0.5;
+ // double barWidth = graphPtr->barWidth;
+ double barWidth = (ops->barWidth > 0.0f) ?
+ ops->barWidth : graphPtr->barWidth;
+ double baseline = (ops->axes.y->logScale) ? 0.0 : graphPtr->baseline;
+ double barOffset = barWidth * 0.5;
// Create an array of bars representing the screen coordinates of all the
// segments in the bar.
- bars = (XRectangle*)calloc(nPoints, sizeof(XRectangle));
- barToData = (int*)calloc(nPoints, sizeof(int));
+ XRectangle* bars = (XRectangle*)calloc(nPoints, sizeof(XRectangle));
+ int* barToData = (int*)calloc(nPoints, sizeof(int));
+
+ double* x = ops->coords.x->values;
+ double* y = ops->coords.y->values;
+ int count = 0;
- x = elemPtr->coords.x->values, y = elemPtr->coords.y->values;
- count = 0;
+ int i;
+ XRectangle *rp;
for (rp = bars, i = 0; i < nPoints; i++) {
Point2d c1, c2; /* Two opposite corners of the rectangle
* in graph coordinates. */
@@ -887,8 +873,8 @@ static void MapBarProc(Graph* graphPtr, Element *basePtr)
int height;
double right, left, top, bottom;
- if (((x[i] - barWidth) > elemPtr->axes.x->axisRange.max) ||
- ((x[i] + barWidth) < elemPtr->axes.x->axisRange.min)) {
+ if (((x[i] - barWidth) > ops->axes.x->axisRange.max) ||
+ ((x[i] + barWidth) < ops->axes.x->axisRange.min)) {
continue; /* Abscissa is out of range of the
* x-axis */
}
@@ -908,14 +894,14 @@ static void MapBarProc(Graph* graphPtr, Element *basePtr)
BarSetKey key;
key.value = (float)x[i];
- key.axes = elemPtr->axes;
+ key.axes = ops->axes;
key.axes.y = NULL;
hPtr = Tcl_FindHashEntry(&graphPtr->setTable, (char *)&key);
if (hPtr) {
Tcl_HashTable *tablePtr = (Tcl_HashTable*)Tcl_GetHashValue(hPtr);
- const char *name = (elemPtr->groupName) ? elemPtr->groupName :
- elemPtr->axes.y->obj.name;
+ const char *name = (ops->groupName) ?
+ ops->groupName : ops->axes.y->obj.name;
hPtr = Tcl_FindHashEntry(tablePtr, name);
if (hPtr) {
double slice, width, offset;
@@ -959,21 +945,21 @@ static void MapBarProc(Graph* graphPtr, Element *basePtr)
}
}
}
- invertBar = FALSE;
+ int invertBar = 0;
if (c1.y < c2.y) {
double temp;
/* Handle negative bar values by swapping ordinates */
temp = c1.y, c1.y = c2.y, c2.y = temp;
- invertBar = TRUE;
+ invertBar = 1;
}
/*
* Get the two corners of the bar segment and compute the rectangle
*/
- ybot = c2.y;
- c1 = Blt_Map2D(graphPtr, c1.x, c1.y, &elemPtr->axes);
- c2 = Blt_Map2D(graphPtr, c2.x, c2.y, &elemPtr->axes);
- if ((ybot == 0.0) && (elemPtr->axes.y->logScale)) {
+ double ybot = c2.y;
+ c1 = Blt_Map2D(graphPtr, c1.x, c1.y, &ops->axes);
+ c2 = Blt_Map2D(graphPtr, c2.x, c2.y, &ops->axes);
+ if ((ybot == 0.0) && (ops->axes.y->logScale)) {
c2.y = graphPtr->bottom;
}
@@ -992,8 +978,8 @@ static void MapBarProc(Graph* graphPtr, Element *basePtr)
/* Bound the bars horizontally by the width of the graph window */
/* Bound the bars vertically by the position of the axis. */
if (graphPtr->stackAxes) {
- top = elemPtr->axes.y->screenMin;
- bottom = elemPtr->axes.y->screenMin + elemPtr->axes.y->screenRange;
+ top = ops->axes.y->screenMin;
+ bottom = ops->axes.y->screenMin + ops->axes.y->screenRange;
left = graphPtr->left;
right = graphPtr->right;
} else {
@@ -1039,55 +1025,57 @@ static void MapBarProc(Graph* graphPtr, Element *basePtr)
count++;
rp++;
}
- elemPtr->nBars = count;
- elemPtr->bars = bars;
- elemPtr->barToData = barToData;
- if (elemPtr->nActiveIndices > 0) {
- MapActiveBars(elemPtr);
+ bePtr->nBars = count;
+ bePtr->bars = bars;
+ bePtr->barToData = barToData;
+ if (bePtr->nActiveIndices > 0) {
+ MapActiveBars(bePtr);
}
- size = 20;
- if (count > 0) {
+ int size = 20;
+ if (count > 0)
size = bars->width;
- }
// Set the symbol size of all the pen styles
- for (Blt_ChainLink link = Blt_Chain_FirstLink(elemPtr->stylePalette); link;
+ for (Blt_ChainLink link = Blt_Chain_FirstLink(ops->stylePalette); link;
link = Blt_Chain_NextLink(link)) {
BarStyle *stylePtr = (BarStyle*)Blt_Chain_GetValue(link);
+ BarPen* penPtr = stylePtr->penPtr;
+ BarPenOptions* penOps = (BarPenOptions*)penPtr->ops;
stylePtr->symbolSize = size;
stylePtr->errorBarCapWidth =
- (stylePtr->penPtr->errorBarCapWidth > 0)
- ? stylePtr->penPtr->errorBarCapWidth : (size * 66666) / 100000;
+ (penOps->errorBarCapWidth > 0)
+ ? penOps->errorBarCapWidth : (size * 66666) / 100000;
stylePtr->errorBarCapWidth /= 2;
}
- dataToStyle = (BarStyle**)Blt_StyleMap((Element *)elemPtr);
- if (((elemPtr->yHigh && elemPtr->yHigh->nValues > 0) &&
- (elemPtr->yLow && elemPtr->yLow->nValues > 0)) ||
- ((elemPtr->xHigh && elemPtr->xHigh->nValues > 0) &&
- (elemPtr->xLow && elemPtr->xLow->nValues > 0)) ||
- (elemPtr->xError && elemPtr->xError->nValues > 0) ||
- (elemPtr->yError && elemPtr->yError->nValues > 0)) {
- MapErrorBars(graphPtr, elemPtr, dataToStyle);
+ BarStyle** dataToStyle = (BarStyle**)Blt_StyleMap((Element*)bePtr);
+ if (((ops->yHigh && ops->yHigh->nValues > 0) &&
+ (ops->yLow && ops->yLow->nValues > 0)) ||
+ ((ops->xHigh && ops->xHigh->nValues > 0) &&
+ (ops->xLow && ops->xLow->nValues > 0)) ||
+ (ops->xError && ops->xError->nValues > 0) ||
+ (ops->yError && ops->yError->nValues > 0)) {
+ MapErrorBars(graphPtr, bePtr, dataToStyle);
}
- MergePens(elemPtr, dataToStyle);
+ MergePens(bePtr, dataToStyle);
free(dataToStyle);
}
static void DrawSymbolProc(Graph* graphPtr, Drawable drawable,
- Element *basePtr, int x, int y, int size)
+ Element* elemPtr, int x, int y, int size)
{
- BarElement* elemPtr = (BarElement *)basePtr;
- BarPen* penPtr;
- int radius;
+ BarElement* bePtr = (BarElement*)elemPtr;
+ BarElementOptions* ops = (BarElementOptions*)bePtr->ops;
+
+ BarPen* penPtr = NORMALPEN(ops);
+ BarPenOptions* penOps = (BarPenOptions*)penPtr->ops;
- penPtr = NORMALPEN(elemPtr);
- if (!penPtr->fill && !penPtr->outlineColor)
+ if (!penOps->fill && !penOps->outlineColor)
return;
- radius = (size / 2);
+ int radius = (size / 2);
size--;
x -= radius;
@@ -1095,12 +1083,12 @@ static void DrawSymbolProc(Graph* graphPtr, Drawable drawable,
if (penPtr->fillGC)
XSetTSOrigin(graphPtr->display, penPtr->fillGC, x, y);
- if (penPtr->stipple != None)
+ if (penOps->stipple != None)
XFillRectangle(graphPtr->display, drawable, penPtr->fillGC, x, y,
size, size);
else
- Tk_Fill3DRectangle(graphPtr->tkwin, drawable, penPtr->fill,
- x, y, size, size, penPtr->borderWidth, penPtr->relief);
+ Tk_Fill3DRectangle(graphPtr->tkwin, drawable, penOps->fill,
+ x, y, size, size, penOps->borderWidth, penOps->relief);
XDrawRectangle(graphPtr->display, drawable, penPtr->outlineGC, x, y,
size, size);
@@ -1140,56 +1128,55 @@ static void UnsetBackgroundClipRegion(Tk_Window tkwin, Tk_3DBorder border)
static void DrawBarSegments(Graph* graphPtr, Drawable drawable, BarPen* penPtr,
XRectangle *bars, int nBars)
{
+ BarPenOptions* penOps = (BarPenOptions*)penPtr->ops;
TkRegion rgn;
- {
- XRectangle clip;
- clip.x = graphPtr->left;
- clip.y = graphPtr->top;
- clip.width = graphPtr->right - graphPtr->left + 1;
- clip.height = graphPtr->bottom - graphPtr->top + 1;
- rgn = TkCreateRegion();
- TkUnionRectWithRegion(&clip, rgn, rgn);
- }
+ XRectangle clip;
+ clip.x = graphPtr->left;
+ clip.y = graphPtr->top;
+ clip.width = graphPtr->right - graphPtr->left + 1;
+ clip.height = graphPtr->bottom - graphPtr->top + 1;
+ rgn = TkCreateRegion();
+ TkUnionRectWithRegion(&clip, rgn, rgn);
- if (penPtr->fill) {
- int relief = (penPtr->relief == TK_RELIEF_SOLID) ?
- TK_RELIEF_FLAT: penPtr->relief;
+ if (penOps->fill) {
+ int relief = (penOps->relief == TK_RELIEF_SOLID) ?
+ TK_RELIEF_FLAT: penOps->relief;
- int hasOutline = ((relief == TK_RELIEF_FLAT) && penPtr->outlineColor);
- if (penPtr->stipple != None)
+ int hasOutline = ((relief == TK_RELIEF_FLAT) && penOps->outlineColor);
+ if (penOps->stipple != None)
TkSetRegion(graphPtr->display, penPtr->fillGC, rgn);
- SetBackgroundClipRegion(graphPtr->tkwin, penPtr->fill, rgn);
+ SetBackgroundClipRegion(graphPtr->tkwin, penOps->fill, rgn);
if (hasOutline)
TkSetRegion(graphPtr->display, penPtr->outlineGC, rgn);
XRectangle *rp, *rend;
for (rp = bars, rend = rp + nBars; rp < rend; rp++) {
- if (penPtr->stipple != None)
+ if (penOps->stipple != None)
XFillRectangle(graphPtr->display, drawable, penPtr->fillGC,
rp->x, rp->y, rp->width, rp->height);
else
Tk_Fill3DRectangle(graphPtr->tkwin, drawable,
- penPtr->fill, rp->x, rp->y, rp->width, rp->height,
- penPtr->borderWidth, relief);
+ penOps->fill, rp->x, rp->y, rp->width, rp->height,
+ penOps->borderWidth, relief);
if (hasOutline)
XDrawRectangle(graphPtr->display, drawable, penPtr->outlineGC,
rp->x, rp->y, rp->width, rp->height);
}
- UnsetBackgroundClipRegion(graphPtr->tkwin, penPtr->fill);
+ UnsetBackgroundClipRegion(graphPtr->tkwin, penOps->fill);
if (hasOutline)
XSetClipMask(graphPtr->display, penPtr->outlineGC, None);
- if (penPtr->stipple != None)
+ if (penOps->stipple != None)
XSetClipMask(graphPtr->display, penPtr->fillGC, None);
}
- else if (penPtr->outlineColor) {
+ else if (penOps->outlineColor) {
TkSetRegion(graphPtr->display, penPtr->outlineGC, rgn);
XDrawRectangles(graphPtr->display, drawable, penPtr->outlineGC, bars,
nBars);
@@ -1200,126 +1187,132 @@ static void DrawBarSegments(Graph* graphPtr, Drawable drawable, BarPen* penPtr,
}
static void DrawBarValues(Graph* graphPtr, Drawable drawable,
- BarElement* elemPtr,
+ BarElement* bePtr,
BarPen* penPtr, XRectangle *bars, int nBars,
int *barToData)
{
- XRectangle *rp, *rend;
- int count;
- const char *fmt;
-
- fmt = penPtr->valueFormat;
- if (!fmt) {
+ BarElementOptions* ops = (BarElementOptions*)bePtr->ops;
+ BarPenOptions* penOps = (BarPenOptions*)penPtr->ops;
+
+ const char *fmt = penOps->valueFormat;
+ if (!fmt)
fmt = "%g";
- }
- count = 0;
+
+ int count = 0;
+ XRectangle *rp, *rend;
for (rp = bars, rend = rp + nBars; rp < rend; rp++) {
Point2d anchorPos;
- double x, y;
char string[TCL_DOUBLE_SPACE * 2 + 2];
- x = elemPtr->coords.x->values[barToData[count]];
- y = elemPtr->coords.y->values[barToData[count]];
+ double x = ops->coords.x->values[barToData[count]];
+ double y = ops->coords.y->values[barToData[count]];
count++;
- if (penPtr->valueShow == SHOW_X) {
+ if (penOps->valueShow == SHOW_X)
sprintf_s(string, TCL_DOUBLE_SPACE, fmt, x);
- } else if (penPtr->valueShow == SHOW_Y) {
+ else if (penOps->valueShow == SHOW_Y)
sprintf_s(string, TCL_DOUBLE_SPACE, fmt, y);
- } else if (penPtr->valueShow == SHOW_BOTH) {
+ else if (penOps->valueShow == SHOW_BOTH) {
sprintf_s(string, TCL_DOUBLE_SPACE, fmt, x);
strcat(string, ",");
sprintf_s(string + strlen(string), TCL_DOUBLE_SPACE, fmt, y);
}
+
if (graphPtr->inverted) {
anchorPos.y = rp->y + rp->height * 0.5;
anchorPos.x = rp->x + rp->width;
- if (x < graphPtr->baseline) {
+ if (x < graphPtr->baseline)
anchorPos.x -= rp->width;
- }
- } else {
+ }
+ else {
anchorPos.x = rp->x + rp->width * 0.5;
anchorPos.y = rp->y;
- if (y < graphPtr->baseline) {
+ if (y < graphPtr->baseline)
anchorPos.y += rp->height;
- }
}
- Blt_DrawText(graphPtr->tkwin, drawable, string, &penPtr->valueStyle,
+ Blt_DrawText(graphPtr->tkwin, drawable, string, &penOps->valueStyle,
(int)anchorPos.x, (int)anchorPos.y);
}
}
static void DrawNormalBarProc(Graph* graphPtr, Drawable drawable,
- Element *basePtr)
+ Element* elemPtr)
{
- BarElement* elemPtr = (BarElement *)basePtr;
+ BarElement* bePtr = (BarElement*)elemPtr;
+ BarElementOptions* ops = (BarElementOptions*)bePtr->ops;
int count = 0;
- for (Blt_ChainLink link = Blt_Chain_FirstLink(elemPtr->stylePalette); link;
+ for (Blt_ChainLink link = Blt_Chain_FirstLink(ops->stylePalette); link;
link = Blt_Chain_NextLink(link)) {
BarStyle *stylePtr = (BarStyle*)Blt_Chain_GetValue(link);
BarPen* penPtr = (BarPen*)stylePtr->penPtr;
+ BarPenOptions* penOps = (BarPenOptions*)penPtr->ops;
+
if (stylePtr->nBars > 0)
DrawBarSegments(graphPtr, drawable, penPtr, stylePtr->bars,
stylePtr->nBars);
- if ((stylePtr->xeb.length > 0) && (penPtr->errorBarShow & SHOW_X))
+ if ((stylePtr->xeb.length > 0) && (penOps->errorBarShow & SHOW_X))
Blt_Draw2DSegments(graphPtr->display, drawable, penPtr->errorBarGC,
stylePtr->xeb.segments, stylePtr->xeb.length);
- if ((stylePtr->yeb.length > 0) && (penPtr->errorBarShow & SHOW_Y))
+ if ((stylePtr->yeb.length > 0) && (penOps->errorBarShow & SHOW_Y))
Blt_Draw2DSegments(graphPtr->display, drawable, penPtr->errorBarGC,
stylePtr->yeb.segments, stylePtr->yeb.length);
- if (penPtr->valueShow != SHOW_NONE)
- DrawBarValues(graphPtr, drawable, elemPtr, penPtr,
+ if (penOps->valueShow != SHOW_NONE)
+ DrawBarValues(graphPtr, drawable, bePtr, penPtr,
stylePtr->bars, stylePtr->nBars,
- elemPtr->barToData + count);
+ bePtr->barToData + count);
count += stylePtr->nBars;
}
}
static void DrawActiveBarProc(Graph* graphPtr, Drawable drawable,
- Element *basePtr)
+ Element* elemPtr)
{
- BarElement* elemPtr = (BarElement *)basePtr;
+ BarElement* bePtr = (BarElement*)elemPtr;
+ BarElementOptions* ops = (BarElementOptions*)bePtr->ops;
- if (elemPtr->activePenPtr) {
- BarPen* penPtr = elemPtr->activePenPtr;
+ if (ops->activePenPtr) {
+ BarPen* penPtr = ops->activePenPtr;
+ BarPenOptions* penOps = (BarPenOptions*)penPtr->ops;
- if (elemPtr->nActiveIndices > 0) {
- if (elemPtr->flags & ACTIVE_PENDING) {
- MapActiveBars(elemPtr);
+ if (bePtr->nActiveIndices > 0) {
+ if (bePtr->flags & ACTIVE_PENDING) {
+ MapActiveBars(bePtr);
}
- DrawBarSegments(graphPtr, drawable, penPtr, elemPtr->activeRects,
- elemPtr->nActive);
- if (penPtr->valueShow != SHOW_NONE) {
- DrawBarValues(graphPtr, drawable, elemPtr, penPtr,
- elemPtr->activeRects, elemPtr->nActive,
- elemPtr->activeToData);
+ DrawBarSegments(graphPtr, drawable, penPtr, bePtr->activeRects,
+ bePtr->nActive);
+ if (penOps->valueShow != SHOW_NONE) {
+ DrawBarValues(graphPtr, drawable, bePtr, penPtr,
+ bePtr->activeRects, bePtr->nActive,
+ bePtr->activeToData);
}
}
- else if (elemPtr->nActiveIndices < 0) {
- DrawBarSegments(graphPtr, drawable, penPtr, elemPtr->bars,
- elemPtr->nBars);
- if (penPtr->valueShow != SHOW_NONE) {
- DrawBarValues(graphPtr, drawable, elemPtr, penPtr,
- elemPtr->bars, elemPtr->nBars, elemPtr->barToData);
+ else if (bePtr->nActiveIndices < 0) {
+ DrawBarSegments(graphPtr, drawable, penPtr, bePtr->bars,
+ bePtr->nBars);
+ if (penOps->valueShow != SHOW_NONE) {
+ DrawBarValues(graphPtr, drawable, bePtr, penPtr,
+ bePtr->bars, bePtr->nBars, bePtr->barToData);
}
}
}
}
-static void SymbolToPostScriptProc(Graph* graphPtr, Blt_Ps ps, Element *basePtr,
+static void SymbolToPostScriptProc(Graph* graphPtr, Blt_Ps ps, Element* elemPtr,
double x, double y, int size)
{
- BarElement* elemPtr = (BarElement *)basePtr;
- BarPen* penPtr;
+ BarElement* bePtr = (BarElement*)elemPtr;
+ BarElementOptions* ops = (BarElementOptions*)bePtr->ops;
+
+ BarPen* penPtr = NORMALPEN(ops);
+ BarPenOptions* penOps = (BarPenOptions*)penPtr->ops;
- penPtr = NORMALPEN(elemPtr);
- if (!penPtr->fill && !penPtr->outlineColor)
+ if (!penOps->fill && !penOps->outlineColor)
return;
/*
@@ -1329,19 +1322,19 @@ static void SymbolToPostScriptProc(Graph* graphPtr, Blt_Ps ps, Element *basePtr,
Blt_Ps_Append(ps, "\n"
"/DrawSymbolProc {\n"
"gsave\n ");
- if (penPtr->stipple != None) {
- if (penPtr->fill) {
- Blt_Ps_XSetBackground(ps, Tk_3DBorderColor(penPtr->fill));
+ if (penOps->stipple != None) {
+ if (penOps->fill) {
+ Blt_Ps_XSetBackground(ps, Tk_3DBorderColor(penOps->fill));
Blt_Ps_Append(ps, " gsave fill grestore\n ");
}
- if (penPtr->outlineColor) {
- Blt_Ps_XSetForeground(ps, penPtr->outlineColor);
+ if (penOps->outlineColor) {
+ Blt_Ps_XSetForeground(ps, penOps->outlineColor);
} else {
- Blt_Ps_XSetForeground(ps, Tk_3DBorderColor(penPtr->fill));
+ Blt_Ps_XSetForeground(ps, Tk_3DBorderColor(penOps->fill));
}
- Blt_Ps_XSetStipple(ps, graphPtr->display, penPtr->stipple);
- } else if (penPtr->outlineColor) {
- Blt_Ps_XSetForeground(ps, penPtr->outlineColor);
+ Blt_Ps_XSetStipple(ps, graphPtr->display, penOps->stipple);
+ } else if (penOps->outlineColor) {
+ Blt_Ps_XSetForeground(ps, penOps->outlineColor);
Blt_Ps_Append(ps, " fill\n");
}
Blt_Ps_Append(ps, " grestore\n");
@@ -1352,67 +1345,69 @@ static void SymbolToPostScriptProc(Graph* graphPtr, Blt_Ps ps, Element *basePtr,
static void SegmentsToPostScript(Graph* graphPtr, Blt_Ps ps, BarPen* penPtr,
XRectangle *bars, int nBars)
{
+ BarPenOptions* penOps = (BarPenOptions*)penPtr->ops;
XRectangle *rp, *rend;
- if (!penPtr->fill && !penPtr->outlineColor)
+ if (!penOps->fill && !penOps->outlineColor)
return;
for (rp = bars, rend = rp + nBars; rp < rend; rp++) {
if ((rp->width < 1) || (rp->height < 1)) {
continue;
}
- if (penPtr->stipple != None) {
+ if (penOps->stipple != None) {
Blt_Ps_Rectangle(ps, rp->x, rp->y, rp->width - 1, rp->height - 1);
- if (penPtr->fill) {
- Blt_Ps_XSetBackground(ps, Tk_3DBorderColor(penPtr->fill));
+ if (penOps->fill) {
+ Blt_Ps_XSetBackground(ps, Tk_3DBorderColor(penOps->fill));
Blt_Ps_Append(ps, "gsave fill grestore\n");
}
- if (penPtr->outlineColor) {
- Blt_Ps_XSetForeground(ps, penPtr->outlineColor);
+ if (penOps->outlineColor) {
+ Blt_Ps_XSetForeground(ps, penOps->outlineColor);
} else {
- Blt_Ps_XSetForeground(ps, Tk_3DBorderColor(penPtr->fill));
+ Blt_Ps_XSetForeground(ps, Tk_3DBorderColor(penOps->fill));
}
- Blt_Ps_XSetStipple(ps, graphPtr->display, penPtr->stipple);
- } else if (penPtr->outlineColor) {
- Blt_Ps_XSetForeground(ps, penPtr->outlineColor);
+ Blt_Ps_XSetStipple(ps, graphPtr->display, penOps->stipple);
+ } else if (penOps->outlineColor) {
+ Blt_Ps_XSetForeground(ps, penOps->outlineColor);
Blt_Ps_XFillRectangle(ps, (double)rp->x, (double)rp->y,
(int)rp->width - 1, (int)rp->height - 1);
}
- if ((penPtr->fill) && (penPtr->borderWidth > 0) &&
- (penPtr->relief != TK_RELIEF_FLAT)) {
- Blt_Ps_Draw3DRectangle(ps, penPtr->fill, (double)rp->x, (double)rp->y,
+ if ((penOps->fill) && (penOps->borderWidth > 0) &&
+ (penOps->relief != TK_RELIEF_FLAT)) {
+ Blt_Ps_Draw3DRectangle(ps, penOps->fill, (double)rp->x, (double)rp->y,
(int)rp->width, (int)rp->height,
- penPtr->borderWidth, penPtr->relief);
+ penOps->borderWidth, penOps->relief);
}
}
}
static void BarValuesToPostScript(Graph* graphPtr, Blt_Ps ps,
- BarElement* elemPtr,
+ BarElement* bePtr,
BarPen* penPtr, XRectangle *bars, int nBars,
int *barToData)
{
+ BarPenOptions* penOps = (BarPenOptions*)penPtr->ops;
+ BarElementOptions* ops = (BarElementOptions*)bePtr->ops;
+
XRectangle *rp, *rend;
- int count;
- const char *fmt;
char string[TCL_DOUBLE_SPACE * 2 + 2];
double x, y;
Point2d anchorPos;
- count = 0;
- fmt = penPtr->valueFormat;
+ int count = 0;
+ const char* fmt = penOps->valueFormat;
if (!fmt)
fmt = "%g";
for (rp = bars, rend = rp + nBars; rp < rend; rp++) {
- x = elemPtr->coords.x->values[barToData[count]];
- y = elemPtr->coords.y->values[barToData[count]];
+ x = ops->coords.x->values[barToData[count]];
+ y = ops->coords.y->values[barToData[count]];
count++;
- if (penPtr->valueShow == SHOW_X) {
+ if (penOps->valueShow == SHOW_X) {
sprintf_s(string, TCL_DOUBLE_SPACE, fmt, x);
- } else if (penPtr->valueShow == SHOW_Y) {
+ } else if (penOps->valueShow == SHOW_Y) {
sprintf_s(string, TCL_DOUBLE_SPACE, fmt, y);
- } else if (penPtr->valueShow == SHOW_BOTH) {
+ } else if (penOps->valueShow == SHOW_BOTH) {
sprintf_s(string, TCL_DOUBLE_SPACE, fmt, x);
strcat(string, ",");
sprintf_s(string + strlen(string), TCL_DOUBLE_SPACE, fmt, y);
@@ -1430,77 +1425,81 @@ static void BarValuesToPostScript(Graph* graphPtr, Blt_Ps ps,
anchorPos.y += rp->height;
}
}
- Blt_Ps_DrawText(ps, string, &penPtr->valueStyle, anchorPos.x,
+ Blt_Ps_DrawText(ps, string, &penOps->valueStyle, anchorPos.x,
anchorPos.y);
}
}
static void ActiveBarToPostScriptProc(Graph* graphPtr, Blt_Ps ps,
- Element *basePtr)
+ Element* elemPtr)
{
- BarElement* elemPtr = (BarElement *)basePtr;
+ BarElement* bePtr = (BarElement*)elemPtr;
+ BarElementOptions* ops = (BarElementOptions*)bePtr->ops;
- if (elemPtr->activePenPtr) {
- BarPen* penPtr = elemPtr->activePenPtr;
+ if (ops->activePenPtr) {
+ BarPen* penPtr = ops->activePenPtr;
+ BarPenOptions* penOps = (BarPenOptions*)penPtr->ops;
- if (elemPtr->nActiveIndices > 0) {
- if (elemPtr->flags & ACTIVE_PENDING) {
- MapActiveBars(elemPtr);
+ if (bePtr->nActiveIndices > 0) {
+ if (bePtr->flags & ACTIVE_PENDING) {
+ MapActiveBars(bePtr);
}
- SegmentsToPostScript(graphPtr, ps, penPtr, elemPtr->activeRects,
- elemPtr->nActive);
- if (penPtr->valueShow != SHOW_NONE) {
- BarValuesToPostScript(graphPtr, ps, elemPtr, penPtr,
- elemPtr->activeRects, elemPtr->nActive, elemPtr->activeToData);
+ SegmentsToPostScript(graphPtr, ps, penPtr, bePtr->activeRects,
+ bePtr->nActive);
+ if (penOps->valueShow != SHOW_NONE) {
+ BarValuesToPostScript(graphPtr, ps, bePtr, penPtr,
+ bePtr->activeRects, bePtr->nActive, bePtr->activeToData);
}
- } else if (elemPtr->nActiveIndices < 0) {
- SegmentsToPostScript(graphPtr, ps, penPtr, elemPtr->bars,
- elemPtr->nBars);
- if (penPtr->valueShow != SHOW_NONE) {
- BarValuesToPostScript(graphPtr, ps, elemPtr, penPtr,
- elemPtr->bars, elemPtr->nBars, elemPtr->barToData);
+ } else if (bePtr->nActiveIndices < 0) {
+ SegmentsToPostScript(graphPtr, ps, penPtr, bePtr->bars,
+ bePtr->nBars);
+ if (penOps->valueShow != SHOW_NONE) {
+ BarValuesToPostScript(graphPtr, ps, bePtr, penPtr,
+ bePtr->bars, bePtr->nBars, bePtr->barToData);
}
}
}
}
static void NormalBarToPostScriptProc(Graph* graphPtr, Blt_Ps ps,
- Element *basePtr)
+ Element* elemPtr)
{
- BarElement* elemPtr = (BarElement *)basePtr;
+ BarElement* bePtr = (BarElement*)elemPtr;
+ BarElementOptions* ops = (BarElementOptions*)bePtr->ops;
int count = 0;
- for (Blt_ChainLink link = Blt_Chain_FirstLink(elemPtr->stylePalette); link;
+ for (Blt_ChainLink link = Blt_Chain_FirstLink(ops->stylePalette); link;
link = Blt_Chain_NextLink(link)) {
BarStyle *stylePtr = (BarStyle*)Blt_Chain_GetValue(link);
BarPen* penPtr = (BarPen*)stylePtr->penPtr;
+ BarPenOptions* penOps = (BarPenOptions*)penPtr->ops;
if (stylePtr->nBars > 0)
SegmentsToPostScript(graphPtr, ps, penPtr, stylePtr->bars,
stylePtr->nBars);
- XColor* colorPtr = penPtr->errorBarColor;
+ XColor* colorPtr = penOps->errorBarColor;
if (!colorPtr)
- colorPtr = penPtr->outlineColor;
+ colorPtr = penOps->outlineColor;
- if ((stylePtr->xeb.length > 0) && (penPtr->errorBarShow & SHOW_X)) {
- Blt_Ps_XSetLineAttributes(ps, colorPtr, penPtr->errorBarLineWidth,
+ if ((stylePtr->xeb.length > 0) && (penOps->errorBarShow & SHOW_X)) {
+ Blt_Ps_XSetLineAttributes(ps, colorPtr, penOps->errorBarLineWidth,
NULL, CapButt, JoinMiter);
Blt_Ps_Draw2DSegments(ps, stylePtr->xeb.segments,
stylePtr->xeb.length);
}
- if ((stylePtr->yeb.length > 0) && (penPtr->errorBarShow & SHOW_Y)) {
- Blt_Ps_XSetLineAttributes(ps, colorPtr, penPtr->errorBarLineWidth,
+ if ((stylePtr->yeb.length > 0) && (penOps->errorBarShow & SHOW_Y)) {
+ Blt_Ps_XSetLineAttributes(ps, colorPtr, penOps->errorBarLineWidth,
NULL, CapButt, JoinMiter);
Blt_Ps_Draw2DSegments(ps, stylePtr->yeb.segments,
stylePtr->yeb.length);
}
- if (penPtr->valueShow != SHOW_NONE)
- BarValuesToPostScript(graphPtr, ps, elemPtr, penPtr,
+ if (penOps->valueShow != SHOW_NONE)
+ BarValuesToPostScript(graphPtr, ps, bePtr, penPtr,
stylePtr->bars, stylePtr->nBars,
- elemPtr->barToData + count);
+ bePtr->barToData + count);
count += stylePtr->nBars;
}
@@ -1536,15 +1535,16 @@ void Blt_InitBarSetTable(Graph* graphPtr)
double *x, *xend;
int nPoints;
- BarElement* elemPtr = (BarElement*)Blt_Chain_GetValue(link);
- if ((elemPtr->hide) || (elemPtr->obj.classId != CID_ELEM_BAR))
+ BarElement* bePtr = (BarElement*)Blt_Chain_GetValue(link);
+ BarElementOptions* ops = (BarElementOptions*)bePtr->ops;
+ if ((bePtr->hide) || (bePtr->obj.classId != CID_ELEM_BAR))
continue;
nSegs++;
- if (elemPtr->coords.x) {
- nPoints = elemPtr->coords.x->nValues;
- for (x = elemPtr->coords.x->values, xend = x + nPoints; x < xend; x++) {
+ if (ops->coords.x) {
+ nPoints = ops->coords.x->nValues;
+ for (x = ops->coords.x->values, xend = x + nPoints; x < xend; x++) {
Tcl_HashEntry *hPtr;
BarSetKey key;
int isNew;
@@ -1552,7 +1552,7 @@ void Blt_InitBarSetTable(Graph* graphPtr)
const char *name;
key.value = *x;
- key.axes = elemPtr->axes;
+ key.axes = ops->axes;
key.axes.y = NULL;
hPtr = Tcl_CreateHashEntry(&setTable, (char *)&key, &isNew);
Tcl_HashTable *tablePtr;
@@ -1564,8 +1564,8 @@ void Blt_InitBarSetTable(Graph* graphPtr)
else
tablePtr = (Tcl_HashTable*)Tcl_GetHashValue(hPtr);
- name = (elemPtr->groupName) ? elemPtr->groupName :
- elemPtr->axes.y->obj.name;
+ name = (ops->groupName) ? ops->groupName :
+ ops->axes.y->obj.name;
hPtr = Tcl_CreateHashEntry(tablePtr, name, &isNew);
if (isNew)
count = 1;
@@ -1654,27 +1654,28 @@ void Blt_ComputeBarStacks(Graph* graphPtr)
link; link = Blt_Chain_NextLink(link)) {
double *x, *y, *xend;
- BarElement* elemPtr = (BarElement*)Blt_Chain_GetValue(link);
- if ((elemPtr->hide) || (elemPtr->obj.classId != CID_ELEM_BAR))
+ BarElement* bePtr = (BarElement*)Blt_Chain_GetValue(link);
+ BarElementOptions* ops = (BarElementOptions*)bePtr->ops;
+ if ((bePtr->hide) || (bePtr->obj.classId != CID_ELEM_BAR))
continue;
- if (elemPtr->coords.x && elemPtr->coords.y) {
- for (x = elemPtr->coords.x->values, y = elemPtr->coords.y->values,
- xend = x + elemPtr->coords.x->nValues; x < xend; x++, y++) {
+ if (ops->coords.x && ops->coords.y) {
+ for (x = ops->coords.x->values, y = ops->coords.y->values,
+ xend = x + ops->coords.x->nValues; x < xend; x++, y++) {
BarSetKey key;
Tcl_HashEntry *hPtr;
const char *name;
key.value = *x;
- key.axes = elemPtr->axes;
+ key.axes = ops->axes;
key.axes.y = NULL;
hPtr = Tcl_FindHashEntry(&graphPtr->setTable, (char *)&key);
if (!hPtr)
continue;
Tcl_HashTable *tablePtr = (Tcl_HashTable*)Tcl_GetHashValue(hPtr);
- name = (elemPtr->groupName) ? elemPtr->groupName :
- elemPtr->axes.y->obj.name;
+ name = (ops->groupName) ? ops->groupName :
+ ops->axes.y->obj.name;
hPtr = Tcl_FindHashEntry(tablePtr, name);
if (!hPtr)
continue;
diff --git a/src/bltGrElemBar.h b/src/bltGrElemBar.h
index 621ffe5..cbe044c 100644
--- a/src/bltGrElemBar.h
+++ b/src/bltGrElemBar.h
@@ -39,6 +39,7 @@ using namespace std;
#include "bltGrPenBar.h"
typedef struct {
+ Element* elemPtr;
const char *label;
char** tags;
Axis2d axes;
@@ -53,12 +54,12 @@ typedef struct {
int hide;
int legendRelief;
Blt_Chain stylePalette;
-
- // derived
- BarPenOptions builtinPenOps;
+ BarPen *builtinPenPtr;
BarPen *activePenPtr;
BarPen *normalPenPtr;
+ BarPenOptions builtinPen;
+ // derived
double barWidth;
const char *groupName;
} BarElementOptions;
@@ -70,33 +71,18 @@ typedef struct {
Tcl_HashEntry *hashPtr;
void* ops;
- // Fields specific to elements
- const char *label;
unsigned short row;
unsigned short col;
- int legendRelief;
- Axis2d axes;
- ElemCoords coords;
- ElemValues* w;
int *activeIndices;
int nActiveIndices;
ElementProcs *procsPtr;
Tk_OptionTable optionTable;
- BarPen *activePenPtr;
- BarPen *normalPenPtr;
- BarPen *builtinPenPtr;
- Blt_Chain stylePalette;
-
- // Symbol scaling
- int scaleSymbols;
double xRange;
double yRange;
- int state;
Blt_ChainLink link;
- // Fields specific to the barchart element
- double barWidth;
- const char *groupName;
+ // Fields specific to Bar Element
+ BarPen builtinPen;
int *barToData;
XRectangle *bars;
int *activeToData;
@@ -104,16 +90,8 @@ typedef struct {
int nBars;
int nActive;
int xPad;
- ElemValues* xError;
- ElemValues* yError;
- ElemValues* xHigh;
- ElemValues* xLow;
- ElemValues* yHigh;
- ElemValues* yLow;
- BarPen builtinPen;
GraphSegments xeb;
GraphSegments yeb;
- int errorBarCapWidth;
} BarElement;
#endif
diff --git a/src/bltGrElemLine.C b/src/bltGrElemLine.C
index b894fd6..f0cb175 100644
--- a/src/bltGrElemLine.C
+++ b/src/bltGrElemLine.C
@@ -154,128 +154,139 @@ extern Tk_ObjCustomOption yAxisObjOption;
static Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_CUSTOM, "-activepen", "activePen", "ActivePen",
- "activeLine", -1, Tk_Offset(LineElement, activePenPtr),
+ "activeLine", -1, Tk_Offset(LineElementOptions, activePenPtr),
TK_OPTION_NULL_OK, &linePenObjOption, 0},
{TK_OPTION_COLOR, "-areaforeground", "areaForeground", "AreaForeground",
- NULL, -1, Tk_Offset(LineElement, fillFgColor), TK_OPTION_NULL_OK, NULL, 0},
+ NULL, -1, Tk_Offset(LineElementOptions, fillFgColor),
+ TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_BORDER, "-areabackground", "areaBackground", "AreaBackground",
- NULL, -1, Tk_Offset(LineElement, fillBg),
+ NULL, -1, Tk_Offset(LineElementOptions, fillBg),
TK_OPTION_NULL_OK, NULL, MAP_ITEM},
{TK_OPTION_CUSTOM, "-bindtags", "bindTags", "BindTags",
- "all", -1, Tk_Offset(LineElement, obj.tags),
+ "all", -1, Tk_Offset(LineElementOptions, tags),
TK_OPTION_NULL_OK, &listObjOption, 0},
{TK_OPTION_COLOR, "-color", "color", "Color",
- STD_NORMAL_FOREGROUND, -1, Tk_Offset(LineElement, builtinPen.traceColor),
+ STD_NORMAL_FOREGROUND, -1,
+ Tk_Offset(LineElementOptions, builtinPen.traceColor),
0, NULL, 0},
{TK_OPTION_CUSTOM, "-dashes", "dashes", "Dashes",
- NULL, -1, Tk_Offset(LineElement, builtinPen.traceDashes),
+ NULL, -1, Tk_Offset(LineElementOptions, builtinPen.traceDashes),
TK_OPTION_NULL_OK, &dashesObjOption, 0},
{TK_OPTION_CUSTOM, "-data", "data", "Data",
- NULL, -1, Tk_Offset(LineElement, coords),
+ NULL, -1, Tk_Offset(LineElementOptions, coords),
TK_OPTION_NULL_OK, &pairsObjOption, MAP_ITEM},
{TK_OPTION_COLOR, "-errorbarcolor", "errorBarColor", "ErrorBarColor",
- NULL, -1, Tk_Offset(LineElement, builtinPen.errorBarColor),
+ NULL, -1, Tk_Offset(LineElementOptions, builtinPen.errorBarColor),
TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_PIXELS,"-errorbarwidth", "errorBarWidth", "ErrorBarWidth",
- "1", -1, Tk_Offset(LineElement, builtinPen.errorBarLineWidth), 0, NULL, 0},
+ "1", -1, Tk_Offset(LineElementOptions, builtinPen.errorBarLineWidth),
+ 0, NULL, 0},
{TK_OPTION_PIXELS, "-errorbarcap", "errorBarCap", "ErrorBarCap",
- "2", -1, Tk_Offset(LineElement, builtinPen.errorBarCapWidth), 0, NULL, 0},
+ "2", -1, Tk_Offset(LineElementOptions, builtinPen.errorBarCapWidth),
+ 0, NULL, 0},
{TK_OPTION_COLOR, "-fill", "fill", "Fill",
- NULL, -1, Tk_Offset(LineElement, builtinPen.symbol.fillColor),
+ NULL, -1, Tk_Offset(LineElementOptions, builtinPen.symbol.fillColor),
TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_BOOLEAN, "-hide", "hide", "Hide",
- "no", -1, Tk_Offset(LineElement, hide), 0, NULL, MAP_ITEM},
+ "no", -1, Tk_Offset(LineElementOptions, hide), 0, NULL, MAP_ITEM},
{TK_OPTION_STRING, "-label", "label", "Label",
- NULL, -1, Tk_Offset(LineElement, label),
+ NULL, -1, Tk_Offset(LineElementOptions, label),
TK_OPTION_NULL_OK | TK_OPTION_DONT_SET_DEFAULT, NULL, MAP_ITEM},
{TK_OPTION_RELIEF, "-legendrelief", "legendRelief", "LegendRelief",
- "flat", -1, Tk_Offset(LineElement, legendRelief), 0, NULL, 0},
+ "flat", -1, Tk_Offset(LineElementOptions, legendRelief), 0, NULL, 0},
{TK_OPTION_PIXELS, "-linewidth", "lineWidth", "LineWidth",
- "1", -1, Tk_Offset(LineElement, builtinPen.traceWidth), 0, NULL, 0},
+ "1", -1, Tk_Offset(LineElementOptions, builtinPen.traceWidth),
+ 0, NULL, 0},
{TK_OPTION_CUSTOM, "-mapx", "mapX", "MapX",
- "x", -1, Tk_Offset(LineElement, axes.x), 0, &xAxisObjOption, MAP_ITEM},
+ "x", -1, Tk_Offset(LineElementOptions, axes.x),
+ 0, &xAxisObjOption, MAP_ITEM},
{TK_OPTION_CUSTOM, "-mapy", "mapY", "MapY",
- "y", -1, Tk_Offset(LineElement, axes.y), 0, &yAxisObjOption, MAP_ITEM},
+ "y", -1, Tk_Offset(LineElementOptions, axes.y),
+ 0, &yAxisObjOption, MAP_ITEM},
{TK_OPTION_INT, "-maxsymbols", "maxSymbols", "MaxSymbols",
- "0", -1, Tk_Offset(LineElement, reqMaxSymbols), 0, NULL, 0},
+ "0", -1, Tk_Offset(LineElementOptions, reqMaxSymbols), 0, NULL, 0},
{TK_OPTION_COLOR, "-offdash", "offDash", "OffDash",
- NULL, -1, Tk_Offset(LineElement, builtinPen.traceOffColor),
+ NULL, -1, Tk_Offset(LineElementOptions, builtinPen.traceOffColor),
TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_COLOR, "-outline", "outline", "Outline",
- NULL, -1, Tk_Offset(LineElement, builtinPen.symbol.outlineColor),
+ NULL, -1, Tk_Offset(LineElementOptions, builtinPen.symbol.outlineColor),
TK_OPTION_NULL_OK, NULL,0},
{TK_OPTION_PIXELS, "-outlinewidth", "outlineWidth", "OutlineWidth",
- "1", -1, Tk_Offset(LineElement, builtinPen.symbol.outlineWidth), 0, NULL, 0},
+ "1", -1, Tk_Offset(LineElementOptions, builtinPen.symbol.outlineWidth),
+ 0, NULL, 0},
{TK_OPTION_CUSTOM, "-pen", "pen", "Pen",
- NULL, -1, Tk_Offset(LineElement, normalPenPtr),
+ NULL, -1, Tk_Offset(LineElementOptions, normalPenPtr),
TK_OPTION_NULL_OK, &linePenObjOption, 0},
{TK_OPTION_PIXELS, "-pixels", "pixels", "Pixels",
- "0.1i", -1, Tk_Offset(LineElement, builtinPen.symbol.size),
+ "0.1i", -1, Tk_Offset(LineElementOptions, builtinPen.symbol.size),
0, NULL, MAP_ITEM},
{TK_OPTION_DOUBLE, "-reduce", "reduce", "Reduce",
- "0", -1, Tk_Offset(LineElement, rTolerance), 0, NULL, 0},
+ "0", -1, Tk_Offset(LineElementOptions, rTolerance), 0, NULL, 0},
{TK_OPTION_BOOLEAN, "-scalesymbols", "scaleSymbols", "ScaleSymbols",
- "yes", -1, Tk_Offset(LineElement, scaleSymbols),
+ "yes", -1, Tk_Offset(LineElementOptions, scaleSymbols),
0, NULL, (MAP_ITEM | SCALE_SYMBOL)},
{TK_OPTION_STRING_TABLE, "-showerrorbars", "showErrorBars", "ShowErrorBars",
- "both", -1, Tk_Offset(LineElement, builtinPen.errorBarShow),
+ "both", -1, Tk_Offset(LineElementOptions, builtinPen.errorBarShow),
0, &fillObjOption, 0},
{TK_OPTION_STRING_TABLE, "-showvalues", "showValues", "ShowValues",
- "none", -1, Tk_Offset(LineElement, builtinPen.valueShow),
+ "none", -1, Tk_Offset(LineElementOptions, builtinPen.valueShow),
0, &fillObjOption, 0},
{TK_OPTION_STRING_TABLE, "-smooth", "smooth", "Smooth",
- "linear", -1, Tk_Offset(LineElement, reqSmooth),
+ "linear", -1, Tk_Offset(LineElementOptions, reqSmooth),
0, &smoothObjOption, MAP_ITEM},
- {TK_OPTION_STRING_TABLE, "-state", "state", "State",
- "normal", -1, Tk_Offset(LineElement, state), 0, &stateObjOption, 0},
{TK_OPTION_CUSTOM, "-styles", "styles", "Styles",
- "", -1, Tk_Offset(LineElement, stylePalette), 0, &styleObjOption, 0},
+ "", -1, Tk_Offset(LineElementOptions, stylePalette), 0, &styleObjOption, 0},
{TK_OPTION_CUSTOM, "-symbol", "symbol", "Symbol",
- "none", -1, Tk_Offset(LineElement, builtinPen.symbol),
+ "none", -1, Tk_Offset(LineElementOptions, builtinPen.symbol),
0, &symbolObjOption, 0},
{TK_OPTION_STRING_TABLE, "-trace", "trace", "Trace",
- "both", -1, Tk_Offset(LineElement, penDir), 0, &penDirObjOption, MAP_ITEM},
+ "both", -1, Tk_Offset(LineElementOptions, penDir),
+ 0, &penDirObjOption, MAP_ITEM},
{TK_OPTION_ANCHOR, "-valueanchor", "valueAnchor", "ValueAnchor",
- "s", -1, Tk_Offset(LineElement, builtinPen.valueStyle.anchor), 0, NULL, 0},
+ "s", -1, Tk_Offset(LineElementOptions, builtinPen.valueStyle.anchor),
+ 0, NULL, 0},
{TK_OPTION_COLOR, "-valuecolor", "valueColor", "ValueColor",
- STD_NORMAL_FOREGROUND,-1,Tk_Offset(LineElement, builtinPen.valueStyle.color),
+ STD_NORMAL_FOREGROUND,-1,
+ Tk_Offset(LineElementOptions, builtinPen.valueStyle.color),
0, NULL, 0},
{TK_OPTION_FONT, "-valuefont", "valueFont", "ValueFont",
- STD_FONT_SMALL, -1, Tk_Offset(LineElement, builtinPen.valueStyle.font),
+ STD_FONT_SMALL, -1,
+ Tk_Offset(LineElementOptions, builtinPen.valueStyle.font),
0, NULL, 0},
{TK_OPTION_STRING, "-valueformat", "valueFormat", "ValueFormat",
- "%g", -1, Tk_Offset(LineElement, builtinPen.valueFormat),
+ "%g", -1, Tk_Offset(LineElementOptions, builtinPen.valueFormat),
TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_DOUBLE, "-valuerotate", "valueRotate", "ValueRotate",
- "0", -1, Tk_Offset(LineElement, builtinPen.valueStyle.angle), 0, NULL, 0},
+ "0", -1, Tk_Offset(LineElementOptions, builtinPen.valueStyle.angle),
+ 0, NULL, 0},
{TK_OPTION_CUSTOM, "-weights", "weights", "Weights",
- NULL, -1, Tk_Offset(LineElement, w),
+ NULL, -1, Tk_Offset(LineElementOptions, w),
TK_OPTION_NULL_OK, &valuesObjOption, MAP_ITEM},
{TK_OPTION_SYNONYM, "-x", NULL, NULL, NULL, -1, 0, 0, "-xdata", 0},
{TK_OPTION_CUSTOM, "-xdata", "xData", "XData",
- NULL, -1, Tk_Offset(LineElement, coords.x),
+ NULL, -1, Tk_Offset(LineElementOptions, coords.x),
TK_OPTION_NULL_OK, &valuesObjOption, MAP_ITEM},
{TK_OPTION_CUSTOM, "-xerror", "xError", "XError",
- NULL, -1, Tk_Offset(LineElement, xError),
+ NULL, -1, Tk_Offset(LineElementOptions, xError),
TK_OPTION_NULL_OK, &valuesObjOption, MAP_ITEM},
{TK_OPTION_CUSTOM, "-xhigh", "xHigh", "XHigh",
- NULL, -1, Tk_Offset(LineElement, xHigh),
+ NULL, -1, Tk_Offset(LineElementOptions, xHigh),
TK_OPTION_NULL_OK, &valuesObjOption, MAP_ITEM},
{TK_OPTION_CUSTOM, "-xlow", "xLow", "XLow",
- NULL, -1, Tk_Offset(LineElement, xLow),
+ NULL, -1, Tk_Offset(LineElementOptions, xLow),
TK_OPTION_NULL_OK, &valuesObjOption, MAP_ITEM},
{TK_OPTION_SYNONYM, "-y", NULL, NULL, NULL, -1, 0, 0, "-ydata", 0},
{TK_OPTION_CUSTOM, "-ydata", "yData", "YData",
- NULL, -1, Tk_Offset(LineElement, coords.y),
+ NULL, -1, Tk_Offset(LineElementOptions, coords.y),
TK_OPTION_NULL_OK, &valuesObjOption, MAP_ITEM},
{TK_OPTION_CUSTOM, "-yerror", "yError", "YError",
- NULL, -1, Tk_Offset(LineElement, yError),
+ NULL, -1, Tk_Offset(LineElementOptions, yError),
TK_OPTION_NULL_OK, &valuesObjOption, MAP_ITEM},
{TK_OPTION_CUSTOM, "-yhigh", "yHigh", "YHigh",
- NULL, -1, Tk_Offset(LineElement, yHigh),
+ NULL, -1, Tk_Offset(LineElementOptions, yHigh),
TK_OPTION_NULL_OK, &valuesObjOption, MAP_ITEM},
{TK_OPTION_CUSTOM, "-ylow", "yLow", "YLow",
- NULL, -1, Tk_Offset(LineElement, yLow),
+ NULL, -1, Tk_Offset(LineElementOptions, yLow),
TK_OPTION_NULL_OK, &valuesObjOption, MAP_ITEM},
{TK_OPTION_END, NULL, NULL, NULL, NULL, -1, 0, 0, NULL, 0}
};
@@ -284,85 +295,88 @@ static Tk_OptionSpec optionSpecs[] = {
Element* Blt_LineElement(Graph* graphPtr)
{
- LineElement* elemPtr = (LineElement*)calloc(1, sizeof(LineElement));
- elemPtr->ops = (LineElementOptions*)calloc(1, sizeof(LineElementOptions));
- elemPtr->procsPtr = &lineProcs;
+ LineElement* lePtr = (LineElement*)calloc(1, sizeof(LineElement));
+ lePtr->ops = (LineElementOptions*)calloc(1, sizeof(LineElementOptions));
+ LineElementOptions* ops = (LineElementOptions*)lePtr->ops;
+ ops->elemPtr = (Element*)lePtr;
- elemPtr->builtinPenPtr = &elemPtr->builtinPen;
- elemPtr->builtinPen.ops =
- &(((LineElementOptions*)(elemPtr->ops))->builtinPenOps);
- elemPtr->builtinPen.manageOptions =0;
+ lePtr->procsPtr = &lineProcs;
+ ops->builtinPenPtr = &lePtr->builtinPen;
+ lePtr->builtinPen.ops =&ops->builtinPen;
+ lePtr->builtinPen.manageOptions =0;
- InitLinePen(graphPtr, elemPtr->builtinPenPtr, "builtin");
- Tk_InitOptions(graphPtr->interp, (char*)elemPtr->builtinPenPtr,
- elemPtr->builtinPenPtr->optionTable, graphPtr->tkwin);
+ InitLinePen(graphPtr, &lePtr->builtinPen, "builtin");
+ Tk_InitOptions(graphPtr->interp, (char*)&(ops->builtinPen),
+ lePtr->builtinPen.optionTable, graphPtr->tkwin);
- elemPtr->optionTable = Tk_CreateOptionTable(graphPtr->interp, optionSpecs);
+ lePtr->optionTable = Tk_CreateOptionTable(graphPtr->interp, optionSpecs);
- elemPtr->flags = SCALE_SYMBOL;
- return (Element*)elemPtr;
+ lePtr->flags = SCALE_SYMBOL;
+ return (Element*)lePtr;
}
-static void DestroyLineProc(Graph* graphPtr, Element* basePtr)
+static void DestroyLineProc(Graph* graphPtr, Element* elemPtr)
{
- LineElement* elemPtr = (LineElement*)basePtr;
+ LineElement* lePtr = (LineElement*)elemPtr;
+ LineElementOptions* ops = (LineElementOptions*)lePtr->ops;
- DestroyLinePenProc(graphPtr, (Pen *)&elemPtr->builtinPen);
- if (elemPtr->activePenPtr)
- Blt_FreePen((Pen *)elemPtr->activePenPtr);
- if (elemPtr->normalPenPtr)
- Blt_FreePen((Pen *)elemPtr->normalPenPtr);
+ DestroyLinePenProc(graphPtr, (Pen *)&lePtr->builtinPen);
+ if (ops->activePenPtr)
+ Blt_FreePen((Pen *)ops->activePenPtr);
+ if (ops->normalPenPtr)
+ Blt_FreePen((Pen *)ops->normalPenPtr);
- ResetLine(elemPtr);
- if (elemPtr->stylePalette) {
- Blt_FreeStylePalette(elemPtr->stylePalette);
- Blt_Chain_Destroy(elemPtr->stylePalette);
+ ResetLine(lePtr);
+ if (ops->stylePalette) {
+ Blt_FreeStylePalette(ops->stylePalette);
+ Blt_Chain_Destroy(ops->stylePalette);
}
- if (elemPtr->activeIndices)
- free(elemPtr->activeIndices);
+ if (lePtr->activeIndices)
+ free(lePtr->activeIndices);
- if (elemPtr->fillPts)
- free(elemPtr->fillPts);
+ if (lePtr->fillPts)
+ free(lePtr->fillPts);
- if (elemPtr->fillGC)
- Tk_FreeGC(graphPtr->display, elemPtr->fillGC);
+ if (lePtr->fillGC)
+ Tk_FreeGC(graphPtr->display, lePtr->fillGC);
}
// Configure
-static int ConfigureLineProc(Graph* graphPtr, Element *basePtr)
+static int ConfigureLineProc(Graph* graphPtr, Element *elemPtr)
{
- LineElement* elemPtr = (LineElement *)basePtr;
+ LineElement* lePtr = (LineElement*)elemPtr;
+ LineElementOptions* ops = (LineElementOptions*)lePtr->ops;
- if (ConfigureLinePenProc(graphPtr, (Pen *)&elemPtr->builtinPen) != TCL_OK)
+ if (ConfigureLinePenProc(graphPtr, (Pen *)&lePtr->builtinPen) != TCL_OK)
return TCL_ERROR;
// Point to the static normal/active pens if no external pens have been
// selected.
- Blt_ChainLink link = Blt_Chain_FirstLink(elemPtr->stylePalette);
+ Blt_ChainLink link = Blt_Chain_FirstLink(ops->stylePalette);
if (!link) {
link = Blt_Chain_AllocLink(sizeof(LineStyle));
- Blt_Chain_LinkAfter(elemPtr->stylePalette, link, NULL);
+ Blt_Chain_LinkAfter(ops->stylePalette, link, NULL);
}
LineStyle* stylePtr = (LineStyle*)Blt_Chain_GetValue(link);
- stylePtr->penPtr = NORMALPEN(elemPtr);
+ stylePtr->penPtr = NORMALPEN(ops);
// Set the outline GC for this pen: GCForeground is outline color.
// GCBackground is the fill color (only used for bitmap symbols).
unsigned long gcMask =0;
XGCValues gcValues;
- if (elemPtr->fillFgColor) {
+ if (ops->fillFgColor) {
gcMask |= GCForeground;
- gcValues.foreground = elemPtr->fillFgColor->pixel;
+ gcValues.foreground = ops->fillFgColor->pixel;
}
- if (elemPtr->fillBgColor) {
+ if (lePtr->fillBgColor) {
gcMask |= GCBackground;
- gcValues.background = elemPtr->fillBgColor->pixel;
+ gcValues.background = lePtr->fillBgColor->pixel;
}
GC newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues);
- if (elemPtr->fillGC)
- Tk_FreeGC(graphPtr->display, elemPtr->fillGC);
- elemPtr->fillGC = newGC;
+ if (lePtr->fillGC)
+ Tk_FreeGC(graphPtr->display, lePtr->fillGC);
+ lePtr->fillGC = newGC;
return TCL_OK;
}
@@ -379,22 +393,24 @@ static void ResetStylePalette(Blt_Chain styles)
}
}
-static int ScaleSymbol(LineElement* elemPtr, int normalSize)
+static int ScaleSymbol(LineElement* lePtr, int normalSize)
{
+ LineElementOptions* ops = (LineElementOptions*)lePtr->ops;
+
double scale = 1.0;
- if (elemPtr->scaleSymbols) {
- double xRange = (elemPtr->axes.x->max - elemPtr->axes.x->min);
- double yRange = (elemPtr->axes.y->max - elemPtr->axes.y->min);
+ if (ops->scaleSymbols) {
+ double xRange = (ops->axes.x->max - ops->axes.x->min);
+ double yRange = (ops->axes.y->max - ops->axes.y->min);
// Save the ranges as a baseline for future scaling
- if (elemPtr->flags & SCALE_SYMBOL) {
- elemPtr->xRange = xRange;
- elemPtr->yRange = yRange;
- elemPtr->flags &= ~SCALE_SYMBOL;
+ if (lePtr->flags & SCALE_SYMBOL) {
+ lePtr->xRange = xRange;
+ lePtr->yRange = yRange;
+ lePtr->flags &= ~SCALE_SYMBOL;
}
else {
// Scale the symbol by the smallest change in the X or Y axes
- double xScale = elemPtr->xRange / xRange;
- double yScale = elemPtr->yRange / yRange;
+ double xScale = lePtr->xRange / xRange;
+ double yScale = lePtr->yRange / yRange;
scale = MIN(xScale, yScale);
}
}
@@ -402,8 +418,8 @@ static int ScaleSymbol(LineElement* elemPtr, int normalSize)
// Don't let the size of symbols go unbounded. Both X and Win32 drawing
// routines assume coordinates to be a signed short int.
- int maxSize = (int)MIN(elemPtr->obj.graphPtr->hRange,
- elemPtr->obj.graphPtr->vRange);
+ int maxSize = (int)MIN(lePtr->obj.graphPtr->hRange,
+ lePtr->obj.graphPtr->vRange);
if (newSize > maxSize)
newSize = maxSize;
@@ -413,19 +429,20 @@ static int ScaleSymbol(LineElement* elemPtr, int normalSize)
return newSize;
}
-static void GetScreenPoints(Graph* graphPtr, LineElement* elemPtr,
+static void GetScreenPoints(Graph* graphPtr, LineElement* lePtr,
MapInfo *mapPtr)
{
+ LineElementOptions* ops = (LineElementOptions*)lePtr->ops;
- if (!elemPtr->coords.x || !elemPtr->coords.y) {
+ if (!ops->coords.x || !ops->coords.y) {
mapPtr->screenPts = NULL;
mapPtr->nScreenPts = 0;
mapPtr->map = NULL;
}
- int np = NUMBEROFPOINTS(elemPtr);
- double* x = elemPtr->coords.x->values;
- double* y = elemPtr->coords.y->values;
+ int np = NUMBEROFPOINTS(ops);
+ double* x = ops->coords.x->values;
+ double* y = ops->coords.y->values;
Point2d *points = (Point2d*)malloc(sizeof(Point2d) * np);
int* map = (int*)malloc(sizeof(int) * np);
@@ -433,8 +450,8 @@ static void GetScreenPoints(Graph* graphPtr, LineElement* elemPtr,
if (graphPtr->inverted) {
for (int i = 0; i < np; i++) {
if ((isfinite(x[i])) && (isfinite(y[i]))) {
- points[count].x = Blt_HMap(elemPtr->axes.y, y[i]);
- points[count].y = Blt_VMap(elemPtr->axes.x, x[i]);
+ points[count].x = Blt_HMap(ops->axes.y, y[i]);
+ points[count].y = Blt_VMap(ops->axes.x, x[i]);
map[count] = i;
count++;
}
@@ -443,8 +460,8 @@ static void GetScreenPoints(Graph* graphPtr, LineElement* elemPtr,
else {
for (int i = 0; i < np; i++) {
if ((isfinite(x[i])) && (isfinite(y[i]))) {
- points[count].x = Blt_HMap(elemPtr->axes.x, x[i]);
- points[count].y = Blt_VMap(elemPtr->axes.y, y[i]);
+ points[count].x = Blt_HMap(ops->axes.x, x[i]);
+ points[count].y = Blt_VMap(ops->axes.y, y[i]);
map[count] = i;
count++;
}
@@ -504,7 +521,7 @@ static void GenerateSteps(MapInfo *mapPtr)
mapPtr->nScreenPts = newSize;
}
-static void GenerateSpline(Graph* graphPtr, LineElement* elemPtr,
+static void GenerateSpline(Graph* graphPtr, LineElement* lePtr,
MapInfo *mapPtr)
{
Point2d *origPts, *iPts;
@@ -582,16 +599,16 @@ static void GenerateSpline(Graph* graphPtr, LineElement* elemPtr,
}
}
niPts = count;
- result = FALSE;
- if (elemPtr->smooth == PEN_SMOOTH_NATURAL) {
+ result = 0;
+ if (lePtr->smooth == PEN_SMOOTH_NATURAL) {
result = Blt_NaturalSpline(origPts, nOrigPts, iPts, niPts);
- } else if (elemPtr->smooth == PEN_SMOOTH_QUADRATIC) {
+ } else if (lePtr->smooth == PEN_SMOOTH_QUADRATIC) {
result = Blt_QuadraticSpline(origPts, nOrigPts, iPts, niPts);
}
if (!result) {
/* The spline interpolation failed. We'll fallback to the current
* coordinates and do no smoothing (standard line segments). */
- elemPtr->smooth = PEN_SMOOTH_LINEAR;
+ lePtr->smooth = PEN_SMOOTH_LINEAR;
free(iPts);
free(map);
} else {
@@ -603,7 +620,7 @@ static void GenerateSpline(Graph* graphPtr, LineElement* elemPtr,
}
}
-static void GenerateParametricSpline(Graph* graphPtr, LineElement* elemPtr,
+static void GenerateParametricSpline(Graph* graphPtr, LineElement* lePtr,
MapInfo *mapPtr)
{
Region2d exts;
@@ -689,17 +706,17 @@ static void GenerateParametricSpline(Graph* graphPtr, LineElement* elemPtr,
map[count] = mapPtr->map[i];
count++;
niPts = count;
- result = FALSE;
- if (elemPtr->smooth == PEN_SMOOTH_NATURAL) {
- result = Blt_NaturalParametricSpline(origPts, nOrigPts, &exts, FALSE,
+ result = 0;
+ if (lePtr->smooth == PEN_SMOOTH_NATURAL) {
+ result = Blt_NaturalParametricSpline(origPts, nOrigPts, &exts, 0,
iPts, niPts);
- } else if (elemPtr->smooth == PEN_SMOOTH_CATROM) {
+ } else if (lePtr->smooth == PEN_SMOOTH_CATROM) {
result = Blt_CatromParametricSpline(origPts, nOrigPts, iPts, niPts);
}
if (!result) {
/* The spline interpolation failed. We will fall back to the current
* coordinates and do no smoothing (standard line segments). */
- elemPtr->smooth = PEN_SMOOTH_LINEAR;
+ lePtr->smooth = PEN_SMOOTH_LINEAR;
free(iPts);
free(map);
} else {
@@ -711,7 +728,7 @@ static void GenerateParametricSpline(Graph* graphPtr, LineElement* elemPtr,
}
}
-static void MapSymbols(Graph* graphPtr, LineElement* elemPtr, MapInfo *mapPtr)
+static void MapSymbols(Graph* graphPtr, LineElement* lePtr, MapInfo *mapPtr)
{
Region2d exts;
Point2d *pp;
@@ -731,38 +748,40 @@ static void MapSymbols(Graph* graphPtr, LineElement* elemPtr, MapInfo *mapPtr)
count++;
}
}
- elemPtr->symbolPts.points = points;
- elemPtr->symbolPts.length = count;
- elemPtr->symbolPts.map = map;
+ lePtr->symbolPts.points = points;
+ lePtr->symbolPts.length = count;
+ lePtr->symbolPts.map = map;
}
-static void MapActiveSymbols(Graph* graphPtr, LineElement* elemPtr)
+static void MapActiveSymbols(Graph* graphPtr, LineElement* lePtr)
{
- if (elemPtr->activePts.points) {
- free(elemPtr->activePts.points);
- elemPtr->activePts.points = NULL;
+ LineElementOptions* ops = (LineElementOptions*)lePtr->ops;
+
+ if (lePtr->activePts.points) {
+ free(lePtr->activePts.points);
+ lePtr->activePts.points = NULL;
}
- if (elemPtr->activePts.map) {
- free(elemPtr->activePts.map);
- elemPtr->activePts.map = NULL;
+ if (lePtr->activePts.map) {
+ free(lePtr->activePts.map);
+ lePtr->activePts.map = NULL;
}
Region2d exts;
Blt_GraphExtents(graphPtr, &exts);
- Point2d *points = (Point2d*)malloc(sizeof(Point2d) * elemPtr->nActiveIndices);
- int* map = (int*)malloc(sizeof(int) * elemPtr->nActiveIndices);
- int np = NUMBEROFPOINTS(elemPtr);
+ Point2d *points = (Point2d*)malloc(sizeof(Point2d) * lePtr->nActiveIndices);
+ int* map = (int*)malloc(sizeof(int) * lePtr->nActiveIndices);
+ int np = NUMBEROFPOINTS(ops);
int count = 0;
- if (elemPtr->coords.x && elemPtr->coords.y) {
- for (int ii=0; ii<elemPtr->nActiveIndices; ii++) {
- int iPoint = elemPtr->activeIndices[ii];
+ if (ops->coords.x && ops->coords.y) {
+ for (int ii=0; ii<lePtr->nActiveIndices; ii++) {
+ int iPoint = lePtr->activeIndices[ii];
if (iPoint >= np)
continue;
- double x = elemPtr->coords.x->values[iPoint];
- double y = elemPtr->coords.y->values[iPoint];
- points[count] = Blt_Map2D(graphPtr, x, y, &elemPtr->axes);
+ double x = ops->coords.x->values[iPoint];
+ double y = ops->coords.y->values[iPoint];
+ points[count] = Blt_Map2D(graphPtr, x, y, &ops->axes);
map[count] = iPoint;
if (PointInRegion(&exts, points[count].x, points[count].y)) {
count++;
@@ -771,151 +790,152 @@ static void MapActiveSymbols(Graph* graphPtr, LineElement* elemPtr)
}
if (count > 0) {
- elemPtr->activePts.points = points;
- elemPtr->activePts.map = map;
+ lePtr->activePts.points = points;
+ lePtr->activePts.map = map;
}
else {
free(points);
free(map);
}
- elemPtr->activePts.length = count;
- elemPtr->flags &= ~ACTIVE_PENDING;
+ lePtr->activePts.length = count;
+ lePtr->flags &= ~ACTIVE_PENDING;
}
-static void MergePens(LineElement* elemPtr, LineStyle **styleMap)
+static void MergePens(LineElement* lePtr, LineStyle **styleMap)
{
- if (Blt_Chain_GetLength(elemPtr->stylePalette) < 2) {
- Blt_ChainLink link = Blt_Chain_FirstLink(elemPtr->stylePalette);
+ LineElementOptions* ops = (LineElementOptions*)lePtr->ops;
+
+ if (Blt_Chain_GetLength(ops->stylePalette) < 2) {
+ Blt_ChainLink link = Blt_Chain_FirstLink(ops->stylePalette);
LineStyle *stylePtr = (LineStyle*)Blt_Chain_GetValue(link);
- stylePtr->errorBarCapWidth = elemPtr->errorBarCapWidth;
- stylePtr->lines.length = elemPtr->lines.length;
- stylePtr->lines.segments = elemPtr->lines.segments;
- stylePtr->symbolPts.length = elemPtr->symbolPts.length;
- stylePtr->symbolPts.points = elemPtr->symbolPts.points;
- stylePtr->xeb.length = elemPtr->xeb.length;
- stylePtr->xeb.segments = elemPtr->xeb.segments;
- stylePtr->yeb.length = elemPtr->yeb.length;
- stylePtr->yeb.segments = elemPtr->yeb.segments;
+ stylePtr->lines.length = lePtr->lines.length;
+ stylePtr->lines.segments = lePtr->lines.segments;
+ stylePtr->symbolPts.length = lePtr->symbolPts.length;
+ stylePtr->symbolPts.points = lePtr->symbolPts.points;
+ stylePtr->xeb.length = lePtr->xeb.length;
+ stylePtr->xeb.segments = lePtr->xeb.segments;
+ stylePtr->yeb.length = lePtr->yeb.length;
+ stylePtr->yeb.segments = lePtr->yeb.segments;
return;
}
/* We have more than one style. Group line segments and points of like pen
* styles. */
- if (elemPtr->lines.length > 0) {
+ if (lePtr->lines.length > 0) {
Blt_ChainLink link;
Segment2d *sp;
int *ip;
Segment2d* segments =
- (Segment2d*)malloc(elemPtr->lines.length * sizeof(Segment2d));
- int* map = (int*)malloc(elemPtr->lines.length * sizeof(int));
+ (Segment2d*)malloc(lePtr->lines.length * sizeof(Segment2d));
+ int* map = (int*)malloc(lePtr->lines.length * sizeof(int));
sp = segments, ip = map;
- for (link = Blt_Chain_FirstLink(elemPtr->stylePalette);
+ for (link = Blt_Chain_FirstLink(ops->stylePalette);
link; link = Blt_Chain_NextLink(link)) {
LineStyle *stylePtr = (LineStyle*)Blt_Chain_GetValue(link);
stylePtr->lines.segments = sp;
- for (int i = 0; i < elemPtr->lines.length; i++) {
+ for (int i = 0; i < lePtr->lines.length; i++) {
int iData;
- iData = elemPtr->lines.map[i];
+ iData = lePtr->lines.map[i];
if (styleMap[iData] == stylePtr) {
- *sp++ = elemPtr->lines.segments[i];
+ *sp++ = lePtr->lines.segments[i];
*ip++ = iData;
}
}
stylePtr->lines.length = sp - stylePtr->lines.segments;
}
- free(elemPtr->lines.segments);
- elemPtr->lines.segments = segments;
- free(elemPtr->lines.map);
- elemPtr->lines.map = map;
+ free(lePtr->lines.segments);
+ lePtr->lines.segments = segments;
+ free(lePtr->lines.map);
+ lePtr->lines.map = map;
}
- if (elemPtr->symbolPts.length > 0) {
+ if (lePtr->symbolPts.length > 0) {
Blt_ChainLink link;
int *ip;
Point2d *pp;
Point2d* points =
- (Point2d*)malloc(elemPtr->symbolPts.length * sizeof(Point2d));
- int* map = (int*)malloc(elemPtr->symbolPts.length * sizeof(int));
+ (Point2d*)malloc(lePtr->symbolPts.length * sizeof(Point2d));
+ int* map = (int*)malloc(lePtr->symbolPts.length * sizeof(int));
pp = points, ip = map;
- for (link = Blt_Chain_FirstLink(elemPtr->stylePalette);
+ for (link = Blt_Chain_FirstLink(ops->stylePalette);
link; link = Blt_Chain_NextLink(link)) {
LineStyle *stylePtr = (LineStyle*)Blt_Chain_GetValue(link);
stylePtr->symbolPts.points = pp;
- for (int i = 0; i < elemPtr->symbolPts.length; i++) {
+ for (int i = 0; i < lePtr->symbolPts.length; i++) {
int iData;
- iData = elemPtr->symbolPts.map[i];
+ iData = lePtr->symbolPts.map[i];
if (styleMap[iData] == stylePtr) {
- *pp++ = elemPtr->symbolPts.points[i];
+ *pp++ = lePtr->symbolPts.points[i];
*ip++ = iData;
}
}
stylePtr->symbolPts.length = pp - stylePtr->symbolPts.points;
}
- free(elemPtr->symbolPts.points);
- free(elemPtr->symbolPts.map);
- elemPtr->symbolPts.points = points;
- elemPtr->symbolPts.map = map;
+ free(lePtr->symbolPts.points);
+ free(lePtr->symbolPts.map);
+ lePtr->symbolPts.points = points;
+ lePtr->symbolPts.map = map;
}
- if (elemPtr->xeb.length > 0) {
+ if (lePtr->xeb.length > 0) {
Segment2d *sp;
int *ip;
Blt_ChainLink link;
Segment2d *segments =
- (Segment2d*)malloc(elemPtr->xeb.length * sizeof(Segment2d));
- int* map = (int*)malloc(elemPtr->xeb.length * sizeof(int));
+ (Segment2d*)malloc(lePtr->xeb.length * sizeof(Segment2d));
+ int* map = (int*)malloc(lePtr->xeb.length * sizeof(int));
sp = segments, ip = map;
- for (link = Blt_Chain_FirstLink(elemPtr->stylePalette);
+ for (link = Blt_Chain_FirstLink(ops->stylePalette);
link; link = Blt_Chain_NextLink(link)) {
LineStyle *stylePtr = (LineStyle*)Blt_Chain_GetValue(link);
stylePtr->xeb.segments = sp;
- for (int i = 0; i < elemPtr->xeb.length; i++) {
+ for (int i = 0; i < lePtr->xeb.length; i++) {
int iData;
- iData = elemPtr->xeb.map[i];
+ iData = lePtr->xeb.map[i];
if (styleMap[iData] == stylePtr) {
- *sp++ = elemPtr->xeb.segments[i];
+ *sp++ = lePtr->xeb.segments[i];
*ip++ = iData;
}
}
stylePtr->xeb.length = sp - stylePtr->xeb.segments;
}
- free(elemPtr->xeb.segments);
- free(elemPtr->xeb.map);
- elemPtr->xeb.segments = segments;
- elemPtr->xeb.map = map;
+ free(lePtr->xeb.segments);
+ free(lePtr->xeb.map);
+ lePtr->xeb.segments = segments;
+ lePtr->xeb.map = map;
}
- if (elemPtr->yeb.length > 0) {
+ if (lePtr->yeb.length > 0) {
Segment2d *sp;
int *ip;
Blt_ChainLink link;
Segment2d *segments =
- (Segment2d*)malloc(elemPtr->yeb.length * sizeof(Segment2d));
- int* map = (int*)malloc(elemPtr->yeb.length * sizeof(int));
+ (Segment2d*)malloc(lePtr->yeb.length * sizeof(Segment2d));
+ int* map = (int*)malloc(lePtr->yeb.length * sizeof(int));
sp = segments, ip = map;
- for (link = Blt_Chain_FirstLink(elemPtr->stylePalette);
+ for (link = Blt_Chain_FirstLink(ops->stylePalette);
link; link = Blt_Chain_NextLink(link)) {
LineStyle *stylePtr = (LineStyle*)Blt_Chain_GetValue(link);
stylePtr->yeb.segments = sp;
- for (int i = 0; i < elemPtr->yeb.length; i++) {
+ for (int i = 0; i < lePtr->yeb.length; i++) {
int iData;
- iData = elemPtr->yeb.map[i];
+ iData = lePtr->yeb.map[i];
if (styleMap[iData] == stylePtr) {
- *sp++ = elemPtr->yeb.segments[i];
+ *sp++ = lePtr->yeb.segments[i];
*ip++ = iData;
}
}
stylePtr->yeb.length = sp - stylePtr->yeb.segments;
}
- free(elemPtr->yeb.segments);
- elemPtr->yeb.segments = segments;
- free(elemPtr->yeb.map);
- elemPtr->yeb.map = map;
+ free(lePtr->yeb.segments);
+ lePtr->yeb.segments = segments;
+ free(lePtr->yeb.map);
+ lePtr->yeb.map = map;
}
}
@@ -988,7 +1008,7 @@ static int ClipSegment(Region2d *extsPtr, int code1, int code2,
return (!inside);
}
-static void SaveTrace(LineElement* elemPtr, int start, int length,
+static void SaveTrace(LineElement* lePtr, int start, int length,
MapInfo *mapPtr)
{
int i, j;
@@ -1016,53 +1036,51 @@ static void SaveTrace(LineElement* elemPtr, int start, int length,
tracePtr->screenPts.points = screenPts;
tracePtr->screenPts.map = map;
tracePtr->start = start;
- if (elemPtr->traces == NULL) {
- elemPtr->traces = Blt_Chain_Create();
+ if (lePtr->traces == NULL) {
+ lePtr->traces = Blt_Chain_Create();
}
- Blt_Chain_Append(elemPtr->traces, tracePtr);
+ Blt_Chain_Append(lePtr->traces, tracePtr);
}
-static void FreeTraces(LineElement* elemPtr)
+static void FreeTraces(LineElement* lePtr)
{
Blt_ChainLink link;
- for (link = Blt_Chain_FirstLink(elemPtr->traces); link;
+ for (link = Blt_Chain_FirstLink(lePtr->traces); link;
link = Blt_Chain_NextLink(link)) {
bltTrace *tracePtr = (bltTrace*)Blt_Chain_GetValue(link);
free(tracePtr->screenPts.map);
free(tracePtr->screenPts.points);
free(tracePtr);
}
- Blt_Chain_Destroy(elemPtr->traces);
- elemPtr->traces = NULL;
+ Blt_Chain_Destroy(lePtr->traces);
+ lePtr->traces = NULL;
}
-static void MapTraces(Graph* graphPtr, LineElement* elemPtr, MapInfo *mapPtr)
+static void MapTraces(Graph* graphPtr, LineElement* lePtr, MapInfo *mapPtr)
{
- Point2d *p, *q;
- Region2d exts;
- int code1;
- int i;
- int start, count;
+ LineElementOptions* ops = (LineElementOptions*)lePtr->ops;
+ Region2d exts;
Blt_GraphExtents(graphPtr, &exts);
- count = 1;
- code1 = OutCode(&exts, mapPtr->screenPts);
- p = mapPtr->screenPts;
- q = p + 1;
- for (i = 1; i < mapPtr->nScreenPts; i++, p++, q++) {
- Point2d s;
- int code2;
- int broken, offscreen;
+ int count = 1;
+ int code1 = OutCode(&exts, mapPtr->screenPts);
+ Point2d* p = mapPtr->screenPts;
+ Point2d* q = p + 1;
- s.x = s.y = 0;
- code2 = OutCode(&exts, q);
+ int start;
+ int ii;
+ for (ii=1; ii<mapPtr->nScreenPts; ii++, p++, q++) {
+ Point2d s;
+ s.x = 0;
+ s.y = 0;
+ int code2 = OutCode(&exts, q);
if (code2 != 0) {
/* Save the coordinates of the last point, before clipping */
s = *q;
}
- broken = BROKEN_TRACE(elemPtr->penDir, p->x, q->x);
- offscreen = ClipSegment(&exts, code1, code2, p, q);
+ int broken = BROKEN_TRACE(ops->penDir, p->x, q->x);
+ int offscreen = ClipSegment(&exts, code1, code2, p, q);
if (broken || offscreen) {
/*
@@ -1073,11 +1091,12 @@ static void MapTraces(Graph* graphPtr, LineElement* elemPtr, MapInfo *mapPtr)
*/
if (count > 1) {
- start = i - count;
- SaveTrace(elemPtr, start, count, mapPtr);
+ start = ii - count;
+ SaveTrace(lePtr, start, count, mapPtr);
count = 1;
}
- } else {
+ }
+ else {
count++; /* Add the point to the trace. */
if (code2 != 0) {
@@ -1087,34 +1106,34 @@ static void MapTraces(Graph* graphPtr, LineElement* elemPtr, MapInfo *mapPtr)
* (before clipping) after saving the trace.
*/
- start = i - (count - 1);
- SaveTrace(elemPtr, start, count, mapPtr);
- mapPtr->screenPts[i] = s;
+ start = ii - (count - 1);
+ SaveTrace(lePtr, start, count, mapPtr);
+ mapPtr->screenPts[ii] = s;
count = 1;
}
}
code1 = code2;
}
if (count > 1) {
- start = i - count;
- SaveTrace(elemPtr, start, count, mapPtr);
+ start = ii - count;
+ SaveTrace(lePtr, start, count, mapPtr);
}
}
-static void MapFillArea(Graph* graphPtr, LineElement* elemPtr, MapInfo *mapPtr)
+static void MapFillArea(Graph* graphPtr, LineElement* lePtr, MapInfo *mapPtr)
{
- Region2d exts;
- int np;
+ LineElementOptions* ops = (LineElementOptions*)lePtr->ops;
- if (elemPtr->fillPts) {
- free(elemPtr->fillPts);
- elemPtr->fillPts = NULL;
- elemPtr->nFillPts = 0;
+ if (lePtr->fillPts) {
+ free(lePtr->fillPts);
+ lePtr->fillPts = NULL;
+ lePtr->nFillPts = 0;
}
- if (mapPtr->nScreenPts < 3) {
+ if (mapPtr->nScreenPts < 3)
return;
- }
- np = mapPtr->nScreenPts + 3;
+
+ int np = mapPtr->nScreenPts + 3;
+ Region2d exts;
Blt_GraphExtents(graphPtr, &exts);
Point2d* origPts = (Point2d*)malloc(sizeof(Point2d) * np);
@@ -1122,7 +1141,7 @@ static void MapFillArea(Graph* graphPtr, LineElement* elemPtr, MapInfo *mapPtr)
double minX;
int i;
- minX = (double)elemPtr->axes.y->screenMin;
+ minX = (double)ops->axes.y->screenMin;
for (i = 0; i < mapPtr->nScreenPts; i++) {
origPts[i].x = mapPtr->screenPts[i].x + 1;
origPts[i].y = mapPtr->screenPts[i].y;
@@ -1143,7 +1162,7 @@ static void MapFillArea(Graph* graphPtr, LineElement* elemPtr, MapInfo *mapPtr)
double maxY;
int i;
- maxY = (double)elemPtr->axes.y->bottom;
+ maxY = (double)ops->axes.y->bottom;
for (i = 0; i < mapPtr->nScreenPts; i++) {
origPts[i].x = mapPtr->screenPts[i].x + 1;
origPts[i].y = mapPtr->screenPts[i].y;
@@ -1169,67 +1188,80 @@ static void MapFillArea(Graph* graphPtr, LineElement* elemPtr, MapInfo *mapPtr)
if (np < 3) {
free(clipPts);
} else {
- elemPtr->fillPts = clipPts;
- elemPtr->nFillPts = np;
+ lePtr->fillPts = clipPts;
+ lePtr->nFillPts = np;
}
}
-static void ResetLine(LineElement* elemPtr)
+static void ResetLine(LineElement* lePtr)
{
- FreeTraces(elemPtr);
- ResetStylePalette(elemPtr->stylePalette);
- if (elemPtr->symbolPts.points) {
- free(elemPtr->symbolPts.points);
- }
- if (elemPtr->symbolPts.map) {
- free(elemPtr->symbolPts.map);
- }
- if (elemPtr->lines.segments) {
- free(elemPtr->lines.segments);
- }
- if (elemPtr->lines.map) {
- free(elemPtr->lines.map);
- }
- if (elemPtr->activePts.points) {
- free(elemPtr->activePts.points);
- }
- if (elemPtr->activePts.map) {
- free(elemPtr->activePts.map);
- }
- if (elemPtr->xeb.segments) {
- free(elemPtr->xeb.segments);
- }
- if (elemPtr->xeb.map) {
- free(elemPtr->xeb.map);
- }
- if (elemPtr->yeb.segments) {
- free(elemPtr->yeb.segments);
- }
- if (elemPtr->yeb.map) {
- free(elemPtr->yeb.map);
- }
- elemPtr->xeb.segments = elemPtr->yeb.segments = elemPtr->lines.segments = NULL;
- elemPtr->symbolPts.points = elemPtr->activePts.points = NULL;
- elemPtr->lines.map = elemPtr->symbolPts.map = elemPtr->xeb.map =
- elemPtr->yeb.map = elemPtr->activePts.map = NULL;
- elemPtr->activePts.length = elemPtr->symbolPts.length =
- elemPtr->lines.length = elemPtr->xeb.length = elemPtr->yeb.length = 0;
+ LineElementOptions* ops = (LineElementOptions*)lePtr->ops;
+
+ FreeTraces(lePtr);
+ ResetStylePalette(ops->stylePalette);
+ if (lePtr->symbolPts.points) {
+ free(lePtr->symbolPts.points);
+ lePtr->symbolPts.points = NULL;
+ }
+
+ if (lePtr->symbolPts.map)
+ free(lePtr->symbolPts.map);
+ lePtr->symbolPts.map = NULL;
+ lePtr->symbolPts.length = 0;
+
+ if (lePtr->lines.segments)
+ free(lePtr->lines.segments);
+ lePtr->lines.segments = NULL;
+ lePtr->lines.length = 0;
+
+ if (lePtr->lines.map)
+ free(lePtr->lines.map);
+ lePtr->lines.map = NULL;
+
+ if (lePtr->activePts.points)
+ free(lePtr->activePts.points);
+ lePtr->activePts.points = NULL;
+ lePtr->activePts.length = 0;
+
+ if (lePtr->activePts.map)
+ free(lePtr->activePts.map);
+ lePtr->activePts.map = NULL;
+
+ if (lePtr->xeb.segments)
+ free(lePtr->xeb.segments);
+ lePtr->xeb.segments = NULL;
+
+ if (lePtr->xeb.map)
+ free(lePtr->xeb.map);
+ lePtr->xeb.map = NULL;
+ lePtr->xeb.length = 0;
+
+ if (lePtr->yeb.segments)
+ free(lePtr->yeb.segments);
+ lePtr->yeb.segments = NULL;
+ lePtr->yeb.length = 0;
+
+ if (lePtr->yeb.map)
+ free(lePtr->yeb.map);
+ lePtr->yeb.map = NULL;
}
-static void MapErrorBars(Graph* graphPtr, LineElement* elemPtr,
+static void MapErrorBars(Graph* graphPtr, LineElement* lePtr,
LineStyle **styleMap)
{
+ LineElementOptions* ops = (LineElementOptions*)lePtr->ops;
+
Region2d exts;
Blt_GraphExtents(graphPtr, &exts);
int n =0;
- int np = NUMBEROFPOINTS(elemPtr);
- if (elemPtr->coords.x && elemPtr->coords.y) {
- if (elemPtr->xError && (elemPtr->xError->nValues > 0))
- n = MIN(elemPtr->xError->nValues, np);
+ int np = NUMBEROFPOINTS(ops);
+ if (ops->coords.x && ops->coords.y) {
+ if (ops->xError && (ops->xError->nValues > 0))
+ n = MIN(ops->xError->nValues, np);
else
- if (elemPtr->xHigh && elemPtr->xLow)
- n = MIN3(elemPtr->xHigh->nValues, elemPtr->xLow->nValues, np);
+ if (ops->xHigh && ops->xLow)
+ n = MIN3(ops->xHigh->nValues, ops->xLow->nValues, np);
}
if (n > 0) {
@@ -1246,22 +1278,22 @@ static void MapErrorBars(Graph* graphPtr, LineElement* elemPtr,
double high, low;
LineStyle *stylePtr;
- x = elemPtr->coords.x->values[i];
- y = elemPtr->coords.y->values[i];
+ x = ops->coords.x->values[i];
+ y = ops->coords.y->values[i];
stylePtr = styleMap[i];
if ((isfinite(x)) && (isfinite(y))) {
- if (elemPtr->xError->nValues > 0) {
- high = x + elemPtr->xError->values[i];
- low = x - elemPtr->xError->values[i];
+ if (ops->xError->nValues > 0) {
+ high = x + ops->xError->values[i];
+ low = x - ops->xError->values[i];
} else {
- high = elemPtr->xHigh ? elemPtr->xHigh->values[i] : 0;
- low = elemPtr->xLow ? elemPtr->xLow->values[i] : 0;
+ high = ops->xHigh ? ops->xHigh->values[i] : 0;
+ low = ops->xLow ? ops->xLow->values[i] : 0;
}
if ((isfinite(high)) && (isfinite(low))) {
Point2d p, q;
- p = Blt_Map2D(graphPtr, high, y, &elemPtr->axes);
- q = Blt_Map2D(graphPtr, low, y, &elemPtr->axes);
+ p = Blt_Map2D(graphPtr, high, y, &ops->axes);
+ q = Blt_Map2D(graphPtr, low, y, &ops->axes);
segPtr->p = p;
segPtr->q = q;
if (Blt_LineRectClip(&exts, &segPtr->p, &segPtr->q)) {
@@ -1287,18 +1319,18 @@ static void MapErrorBars(Graph* graphPtr, LineElement* elemPtr,
}
}
}
- elemPtr->xeb.segments = errorBars;
- elemPtr->xeb.length = segPtr - errorBars;
- elemPtr->xeb.map = errorToData;
+ lePtr->xeb.segments = errorBars;
+ lePtr->xeb.length = segPtr - errorBars;
+ lePtr->xeb.map = errorToData;
}
n =0;
- if (elemPtr->coords.x && elemPtr->coords.y) {
- if (elemPtr->yError && (elemPtr->yError->nValues > 0))
- n = MIN(elemPtr->yError->nValues, np);
+ if (ops->coords.x && ops->coords.y) {
+ if (ops->yError && (ops->yError->nValues > 0))
+ n = MIN(ops->yError->nValues, np);
else
- if (elemPtr->yHigh && elemPtr->yLow)
- n = MIN3(elemPtr->yHigh->nValues, elemPtr->yLow->nValues, np);
+ if (ops->yHigh && ops->yLow)
+ n = MIN3(ops->yHigh->nValues, ops->yLow->nValues, np);
}
if (n > 0) {
@@ -1315,22 +1347,22 @@ static void MapErrorBars(Graph* graphPtr, LineElement* elemPtr,
double high, low;
LineStyle *stylePtr;
- x = elemPtr->coords.x->values[i];
- y = elemPtr->coords.y->values[i];
+ x = ops->coords.x->values[i];
+ y = ops->coords.y->values[i];
stylePtr = styleMap[i];
if ((isfinite(x)) && (isfinite(y))) {
- if (elemPtr->yError->nValues > 0) {
- high = y + elemPtr->yError->values[i];
- low = y - elemPtr->yError->values[i];
+ if (ops->yError->nValues > 0) {
+ high = y + ops->yError->values[i];
+ low = y - ops->yError->values[i];
} else {
- high = elemPtr->yHigh->values[i];
- low = elemPtr->yLow->values[i];
+ high = ops->yHigh->values[i];
+ low = ops->yLow->values[i];
}
if ((isfinite(high)) && (isfinite(low))) {
Point2d p, q;
- p = Blt_Map2D(graphPtr, x, high, &elemPtr->axes);
- q = Blt_Map2D(graphPtr, x, low, &elemPtr->axes);
+ p = Blt_Map2D(graphPtr, x, high, &ops->axes);
+ q = Blt_Map2D(graphPtr, x, low, &ops->axes);
segPtr->p = p;
segPtr->q = q;
if (Blt_LineRectClip(&exts, &segPtr->p, &segPtr->q)) {
@@ -1356,35 +1388,36 @@ static void MapErrorBars(Graph* graphPtr, LineElement* elemPtr,
}
}
}
- elemPtr->yeb.segments = errorBars;
- elemPtr->yeb.length = segPtr - errorBars;
- elemPtr->yeb.map = errorToData;
+ lePtr->yeb.segments = errorBars;
+ lePtr->yeb.length = segPtr - errorBars;
+ lePtr->yeb.map = errorToData;
}
}
-static void MapLineProc(Graph* graphPtr, Element *basePtr)
+static void MapLineProc(Graph* graphPtr, Element *elemPtr)
{
- LineElement* elemPtr = (LineElement *)basePtr;
+ LineElement* lePtr = (LineElement *)elemPtr;
+ LineElementOptions* ops = (LineElementOptions*)lePtr->ops;
- ResetLine(elemPtr);
- if (!elemPtr->coords.x || !elemPtr->coords.y ||
- !elemPtr->coords.x->nValues || !elemPtr->coords.y->nValues)
+ ResetLine(lePtr);
+ if (!ops->coords.x || !ops->coords.y ||
+ !ops->coords.x->nValues || !ops->coords.y->nValues)
return;
- int np = NUMBEROFPOINTS(elemPtr);
+ int np = NUMBEROFPOINTS(ops);
MapInfo mi;
- GetScreenPoints(graphPtr, elemPtr, &mi);
- MapSymbols(graphPtr, elemPtr, &mi);
+ GetScreenPoints(graphPtr, lePtr, &mi);
+ MapSymbols(graphPtr, lePtr, &mi);
- if ((elemPtr->flags & ACTIVE_PENDING) && (elemPtr->nActiveIndices > 0))
- MapActiveSymbols(graphPtr, elemPtr);
+ if ((lePtr->flags & ACTIVE_PENDING) && (lePtr->nActiveIndices > 0))
+ MapActiveSymbols(graphPtr, lePtr);
// Map connecting line segments if they are to be displayed.
- elemPtr->smooth = elemPtr->reqSmooth;
- if ((np > 1) && (elemPtr->builtinPen.traceWidth > 0)) {
+ lePtr->smooth = ops->reqSmooth;
+ if ((np > 1) && (ops->builtinPen.traceWidth > 0)) {
// Do smoothing if necessary. This can extend the coordinate array,
// so both mi.points and mi.nPoints may change.
- switch (elemPtr->smooth) {
+ switch (lePtr->smooth) {
case PEN_SMOOTH_STEP:
GenerateSteps(&mi);
break;
@@ -1393,56 +1426,57 @@ static void MapLineProc(Graph* graphPtr, Element *basePtr)
case PEN_SMOOTH_QUADRATIC:
// Can't interpolate with less than three points
if (mi.nScreenPts < 3)
- elemPtr->smooth = PEN_SMOOTH_LINEAR;
+ lePtr->smooth = PEN_SMOOTH_LINEAR;
else
- GenerateSpline(graphPtr, elemPtr, &mi);
+ GenerateSpline(graphPtr, lePtr, &mi);
break;
case PEN_SMOOTH_CATROM:
// Can't interpolate with less than three points
if (mi.nScreenPts < 3)
- elemPtr->smooth = PEN_SMOOTH_LINEAR;
+ lePtr->smooth = PEN_SMOOTH_LINEAR;
else
- GenerateParametricSpline(graphPtr, elemPtr, &mi);
+ GenerateParametricSpline(graphPtr, lePtr, &mi);
break;
default:
break;
}
- if (elemPtr->rTolerance > 0.0) {
- ReducePoints(&mi, elemPtr->rTolerance);
+ if (ops->rTolerance > 0.0) {
+ ReducePoints(&mi, ops->rTolerance);
}
- if (elemPtr->fillBg) {
- MapFillArea(graphPtr, elemPtr, &mi);
+ if (ops->fillBg) {
+ MapFillArea(graphPtr, lePtr, &mi);
}
- MapTraces(graphPtr, elemPtr, &mi);
+ MapTraces(graphPtr, lePtr, &mi);
}
free(mi.screenPts);
free(mi.map);
// Set the symbol size of all the pen styles
- for (Blt_ChainLink link = Blt_Chain_FirstLink(elemPtr->stylePalette); link;
+ for (Blt_ChainLink link = Blt_Chain_FirstLink(ops->stylePalette); link;
link = Blt_Chain_NextLink(link)) {
LineStyle *stylePtr = (LineStyle*)Blt_Chain_GetValue(link);
LinePen* penPtr = (LinePen *)stylePtr->penPtr;
- int size = ScaleSymbol(elemPtr, penPtr->symbol.size);
+ LinePenOptions* penOps = (LinePenOptions*)penPtr->ops;
+ int size = ScaleSymbol(lePtr, penOps->symbol.size);
stylePtr->symbolSize = size;
- stylePtr->errorBarCapWidth = (penPtr->errorBarCapWidth > 0)
- ? penPtr->errorBarCapWidth : Round(size * 0.6666666);
+ stylePtr->errorBarCapWidth = (penOps->errorBarCapWidth > 0)
+ ? penOps->errorBarCapWidth : Round(size * 0.6666666);
stylePtr->errorBarCapWidth /= 2;
}
- LineStyle **styleMap = (LineStyle **)Blt_StyleMap((Element *)elemPtr);
- if (((elemPtr->yHigh && elemPtr->yHigh->nValues > 0) &&
- (elemPtr->yLow && elemPtr->yLow->nValues > 0)) ||
- ((elemPtr->xHigh && elemPtr->xHigh->nValues > 0) &&
- (elemPtr->xLow && elemPtr->xLow->nValues > 0)) ||
- (elemPtr->xError && elemPtr->xError->nValues > 0) ||
- (elemPtr->yError && elemPtr->yError->nValues > 0)) {
- MapErrorBars(graphPtr, elemPtr, styleMap);
+ LineStyle **styleMap = (LineStyle **)Blt_StyleMap((Element *)lePtr);
+ if (((ops->yHigh && ops->yHigh->nValues > 0) &&
+ (ops->yLow && ops->yLow->nValues > 0)) ||
+ ((ops->xHigh && ops->xHigh->nValues > 0) &&
+ (ops->xLow && ops->xLow->nValues > 0)) ||
+ (ops->xError && ops->xError->nValues > 0) ||
+ (ops->yError && ops->yError->nValues > 0)) {
+ MapErrorBars(graphPtr, lePtr, styleMap);
}
- MergePens(elemPtr, styleMap);
+ MergePens(lePtr, styleMap);
free(styleMap);
}
@@ -1563,9 +1597,10 @@ static double DistanceToYProc(int x, int y, Point2d *p, Point2d *q, Point2d *t)
return fabs(d);
}
-static int ClosestTrace(Graph* graphPtr, LineElement* elemPtr,
+static int ClosestTrace(Graph* graphPtr, LineElement* lePtr,
DistanceProc *distProc)
{
+ LineElementOptions* ops = (LineElementOptions*)lePtr->ops;
ClosestSearch* searchPtr = &graphPtr->search;
Blt_ChainLink link;
@@ -1576,7 +1611,7 @@ static int ClosestTrace(Graph* graphPtr, LineElement* elemPtr,
iClose = -1; /* Suppress compiler warning. */
dMin = searchPtr->dist;
closest.x = closest.y = 0; /* Suppress compiler warning. */
- for (link = Blt_Chain_FirstLink(elemPtr->traces); link;
+ for (link = Blt_Chain_FirstLink(lePtr->traces); link;
link = Blt_Chain_NextLink(link)) {
Point2d *p, *pend;
@@ -1596,100 +1631,94 @@ static int ClosestTrace(Graph* graphPtr, LineElement* elemPtr,
}
if (dMin < searchPtr->dist) {
searchPtr->dist = dMin;
- searchPtr->elemPtr = (Element *)elemPtr;
+ searchPtr->elemPtr = (Element*)lePtr;
searchPtr->index = iClose;
- searchPtr->point = Blt_InvMap2D(graphPtr, closest.x, closest.y,
- &elemPtr->axes);
- return TRUE;
+ searchPtr->point = Blt_InvMap2D(graphPtr, closest.x, closest.y, &ops->axes);
+ return 1;
}
- return FALSE;
+ return 0;
}
-static void ClosestPoint(LineElement* elemPtr, ClosestSearch *searchPtr)
+static void ClosestPoint(LineElement* lePtr, ClosestSearch *searchPtr)
{
- double dMin;
- int count, iClose;
- Point2d *pp;
+ LineElementOptions* ops = (LineElementOptions*)lePtr->ops;
- dMin = searchPtr->dist;
- iClose = 0;
+ double dMin = searchPtr->dist;
+ int iClose = 0;
- /*
- * Instead of testing each data point in graph coordinates, look at the
- * array of mapped screen coordinates. The advantages are
- * 1) only examine points that are visible (unclipped), and
- * 2) the computed distance is already in screen coordinates.
- */
- for (pp = elemPtr->symbolPts.points, count = 0;
- count < elemPtr->symbolPts.length; count++, pp++) {
- double dx, dy;
+ // Instead of testing each data point in graph coordinates, look at the
+ // array of mapped screen coordinates. The advantages are
+ // 1) only examine points that are visible (unclipped), and
+ // 2) the computed distance is already in screen coordinates.
+ int count;
+ Point2d *pp;
+ for (pp = lePtr->symbolPts.points, count = 0;
+ count < lePtr->symbolPts.length; count++, pp++) {
+ double dx = (double)(searchPtr->x - pp->x);
+ double dy = (double)(searchPtr->y - pp->y);
double d;
-
- dx = (double)(searchPtr->x - pp->x);
- dy = (double)(searchPtr->y - pp->y);
- if (searchPtr->along == SEARCH_BOTH) {
+ if (searchPtr->along == SEARCH_BOTH)
d = hypot(dx, dy);
- } else if (searchPtr->along == SEARCH_X) {
+ else if (searchPtr->along == SEARCH_X)
d = dx;
- } else if (searchPtr->along == SEARCH_Y) {
+ else if (searchPtr->along == SEARCH_Y)
d = dy;
- } else {
- /* This can't happen */
+ else
continue;
- }
+
if (d < dMin) {
- iClose = elemPtr->symbolPts.map[count];
+ iClose = lePtr->symbolPts.map[count];
dMin = d;
}
}
if (dMin < searchPtr->dist) {
- searchPtr->elemPtr = (Element *)elemPtr;
+ searchPtr->elemPtr = (Element*)lePtr;
searchPtr->dist = dMin;
searchPtr->index = iClose;
- searchPtr->point.x = elemPtr->coords.x->values[iClose];
- searchPtr->point.y = elemPtr->coords.y->values[iClose];
+ searchPtr->point.x = ops->coords.x->values[iClose];
+ searchPtr->point.y = ops->coords.y->values[iClose];
}
}
-static void GetLineExtentsProc(Element *basePtr, Region2d *extsPtr)
+static void GetLineExtentsProc(Element *elemPtr, Region2d *extsPtr)
{
- LineElement* elemPtr = (LineElement *)basePtr;
- int np;
+ LineElement* lePtr = (LineElement *)elemPtr;
+ LineElementOptions* ops = (LineElementOptions*)lePtr->ops;
extsPtr->top = extsPtr->left = DBL_MAX;
extsPtr->bottom = extsPtr->right = -DBL_MAX;
- if (!elemPtr->coords.x || !elemPtr->coords.y ||
- !elemPtr->coords.x->nValues || !elemPtr->coords.y->nValues)
+ if (!ops->coords.x || !ops->coords.y ||
+ !ops->coords.x->nValues || !ops->coords.y->nValues)
return;
- np = NUMBEROFPOINTS(elemPtr);
+ int np = NUMBEROFPOINTS(ops);
- extsPtr->right = elemPtr->coords.x->max;
- if ((elemPtr->coords.x->min <= 0.0) && (elemPtr->axes.x->logScale))
- extsPtr->left = Blt_FindElemValuesMinimum(elemPtr->coords.x, DBL_MIN);
+ extsPtr->right = ops->coords.x->max;
+ if ((ops->coords.x->min <= 0.0) && (ops->axes.x->logScale))
+ extsPtr->left = Blt_FindElemValuesMinimum(ops->coords.x, DBL_MIN);
else
- extsPtr->left = elemPtr->coords.x->min;
+ extsPtr->left = ops->coords.x->min;
- extsPtr->bottom = elemPtr->coords.y->max;
- if ((elemPtr->coords.y->min <= 0.0) && (elemPtr->axes.y->logScale))
- extsPtr->top = Blt_FindElemValuesMinimum(elemPtr->coords.y, DBL_MIN);
+ extsPtr->bottom = ops->coords.y->max;
+ if ((ops->coords.y->min <= 0.0) && (ops->axes.y->logScale))
+ extsPtr->top = Blt_FindElemValuesMinimum(ops->coords.y, DBL_MIN);
else
- extsPtr->top = elemPtr->coords.y->min;
+ extsPtr->top = ops->coords.y->min;
// Correct the data limits for error bars
- if (elemPtr->xError && elemPtr->xError->nValues > 0) {
+ if (ops->xError && ops->xError->nValues > 0) {
int i;
- np = MIN(elemPtr->xError->nValues, np);
+ np = MIN(ops->xError->nValues, np);
for (i = 0; i < np; i++) {
double x;
- x = elemPtr->coords.x->values[i] + elemPtr->xError->values[i];
+ x = ops->coords.x->values[i] + ops->xError->values[i];
if (x > extsPtr->right) {
extsPtr->right = x;
}
- x = elemPtr->coords.x->values[i] - elemPtr->xError->values[i];
- if (elemPtr->axes.x->logScale) {
+ x = ops->coords.x->values[i] - ops->xError->values[i];
+ if (ops->axes.x->logScale) {
// Mirror negative values, instead of ignoring them
if (x < 0.0)
x = -x;
@@ -1701,38 +1730,38 @@ static void GetLineExtentsProc(Element *basePtr, Region2d *extsPtr)
}
}
else {
- if (elemPtr->xHigh &&
- (elemPtr->xHigh->nValues > 0) &&
- (elemPtr->xHigh->max > extsPtr->right)) {
- extsPtr->right = elemPtr->xHigh->max;
+ if (ops->xHigh &&
+ (ops->xHigh->nValues > 0) &&
+ (ops->xHigh->max > extsPtr->right)) {
+ extsPtr->right = ops->xHigh->max;
}
- if (elemPtr->xLow && elemPtr->xLow->nValues > 0) {
+ if (ops->xLow && ops->xLow->nValues > 0) {
double left;
- if ((elemPtr->xLow->min <= 0.0) &&
- (elemPtr->axes.x->logScale))
- left = Blt_FindElemValuesMinimum(elemPtr->xLow, DBL_MIN);
+ if ((ops->xLow->min <= 0.0) &&
+ (ops->axes.x->logScale))
+ left = Blt_FindElemValuesMinimum(ops->xLow, DBL_MIN);
else
- left = elemPtr->xLow->min;
+ left = ops->xLow->min;
if (left < extsPtr->left)
extsPtr->left = left;
}
}
- if (elemPtr->yError && elemPtr->yError->nValues > 0) {
+ if (ops->yError && ops->yError->nValues > 0) {
int i;
- np = MIN(elemPtr->yError->nValues, np);
+ np = MIN(ops->yError->nValues, np);
for (i = 0; i < np; i++) {
double y;
- y = elemPtr->coords.y->values[i] + elemPtr->yError->values[i];
+ y = ops->coords.y->values[i] + ops->yError->values[i];
if (y > extsPtr->bottom) {
extsPtr->bottom = y;
}
- y = elemPtr->coords.y->values[i] - elemPtr->yError->values[i];
- if (elemPtr->axes.y->logScale) {
+ y = ops->coords.y->values[i] - ops->yError->values[i];
+ if (ops->axes.y->logScale) {
if (y < 0.0) {
y = -y; /* Mirror negative values, instead of
* ignoring them. */
@@ -1745,19 +1774,19 @@ static void GetLineExtentsProc(Element *basePtr, Region2d *extsPtr)
}
}
} else {
- if (elemPtr->yHigh &&
- (elemPtr->yHigh->nValues > 0) &&
- (elemPtr->yHigh->max > extsPtr->bottom)) {
- extsPtr->bottom = elemPtr->yHigh->max;
+ if (ops->yHigh &&
+ (ops->yHigh->nValues > 0) &&
+ (ops->yHigh->max > extsPtr->bottom)) {
+ extsPtr->bottom = ops->yHigh->max;
}
- if (elemPtr->yLow && elemPtr->yLow->nValues > 0) {
+ if (ops->yLow && ops->yLow->nValues > 0) {
double top;
- if ((elemPtr->yLow->min <= 0.0) &&
- (elemPtr->axes.y->logScale))
- top = Blt_FindElemValuesMinimum(elemPtr->yLow, DBL_MIN);
+ if ((ops->yLow->min <= 0.0) &&
+ (ops->axes.y->logScale))
+ top = Blt_FindElemValuesMinimum(ops->yLow, DBL_MIN);
else
- top = elemPtr->yLow->min;
+ top = ops->yLow->min;
if (top < extsPtr->top)
extsPtr->top = top;
@@ -1765,19 +1794,22 @@ static void GetLineExtentsProc(Element *basePtr, Region2d *extsPtr)
}
}
-static void ClosestLineProc(Graph* graphPtr, Element *basePtr)
+static void ClosestLineProc(Graph* graphPtr, Element *elemPtr)
{
+ LineElement* lePtr = (LineElement*)elemPtr;
+ LineElementOptions* ops = (LineElementOptions*)lePtr->ops;
+
ClosestSearch* searchPtr = &graphPtr->search;
- LineElement* elemPtr = (LineElement *)basePtr;
int mode = searchPtr->mode;
if (mode == SEARCH_AUTO) {
- LinePen* penPtr = NORMALPEN(elemPtr);
+ LinePen* penPtr = NORMALPEN(ops);
+ LinePenOptions* penOps = (LinePenOptions*)penPtr->ops;
mode = SEARCH_POINTS;
- if ((NUMBEROFPOINTS(elemPtr) > 1) && (penPtr->traceWidth > 0))
+ if ((NUMBEROFPOINTS(ops) > 1) && (penOps->traceWidth > 0))
mode = SEARCH_TRACES;
}
if (mode == SEARCH_POINTS)
- ClosestPoint(elemPtr, searchPtr);
+ ClosestPoint(lePtr, searchPtr);
else {
DistanceProc *distProc;
if (searchPtr->along == SEARCH_X)
@@ -1787,9 +1819,9 @@ static void ClosestLineProc(Graph* graphPtr, Element *basePtr)
else
distProc = DistanceToLineProc;
- int found = ClosestTrace(graphPtr, elemPtr, distProc);
+ int found = ClosestTrace(graphPtr, lePtr, distProc);
if ((!found) && (searchPtr->along != SEARCH_BOTH)) {
- ClosestPoint(elemPtr, searchPtr);
+ ClosestPoint(lePtr, searchPtr);
}
}
}
@@ -1810,18 +1842,20 @@ static void ClosestLineProc(Graph* graphPtr, Element *basePtr)
#define MAX_DRAWARCS(d) Blt_MaxRequestSize(d, sizeof(XArc))
static void DrawCircles(Display *display, Drawable drawable,
- LineElement* elemPtr, LinePen* penPtr,
+ LineElement* lePtr, LinePen* penPtr,
int nSymbolPts, Point2d *symbolPts, int radius)
{
+ LinePenOptions* penOps = (LinePenOptions*)penPtr->ops;
+
int count = 0;
int s = radius + radius;
XArc *arcs = (XArc*)malloc(nSymbolPts * sizeof(XArc));
- if (elemPtr->symbolInterval > 0) {
+ if (lePtr->symbolInterval > 0) {
XArc* ap = arcs;
Point2d *pp, *pend;
for (pp = symbolPts, pend = pp + nSymbolPts; pp < pend; pp++) {
- if (DRAW_SYMBOL(elemPtr)) {
+ if (DRAW_SYMBOL(lePtr)) {
ap->x = Round(pp->x) - radius;
ap->y = Round(pp->y) - radius;
ap->width = ap->height = (unsigned short)s;
@@ -1829,7 +1863,7 @@ static void DrawCircles(Display *display, Drawable drawable,
ap->angle2 = 23040;
ap++, count++;
}
- elemPtr->symbolCounter++;
+ lePtr->symbolCounter++;
}
}
else {
@@ -1849,35 +1883,37 @@ static void DrawCircles(Display *display, Drawable drawable,
int reqSize = MAX_DRAWARCS(display);
for (int ii=0; ii<count; ii+= reqSize) {
int n = ((ii + reqSize) > count) ? (count - ii) : reqSize;
- if (penPtr->symbol.fillGC)
- XFillArcs(display, drawable, penPtr->symbol.fillGC, arcs + ii, n);
+ if (penOps->symbol.fillGC)
+ XFillArcs(display, drawable, penOps->symbol.fillGC, arcs + ii, n);
- if (penPtr->symbol.outlineWidth > 0)
- XDrawArcs(display, drawable, penPtr->symbol.outlineGC, arcs + ii, n);
+ if (penOps->symbol.outlineWidth > 0)
+ XDrawArcs(display, drawable, penOps->symbol.outlineGC, arcs + ii, n);
}
free(arcs);
}
static void DrawSquares(Display *display, Drawable drawable,
- LineElement* elemPtr, LinePen* penPtr,
+ LineElement* lePtr, LinePen* penPtr,
int nSymbolPts, Point2d *symbolPts, int r)
{
+ LinePenOptions* penOps = (LinePenOptions*)penPtr->ops;
+
int count =0;
int s = r + r;
XRectangle *rectangles = (XRectangle*)malloc(nSymbolPts * sizeof(XRectangle));
- if (elemPtr->symbolInterval > 0) {
+ if (lePtr->symbolInterval > 0) {
XRectangle* rp = rectangles;
Point2d *pp, *pend;
for (pp = symbolPts, pend = pp + nSymbolPts; pp < pend; pp++) {
- if (DRAW_SYMBOL(elemPtr)) {
+ if (DRAW_SYMBOL(lePtr)) {
rp->x = Round(pp->x) - r;
rp->y = Round(pp->y) - r;
rp->width = rp->height = (unsigned short)s;
rp++, count++;
}
- elemPtr->symbolCounter++;
+ lePtr->symbolCounter++;
}
}
else {
@@ -1899,11 +1935,11 @@ static void DrawSquares(Display *display, Drawable drawable,
if (n > reqSize)
n = reqSize;
- if (penPtr->symbol.fillGC)
- XFillRectangles(display, drawable, penPtr->symbol.fillGC, rp, n);
+ if (penOps->symbol.fillGC)
+ XFillRectangles(display, drawable, penOps->symbol.fillGC, rp, n);
- if (penPtr->symbol.outlineWidth > 0)
- XDrawRectangles(display, drawable, penPtr->symbol.outlineGC, rp, n);
+ if (penOps->symbol.outlineWidth > 0)
+ XDrawRectangles(display, drawable, penOps->symbol.outlineGC, rp, n);
}
free(rectangles);
@@ -1912,14 +1948,16 @@ static void DrawSquares(Display *display, Drawable drawable,
#define SQRT_PI 1.77245385090552
#define S_RATIO 0.886226925452758
static void DrawSymbols(Graph* graphPtr, Drawable drawable,
- LineElement* elemPtr, LinePen* penPtr,
+ LineElement* lePtr, LinePen* penPtr,
int size, int nSymbolPts, Point2d *symbolPts)
{
- XPoint pattern[13]; /* Template for polygon symbols */
+ LinePenOptions* penOps = (LinePenOptions*)penPtr->ops;
+
+ XPoint pattern[13];
int count;
if (size < 3) {
- if (penPtr->symbol.fillGC) {
+ if (penOps->symbol.fillGC) {
XPoint* points = (XPoint*)malloc(nSymbolPts * sizeof(XPoint));
XPoint* xpp = points;
Point2d *pp, *endp;
@@ -1928,7 +1966,7 @@ static void DrawSymbols(Graph* graphPtr, Drawable drawable,
xpp->y = Round(pp->y);
xpp++;
}
- XDrawPoints(graphPtr->display, drawable, penPtr->symbol.fillGC,
+ XDrawPoints(graphPtr->display, drawable, penOps->symbol.fillGC,
points, nSymbolPts, CoordModeOrigin);
free(points);
}
@@ -1938,24 +1976,24 @@ static void DrawSymbols(Graph* graphPtr, Drawable drawable,
int r1 = (int)ceil(size * 0.5);
int r2 = (int)ceil(size * S_RATIO * 0.5);
- switch (penPtr->symbol.type) {
+ switch (penOps->symbol.type) {
case SYMBOL_NONE:
break;
case SYMBOL_SQUARE:
- DrawSquares(graphPtr->display, drawable, elemPtr, penPtr, nSymbolPts,
+ DrawSquares(graphPtr->display, drawable, lePtr, penPtr, nSymbolPts,
symbolPts, r2);
break;
case SYMBOL_CIRCLE:
- DrawCircles(graphPtr->display, drawable, elemPtr, penPtr, nSymbolPts,
+ DrawCircles(graphPtr->display, drawable, lePtr, penPtr, nSymbolPts,
symbolPts, r1);
break;
case SYMBOL_SPLUS:
case SYMBOL_SCROSS:
{
- if (penPtr->symbol.type == SYMBOL_SCROSS) {
+ if (penOps->symbol.type == SYMBOL_SCROSS) {
r2 = Round((double)r2 * M_SQRT1_2);
pattern[3].y = pattern[2].x = pattern[0].x = pattern[0].y = -r2;
pattern[3].x = pattern[2].y = pattern[1].y = pattern[1].x = r2;
@@ -1967,12 +2005,12 @@ static void DrawSymbols(Graph* graphPtr, Drawable drawable,
}
XSegment *segments = (XSegment*)malloc(nSymbolPts * 2 * sizeof(XSegment));
- if (elemPtr->symbolInterval > 0) {
+ if (lePtr->symbolInterval > 0) {
XSegment* sp = segments;
count = 0;
Point2d *pp, *endp;
for (pp = symbolPts, endp = pp + nSymbolPts; pp < endp; pp++) {
- if (DRAW_SYMBOL(elemPtr)) {
+ if (DRAW_SYMBOL(lePtr)) {
int rndx, rndy;
rndx = Round(pp->x), rndy = Round(pp->y);
sp->x1 = pattern[0].x + rndx;
@@ -1987,7 +2025,7 @@ static void DrawSymbols(Graph* graphPtr, Drawable drawable,
sp++;
count++;
}
- elemPtr->symbolCounter++;
+ lePtr->symbolCounter++;
}
}
else {
@@ -2015,7 +2053,7 @@ static void DrawSymbols(Graph* graphPtr, Drawable drawable,
for (int ii=0; ii<nSegs; ii+=reqSize) {
int chunk = ((ii + reqSize) > nSegs) ? (nSegs - ii) : reqSize;
XDrawSegments(graphPtr->display, drawable,
- penPtr->symbol.outlineGC, segments + ii, chunk);
+ penOps->symbol.outlineGC, segments + ii, chunk);
}
free(segments);
}
@@ -2051,7 +2089,7 @@ static void DrawSymbols(Graph* graphPtr, Drawable drawable,
pattern[11].y = pattern[10].y = pattern[7].y = pattern[6].y = d;
pattern[9].y = pattern[8].y = r2;
- if (penPtr->symbol.type == SYMBOL_CROSS) {
+ if (penOps->symbol.type == SYMBOL_CROSS) {
/* For the cross symbol, rotate the points by 45 degrees. */
for (int ii=0; ii<12; ii++) {
double dx = (double)pattern[ii].x * M_SQRT1_2;
@@ -2062,12 +2100,12 @@ static void DrawSymbols(Graph* graphPtr, Drawable drawable,
pattern[12] = pattern[0];
}
polygon = (XPoint*)malloc(nSymbolPts * 13 * sizeof(XPoint));
- if (elemPtr->symbolInterval > 0) {
+ if (lePtr->symbolInterval > 0) {
count = 0;
XPoint* xpp = polygon;
Point2d *pp, *endp;
for (pp = symbolPts, endp = pp + nSymbolPts; pp < endp; pp++) {
- if (DRAW_SYMBOL(elemPtr)) {
+ if (DRAW_SYMBOL(lePtr)) {
int rndx = Round(pp->x);
int rndy = Round(pp->y);
for (int ii=0; ii<13; ii++) {
@@ -2077,7 +2115,7 @@ static void DrawSymbols(Graph* graphPtr, Drawable drawable,
}
count++;
}
- elemPtr->symbolCounter++;
+ lePtr->symbolCounter++;
}
}
else {
@@ -2094,20 +2132,20 @@ static void DrawSymbols(Graph* graphPtr, Drawable drawable,
}
count = nSymbolPts;
}
- if (penPtr->symbol.fillGC) {
+ if (penOps->symbol.fillGC) {
int ii;
XPoint *xpp;
for (xpp = polygon, ii = 0; ii<count; ii++, xpp += 13)
XFillPolygon(graphPtr->display, drawable,
- penPtr->symbol.fillGC, xpp, 13, Complex,
+ penOps->symbol.fillGC, xpp, 13, Complex,
CoordModeOrigin);
}
- if (penPtr->symbol.outlineWidth > 0) {
+ if (penOps->symbol.outlineWidth > 0) {
int ii;
XPoint *xpp;
for (xpp = polygon, ii=0; ii<count; ii++, xpp += 13)
XDrawLines(graphPtr->display, drawable,
- penPtr->symbol.outlineGC, xpp, 13, CoordModeOrigin);
+ penOps->symbol.outlineGC, xpp, 13, CoordModeOrigin);
}
free(polygon);
}
@@ -2133,7 +2171,7 @@ static void DrawSymbols(Graph* graphPtr, Drawable drawable,
pattern[4] = pattern[0];
polygon = (XPoint*)malloc(nSymbolPts * 5 * sizeof(XPoint));
- if (elemPtr->symbolInterval > 0) {
+ if (lePtr->symbolInterval > 0) {
Point2d *pp, *endp;
XPoint *xpp;
@@ -2142,7 +2180,7 @@ static void DrawSymbols(Graph* graphPtr, Drawable drawable,
for (pp = symbolPts, endp = pp + nSymbolPts; pp < endp; pp++) {
int i;
- if (DRAW_SYMBOL(elemPtr)) {
+ if (DRAW_SYMBOL(lePtr)) {
int rndx, rndy;
rndx = Round(pp->x), rndy = Round(pp->y);
@@ -2153,7 +2191,7 @@ static void DrawSymbols(Graph* graphPtr, Drawable drawable,
}
count++;
}
- elemPtr->symbolCounter++;
+ lePtr->symbolCounter++;
}
} else {
Point2d *pp, *endp;
@@ -2173,21 +2211,21 @@ static void DrawSymbols(Graph* graphPtr, Drawable drawable,
}
count = nSymbolPts;
}
- if (penPtr->symbol.fillGC) {
+ if (penOps->symbol.fillGC) {
XPoint *xpp;
int i;
for (xpp = polygon, i = 0; i < count; i++, xpp += 5)
XFillPolygon(graphPtr->display, drawable,
- penPtr->symbol.fillGC, xpp, 5, Convex, CoordModeOrigin);
+ penOps->symbol.fillGC, xpp, 5, Convex, CoordModeOrigin);
}
- if (penPtr->symbol.outlineWidth > 0) {
+ if (penOps->symbol.outlineWidth > 0) {
XPoint *xpp;
int i;
for (xpp = polygon, i = 0; i < count; i++, xpp += 5) {
XDrawLines(graphPtr->display, drawable,
- penPtr->symbol.outlineGC, xpp, 5, CoordModeOrigin);
+ penOps->symbol.outlineGC, xpp, 5, CoordModeOrigin);
}
}
free(polygon);
@@ -2220,7 +2258,7 @@ static void DrawSymbols(Graph* graphPtr, Drawable drawable,
*
*/
- if (penPtr->symbol.type == SYMBOL_ARROW) {
+ if (penOps->symbol.type == SYMBOL_ARROW) {
pattern[3].x = pattern[0].x = 0;
pattern[3].y = pattern[0].y = h1;
pattern[1].x = b2;
@@ -2234,7 +2272,7 @@ static void DrawSymbols(Graph* graphPtr, Drawable drawable,
pattern[2].x = -b2;
}
polygon = (XPoint*)malloc(nSymbolPts * 4 * sizeof(XPoint));
- if (elemPtr->symbolInterval > 0) {
+ if (lePtr->symbolInterval > 0) {
Point2d *pp, *endp;
XPoint *xpp;
@@ -2243,7 +2281,7 @@ static void DrawSymbols(Graph* graphPtr, Drawable drawable,
for (pp = symbolPts, endp = pp + nSymbolPts; pp < endp; pp++) {
int i;
- if (DRAW_SYMBOL(elemPtr)) {
+ if (DRAW_SYMBOL(lePtr)) {
int rndx, rndy;
rndx = Round(pp->x), rndy = Round(pp->y);
@@ -2254,7 +2292,7 @@ static void DrawSymbols(Graph* graphPtr, Drawable drawable,
}
count++;
}
- elemPtr->symbolCounter++;
+ lePtr->symbolCounter++;
}
} else {
Point2d *pp, *endp;
@@ -2274,23 +2312,23 @@ static void DrawSymbols(Graph* graphPtr, Drawable drawable,
}
count = nSymbolPts;
}
- if (penPtr->symbol.fillGC) {
+ if (penOps->symbol.fillGC) {
XPoint *xpp;
int i;
xpp = polygon;
for (xpp = polygon, i = 0; i < count; i++, xpp += 4)
XFillPolygon(graphPtr->display, drawable,
- penPtr->symbol.fillGC, xpp, 4, Convex, CoordModeOrigin);
+ penOps->symbol.fillGC, xpp, 4, Convex, CoordModeOrigin);
}
- if (penPtr->symbol.outlineWidth > 0) {
+ if (penOps->symbol.outlineWidth > 0) {
XPoint *xpp;
int i;
xpp = polygon;
for (xpp = polygon, i = 0; i < count; i++, xpp += 4) {
XDrawLines(graphPtr->display, drawable,
- penPtr->symbol.outlineGC, xpp, 4, CoordModeOrigin);
+ penOps->symbol.outlineGC, xpp, 4, CoordModeOrigin);
}
}
free(polygon);
@@ -2303,7 +2341,7 @@ static void DrawSymbols(Graph* graphPtr, Drawable drawable,
double scale, sx, sy;
int dx, dy;
- Tk_SizeOfBitmap(graphPtr->display, penPtr->symbol.bitmap, &w, &h);
+ Tk_SizeOfBitmap(graphPtr->display, penOps->symbol.bitmap, &w, &h);
// Compute the size of the scaled bitmap. Stretch the bitmap to fit
// a nxn bounding box.
@@ -2313,32 +2351,32 @@ static void DrawSymbols(Graph* graphPtr, Drawable drawable,
bw = (int)(w * scale);
bh = (int)(h * scale);
- XSetClipMask(graphPtr->display, penPtr->symbol.outlineGC, None);
- if (penPtr->symbol.mask != None)
- XSetClipMask(graphPtr->display, penPtr->symbol.outlineGC,
- penPtr->symbol.mask);
+ XSetClipMask(graphPtr->display, penOps->symbol.outlineGC, None);
+ if (penOps->symbol.mask != None)
+ XSetClipMask(graphPtr->display, penOps->symbol.outlineGC,
+ penOps->symbol.mask);
- if (penPtr->symbol.fillGC == NULL)
- XSetClipMask(graphPtr->display, penPtr->symbol.outlineGC,
- penPtr->symbol.bitmap);
+ if (penOps->symbol.fillGC == NULL)
+ XSetClipMask(graphPtr->display, penOps->symbol.outlineGC,
+ penOps->symbol.bitmap);
dx = bw / 2;
dy = bh / 2;
- if (elemPtr->symbolInterval > 0) {
+ if (lePtr->symbolInterval > 0) {
Point2d *pp, *endp;
for (pp = symbolPts, endp = pp + nSymbolPts; pp < endp; pp++) {
- if (DRAW_SYMBOL(elemPtr)) {
+ if (DRAW_SYMBOL(lePtr)) {
int x = Round(pp->x) - dx;
int y = Round(pp->y) - dy;
- if ((penPtr->symbol.fillGC == NULL) ||
- (penPtr->symbol.mask != None))
+ if ((penOps->symbol.fillGC == NULL) ||
+ (penOps->symbol.mask != None))
XSetClipOrigin(graphPtr->display,
- penPtr->symbol.outlineGC, x, y);
- XCopyPlane(graphPtr->display, penPtr->symbol.bitmap, drawable,
- penPtr->symbol.outlineGC, 0, 0, bw, bh, x, y, 1);
+ penOps->symbol.outlineGC, x, y);
+ XCopyPlane(graphPtr->display, penOps->symbol.bitmap, drawable,
+ penOps->symbol.outlineGC, 0, 0, bw, bh, x, y, 1);
}
- elemPtr->symbolCounter++;
+ lePtr->symbolCounter++;
}
}
else {
@@ -2346,12 +2384,12 @@ static void DrawSymbols(Graph* graphPtr, Drawable drawable,
for (pp = symbolPts, endp = pp + nSymbolPts; pp < endp; pp++) {
int x = Round(pp->x) - dx;
int y = Round(pp->y) - dy;
- if ((penPtr->symbol.fillGC == NULL) ||
- (penPtr->symbol.mask != None))
+ if ((penOps->symbol.fillGC == NULL) ||
+ (penOps->symbol.mask != None))
XSetClipOrigin(graphPtr->display,
- penPtr->symbol.outlineGC, x, y);
- XCopyPlane(graphPtr->display, penPtr->symbol.bitmap, drawable,
- penPtr->symbol.outlineGC, 0, 0, bw, bh, x, y, 1);
+ penOps->symbol.outlineGC, x, y);
+ XCopyPlane(graphPtr->display, penOps->symbol.bitmap, drawable,
+ penOps->symbol.outlineGC, 0, 0, bw, bh, x, y, 1);
}
}
}
@@ -2360,13 +2398,15 @@ static void DrawSymbols(Graph* graphPtr, Drawable drawable,
}
static void DrawSymbolProc(Graph* graphPtr, Drawable drawable,
- Element *basePtr, int x, int y, int size)
+ Element *elemPtr, int x, int y, int size)
{
- LineElement* elemPtr = (LineElement *)basePtr;
- LinePen* penPtr;
+ LineElement* lePtr = (LineElement *)elemPtr;
+ LineElementOptions* ops = (LineElementOptions*)lePtr->ops;
+
+ LinePen* penPtr = NORMALPEN(ops);
+ LinePenOptions* penOps = (LinePenOptions*)penPtr->ops;
- penPtr = NORMALPEN(elemPtr);
- if (penPtr->traceWidth > 0) {
+ if (penOps->traceWidth > 0) {
/*
* Draw an extra line offset by one pixel from the previous to give a
* thicker appearance. This is only for the legend entry. This routine
@@ -2377,16 +2417,16 @@ static void DrawSymbolProc(Graph* graphPtr, Drawable drawable,
XDrawLine(graphPtr->display, drawable, penPtr->traceGC, x - size, y + 1,
x + size, y + 1);
}
- if (penPtr->symbol.type != SYMBOL_NONE) {
+ if (penOps->symbol.type != SYMBOL_NONE) {
Point2d point;
point.x = x, point.y = y;
- DrawSymbols(graphPtr, drawable, elemPtr, penPtr, size, 1, &point);
+ DrawSymbols(graphPtr, drawable, lePtr, penPtr, size, 1, &point);
}
}
static void DrawTraces(Graph* graphPtr, Drawable drawable,
- LineElement* elemPtr, LinePen* penPtr)
+ LineElement* lePtr, LinePen* penPtr)
{
Blt_ChainLink link;
int np;
@@ -2394,7 +2434,7 @@ static void DrawTraces(Graph* graphPtr, Drawable drawable,
np = Blt_MaxRequestSize(graphPtr->display, sizeof(XPoint)) - 1;
XPoint *points = (XPoint*)malloc((np + 1) * sizeof(XPoint));
- for (link = Blt_Chain_FirstLink(elemPtr->traces); link;
+ for (link = Blt_Chain_FirstLink(lePtr->traces); link;
link = Blt_Chain_NextLink(link)) {
XPoint *xpp;
int remaining, count;
@@ -2455,54 +2495,59 @@ static void DrawTraces(Graph* graphPtr, Drawable drawable,
}
static void DrawValues(Graph* graphPtr, Drawable drawable,
- LineElement* elemPtr, LinePen* penPtr,
+ LineElement* lePtr, LinePen* penPtr,
int length, Point2d *points, int *map)
{
+ LineElementOptions* ops = (LineElementOptions*)lePtr->ops;
+ LinePenOptions* penOps = (LinePenOptions*)penPtr->ops;
+
Point2d *pp, *endp;
double *xval, *yval;
const char* fmt;
char string[TCL_DOUBLE_SPACE * 2 + 2];
int count;
- fmt = penPtr->valueFormat;
- if (fmt == NULL) {
+ fmt = penOps->valueFormat;
+ if (fmt == NULL)
fmt = "%g";
- }
+
count = 0;
- xval = elemPtr->coords.x->values, yval = elemPtr->coords.y->values;
+ xval = ops->coords.x->values, yval = ops->coords.y->values;
// be sure to update style->gc, things might have changed
- penPtr->valueStyle.flags |= UPDATE_GC;
+ penOps->valueStyle.flags |= UPDATE_GC;
for (pp = points, endp = points + length; pp < endp; pp++) {
double x, y;
x = xval[map[count]];
y = yval[map[count]];
count++;
- if (penPtr->valueShow == SHOW_X) {
+ if (penOps->valueShow == SHOW_X) {
sprintf_s(string, TCL_DOUBLE_SPACE, fmt, x);
- } else if (penPtr->valueShow == SHOW_Y) {
+ } else if (penOps->valueShow == SHOW_Y) {
sprintf_s(string, TCL_DOUBLE_SPACE, fmt, y);
- } else if (penPtr->valueShow == SHOW_BOTH) {
+ } else if (penOps->valueShow == SHOW_BOTH) {
sprintf_s(string, TCL_DOUBLE_SPACE, fmt, x);
strcat(string, ",");
sprintf_s(string + strlen(string), TCL_DOUBLE_SPACE, fmt, y);
}
- Blt_DrawText(graphPtr->tkwin, drawable, string, &penPtr->valueStyle,
+ Blt_DrawText(graphPtr->tkwin, drawable, string, &penOps->valueStyle,
Round(pp->x), Round(pp->y));
}
}
static void DrawActiveLineProc(Graph* graphPtr, Drawable drawable,
- Element *basePtr)
+ Element *elemPtr)
{
- LineElement* elemPtr = (LineElement *)basePtr;
- LinePen* penPtr = (LinePen *)elemPtr->activePenPtr;
+ LineElement* lePtr = (LineElement *)elemPtr;
+ LineElementOptions* ops = (LineElementOptions*)lePtr->ops;
+ LinePen* penPtr = (LinePen *)ops->activePenPtr;
if (!penPtr)
return;
+ LinePenOptions* penOps = (LinePenOptions*)penPtr->ops;
- int symbolSize = ScaleSymbol(elemPtr, penPtr->symbol.size);
+ int symbolSize = ScaleSymbol(lePtr, penOps->symbol.size);
/*
* nActiveIndices
@@ -2510,151 +2555,154 @@ static void DrawActiveLineProc(Graph* graphPtr, Drawable drawable,
* < 0 All points are active.
* == 0 No points are active.
*/
- if (elemPtr->nActiveIndices > 0) {
- if (elemPtr->flags & ACTIVE_PENDING) {
- MapActiveSymbols(graphPtr, elemPtr);
- }
- if (penPtr->symbol.type != SYMBOL_NONE) {
- DrawSymbols(graphPtr, drawable, elemPtr, penPtr, symbolSize,
- elemPtr->activePts.length, elemPtr->activePts.points);
- }
- if (penPtr->valueShow != SHOW_NONE) {
- DrawValues(graphPtr, drawable, elemPtr, penPtr,
- elemPtr->activePts.length,
- elemPtr->activePts.points,
- elemPtr->activePts.map);
- }
- } else if (elemPtr->nActiveIndices < 0) {
- if (penPtr->traceWidth > 0) {
- if (elemPtr->lines.length > 0) {
+ if (lePtr->nActiveIndices > 0) {
+ if (lePtr->flags & ACTIVE_PENDING) {
+ MapActiveSymbols(graphPtr, lePtr);
+ }
+ if (penOps->symbol.type != SYMBOL_NONE) {
+ DrawSymbols(graphPtr, drawable, lePtr, penPtr, symbolSize,
+ lePtr->activePts.length, lePtr->activePts.points);
+ }
+ if (penOps->valueShow != SHOW_NONE) {
+ DrawValues(graphPtr, drawable, lePtr, penPtr,
+ lePtr->activePts.length,
+ lePtr->activePts.points,
+ lePtr->activePts.map);
+ }
+ } else if (lePtr->nActiveIndices < 0) {
+ if (penOps->traceWidth > 0) {
+ if (lePtr->lines.length > 0) {
Blt_Draw2DSegments(graphPtr->display, drawable,
- penPtr->traceGC, elemPtr->lines.segments,
- elemPtr->lines.length);
- } else if (Blt_Chain_GetLength(elemPtr->traces) > 0) {
- DrawTraces(graphPtr, drawable, elemPtr, penPtr);
+ penPtr->traceGC, lePtr->lines.segments,
+ lePtr->lines.length);
+ } else if (Blt_Chain_GetLength(lePtr->traces) > 0) {
+ DrawTraces(graphPtr, drawable, lePtr, penPtr);
}
}
- if (penPtr->symbol.type != SYMBOL_NONE) {
- DrawSymbols(graphPtr, drawable, elemPtr, penPtr, symbolSize,
- elemPtr->symbolPts.length, elemPtr->symbolPts.points);
+ if (penOps->symbol.type != SYMBOL_NONE) {
+ DrawSymbols(graphPtr, drawable, lePtr, penPtr, symbolSize,
+ lePtr->symbolPts.length, lePtr->symbolPts.points);
}
- if (penPtr->valueShow != SHOW_NONE) {
- DrawValues(graphPtr, drawable, elemPtr, penPtr,
- elemPtr->symbolPts.length, elemPtr->symbolPts.points,
- elemPtr->symbolPts.map);
+ if (penOps->valueShow != SHOW_NONE) {
+ DrawValues(graphPtr, drawable, lePtr, penPtr,
+ lePtr->symbolPts.length, lePtr->symbolPts.points,
+ lePtr->symbolPts.map);
}
}
}
static void DrawNormalLineProc(Graph* graphPtr, Drawable drawable,
- Element *basePtr)
+ Element *elemPtr)
{
- LineElement* elemPtr = (LineElement *)basePtr;
- Blt_ChainLink link;
- unsigned int count;
+ LineElement* lePtr = (LineElement *)elemPtr;
+ LineElementOptions* ops = (LineElementOptions*)lePtr->ops;
- /* Fill area under the curve */
- if (elemPtr->fillPts) {
- Point2d *endp, *pp;
+ // Fill area under the curve
+ if (lePtr->fillPts) {
+ XPoint *points = (XPoint*)malloc(sizeof(XPoint) * lePtr->nFillPts);
- XPoint *points = (XPoint*)malloc(sizeof(XPoint) * elemPtr->nFillPts);
- count = 0;
- for (pp = elemPtr->fillPts, endp = pp + elemPtr->nFillPts;
+ unsigned int count =0;
+ Point2d *endp, *pp;
+ for (pp = lePtr->fillPts, endp = pp + lePtr->nFillPts;
pp < endp; pp++) {
points[count].x = Round(pp->x);
points[count].y = Round(pp->y);
count++;
}
- if (elemPtr->fillBg) {
- Tk_Fill3DPolygon(graphPtr->tkwin, drawable,
- elemPtr->fillBg, points,
- elemPtr->nFillPts, 0, TK_RELIEF_FLAT);
- }
+ if (ops->fillBg)
+ Tk_Fill3DPolygon(graphPtr->tkwin, drawable, ops->fillBg, points,
+ lePtr->nFillPts, 0, TK_RELIEF_FLAT);
free(points);
}
- /* Lines: stripchart segments or graph traces. */
- if (elemPtr->lines.length > 0) {
- for (link = Blt_Chain_FirstLink(elemPtr->stylePalette);
+ // Lines: stripchart segments or graph traces
+ if (lePtr->lines.length > 0) {
+ for (Blt_ChainLink link = Blt_Chain_FirstLink(ops->stylePalette);
link; link = Blt_Chain_NextLink(link)) {
LineStyle *stylePtr = (LineStyle*)Blt_Chain_GetValue(link);
LinePen* penPtr = (LinePen *)stylePtr->penPtr;
+ LinePenOptions* penOps = (LinePenOptions*)penPtr->ops;
if ((stylePtr->lines.length > 0) &&
- (penPtr->errorBarLineWidth > 0)) {
+ (penOps->errorBarLineWidth > 0)) {
Blt_Draw2DSegments(graphPtr->display, drawable, penPtr->traceGC,
stylePtr->lines.segments, stylePtr->lines.length);
}
}
- } else {
- LinePen* penPtr;
+ }
+ else {
+ LinePen* penPtr = NORMALPEN(ops);
+ LinePenOptions* penOps = (LinePenOptions*)penPtr->ops;
- penPtr = NORMALPEN(elemPtr);
- if ((Blt_Chain_GetLength(elemPtr->traces) > 0) &&
- (penPtr->traceWidth > 0)) {
- DrawTraces(graphPtr, drawable, elemPtr, penPtr);
+ if ((Blt_Chain_GetLength(lePtr->traces) > 0) &&
+ (penOps->traceWidth > 0)) {
+ DrawTraces(graphPtr, drawable, lePtr, penPtr);
}
}
- if (elemPtr->reqMaxSymbols > 0) {
+ if (ops->reqMaxSymbols > 0) {
int total = 0;
- for (link = Blt_Chain_FirstLink(elemPtr->stylePalette);
+ for (Blt_ChainLink link = Blt_Chain_FirstLink(ops->stylePalette);
link; link = Blt_Chain_NextLink(link)) {
LineStyle *stylePtr = (LineStyle*)Blt_Chain_GetValue(link);
total += stylePtr->symbolPts.length;
}
- elemPtr->symbolInterval = total / elemPtr->reqMaxSymbols;
- elemPtr->symbolCounter = 0;
+ lePtr->symbolInterval = total / ops->reqMaxSymbols;
+ lePtr->symbolCounter = 0;
}
- /* Symbols, error bars, values. */
+ // Symbols, error bars, values
- count = 0;
- for (link = Blt_Chain_FirstLink(elemPtr->stylePalette); link;
+ unsigned int count =0;
+ for (Blt_ChainLink link = Blt_Chain_FirstLink(ops->stylePalette); link;
link = Blt_Chain_NextLink(link)) {
LineStyle *stylePtr = (LineStyle*)Blt_Chain_GetValue(link);
LinePen* penPtr = (LinePen *)stylePtr->penPtr;
- if ((stylePtr->xeb.length > 0) && (penPtr->errorBarShow & SHOW_X)) {
+ LinePenOptions* penOps = (LinePenOptions*)penPtr->ops;
+
+ if ((stylePtr->xeb.length > 0) && (penOps->errorBarShow & SHOW_X))
Blt_Draw2DSegments(graphPtr->display, drawable, penPtr->errorBarGC,
stylePtr->xeb.segments, stylePtr->xeb.length);
- }
- if ((stylePtr->yeb.length > 0) && (penPtr->errorBarShow & SHOW_Y)) {
+
+ if ((stylePtr->yeb.length > 0) && (penOps->errorBarShow & SHOW_Y))
Blt_Draw2DSegments(graphPtr->display, drawable, penPtr->errorBarGC,
stylePtr->yeb.segments, stylePtr->yeb.length);
- }
+
if ((stylePtr->symbolPts.length > 0) &&
- (penPtr->symbol.type != SYMBOL_NONE)) {
- DrawSymbols(graphPtr, drawable, elemPtr, penPtr,
+ (penOps->symbol.type != SYMBOL_NONE))
+ DrawSymbols(graphPtr, drawable, lePtr, penPtr,
stylePtr->symbolSize, stylePtr->symbolPts.length,
stylePtr->symbolPts.points);
- }
- if (penPtr->valueShow != SHOW_NONE) {
- DrawValues(graphPtr, drawable, elemPtr, penPtr,
+
+ if (penOps->valueShow != SHOW_NONE)
+ DrawValues(graphPtr, drawable, lePtr, penPtr,
stylePtr->symbolPts.length, stylePtr->symbolPts.points,
- elemPtr->symbolPts.map + count);
- }
+ lePtr->symbolPts.map + count);
+
count += stylePtr->symbolPts.length;
}
- elemPtr->symbolInterval = 0;
+ lePtr->symbolInterval = 0;
}
static void GetSymbolPostScriptInfo(Graph* graphPtr, Blt_Ps ps,
LinePen* penPtr, int size)
{
+ LinePenOptions* penOps = (LinePenOptions*)penPtr->ops;
+
/* Set line and foreground attributes */
- XColor* fillColor = penPtr->symbol.fillColor;
+ XColor* fillColor = penOps->symbol.fillColor;
if (!fillColor)
- fillColor = penPtr->traceColor;
+ fillColor = penOps->traceColor;
- XColor* outlineColor = penPtr->symbol.outlineColor;
+ XColor* outlineColor = penOps->symbol.outlineColor;
if (!outlineColor)
- outlineColor = penPtr->traceColor;
+ outlineColor = penOps->traceColor;
- if (penPtr->symbol.type == SYMBOL_NONE)
- Blt_Ps_XSetLineAttributes(ps, penPtr->traceColor, penPtr->traceWidth + 2,
- &penPtr->traceDashes, CapButt, JoinMiter);
+ if (penOps->symbol.type == SYMBOL_NONE)
+ Blt_Ps_XSetLineAttributes(ps, penOps->traceColor, penOps->traceWidth + 2,
+ &penOps->traceDashes, CapButt, JoinMiter);
else {
- Blt_Ps_XSetLineWidth(ps, penPtr->symbol.outlineWidth);
+ Blt_Ps_XSetLineWidth(ps, penOps->symbol.outlineWidth);
Blt_Ps_XSetDashes(ps, (Blt_Dashes *)NULL);
}
@@ -2664,7 +2712,7 @@ static void GetSymbolPostScriptInfo(Graph* graphPtr, Blt_Ps ps,
* already.
*/
Blt_Ps_Append(ps, "\n/DrawSymbolProc {\n");
- switch (penPtr->symbol.type) {
+ switch (penOps->symbol.type) {
case SYMBOL_NONE:
break; /* Do nothing */
case SYMBOL_BITMAP:
@@ -2676,24 +2724,24 @@ static void GetSymbolPostScriptInfo(Graph* graphPtr, Blt_Ps ps,
* Compute how much to scale the bitmap. Don't let the scaled
* bitmap exceed the bounding square for the symbol.
*/
- Tk_SizeOfBitmap(graphPtr->display, penPtr->symbol.bitmap, &w, &h);
+ Tk_SizeOfBitmap(graphPtr->display, penOps->symbol.bitmap, &w, &h);
sx = (double)size / (double)w;
sy = (double)size / (double)h;
scale = MIN(sx, sy);
- if (penPtr->symbol.mask != None) {
+ if (penOps->symbol.mask != None) {
Blt_Ps_VarAppend(ps, "\n % Bitmap mask is \"",
- Tk_NameOfBitmap(graphPtr->display, penPtr->symbol.mask),
+ Tk_NameOfBitmap(graphPtr->display, penOps->symbol.mask),
"\"\n\n ", NULL);
Blt_Ps_XSetBackground(ps, fillColor);
- Blt_Ps_DrawBitmap(ps, graphPtr->display, penPtr->symbol.mask,
+ Blt_Ps_DrawBitmap(ps, graphPtr->display, penOps->symbol.mask,
scale, scale);
}
Blt_Ps_VarAppend(ps, "\n % Bitmap symbol is \"",
- Tk_NameOfBitmap(graphPtr->display, penPtr->symbol.bitmap),
+ Tk_NameOfBitmap(graphPtr->display, penOps->symbol.bitmap),
"\"\n\n ", NULL);
Blt_Ps_XSetForeground(ps, outlineColor);
- Blt_Ps_DrawBitmap(ps, graphPtr->display, penPtr->symbol.bitmap,
+ Blt_Ps_DrawBitmap(ps, graphPtr->display, penOps->symbol.bitmap,
scale, scale);
}
break;
@@ -2702,7 +2750,7 @@ static void GetSymbolPostScriptInfo(Graph* graphPtr, Blt_Ps ps,
Blt_Ps_XSetBackground(ps, fillColor);
Blt_Ps_Append(ps, " gsave fill grestore\n");
- if (penPtr->symbol.outlineWidth > 0) {
+ if (penOps->symbol.outlineWidth > 0) {
Blt_Ps_Append(ps, " ");
Blt_Ps_XSetForeground(ps, outlineColor);
Blt_Ps_Append(ps, " stroke\n");
@@ -2715,6 +2763,8 @@ static void GetSymbolPostScriptInfo(Graph* graphPtr, Blt_Ps ps,
static void SymbolsToPostScript(Graph* graphPtr, Blt_Ps ps, LinePen* penPtr,
int size, int nSymbolPts, Point2d *symbolPts)
{
+ LinePenOptions* penOps = (LinePenOptions*)penPtr->ops;
+
double symbolSize;
static const char* symbolMacros[] =
{
@@ -2723,7 +2773,7 @@ static void SymbolsToPostScript(Graph* graphPtr, Blt_Ps ps, LinePen* penPtr,
GetSymbolPostScriptInfo(graphPtr, ps, penPtr, size);
symbolSize = (double)size;
- switch (penPtr->symbol.type) {
+ switch (penOps->symbol.type) {
case SYMBOL_SQUARE:
case SYMBOL_CROSS:
case SYMBOL_PLUS:
@@ -2747,30 +2797,32 @@ static void SymbolsToPostScript(Graph* graphPtr, Blt_Ps ps, LinePen* penPtr,
for (pp = symbolPts, endp = symbolPts + nSymbolPts; pp < endp; pp++) {
Blt_Ps_Format(ps, "%g %g %g %s\n", pp->x, pp->y,
- symbolSize, symbolMacros[penPtr->symbol.type]);
+ symbolSize, symbolMacros[penOps->symbol.type]);
}
}
}
static void SymbolToPostScriptProc(Graph* graphPtr, Blt_Ps ps,
- Element *basePtr, double x, double y,
+ Element *elemPtr, double x, double y,
int size)
{
- LineElement* elemPtr = (LineElement *)basePtr;
- LinePen* penPtr;
+ LineElement* lePtr = (LineElement *)elemPtr;
+ LineElementOptions* ops = (LineElementOptions*)lePtr->ops;
+
+ LinePen* penPtr = NORMALPEN(ops);
+ LinePenOptions* penOps = (LinePenOptions*)penPtr->ops;
- penPtr = NORMALPEN(elemPtr);
- if (penPtr->traceWidth > 0) {
+ if (penOps->traceWidth > 0) {
/*
* Draw an extra line offset by one pixel from the previous to give a
* thicker appearance. This is only for the legend entry. This routine
* is never called for drawing the actual line segments.
*/
- Blt_Ps_XSetLineAttributes(ps, penPtr->traceColor, penPtr->traceWidth,
- &penPtr->traceDashes, CapButt, JoinMiter);
+ Blt_Ps_XSetLineAttributes(ps, penOps->traceColor, penOps->traceWidth,
+ &penOps->traceDashes, CapButt, JoinMiter);
Blt_Ps_Format(ps, "%g %g %d Li\n", x, y, size + size);
}
- if (penPtr->symbol.type != SYMBOL_NONE) {
+ if (penOps->symbol.type != SYMBOL_NONE) {
Point2d point;
point.x = x, point.y = y;
@@ -2780,13 +2832,15 @@ static void SymbolToPostScriptProc(Graph* graphPtr, Blt_Ps ps,
static void SetLineAttributes(Blt_Ps ps, LinePen* penPtr)
{
+ LinePenOptions* penOps = (LinePenOptions*)penPtr->ops;
+
/* Set the attributes of the line (color, dashes, linewidth) */
- Blt_Ps_XSetLineAttributes(ps, penPtr->traceColor, penPtr->traceWidth,
- &penPtr->traceDashes, CapButt, JoinMiter);
- if ((LineIsDashed(penPtr->traceDashes)) &&
- (penPtr->traceOffColor)) {
+ Blt_Ps_XSetLineAttributes(ps, penOps->traceColor, penOps->traceWidth,
+ &penOps->traceDashes, CapButt, JoinMiter);
+ if ((LineIsDashed(penOps->traceDashes)) &&
+ (penOps->traceOffColor)) {
Blt_Ps_Append(ps, "/DashesProc {\n gsave\n ");
- Blt_Ps_XSetBackground(ps, penPtr->traceOffColor);
+ Blt_Ps_XSetBackground(ps, penOps->traceOffColor);
Blt_Ps_Append(ps, " ");
Blt_Ps_XSetDashes(ps, (Blt_Dashes *)NULL);
Blt_Ps_Append(ps, "stroke\n grestore\n} def\n");
@@ -2795,12 +2849,12 @@ static void SetLineAttributes(Blt_Ps ps, LinePen* penPtr)
}
}
-static void TracesToPostScript(Blt_Ps ps, LineElement* elemPtr, LinePen* penPtr)
+static void TracesToPostScript(Blt_Ps ps, LineElement* lePtr, LinePen* penPtr)
{
Blt_ChainLink link;
SetLineAttributes(ps, penPtr);
- for (link = Blt_Chain_FirstLink(elemPtr->traces); link;
+ for (link = Blt_Chain_FirstLink(lePtr->traces); link;
link = Blt_Chain_NextLink(link)) {
bltTrace *tracePtr = (bltTrace*)Blt_Chain_GetValue(link);
if (tracePtr->screenPts.length > 0) {
@@ -2812,120 +2866,123 @@ static void TracesToPostScript(Blt_Ps ps, LineElement* elemPtr, LinePen* penPtr)
}
}
-static void ValuesToPostScript(Blt_Ps ps, LineElement* elemPtr, LinePen* penPtr,
+static void ValuesToPostScript(Blt_Ps ps, LineElement* lePtr, LinePen* penPtr,
int nSymbolPts, Point2d *symbolPts,
int *pointToData)
{
- Point2d *pp, *endp;
- int count;
- char string[TCL_DOUBLE_SPACE * 2 + 2];
- const char* fmt;
-
- fmt = penPtr->valueFormat;
- if (fmt == NULL) {
+ LineElementOptions* ops = (LineElementOptions*)lePtr->ops;
+ LinePenOptions* penOps = (LinePenOptions*)penPtr->ops;
+
+ const char* fmt = penOps->valueFormat;
+ if (fmt == NULL)
fmt = "%g";
- }
- count = 0;
+
+ int count = 0;
+ Point2d *pp, *endp;
for (pp = symbolPts, endp = symbolPts + nSymbolPts; pp < endp; pp++) {
double x, y;
- x = elemPtr->coords.x->values[pointToData[count]];
- y = elemPtr->coords.y->values[pointToData[count]];
+ x = ops->coords.x->values[pointToData[count]];
+ y = ops->coords.y->values[pointToData[count]];
count++;
- if (penPtr->valueShow == SHOW_X) {
+
+ char string[TCL_DOUBLE_SPACE * 2 + 2];
+ if (penOps->valueShow == SHOW_X) {
sprintf_s(string, TCL_DOUBLE_SPACE, fmt, x);
- } else if (penPtr->valueShow == SHOW_Y) {
+ } else if (penOps->valueShow == SHOW_Y) {
sprintf_s(string, TCL_DOUBLE_SPACE, fmt, y);
- } else if (penPtr->valueShow == SHOW_BOTH) {
+ } else if (penOps->valueShow == SHOW_BOTH) {
sprintf_s(string, TCL_DOUBLE_SPACE, fmt, x);
strcat(string, ",");
sprintf_s(string + strlen(string), TCL_DOUBLE_SPACE, fmt, y);
}
- Blt_Ps_DrawText(ps, string, &penPtr->valueStyle, pp->x, pp->y);
+ Blt_Ps_DrawText(ps, string, &penOps->valueStyle, pp->x, pp->y);
}
}
static void ActiveLineToPostScriptProc(Graph* graphPtr, Blt_Ps ps,
- Element *basePtr)
+ Element *elemPtr)
{
- LineElement* elemPtr = (LineElement *)basePtr;
- LinePen* penPtr = (LinePen *)elemPtr->activePenPtr;
+ LineElement* lePtr = (LineElement *)elemPtr;
+ LineElementOptions* ops = (LineElementOptions*)lePtr->ops;
+ LinePen* penPtr = (LinePen *)ops->activePenPtr;
if (!penPtr)
return;
+ LinePenOptions* penOps = (LinePenOptions*)penPtr->ops;
- int symbolSize = ScaleSymbol(elemPtr, penPtr->symbol.size);
- if (elemPtr->nActiveIndices > 0) {
- if (elemPtr->flags & ACTIVE_PENDING) {
- MapActiveSymbols(graphPtr, elemPtr);
+ int symbolSize = ScaleSymbol(lePtr, penOps->symbol.size);
+ if (lePtr->nActiveIndices > 0) {
+ if (lePtr->flags & ACTIVE_PENDING) {
+ MapActiveSymbols(graphPtr, lePtr);
}
- if (penPtr->symbol.type != SYMBOL_NONE) {
+ if (penOps->symbol.type != SYMBOL_NONE) {
SymbolsToPostScript(graphPtr, ps, penPtr, symbolSize,
- elemPtr->activePts.length, elemPtr->activePts.points);
+ lePtr->activePts.length, lePtr->activePts.points);
}
- if (penPtr->valueShow != SHOW_NONE) {
- ValuesToPostScript(ps, elemPtr, penPtr, elemPtr->activePts.length,
- elemPtr->activePts.points, elemPtr->activePts.map);
+ if (penOps->valueShow != SHOW_NONE) {
+ ValuesToPostScript(ps, lePtr, penPtr, lePtr->activePts.length,
+ lePtr->activePts.points, lePtr->activePts.map);
}
}
- else if (elemPtr->nActiveIndices < 0) {
- if (penPtr->traceWidth > 0) {
- if (elemPtr->lines.length > 0) {
+ else if (lePtr->nActiveIndices < 0) {
+ if (penOps->traceWidth > 0) {
+ if (lePtr->lines.length > 0) {
SetLineAttributes(ps, penPtr);
- Blt_Ps_Draw2DSegments(ps, elemPtr->lines.segments,
- elemPtr->lines.length);
+ Blt_Ps_Draw2DSegments(ps, lePtr->lines.segments,
+ lePtr->lines.length);
}
- if (Blt_Chain_GetLength(elemPtr->traces) > 0) {
- TracesToPostScript(ps, elemPtr, (LinePen *)penPtr);
+ if (Blt_Chain_GetLength(lePtr->traces) > 0) {
+ TracesToPostScript(ps, lePtr, (LinePen *)penPtr);
}
}
- if (penPtr->symbol.type != SYMBOL_NONE) {
+ if (penOps->symbol.type != SYMBOL_NONE) {
SymbolsToPostScript(graphPtr, ps, penPtr, symbolSize,
- elemPtr->symbolPts.length, elemPtr->symbolPts.points);
+ lePtr->symbolPts.length, lePtr->symbolPts.points);
}
- if (penPtr->valueShow != SHOW_NONE) {
- ValuesToPostScript(ps, elemPtr, penPtr, elemPtr->symbolPts.length,
- elemPtr->symbolPts.points, elemPtr->symbolPts.map);
+ if (penOps->valueShow != SHOW_NONE) {
+ ValuesToPostScript(ps, lePtr, penPtr, lePtr->symbolPts.length,
+ lePtr->symbolPts.points, lePtr->symbolPts.map);
}
}
}
static void NormalLineToPostScriptProc(Graph* graphPtr, Blt_Ps ps,
- Element *basePtr)
+ Element *elemPtr)
{
- LineElement* elemPtr = (LineElement *)basePtr;
- Blt_ChainLink link;
- unsigned int count;
+ LineElement* lePtr = (LineElement *)elemPtr;
+ LineElementOptions* ops = (LineElementOptions*)lePtr->ops;
- /* Draw fill area */
- if (elemPtr->fillPts) {
- /* Create a path to use for both the polygon and its outline. */
+ // Draw fill area
+ if (lePtr->fillPts) {
+ // Create a path to use for both the polygon and its outline
Blt_Ps_Append(ps, "% start fill area\n");
- Blt_Ps_Polyline(ps, elemPtr->fillPts, elemPtr->nFillPts);
+ Blt_Ps_Polyline(ps, lePtr->fillPts, lePtr->nFillPts);
- /* If the background fill color was specified, draw the polygon in a
- * solid fashion with that color. */
- if (elemPtr->fillBgColor) {
- Blt_Ps_XSetBackground(ps, elemPtr->fillBgColor);
+ // If the background fill color was specified, draw the polygon in a
+ // solid fashion with that color
+ if (lePtr->fillBgColor) {
+ Blt_Ps_XSetBackground(ps, lePtr->fillBgColor);
Blt_Ps_Append(ps, "gsave fill grestore\n");
}
- Blt_Ps_XSetForeground(ps, elemPtr->fillFgColor);
- if (elemPtr->fillBg) {
+ Blt_Ps_XSetForeground(ps, ops->fillFgColor);
+ if (ops->fillBg)
Blt_Ps_Append(ps, "gsave fill grestore\n");
- /* TBA: Transparent tiling is the hard part. */
- } else {
+ else
Blt_Ps_Append(ps, "gsave fill grestore\n");
- }
+
Blt_Ps_Append(ps, "% end fill area\n");
}
- /* Draw lines (strip chart) or traces (xy graph) */
- if (elemPtr->lines.length > 0) {
- for (link = Blt_Chain_FirstLink(elemPtr->stylePalette); link;
+ // Draw lines (strip chart) or traces (xy graph)
+ if (lePtr->lines.length > 0) {
+ for (Blt_ChainLink link = Blt_Chain_FirstLink(ops->stylePalette); link;
link = Blt_Chain_NextLink(link)) {
LineStyle *stylePtr = (LineStyle*)Blt_Chain_GetValue(link);
LinePen* penPtr = (LinePen *)stylePtr->penPtr;
- if ((stylePtr->lines.length > 0) && (penPtr->traceWidth > 0)) {
+ LinePenOptions* penOps = (LinePenOptions*)penPtr->ops;
+
+ if ((stylePtr->lines.length > 0) && (penOps->traceWidth > 0)) {
SetLineAttributes(ps, penPtr);
Blt_Ps_Append(ps, "% start segments\n");
Blt_Ps_Draw2DSegments(ps, stylePtr->lines.segments,
@@ -2935,47 +2992,50 @@ static void NormalLineToPostScriptProc(Graph* graphPtr, Blt_Ps ps,
}
}
else {
- LinePen* penPtr = NORMALPEN(elemPtr);
- if ((Blt_Chain_GetLength(elemPtr->traces) > 0) &&
- (penPtr->traceWidth > 0)) {
- TracesToPostScript(ps, elemPtr, penPtr);
+ LinePen* penPtr = NORMALPEN(ops);
+ LinePenOptions* penOps = (LinePenOptions*)penPtr->ops;
+
+ if ((Blt_Chain_GetLength(lePtr->traces) > 0) &&
+ (penOps->traceWidth > 0)) {
+ TracesToPostScript(ps, lePtr, penPtr);
}
}
- /* Draw symbols, error bars, values. */
+ // Draw symbols, error bars, values
- count = 0;
- for (link = Blt_Chain_FirstLink(elemPtr->stylePalette); link;
+ unsigned int count =0;
+ for (Blt_ChainLink link = Blt_Chain_FirstLink(ops->stylePalette); link;
link = Blt_Chain_NextLink(link)) {
LineStyle *stylePtr = (LineStyle*)Blt_Chain_GetValue(link);
LinePen* penPtr = (LinePen *)stylePtr->penPtr;
- XColor* colorPtr = penPtr->errorBarColor;
+ LinePenOptions* penOps = (LinePenOptions*)penPtr->ops;
+ XColor* colorPtr = penOps->errorBarColor;
if (!colorPtr)
- colorPtr = penPtr->traceColor;
+ colorPtr = penOps->traceColor;
- if ((stylePtr->xeb.length > 0) && (penPtr->errorBarShow & SHOW_X)) {
- Blt_Ps_XSetLineAttributes(ps, colorPtr, penPtr->errorBarLineWidth,
+ if ((stylePtr->xeb.length > 0) && (penOps->errorBarShow & SHOW_X)) {
+ Blt_Ps_XSetLineAttributes(ps, colorPtr, penOps->errorBarLineWidth,
NULL, CapButt, JoinMiter);
Blt_Ps_Draw2DSegments(ps, stylePtr->xeb.segments,
stylePtr->xeb.length);
}
- if ((stylePtr->yeb.length > 0) && (penPtr->errorBarShow & SHOW_Y)) {
- Blt_Ps_XSetLineAttributes(ps, colorPtr, penPtr->errorBarLineWidth,
+ if ((stylePtr->yeb.length > 0) && (penOps->errorBarShow & SHOW_Y)) {
+ Blt_Ps_XSetLineAttributes(ps, colorPtr, penOps->errorBarLineWidth,
NULL, CapButt, JoinMiter);
Blt_Ps_Draw2DSegments(ps, stylePtr->yeb.segments,
stylePtr->yeb.length);
}
if ((stylePtr->symbolPts.length > 0) &&
- (penPtr->symbol.type != SYMBOL_NONE)) {
+ (penOps->symbol.type != SYMBOL_NONE)) {
SymbolsToPostScript(graphPtr, ps, penPtr, stylePtr->symbolSize,
stylePtr->symbolPts.length,
stylePtr->symbolPts.points);
}
- if (penPtr->valueShow != SHOW_NONE) {
- ValuesToPostScript(ps, elemPtr, penPtr, stylePtr->symbolPts.length,
+ if (penOps->valueShow != SHOW_NONE) {
+ ValuesToPostScript(ps, lePtr, penPtr, stylePtr->symbolPts.length,
stylePtr->symbolPts.points,
- elemPtr->symbolPts.map + count);
+ lePtr->symbolPts.map + count);
}
count += stylePtr->symbolPts.length;
}
diff --git a/src/bltGrElemLine.h b/src/bltGrElemLine.h
index 8d6f01c..56aa92d 100644
--- a/src/bltGrElemLine.h
+++ b/src/bltGrElemLine.h
@@ -45,6 +45,7 @@ typedef struct {
} GraphPoints;
typedef struct {
+ Element* elemPtr;
const char* label;
char** tags;
Axis2d axes;
@@ -59,19 +60,18 @@ typedef struct {
int hide;
int legendRelief;
Blt_Chain stylePalette;
-
- // derived
- LinePenOptions builtinPenOps;
+ LinePen *builtinPenPtr;
LinePen *activePenPtr;
LinePen *normalPenPtr;
+ LinePenOptions builtinPen;
+ // derived
XColor* fillFgColor;
Tk_3DBorder fillBg;
int reqMaxSymbols;
double rTolerance;
int scaleSymbols;
Smoothing reqSmooth;
- int state;
int penDir;
} LineElementOptions;
@@ -82,68 +82,30 @@ typedef struct {
Tcl_HashEntry *hashPtr;
void* ops;
- // Fields specific to elements
- const char* label;
unsigned short row;
unsigned short col;
- int legendRelief;
- Axis2d axes;
- ElemCoords coords;
- ElemValues* w;
int *activeIndices;
int nActiveIndices;
ElementProcs *procsPtr;
Tk_OptionTable optionTable;
- LinePen *activePenPtr;
- LinePen *normalPenPtr;
- LinePen *builtinPenPtr;
- Blt_Chain stylePalette;
- int scaleSymbols;
double xRange;
double yRange;
- int state;
Blt_ChainLink link;
- // The line element specific fields start here
- ElemValues* xError;
- ElemValues* yError;
- ElemValues* xHigh;
- ElemValues* xLow;
- ElemValues* yHigh;
- ElemValues* yLow;
+ // Fields specific to Line Element
LinePen builtinPen;
- int errorBarCapWidth;
-
- // Line smoothing
- Smoothing reqSmooth;
Smoothing smooth;
- double rTolerance;
-
- // Area-under-curve fill attributes
- XColor* fillFgColor;
XColor* fillBgColor;
GC fillGC;
- Tk_3DBorder fillBg;
Point2d *fillPts;
int nFillPts;
-
- // Symbol points
GraphPoints symbolPts;
-
- // Active symbol points
GraphPoints activePts;
GraphSegments xeb;
GraphSegments yeb;
-
- int reqMaxSymbols;
int symbolInterval;
int symbolCounter;
-
- // X-Y graph-specific fields
- int penDir;
Blt_Chain traces;
-
- // Stripchart-specific fields
GraphSegments lines;
} LineElement;
diff --git a/src/bltGrElemLineSpline.C b/src/bltGrElemLineSpline.C
index c8e1cb7..982ca89 100644
--- a/src/bltGrElemLineSpline.C
+++ b/src/bltGrElemLineSpline.C
@@ -787,9 +787,9 @@ Blt_QuadraticSpline(Point2d *origPts, int nOrigPts, Point2d *intpPts,
int result = QuadEval(origPts, nOrigPts, intpPts, nIntpPts, work, epsilon);
free(work);
if (result > 1) {
- return FALSE;
+ return 0;
}
- return TRUE;
+ return 1;
}
/*
@@ -847,7 +847,7 @@ Blt_NaturalSpline(Point2d *origPts, int nOrigPts, Point2d *intpPts,
if (!eq) {
free(A);
free(dx);
- return FALSE;
+ return 0;
}
eq[0].c = eq[n].c = 0.0;
for (j = n, i = n - 1; i >= 0; i--, j--) {
@@ -879,7 +879,7 @@ Blt_NaturalSpline(Point2d *origPts, int nOrigPts, Point2d *intpPts,
}
}
free(eq);
- return TRUE;
+ return 1;
}
typedef struct {
@@ -912,11 +912,11 @@ SolveCubic1(TriDiagonalMatrix A[], int n)
double m_ij, m_n, m_nn, d;
if (n < 1) {
- return FALSE; /* Dimension should be at least 1 */
+ return 0; /* Dimension should be at least 1 */
}
d = A[0][1]; /* D_{0,0} = A_{0,0} */
if (d <= 0.0) {
- return FALSE; /* A (or D) should be positive definite */
+ return 0; /* A (or D) should be positive definite */
}
m_n = A[0][0]; /* A_{0,n-1} */
m_nn = A[n - 1][1]; /* A_{n-1,n-1} */
@@ -928,7 +928,7 @@ SolveCubic1(TriDiagonalMatrix A[], int n)
m_n = -A[i][2] * m_n; /* to get C_{i+1,n-1} */
d = A[i + 1][1] - A[i][2] * m_ij; /* D_{i+1,i+1} */
if (d <= 0.0) {
- return FALSE; /* Elements of D should be positive */
+ return 0; /* Elements of D should be positive */
}
A[i + 1][1] = d;
}
@@ -937,10 +937,10 @@ SolveCubic1(TriDiagonalMatrix A[], int n)
A[n - 2][0] = m_n / d; /* C_{n-2,n-1} */
A[n - 1][1] = d = m_nn - A[n - 2][0] * m_n; /* D_{n-1,n-1} */
if (d <= 0.0) {
- return FALSE;
+ return 0;
}
}
- return TRUE;
+ return 1;
}
/*
diff --git a/src/bltGrElemOp.C b/src/bltGrElemOp.C
index d480542..2542fb0 100644
--- a/src/bltGrElemOp.C
+++ b/src/bltGrElemOp.C
@@ -89,21 +89,22 @@ static int CreateElement(Graph* graphPtr, Tcl_Interp* interp, int objc,
if (!elemPtr)
return TCL_ERROR;
+ ElementOptions* ops = (ElementOptions*)elemPtr->ops;
elemPtr->obj.graphPtr = graphPtr;
elemPtr->obj.name = Blt_Strdup(name);
// this is an option and will be freed via Tk_FreeConfigOptions
// By default an element's name and label are the same
- elemPtr->label = Tcl_Alloc(strlen(name)+1);
+ ops->label = Tcl_Alloc(strlen(name)+1);
if (name)
- strcpy((char*)elemPtr->label,(char*)name);
+ strcpy((char*)ops->label,(char*)name);
Blt_GraphSetObjectClass(&elemPtr->obj, classId);
- elemPtr->stylePalette = Blt_Chain_Create();
+ ops->stylePalette = Blt_Chain_Create();
elemPtr->hashPtr = hPtr;
Tcl_SetHashValue(hPtr, elemPtr);
- if ((Tk_InitOptions(graphPtr->interp, (char*)elemPtr, elemPtr->optionTable, graphPtr->tkwin) != TCL_OK) || (ElementObjConfigure(interp,graphPtr, elemPtr, objc-4, objv+4) != TCL_OK)) {
+ if ((Tk_InitOptions(graphPtr->interp, (char*)elemPtr->ops, elemPtr->optionTable, graphPtr->tkwin) != TCL_OK) || (ElementObjConfigure(interp, graphPtr, elemPtr, objc-4, objv+4) != TCL_OK)) {
DestroyElement(elemPtr);
return TCL_ERROR;
}
@@ -654,9 +655,11 @@ static void FreeElement(char* data)
static int GetIndex(Tcl_Interp* interp, Element* elemPtr,
Tcl_Obj *objPtr, int *indexPtr)
{
+ ElementOptions* ops = (ElementOptions*)elemPtr->ops;
+
char *string = Tcl_GetString(objPtr);
if ((*string == 'e') && (strcmp("end", string) == 0))
- *indexPtr = NUMBEROFPOINTS(elemPtr);
+ *indexPtr = NUMBEROFPOINTS(ops);
else if (Blt_ExprIntFromObj(interp, objPtr, indexPtr) != TCL_OK)
return TCL_ERROR;
diff --git a/src/bltGrElemOption.C b/src/bltGrElemOption.C
index c933e66..b7a2627 100644
--- a/src/bltGrElemOption.C
+++ b/src/bltGrElemOption.C
@@ -66,7 +66,8 @@ static int ValuesSetProc(ClientData clientData, Tcl_Interp* interp,
{
ElemValues** valuesPtrPtr = (ElemValues**)(widgRec + offset);
*(double*)savePtr = *(double*)valuesPtrPtr;
- Element* elemPtr = (Element*)widgRec;
+ ElementOptions* ops = (ElementOptions*)widgRec;
+ Element* elemPtr = ops->elemPtr;
if (!valuesPtrPtr)
return TCL_OK;
@@ -256,7 +257,8 @@ int StyleSetProc(ClientData clientData, Tcl_Interp* interp,
int offset, char* save, int flags)
{
Blt_Chain stylePalette = *(Blt_Chain*)(widgRec + offset);
- Element* elemPtr = (Element*)(widgRec);
+ ElementOptions* ops = (ElementOptions*)(widgRec);
+ Element* elemPtr = ops->elemPtr;
size_t size = (size_t)clientData;
int objc;
@@ -273,7 +275,7 @@ int StyleSetProc(ClientData clientData, Tcl_Interp* interp,
}
PenStyle* stylePtr = (PenStyle*)Blt_Chain_GetValue(link);
- stylePtr->penPtr = NORMALPEN(elemPtr);
+ stylePtr->penPtr = NORMALPEN(ops);
for (int ii = 0; ii<objc; ii++) {
link = Blt_Chain_AllocLink(size);
stylePtr = (PenStyle*)Blt_Chain_GetValue(link);
@@ -286,7 +288,6 @@ int StyleSetProc(ClientData clientData, Tcl_Interp* interp,
Blt_FreeStylePalette(stylePalette);
return TCL_ERROR;
}
-
Blt_Chain_LinkAfter(stylePalette, link, NULL);
}
diff --git a/src/bltGrHairs.C b/src/bltGrHairs.C
index c747de6..878e960 100644
--- a/src/bltGrHairs.C
+++ b/src/bltGrHairs.C
@@ -95,7 +95,7 @@ static Tk_OptionSpec optionSpecs[] = {
int Blt_CreateCrosshairs(Graph* graphPtr)
{
Crosshairs* chPtr = (Crosshairs*)calloc(1, sizeof(Crosshairs));
- chPtr->hide = TRUE;
+ chPtr->hide = 1;
chPtr->hotSpot.x = chPtr->hotSpot.y = -1;
graphPtr->crosshairs = chPtr;
@@ -248,7 +248,7 @@ static int OnOp(Graph* graphPtr, Tcl_Interp* interp,
if (chPtr->hide) {
TurnOnHairs(graphPtr, chPtr);
- chPtr->hide = FALSE;
+ chPtr->hide = 0;
}
return TCL_OK;
}
@@ -260,7 +260,7 @@ static int OffOp(Graph* graphPtr, Tcl_Interp* interp,
if (!chPtr->hide) {
TurnOffHairs(graphPtr->tkwin, chPtr);
- chPtr->hide = TRUE;
+ chPtr->hide = 1;
}
return TCL_OK;
}
@@ -306,7 +306,7 @@ static void TurnOffHairs(Tk_Window tkwin, Crosshairs *chPtr)
if (Tk_IsMapped(tkwin) && (chPtr->visible)) {
XDrawSegments(Tk_Display(tkwin), Tk_WindowId(tkwin), chPtr->gc,
chPtr->segArr, 2);
- chPtr->visible = FALSE;
+ chPtr->visible = 0;
}
}
@@ -318,7 +318,7 @@ static void TurnOnHairs(Graph* graphPtr, Crosshairs *chPtr)
}
XDrawSegments(graphPtr->display, Tk_WindowId(graphPtr->tkwin),
chPtr->gc, chPtr->segArr, 2);
- chPtr->visible = TRUE;
+ chPtr->visible = 1;
}
}
diff --git a/src/bltGrLegd.C b/src/bltGrLegd.C
index e881a3c..bb937a5 100644
--- a/src/bltGrLegd.C
+++ b/src/bltGrLegd.C
@@ -511,7 +511,7 @@ static void LegendEventProc(ClientData clientData, XEvent *eventPtr)
}
Tcl_DeleteTimerHandler(legendPtr->timerToken);
if ((legendPtr->active) && (legendPtr->flags & FOCUS)) {
- legendPtr->cursorOn = TRUE;
+ legendPtr->cursorOn = 1;
if (legendPtr->offTime != 0) {
legendPtr->timerToken = Tcl_CreateTimerHandler(legendPtr->onTime,
BlinkCursorProc,
@@ -519,7 +519,7 @@ static void LegendEventProc(ClientData clientData, XEvent *eventPtr)
}
}
else {
- legendPtr->cursorOn = FALSE;
+ legendPtr->cursorOn = 0;
legendPtr->timerToken = (Tcl_TimerToken)NULL;
}
Blt_Legend_EventuallyRedraw(graphPtr);
@@ -664,7 +664,7 @@ static int ActivateOp(Graph* graphPtr, Tcl_Interp* interp,
string = Tcl_GetString(objv[2]);
active = (string[0] == 'a') ? LABEL_ACTIVE : 0;
- redraw = FALSE;
+ redraw = 0;
for (i = 3; i < objc; i++) {
Blt_ChainLink link;
const char *pattern;
@@ -680,12 +680,12 @@ static int ActivateOp(Graph* graphPtr, Tcl_Interp* interp,
if (active) {
if ((elemPtr->flags & LABEL_ACTIVE) == 0) {
elemPtr->flags |= LABEL_ACTIVE;
- redraw = TRUE;
+ redraw = 1;
}
} else {
if (elemPtr->flags & LABEL_ACTIVE) {
elemPtr->flags &= ~LABEL_ACTIVE;
- redraw = TRUE;
+ redraw = 1;
}
}
fprintf(stderr, "legend %s(%s) %s is now %d\n",
@@ -1361,16 +1361,15 @@ static ClientData PickEntryProc(ClientData clientData, int x, int y,
for (link = Blt_Chain_FirstLink(graphPtr->elements.displayList);
link != NULL; link = Blt_Chain_NextLink(link)) {
Element* elemPtr = (Element*)Blt_Chain_GetValue(link);
- if (elemPtr->label) {
- if (count == n) {
+ ElementOptions* ops = (ElementOptions*)elemPtr->ops;
+ if (ops->label) {
+ if (count == n)
return elemPtr;
- }
count++;
}
}
- if (link) {
+ if (link)
return Blt_Chain_GetValue(link);
- }
}
}
return NULL;
@@ -1412,22 +1411,22 @@ void Blt_MapLegend(Graph* graphPtr, int plotWidth, int plotHeight)
link != NULL; link = Blt_Chain_NextLink(link)) {
unsigned int w, h;
Element* elemPtr = (Element*)Blt_Chain_GetValue(link);
- if (elemPtr->label == NULL) {
- continue; /* Element has no legend entry. */
- }
- Blt_Ts_GetExtents(&legendPtr->style, elemPtr->label, &w, &h);
- if (maxWidth < (int)w) {
+ ElementOptions* ops = (ElementOptions*)elemPtr->ops;
+
+ if (ops->label == NULL)
+ continue;
+
+ Blt_Ts_GetExtents(&legendPtr->style, ops->label, &w, &h);
+ if (maxWidth < (int)w)
maxWidth = w;
- }
- if (maxHeight < (int)h) {
+
+ if (maxHeight < (int)h)
maxHeight = h;
- }
+
nEntries++;
}
- if (nEntries == 0) {
+ if (nEntries == 0)
return; /* No visible legend entries. */
- }
-
Tk_GetFontMetrics(legendPtr->style.font, &fontMetrics);
symbolWidth = 2 * fontMetrics.ascent;
@@ -1615,9 +1614,10 @@ void Blt_DrawLegend(Graph* graphPtr, Drawable drawable)
int isSelected;
Element* elemPtr = (Element*)Blt_Chain_GetValue(link);
- if (elemPtr->label == NULL) {
- continue; /* Skip this entry */
- }
+ ElementOptions* ops = (ElementOptions*)elemPtr->ops;
+ if (ops->label == NULL)
+ continue;
+
isSelected = EntryIsSelected(legendPtr, elemPtr);
if (elemPtr->flags & LABEL_ACTIVE) {
Tk_Fill3DRectangle(tkwin, pixmap, legendPtr->activeBg,
@@ -1634,16 +1634,16 @@ void Blt_DrawLegend(Graph* graphPtr, Drawable drawable)
legendPtr->selBW, legendPtr->selRelief);
} else {
Blt_Ts_SetForeground(legendPtr->style, legendPtr->fgColor);
- if (elemPtr->legendRelief != TK_RELIEF_FLAT) {
+ if (ops->legendRelief != TK_RELIEF_FLAT) {
Tk_Fill3DRectangle(tkwin, pixmap, graphPtr->normalBg,
x, y, legendPtr->entryWidth,
legendPtr->entryHeight, legendPtr->entryBW,
- elemPtr->legendRelief);
+ ops->legendRelief);
}
}
(*elemPtr->procsPtr->drawSymbolProc) (graphPtr, pixmap, elemPtr,
x + xSymbol, y + ySymbol, symbolSize);
- Blt_DrawText(tkwin, pixmap, elemPtr->label, &legendPtr->style,
+ Blt_DrawText(tkwin, pixmap, ops->label, &legendPtr->style,
x + xLabel,
y + legendPtr->entryBW + legendPtr->iyPad);
count++;
@@ -1749,9 +1749,10 @@ void Blt_LegendToPostScript(Graph* graphPtr, Blt_Ps ps)
for (link = Blt_Chain_FirstLink(graphPtr->elements.displayList);
link != NULL; link = Blt_Chain_NextLink(link)) {
Element* elemPtr = (Element*)Blt_Chain_GetValue(link);
- if (elemPtr->label == NULL) {
- continue; /* Skip this label */
- }
+ ElementOptions* ops = (ElementOptions*)elemPtr->ops;
+ if (ops->label == NULL)
+ continue;
+
if (elemPtr->flags & LABEL_ACTIVE) {
Blt_Ts_SetForeground(legendPtr->style, legendPtr->activeFgColor);
Blt_Ps_Fill3DRectangle(ps, legendPtr->activeBg, x, y, legendPtr->entryWidth,
@@ -1759,16 +1760,16 @@ void Blt_LegendToPostScript(Graph* graphPtr, Blt_Ps ps)
legendPtr->activeRelief);
} else {
Blt_Ts_SetForeground(legendPtr->style, legendPtr->fgColor);
- if (elemPtr->legendRelief != TK_RELIEF_FLAT) {
+ if (ops->legendRelief != TK_RELIEF_FLAT) {
Blt_Ps_Draw3DRectangle(ps, graphPtr->normalBg, x, y,
legendPtr->entryWidth,
legendPtr->entryHeight, legendPtr->entryBW,
- elemPtr->legendRelief);
+ ops->legendRelief);
}
}
(*elemPtr->procsPtr->printSymbolProc) (graphPtr, ps, elemPtr,
x + xSymbol, y + ySymbol, symbolSize);
- Blt_Ps_DrawText(ps, elemPtr->label, &legendPtr->style,
+ Blt_Ps_DrawText(ps, ops->label, &legendPtr->style,
x + xLabel, y + legendPtr->entryBW + legendPtr->iyPad);
count++;
if ((count % legendPtr->nRows) > 0) {
@@ -1789,12 +1790,12 @@ static Element *GetNextRow(Graph* graphPtr, Element *focusPtr)
row = focusPtr->row + 1;
for (link = focusPtr->link; link != NULL; link = Blt_Chain_NextLink(link)) {
Element* elemPtr = (Element*)Blt_Chain_GetValue(link);
- if (elemPtr->label == NULL) {
+ ElementOptions* ops = (ElementOptions*)elemPtr->ops;
+ if (ops->label == NULL)
continue;
- }
- if ((elemPtr->col == col) && (elemPtr->row == row)) {
+
+ if ((elemPtr->col == col) && (elemPtr->row == row))
return elemPtr;
- }
}
return NULL;
}
@@ -1808,12 +1809,12 @@ static Element *GetNextColumn(Graph* graphPtr, Element *focusPtr)
row = focusPtr->row;
for (link = focusPtr->link; link != NULL; link = Blt_Chain_NextLink(link)) {
Element* elemPtr = (Element*)Blt_Chain_GetValue(link);
- if (elemPtr->label == NULL) {
+ ElementOptions* ops = (ElementOptions*)elemPtr->ops;
+ if (ops->label == NULL)
continue;
- }
- if ((elemPtr->col == col) && (elemPtr->row == row)) {
- return elemPtr; /* Don't go beyond legend boundaries. */
- }
+
+ if ((elemPtr->col == col) && (elemPtr->row == row))
+ return elemPtr;
}
return NULL;
}
@@ -1825,7 +1826,8 @@ static Element *GetPreviousRow(Graph* graphPtr, Element *focusPtr)
for (Blt_ChainLink link = focusPtr->link; link != NULL;
link = Blt_Chain_PrevLink(link)) {
Element* elemPtr = (Element*)Blt_Chain_GetValue(link);
- if (elemPtr->label == NULL)
+ ElementOptions* ops = (ElementOptions*)elemPtr->ops;
+ if (ops->label == NULL)
continue;
if ((elemPtr->col == col) && (elemPtr->row == row))
@@ -1841,7 +1843,8 @@ static Element *GetPreviousColumn(Graph* graphPtr, Element *focusPtr)
for (Blt_ChainLink link = focusPtr->link; link != NULL;
link = Blt_Chain_PrevLink(link)) {
Element* elemPtr = (Element*)Blt_Chain_GetValue(link);
- if (elemPtr->label == NULL)
+ ElementOptions* ops = (ElementOptions*)elemPtr->ops;
+ if (ops->label == NULL)
continue;
if ((elemPtr->col == col) && (elemPtr->row == row))
@@ -1854,7 +1857,8 @@ static Element *GetFirstElement(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);
- if (elemPtr->label)
+ ElementOptions* ops = (ElementOptions*)elemPtr->ops;
+ if (ops->label)
return elemPtr;
}
return NULL;
@@ -1865,7 +1869,8 @@ static Element *GetLastElement(Graph* graphPtr)
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->label)
+ ElementOptions* ops = (ElementOptions*)elemPtr->ops;
+ if (ops->label)
return elemPtr;
}
return NULL;
@@ -1888,49 +1893,50 @@ static int GetElementFromObj(Graph* graphPtr, Tcl_Obj *objPtr,
elemPtr = NULL;
last = Blt_Chain_GetLength(graphPtr->elements.displayList) - 1;
- if ((c == 'a') && (strcmp(string, "anchor") == 0)) {
+ if ((c == 'a') && (strcmp(string, "anchor") == 0))
elemPtr = legendPtr->selAnchorPtr;
- } else if ((c == 'c') && (strcmp(string, "current") == 0)) {
+ else if ((c == 'c') && (strcmp(string, "current") == 0))
elemPtr = (Element *)Blt_GetCurrentItem(legendPtr->bindTable);
- } else if ((c == 'f') && (strcmp(string, "first") == 0)) {
+ else if ((c == 'f') && (strcmp(string, "first") == 0))
elemPtr = GetFirstElement(graphPtr);
- } else if ((c == 'f') && (strcmp(string, "focus") == 0)) {
+ else if ((c == 'f') && (strcmp(string, "focus") == 0))
elemPtr = legendPtr->focusPtr;
- } else if ((c == 'l') && (strcmp(string, "last") == 0)) {
+ else if ((c == 'l') && (strcmp(string, "last") == 0))
elemPtr = GetLastElement(graphPtr);
- } else if ((c == 'e') && (strcmp(string, "end") == 0)) {
+ else if ((c == 'e') && (strcmp(string, "end") == 0))
elemPtr = GetLastElement(graphPtr);
- } else if ((c == 'n') && (strcmp(string, "next.row") == 0)) {
+ else if ((c == 'n') && (strcmp(string, "next.row") == 0))
elemPtr = GetNextRow(graphPtr, legendPtr->focusPtr);
- } else if ((c == 'n') && (strcmp(string, "next.column") == 0)) {
+ else if ((c == 'n') && (strcmp(string, "next.column") == 0))
elemPtr = GetNextColumn(graphPtr, legendPtr->focusPtr);
- } else if ((c == 'p') && (strcmp(string, "previous.row") == 0)) {
+ else if ((c == 'p') && (strcmp(string, "previous.row") == 0))
elemPtr = GetPreviousRow(graphPtr, legendPtr->focusPtr);
- } else if ((c == 'p') && (strcmp(string, "previous.column") == 0)) {
+ else if ((c == 'p') && (strcmp(string, "previous.column") == 0))
elemPtr = GetPreviousColumn(graphPtr, legendPtr->focusPtr);
- } else if ((c == 's') && (strcmp(string, "sel.first") == 0)) {
+ else if ((c == 's') && (strcmp(string, "sel.first") == 0))
elemPtr = legendPtr->selFirstPtr;
- } else if ((c == 's') && (strcmp(string, "sel.last") == 0)) {
+ else if ((c == 's') && (strcmp(string, "sel.last") == 0))
elemPtr = legendPtr->selLastPtr;
- } else if (c == '@') {
+ else if (c == '@') {
int x, y;
- if (Blt_GetXY(interp, legendPtr->tkwin, string, &x, &y) != TCL_OK) {
+ if (Blt_GetXY(interp, legendPtr->tkwin, string, &x, &y) != TCL_OK)
return TCL_ERROR;
- }
+
elemPtr = (Element *)PickEntryProc(graphPtr, x, y, NULL);
- } else {
- if (Blt_GetElement(interp, graphPtr, objPtr, &elemPtr) != TCL_OK) {
+ }
+ else {
+ if (Blt_GetElement(interp, graphPtr, objPtr, &elemPtr) != TCL_OK)
return TCL_ERROR;
- }
+
if (elemPtr->link == NULL) {
Tcl_AppendResult(interp, "bad legend index \"", string, "\"",
(char *)NULL);
return TCL_ERROR;
}
- if (elemPtr->label == NULL) {
+ ElementOptions* ops = (ElementOptions*)elemPtr->ops;
+ if (ops->label == NULL)
elemPtr = NULL;
- }
}
*elemPtrPtr = elemPtr;
return TCL_OK;
diff --git a/src/bltGrMarker.C b/src/bltGrMarker.C
index 4f5e12d..02e6f00 100644
--- a/src/bltGrMarker.C
+++ b/src/bltGrMarker.C
@@ -144,10 +144,10 @@ int Marker::regionInPolygon(Region2d *regionPtr, Point2d *points, int nPoints,
for (pp = points, pend = pp + nPoints; pp < pend; pp++) {
if ((pp->x < regionPtr->left) || (pp->x > regionPtr->right) ||
(pp->y < regionPtr->top) || (pp->y > regionPtr->bottom)) {
- return FALSE; /* One point is exterior. */
+ return 0; /* One point is exterior. */
}
}
- return TRUE;
+ return 1;
}
else {
// If any segment of the polygon clips the bounding region, the
@@ -160,7 +160,7 @@ int Marker::regionInPolygon(Region2d *regionPtr, Point2d *points, int nPoints,
p = *pp;
q = *(pp + 1);
if (Blt_LineRectClip(regionPtr, &p, &q))
- return TRUE;
+ return 1;
}
// Otherwise the polygon and rectangle are either disjoint or
diff --git a/src/bltGrMarkerPolygon.C b/src/bltGrMarkerPolygon.C
index 15f39d2..70910f1 100644
--- a/src/bltGrMarkerPolygon.C
+++ b/src/bltGrMarkerPolygon.C
@@ -273,7 +273,7 @@ void PolygonMarker::map()
}
Region2d extents;
Blt_GraphExtents(graphPtr_, &extents);
- clipped_ = TRUE;
+ clipped_ = 1;
if (ops->fill) {
Point2d* lfillPts = new Point2d[nScreenPts * 3];
int n =
diff --git a/src/bltGrMisc.C b/src/bltGrMisc.C
index 1b38d67..7f49cdf 100644
--- a/src/bltGrMisc.C
+++ b/src/bltGrMisc.C
@@ -126,7 +126,7 @@ static int ClipTest (double ds, double dr, double *t1, double *t2)
if (ds < 0.0) {
t = dr / ds;
if (t > *t2) {
- return FALSE;
+ return 0;
}
if (t > *t1) {
*t1 = t;
@@ -134,7 +134,7 @@ static int ClipTest (double ds, double dr, double *t1, double *t2)
} else if (ds > 0.0) {
t = dr / ds;
if (t < *t1) {
- return FALSE;
+ return 0;
}
if (t < *t2) {
*t2 = t;
@@ -142,10 +142,10 @@ static int ClipTest (double ds, double dr, double *t1, double *t2)
} else {
/* d = 0, so line is parallel to this clipping edge */
if (dr < 0.0) { /* Line is outside clipping edge */
- return FALSE;
+ return 0;
}
}
- return TRUE;
+ return 1;
}
/*
@@ -179,10 +179,10 @@ int Blt_LineRectClip(Region2d* regionPtr, Point2d *p, Point2d *q)
p->x += t1 * dx;
p->y += t1 * dy;
}
- return TRUE;
+ return 1;
}
}
- return FALSE;
+ return 0;
}
/*
diff --git a/src/bltGrPSOutput.C b/src/bltGrPSOutput.C
index 84b146c..5076afd 100644
--- a/src/bltGrPSOutput.C
+++ b/src/bltGrPSOutput.C
@@ -922,16 +922,16 @@ void Blt_Ps_FontName(const char *family, int flags, Tcl_DString *resultPtr)
*/
Tcl_DStringAppend(resultPtr, family, -1);
src = dest = Tcl_DStringValue(resultPtr) + len;
- upper = TRUE;
+ upper = 1;
while (*src != '\0') {
while (isspace(*src)) { /* INTL: ISO space */
src++;
- upper = TRUE;
+ upper = 1;
}
src += Tcl_UtfToUniChar(src, &ch);
if (upper) {
ch = Tcl_UniCharToUpper(ch);
- upper = FALSE;
+ upper = 0;
} else {
ch = Tcl_UniCharToLower(ch);
}
diff --git a/src/bltGrPen.h b/src/bltGrPen.h
index 06d6c2d..6dd1435 100644
--- a/src/bltGrPen.h
+++ b/src/bltGrPen.h
@@ -50,7 +50,6 @@ typedef struct {
int errorBarLineWidth;
int errorBarCapWidth;
XColor* errorBarColor;
-
int valueShow;
const char* valueFormat;
TextStyle valueStyle;
diff --git a/src/bltGrPenBar.C b/src/bltGrPenBar.C
index ca56d29..6625b24 100644
--- a/src/bltGrPenBar.C
+++ b/src/bltGrPenBar.C
@@ -31,42 +31,44 @@
static Tk_OptionSpec barPenOptionSpecs[] = {
{TK_OPTION_BORDER, "-background", "background", "Background",
- STD_NORMAL_FOREGROUND, -1, Tk_Offset(BarPen, fill),
+ STD_NORMAL_FOREGROUND, -1, Tk_Offset(BarPenOptions, fill),
TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL, -1, 0, 0, "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, -1, 0, 0, "-background", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- STD_BORDERWIDTH, -1, Tk_Offset(BarPen, borderWidth), 0, NULL, 0},
+ STD_BORDERWIDTH, -1, Tk_Offset(BarPenOptions, borderWidth), 0, NULL, 0},
{TK_OPTION_COLOR, "-errorbarcolor", "errorBarColor", "ErrorBarColor",
- NULL, -1, Tk_Offset(BarPen, errorBarColor), TK_OPTION_NULL_OK, NULL, 0},
+ NULL, -1, Tk_Offset(BarPenOptions, errorBarColor),
+ TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_PIXELS, "-errorbarwidth", "errorBarWidth","ErrorBarWidth",
- "1", -1, Tk_Offset(BarPen, errorBarLineWidth), 0, NULL, 0},
+ "1", -1, Tk_Offset(BarPenOptions, errorBarLineWidth), 0, NULL, 0},
{TK_OPTION_PIXELS, "-errorbarcap", "errorBarCap", "ErrorBarCap",
- "2", -1, Tk_Offset(BarPen, errorBarCapWidth), 0, NULL, 0},
+ "2", -1, Tk_Offset(BarPenOptions, errorBarCapWidth), 0, NULL, 0},
{TK_OPTION_SYNONYM, "-fg", NULL, NULL, NULL, -1, 0, 0, "-foreground", 0},
{TK_OPTION_SYNONYM, "-fill", NULL, NULL, NULL, -1, 0, 0, "-background", 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- STD_NORMAL_FOREGROUND, -1, Tk_Offset(BarPen, outlineColor),
+ STD_NORMAL_FOREGROUND, -1, Tk_Offset(BarPenOptions, outlineColor),
TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_SYNONYM, "-outline", NULL, NULL, NULL, -1, 0, 0, "-foreground", 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- "raised", -1, Tk_Offset(BarPen, relief), 0, NULL, 0},
+ "raised", -1, Tk_Offset(BarPenOptions, relief), 0, NULL, 0},
{TK_OPTION_STRING_TABLE, "-showerrorbars", "showErrorBars", "ShowErrorBars",
- "both", -1, Tk_Offset(BarPen, errorBarShow), 0, &fillObjOption, 0},
+ "both", -1, Tk_Offset(BarPenOptions, errorBarShow), 0, &fillObjOption, 0},
{TK_OPTION_STRING_TABLE, "-showvalues", "showValues", "ShowValues",
- "none", -1, Tk_Offset(BarPen, valueShow), 0, &fillObjOption, 0},
+ "none", -1, Tk_Offset(BarPenOptions, valueShow), 0, &fillObjOption, 0},
{TK_OPTION_BITMAP, "-stipple", "stipple", "Stipple",
- NULL, -1, Tk_Offset(BarPen, stipple), TK_OPTION_NULL_OK, NULL, 0},
+ NULL, -1, Tk_Offset(BarPenOptions, stipple), TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_ANCHOR, "-valueanchor", "valueAnchor", "ValueAnchor",
- "s", -1, Tk_Offset(BarPen, valueStyle.anchor), 0, NULL, 0},
+ "s", -1, Tk_Offset(BarPenOptions, valueStyle.anchor), 0, NULL, 0},
{TK_OPTION_COLOR, "-valuecolor", "valueColor", "ValueColor",
- STD_NORMAL_FOREGROUND, -1, Tk_Offset(BarPen, valueStyle.color), 0, NULL, 0},
+ STD_NORMAL_FOREGROUND, -1, Tk_Offset(BarPenOptions, valueStyle.color),
+ 0, NULL, 0},
{TK_OPTION_FONT, "-valuefont", "valueFont", "ValueFont",
- STD_FONT_SMALL, -1, Tk_Offset(BarPen, valueStyle.font), 0, NULL, 0},
+ STD_FONT_SMALL, -1, Tk_Offset(BarPenOptions, valueStyle.font), 0, NULL, 0},
{TK_OPTION_STRING, "-valueformat", "valueFormat", "ValueFormat",
- "%g", -1, Tk_Offset(BarPen, valueFormat), TK_OPTION_NULL_OK, NULL, 0},
+ "%g", -1, Tk_Offset(BarPenOptions, valueFormat), TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_DOUBLE, "-valuerotate", "valueRotate", "ValueRotate",
- "0", -1, Tk_Offset(BarPen, valueStyle.angle), 0, NULL, 0},
+ "0", -1, Tk_Offset(BarPenOptions, valueStyle.angle), 0, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, -1, 0, 0, NULL, 0}
};
@@ -82,88 +84,95 @@ Pen* CreateBarPen(Graph* graphPtr, const char *penName)
void InitBarPen(Graph* graphPtr, BarPen* penPtr, const char* penName)
{
+ BarPenOptions* ops = (BarPenOptions*)penPtr->ops;
+
penPtr->configProc = ConfigureBarPenProc;
penPtr->destroyProc = DestroyBarPenProc;
penPtr->classId = CID_ELEM_BAR;
penPtr->name = Blt_Strdup(penName);
- Blt_Ts_InitStyle(penPtr->valueStyle);
+ Blt_Ts_InitStyle(ops->valueStyle);
penPtr->optionTable =
Tk_CreateOptionTable(graphPtr->interp, barPenOptionSpecs);
}
-int ConfigureBarPenProc(Graph* graphPtr, Pen *basePtr)
+int ConfigureBarPenProc(Graph* graphPtr, Pen *penPtr)
{
- BarPen* penPtr = (BarPen*)basePtr;
- int screenNum = Tk_ScreenNumber(graphPtr->tkwin);
- XGCValues gcValues;
- unsigned long gcMask;
- GC newGC;
+ BarPen* bpPtr = (BarPen*)penPtr;
+ BarPenOptions* ops = (BarPenOptions*)bpPtr->ops;
// outlineGC
- gcMask = GCForeground | GCLineWidth;
- gcValues.line_width = LineWidth(penPtr->errorBarLineWidth);
-
- if (penPtr->outlineColor)
- gcValues.foreground = penPtr->outlineColor->pixel;
- else if (penPtr->fill)
- gcValues.foreground = Tk_3DBorderColor(penPtr->fill)->pixel;
-
- newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues);
- if (penPtr->outlineGC)
- Tk_FreeGC(graphPtr->display, penPtr->outlineGC);
- penPtr->outlineGC = newGC;
-
- newGC = NULL;
- if (penPtr->stipple != None) {
- // Handle old-style -stipple specially
- gcMask = GCForeground | GCBackground | GCFillStyle | GCStipple;
- gcValues.foreground = BlackPixel(graphPtr->display, screenNum);
- gcValues.background = WhitePixel(graphPtr->display, screenNum);
- if (penPtr->fill)
- gcValues.foreground = Tk_3DBorderColor(penPtr->fill)->pixel;
- else if (penPtr->outlineColor)
- gcValues.foreground = penPtr->outlineColor->pixel;
-
- gcValues.stipple = penPtr->stipple;
- gcValues.fill_style = FillStippled;
- newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues);
+ {
+ unsigned long gcMask = GCForeground | GCLineWidth;
+ XGCValues gcValues;
+ gcValues.line_width = LineWidth(ops->errorBarLineWidth);
+ if (ops->outlineColor)
+ gcValues.foreground = ops->outlineColor->pixel;
+ else if (ops->fill)
+ gcValues.foreground = Tk_3DBorderColor(ops->fill)->pixel;
+ GC newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues);
+ if (bpPtr->outlineGC)
+ Tk_FreeGC(graphPtr->display, bpPtr->outlineGC);
+ bpPtr->outlineGC = newGC;
+ }
+
+ // fillGC
+ {
+ GC newGC = NULL;
+ if (ops->stipple != None) {
+ // Handle old-style -stipple specially
+ unsigned long gcMask =
+ GCForeground | GCBackground | GCFillStyle | GCStipple;
+ XGCValues gcValues;
+ int screenNum = Tk_ScreenNumber(graphPtr->tkwin);
+ gcValues.foreground = BlackPixel(graphPtr->display, screenNum);
+ gcValues.background = WhitePixel(graphPtr->display, screenNum);
+ if (ops->fill)
+ gcValues.foreground = Tk_3DBorderColor(ops->fill)->pixel;
+ else if (ops->outlineColor)
+ gcValues.foreground = ops->outlineColor->pixel;
+ gcValues.stipple = ops->stipple;
+ gcValues.fill_style = FillStippled;
+ newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues);
+ }
+ if (bpPtr->fillGC)
+ Tk_FreeGC(graphPtr->display, bpPtr->fillGC);
+ bpPtr->fillGC = newGC;
}
- if (penPtr->fillGC)
- Tk_FreeGC(graphPtr->display, penPtr->fillGC);
- penPtr->fillGC = newGC;
// errorBarGC
- gcMask = GCForeground | GCLineWidth;
- XColor* colorPtr = penPtr->errorBarColor;
- if (!colorPtr)
- colorPtr = penPtr->outlineColor;
- gcValues.foreground = colorPtr->pixel;
- gcValues.line_width = LineWidth(penPtr->errorBarLineWidth);
- newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues);
- if (penPtr->errorBarGC)
- Tk_FreeGC(graphPtr->display, penPtr->errorBarGC);
- penPtr->errorBarGC = newGC;
+ {
+ unsigned long gcMask = GCForeground | GCLineWidth;
+ XColor* colorPtr = ops->errorBarColor;
+ if (!colorPtr)
+ colorPtr = ops->outlineColor;
+ XGCValues gcValues;
+ gcValues.foreground = colorPtr->pixel;
+ gcValues.line_width = LineWidth(ops->errorBarLineWidth);
+ GC newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues);
+ if (bpPtr->errorBarGC)
+ Tk_FreeGC(graphPtr->display, bpPtr->errorBarGC);
+ bpPtr->errorBarGC = newGC;
+ }
return TCL_OK;
}
-void DestroyBarPenProc(Graph* graphPtr, Pen* basePtr)
+void DestroyBarPenProc(Graph* graphPtr, Pen* penPtr)
{
- BarPen* penPtr = (BarPen*)basePtr;
-
- Blt_Ts_FreeStyle(graphPtr->display, &penPtr->valueStyle);
- if (penPtr->outlineGC)
- Tk_FreeGC(graphPtr->display, penPtr->outlineGC);
-
- if (penPtr->fillGC)
- Tk_FreeGC(graphPtr->display, penPtr->fillGC);
-
- if (penPtr->errorBarGC)
- Tk_FreeGC(graphPtr->display, penPtr->errorBarGC);
-
- Tk_FreeConfigOptions((char*)penPtr, penPtr->optionTable, graphPtr->tkwin);
+ BarPen* bpPtr = (BarPen*)penPtr;
+ BarPenOptions* ops = (BarPenOptions*)bpPtr->ops;
+
+ Blt_Ts_FreeStyle(graphPtr->display, &ops->valueStyle);
+ if (bpPtr->outlineGC)
+ Tk_FreeGC(graphPtr->display, bpPtr->outlineGC);
+ if (bpPtr->fillGC)
+ Tk_FreeGC(graphPtr->display, bpPtr->fillGC);
+ if (bpPtr->errorBarGC)
+ Tk_FreeGC(graphPtr->display, bpPtr->errorBarGC);
+
+ Tk_FreeConfigOptions((char*)bpPtr, bpPtr->optionTable, graphPtr->tkwin);
}
diff --git a/src/bltGrPenBar.h b/src/bltGrPenBar.h
index 41cbc84..fca03de 100644
--- a/src/bltGrPenBar.h
+++ b/src/bltGrPenBar.h
@@ -42,7 +42,6 @@ typedef struct {
int errorBarLineWidth;
int errorBarCapWidth;
XColor* errorBarColor;
-
int valueShow;
const char *valueFormat;
TextStyle valueStyle;
@@ -52,7 +51,6 @@ typedef struct {
int borderWidth;
int relief;
Pixmap stipple;
-
} BarPenOptions;
typedef struct {
@@ -68,26 +66,9 @@ typedef struct {
void* ops;
int manageOptions;
- // Barchart specific pen fields start here
- XColor* outlineColor;
- Tk_3DBorder fill;
- int borderWidth;
- int relief;
- Pixmap stipple;
GC fillGC;
GC outlineGC;
-
- // Error bar attributes
- int errorBarShow;
- int errorBarLineWidth;
- int errorBarCapWidth;
- XColor* errorBarColor;
GC errorBarGC;
-
- // Show value attributes
- int valueShow;
- const char *valueFormat;
- TextStyle valueStyle;
} BarPen;
extern Pen* CreateBarPen(Graph* graphPtr, const char *penName);
diff --git a/src/bltGrPenLine.C b/src/bltGrPenLine.C
index 900cfd6..1e4a49e 100644
--- a/src/bltGrPenLine.C
+++ b/src/bltGrPenLine.C
@@ -151,45 +151,51 @@ static Tcl_Obj* SymbolGetProc(ClientData clientData, Tk_Window tkwin,
static Tk_OptionSpec linePenOptionSpecs[] = {
{TK_OPTION_COLOR, "-color", "color", "Color",
- STD_NORMAL_FOREGROUND, -1, Tk_Offset(LinePen, traceColor), 0, NULL, 0},
+ STD_NORMAL_FOREGROUND, -1, Tk_Offset(LinePenOptions, traceColor),
+ 0, NULL, 0},
{TK_OPTION_CUSTOM, "-dashes", "dashes", "Dashes",
- NULL, -1, Tk_Offset(LinePen, traceDashes),
+ NULL, -1, Tk_Offset(LinePenOptions, traceDashes),
TK_OPTION_NULL_OK, &dashesObjOption, 0},
{TK_OPTION_COLOR, "-errorbarcolor", "errorBarColor", "ErrorBarColor",
- NULL, -1, Tk_Offset(LinePen, errorBarColor), TK_OPTION_NULL_OK, NULL, 0},
+ NULL, -1, Tk_Offset(LinePenOptions, errorBarColor),
+ TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_PIXELS, "-errorbarwidth", "errorBarWidth", "ErrorBarWidth",
- "1", -1, Tk_Offset(LinePen, errorBarLineWidth), 0, NULL, 0},
+ "1", -1, Tk_Offset(LinePenOptions, errorBarLineWidth), 0, NULL, 0},
{TK_OPTION_PIXELS, "-errorbarcap", "errorBarCap", "ErrorBarCap",
- "2", -1, Tk_Offset(LinePen, errorBarCapWidth), 0, NULL, 0},
+ "2", -1, Tk_Offset(LinePenOptions, errorBarCapWidth), 0, NULL, 0},
{TK_OPTION_COLOR, "-fill", "fill", "Fill",
- NULL, -1, Tk_Offset(LinePen, symbol.fillColor), TK_OPTION_NULL_OK, NULL, 0},
+ NULL, -1, Tk_Offset(LinePenOptions, symbol.fillColor),
+ TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_PIXELS, "-linewidth", "lineWidth", "LineWidth",
- "1", -1, Tk_Offset(LinePen, traceWidth), 0, NULL, 0},
+ "1", -1, Tk_Offset(LinePenOptions, traceWidth), 0, NULL, 0},
{TK_OPTION_COLOR, "-offdash", "offDash", "OffDash",
- NULL, -1, Tk_Offset(LinePen, traceOffColor), TK_OPTION_NULL_OK, NULL, 0},
+ NULL, -1, Tk_Offset(LinePenOptions, traceOffColor),
+ TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_COLOR, "-outline", "outline", "Outline",
- NULL, -1, Tk_Offset(LinePen, symbol.outlineColor),
+ NULL, -1, Tk_Offset(LinePenOptions, symbol.outlineColor),
TK_OPTION_NULL_OK, NULL,0},
{TK_OPTION_PIXELS, "-outlinewidth", "outlineWidth", "OutlineWidth",
- "1", -1, Tk_Offset(LinePen, symbol.outlineWidth), 0, NULL, 0},
+ "1", -1, Tk_Offset(LinePenOptions, symbol.outlineWidth), 0, NULL, 0},
{TK_OPTION_PIXELS, "-pixels", "pixels", "Pixels",
- "0.1i", -1, Tk_Offset(LinePen, symbol.size), 0, NULL, 0},
+ "0.1i", -1, Tk_Offset(LinePenOptions, symbol.size), 0, NULL, 0},
{TK_OPTION_STRING_TABLE, "-showerrorbars", "showErrorBars", "ShowErrorBars",
- "both", -1, Tk_Offset(LinePen, errorBarShow), 0, &fillObjOption, 0},
+ "both", -1, Tk_Offset(LinePenOptions, errorBarShow), 0, &fillObjOption, 0},
{TK_OPTION_STRING_TABLE, "-showvalues", "showValues", "ShowValues",
- "none", -1, Tk_Offset(LinePen, valueShow), 0, &fillObjOption, 0},
+ "none", -1, Tk_Offset(LinePenOptions, valueShow), 0, &fillObjOption, 0},
{TK_OPTION_CUSTOM, "-symbol", "symbol", "Symbol",
- "none", -1, Tk_Offset(LinePen, symbol), 0, &symbolObjOption, 0},
+ "none", -1, Tk_Offset(LinePenOptions, symbol), 0, &symbolObjOption, 0},
{TK_OPTION_ANCHOR, "-valueanchor", "valueAnchor", "ValueAnchor",
- "s", -1, Tk_Offset(LinePen, valueStyle.anchor), 0, NULL, 0},
+ "s", -1, Tk_Offset(LinePenOptions, valueStyle.anchor), 0, NULL, 0},
{TK_OPTION_COLOR, "-valuecolor", "valueColor", "ValueColor",
- STD_NORMAL_FOREGROUND, -1, Tk_Offset(LinePen, valueStyle.color), 0, NULL, 0},
+ STD_NORMAL_FOREGROUND, -1, Tk_Offset(LinePenOptions, valueStyle.color),
+ 0, NULL, 0},
{TK_OPTION_FONT, "-valuefont", "valueFont", "ValueFont",
- STD_FONT_SMALL, -1, Tk_Offset(LinePen, valueStyle.font), 0, NULL, 0},
+ STD_FONT_SMALL, -1, Tk_Offset(LinePenOptions, valueStyle.font), 0, NULL, 0},
{TK_OPTION_STRING, "-valueformat", "valueFormat", "ValueFormat",
- "%g", -1, Tk_Offset(LinePen, valueFormat), TK_OPTION_NULL_OK, NULL, 0},
+ "%g", -1, Tk_Offset(LinePenOptions, valueFormat),
+ TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_DOUBLE, "-valuerotate", "valueRotate", "ValueRotate",
- "0", -1, Tk_Offset(LinePen, valueStyle.angle), 0, NULL, 0},
+ "0", -1, Tk_Offset(LinePenOptions, valueStyle.angle), 0, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, -1, 0, 0, NULL, 0}
};
@@ -205,151 +211,163 @@ Pen* CreateLinePen(Graph* graphPtr, const char* penName)
void InitLinePen(Graph* graphPtr, LinePen* penPtr, const char* penName)
{
+ LinePenOptions* ops = (LinePenOptions*)penPtr->ops;
+
penPtr->configProc = ConfigureLinePenProc;
penPtr->destroyProc = DestroyLinePenProc;
penPtr->classId = CID_ELEM_LINE;
penPtr->name = Blt_Strdup(penName);
- Blt_Ts_InitStyle(penPtr->valueStyle);
- penPtr->symbol.bitmap = None;
- penPtr->symbol.mask = None;
- penPtr->symbol.type = SYMBOL_NONE;
+ Blt_Ts_InitStyle(ops->valueStyle);
+ ops->symbol.bitmap = None;
+ ops->symbol.mask = None;
+ ops->symbol.type = SYMBOL_NONE;
penPtr->optionTable =
Tk_CreateOptionTable(graphPtr->interp, linePenOptionSpecs);
}
-int ConfigureLinePenProc(Graph* graphPtr, Pen* basePtr)
+int ConfigureLinePenProc(Graph* graphPtr, Pen* penPtr)
{
- LinePen* lpPtr = (LinePen*)basePtr;
+ LinePen* lpPtr = (LinePen*)penPtr;
+ LinePenOptions* ops = (LinePenOptions*)lpPtr->ops;
// symbol outline
- unsigned long gcMask = (GCLineWidth | GCForeground);
- XColor* colorPtr = lpPtr->symbol.outlineColor;
- if (!colorPtr)
- colorPtr = lpPtr->traceColor;
-
- XGCValues gcValues;
- gcValues.foreground = colorPtr->pixel;
- if (lpPtr->symbol.type == SYMBOL_BITMAP) {
- colorPtr = lpPtr->symbol.fillColor;
+ {
+ unsigned long gcMask = (GCLineWidth | GCForeground);
+ XColor* colorPtr = ops->symbol.outlineColor;
if (!colorPtr)
- colorPtr = lpPtr->traceColor;
-
- if (colorPtr) {
- gcValues.background = colorPtr->pixel;
- gcMask |= GCBackground;
- if (lpPtr->symbol.mask != None) {
- gcValues.clip_mask = lpPtr->symbol.mask;
+ colorPtr = ops->traceColor;
+ XGCValues gcValues;
+ gcValues.foreground = colorPtr->pixel;
+ if (ops->symbol.type == SYMBOL_BITMAP) {
+ colorPtr = ops->symbol.fillColor;
+ if (!colorPtr)
+ colorPtr = ops->traceColor;
+
+ if (colorPtr) {
+ gcValues.background = colorPtr->pixel;
+ gcMask |= GCBackground;
+ if (ops->symbol.mask != None) {
+ gcValues.clip_mask = ops->symbol.mask;
+ gcMask |= GCClipMask;
+ }
+ }
+ else {
+ gcValues.clip_mask = ops->symbol.bitmap;
gcMask |= GCClipMask;
}
}
- else {
- gcValues.clip_mask = lpPtr->symbol.bitmap;
- gcMask |= GCClipMask;
- }
+ gcValues.line_width = LineWidth(ops->symbol.outlineWidth);
+ GC newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues);
+ if (ops->symbol.outlineGC)
+ Tk_FreeGC(graphPtr->display, ops->symbol.outlineGC);
+ ops->symbol.outlineGC = newGC;
}
- gcValues.line_width = LineWidth(lpPtr->symbol.outlineWidth);
- GC newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues);
- if (lpPtr->symbol.outlineGC)
- Tk_FreeGC(graphPtr->display, lpPtr->symbol.outlineGC);
- lpPtr->symbol.outlineGC = newGC;
// symbol fill
- gcMask = (GCLineWidth | GCForeground);
- colorPtr = lpPtr->symbol.fillColor;
- if (!colorPtr)
- colorPtr = lpPtr->traceColor;
-
- newGC = NULL;
- if (colorPtr) {
- gcValues.foreground = colorPtr->pixel;
- newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues);
+ {
+ unsigned long gcMask = (GCLineWidth | GCForeground);
+ XColor* colorPtr = ops->symbol.fillColor;
+ if (!colorPtr)
+ colorPtr = ops->traceColor;
+ GC newGC = NULL;
+ XGCValues gcValues;
+ if (colorPtr) {
+ gcValues.foreground = colorPtr->pixel;
+ newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues);
+ }
+ if (ops->symbol.fillGC)
+ Tk_FreeGC(graphPtr->display, ops->symbol.fillGC);
+ ops->symbol.fillGC = newGC;
}
- if (lpPtr->symbol.fillGC)
- Tk_FreeGC(graphPtr->display, lpPtr->symbol.fillGC);
- lpPtr->symbol.fillGC = newGC;
// trace
- gcMask = (GCLineWidth | GCForeground | GCLineStyle | GCCapStyle |
- GCJoinStyle);
- gcValues.cap_style = CapButt;
- gcValues.join_style = JoinRound;
- gcValues.line_style = LineSolid;
- gcValues.line_width = LineWidth(lpPtr->traceWidth);
-
- gcValues.foreground = lpPtr->traceColor->pixel;
- colorPtr = lpPtr->traceOffColor;
- if (colorPtr) {
- gcMask |= GCBackground;
- gcValues.background = colorPtr->pixel;
- }
- if (LineIsDashed(lpPtr->traceDashes)) {
- gcValues.line_width = lpPtr->traceWidth;
- gcValues.line_style = !colorPtr ? LineOnOffDash : LineDoubleDash;
- }
- newGC = Blt_GetPrivateGC(graphPtr->tkwin, gcMask, &gcValues);
- if (lpPtr->traceGC)
- Blt_FreePrivateGC(graphPtr->display, lpPtr->traceGC);
+ {
+ unsigned long gcMask =
+ (GCLineWidth | GCForeground | GCLineStyle | GCCapStyle | GCJoinStyle);
+ XGCValues gcValues;
+ gcValues.cap_style = CapButt;
+ gcValues.join_style = JoinRound;
+ gcValues.line_style = LineSolid;
+ gcValues.line_width = LineWidth(ops->traceWidth);
+
+ gcValues.foreground = ops->traceColor->pixel;
+ XColor* colorPtr = ops->traceOffColor;
+ if (colorPtr) {
+ gcMask |= GCBackground;
+ gcValues.background = colorPtr->pixel;
+ }
+ if (LineIsDashed(ops->traceDashes)) {
+ gcValues.line_width = ops->traceWidth;
+ gcValues.line_style = !colorPtr ? LineOnOffDash : LineDoubleDash;
+ }
+ GC newGC = Blt_GetPrivateGC(graphPtr->tkwin, gcMask, &gcValues);
+ if (lpPtr->traceGC)
+ Blt_FreePrivateGC(graphPtr->display, lpPtr->traceGC);
- if (LineIsDashed(lpPtr->traceDashes)) {
- lpPtr->traceDashes.offset = lpPtr->traceDashes.values[0] / 2;
- Blt_SetDashes(graphPtr->display, newGC, &lpPtr->traceDashes);
+ if (LineIsDashed(ops->traceDashes)) {
+ ops->traceDashes.offset = ops->traceDashes.values[0] / 2;
+ Blt_SetDashes(graphPtr->display, newGC, &ops->traceDashes);
+ }
+ lpPtr->traceGC = newGC;
}
- lpPtr->traceGC = newGC;
// errorbar
- gcMask = (GCLineWidth | GCForeground);
- colorPtr = lpPtr->errorBarColor;
- if (!colorPtr)
- colorPtr = lpPtr->traceColor;
-
- gcValues.line_width = LineWidth(lpPtr->errorBarLineWidth);
- gcValues.foreground = colorPtr->pixel;
- newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues);
- if (lpPtr->errorBarGC) {
- Tk_FreeGC(graphPtr->display, lpPtr->errorBarGC);
+ {
+ unsigned long gcMask = (GCLineWidth | GCForeground);
+ XColor* colorPtr = ops->errorBarColor;
+ if (!colorPtr)
+ colorPtr = ops->traceColor;
+ XGCValues gcValues;
+ gcValues.line_width = LineWidth(ops->errorBarLineWidth);
+ gcValues.foreground = colorPtr->pixel;
+ GC newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues);
+ if (lpPtr->errorBarGC) {
+ Tk_FreeGC(graphPtr->display, lpPtr->errorBarGC);
+ }
+ lpPtr->errorBarGC = newGC;
}
- lpPtr->errorBarGC = newGC;
return TCL_OK;
}
-void DestroyLinePenProc(Graph* graphPtr, Pen* basePtr)
+void DestroyLinePenProc(Graph* graphPtr, Pen* penPtr)
{
- LinePen* penPtr = (LinePen*)basePtr;
+ LinePen* lpPtr = (LinePen*)penPtr;
+ LinePenOptions* ops = (LinePenOptions*)lpPtr->ops;
- Blt_Ts_FreeStyle(graphPtr->display, &penPtr->valueStyle);
- if (penPtr->symbol.outlineGC)
- Tk_FreeGC(graphPtr->display, penPtr->symbol.outlineGC);
+ Blt_Ts_FreeStyle(graphPtr->display, &ops->valueStyle);
+ if (ops->symbol.outlineGC)
+ Tk_FreeGC(graphPtr->display, ops->symbol.outlineGC);
- if (penPtr->symbol.fillGC)
- Tk_FreeGC(graphPtr->display, penPtr->symbol.fillGC);
+ if (ops->symbol.fillGC)
+ Tk_FreeGC(graphPtr->display, ops->symbol.fillGC);
- if (penPtr->errorBarGC)
- Tk_FreeGC(graphPtr->display, penPtr->errorBarGC);
+ if (lpPtr->errorBarGC)
+ Tk_FreeGC(graphPtr->display, lpPtr->errorBarGC);
- if (penPtr->traceGC)
- Blt_FreePrivateGC(graphPtr->display, penPtr->traceGC);
+ if (lpPtr->traceGC)
+ Blt_FreePrivateGC(graphPtr->display, lpPtr->traceGC);
- if (penPtr->symbol.bitmap != None) {
- Tk_FreeBitmap(graphPtr->display, penPtr->symbol.bitmap);
- penPtr->symbol.bitmap = None;
+ if (ops->symbol.bitmap != None) {
+ Tk_FreeBitmap(graphPtr->display, ops->symbol.bitmap);
+ ops->symbol.bitmap = None;
}
- if (penPtr->symbol.mask != None) {
- Tk_FreeBitmap(graphPtr->display, penPtr->symbol.mask);
- penPtr->symbol.mask = None;
+ if (ops->symbol.mask != None) {
+ Tk_FreeBitmap(graphPtr->display, ops->symbol.mask);
+ ops->symbol.mask = None;
}
- Tk_FreeConfigOptions((char*)penPtr, penPtr->optionTable, graphPtr->tkwin);
+ Tk_FreeConfigOptions((char*)lpPtr, lpPtr->optionTable, graphPtr->tkwin);
- if (penPtr->manageOptions)
- if (penPtr->ops)
- free(penPtr->ops);
+ if (lpPtr->manageOptions)
+ if (lpPtr->ops)
+ free(lpPtr->ops);
}
-static void DestroySymbol(Display *display, Symbol *symbolPtr)
+static void DestroySymbol(Display* display, Symbol* symbolPtr)
{
if (symbolPtr->bitmap != None) {
Tk_FreeBitmap(display, symbolPtr->bitmap);
@@ -359,6 +377,7 @@ static void DestroySymbol(Display *display, Symbol *symbolPtr)
Tk_FreeBitmap(display, symbolPtr->mask);
symbolPtr->mask = None;
}
+
symbolPtr->type = SYMBOL_NONE;
}
diff --git a/src/bltGrPenLine.h b/src/bltGrPenLine.h
index be5cddb..57a4900 100644
--- a/src/bltGrPenLine.h
+++ b/src/bltGrPenLine.h
@@ -62,7 +62,6 @@ typedef struct {
int errorBarLineWidth;
int errorBarCapWidth;
XColor* errorBarColor;
-
int valueShow;
const char* valueFormat;
TextStyle valueStyle;
@@ -87,27 +86,8 @@ typedef struct {
void* ops;
int manageOptions;
- // Symbol attributes
- Symbol symbol;
-
- // Trace attributes.
- int traceWidth;
- Blt_Dashes traceDashes;
- XColor* traceColor;
- XColor* traceOffColor;
GC traceGC;
-
- // Error bar attributes
- int errorBarShow;
- int errorBarLineWidth;
- int errorBarCapWidth;
- XColor* errorBarColor;
GC errorBarGC;
-
- // Show value attributes
- int valueShow;
- const char* valueFormat;
- TextStyle valueStyle;
} LinePen;
extern Tk_ObjCustomOption symbolObjOption;
diff --git a/src/bltGrPenOp.C b/src/bltGrPenOp.C
index e52eadd..b6ec534 100644
--- a/src/bltGrPenOp.C
+++ b/src/bltGrPenOp.C
@@ -81,7 +81,7 @@ int Blt_CreatePen(Graph* graphPtr, Tcl_Interp* interp,
penPtr->hashPtr = hPtr;
Tcl_SetHashValue(hPtr, penPtr);
- if ((Tk_InitOptions(graphPtr->interp, (char*)penPtr, penPtr->optionTable, graphPtr->tkwin) != TCL_OK) || (PenObjConfigure(interp, graphPtr, penPtr, objc-4, objv+4) != TCL_OK)) {
+ if ((Tk_InitOptions(graphPtr->interp, (char*)penPtr->ops, penPtr->optionTable, graphPtr->tkwin) != TCL_OK) || (PenObjConfigure(interp, graphPtr, penPtr, objc-4, objv+4) != TCL_OK)) {
DestroyPen(penPtr);
return TCL_ERROR;
}
diff --git a/src/bltGraph.C b/src/bltGraph.C
index 15a01d8..64b1783 100644
--- a/src/bltGraph.C
+++ b/src/bltGraph.C
@@ -281,8 +281,8 @@ static int NewGraph(ClientData clientData, Tcl_Interp*interp,
GraphInstCmdDeleteProc);
graphPtr->optionTable = optionTable;
graphPtr->classId = classId;
- graphPtr->backingStore = TRUE;
- graphPtr->doubleBuffer = TRUE;
+ graphPtr->backingStore = 1;
+ graphPtr->doubleBuffer = 1;
graphPtr->borderWidth = 2;
graphPtr->plotBW = 1;
graphPtr->highlightWidth = 2;
@@ -1034,7 +1034,7 @@ static ClientData PickEntry(ClientData clientData, int x, int y,
// 1. markers drawn on top (-under false).
// 2. elements using its display list back to front.
// 3. markers drawn under element (-under true).
- Marker* markerPtr = (Marker*)Blt::NearestMarker(graphPtr, x, y, FALSE);
+ Marker* markerPtr = (Marker*)Blt::NearestMarker(graphPtr, x, y, 0);
if (markerPtr) {
*contextPtr = (ClientData)markerPtr->classId();
return markerPtr;
@@ -1054,8 +1054,7 @@ static ClientData PickEntry(ClientData clientData, int x, int y,
if (elemPtr->hide || (elemPtr->flags & MAP_ITEM))
continue;
- if (elemPtr->state == BLT_STATE_NORMAL)
- (*elemPtr->procsPtr->closestProc) (graphPtr, elemPtr);
+ (*elemPtr->procsPtr->closestProc) (graphPtr, elemPtr);
}
// Found an element within the minimum halo distance.
if (searchPtr->dist <= (double)searchPtr->halo) {
@@ -1063,7 +1062,7 @@ static ClientData PickEntry(ClientData clientData, int x, int y,
return searchPtr->elemPtr;
}
- markerPtr = (Marker*)Blt::NearestMarker(graphPtr, x, y, TRUE);
+ markerPtr = (Marker*)Blt::NearestMarker(graphPtr, x, y, 1);
if (markerPtr) {
*contextPtr = (ClientData)markerPtr->classId();
return markerPtr;
diff --git a/src/bltInt.C b/src/bltInt.C
index 641ae0a..9bffac7 100644
--- a/src/bltInt.C
+++ b/src/bltInt.C
@@ -111,7 +111,7 @@ int Blt_InitCmd(Tcl_Interp* interp, const char *nsName,
if (nsPtr == NULL)
return TCL_ERROR;
- if (Tcl_Export(interp, nsPtr, specPtr->name, FALSE) != TCL_OK)
+ if (Tcl_Export(interp, nsPtr, specPtr->name, 0) != TCL_OK)
return TCL_ERROR;
return TCL_OK;
diff --git a/src/bltNsUtil.C b/src/bltNsUtil.C
index b4abfb2..6eb9b95 100644
--- a/src/bltNsUtil.C
+++ b/src/bltNsUtil.C
@@ -64,7 +64,7 @@ int Blt_ParseObjectName(Tcl_Interp* interp, const char *path,
if ((flags & BLT_NO_DEFAULT_NS) == 0) {
namePtr->nsPtr = Tcl_GetCurrentNamespace(interp);
}
- return TRUE; /* No namespace designated in name. */
+ return 1; /* No namespace designated in name. */
}
/* Separate the namespace and the object name. */
@@ -78,10 +78,10 @@ int Blt_ParseObjectName(Tcl_Interp* interp, const char *path,
/* Repair the string. */ *colon = ':';
if (namePtr->nsPtr == NULL) {
- return FALSE; /* Namespace doesn't exist. */
+ return 0; /* Namespace doesn't exist. */
}
namePtr->name =last;
- return TRUE;
+ return 1;
}
char* Blt_MakeQualifiedName(Blt_ObjectName *namePtr, Tcl_DString *resultPtr)
diff --git a/src/bltVecCmd.C b/src/bltVecCmd.C
index f9303d0..a448131 100644
--- a/src/bltVecCmd.C
+++ b/src/bltVecCmd.C
@@ -1409,7 +1409,7 @@ BinreadOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[])
first = vPtr->length;
fmt = FMT_DOUBLE;
size = sizeof(double);
- swap = FALSE;
+ swap = 0;
count = 0;
if (objc > 3) {
@@ -1433,7 +1433,7 @@ BinreadOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[])
for (i = 3; i < objc; i++) {
string = Tcl_GetString(objv[i]);
if (strcmp(string, "-swap") == 0) {
- swap = TRUE;
+ swap = 1;
} else if (strcmp(string, "-format") == 0) {
i++;
if (i >= objc) {
@@ -1539,10 +1539,10 @@ SearchOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[])
char *string;
Tcl_Obj *listObjPtr;
- wantValue = FALSE;
+ wantValue = 0;
string = Tcl_GetString(objv[2]);
if ((string[0] == '-') && (strcmp(string, "-value") == 0)) {
- wantValue = TRUE;
+ wantValue = 1;
objv++, objc--;
}
if (Blt_ExprDoubleFromObj(interp, objv[2], &min) != TCL_OK) {
@@ -1990,7 +1990,7 @@ SortOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[])
unsigned int n;
SortSwitches switches;
- sortDecreasing = FALSE;
+ sortDecreasing = 0;
switches.flags = 0;
i = Blt_ParseSwitches(interp, sortSwitches, objc - 2, objv + 2, &switches,
BLT_SWITCH_OBJV_PARTIAL);
diff --git a/src/bltVecMath.C b/src/bltVecMath.C
index be09a1a..1d5fd21 100644
--- a/src/bltVecMath.C
+++ b/src/bltVecMath.C
@@ -1081,7 +1081,7 @@ NextValue(
vPtr = valuePtr->vPtr;
v2Ptr = Blt_Vec_New(vPtr->dataPtr);
- gotOp = FALSE;
+ gotOp = 0;
value2.vPtr = v2Ptr;
value2.pv.buffer = value2.pv.next = value2.staticSpace;
value2.pv.end = value2.pv.buffer + STATIC_STRING_SPACE - 1;
@@ -1116,7 +1116,7 @@ NextValue(
if (result != TCL_OK) {
goto done;
}
- gotOp = TRUE;
+ gotOp = 1;
/* Process unary operators. */
switch (operator) {
case UNARY_MINUS:
diff --git a/src/bltVector.C b/src/bltVector.C
index 7d4764a..f7e520f 100644
--- a/src/bltVector.C
+++ b/src/bltVector.C
@@ -1100,7 +1100,7 @@ Blt_Vec_New(VectorInterpData *dataPtr) /* Interpreter-specific data. */
vPtr->interp = dataPtr->interp;
vPtr->hashPtr = NULL;
vPtr->chain = Blt_Chain_Create();
- vPtr->flush = FALSE;
+ vPtr->flush = 0;
vPtr->min = vPtr->max = NAN;
vPtr->notifyFlags = NOTIFY_WHENIDLE;
vPtr->dataPtr = dataPtr;
@@ -1991,9 +1991,9 @@ Blt_VectorExists2(Tcl_Interp* interp, const char *vecName)
dataPtr = Blt_Vec_GetInterpData(interp);
if (GetVectorObject(dataPtr, vecName, NS_SEARCH_BOTH) != NULL) {
- return TRUE;
+ return 1;
}
- return FALSE;
+ return 0;
}
/*