From ac8963f0b5c46c5486af588c1ce2876eef6848a9 Mon Sep 17 00:00:00 2001 From: joye Date: Wed, 16 Apr 2014 15:34:51 +0000 Subject: *** empty log message *** --- src/bltGrAxis.C | 53 ++--- src/bltGrAxisOp.C | 165 ++++++++------- src/bltGrElemBar.C | 50 +++-- src/bltGrElemLine.C | 12 +- src/bltGrElemOp.C | 6 +- src/bltGrHairs.C | 3 +- src/bltGrLegd.C | 31 +-- src/bltGrMarker.C | 3 +- src/bltGrMarkerLine.C | 6 +- src/bltGrMarkerPolygon.C | 3 +- src/bltGrXAxisOp.C | 10 +- src/bltGraph.C | 519 +++++++++++++++++++++++++---------------------- src/bltGraph.h | 64 +++--- src/bltGraphOp.C | 27 ++- 14 files changed, 515 insertions(+), 437 deletions(-) diff --git a/src/bltGrAxis.C b/src/bltGrAxis.C index 5da1040..6f5cb58 100644 --- a/src/bltGrAxis.C +++ b/src/bltGrAxis.C @@ -394,20 +394,21 @@ void Axis::map(int offset, int margin) void Axis::mapStacked(int count, int margin) { AxisOptions* ops = (AxisOptions*)ops_; + GraphOptions* gops = (GraphOptions*)graphPtr_->ops_; - if ((graphPtr_->margins[margin_].axes->nLinks > 1) || + if ((gops->margins[margin_].axes->nLinks > 1) || (ops->reqNumMajorTicks <= 0)) { ops->reqNumMajorTicks = 4; } unsigned int slice; if (isHorizontal()) { - slice = graphPtr_->hRange / graphPtr_->margins[margin].axes->nLinks; + slice = graphPtr_->hRange / gops->margins[margin].axes->nLinks; screenMin_ = graphPtr_->hOffset; width_ = slice; } else { - slice = graphPtr_->vRange / graphPtr_->margins[margin].axes->nLinks; + slice = graphPtr_->vRange / gops->margins[margin].axes->nLinks; screenMin_ = graphPtr_->vOffset; height_ = slice; } @@ -920,7 +921,8 @@ int Axis::inRange(double x, AxisRange *rangePtr) int Axis::isHorizontal() { - return ((classId_ == CID_AXIS_Y) == graphPtr_->inverted); + GraphOptions* gops = (GraphOptions*)graphPtr_->ops_; + return ((classId_ == CID_AXIS_Y) == gops->inverted); } void Axis::freeTickLabels() @@ -1130,6 +1132,7 @@ void Axis::makeLine(int line, Segment2d *sp) void Axis::offsets(int margin, int offset, AxisInfo *infoPtr) { AxisOptions* ops = (AxisOptions*)ops_; + GraphOptions* gops = (GraphOptions*)graphPtr_->ops_; int axisLine =0; int t1 =0; @@ -1139,7 +1142,7 @@ void Axis::offsets(int margin, int offset, AxisInfo *infoPtr) float titleAngle[4] = {0.0, 90.0, 0.0, 270.0}; titleAngle_ = titleAngle[margin]; - Margin *marginPtr = graphPtr_->margins + margin; + Margin *marginPtr = gops->margins + margin; if (ops->lineWidth > 0) { if (ops->showTicks) { @@ -1171,24 +1174,24 @@ void Axis::offsets(int margin, int offset, AxisInfo *infoPtr) { axisLine = graphPtr_->top; if (ops->exterior) { - axisLine -= graphPtr_->plotBW + axisPad + ops->lineWidth / 2; + axisLine -= gops->plotBW + axisPad + ops->lineWidth / 2; tickLabel = axisLine - 2; if (ops->lineWidth > 0) tickLabel -= ops->tickLength; } else { - if (graphPtr_->plotRelief == TK_RELIEF_SOLID) + if (gops->plotRelief == TK_RELIEF_SOLID) axisLine--; axisLine -= axisPad + ops->lineWidth / 2; - tickLabel = graphPtr_->top - graphPtr_->plotBW - 2; + tickLabel = graphPtr_->top - gops->plotBW - 2; } int mark = graphPtr_->top - offset - pad; tickAnchor_ = TK_ANCHOR_S; left_ = screenMin_ - inset - 2; right_ = screenMin_ + screenRange_ + inset - 1; - if (graphPtr_->stackAxes) + if (gops->stackAxes) top_ = mark - marginPtr->axesOffset; else top_ = mark - height_; @@ -1202,7 +1205,7 @@ void Axis::offsets(int margin, int offset, AxisInfo *infoPtr) } else { x = (right_ + left_) / 2; - if (graphPtr_->stackAxes) + if (gops->stackAxes) y = mark - marginPtr->axesOffset + AXIS_PAD_TITLE; else y = mark - height_ + AXIS_PAD_TITLE; @@ -1230,18 +1233,18 @@ void Axis::offsets(int margin, int offset, AxisInfo *infoPtr) * title */ axisLine = graphPtr_->bottom; - if (graphPtr_->plotRelief == TK_RELIEF_SOLID) + if (gops->plotRelief == TK_RELIEF_SOLID) axisLine++; if (ops->exterior) { - axisLine += graphPtr_->plotBW + axisPad + ops->lineWidth / 2; + axisLine += gops->plotBW + axisPad + ops->lineWidth / 2; tickLabel = axisLine + 2; if (ops->lineWidth > 0) tickLabel += ops->tickLength; } else { axisLine -= axisPad + ops->lineWidth / 2; - tickLabel = graphPtr_->bottom + graphPtr_->plotBW + 2; + tickLabel = graphPtr_->bottom + gops->plotBW + 2; } int mark = graphPtr_->bottom + offset; @@ -1259,7 +1262,7 @@ void Axis::offsets(int margin, int offset, AxisInfo *infoPtr) left_ = screenMin_ - inset - 2; right_ = screenMin_ + screenRange_ + inset - 1; top_ = graphPtr_->bottom + labelOffset - t1; - if (graphPtr_->stackAxes) + if (gops->stackAxes) bottom_ = mark + marginPtr->axesOffset - 1; else bottom_ = mark + height_ - 1; @@ -1272,7 +1275,7 @@ void Axis::offsets(int margin, int offset, AxisInfo *infoPtr) } else { x = (right_ + left_) / 2; - if (graphPtr_->stackAxes) + if (gops->stackAxes) y = mark + marginPtr->axesOffset - AXIS_PAD_TITLE; else y = mark + height_ - AXIS_PAD_TITLE; @@ -1324,21 +1327,21 @@ void Axis::offsets(int margin, int offset, AxisInfo *infoPtr) */ axisLine = graphPtr_->left; if (ops->exterior) { - axisLine -= graphPtr_->plotBW + axisPad + ops->lineWidth / 2; + axisLine -= gops->plotBW + axisPad + ops->lineWidth / 2; tickLabel = axisLine - 2; if (ops->lineWidth > 0) tickLabel -= ops->tickLength; } else { - if (graphPtr_->plotRelief == TK_RELIEF_SOLID) + if (gops->plotRelief == TK_RELIEF_SOLID) axisLine--; axisLine += axisPad + ops->lineWidth / 2; - tickLabel = graphPtr_->left - graphPtr_->plotBW - 2; + tickLabel = graphPtr_->left - gops->plotBW - 2; } int mark = graphPtr_->left - offset; tickAnchor_ = TK_ANCHOR_E; - if (graphPtr_->stackAxes) + if (gops->stackAxes) left_ = mark - marginPtr->axesOffset; else left_ = mark - width_; @@ -1353,7 +1356,7 @@ void Axis::offsets(int margin, int offset, AxisInfo *infoPtr) titleAnchor_ = TK_ANCHOR_SW; } else { - if (graphPtr_->stackAxes) + if (gops->stackAxes) x = mark - marginPtr->axesOffset; else x = mark - width_ + AXIS_PAD_TITLE; @@ -1368,24 +1371,24 @@ void Axis::offsets(int margin, int offset, AxisInfo *infoPtr) case MARGIN_RIGHT: { axisLine = graphPtr_->right; - if (graphPtr_->plotRelief == TK_RELIEF_SOLID) + if (gops->plotRelief == TK_RELIEF_SOLID) axisLine++; if (ops->exterior) { - axisLine += graphPtr_->plotBW + axisPad + ops->lineWidth / 2; + axisLine += gops->plotBW + axisPad + ops->lineWidth / 2; tickLabel = axisLine + 2; if (ops->lineWidth > 0) tickLabel += ops->tickLength; } else { axisLine -= axisPad + ops->lineWidth / 2; - tickLabel = graphPtr_->right + graphPtr_->plotBW + 2; + tickLabel = graphPtr_->right + gops->plotBW + 2; } int mark = graphPtr_->right + offset + pad; tickAnchor_ = TK_ANCHOR_W; left_ = mark; - if (graphPtr_->stackAxes) + if (gops->stackAxes) right_ = mark + marginPtr->axesOffset - 1; else right_ = mark + width_ - 1; @@ -1400,7 +1403,7 @@ void Axis::offsets(int margin, int offset, AxisInfo *infoPtr) titleAnchor_ = TK_ANCHOR_SE; } else { - if (graphPtr_->stackAxes) + if (gops->stackAxes) x = mark + marginPtr->axesOffset - AXIS_PAD_TITLE; else x = mark + width_ - AXIS_PAD_TITLE; diff --git a/src/bltGrAxisOp.C b/src/bltGrAxisOp.C index dc57a92..c1b87c3 100644 --- a/src/bltGrAxisOp.C +++ b/src/bltGrAxisOp.C @@ -674,6 +674,7 @@ void FreeAxis(char* data) void Blt_ResetAxes(Graph* graphPtr) { + GraphOptions* gops = (GraphOptions*)graphPtr->ops_; Blt_ChainLink link; Tcl_HashEntry *hPtr; Tcl_HashSearch cursor; @@ -684,7 +685,7 @@ void Blt_ResetAxes(Graph* graphPtr) * Needs to be done before the axis limits are set. */ Blt_InitBarSetTable(graphPtr); - if ((graphPtr->barMode == BARS_STACKED) && (graphPtr->nBarGroups > 0)) + if ((gops->barMode == BARS_STACKED) && (graphPtr->nBarGroups > 0)) Blt_ComputeBarStacks(graphPtr); /* @@ -753,9 +754,10 @@ void Blt_ResetAxes(Graph* graphPtr) Point2d Blt_Map2D(Graph* graphPtr, double x, double y, Axis2d *axesPtr) { + GraphOptions* gops = (GraphOptions*)graphPtr->ops_; Point2d point; - if (graphPtr->inverted) { + if (gops->inverted) { point.x = axesPtr->y->hMap(y); point.y = axesPtr->x->vMap(x); } @@ -768,9 +770,10 @@ Point2d Blt_Map2D(Graph* graphPtr, double x, double y, Axis2d *axesPtr) Point2d Blt_InvMap2D(Graph* graphPtr, double x, double y, Axis2d *axesPtr) { + GraphOptions* gops = (GraphOptions*)graphPtr->ops_; Point2d point; - if (graphPtr->inverted) { + if (gops->inverted) { point.x = axesPtr->x->invVMap(y); point.y = axesPtr->y->invHMap(x); } @@ -783,10 +786,11 @@ Point2d Blt_InvMap2D(Graph* graphPtr, double x, double y, Axis2d *axesPtr) void Blt_MapAxes(Graph* graphPtr) { + GraphOptions* gops = (GraphOptions*)graphPtr->ops_; for (int margin = 0; margin < 4; margin++) { int count =0; int offset =0; - Blt_Chain chain = graphPtr->margins[margin].axes; + Blt_Chain chain = gops->margins[margin].axes; for (Blt_ChainLink link=Blt_Chain_FirstLink(chain); link; link = Blt_Chain_NextLink(link)) { Axis *axisPtr = (Axis*)Blt_Chain_GetValue(link); @@ -794,7 +798,7 @@ void Blt_MapAxes(Graph* graphPtr) if (!axisPtr->use_ || (axisPtr->flags & DELETE_PENDING)) continue; - if (graphPtr->stackAxes) { + if (gops->stackAxes) { if (ops->reqNumMajorTicks <= 0) ops->reqNumMajorTicks = 4; @@ -818,8 +822,9 @@ void Blt_MapAxes(Graph* graphPtr) void Blt_DrawAxes(Graph* graphPtr, Drawable drawable) { + GraphOptions* gops = (GraphOptions*)graphPtr->ops_; for (int i = 0; i < 4; i++) { - for (Blt_ChainLink link = Blt_Chain_LastLink(graphPtr->margins[i].axes); + for (Blt_ChainLink link = Blt_Chain_LastLink(gops->margins[i].axes); link != NULL; link = Blt_Chain_PrevLink(link)) { Axis *axisPtr = (Axis*)Blt_Chain_GetValue(link); AxisOptions* ops = (AxisOptions*)axisPtr->ops(); @@ -831,14 +836,15 @@ void Blt_DrawAxes(Graph* graphPtr, Drawable drawable) void Blt_DrawAxisLimits(Graph* graphPtr, Drawable drawable) { + GraphOptions* gops = (GraphOptions*)graphPtr->ops_; Tcl_HashEntry *hPtr; Tcl_HashSearch cursor; char minString[200], maxString[200]; int vMin, hMin, vMax, hMax; #define SPACING 8 - vMin = vMax = graphPtr->left + graphPtr->xPad + 2; - hMin = hMax = graphPtr->bottom - graphPtr->yPad - 2; /* Offsets */ + vMin = vMax = graphPtr->left + gops->xPad + 2; + hMin = hMax = graphPtr->bottom - gops->yPad - 2; /* Offsets */ for (hPtr = Tcl_FirstHashEntry(&graphPtr->axes.table, &cursor); hPtr != NULL; hPtr = Tcl_NextHashEntry(&cursor)) { @@ -918,14 +924,15 @@ void Blt_DrawAxisLimits(Graph* graphPtr, Drawable drawable) void Blt_AxisLimitsToPostScript(Graph* graphPtr, Blt_Ps ps) { + GraphOptions* gops = (GraphOptions*)graphPtr->ops_; Tcl_HashEntry *hPtr; Tcl_HashSearch cursor; double vMin, hMin, vMax, hMax; char string[200]; #define SPACING 8 - vMin = vMax = graphPtr->left + graphPtr->xPad + 2; - hMin = hMax = graphPtr->bottom - graphPtr->yPad - 2; /* Offsets */ + vMin = vMax = graphPtr->left + gops->xPad + 2; + hMin = hMax = graphPtr->bottom - gops->yPad - 2; /* Offsets */ for (hPtr = Tcl_FirstHashEntry(&graphPtr->axes.table, &cursor); hPtr != NULL; hPtr = Tcl_NextHashEntry(&cursor)) { const char *minFmt, *maxFmt; @@ -1001,8 +1008,9 @@ void Blt_ConfigureAxes(Graph* graphPtr) void Blt_DrawGrids(Graph* graphPtr, Drawable drawable) { + GraphOptions* gops = (GraphOptions*)graphPtr->ops_; for (int i = 0; i < 4; i++) { - for (Blt_ChainLink link = Blt_Chain_FirstLink(graphPtr->margins[i].axes); link != NULL; + for (Blt_ChainLink link = Blt_Chain_FirstLink(gops->margins[i].axes); link != NULL; link = Blt_Chain_NextLink(link)) { Axis *axisPtr = (Axis*)Blt_Chain_GetValue(link); AxisOptions* ops = (AxisOptions*)axisPtr->ops(); @@ -1025,9 +1033,10 @@ void Blt_DrawGrids(Graph* graphPtr, Drawable drawable) void Blt_AxesToPostScript(Graph* graphPtr, Blt_Ps ps) { + GraphOptions* gops = (GraphOptions*)graphPtr->ops_; Margin *mp, *mend; - for (mp = graphPtr->margins, mend = mp + 4; mp < mend; mp++) { + for (mp = gops->margins, mend = mp + 4; mp < mend; mp++) { Blt_ChainLink link; for (link = Blt_Chain_FirstLink(mp->axes); link != NULL; @@ -1042,8 +1051,9 @@ void Blt_AxesToPostScript(Graph* graphPtr, Blt_Ps ps) void Blt_GridsToPostScript(Graph* graphPtr, Blt_Ps ps) { + GraphOptions* gops = (GraphOptions*)graphPtr->ops_; for (int i = 0; i < 4; i++) { - for (Blt_ChainLink link = Blt_Chain_FirstLink(graphPtr->margins[i].axes); link != NULL; link = Blt_Chain_NextLink(link)) { + for (Blt_ChainLink link = Blt_Chain_FirstLink(gops->margins[i].axes); link != NULL; link = Blt_Chain_NextLink(link)) { Axis *axisPtr = (Axis*)Blt_Chain_GetValue(link); AxisOptions* ops = (AxisOptions*)axisPtr->ops(); if (ops->hide || !ops->showGrid || !axisPtr->use_ || @@ -1246,6 +1256,7 @@ ClientData Blt_MakeAxisTag(Graph* graphPtr, const char *tagName) void Blt_LayoutGraph(Graph* graphPtr) { + GraphOptions* gops = (GraphOptions*)graphPtr->ops_; int titleY; int plotWidth, plotHeight; int inset, inset2; @@ -1259,14 +1270,14 @@ void Blt_LayoutGraph(Graph* graphPtr) * -leftmargin, -rightmargin, -bottommargin, and -topmargin * graph options, respectively. */ - int left = GetMarginGeometry(graphPtr, &graphPtr->leftMargin); - int right = GetMarginGeometry(graphPtr, &graphPtr->rightMargin); - int top = GetMarginGeometry(graphPtr, &graphPtr->topMargin); - int bottom = GetMarginGeometry(graphPtr, &graphPtr->bottomMargin); + int left = GetMarginGeometry(graphPtr, &gops->leftMargin); + int right = GetMarginGeometry(graphPtr, &gops->rightMargin); + int top = GetMarginGeometry(graphPtr, &gops->topMargin); + int bottom = GetMarginGeometry(graphPtr, &gops->bottomMargin); - int pad = graphPtr->bottomMargin.maxTickWidth; - if (pad < graphPtr->topMargin.maxTickWidth) - pad = graphPtr->topMargin.maxTickWidth; + int pad = gops->bottomMargin.maxTickWidth; + if (pad < gops->topMargin.maxTickWidth) + pad = gops->topMargin.maxTickWidth; pad = pad / 2 + 3; if (right < pad) @@ -1275,9 +1286,9 @@ void Blt_LayoutGraph(Graph* graphPtr) if (left < pad) left = pad; - pad = graphPtr->leftMargin.maxTickHeight; - if (pad < graphPtr->rightMargin.maxTickHeight) - pad = graphPtr->rightMargin.maxTickHeight; + pad = gops->leftMargin.maxTickHeight; + if (pad < gops->rightMargin.maxTickHeight) + pad = gops->rightMargin.maxTickHeight; pad = pad / 2; if (top < pad) @@ -1286,25 +1297,25 @@ void Blt_LayoutGraph(Graph* graphPtr) if (bottom < pad) bottom = pad; - if (graphPtr->leftMargin.reqSize > 0) - left = graphPtr->leftMargin.reqSize; + if (gops->leftMargin.reqSize > 0) + left = gops->leftMargin.reqSize; - if (graphPtr->rightMargin.reqSize > 0) - right = graphPtr->rightMargin.reqSize; + if (gops->rightMargin.reqSize > 0) + right = gops->rightMargin.reqSize; - if (graphPtr->topMargin.reqSize > 0) - top = graphPtr->topMargin.reqSize; + if (gops->topMargin.reqSize > 0) + top = gops->topMargin.reqSize; - if (graphPtr->bottomMargin.reqSize > 0) - bottom = graphPtr->bottomMargin.reqSize; + if (gops->bottomMargin.reqSize > 0) + bottom = gops->bottomMargin.reqSize; /* * Step 2: Add the graph title height to the top margin. */ - if (graphPtr->title) + if (gops->title) top += graphPtr->titleHeight + 6; - inset = (graphPtr->inset + graphPtr->plotBW); + inset = (graphPtr->inset + gops->plotBW); inset2 = 2 * inset; /* @@ -1319,9 +1330,9 @@ void Blt_LayoutGraph(Graph* graphPtr) if (height == 0) height = 400; - plotWidth = (graphPtr->reqPlotWidth > 0) ? graphPtr->reqPlotWidth : + plotWidth = (gops->reqPlotWidth > 0) ? gops->reqPlotWidth : width - (inset2 + left + right); /* Plot width. */ - plotHeight = (graphPtr->reqPlotHeight > 0) ? graphPtr->reqPlotHeight : + plotHeight = (gops->reqPlotHeight > 0) ? gops->reqPlotHeight : height - (inset2 + top + bottom); /* Plot height. */ graphPtr->legend->map(plotWidth, plotHeight); @@ -1352,12 +1363,12 @@ void Blt_LayoutGraph(Graph* graphPtr) /* * Recompute the plotarea or graph size, now accounting for the legend. */ - if (graphPtr->reqPlotWidth == 0) { + if (gops->reqPlotWidth == 0) { plotWidth = width - (inset2 + left + right); if (plotWidth < 1) plotWidth = 1; } - if (graphPtr->reqPlotHeight == 0) { + if (gops->reqPlotHeight == 0) { plotHeight = height - (inset2 + top + bottom); if (plotHeight < 1) plotHeight = 1; @@ -1367,8 +1378,8 @@ void Blt_LayoutGraph(Graph* graphPtr) * Step 5: If necessary, correct for the requested plot area aspect * ratio. */ - if ((graphPtr->reqPlotWidth == 0) && (graphPtr->reqPlotHeight == 0) && - (graphPtr->aspect > 0.0f)) { + if ((gops->reqPlotWidth == 0) && (gops->reqPlotHeight == 0) && + (gops->aspect > 0.0f)) { float ratio; /* @@ -1376,9 +1387,9 @@ void Blt_LayoutGraph(Graph* graphPtr) * width/height aspect ratio. */ ratio = (float)plotWidth / (float)plotHeight; - if (ratio > graphPtr->aspect) { + if (ratio > gops->aspect) { // Shrink the width - int scaledWidth = (int)(plotHeight * graphPtr->aspect); + int scaledWidth = (int)(plotHeight * gops->aspect); if (scaledWidth < 1) scaledWidth = 1; @@ -1388,7 +1399,7 @@ void Blt_LayoutGraph(Graph* graphPtr) } else { // Shrink the height - int scaledHeight = (int)(plotWidth / graphPtr->aspect); + int scaledHeight = (int)(plotWidth / gops->aspect); if (scaledHeight < 1) scaledHeight = 1; @@ -1404,34 +1415,34 @@ void Blt_LayoutGraph(Graph* graphPtr) * for the longest axis titles. */ - if (top < graphPtr->leftMargin.axesTitleLength) - top = graphPtr->leftMargin.axesTitleLength; + if (top < gops->leftMargin.axesTitleLength) + top = gops->leftMargin.axesTitleLength; - if (right < graphPtr->bottomMargin.axesTitleLength) - right = graphPtr->bottomMargin.axesTitleLength; + if (right < gops->bottomMargin.axesTitleLength) + right = gops->bottomMargin.axesTitleLength; - if (top < graphPtr->rightMargin.axesTitleLength) - top = graphPtr->rightMargin.axesTitleLength; + if (top < gops->rightMargin.axesTitleLength) + top = gops->rightMargin.axesTitleLength; - if (right < graphPtr->topMargin.axesTitleLength) - right = graphPtr->topMargin.axesTitleLength; + if (right < gops->topMargin.axesTitleLength) + right = gops->topMargin.axesTitleLength; /* * Step 7: Override calculated values with requested margin sizes. */ - if (graphPtr->leftMargin.reqSize > 0) - left = graphPtr->leftMargin.reqSize; + if (gops->leftMargin.reqSize > 0) + left = gops->leftMargin.reqSize; - if (graphPtr->rightMargin.reqSize > 0) - right = graphPtr->rightMargin.reqSize; + if (gops->rightMargin.reqSize > 0) + right = gops->rightMargin.reqSize; - if (graphPtr->topMargin.reqSize > 0) - top = graphPtr->topMargin.reqSize; + if (gops->topMargin.reqSize > 0) + top = gops->topMargin.reqSize; - if (graphPtr->bottomMargin.reqSize > 0) - bottom = graphPtr->bottomMargin.reqSize; + if (gops->bottomMargin.reqSize > 0) + bottom = gops->bottomMargin.reqSize; - if (graphPtr->reqPlotWidth > 0) { + if (gops->reqPlotWidth > 0) { /* * Width of plotarea is constained. If there's extra space, add it to * th left and/or right margins. If there's too little, grow the @@ -1440,16 +1451,16 @@ void Blt_LayoutGraph(Graph* graphPtr) int w = plotWidth + inset2 + left + right; if (width > w) { /* Extra space in window. */ int extra = (width - w) / 2; - if (graphPtr->leftMargin.reqSize == 0) { + if (gops->leftMargin.reqSize == 0) { left += extra; - if (graphPtr->rightMargin.reqSize == 0) { + if (gops->rightMargin.reqSize == 0) { right += extra; } else { left += extra; } } - else if (graphPtr->rightMargin.reqSize == 0) { + else if (gops->rightMargin.reqSize == 0) { right += extra + extra; } } @@ -1457,7 +1468,7 @@ void Blt_LayoutGraph(Graph* graphPtr) width = w; } } - if (graphPtr->reqPlotHeight > 0) { /* Constrain the plotarea height. */ + if (gops->reqPlotHeight > 0) { /* Constrain the plotarea height. */ /* * Height of plotarea is constained. If there's extra space, * add it to th top and/or bottom margins. If there's too little, @@ -1468,16 +1479,16 @@ void Blt_LayoutGraph(Graph* graphPtr) int extra; extra = (height - h) / 2; - if (graphPtr->topMargin.reqSize == 0) { + if (gops->topMargin.reqSize == 0) { top += extra; - if (graphPtr->bottomMargin.reqSize == 0) { + if (gops->bottomMargin.reqSize == 0) { bottom += extra; } else { top += extra; } } - else if (graphPtr->bottomMargin.reqSize == 0) { + else if (gops->bottomMargin.reqSize == 0) { bottom += extra + extra; } } @@ -1492,15 +1503,15 @@ void Blt_LayoutGraph(Graph* graphPtr) graphPtr->right = width - right - inset; graphPtr->bottom = height - bottom - inset; - graphPtr->leftMargin.width = left + graphPtr->inset; - graphPtr->rightMargin.width = right + graphPtr->inset; - graphPtr->topMargin.height = top + graphPtr->inset; - graphPtr->bottomMargin.height = bottom + graphPtr->inset; + gops->leftMargin.width = left + graphPtr->inset; + gops->rightMargin.width = right + graphPtr->inset; + gops->topMargin.height = top + graphPtr->inset; + gops->bottomMargin.height = bottom + graphPtr->inset; - graphPtr->vOffset = graphPtr->top + graphPtr->yPad; - graphPtr->vRange = plotHeight - 2*graphPtr->yPad; - graphPtr->hOffset = graphPtr->left + graphPtr->xPad; - graphPtr->hRange = plotWidth - 2*graphPtr->xPad; + graphPtr->vOffset = graphPtr->top + gops->yPad; + graphPtr->vRange = plotHeight - 2*gops->yPad; + graphPtr->hOffset = graphPtr->left + gops->xPad; + graphPtr->hRange = plotWidth - 2*gops->xPad; if (graphPtr->vRange < 1) graphPtr->vRange = 1; @@ -1520,6 +1531,7 @@ void Blt_LayoutGraph(Graph* graphPtr) static int GetMarginGeometry(Graph* graphPtr, Margin *marginPtr) { + GraphOptions* gops = (GraphOptions*)graphPtr->ops_; int isHoriz = !(marginPtr->site & 0x1); /* Even sites are horizontal */ // Count the visible axes. @@ -1531,7 +1543,7 @@ static int GetMarginGeometry(Graph* graphPtr, Margin *marginPtr) marginPtr->maxTickWidth =0; marginPtr->maxTickHeight =0; - if (graphPtr->stackAxes) { + if (gops->stackAxes) { for (Blt_ChainLink link = Blt_Chain_FirstLink(marginPtr->axes); link != NULL; link = Blt_Chain_NextLink(link)) { Axis* axisPtr = (Axis*)Blt_Chain_GetValue(link); @@ -1601,11 +1613,12 @@ static int GetMarginGeometry(Graph* graphPtr, Margin *marginPtr) static void GetAxisGeometry(Graph* graphPtr, Axis *axisPtr) { AxisOptions* ops = (AxisOptions*)axisPtr->ops(); + GraphOptions* gops = (GraphOptions*)graphPtr->ops_; axisPtr->freeTickLabels(); // Leave room for axis baseline and padding unsigned int y =0; - if (ops->exterior && (graphPtr->plotRelief != TK_RELIEF_SOLID)) + if (ops->exterior && (gops->plotRelief != TK_RELIEF_SOLID)) y += ops->lineWidth + 2; axisPtr->maxTickHeight_ = axisPtr->maxTickWidth_ = 0; diff --git a/src/bltGrElemBar.C b/src/bltGrElemBar.C index c7ee3fb..c609167 100644 --- a/src/bltGrElemBar.C +++ b/src/bltGrElemBar.C @@ -256,6 +256,7 @@ int BarElement::configure() void BarElement::map() { BarElementOptions* ops = (BarElementOptions*)ops_; + GraphOptions* gops = (GraphOptions*)graphPtr_->ops_; ResetBar(); if (!ops->coords.x || !ops->coords.y || @@ -264,10 +265,9 @@ void BarElement::map() int nPoints = NUMBEROFPOINTS(ops); // double barWidth = graphPtr->barWidth; - double barWidth = (ops->barWidth > 0.0f) ? - ops->barWidth : graphPtr_->barWidth; + double barWidth = (ops->barWidth > 0.0f) ? ops->barWidth : gops->barWidth; AxisOptions* axisyops = (AxisOptions*)ops->axes.y->ops(); - double baseline = (axisyops->logScale) ? 0.0 : graphPtr_->baseline; + double baseline = (axisyops->logScale) ? 0.0 : gops->baseline; double barOffset = barWidth * 0.5; // Create an array of bars representing the screen coordinates of all the @@ -303,8 +303,8 @@ void BarElement::map() * coordinates of the two corners. */ - if ((graphPtr_->nBarGroups > 0) && (graphPtr_->barMode != BARS_INFRONT) && - (!graphPtr_->stackAxes)) { + if ((graphPtr_->nBarGroups > 0) && (gops->barMode != BARS_INFRONT) && + (!gops->stackAxes)) { Tcl_HashEntry *hPtr; BarSetKey key; @@ -328,7 +328,7 @@ void BarElement::map() offset += slice * 0.05; slice *= 0.90; } - switch (graphPtr_->barMode) { + switch (gops->barMode) { case BARS_STACKED: groupPtr->count++; c2.y = groupPtr->lastY; @@ -392,7 +392,7 @@ void BarElement::map() } /* Bound the bars horizontally by the width of the graph window */ /* Bound the bars vertically by the position of the axis. */ - if (graphPtr_->stackAxes) { + if (gops->stackAxes) { top = ops->axes.y->screenMin_; bottom = ops->axes.y->screenMin_ + ops->axes.y->screenRange_; left = graphPtr_->left; @@ -481,6 +481,7 @@ void BarElement::map() void BarElement::extents(Region2d *regPtr) { BarElementOptions* ops = (BarElementOptions*)ops_; + GraphOptions* gops = (GraphOptions*)graphPtr_->ops_; regPtr->top = regPtr->left = DBL_MAX; regPtr->bottom = regPtr->right = -DBL_MAX; @@ -490,7 +491,7 @@ void BarElement::extents(Region2d *regPtr) return; int nPoints = NUMBEROFPOINTS(ops); - double barWidth = graphPtr_->barWidth; + double barWidth = gops->barWidth; if (ops->barWidth > 0.0f) barWidth = ops->barWidth; @@ -500,13 +501,13 @@ void BarElement::extents(Region2d *regPtr) regPtr->top = ops->coords.y->min; regPtr->bottom = ops->coords.y->max; - if (regPtr->bottom < graphPtr_->baseline) - regPtr->bottom = graphPtr_->baseline; + if (regPtr->bottom < gops->baseline) + regPtr->bottom = gops->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)) + if ((gops->barMode == BARS_STACKED) && (graphPtr_->nBarGroups > 0)) CheckBarStacks(&ops->axes, ®Ptr->top, ®Ptr->bottom); // Warning: You get what you deserve if the x-axis is logScale @@ -610,8 +611,9 @@ void BarElement::extents(Region2d *regPtr) void BarElement::closest() { BarElementOptions* ops = (BarElementOptions*)ops_; + GraphOptions* gops = (GraphOptions*)graphPtr_->ops_; - ClosestSearch* searchPtr = &graphPtr_->search; + ClosestSearch* searchPtr = &gops->search; double minDist = searchPtr->dist; int imin = 0; @@ -866,7 +868,8 @@ void BarElement::ResetStylePalette(Blt_Chain stylePalette) void BarElement::CheckBarStacks(Axis2d *pairPtr, double *minPtr, double *maxPtr) { - if ((graphPtr_->barMode != BARS_STACKED) || (graphPtr_->nBarGroups == 0)) + GraphOptions* gops = (GraphOptions*)graphPtr_->ops_; + if ((gops->barMode != BARS_STACKED) || (graphPtr_->nBarGroups == 0)) return; BarGroup *gp, *gend; @@ -1282,6 +1285,7 @@ void BarElement::DrawBarValues(Drawable drawable, BarPen* penPtr, { BarElementOptions* ops = (BarElementOptions*)ops_; BarPenOptions* penOps = (BarPenOptions*)penPtr->ops(); + GraphOptions* gops = (GraphOptions*)graphPtr_->ops_; const char *fmt = penOps->valueFormat; if (!fmt) @@ -1307,16 +1311,16 @@ void BarElement::DrawBarValues(Drawable drawable, BarPen* penPtr, sprintf_s(string + strlen(string), TCL_DOUBLE_SPACE, fmt, y); } - if (graphPtr_->inverted) { + if (gops->inverted) { anchorPos.y = rp->y + rp->height * 0.5; anchorPos.x = rp->x + rp->width; - if (x < graphPtr_->baseline) + if (x < gops->baseline) anchorPos.x -= rp->width; } else { anchorPos.x = rp->x + rp->width * 0.5; anchorPos.y = rp->y; - if (y < graphPtr_->baseline) + if (y < gops->baseline) anchorPos.y += rp->height; } Blt_DrawText(graphPtr_->tkwin, drawable, string, &penOps->valueStyle, @@ -1369,6 +1373,7 @@ void BarElement::BarValuesToPostScript(Blt_Ps ps, BarPen* penPtr, { BarPenOptions* penOps = (BarPenOptions*)penPtr->ops(); BarElementOptions* ops = (BarElementOptions*)ops_; + GraphOptions* gops = (GraphOptions*)graphPtr_->ops_; XRectangle *rp, *rend; char string[TCL_DOUBLE_SPACE * 2 + 2]; @@ -1393,16 +1398,16 @@ void BarElement::BarValuesToPostScript(Blt_Ps ps, BarPen* penPtr, strcat(string, ","); sprintf_s(string + strlen(string), TCL_DOUBLE_SPACE, fmt, y); } - if (graphPtr_->inverted) { + if (gops->inverted) { anchorPos.y = rp->y + rp->height * 0.5; anchorPos.x = rp->x + rp->width; - if (x < graphPtr_->baseline) { + if (x < gops->baseline) { anchorPos.x -= rp->width; } } else { anchorPos.x = rp->x + rp->width * 0.5; anchorPos.y = rp->y; - if (y < graphPtr_->baseline) { + if (y < gops->baseline) { anchorPos.y += rp->height; } } @@ -1415,6 +1420,7 @@ void BarElement::BarValuesToPostScript(Blt_Ps ps, BarPen* penPtr, void Blt_InitBarSetTable(Graph* graphPtr) { + GraphOptions* gops = (GraphOptions*)graphPtr->ops_; Blt_ChainLink link; int nStacks, nSegs; Tcl_HashTable setTable; @@ -1427,7 +1433,7 @@ void Blt_InitBarSetTable(Graph* graphPtr) * the array of frequency information and the table itself */ Blt_DestroyBarSets(graphPtr); - if (graphPtr->barMode == BARS_INFRONT) + if (gops->barMode == BARS_INFRONT) return; Tcl_InitHashTable(&graphPtr->setTable, sizeof(BarSetKey) / sizeof(int)); @@ -1540,8 +1546,10 @@ void Blt_InitBarSetTable(Graph* graphPtr) void Blt_ComputeBarStacks(Graph* graphPtr) { + GraphOptions* gops = (GraphOptions*)graphPtr->ops_; + Blt_ChainLink link; - if ((graphPtr->barMode != BARS_STACKED) || (graphPtr->nBarGroups == 0)) + if ((gops->barMode != BARS_STACKED) || (graphPtr->nBarGroups == 0)) return; /* Initialize the stack sums to zero. */ diff --git a/src/bltGrElemLine.C b/src/bltGrElemLine.C index cd6ae6c..e1c8d4f 100644 --- a/src/bltGrElemLine.C +++ b/src/bltGrElemLine.C @@ -549,8 +549,9 @@ void LineElement::extents(Region2d *extsPtr) void LineElement::closest() { LineElementOptions* ops = (LineElementOptions*)ops_; + GraphOptions* gops = (GraphOptions*)graphPtr_->ops_; - ClosestSearch* searchPtr = &graphPtr_->search; + ClosestSearch* searchPtr = &gops->search; int mode = searchPtr->mode; if (mode == SEARCH_AUTO) { LinePen* penPtr = NORMALPEN(ops); @@ -1050,6 +1051,7 @@ int LineElement::ScaleSymbol(int normalSize) void LineElement::GetScreenPoints(MapInfo *mapPtr) { LineElementOptions* ops = (LineElementOptions*)ops_; + GraphOptions* gops = (GraphOptions*)graphPtr_->ops_; if (!ops->coords.x || !ops->coords.y) { mapPtr->screenPts = NULL; @@ -1064,7 +1066,7 @@ void LineElement::GetScreenPoints(MapInfo *mapPtr) int* map = (int*)malloc(sizeof(int) * np); int count = 0; - if (graphPtr_->inverted) { + if (gops->inverted) { for (int i = 0; i < np; i++) { if ((isfinite(x[i])) && (isfinite(y[i]))) { points[count].x = ops->axes.y->hMap(y[i]); @@ -1762,6 +1764,7 @@ void LineElement::MapTraces(MapInfo *mapPtr) void LineElement::MapFillArea(MapInfo *mapPtr) { LineElementOptions* ops = (LineElementOptions*)ops_; + GraphOptions* gops = (GraphOptions*)graphPtr_->ops_; if (fillPts_) { free(fillPts_); @@ -1776,7 +1779,7 @@ void LineElement::MapFillArea(MapInfo *mapPtr) Blt_GraphExtents(graphPtr_, &exts); Point2d* origPts = (Point2d*)malloc(sizeof(Point2d) * np); - if (graphPtr_->inverted) { + if (gops->inverted) { double minX; int i; @@ -2044,7 +2047,8 @@ void LineElement::MapErrorBars(LineStyle **styleMap) int LineElement::ClosestTrace() { LineElementOptions* ops = (LineElementOptions*)ops_; - ClosestSearch* searchPtr = &graphPtr_->search; + GraphOptions* gops = (GraphOptions*)graphPtr_->ops_; + ClosestSearch* searchPtr = &gops->search; Blt_ChainLink link; Point2d closest; diff --git a/src/bltGrElemOp.C b/src/bltGrElemOp.C index 501c176..36b4a5b 100644 --- a/src/bltGrElemOp.C +++ b/src/bltGrElemOp.C @@ -276,7 +276,8 @@ static int BindOp(Graph* graphPtr, Tcl_Interp* interp, static int ClosestOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { - ClosestSearch* searchPtr = &graphPtr->search; + GraphOptions* gops = (GraphOptions*)graphPtr->ops_; + ClosestSearch* searchPtr = &gops->search; if (graphPtr->flags & RESET_AXES) Blt_ResetAxes(graphPtr); @@ -680,7 +681,8 @@ void Blt_ConfigureElements(Graph* graphPtr) void Blt_MapElements(Graph* graphPtr) { - if (graphPtr->barMode != BARS_INFRONT) + GraphOptions* gops = (GraphOptions*)graphPtr->ops_; + if (gops->barMode != BARS_INFRONT) Blt_ResetBarGroups(graphPtr); for (Blt_ChainLink link =Blt_Chain_FirstLink(graphPtr->elements.displayList); diff --git a/src/bltGrHairs.C b/src/bltGrHairs.C index 63c50c7..8fc01d4 100644 --- a/src/bltGrHairs.C +++ b/src/bltGrHairs.C @@ -84,6 +84,7 @@ Crosshairs::~Crosshairs() void Crosshairs::configure() { CrosshairsOptions* ops = (CrosshairsOptions*)ops_; + GraphOptions* gops = (GraphOptions*)graphPtr_->ops_; // Turn off the crosshairs temporarily. This is in case the new // configuration changes the size, style, or position of the lines. @@ -92,7 +93,7 @@ void Crosshairs::configure() XGCValues gcValues; gcValues.function = GXxor; - unsigned long int pixel = Tk_3DBorderColor(graphPtr_->plotBg)->pixel; + unsigned long int pixel = Tk_3DBorderColor(gops->plotBg)->pixel; gcValues.background = pixel; gcValues.foreground = (pixel ^ ops->colorPtr->pixel); diff --git a/src/bltGrLegd.C b/src/bltGrLegd.C index e0238da..0e7c771 100644 --- a/src/bltGrLegd.C +++ b/src/bltGrLegd.C @@ -379,6 +379,7 @@ void Legend::map(int plotWidth, int plotHeight) void Legend::draw(Drawable drawable) { LegendOptions* ops = (LegendOptions*)ops_; + GraphOptions* gops = (GraphOptions*)graphPtr_->ops_; if ((ops->hide) || (nEntries_ == 0)) return; @@ -404,7 +405,7 @@ void Legend::draw(Drawable drawable) case BOTTOM: case RIGHT: case LEFT: - Tk_Fill3DRectangle(tkwin, pixmap, graphPtr_->normalBg, 0, 0, + Tk_Fill3DRectangle(tkwin, pixmap, gops->normalBg, 0, 0, w, h, 0, TK_RELIEF_FLAT); break; case PLOT: @@ -417,7 +418,7 @@ void Legend::draw(Drawable drawable) XCopyArea(graphPtr_->display, graphPtr_->cache, pixmap, graphPtr_->drawGC, x_, y_, w, h, 0, 0); else - Tk_Fill3DRectangle(tkwin, pixmap, graphPtr_->plotBg, 0, 0, + Tk_Fill3DRectangle(tkwin, pixmap, gops->plotBg, 0, 0, w, h, TK_RELIEF_FLAT, 0); break; }; @@ -467,7 +468,7 @@ void Legend::draw(Drawable drawable) else { ops->style.color = ops->fgColor; if (elemOps->legendRelief != TK_RELIEF_FLAT) - Tk_Fill3DRectangle(tkwin, pixmap, graphPtr_->normalBg, + Tk_Fill3DRectangle(tkwin, pixmap, gops->normalBg, x, y, entryWidth_, entryHeight_, ops->entryBW, elemOps->legendRelief); @@ -504,7 +505,7 @@ void Legend::draw(Drawable drawable) Tk_3DBorder bg = ops->normalBg; if (!bg) - bg = graphPtr_->normalBg; + bg = gops->normalBg; // Disable crosshairs before redisplaying to the screen switch ((Position)ops->position) { @@ -537,6 +538,7 @@ void Legend::draw(Drawable drawable) void Legend::print(Blt_Ps ps) { LegendOptions* ops = (LegendOptions*)ops_; + GraphOptions* gops = (GraphOptions*)graphPtr_->ops_; if ((ops->hide) || (nEntries_ == 0)) return; @@ -554,7 +556,7 @@ void Legend::print(Blt_Ps ps) Blt_Ps_Fill3DRectangle(ps, ops->normalBg, x, y, width, height, ops->borderWidth, ops->relief); else - Blt_Ps_Draw3DRectangle(ps, graphPtr_->normalBg, x, y, width, height, + Blt_Ps_Draw3DRectangle(ps, gops->normalBg, x, y, width, height, ops->borderWidth, ops->relief); } @@ -597,7 +599,7 @@ void Legend::print(Blt_Ps ps) else { ops->style.color = ops->fgColor; if (elemOps->legendRelief != TK_RELIEF_FLAT) { - Blt_Ps_Draw3DRectangle(ps, graphPtr_->normalBg, x, y, + Blt_Ps_Draw3DRectangle(ps, gops->normalBg, x, y, entryWidth_, entryHeight_, ops->entryBW, elemOps->legendRelief); @@ -641,6 +643,7 @@ void Legend::eventuallyInvokeSelectCmd() void Legend::setOrigin() { LegendOptions* ops = (LegendOptions*)ops_; + GraphOptions* gops = (GraphOptions*)graphPtr_->ops_; int x =0; int y =0; @@ -648,14 +651,14 @@ void Legend::setOrigin() int h =0; switch ((Position)ops->position) { case RIGHT: - w = graphPtr_->rightMargin.width - graphPtr_->rightMargin.axesOffset; + w = gops->rightMargin.width - gops->rightMargin.axesOffset; h = graphPtr_->bottom - graphPtr_->top; - x = graphPtr_->right + graphPtr_->rightMargin.axesOffset; + x = graphPtr_->right + gops->rightMargin.axesOffset; y = graphPtr_->top; break; case LEFT: - w = graphPtr_->leftMargin.width - graphPtr_->leftMargin.axesOffset; + w = gops->leftMargin.width - gops->leftMargin.axesOffset; h = graphPtr_->bottom - graphPtr_->top; x = graphPtr_->inset; y = graphPtr_->top; @@ -663,21 +666,21 @@ void Legend::setOrigin() case TOP: w = graphPtr_->right - graphPtr_->left; - h = graphPtr_->topMargin.height - graphPtr_->topMargin.axesOffset; - if (graphPtr_->title) + h = gops->topMargin.height - gops->topMargin.axesOffset; + if (gops->title) h -= graphPtr_->titleHeight; x = graphPtr_->left; y = graphPtr_->inset; - if (graphPtr_->title) + if (gops->title) y += graphPtr_->titleHeight; break; case BOTTOM: w = graphPtr_->right - graphPtr_->left; - h = graphPtr_->bottomMargin.height - graphPtr_->bottomMargin.axesOffset; + h = gops->bottomMargin.height - gops->bottomMargin.axesOffset; x = graphPtr_->left; - y = graphPtr_->bottom + graphPtr_->bottomMargin.axesOffset; + y = graphPtr_->bottom + gops->bottomMargin.axesOffset; break; case PLOT: diff --git a/src/bltGrMarker.C b/src/bltGrMarker.C index 6332386..2f1f585 100644 --- a/src/bltGrMarker.C +++ b/src/bltGrMarker.C @@ -115,8 +115,9 @@ double Marker::VMap(Axis *axisPtr, double y) Point2d Marker::mapPoint(Point2d* pointPtr, Axis2d* axesPtr) { + GraphOptions* gops = (GraphOptions*)graphPtr_->ops_; Point2d result; - if (graphPtr_->inverted) { + if (gops->inverted) { result.x = HMap(axesPtr->y, pointPtr->y); result.y = VMap(axesPtr->x, pointPtr->x); } diff --git a/src/bltGrMarkerLine.C b/src/bltGrMarkerLine.C index 28a973f..bdbee9e 100644 --- a/src/bltGrMarkerLine.C +++ b/src/bltGrMarkerLine.C @@ -106,6 +106,7 @@ LineMarker::~LineMarker() int LineMarker::configure() { LineMarkerOptions* ops = (LineMarkerOptions*)ops_; + GraphOptions* gops = (GraphOptions*)graphPtr_->ops_; Drawable drawable = Tk_WindowId(graphPtr_->tkwin); unsigned long gcMask = (GCLineWidth | GCLineStyle | GCCapStyle | GCJoinStyle); @@ -131,7 +132,7 @@ int LineMarker::configure() gcValues.function = GXxor; gcMask |= GCFunction; - pixel = Tk_3DBorderColor(graphPtr_->plotBg)->pixel; + pixel = Tk_3DBorderColor(gops->plotBg)->pixel; if (gcMask & GCBackground) gcValues.background ^= pixel; @@ -213,8 +214,9 @@ void LineMarker::map() int LineMarker::pointIn(Point2d *samplePtr) { + GraphOptions* gops = (GraphOptions*)graphPtr_->ops_; return pointInSegments(samplePtr, segments_, nSegments_, - (double)graphPtr_->search.halo); + (double)gops->search.halo); } int LineMarker::pointInSegments(Point2d* samplePtr, Segment2d* segments, diff --git a/src/bltGrMarkerPolygon.C b/src/bltGrMarkerPolygon.C index ef445bf..a522047 100644 --- a/src/bltGrMarkerPolygon.C +++ b/src/bltGrMarkerPolygon.C @@ -123,6 +123,7 @@ PolygonMarker::~PolygonMarker() int PolygonMarker::configure() { PolygonMarkerOptions* ops = (PolygonMarkerOptions*)ops_; + GraphOptions* gops = (GraphOptions*)graphPtr_->ops_; Drawable drawable = Tk_WindowId(graphPtr_->tkwin); unsigned long gcMask = (GCLineWidth | GCLineStyle); @@ -150,7 +151,7 @@ int PolygonMarker::configure() gcValues.function = GXxor; gcMask |= GCFunction; - pixel = Tk_3DBorderColor(graphPtr_->plotBg)->pixel; + pixel = Tk_3DBorderColor(gops->plotBg)->pixel; if (gcMask & GCBackground) gcValues.background ^= pixel; diff --git a/src/bltGrXAxisOp.C b/src/bltGrXAxisOp.C index 7a697dc..fb18f9f 100644 --- a/src/bltGrXAxisOp.C +++ b/src/bltGrXAxisOp.C @@ -108,8 +108,9 @@ static int UseOp(Tcl_Interp* interp, Axis* axisPtr, int objc, Tcl_Obj* const objv[]) { Graph* graphPtr = (Graph *)axisPtr; + GraphOptions* gops = (GraphOptions*)graphPtr->ops_; - Blt_Chain chain = graphPtr->margins[lastMargin].axes; + Blt_Chain chain = gops->margins[lastMargin].axes; if (objc == 3) { Tcl_Obj *listObjPtr; @@ -125,9 +126,9 @@ static int UseOp(Tcl_Interp* interp, Axis* axisPtr, } ClassId classId; if ((lastMargin == MARGIN_BOTTOM) || (lastMargin == MARGIN_TOP)) - classId = (graphPtr->inverted) ? CID_AXIS_Y : CID_AXIS_X; + classId = (gops->inverted) ? CID_AXIS_Y : CID_AXIS_X; else - classId = (graphPtr->inverted) ? CID_AXIS_X : CID_AXIS_Y; + classId = (gops->inverted) ? CID_AXIS_X : CID_AXIS_Y; int axisObjc; Tcl_Obj **axisObjv; @@ -199,6 +200,7 @@ typedef int (GraphAxisProc)(Tcl_Interp* interp, Axis* axisPtr, int Blt_XAxisOp(Tcl_Interp* interp, Graph* graphPtr, int margin, int objc, Tcl_Obj* const objv[]) { + GraphOptions* gops = (GraphOptions*)graphPtr->ops_; GraphAxisProc* proc = (GraphAxisProc*)Blt_GetOpFromObj(interp, nAxisOps, axisOps, BLT_OP_ARG2, objc, objv, 0); if (!proc) return TCL_ERROR; @@ -208,7 +210,7 @@ int Blt_XAxisOp(Tcl_Interp* interp, Graph* graphPtr, int margin, return (*proc)(interp, (Axis*)graphPtr, objc, objv); } else { - Axis* axisPtr = Blt_GetFirstAxis(graphPtr->margins[margin].axes); + Axis* axisPtr = Blt_GetFirstAxis(gops->margins[margin].axes); if (!axisPtr) return TCL_OK; return (*proc)(interp, axisPtr, objc, objv); diff --git a/src/bltGraph.C b/src/bltGraph.C index c66fb0d..22397dd 100644 --- a/src/bltGraph.C +++ b/src/bltGraph.C @@ -76,111 +76,126 @@ const char* searchAlongObjOption[] = {"x", "y", "both", NULL}; static Tk_OptionSpec optionSpecs[] = { {TK_OPTION_DOUBLE, "-aspect", "aspect", "Aspect", - "0", -1, Tk_Offset(Graph, aspect), 0, NULL, RESET_WORLD | CACHE_DIRTY}, + "0", -1, Tk_Offset(GraphOptions, aspect), + 0, NULL, RESET_WORLD | CACHE_DIRTY}, {TK_OPTION_BORDER, "-background", "background", "Background", - STD_NORMAL_BACKGROUND, -1, Tk_Offset(Graph, normalBg), 0, NULL, CACHE_DIRTY}, + STD_NORMAL_BACKGROUND, -1, Tk_Offset(GraphOptions, normalBg), + 0, NULL, CACHE_DIRTY}, {TK_OPTION_STRING_TABLE, "-barmode", "barMode", "BarMode", - "normal", -1, Tk_Offset(Graph, barMode), 0, &barmodeObjOption, - RESET_WORLD | CACHE_DIRTY}, + "normal", -1, Tk_Offset(GraphOptions, barMode), + 0, &barmodeObjOption, RESET_WORLD | CACHE_DIRTY}, {TK_OPTION_DOUBLE, "-barwidth", "barWidth", "BarWidth", - ".9", -1, Tk_Offset(Graph, barWidth), 0, NULL, RESET_WORLD | CACHE_DIRTY}, + ".9", -1, Tk_Offset(GraphOptions, barWidth), + 0, NULL, RESET_WORLD | CACHE_DIRTY}, {TK_OPTION_DOUBLE, "-baseline", "baseline", "Baseline", - "0", -1, Tk_Offset(Graph, baseline), 0, NULL, 0}, + "0", -1, Tk_Offset(GraphOptions, baseline), 0, 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_SYNONYM, "-bm", NULL, NULL, NULL, -1, 0, 0, "-bottommargin", 0}, {TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", - STD_BORDERWIDTH, -1, Tk_Offset(Graph, borderWidth), 0, NULL, + STD_BORDERWIDTH, -1, Tk_Offset(GraphOptions, borderWidth), 0, NULL, RESET_WORLD | CACHE_DIRTY}, {TK_OPTION_PIXELS, "-bottommargin", "bottomMargin", "BottomMargin", - "0", -1, Tk_Offset(Graph, bottomMargin.reqSize), 0, NULL, + "0", -1, Tk_Offset(GraphOptions, bottomMargin.reqSize), 0, NULL, RESET_WORLD | CACHE_DIRTY}, {TK_OPTION_STRING, "-bottomvariable", "bottomVariable", "BottomVariable", - NULL, -1, Tk_Offset(Graph, bottomMargin.varName), + NULL, -1, Tk_Offset(GraphOptions, bottomMargin.varName), TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_BOOLEAN, "-bufferelements", "bufferElements", "BufferElements", - "yes", -1, Tk_Offset(Graph, backingStore), 0, NULL, 0}, + "yes", -1, Tk_Offset(GraphOptions, backingStore), 0, NULL, 0}, {TK_OPTION_BOOLEAN, "-buffergraph", "bufferGraph", "BufferGraph", - "yes", -1, Tk_Offset(Graph, doubleBuffer), 0, NULL, 0}, + "yes", -1, Tk_Offset(GraphOptions, doubleBuffer), 0, NULL, 0}, {TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", - "crosshair", -1, Tk_Offset(Graph, cursor), TK_OPTION_NULL_OK, NULL, 0}, + "crosshair", -1, Tk_Offset(GraphOptions, cursor), + TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_SYNONYM, "-fg", NULL, NULL, NULL, -1, 0, 0, "-foreground", 0}, {TK_OPTION_FONT, "-font", "font", "Font", - STD_FONT_MEDIUM, -1, Tk_Offset(Graph, titleTextStyle.font), 0, NULL, + STD_FONT_MEDIUM, -1, Tk_Offset(GraphOptions, titleTextStyle.font), 0, NULL, RESET_WORLD | CACHE_DIRTY}, {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", - STD_NORMAL_FOREGROUND, -1, Tk_Offset(Graph, titleTextStyle.color), 0, NULL, + STD_NORMAL_FOREGROUND, -1, Tk_Offset(GraphOptions, titleTextStyle.color), + 0, NULL, CACHE_DIRTY}, {TK_OPTION_SYNONYM, "-halo", NULL, NULL, NULL, -1, 0, 0, "-searchhalo", 0}, {TK_OPTION_PIXELS, "-height", "height", "Height", - "4i", -1, Tk_Offset(Graph, reqHeight), 0, NULL, RESET_WORLD | CACHE_DIRTY}, + "4i", -1, Tk_Offset(GraphOptions, reqHeight), + 0, NULL, RESET_WORLD | CACHE_DIRTY}, {TK_OPTION_COLOR, "-highlightbackground", "highlightBackground", "HighlightBackground", - STD_NORMAL_BACKGROUND, -1, Tk_Offset(Graph, highlightBgColor), 0, NULL, + STD_NORMAL_BACKGROUND, -1, Tk_Offset(GraphOptions, highlightBgColor), + 0, NULL, CACHE_DIRTY}, {TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor", - STD_NORMAL_FOREGROUND, -1, Tk_Offset(Graph, highlightColor), 0, NULL, 0}, + STD_NORMAL_FOREGROUND, -1, Tk_Offset(GraphOptions, highlightColor), + 0, NULL, 0}, {TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness", "HighlightThickness", - "2", -1, Tk_Offset(Graph, highlightWidth), 0, NULL, 0}, + "2", -1, Tk_Offset(GraphOptions, highlightWidth), 0, NULL, 0}, {TK_OPTION_BOOLEAN, "-invertxy", "invertXY", "InvertXY", - "no", -1, Tk_Offset(Graph, inverted), 0, NULL, + "no", -1, Tk_Offset(GraphOptions, inverted), 0, NULL, RESET_WORLD | CACHE_DIRTY | RESET_AXES}, {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", - "center", -1, Tk_Offset(Graph, titleTextStyle.justify), 0, NULL, 0}, + "center", -1, Tk_Offset(GraphOptions, titleTextStyle.justify), 0, NULL, 0}, {TK_OPTION_PIXELS, "-leftmargin", "leftMargin", "Margin", - "0", -1, Tk_Offset(Graph, leftMargin.reqSize), 0, NULL, + "0", -1, Tk_Offset(GraphOptions, leftMargin.reqSize), 0, NULL, RESET_WORLD | CACHE_DIRTY}, {TK_OPTION_STRING, "-leftvariable", "leftVariable", "LeftVariable", - NULL, -1, Tk_Offset(Graph, leftMargin.varName), TK_OPTION_NULL_OK, NULL, 0}, + NULL, -1, Tk_Offset(GraphOptions, leftMargin.varName), + TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_SYNONYM, "-lm", NULL, NULL, NULL, -1, 0, 0, "-leftmargin", 0}, {TK_OPTION_BORDER, "-plotbackground", "plotbackground", "PlotBackground", - STD_NORMAL_BACKGROUND, -1, Tk_Offset(Graph, plotBg), 0, NULL, + STD_NORMAL_BACKGROUND, -1, Tk_Offset(GraphOptions, plotBg), 0, NULL, RESET_WORLD | CACHE_DIRTY}, {TK_OPTION_PIXELS, "-plotborderwidth", "plotBorderWidth", "PlotBorderWidth", - STD_BORDERWIDTH, -1, Tk_Offset(Graph, plotBW), 0, NULL, + STD_BORDERWIDTH, -1, Tk_Offset(GraphOptions, plotBW), 0, NULL, RESET_WORLD | CACHE_DIRTY}, {TK_OPTION_PIXELS, "-plotpadx", "plotPadX", "PlotPad", - "0", -1, Tk_Offset(Graph, xPad), 0, NULL, RESET_WORLD | CACHE_DIRTY}, + "0", -1, Tk_Offset(GraphOptions, xPad), 0, NULL, RESET_WORLD | CACHE_DIRTY}, {TK_OPTION_PIXELS, "-plotpady", "plotPadY", "PlotPad", - "0", -1, Tk_Offset(Graph, yPad), 0, NULL, RESET_WORLD | CACHE_DIRTY}, + "0", -1, Tk_Offset(GraphOptions, yPad), 0, NULL, RESET_WORLD | CACHE_DIRTY}, {TK_OPTION_RELIEF, "-plotrelief", "plotRelief", "Relief", - "flat", -1, Tk_Offset(Graph, plotRelief), 0, NULL, + "flat", -1, Tk_Offset(GraphOptions, plotRelief), 0, NULL, RESET_WORLD | CACHE_DIRTY}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", - "flat", -1, Tk_Offset(Graph, relief), 0, NULL, 0}, + "flat", -1, Tk_Offset(GraphOptions, relief), 0, NULL, 0}, {TK_OPTION_PIXELS, "-rightmargin", "rightMargin", "Margin", - "0", -1, Tk_Offset(Graph, rightMargin.reqSize), 0, NULL, + "0", -1, Tk_Offset(GraphOptions, rightMargin.reqSize), 0, NULL, RESET_WORLD | CACHE_DIRTY}, {TK_OPTION_STRING, "-rightvariable", "rightVariable", "RightVariable", - NULL, -1, Tk_Offset(Graph, rightMargin.varName), TK_OPTION_NULL_OK, NULL, 0}, + NULL, -1, Tk_Offset(GraphOptions, rightMargin.varName), + TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_SYNONYM, "-rm", NULL, NULL, NULL, -1, 0, 0, "-rightmargin", 0}, {TK_OPTION_PIXELS, "-searchhalo", "searchhalo", "SearchHalo", - "2m", -1, Tk_Offset(Graph, search.halo), 0, NULL, 0}, + "2m", -1, Tk_Offset(GraphOptions, search.halo), 0, NULL, 0}, {TK_OPTION_STRING_TABLE, "-searchmode", "searchMode", "SearchMode", - "points", -1, Tk_Offset(Graph, search.mode), 0, &searchModeObjOption, 0}, + "points", -1, Tk_Offset(GraphOptions, search.mode), + 0, &searchModeObjOption, 0}, {TK_OPTION_STRING_TABLE, "-searchalong", "searchAlong", "SearchAlong", - "both", -1, Tk_Offset(Graph, search.along), 0, &searchAlongObjOption, 0}, + "both", -1, Tk_Offset(GraphOptions, search.along), + 0, &searchAlongObjOption, 0}, {TK_OPTION_BOOLEAN, "-stackaxes", "stackAxes", "StackAxes", - "no", -1, Tk_Offset(Graph, stackAxes), 0, NULL, 0}, + "no", -1, Tk_Offset(GraphOptions, stackAxes), 0, NULL, 0}, {TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", - NULL, -1, Tk_Offset(Graph, takeFocus), TK_OPTION_NULL_OK, NULL, 0}, + NULL, -1, Tk_Offset(GraphOptions, takeFocus), TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_STRING, "-title", "title", "Title", - NULL, -1, Tk_Offset(Graph, title), TK_OPTION_NULL_OK, NULL, - RESET_WORLD | CACHE_DIRTY}, + NULL, -1, Tk_Offset(GraphOptions, title), + TK_OPTION_NULL_OK, NULL, RESET_WORLD | CACHE_DIRTY}, {TK_OPTION_SYNONYM, "-tm", NULL, NULL, NULL, -1, 0, 0, "-topmargin", 0}, {TK_OPTION_PIXELS, "-topmargin", "topMargin", "TopMargin", - "0", -1, Tk_Offset(Graph, topMargin.reqSize), 0, NULL, - RESET_WORLD | CACHE_DIRTY}, + "0", -1, Tk_Offset(GraphOptions, topMargin.reqSize), + 0, NULL, RESET_WORLD | CACHE_DIRTY}, {TK_OPTION_STRING, "-topvariable", "topVariable", "TopVariable", - NULL, -1, Tk_Offset(Graph, topMargin.varName), TK_OPTION_NULL_OK, NULL, 0}, + NULL, -1, Tk_Offset(GraphOptions, topMargin.varName), + TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_PIXELS, "-width", "width", "Width", - "5i", -1, Tk_Offset(Graph, reqWidth), 0, NULL, RESET_WORLD | CACHE_DIRTY}, + "5i", -1, Tk_Offset(GraphOptions, reqWidth), + 0, NULL, RESET_WORLD | CACHE_DIRTY}, {TK_OPTION_PIXELS, "-plotwidth", "plotWidth", "PlotWidth", - "0", -1, Tk_Offset(Graph, reqPlotWidth), 0, NULL, RESET_WORLD | CACHE_DIRTY}, + "0", -1, Tk_Offset(GraphOptions, reqPlotWidth), + 0, NULL, RESET_WORLD | CACHE_DIRTY}, {TK_OPTION_PIXELS, "-plotheight", "plotHeight", "PlotHeight", - "0", -1, Tk_Offset(Graph, reqPlotHeight), 0, NULL, - RESET_WORLD | CACHE_DIRTY}, + "0", -1, Tk_Offset(GraphOptions, reqPlotHeight), + 0, NULL, RESET_WORLD | CACHE_DIRTY}, {TK_OPTION_END, NULL, NULL, NULL, NULL, -1, 0, 0, NULL, 0} }; @@ -210,6 +225,9 @@ int NewGraph(ClientData clientData, Tcl_Interp*interp, Graph* graphPtr = (Graph*)calloc(1, sizeof(Graph)); ((TkWindow*)tkwin)->instanceData = graphPtr; + graphPtr->ops_ = (GraphOptions*)calloc(1, sizeof(GraphOptions)); + GraphOptions* ops = (GraphOptions*)graphPtr->ops_; + graphPtr->tkwin = tkwin; graphPtr->display = Tk_Display(tkwin); graphPtr->interp = interp; @@ -220,22 +238,15 @@ int NewGraph(ClientData clientData, Tcl_Interp*interp, GraphInstCmdDeleteProc); graphPtr->optionTable = optionTable; graphPtr->classId = classId; - graphPtr->backingStore = 1; - graphPtr->doubleBuffer = 1; - graphPtr->borderWidth = 2; - graphPtr->plotBW = 1; - graphPtr->highlightWidth = 2; - graphPtr->plotRelief = TK_RELIEF_SOLID; - graphPtr->relief = TK_RELIEF_FLAT; graphPtr->flags = MAP_WORLD | REDRAW_WORLD; graphPtr->nextMarkerId = 1; - graphPtr->bottomMargin.site = MARGIN_BOTTOM; - graphPtr->leftMargin.site = MARGIN_LEFT; - graphPtr->topMargin.site = MARGIN_TOP; - graphPtr->rightMargin.site = MARGIN_RIGHT; + ops->bottomMargin.site = MARGIN_BOTTOM; + ops->leftMargin.site = MARGIN_LEFT; + ops->topMargin.site = MARGIN_TOP; + ops->rightMargin.site = MARGIN_RIGHT; - Blt_Ts_InitStyle(graphPtr->titleTextStyle); - graphPtr->titleTextStyle.anchor = TK_ANCHOR_N; + Blt_Ts_InitStyle(ops->titleTextStyle); + ops->titleTextStyle.anchor = TK_ANCHOR_N; Tcl_InitHashTable(&graphPtr->axes.table, TCL_STRING_KEYS); Tcl_InitHashTable(&graphPtr->axes.tagTable, TCL_STRING_KEYS); @@ -272,7 +283,7 @@ int NewGraph(ClientData clientData, Tcl_Interp*interp, ExposureMask|StructureNotifyMask|FocusChangeMask, GraphEventProc, graphPtr); - if ((Tk_InitOptions(interp, (char*)graphPtr, optionTable, tkwin) != TCL_OK) || + if ((Tk_InitOptions(interp, (char*)graphPtr->ops_, optionTable, tkwin) != TCL_OK) || (GraphObjConfigure(interp, graphPtr, objc-2, objv+2) != TCL_OK)) return TCL_ERROR; @@ -288,6 +299,8 @@ int NewGraph(ClientData clientData, Tcl_Interp*interp, void GraphDestroy(Graph* graphPtr) { + GraphOptions* ops = (GraphOptions*)graphPtr->ops_; + Blt::DestroyMarkers(graphPtr); if (graphPtr->crosshairs) @@ -307,36 +320,42 @@ void GraphDestroy(Graph* graphPtr) if (graphPtr->drawGC) Tk_FreeGC(graphPtr->display, graphPtr->drawGC); - Blt_Ts_FreeStyle(graphPtr->display, &graphPtr->titleTextStyle); + Blt_Ts_FreeStyle(graphPtr->display, &ops->titleTextStyle); if (graphPtr->cache != None) Tk_FreePixmap(graphPtr->display, graphPtr->cache); - Tk_FreeConfigOptions((char*)graphPtr, graphPtr->optionTable, graphPtr->tkwin); + Tk_FreeConfigOptions((char*)graphPtr->ops_, graphPtr->optionTable, graphPtr->tkwin); Tcl_Release(graphPtr->tkwin); graphPtr->tkwin = NULL; + + if (graphPtr->ops_) + free (graphPtr->ops_); + free(graphPtr); } void GraphConfigure(Graph* graphPtr) { + GraphOptions* ops = (GraphOptions*)graphPtr->ops_; + // Don't allow negative bar widths. Reset to an arbitrary value (0.1) - if (graphPtr->barWidth <= 0.0f) { - graphPtr->barWidth = 0.8f; + if (ops->barWidth <= 0.0f) + ops->barWidth = 0.8f; + + graphPtr->inset = ops->borderWidth + ops->highlightWidth; + if ((ops->reqHeight != Tk_ReqHeight(graphPtr->tkwin)) || + (ops->reqWidth != Tk_ReqWidth(graphPtr->tkwin))) { + Tk_GeometryRequest(graphPtr->tkwin, ops->reqWidth, + ops->reqHeight); } - graphPtr->inset = graphPtr->borderWidth + graphPtr->highlightWidth; - if ((graphPtr->reqHeight != Tk_ReqHeight(graphPtr->tkwin)) || - (graphPtr->reqWidth != Tk_ReqWidth(graphPtr->tkwin))) { - Tk_GeometryRequest(graphPtr->tkwin, graphPtr->reqWidth, - graphPtr->reqHeight); - } - Tk_SetInternalBorder(graphPtr->tkwin, graphPtr->borderWidth); - XColor* colorPtr = Tk_3DBorderColor(graphPtr->normalBg); + Tk_SetInternalBorder(graphPtr->tkwin, ops->borderWidth); + XColor* colorPtr = Tk_3DBorderColor(ops->normalBg); graphPtr->titleWidth = graphPtr->titleHeight = 0; - if (graphPtr->title != NULL) { + if (ops->title != NULL) { unsigned int w, h; - Blt_Ts_GetExtents(&graphPtr->titleTextStyle, graphPtr->title, &w, &h); + Blt_Ts_GetExtents(&ops->titleTextStyle, ops->title, &w, &h); graphPtr->titleHeight = h; } @@ -344,7 +363,7 @@ void GraphConfigure(Graph* graphPtr) // clearing the margins with XFillRectangle // Margin XGCValues gcValues; - gcValues.foreground = graphPtr->titleTextStyle.color->pixel; + gcValues.foreground = ops->titleTextStyle.color->pixel; gcValues.background = colorPtr->pixel; unsigned long gcMask = (GCForeground | GCBackground); GC newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues); @@ -359,7 +378,7 @@ void GraphConfigure(Graph* graphPtr) AdjustAxisPointers(graphPtr); // Free the pixmap if we're not buffering the display of elements anymore. - if ((!graphPtr->backingStore) && (graphPtr->cache != None)) { + if ((!ops->backingStore) && (graphPtr->cache != None)) { Tk_FreePixmap(graphPtr->display, graphPtr->cache); graphPtr->cache = None; } @@ -367,7 +386,8 @@ void GraphConfigure(Graph* graphPtr) void GraphDisplay(Graph* graphPtr) { - Tk_Window tkwin = graphPtr->tkwin; + GraphOptions* ops = (GraphOptions*)graphPtr->ops_; + Tk_Window tkwin = graphPtr->tkwin; graphPtr->flags &= ~REDRAW_PENDING; if ((graphPtr->flags & GRAPH_DELETED) || !Tk_IsMapped(tkwin)) @@ -389,13 +409,13 @@ void GraphDisplay(Graph* graphPtr) } /* Create a pixmap the size of the window for double buffering. */ Pixmap drawable; - if (graphPtr->doubleBuffer) + if (ops->doubleBuffer) drawable = Tk_GetPixmap(graphPtr->display, Tk_WindowId(tkwin), graphPtr->width, graphPtr->height, Tk_Depth(tkwin)); else drawable = Tk_WindowId(tkwin); - if (graphPtr->backingStore) { + if (ops->backingStore) { if ((graphPtr->cache == None) || (graphPtr->cacheWidth != graphPtr->width) || (graphPtr->cacheHeight != graphPtr->height)) { @@ -413,7 +433,7 @@ void GraphDisplay(Graph* graphPtr) graphPtr->flags |= CACHE_DIRTY; } } - if (graphPtr->backingStore) { + if (ops->backingStore) { if (graphPtr->flags & CACHE_DIRTY) { /* The backing store is new or out-of-date. */ DrawPlot(graphPtr, graphPtr->cache); @@ -444,19 +464,19 @@ void GraphDisplay(Graph* graphPtr) } // Draw 3D border just inside of the focus highlight ring - if ((graphPtr->borderWidth > 0) && (graphPtr->relief != TK_RELIEF_FLAT)) { - Tk_Draw3DRectangle(graphPtr->tkwin, drawable, graphPtr->normalBg, - graphPtr->highlightWidth, graphPtr->highlightWidth, - graphPtr->width - 2*graphPtr->highlightWidth, - graphPtr->height - 2*graphPtr->highlightWidth, - graphPtr->borderWidth, graphPtr->relief); + if ((ops->borderWidth > 0) && (ops->relief != TK_RELIEF_FLAT)) { + Tk_Draw3DRectangle(graphPtr->tkwin, drawable, ops->normalBg, + ops->highlightWidth, ops->highlightWidth, + graphPtr->width - 2*ops->highlightWidth, + graphPtr->height - 2*ops->highlightWidth, + ops->borderWidth, ops->relief); } /* Draw focus highlight ring. */ - if ((graphPtr->highlightWidth > 0) && (graphPtr->flags & FOCUS)) { + if ((ops->highlightWidth > 0) && (graphPtr->flags & FOCUS)) { GC gc; - gc = Tk_GCForColor(graphPtr->highlightColor, drawable); - Tk_DrawFocusHighlight(graphPtr->tkwin, gc, graphPtr->highlightWidth, + gc = Tk_GCForColor(ops->highlightColor, drawable); + Tk_DrawFocusHighlight(graphPtr->tkwin, gc, ops->highlightWidth, drawable); } /* Disable crosshairs before redisplaying to the screen */ @@ -464,7 +484,7 @@ void GraphDisplay(Graph* graphPtr) XCopyArea(graphPtr->display, drawable, Tk_WindowId(tkwin), graphPtr->drawGC, 0, 0, graphPtr->width, graphPtr->height, 0, 0); Blt_EnableCrosshairs(graphPtr); - if (graphPtr->doubleBuffer) { + if (ops->doubleBuffer) { Tk_FreePixmap(graphPtr->display, drawable); } @@ -488,144 +508,21 @@ void Blt_EventuallyRedrawGraph(Graph* graphPtr) static void AdjustAxisPointers(Graph* graphPtr) { - if (graphPtr->inverted) { - graphPtr->leftMargin.axes = graphPtr->axisChain[0]; - graphPtr->bottomMargin.axes = graphPtr->axisChain[1]; - graphPtr->rightMargin.axes = graphPtr->axisChain[2]; - graphPtr->topMargin.axes = graphPtr->axisChain[3]; + GraphOptions* ops = (GraphOptions*)graphPtr->ops_; + if (ops->inverted) { + ops->leftMargin.axes = graphPtr->axisChain[0]; + ops->bottomMargin.axes = graphPtr->axisChain[1]; + ops->rightMargin.axes = graphPtr->axisChain[2]; + ops->topMargin.axes = graphPtr->axisChain[3]; } else { - graphPtr->leftMargin.axes = graphPtr->axisChain[1]; - graphPtr->bottomMargin.axes = graphPtr->axisChain[0]; - graphPtr->rightMargin.axes = graphPtr->axisChain[3]; - graphPtr->topMargin.axes = graphPtr->axisChain[2]; + ops->leftMargin.axes = graphPtr->axisChain[1]; + ops->bottomMargin.axes = graphPtr->axisChain[0]; + ops->rightMargin.axes = graphPtr->axisChain[3]; + ops->topMargin.axes = graphPtr->axisChain[2]; } } -void Blt_GraphTags(Blt_BindTable table, ClientData object, ClientData context, - Blt_List list) -{ - Graph* graphPtr = (Graph*)Blt_GetBindingData(table); - ClassId classId = (ClassId)(long(context)); - - switch (classId) { - case CID_ELEM_BAR: - case CID_ELEM_LINE: - { - Element* elemPtr = (Element*)object; - ElementOptions* ops = (ElementOptions*)elemPtr->ops(); - MakeTagProc* tagProc = Blt_MakeElementTag; - Blt_List_Append(list, (const char*)(*tagProc)(graphPtr, elemPtr->name()), 0); - Blt_List_Append(list, (const char*)(*tagProc)(graphPtr, elemPtr->className()), 0); - if (ops->tags) - for (const char** p = ops->tags; *p != NULL; p++) - Blt_List_Append(list, (const char*)(*tagProc)(graphPtr, *p), 0); - } - break; - case CID_AXIS_X: - case CID_AXIS_Y: - { - Axis* axisPtr = (Axis*)object; - AxisOptions* ops = (AxisOptions*)axisPtr->ops(); - MakeTagProc* tagProc = Blt_MakeAxisTag; - Blt_List_Append(list, (const char*)(*tagProc)(graphPtr, axisPtr->name()), 0); - Blt_List_Append(list, (const char*)(*tagProc)(graphPtr, axisPtr->className()), 0); - if (ops->tags) - for (const char** p = ops->tags; *p != NULL; p++) - Blt_List_Append(list, (const char*)(*tagProc)(graphPtr, *p), 0); - } - break; - case CID_MARKER_BITMAP: - case CID_MARKER_LINE: - case CID_MARKER_POLYGON: - case CID_MARKER_TEXT: - case CID_MARKER_WINDOW: - { - Marker* markerPtr = (Marker*)object; - MarkerOptions* ops = (MarkerOptions*)markerPtr->ops(); - MakeTagProc* tagProc = Blt::MakeMarkerTag; - Blt_List_Append(list, (const char*)(*tagProc)(graphPtr, markerPtr->name()), 0); - Blt_List_Append(list, (const char*)(*tagProc)(graphPtr, markerPtr->className()), 0); - if (ops->tags) - for (const char** p = ops->tags; *p != NULL; p++) - Blt_List_Append(list, (const char*)(*tagProc)(graphPtr, *p), 0); - - } - break; - default: - break; - } -} - -// Find the closest point from the set of displayed elements, searching -// the display list from back to front. That way, if the points from -// two different elements overlay each other exactly, the one that's on -// top (visible) is picked. -static ClientData PickEntry(ClientData clientData, int x, int y, - ClientData* contextPtr) -{ - Graph* graphPtr = (Graph*)clientData; - - if (graphPtr->flags & MAP_ALL) { - *contextPtr = (ClientData)NULL; - return NULL; - } - - Region2d exts; - Blt_GraphExtents(graphPtr, &exts); - - // Sample coordinate is in one of the graph margins. Can only pick an axis. - if ((x >= exts.right) || (x < exts.left) || - (y >= exts.bottom) || (y < exts.top)) { - Axis* axisPtr = Blt_NearestAxis(graphPtr, x, y); - if (axisPtr) { - *contextPtr = (ClientData)axisPtr->classId(); - return axisPtr; - } - } - - // From top-to-bottom check: - // 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, 0); - if (markerPtr) { - *contextPtr = (ClientData)markerPtr->classId(); - return markerPtr; - } - - ClosestSearch* searchPtr = &graphPtr->search; - searchPtr->index = -1; - searchPtr->x = x; - searchPtr->y = y; - searchPtr->dist = (double)(searchPtr->halo + 1); - - Blt_ChainLink link; - Element* elemPtr; - for (link = Blt_Chain_LastLink(graphPtr->elements.displayList); - link != NULL; link = Blt_Chain_PrevLink(link)) { - elemPtr = (Element*)Blt_Chain_GetValue(link); - if (elemPtr->hide() || (elemPtr->flags & MAP_ITEM)) - continue; - - elemPtr->closest(); - } - // Found an element within the minimum halo distance. - if (searchPtr->dist <= (double)searchPtr->halo) { - *contextPtr = (ClientData)elemPtr->classId(); - return searchPtr->elemPtr; - } - - markerPtr = (Marker*)Blt::NearestMarker(graphPtr, x, y, 1); - if (markerPtr) { - *contextPtr = (ClientData)markerPtr->classId(); - return markerPtr; - } - - *contextPtr = (ClientData)NULL; - return NULL; -} - /* *--------------------------------------------------------------------------- * @@ -673,6 +570,7 @@ static ClientData PickEntry(ClientData clientData, int x, int y, */ static void DrawMargins(Graph* graphPtr, Drawable drawable) { + GraphOptions* ops = (GraphOptions*)graphPtr->ops_; XRectangle rects[4]; /* @@ -690,30 +588,30 @@ static void DrawMargins(Graph* graphPtr, Drawable drawable) rects[2].x = graphPtr->right; rects[2].width = graphPtr->width - graphPtr->right; - Tk_Fill3DRectangle(graphPtr->tkwin, drawable, graphPtr->normalBg, + Tk_Fill3DRectangle(graphPtr->tkwin, drawable, ops->normalBg, rects[0].x, rects[0].y, rects[0].width, rects[0].height, 0, TK_RELIEF_FLAT); - Tk_Fill3DRectangle(graphPtr->tkwin, drawable, graphPtr->normalBg, + Tk_Fill3DRectangle(graphPtr->tkwin, drawable, ops->normalBg, rects[1].x, rects[1].y, rects[1].width, rects[1].height, 0, TK_RELIEF_FLAT); - Tk_Fill3DRectangle(graphPtr->tkwin, drawable, graphPtr->normalBg, + Tk_Fill3DRectangle(graphPtr->tkwin, drawable, ops->normalBg, rects[2].x, rects[2].y, rects[2].width, rects[2].height, 0, TK_RELIEF_FLAT); - Tk_Fill3DRectangle(graphPtr->tkwin, drawable, graphPtr->normalBg, + Tk_Fill3DRectangle(graphPtr->tkwin, drawable, ops->normalBg, rects[3].x, rects[3].y, rects[3].width, rects[3].height, 0, TK_RELIEF_FLAT); /* Draw 3D border around the plotting area */ - if (graphPtr->plotBW > 0) { + if (ops->plotBW > 0) { int x, y, w, h; - x = graphPtr->left - graphPtr->plotBW; - y = graphPtr->top - graphPtr->plotBW; - w = (graphPtr->right - graphPtr->left) + (2*graphPtr->plotBW); - h = (graphPtr->bottom - graphPtr->top) + (2*graphPtr->plotBW); - Tk_Draw3DRectangle(graphPtr->tkwin, drawable, graphPtr->normalBg, - x, y, w, h, graphPtr->plotBW, graphPtr->plotRelief); + x = graphPtr->left - ops->plotBW; + y = graphPtr->top - ops->plotBW; + w = (graphPtr->right - graphPtr->left) + (2*ops->plotBW); + h = (graphPtr->bottom - graphPtr->top) + (2*ops->plotBW); + Tk_Draw3DRectangle(graphPtr->tkwin, drawable, ops->normalBg, + x, y, w, h, ops->plotBW, ops->plotRelief); } switch (graphPtr->legend->position()) { @@ -727,9 +625,9 @@ static void DrawMargins(Graph* graphPtr, Drawable drawable) break; } - if (graphPtr->title != NULL) - Blt_DrawText(graphPtr->tkwin, drawable, graphPtr->title, - &graphPtr->titleTextStyle, graphPtr->titleX, graphPtr->titleY); + if (ops->title != NULL) + Blt_DrawText(graphPtr->tkwin, drawable, ops->title, + &ops->titleTextStyle, graphPtr->titleX, graphPtr->titleY); Blt_DrawAxes(graphPtr, drawable); graphPtr->flags &= ~DRAW_MARGINS; @@ -737,15 +635,16 @@ static void DrawMargins(Graph* graphPtr, Drawable drawable) static void DrawPlot(Graph* graphPtr, Drawable drawable) { + GraphOptions* ops = (GraphOptions*)graphPtr->ops_; DrawMargins(graphPtr, drawable); // Draw the background of the plotting area with 3D border - Tk_Fill3DRectangle(graphPtr->tkwin, drawable, graphPtr->plotBg, - graphPtr->left-graphPtr->plotBW, - graphPtr->top-graphPtr->plotBW, - graphPtr->right - graphPtr->left + 1 +2*graphPtr->plotBW, - graphPtr->bottom - graphPtr->top + 1 +2*graphPtr->plotBW, - graphPtr->plotBW, graphPtr->plotRelief); + Tk_Fill3DRectangle(graphPtr->tkwin, drawable, ops->plotBg, + graphPtr->left-ops->plotBW, + graphPtr->top-ops->plotBW, + graphPtr->right - graphPtr->left + 1 +2*ops->plotBW, + graphPtr->bottom - graphPtr->top + 1 +2*ops->plotBW, + ops->plotBW, ops->plotRelief); // Draw the elements, markers, legend, and axis limits Blt_DrawAxes(graphPtr, drawable); @@ -789,10 +688,11 @@ void Blt_MapGraph(Graph* graphPtr) static void UpdateMarginTraces(Graph* graphPtr) { + GraphOptions* ops = (GraphOptions*)graphPtr->ops_; Margin* marginPtr; Margin* endPtr; - for (marginPtr = graphPtr->margins, endPtr = marginPtr + 4; + for (marginPtr = ops->margins, endPtr = marginPtr + 4; marginPtr < endPtr; marginPtr++) { if (marginPtr->varName != NULL) { /* Trigger variable traces */ int size; @@ -823,12 +723,13 @@ static void UpdateMarginTraces(Graph* graphPtr) void Blt_GraphExtents(Graph* graphPtr, Region2d *regionPtr) { - regionPtr->left = (double)(graphPtr->hOffset - graphPtr->xPad); - regionPtr->top = (double)(graphPtr->vOffset - graphPtr->yPad); + GraphOptions* ops = (GraphOptions*)graphPtr->ops_; + regionPtr->left = (double)(graphPtr->hOffset - ops->xPad); + regionPtr->top = (double)(graphPtr->vOffset - ops->yPad); regionPtr->right = (double)(graphPtr->hOffset + graphPtr->hRange + - graphPtr->xPad); + ops->xPad); regionPtr->bottom = (double)(graphPtr->vOffset + graphPtr->vRange + - graphPtr->yPad); + ops->yPad); } void Blt_ReconfigureGraph(Graph* graphPtr) @@ -839,3 +740,129 @@ void Blt_ReconfigureGraph(Graph* graphPtr) Blt_ConfigureAxes(graphPtr); Blt::ConfigureMarkers(graphPtr); } + +void Blt_GraphTags(Blt_BindTable table, ClientData object, ClientData context, + Blt_List list) +{ + Graph* graphPtr = (Graph*)Blt_GetBindingData(table); + ClassId classId = (ClassId)(long(context)); + + switch (classId) { + case CID_ELEM_BAR: + case CID_ELEM_LINE: + { + Element* elemPtr = (Element*)object; + ElementOptions* ops = (ElementOptions*)elemPtr->ops(); + MakeTagProc* tagProc = Blt_MakeElementTag; + Blt_List_Append(list, (const char*)(*tagProc)(graphPtr, elemPtr->name()), 0); + Blt_List_Append(list, (const char*)(*tagProc)(graphPtr, elemPtr->className()), 0); + if (ops->tags) + for (const char** p = ops->tags; *p != NULL; p++) + Blt_List_Append(list, (const char*)(*tagProc)(graphPtr, *p), 0); + } + break; + case CID_AXIS_X: + case CID_AXIS_Y: + { + Axis* axisPtr = (Axis*)object; + AxisOptions* ops = (AxisOptions*)axisPtr->ops(); + MakeTagProc* tagProc = Blt_MakeAxisTag; + Blt_List_Append(list, (const char*)(*tagProc)(graphPtr, axisPtr->name()), 0); + Blt_List_Append(list, (const char*)(*tagProc)(graphPtr, axisPtr->className()), 0); + if (ops->tags) + for (const char** p = ops->tags; *p != NULL; p++) + Blt_List_Append(list, (const char*)(*tagProc)(graphPtr, *p), 0); + } + break; + case CID_MARKER_BITMAP: + case CID_MARKER_LINE: + case CID_MARKER_POLYGON: + case CID_MARKER_TEXT: + case CID_MARKER_WINDOW: + { + Marker* markerPtr = (Marker*)object; + MarkerOptions* ops = (MarkerOptions*)markerPtr->ops(); + MakeTagProc* tagProc = Blt::MakeMarkerTag; + Blt_List_Append(list, (const char*)(*tagProc)(graphPtr, markerPtr->name()), 0); + Blt_List_Append(list, (const char*)(*tagProc)(graphPtr, markerPtr->className()), 0); + if (ops->tags) + for (const char** p = ops->tags; *p != NULL; p++) + Blt_List_Append(list, (const char*)(*tagProc)(graphPtr, *p), 0); + + } + break; + default: + break; + } +} + +// Find the closest point from the set of displayed elements, searching +// the display list from back to front. That way, if the points from +// two different elements overlay each other exactly, the one that's on +// top (visible) is picked. +static ClientData PickEntry(ClientData clientData, int x, int y, + ClientData* contextPtr) +{ + Graph* graphPtr = (Graph*)clientData; + GraphOptions* ops = (GraphOptions*)graphPtr->ops_; + + if (graphPtr->flags & MAP_ALL) { + *contextPtr = (ClientData)NULL; + return NULL; + } + + Region2d exts; + Blt_GraphExtents(graphPtr, &exts); + + // Sample coordinate is in one of the graph margins. Can only pick an axis. + if ((x >= exts.right) || (x < exts.left) || + (y >= exts.bottom) || (y < exts.top)) { + Axis* axisPtr = Blt_NearestAxis(graphPtr, x, y); + if (axisPtr) { + *contextPtr = (ClientData)axisPtr->classId(); + return axisPtr; + } + } + + // From top-to-bottom check: + // 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, 0); + if (markerPtr) { + *contextPtr = (ClientData)markerPtr->classId(); + return markerPtr; + } + + ClosestSearch* searchPtr = &ops->search; + searchPtr->index = -1; + searchPtr->x = x; + searchPtr->y = y; + searchPtr->dist = (double)(searchPtr->halo + 1); + + Blt_ChainLink link; + Element* elemPtr; + for (link = Blt_Chain_LastLink(graphPtr->elements.displayList); + link != NULL; link = Blt_Chain_PrevLink(link)) { + elemPtr = (Element*)Blt_Chain_GetValue(link); + if (elemPtr->hide() || (elemPtr->flags & MAP_ITEM)) + continue; + + elemPtr->closest(); + } + // Found an element within the minimum halo distance. + if (searchPtr->dist <= (double)searchPtr->halo) { + *contextPtr = (ClientData)elemPtr->classId(); + return searchPtr->elemPtr; + } + + markerPtr = (Marker*)Blt::NearestMarker(graphPtr, x, y, 1); + if (markerPtr) { + *contextPtr = (ClientData)markerPtr->classId(); + return markerPtr; + } + + *contextPtr = (ClientData)NULL; + return NULL; +} + diff --git a/src/bltGraph.h b/src/bltGraph.h index b0984b7..6d18157 100644 --- a/src/bltGraph.h +++ b/src/bltGraph.h @@ -104,6 +104,40 @@ typedef struct { #define topMargin margins[MARGIN_TOP] #define bottomMargin margins[MARGIN_BOTTOM] +typedef struct { + double aspect; + Tk_3DBorder normalBg; + int borderWidth; + Margin margins[4]; + int backingStore; + int doubleBuffer; + Tk_Cursor cursor; + TextStyle titleTextStyle; + int reqHeight; + XColor* highlightBgColor; + XColor* highlightColor; + int highlightWidth; + int inverted; + Tk_3DBorder plotBg; + int plotBW; + int xPad; + int yPad; + int plotRelief; + int relief; + ClosestSearch search; + int stackAxes; + const char *takeFocus; // nor used in C code + const char *title; + int reqWidth; + int reqPlotWidth; + int reqPlotHeight; + + // bar graph + BarMode barMode; + double barWidth; + double baseline; +} GraphOptions; + class Graph { public: Tcl_Interp* interp; @@ -111,28 +145,15 @@ class Graph { Display *display; Tcl_Command cmdToken; Tk_OptionTable optionTable; + void* ops_; ClassId classId; - Tk_Cursor cursor; int inset; - int borderWidth; - int relief; unsigned int flags; - Tk_3DBorder normalBg; - int highlightWidth; - XColor* highlightBgColor; - XColor* highlightColor; - const char *title; short int titleX; short int titleY; short int titleWidth; short int titleHeight; - TextStyle titleTextStyle; - const char *takeFocus; // nor used in C code Axis *focusPtr; - int reqWidth; - int reqHeight; - int reqPlotWidth; - int reqPlotHeight; int width; int height; Tcl_HashTable penTable; @@ -145,42 +166,27 @@ class Graph { Blt_BindTable bindTable; int nextMarkerId; Blt_Chain axisChain[4]; - Margin margins[4]; PageSetup *pageSetup; Legend *legend; Crosshairs *crosshairs; int halo; - int inverted; - int stackAxes; GC drawGC; - int plotBW; - int plotRelief; - Tk_3DBorder plotBg; - double aspect; short int left; short int right; short int top; short int bottom; - int xPad; int vRange; int vOffset; - int yPad; int hRange; int hOffset; float vScale; float hScale; - int doubleBuffer; - int backingStore; Pixmap cache; short int cacheWidth; short int cacheHeight; - ClosestSearch search; // barchart specific information - double baseline; - double barWidth; - BarMode barMode; BarGroup *barGroups; int nBarGroups; Tcl_HashTable setTable; diff --git a/src/bltGraphOp.C b/src/bltGraphOp.C index 8249f7e..a8f8487 100644 --- a/src/bltGraphOp.C +++ b/src/bltGraphOp.C @@ -113,7 +113,7 @@ int GraphObjConfigure(Tcl_Interp* interp, Graph* graphPtr, for (error=0; error<=1; error++) { if (!error) { - if (Tk_SetOptions(interp, (char*)graphPtr, graphPtr->optionTable, + if (Tk_SetOptions(interp, (char*)graphPtr->ops_, graphPtr->optionTable, objc, objv, graphPtr->tkwin, &savedOptions, &mask) != TCL_OK) continue; @@ -150,7 +150,7 @@ static int CgetOp(Graph* graphPtr, Tcl_Interp* interp, return TCL_ERROR; } Tcl_Obj* objPtr = Tk_GetOptionValue(interp, - (char*)graphPtr, + (char*)graphPtr->ops_, graphPtr->optionTable, objv[2], graphPtr->tkwin); if (objPtr == NULL) @@ -165,7 +165,7 @@ static int ConfigureOp(Graph* graphPtr, Tcl_Interp* interp, { if (objc <= 3) { Tcl_Obj* objPtr = Tk_GetOptionInfo(interp, - (char*)graphPtr, + (char*)graphPtr->ops_, graphPtr->optionTable, (objc == 3) ? objv[2] : NULL, graphPtr->tkwin); @@ -182,28 +182,32 @@ static int ConfigureOp(Graph* graphPtr, Tcl_Interp* interp, static int XAxisOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { - int margin = (graphPtr->inverted) ? MARGIN_LEFT : MARGIN_BOTTOM; + GraphOptions* ops = (GraphOptions*)graphPtr->ops_; + int margin = (ops->inverted) ? MARGIN_LEFT : MARGIN_BOTTOM; return Blt_XAxisOp(interp, graphPtr, margin, objc, objv); } static int X2AxisOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { - int margin = (graphPtr->inverted) ? MARGIN_RIGHT : MARGIN_TOP; + GraphOptions* ops = (GraphOptions*)graphPtr->ops_; + int margin = (ops->inverted) ? MARGIN_RIGHT : MARGIN_TOP; return Blt_XAxisOp(interp, graphPtr, margin, objc, objv); } static int YAxisOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { - int margin = (graphPtr->inverted) ? MARGIN_BOTTOM : MARGIN_LEFT; + GraphOptions* ops = (GraphOptions*)graphPtr->ops_; + int margin = (ops->inverted) ? MARGIN_BOTTOM : MARGIN_LEFT; return Blt_XAxisOp(interp, graphPtr, margin, objc, objv); } static int Y2AxisOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { - int margin = (graphPtr->inverted) ? MARGIN_TOP : MARGIN_RIGHT; + GraphOptions* ops = (GraphOptions*)graphPtr->ops_; + int margin = (ops->inverted) ? MARGIN_TOP : MARGIN_RIGHT; return Blt_XAxisOp(interp, graphPtr, margin, objc, objv); } @@ -251,6 +255,7 @@ static int ElementOp(Graph* graphPtr, Tcl_Interp* interp, int objc, static int ExtentsOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { + GraphOptions* ops = (GraphOptions*)graphPtr->ops_; int length; const char* string = Tcl_GetStringFromObj(objv[2], &length); char c = string[0]; @@ -292,19 +297,19 @@ static int ExtentsOp(Graph* graphPtr, Tcl_Interp* interp, int objc, } else if ((c == 'l') && (length > 2) && (strncmp("leftmargin", string, length) == 0)) { - Tcl_SetIntObj(Tcl_GetObjResult(interp), graphPtr->leftMargin.width); + Tcl_SetIntObj(Tcl_GetObjResult(interp), ops->leftMargin.width); } else if ((c == 'r') && (length > 1) && (strncmp("rightmargin", string, length) == 0)) { - Tcl_SetIntObj(Tcl_GetObjResult(interp), graphPtr->rightMargin.width); + Tcl_SetIntObj(Tcl_GetObjResult(interp), ops->rightMargin.width); } else if ((c == 't') && (length > 1) && (strncmp("topmargin", string, length) == 0)) { - Tcl_SetIntObj(Tcl_GetObjResult(interp), graphPtr->topMargin.height); + Tcl_SetIntObj(Tcl_GetObjResult(interp), ops->topMargin.height); } else if ((c == 'b') && (length > 1) && (strncmp("bottommargin", string, length) == 0)) { - Tcl_SetIntObj(Tcl_GetObjResult(interp), graphPtr->bottomMargin.height); + Tcl_SetIntObj(Tcl_GetObjResult(interp), ops->bottomMargin.height); } else { Tcl_AppendResult(interp, "bad extent item \"", objv[2], -- cgit v0.12