diff options
author | joye <joye> | 2014-04-04 21:00:18 (GMT) |
---|---|---|
committer | joye <joye> | 2014-04-04 21:00:18 (GMT) |
commit | ae3cf41403223191dda5efcf6d3a4165649a4a68 (patch) | |
tree | 3a31f27cac2b0b8e05efe6c1e3112385290c1e63 /src | |
parent | 7290c2469f708b3b676ffae464e825ec3a99b721 (diff) | |
download | blt-ae3cf41403223191dda5efcf6d3a4165649a4a68.zip blt-ae3cf41403223191dda5efcf6d3a4165649a4a68.tar.gz blt-ae3cf41403223191dda5efcf6d3a4165649a4a68.tar.bz2 |
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r-- | src/bltGrElemBar.C | 66 | ||||
-rw-r--r-- | src/bltGrElemLine.C | 67 | ||||
-rw-r--r-- | src/bltGrElemOption.C | 2 | ||||
-rw-r--r-- | src/bltGrMarkerOp.C | 7 | ||||
-rw-r--r-- | src/bltGrPen.C | 44 | ||||
-rw-r--r-- | src/bltGrPen.h | 33 | ||||
-rw-r--r-- | src/bltGrPenBar.C | 103 | ||||
-rw-r--r-- | src/bltGrPenBar.h | 31 | ||||
-rw-r--r-- | src/bltGrPenLine.C | 159 | ||||
-rw-r--r-- | src/bltGrPenLine.h | 29 | ||||
-rw-r--r-- | src/bltGrPenOp.C | 65 | ||||
-rw-r--r-- | src/bltGrPenOp.h | 6 | ||||
-rw-r--r-- | src/bltGrPenOption.C | 2 | ||||
-rw-r--r-- | src/bltGraph.C | 5 | ||||
-rw-r--r-- | src/bltGraph.h | 10 |
15 files changed, 314 insertions, 315 deletions
diff --git a/src/bltGrElemBar.C b/src/bltGrElemBar.C index dab0a49..44c29ba 100644 --- a/src/bltGrElemBar.C +++ b/src/bltGrElemBar.C @@ -224,12 +224,10 @@ Element* Blt_BarElement(Graph* graphPtr) bePtr->procsPtr = &barProcs; ops->builtinPenPtr = &bePtr->builtinPen; - bePtr->builtinPen.ops = &ops->builtinPen; - bePtr->builtinPen.manageOptions =0; - InitBarPen(graphPtr, &bePtr->builtinPen, "builtin"); + bePtr->builtinPen.init(graphPtr, "builtin", &ops->builtinPen); Tk_InitOptions(graphPtr->interp, (char*)&(ops->builtinPen), - bePtr->builtinPen.optionTable, graphPtr->tkwin); + bePtr->builtinPen.optionTable(), graphPtr->tkwin); bePtr->optionTable = Tk_CreateOptionTable(graphPtr->interp, optionSpecs); @@ -241,8 +239,6 @@ static void DestroyBarProc(Graph* graphPtr, Element* elemPtr) BarElement* bePtr = (BarElement*)elemPtr; BarElementOptions* ops = (BarElementOptions*)bePtr->ops; - DestroyBarPenProc(graphPtr, (Pen*)&bePtr->builtinPen); - if (ops->activePenPtr) Blt_FreePen((Pen*)ops->activePenPtr); if (ops->normalPenPtr) @@ -266,7 +262,7 @@ static int ConfigureBarProc(Graph* graphPtr, Element* elemPtr) BarElement* bePtr = (BarElement*)elemPtr; BarElementOptions* ops = (BarElementOptions*)bePtr->ops; - if (ConfigureBarPenProc(graphPtr, (Pen*)&bePtr->builtinPen)!= TCL_OK) + if (bePtr->builtinPen.configure() != TCL_OK) return TCL_ERROR; // Point to the static normal pen if no external pens have been selected. @@ -1041,7 +1037,7 @@ static void MapBarProc(Graph* graphPtr, Element* elemPtr) link = Blt_Chain_NextLink(link)) { BarStyle *stylePtr = (BarStyle*)Blt_Chain_GetValue(link); BarPen* penPtr = stylePtr->penPtr; - BarPenOptions* penOps = (BarPenOptions*)penPtr->ops; + BarPenOptions* penOps = (BarPenOptions*)penPtr->ops(); stylePtr->symbolSize = size; stylePtr->errorBarCapWidth = (penOps->errorBarCapWidth > 0) @@ -1070,7 +1066,7 @@ static void DrawSymbolProc(Graph* graphPtr, Drawable drawable, BarElementOptions* ops = (BarElementOptions*)bePtr->ops; BarPen* penPtr = NORMALPEN(ops); - BarPenOptions* penOps = (BarPenOptions*)penPtr->ops; + BarPenOptions* penOps = (BarPenOptions*)penPtr->ops(); if (!penOps->fill && !penOps->outlineColor) return; @@ -1080,20 +1076,20 @@ static void DrawSymbolProc(Graph* graphPtr, Drawable drawable, x -= radius; y -= radius; - if (penPtr->fillGC) - XSetTSOrigin(graphPtr->display, penPtr->fillGC, x, y); + if (penPtr->fillGC_) + XSetTSOrigin(graphPtr->display, penPtr->fillGC_, x, y); if (penOps->stipple != None) - XFillRectangle(graphPtr->display, drawable, penPtr->fillGC, x, y, + XFillRectangle(graphPtr->display, drawable, penPtr->fillGC_, x, y, size, size); else Tk_Fill3DRectangle(graphPtr->tkwin, drawable, penOps->fill, x, y, size, size, penOps->borderWidth, penOps->relief); - XDrawRectangle(graphPtr->display, drawable, penPtr->outlineGC, x, y, + XDrawRectangle(graphPtr->display, drawable, penPtr->outlineGC_, x, y, size, size); - if (penPtr->fillGC) - XSetTSOrigin(graphPtr->display, penPtr->fillGC, 0, 0); + if (penPtr->fillGC_) + XSetTSOrigin(graphPtr->display, penPtr->fillGC_, 0, 0); } static void SetBackgroundClipRegion(Tk_Window tkwin, Tk_3DBorder border, @@ -1128,7 +1124,7 @@ 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; + BarPenOptions* penOps = (BarPenOptions*)penPtr->ops(); TkRegion rgn; XRectangle clip; @@ -1145,17 +1141,17 @@ static void DrawBarSegments(Graph* graphPtr, Drawable drawable, BarPen* penPtr, int hasOutline = ((relief == TK_RELIEF_FLAT) && penOps->outlineColor); if (penOps->stipple != None) - TkSetRegion(graphPtr->display, penPtr->fillGC, rgn); + TkSetRegion(graphPtr->display, penPtr->fillGC_, rgn); SetBackgroundClipRegion(graphPtr->tkwin, penOps->fill, rgn); if (hasOutline) - TkSetRegion(graphPtr->display, penPtr->outlineGC, rgn); + TkSetRegion(graphPtr->display, penPtr->outlineGC_, rgn); XRectangle *rp, *rend; for (rp = bars, rend = rp + nBars; rp < rend; rp++) { if (penOps->stipple != None) - XFillRectangle(graphPtr->display, drawable, penPtr->fillGC, + XFillRectangle(graphPtr->display, drawable, penPtr->fillGC_, rp->x, rp->y, rp->width, rp->height); else Tk_Fill3DRectangle(graphPtr->tkwin, drawable, @@ -1163,24 +1159,24 @@ static void DrawBarSegments(Graph* graphPtr, Drawable drawable, BarPen* penPtr, penOps->borderWidth, relief); if (hasOutline) - XDrawRectangle(graphPtr->display, drawable, penPtr->outlineGC, + XDrawRectangle(graphPtr->display, drawable, penPtr->outlineGC_, rp->x, rp->y, rp->width, rp->height); } UnsetBackgroundClipRegion(graphPtr->tkwin, penOps->fill); if (hasOutline) - XSetClipMask(graphPtr->display, penPtr->outlineGC, None); + XSetClipMask(graphPtr->display, penPtr->outlineGC_, None); if (penOps->stipple != None) - XSetClipMask(graphPtr->display, penPtr->fillGC, None); + XSetClipMask(graphPtr->display, penPtr->fillGC_, None); } else if (penOps->outlineColor) { - TkSetRegion(graphPtr->display, penPtr->outlineGC, rgn); - XDrawRectangles(graphPtr->display, drawable, penPtr->outlineGC, bars, + TkSetRegion(graphPtr->display, penPtr->outlineGC_, rgn); + XDrawRectangles(graphPtr->display, drawable, penPtr->outlineGC_, bars, nBars); - XSetClipMask(graphPtr->display, penPtr->outlineGC, None); + XSetClipMask(graphPtr->display, penPtr->outlineGC_, None); } TkDestroyRegion(rgn); @@ -1192,7 +1188,7 @@ static void DrawBarValues(Graph* graphPtr, Drawable drawable, int *barToData) { BarElementOptions* ops = (BarElementOptions*)bePtr->ops; - BarPenOptions* penOps = (BarPenOptions*)penPtr->ops; + BarPenOptions* penOps = (BarPenOptions*)penPtr->ops(); const char *fmt = penOps->valueFormat; if (!fmt) @@ -1247,18 +1243,18 @@ static void DrawNormalBarProc(Graph* graphPtr, Drawable drawable, BarStyle *stylePtr = (BarStyle*)Blt_Chain_GetValue(link); BarPen* penPtr = (BarPen*)stylePtr->penPtr; - BarPenOptions* penOps = (BarPenOptions*)penPtr->ops; + BarPenOptions* penOps = (BarPenOptions*)penPtr->ops(); if (stylePtr->nBars > 0) DrawBarSegments(graphPtr, drawable, penPtr, stylePtr->bars, stylePtr->nBars); if ((stylePtr->xeb.length > 0) && (penOps->errorBarShow & SHOW_X)) - Blt_Draw2DSegments(graphPtr->display, drawable, penPtr->errorBarGC, + Blt_Draw2DSegments(graphPtr->display, drawable, penPtr->errorBarGC_, stylePtr->xeb.segments, stylePtr->xeb.length); if ((stylePtr->yeb.length > 0) && (penOps->errorBarShow & SHOW_Y)) - Blt_Draw2DSegments(graphPtr->display, drawable, penPtr->errorBarGC, + Blt_Draw2DSegments(graphPtr->display, drawable, penPtr->errorBarGC_, stylePtr->yeb.segments, stylePtr->yeb.length); if (penOps->valueShow != SHOW_NONE) @@ -1278,7 +1274,7 @@ static void DrawActiveBarProc(Graph* graphPtr, Drawable drawable, if (ops->activePenPtr) { BarPen* penPtr = ops->activePenPtr; - BarPenOptions* penOps = (BarPenOptions*)penPtr->ops; + BarPenOptions* penOps = (BarPenOptions*)penPtr->ops(); if (bePtr->nActiveIndices > 0) { if (bePtr->flags & ACTIVE_PENDING) { @@ -1310,7 +1306,7 @@ static void SymbolToPostScriptProc(Graph* graphPtr, Blt_Ps ps, Element* elemPtr, BarElementOptions* ops = (BarElementOptions*)bePtr->ops; BarPen* penPtr = NORMALPEN(ops); - BarPenOptions* penOps = (BarPenOptions*)penPtr->ops; + BarPenOptions* penOps = (BarPenOptions*)penPtr->ops(); if (!penOps->fill && !penOps->outlineColor) return; @@ -1345,7 +1341,7 @@ static void SymbolToPostScriptProc(Graph* graphPtr, Blt_Ps ps, Element* elemPtr, static void SegmentsToPostScript(Graph* graphPtr, Blt_Ps ps, BarPen* penPtr, XRectangle *bars, int nBars) { - BarPenOptions* penOps = (BarPenOptions*)penPtr->ops; + BarPenOptions* penOps = (BarPenOptions*)penPtr->ops(); XRectangle *rp, *rend; if (!penOps->fill && !penOps->outlineColor) @@ -1386,7 +1382,7 @@ static void BarValuesToPostScript(Graph* graphPtr, Blt_Ps ps, BarPen* penPtr, XRectangle *bars, int nBars, int *barToData) { - BarPenOptions* penOps = (BarPenOptions*)penPtr->ops; + BarPenOptions* penOps = (BarPenOptions*)penPtr->ops(); BarElementOptions* ops = (BarElementOptions*)bePtr->ops; XRectangle *rp, *rend; @@ -1438,7 +1434,7 @@ static void ActiveBarToPostScriptProc(Graph* graphPtr, Blt_Ps ps, if (ops->activePenPtr) { BarPen* penPtr = ops->activePenPtr; - BarPenOptions* penOps = (BarPenOptions*)penPtr->ops; + BarPenOptions* penOps = (BarPenOptions*)penPtr->ops(); if (bePtr->nActiveIndices > 0) { if (bePtr->flags & ACTIVE_PENDING) { @@ -1473,7 +1469,7 @@ static void NormalBarToPostScriptProc(Graph* graphPtr, Blt_Ps ps, BarStyle *stylePtr = (BarStyle*)Blt_Chain_GetValue(link); BarPen* penPtr = (BarPen*)stylePtr->penPtr; - BarPenOptions* penOps = (BarPenOptions*)penPtr->ops; + BarPenOptions* penOps = (BarPenOptions*)penPtr->ops(); if (stylePtr->nBars > 0) SegmentsToPostScript(graphPtr, ps, penPtr, stylePtr->bars, stylePtr->nBars); diff --git a/src/bltGrElemLine.C b/src/bltGrElemLine.C index f0cb175..79ac361 100644 --- a/src/bltGrElemLine.C +++ b/src/bltGrElemLine.C @@ -302,12 +302,10 @@ Element* Blt_LineElement(Graph* graphPtr) lePtr->procsPtr = &lineProcs; ops->builtinPenPtr = &lePtr->builtinPen; - lePtr->builtinPen.ops =&ops->builtinPen; - lePtr->builtinPen.manageOptions =0; - InitLinePen(graphPtr, &lePtr->builtinPen, "builtin"); + lePtr->builtinPen.init(graphPtr, "builtin", &ops->builtinPen); Tk_InitOptions(graphPtr->interp, (char*)&(ops->builtinPen), - lePtr->builtinPen.optionTable, graphPtr->tkwin); + lePtr->builtinPen.optionTable(), graphPtr->tkwin); lePtr->optionTable = Tk_CreateOptionTable(graphPtr->interp, optionSpecs); @@ -320,7 +318,6 @@ static void DestroyLineProc(Graph* graphPtr, Element* elemPtr) LineElement* lePtr = (LineElement*)elemPtr; LineElementOptions* ops = (LineElementOptions*)lePtr->ops; - DestroyLinePenProc(graphPtr, (Pen *)&lePtr->builtinPen); if (ops->activePenPtr) Blt_FreePen((Pen *)ops->activePenPtr); if (ops->normalPenPtr) @@ -348,7 +345,7 @@ static int ConfigureLineProc(Graph* graphPtr, Element *elemPtr) LineElement* lePtr = (LineElement*)elemPtr; LineElementOptions* ops = (LineElementOptions*)lePtr->ops; - if (ConfigureLinePenProc(graphPtr, (Pen *)&lePtr->builtinPen) != TCL_OK) + if (lePtr->builtinPen.configure() != TCL_OK) return TCL_ERROR; // Point to the static normal/active pens if no external pens have been @@ -1458,7 +1455,7 @@ static void MapLineProc(Graph* graphPtr, Element *elemPtr) link = Blt_Chain_NextLink(link)) { LineStyle *stylePtr = (LineStyle*)Blt_Chain_GetValue(link); LinePen* penPtr = (LinePen *)stylePtr->penPtr; - LinePenOptions* penOps = (LinePenOptions*)penPtr->ops; + LinePenOptions* penOps = (LinePenOptions*)penPtr->ops(); int size = ScaleSymbol(lePtr, penOps->symbol.size); stylePtr->symbolSize = size; stylePtr->errorBarCapWidth = (penOps->errorBarCapWidth > 0) @@ -1803,7 +1800,7 @@ static void ClosestLineProc(Graph* graphPtr, Element *elemPtr) int mode = searchPtr->mode; if (mode == SEARCH_AUTO) { LinePen* penPtr = NORMALPEN(ops); - LinePenOptions* penOps = (LinePenOptions*)penPtr->ops; + LinePenOptions* penOps = (LinePenOptions*)penPtr->ops(); mode = SEARCH_POINTS; if ((NUMBEROFPOINTS(ops) > 1) && (penOps->traceWidth > 0)) mode = SEARCH_TRACES; @@ -1845,7 +1842,7 @@ static void DrawCircles(Display *display, Drawable drawable, LineElement* lePtr, LinePen* penPtr, int nSymbolPts, Point2d *symbolPts, int radius) { - LinePenOptions* penOps = (LinePenOptions*)penPtr->ops; + LinePenOptions* penOps = (LinePenOptions*)penPtr->ops(); int count = 0; int s = radius + radius; @@ -1897,7 +1894,7 @@ static void DrawSquares(Display *display, Drawable drawable, LineElement* lePtr, LinePen* penPtr, int nSymbolPts, Point2d *symbolPts, int r) { - LinePenOptions* penOps = (LinePenOptions*)penPtr->ops; + LinePenOptions* penOps = (LinePenOptions*)penPtr->ops(); int count =0; int s = r + r; @@ -1951,7 +1948,7 @@ static void DrawSymbols(Graph* graphPtr, Drawable drawable, LineElement* lePtr, LinePen* penPtr, int size, int nSymbolPts, Point2d *symbolPts) { - LinePenOptions* penOps = (LinePenOptions*)penPtr->ops; + LinePenOptions* penOps = (LinePenOptions*)penPtr->ops(); XPoint pattern[13]; int count; @@ -2404,7 +2401,7 @@ static void DrawSymbolProc(Graph* graphPtr, Drawable drawable, LineElementOptions* ops = (LineElementOptions*)lePtr->ops; LinePen* penPtr = NORMALPEN(ops); - LinePenOptions* penOps = (LinePenOptions*)penPtr->ops; + LinePenOptions* penOps = (LinePenOptions*)penPtr->ops(); if (penOps->traceWidth > 0) { /* @@ -2412,9 +2409,9 @@ static void DrawSymbolProc(Graph* graphPtr, Drawable drawable, * thicker appearance. This is only for the legend entry. This routine * is never called for drawing the actual line segments. */ - XDrawLine(graphPtr->display, drawable, penPtr->traceGC, x - size, y, + XDrawLine(graphPtr->display, drawable, penPtr->traceGC_, x - size, y, x + size, y); - XDrawLine(graphPtr->display, drawable, penPtr->traceGC, x - size, y + 1, + XDrawLine(graphPtr->display, drawable, penPtr->traceGC_, x - size, y + 1, x + size, y + 1); } if (penOps->symbol.type != SYMBOL_NONE) { @@ -2455,7 +2452,7 @@ static void DrawTraces(Graph* graphPtr, Drawable drawable, xpp->x = Round(tracePtr->screenPts.points[count].x); xpp->y = Round(tracePtr->screenPts.points[count].y); } - XDrawLines(graphPtr->display, drawable, penPtr->traceGC, points, + XDrawLines(graphPtr->display, drawable, penPtr->traceGC_, points, count, CoordModeOrigin); /* Step 2. Next handle any full-size chunks left. */ @@ -2471,7 +2468,7 @@ static void DrawTraces(Graph* graphPtr, Drawable drawable, xpp->x = Round(tracePtr->screenPts.points[count].x); xpp->y = Round(tracePtr->screenPts.points[count].y); } - XDrawLines(graphPtr->display, drawable, penPtr->traceGC, points, + XDrawLines(graphPtr->display, drawable, penPtr->traceGC_, points, np + 1, CoordModeOrigin); } @@ -2487,7 +2484,7 @@ static void DrawTraces(Graph* graphPtr, Drawable drawable, xpp->x = Round(tracePtr->screenPts.points[count].x); xpp->y = Round(tracePtr->screenPts.points[count].y); } - XDrawLines(graphPtr->display, drawable, penPtr->traceGC, points, + XDrawLines(graphPtr->display, drawable, penPtr->traceGC_, points, remaining + 1, CoordModeOrigin); } } @@ -2499,7 +2496,7 @@ static void DrawValues(Graph* graphPtr, Drawable drawable, int length, Point2d *points, int *map) { LineElementOptions* ops = (LineElementOptions*)lePtr->ops; - LinePenOptions* penOps = (LinePenOptions*)penPtr->ops; + LinePenOptions* penOps = (LinePenOptions*)penPtr->ops(); Point2d *pp, *endp; double *xval, *yval; @@ -2545,7 +2542,7 @@ static void DrawActiveLineProc(Graph* graphPtr, Drawable drawable, if (!penPtr) return; - LinePenOptions* penOps = (LinePenOptions*)penPtr->ops; + LinePenOptions* penOps = (LinePenOptions*)penPtr->ops(); int symbolSize = ScaleSymbol(lePtr, penOps->symbol.size); @@ -2573,7 +2570,7 @@ static void DrawActiveLineProc(Graph* graphPtr, Drawable drawable, if (penOps->traceWidth > 0) { if (lePtr->lines.length > 0) { Blt_Draw2DSegments(graphPtr->display, drawable, - penPtr->traceGC, lePtr->lines.segments, + penPtr->traceGC_, lePtr->lines.segments, lePtr->lines.length); } else if (Blt_Chain_GetLength(lePtr->traces) > 0) { DrawTraces(graphPtr, drawable, lePtr, penPtr); @@ -2622,17 +2619,17 @@ static void DrawNormalLineProc(Graph* graphPtr, Drawable drawable, LineStyle *stylePtr = (LineStyle*)Blt_Chain_GetValue(link); LinePen* penPtr = (LinePen *)stylePtr->penPtr; - LinePenOptions* penOps = (LinePenOptions*)penPtr->ops; + LinePenOptions* penOps = (LinePenOptions*)penPtr->ops(); if ((stylePtr->lines.length > 0) && (penOps->errorBarLineWidth > 0)) { - Blt_Draw2DSegments(graphPtr->display, drawable, penPtr->traceGC, + Blt_Draw2DSegments(graphPtr->display, drawable, penPtr->traceGC_, stylePtr->lines.segments, stylePtr->lines.length); } } } else { LinePen* penPtr = NORMALPEN(ops); - LinePenOptions* penOps = (LinePenOptions*)penPtr->ops; + LinePenOptions* penOps = (LinePenOptions*)penPtr->ops(); if ((Blt_Chain_GetLength(lePtr->traces) > 0) && (penOps->traceWidth > 0)) { @@ -2658,14 +2655,14 @@ static void DrawNormalLineProc(Graph* graphPtr, Drawable drawable, link = Blt_Chain_NextLink(link)) { LineStyle *stylePtr = (LineStyle*)Blt_Chain_GetValue(link); LinePen* penPtr = (LinePen *)stylePtr->penPtr; - LinePenOptions* penOps = (LinePenOptions*)penPtr->ops; + LinePenOptions* penOps = (LinePenOptions*)penPtr->ops(); if ((stylePtr->xeb.length > 0) && (penOps->errorBarShow & SHOW_X)) - Blt_Draw2DSegments(graphPtr->display, drawable, penPtr->errorBarGC, + Blt_Draw2DSegments(graphPtr->display, drawable, penPtr->errorBarGC_, stylePtr->xeb.segments, stylePtr->xeb.length); if ((stylePtr->yeb.length > 0) && (penOps->errorBarShow & SHOW_Y)) - Blt_Draw2DSegments(graphPtr->display, drawable, penPtr->errorBarGC, + Blt_Draw2DSegments(graphPtr->display, drawable, penPtr->errorBarGC_, stylePtr->yeb.segments, stylePtr->yeb.length); if ((stylePtr->symbolPts.length > 0) && @@ -2687,7 +2684,7 @@ static void DrawNormalLineProc(Graph* graphPtr, Drawable drawable, static void GetSymbolPostScriptInfo(Graph* graphPtr, Blt_Ps ps, LinePen* penPtr, int size) { - LinePenOptions* penOps = (LinePenOptions*)penPtr->ops; + LinePenOptions* penOps = (LinePenOptions*)penPtr->ops(); /* Set line and foreground attributes */ XColor* fillColor = penOps->symbol.fillColor; @@ -2763,7 +2760,7 @@ 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; + LinePenOptions* penOps = (LinePenOptions*)penPtr->ops(); double symbolSize; static const char* symbolMacros[] = @@ -2810,7 +2807,7 @@ static void SymbolToPostScriptProc(Graph* graphPtr, Blt_Ps ps, LineElementOptions* ops = (LineElementOptions*)lePtr->ops; LinePen* penPtr = NORMALPEN(ops); - LinePenOptions* penOps = (LinePenOptions*)penPtr->ops; + LinePenOptions* penOps = (LinePenOptions*)penPtr->ops(); if (penOps->traceWidth > 0) { /* @@ -2832,7 +2829,7 @@ static void SymbolToPostScriptProc(Graph* graphPtr, Blt_Ps ps, static void SetLineAttributes(Blt_Ps ps, LinePen* penPtr) { - LinePenOptions* penOps = (LinePenOptions*)penPtr->ops; + LinePenOptions* penOps = (LinePenOptions*)penPtr->ops(); /* Set the attributes of the line (color, dashes, linewidth) */ Blt_Ps_XSetLineAttributes(ps, penOps->traceColor, penOps->traceWidth, @@ -2871,7 +2868,7 @@ static void ValuesToPostScript(Blt_Ps ps, LineElement* lePtr, LinePen* penPtr, int *pointToData) { LineElementOptions* ops = (LineElementOptions*)lePtr->ops; - LinePenOptions* penOps = (LinePenOptions*)penPtr->ops; + LinePenOptions* penOps = (LinePenOptions*)penPtr->ops(); const char* fmt = penOps->valueFormat; if (fmt == NULL) @@ -2909,7 +2906,7 @@ static void ActiveLineToPostScriptProc(Graph* graphPtr, Blt_Ps ps, LinePen* penPtr = (LinePen *)ops->activePenPtr; if (!penPtr) return; - LinePenOptions* penOps = (LinePenOptions*)penPtr->ops; + LinePenOptions* penOps = (LinePenOptions*)penPtr->ops(); int symbolSize = ScaleSymbol(lePtr, penOps->symbol.size); if (lePtr->nActiveIndices > 0) { @@ -2980,7 +2977,7 @@ static void NormalLineToPostScriptProc(Graph* graphPtr, Blt_Ps ps, link = Blt_Chain_NextLink(link)) { LineStyle *stylePtr = (LineStyle*)Blt_Chain_GetValue(link); LinePen* penPtr = (LinePen *)stylePtr->penPtr; - LinePenOptions* penOps = (LinePenOptions*)penPtr->ops; + LinePenOptions* penOps = (LinePenOptions*)penPtr->ops(); if ((stylePtr->lines.length > 0) && (penOps->traceWidth > 0)) { SetLineAttributes(ps, penPtr); @@ -2993,7 +2990,7 @@ static void NormalLineToPostScriptProc(Graph* graphPtr, Blt_Ps ps, } else { LinePen* penPtr = NORMALPEN(ops); - LinePenOptions* penOps = (LinePenOptions*)penPtr->ops; + LinePenOptions* penOps = (LinePenOptions*)penPtr->ops(); if ((Blt_Chain_GetLength(lePtr->traces) > 0) && (penOps->traceWidth > 0)) { @@ -3009,7 +3006,7 @@ static void NormalLineToPostScriptProc(Graph* graphPtr, Blt_Ps ps, LineStyle *stylePtr = (LineStyle*)Blt_Chain_GetValue(link); LinePen* penPtr = (LinePen *)stylePtr->penPtr; - LinePenOptions* penOps = (LinePenOptions*)penPtr->ops; + LinePenOptions* penOps = (LinePenOptions*)penPtr->ops(); XColor* colorPtr = penOps->errorBarColor; if (!colorPtr) colorPtr = penOps->traceColor; diff --git a/src/bltGrElemOption.C b/src/bltGrElemOption.C index b7a2627..30effe4 100644 --- a/src/bltGrElemOption.C +++ b/src/bltGrElemOption.C @@ -311,7 +311,7 @@ Tcl_Obj* StyleGetProc(ClientData clientData, Tk_Window tkwin, for (Blt_ChainLink link = Blt_Chain_FirstLink(stylePalette); !link; link = Blt_Chain_NextLink(link)) { PenStyle *stylePtr = (PenStyle*)Blt_Chain_GetValue(link); - ll[ii++] = Tcl_NewStringObj(stylePtr->penPtr->name, -1); + ll[ii++] = Tcl_NewStringObj(stylePtr->penPtr->name(), -1); ll[ii++] = Tcl_NewDoubleObj(stylePtr->weight.min); ll[ii++] = Tcl_NewDoubleObj(stylePtr->weight.max); } diff --git a/src/bltGrMarkerOp.C b/src/bltGrMarkerOp.C index 66a0dc3..9d512a3 100644 --- a/src/bltGrMarkerOp.C +++ b/src/bltGrMarkerOp.C @@ -314,9 +314,9 @@ static int FindOp(Graph* graphPtr, Tcl_Interp* interp, link; link = Blt_Chain_NextLink(link)) { Marker* markerPtr = (Marker*)Blt_Chain_GetValue(link); MarkerOptions* ops = (MarkerOptions*)markerPtr->ops(); - if ((markerPtr->flags & DELETE_PENDING) || ops->hide) { + if ((markerPtr->flags & DELETE_PENDING) || ops->hide) continue; - } + if (IsElementHidden(graphPtr, markerPtr)) continue; @@ -598,8 +598,7 @@ void* Blt::NearestMarker(Graph* graphPtr, int x, int y, int under) Marker* markerPtr = (Marker*)Blt_Chain_GetValue(link); MarkerOptions* ops = (MarkerOptions*)markerPtr->ops(); - if ((markerPtr->flags & (DELETE_PENDING|MAP_ITEM)) || - (ops->hide)) + if ((markerPtr->flags & (DELETE_PENDING|MAP_ITEM)) || (ops->hide)) continue; if (IsElementHidden(graphPtr, markerPtr)) diff --git a/src/bltGrPen.C b/src/bltGrPen.C index e2f1d36..c44a496 100644 --- a/src/bltGrPen.C +++ b/src/bltGrPen.C @@ -28,3 +28,47 @@ */ #include "bltGrPen.h" + +Pen::Pen() +{ + graphPtr_ =NULL; + classId_ = CID_NONE; + name_ =NULL; + optionTable_ =NULL; + ops_ =NULL; + manageOptions_ =0; + flags =0; + refCount =0; + hashPtr_ =NULL; +} + +Pen::Pen(Graph* graphPtr, const char* name, Tcl_HashEntry* hPtr) +{ + graphPtr_ = graphPtr; + classId_ = CID_NONE; + name_ = dupstr(name); + optionTable_ = NULL; + ops_ = NULL; + manageOptions_ =0; + flags =0; + refCount =0; + hashPtr_ = hPtr; +} + +Pen::~Pen() +{ + if (name_) + delete [] name_; + + if (hashPtr_) + Tcl_DeleteHashEntry(hashPtr_); + + PenOptions* ops = (PenOptions*)ops_; + Blt_Ts_FreeStyle(graphPtr_->display, &ops->valueStyle); + + Tk_FreeConfigOptions((char*)ops_, optionTable_, graphPtr_->tkwin); + + if (manageOptions_) + if (ops_) + free(ops_); +} diff --git a/src/bltGrPen.h b/src/bltGrPen.h index 20917f6..b10ee37 100644 --- a/src/bltGrPen.h +++ b/src/bltGrPen.h @@ -39,12 +39,6 @@ extern "C" { #include "bltGraph.h" }; -class Pen; - -typedef Pen* (PenCreateProc)(void); -typedef int (PenConfigureProc)(Graph* graphPtr, Pen* penPtr); -typedef void (PenDestroyProc)(Graph* graphPtr, Pen* penPtr); - typedef struct { int errorBarShow; int errorBarLineWidth; @@ -57,17 +51,26 @@ typedef struct { class Pen { public: - const char *name; - ClassId classId; + Graph* graphPtr_; + ClassId classId_; + const char *name_; + Tk_OptionTable optionTable_; + void* ops_; + int manageOptions_; unsigned int flags; int refCount; - Tcl_HashEntry *hashPtr; - Tk_OptionTable optionTable; - PenConfigureProc *configProc; - PenDestroyProc *destroyProc; - Graph* graphPtr; - void* ops; - int manageOptions; + Tcl_HashEntry *hashPtr_; + + public: + Pen(); + Pen(Graph*, const char*, Tcl_HashEntry*); + virtual ~Pen(); + + virtual int configure() =0; + void* ops() {return ops_;} + Tk_OptionTable optionTable() {return optionTable_;} + const char* name() {return name_;} + ClassId classId() {return classId_;} }; #endif diff --git a/src/bltGrPenBar.C b/src/bltGrPenBar.C index c624690..860d8cf 100644 --- a/src/bltGrPenBar.C +++ b/src/bltGrPenBar.C @@ -72,36 +72,55 @@ static Tk_OptionSpec barPenOptionSpecs[] = { {TK_OPTION_END, NULL, NULL, NULL, NULL, -1, 0, 0, NULL, 0} }; -Pen* CreateBarPen(Graph* graphPtr, const char *penName) +BarPen::BarPen() : Pen() { - BarPen* penPtr = (BarPen*)calloc(1, sizeof(BarPen)); - penPtr->ops = (BarPenOptions*)calloc(1, sizeof(BarPenOptions)); - penPtr->manageOptions =1; + classId_ = CID_ELEM_BAR; - InitBarPen(graphPtr, penPtr, penName); - return (Pen*)penPtr; + fillGC_ =NULL; + outlineGC_ =NULL; + errorBarGC_ =NULL; } -void InitBarPen(Graph* graphPtr, BarPen* penPtr, const char* penName) +BarPen::BarPen(Graph* graphPtr, const char* name, Tcl_HashEntry* hPtr) + : Pen(graphPtr, name, hPtr) { - BarPenOptions* ops = (BarPenOptions*)penPtr->ops; + classId_ = CID_ELEM_BAR; + optionTable_ = Tk_CreateOptionTable(graphPtr_->interp, barPenOptionSpecs); + ops_ = (BarPenOptions*)calloc(1, sizeof(BarPenOptions)); + manageOptions_ =1; - penPtr->configProc = ConfigureBarPenProc; - penPtr->destroyProc = DestroyBarPenProc; + fillGC_ =NULL; + outlineGC_ =NULL; + errorBarGC_ =NULL; - penPtr->classId = CID_ELEM_BAR; - penPtr->name = Blt_Strdup(penName); + BarPenOptions* ops = (BarPenOptions*)ops_; + Blt_Ts_InitStyle(ops->valueStyle); +} + +void BarPen::init(Graph* graphPtr, const char* penName, BarPenOptions* ops) +{ + graphPtr_ = graphPtr; + name_ = dupstr(penName); + optionTable_ = Tk_CreateOptionTable(graphPtr_->interp, barPenOptionSpecs); + ops_ = ops; + manageOptions_ =0; Blt_Ts_InitStyle(ops->valueStyle); +} - penPtr->optionTable = - Tk_CreateOptionTable(graphPtr->interp, barPenOptionSpecs); +BarPen::~BarPen() +{ + if (outlineGC_) + Tk_FreeGC(graphPtr_->display, outlineGC_); + if (fillGC_) + Tk_FreeGC(graphPtr_->display, fillGC_); + if (errorBarGC_) + Tk_FreeGC(graphPtr_->display, errorBarGC_); } -int ConfigureBarPenProc(Graph* graphPtr, Pen *penPtr) +int BarPen::configure() { - BarPen* bpPtr = (BarPen*)penPtr; - BarPenOptions* ops = (BarPenOptions*)bpPtr->ops; + BarPenOptions* ops = (BarPenOptions*)ops_; // outlineGC { @@ -112,10 +131,10 @@ int ConfigureBarPenProc(Graph* graphPtr, Pen *penPtr) 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; + GC newGC = Tk_GetGC(graphPtr_->tkwin, gcMask, &gcValues); + if (outlineGC_) + Tk_FreeGC(graphPtr_->display, outlineGC_); + outlineGC_ = newGC; } // fillGC @@ -126,20 +145,20 @@ int ConfigureBarPenProc(Graph* graphPtr, Pen *penPtr) 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); + 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); + newGC = Tk_GetGC(graphPtr_->tkwin, gcMask, &gcValues); } - if (bpPtr->fillGC) - Tk_FreeGC(graphPtr->display, bpPtr->fillGC); - bpPtr->fillGC = newGC; + if (fillGC_) + Tk_FreeGC(graphPtr_->display, fillGC_); + fillGC_ = newGC; } // errorBarGC @@ -151,32 +170,12 @@ int ConfigureBarPenProc(Graph* graphPtr, Pen *penPtr) 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; + GC newGC = Tk_GetGC(graphPtr_->tkwin, gcMask, &gcValues); + if (errorBarGC_) + Tk_FreeGC(graphPtr_->display, errorBarGC_); + errorBarGC_ = newGC; } return TCL_OK; } -void DestroyBarPenProc(Graph* graphPtr, Pen* penPtr) -{ - 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->ops, bpPtr->optionTable, graphPtr->tkwin); - - if (bpPtr->manageOptions) - if (bpPtr->ops) - free(bpPtr->ops); -} - diff --git a/src/bltGrPenBar.h b/src/bltGrPenBar.h index 2ab3243..2e11fe2 100644 --- a/src/bltGrPenBar.h +++ b/src/bltGrPenBar.h @@ -53,28 +53,19 @@ typedef struct { Pixmap stipple; } BarPenOptions; -class BarPen { +class BarPen : public Pen { public: - const char *name; - ClassId classId; - unsigned int flags; - int refCount; - Tcl_HashEntry *hashPtr; - Tk_OptionTable optionTable; - PenConfigureProc *configProc; - PenDestroyProc *destroyProc; - Graph* graphPtr; - void* ops; - int manageOptions; + GC fillGC_; + GC outlineGC_; + GC errorBarGC_; - GC fillGC; - GC outlineGC; - GC errorBarGC; -}; + public: + BarPen(); + BarPen(Graph*, const char*, Tcl_HashEntry*); + virtual ~BarPen(); -extern Pen* CreateBarPen(Graph* graphPtr, const char *penName); -extern void InitBarPen(Graph* graphPtr, BarPen* penPtr, const char* penName); -extern int ConfigureBarPenProc(Graph* graphPtr, Pen *basePtr); -extern void DestroyBarPenProc(Graph* graphPtr, Pen* basePtr); + void init(Graph*, const char*, BarPenOptions*); + int configure(); +}; #endif diff --git a/src/bltGrPenLine.C b/src/bltGrPenLine.C index 312039c..9983ac0 100644 --- a/src/bltGrPenLine.C +++ b/src/bltGrPenLine.C @@ -149,6 +149,20 @@ static Tcl_Obj* SymbolGetProc(ClientData clientData, Tk_Window tkwin, } } +static void DestroySymbol(Display* display, Symbol* symbolPtr) +{ + if (symbolPtr->bitmap != None) { + Tk_FreeBitmap(display, symbolPtr->bitmap); + symbolPtr->bitmap = None; + } + if (symbolPtr->mask != None) { + Tk_FreeBitmap(display, symbolPtr->mask); + symbolPtr->mask = None; + } + + symbolPtr->type = SYMBOL_NONE; +} + static Tk_OptionSpec linePenOptionSpecs[] = { {TK_OPTION_COLOR, "-color", "color", "Color", STD_NORMAL_FOREGROUND, -1, Tk_Offset(LinePenOptions, traceColor), @@ -199,39 +213,76 @@ static Tk_OptionSpec linePenOptionSpecs[] = { {TK_OPTION_END, NULL, NULL, NULL, NULL, -1, 0, 0, NULL, 0} }; -Pen* CreateLinePen(Graph* graphPtr, const char* penName) +LinePen::LinePen() : Pen() { - LinePen* penPtr = (LinePen*)calloc(1, sizeof(LinePen)); - penPtr->ops = (LinePenOptions*)calloc(1, sizeof(LinePenOptions)); - penPtr->manageOptions =1; + classId_ = CID_ELEM_LINE; - InitLinePen(graphPtr, penPtr, penName); - return (Pen*)penPtr; + traceGC_ =NULL; + errorBarGC_ =NULL; } -void InitLinePen(Graph* graphPtr, LinePen* penPtr, const char* penName) +LinePen::LinePen(Graph* graphPtr, const char* name, Tcl_HashEntry* hPtr) + : Pen(graphPtr, name, hPtr) { - LinePenOptions* ops = (LinePenOptions*)penPtr->ops; + classId_ = CID_ELEM_LINE; + optionTable_ = Tk_CreateOptionTable(graphPtr_->interp, linePenOptionSpecs); + ops_ = (LinePenOptions*)calloc(1, sizeof(LinePenOptions)); + manageOptions_ =1; - penPtr->configProc = ConfigureLinePenProc; - penPtr->destroyProc = DestroyLinePenProc; + traceGC_ =NULL; + errorBarGC_ =NULL; - penPtr->classId = CID_ELEM_LINE; - penPtr->name = Blt_Strdup(penName); + LinePenOptions* ops = (LinePenOptions*)ops_; + Blt_Ts_InitStyle(ops->valueStyle); + ops->symbol.bitmap = None; + ops->symbol.mask = None; + ops->symbol.type = SYMBOL_NONE; +} + +void LinePen::init(Graph* graphPtr, const char* penName, LinePenOptions* ops) +{ + graphPtr_ = graphPtr; + name_ = dupstr(penName); + optionTable_ = Tk_CreateOptionTable(graphPtr_->interp, linePenOptionSpecs); + ops_ = ops; + manageOptions_ =0; 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); +LinePen::~LinePen() +{ + LinePenOptions* ops = (LinePenOptions*)ops_; + + if (errorBarGC_) + Tk_FreeGC(graphPtr_->display, errorBarGC_); + + if (traceGC_) + Blt_FreePrivateGC(graphPtr_->display, traceGC_); + + if (ops->symbol.outlineGC) + Tk_FreeGC(graphPtr_->display, ops->symbol.outlineGC); + + if (ops->symbol.fillGC) + Tk_FreeGC(graphPtr_->display, ops->symbol.fillGC); + + if (ops->symbol.bitmap != None) { + Tk_FreeBitmap(graphPtr_->display, ops->symbol.bitmap); + ops->symbol.bitmap = None; + } + + if (ops->symbol.mask != None) { + Tk_FreeBitmap(graphPtr_->display, ops->symbol.mask); + ops->symbol.mask = None; + } } -int ConfigureLinePenProc(Graph* graphPtr, Pen* penPtr) +int LinePen::configure() { - LinePen* lpPtr = (LinePen*)penPtr; - LinePenOptions* ops = (LinePenOptions*)lpPtr->ops; + LinePenOptions* ops = (LinePenOptions*)ops_; // symbol outline { @@ -260,9 +311,9 @@ int ConfigureLinePenProc(Graph* graphPtr, Pen* penPtr) } } gcValues.line_width = LineWidth(ops->symbol.outlineWidth); - GC newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues); + GC newGC = Tk_GetGC(graphPtr_->tkwin, gcMask, &gcValues); if (ops->symbol.outlineGC) - Tk_FreeGC(graphPtr->display, ops->symbol.outlineGC); + Tk_FreeGC(graphPtr_->display, ops->symbol.outlineGC); ops->symbol.outlineGC = newGC; } @@ -276,10 +327,10 @@ int ConfigureLinePenProc(Graph* graphPtr, Pen* penPtr) XGCValues gcValues; if (colorPtr) { gcValues.foreground = colorPtr->pixel; - newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues); + newGC = Tk_GetGC(graphPtr_->tkwin, gcMask, &gcValues); } if (ops->symbol.fillGC) - Tk_FreeGC(graphPtr->display, ops->symbol.fillGC); + Tk_FreeGC(graphPtr_->display, ops->symbol.fillGC); ops->symbol.fillGC = newGC; } @@ -303,15 +354,15 @@ int ConfigureLinePenProc(Graph* graphPtr, Pen* penPtr) 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); + GC newGC = Blt_GetPrivateGC(graphPtr_->tkwin, gcMask, &gcValues); + if (traceGC_) + Blt_FreePrivateGC(graphPtr_->display, traceGC_); if (LineIsDashed(ops->traceDashes)) { ops->traceDashes.offset = ops->traceDashes.values[0] / 2; - Blt_SetDashes(graphPtr->display, newGC, &ops->traceDashes); + Blt_SetDashes(graphPtr_->display, newGC, &ops->traceDashes); } - lpPtr->traceGC = newGC; + traceGC_ = newGC; } // errorbar @@ -323,62 +374,14 @@ int ConfigureLinePenProc(Graph* graphPtr, Pen* penPtr) 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); + GC newGC = Tk_GetGC(graphPtr_->tkwin, gcMask, &gcValues); + if (errorBarGC_) { + Tk_FreeGC(graphPtr_->display, errorBarGC_); } - lpPtr->errorBarGC = newGC; + errorBarGC_ = newGC; } return TCL_OK; } -void DestroyLinePenProc(Graph* graphPtr, Pen* penPtr) -{ - LinePen* lpPtr = (LinePen*)penPtr; - LinePenOptions* ops = (LinePenOptions*)lpPtr->ops; - - Blt_Ts_FreeStyle(graphPtr->display, &ops->valueStyle); - if (ops->symbol.outlineGC) - Tk_FreeGC(graphPtr->display, ops->symbol.outlineGC); - - if (ops->symbol.fillGC) - Tk_FreeGC(graphPtr->display, ops->symbol.fillGC); - - if (lpPtr->errorBarGC) - Tk_FreeGC(graphPtr->display, lpPtr->errorBarGC); - - if (lpPtr->traceGC) - Blt_FreePrivateGC(graphPtr->display, lpPtr->traceGC); - - if (ops->symbol.bitmap != None) { - Tk_FreeBitmap(graphPtr->display, ops->symbol.bitmap); - ops->symbol.bitmap = None; - } - if (ops->symbol.mask != None) { - Tk_FreeBitmap(graphPtr->display, ops->symbol.mask); - ops->symbol.mask = None; - } - - Tk_FreeConfigOptions((char*)lpPtr->ops, lpPtr->optionTable, graphPtr->tkwin); - - if (lpPtr->manageOptions) - if (lpPtr->ops) - free(lpPtr->ops); -} - -static void DestroySymbol(Display* display, Symbol* symbolPtr) -{ - if (symbolPtr->bitmap != None) { - Tk_FreeBitmap(display, symbolPtr->bitmap); - symbolPtr->bitmap = None; - } - if (symbolPtr->mask != None) { - Tk_FreeBitmap(display, symbolPtr->mask); - symbolPtr->mask = None; - } - - symbolPtr->type = SYMBOL_NONE; -} - diff --git a/src/bltGrPenLine.h b/src/bltGrPenLine.h index 62d7395..ff80664 100644 --- a/src/bltGrPenLine.h +++ b/src/bltGrPenLine.h @@ -73,29 +73,20 @@ typedef struct { XColor* traceOffColor; } LinePenOptions; -class LinePen { +class LinePen : public Pen { public: - const char* name; - ClassId classId; - unsigned int flags; - int refCount; - Tcl_HashEntry *hashPtr; - Tk_OptionTable optionTable; - PenConfigureProc *configProc; - PenDestroyProc *destroyProc; - Graph* graphPtr; - void* ops; - int manageOptions; + GC traceGC_; + GC errorBarGC_; - GC traceGC; - GC errorBarGC; + public: + LinePen(); + LinePen(Graph*, const char*, Tcl_HashEntry*); + virtual ~LinePen(); + + void init(Graph*, const char*, LinePenOptions*); + int configure(); }; extern Tk_ObjCustomOption symbolObjOption; -extern Pen* CreateLinePen(Graph* graphPtr, const char* penName); -extern void InitLinePen(Graph* graphPtr, LinePen* penPtr, const char* penName); -extern int ConfigureLinePenProc(Graph* graphPtr, Pen *basePtr); -extern void DestroyLinePenProc(Graph* graphPtr, Pen* basePtr); - #endif diff --git a/src/bltGrPenOp.C b/src/bltGrPenOp.C index 651db4b..cc13a13 100644 --- a/src/bltGrPenOp.C +++ b/src/bltGrPenOp.C @@ -39,7 +39,6 @@ extern "C" { // Defs -static void DestroyPen(Pen* penPtr); static int GetPenFromObj(Tcl_Interp* interp, Graph* graphPtr, Tcl_Obj *objPtr, Pen **penPtrPtr); static int PenObjConfigure(Tcl_Interp* interp, Graph* graphPtr, Pen* penPtr, @@ -66,10 +65,10 @@ int Blt_CreatePen(Graph* graphPtr, Tcl_Interp* interp, Pen* penPtr; switch (classId) { case CID_ELEM_BAR: - penPtr = CreateBarPen(graphPtr, penName); + penPtr = new BarPen(graphPtr, penName, hPtr); break; case CID_ELEM_LINE: - penPtr = CreateLinePen(graphPtr, penName); + penPtr = new LinePen(graphPtr, penName, hPtr); break; default: return TCL_ERROR; @@ -77,12 +76,10 @@ int Blt_CreatePen(Graph* graphPtr, Tcl_Interp* interp, if (!penPtr) return TCL_ERROR; - penPtr->graphPtr = graphPtr; - penPtr->hashPtr = hPtr; Tcl_SetHashValue(hPtr, penPtr); - 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); + if ((Tk_InitOptions(graphPtr->interp, (char*)penPtr->ops(), penPtr->optionTable(), graphPtr->tkwin) != TCL_OK) || (PenObjConfigure(interp, graphPtr, penPtr, objc-4, objv+4) != TCL_OK)) { + delete penPtr; return TCL_ERROR; } @@ -92,21 +89,6 @@ int Blt_CreatePen(Graph* graphPtr, Tcl_Interp* interp, return TCL_OK; } -static void DestroyPen(Pen* penPtr) -{ - Graph* graphPtr = penPtr->graphPtr; - - (*penPtr->destroyProc)(graphPtr, penPtr); - - if (penPtr->name) - free((void*)(penPtr->name)); - - if (penPtr->hashPtr) - Tcl_DeleteHashEntry(penPtr->hashPtr); - - free(penPtr); -} - // Configure static int CgetOp(Tcl_Interp* interp, Graph* graphPtr, @@ -123,7 +105,7 @@ static int CgetOp(Tcl_Interp* interp, Graph* graphPtr, Tcl_Obj* objPtr = Tk_GetOptionValue(interp, (char*)penPtr, - penPtr->optionTable, + penPtr->optionTable(), objv[4], graphPtr->tkwin); if (objPtr == NULL) return TCL_ERROR; @@ -141,7 +123,7 @@ static int ConfigureOp(Tcl_Interp* interp, Graph* graphPtr, if (objc <= 5) { Tcl_Obj* objPtr = Tk_GetOptionInfo(graphPtr->interp, (char*)penPtr, - penPtr->optionTable, + penPtr->optionTable(), (objc == 5) ? objv[4] : NULL, graphPtr->tkwin); if (objPtr == NULL) @@ -164,7 +146,7 @@ static int PenObjConfigure(Tcl_Interp* interp, Graph* graphPtr, Pen* penPtr, for (error=0; error<=1; error++) { if (!error) { - if (Tk_SetOptions(interp, (char*)penPtr->ops, penPtr->optionTable, + if (Tk_SetOptions(interp, (char*)penPtr->ops(), penPtr->optionTable(), objc, objv, graphPtr->tkwin, &savedOptions, &mask) != TCL_OK) continue; @@ -177,7 +159,7 @@ static int PenObjConfigure(Tcl_Interp* interp, Graph* graphPtr, Pen* penPtr, graphPtr->flags |= mask; graphPtr->flags |= CACHE_DIRTY; - if ((*penPtr->configProc)(graphPtr, penPtr) != TCL_OK) + if (penPtr->configure() != TCL_OK) return TCL_ERROR; Blt_EventuallyRedrawGraph(graphPtr); @@ -224,7 +206,7 @@ static int DeleteOp(Tcl_Interp* interp, Graph* graphPtr, penPtr->flags |= DELETE_PENDING; if (penPtr->refCount == 0) - DestroyPen(penPtr); + delete penPtr; return TCL_OK; } @@ -238,10 +220,9 @@ static int NamesOp(Tcl_Interp* interp, Graph* graphPtr, for (Tcl_HashEntry *hPtr = Tcl_FirstHashEntry(&graphPtr->penTable, &iter); hPtr != NULL; hPtr = Tcl_NextHashEntry(&iter)) { Pen* penPtr = (Pen*)Tcl_GetHashValue(hPtr); - if ((penPtr->flags & DELETE_PENDING) == 0) { + if ((penPtr->flags & DELETE_PENDING) == 0) Tcl_ListObjAppendElement(interp, listObjPtr, - Tcl_NewStringObj(penPtr->name, -1)); - } + Tcl_NewStringObj(penPtr->name(), -1)); } } else { @@ -250,11 +231,11 @@ static int NamesOp(Tcl_Interp* interp, Graph* graphPtr, hPtr != NULL; hPtr = Tcl_NextHashEntry(&iter)) { Pen* penPtr = (Pen*)Tcl_GetHashValue(hPtr); if ((penPtr->flags & DELETE_PENDING) == 0) { - for (int i = 3; i < objc; i++) { - char *pattern = Tcl_GetString(objv[i]); - if (Tcl_StringMatch(penPtr->name, pattern)) { + for (int ii=3; ii<objc; ii++) { + char *pattern = Tcl_GetString(objv[ii]); + if (Tcl_StringMatch(penPtr->name(), pattern)) { Tcl_ListObjAppendElement(interp, listObjPtr, - Tcl_NewStringObj(penPtr->name, -1)); + Tcl_NewStringObj(penPtr->name(), -1)); break; } } @@ -272,7 +253,8 @@ static int TypeOp(Tcl_Interp* interp, Graph* graphPtr, if (GetPenFromObj(interp, graphPtr, objv[3], &penPtr) != TCL_OK) return TCL_ERROR; - Tcl_SetStringObj(Tcl_GetObjResult(interp), Blt_GraphClassName(penPtr->classId), -1); + Tcl_SetStringObj(Tcl_GetObjResult(interp), + Blt_GraphClassName(penPtr->classId()), -1); return TCL_OK; } @@ -305,8 +287,7 @@ void Blt_DestroyPens(Graph* graphPtr) for (Tcl_HashEntry *hPtr = Tcl_FirstHashEntry(&graphPtr->penTable, &iter); hPtr != NULL; hPtr = Tcl_NextHashEntry(&iter)) { Pen* penPtr = (Pen*)Tcl_GetHashValue(hPtr); - penPtr->hashPtr = NULL; - DestroyPen(penPtr); + delete penPtr; } Tcl_DeleteHashTable(&graphPtr->penTable); } @@ -316,7 +297,7 @@ void Blt_FreePen(Pen* penPtr) if (penPtr != NULL) { penPtr->refCount--; if ((penPtr->refCount == 0) && (penPtr->flags & DELETE_PENDING)) - DestroyPen(penPtr); + delete penPtr; } } @@ -338,10 +319,11 @@ int Blt_GetPenFromObj(Tcl_Interp* interp, Graph* graphPtr, Tcl_Obj *objPtr, return TCL_ERROR; } - if (penPtr->classId != classId) { + if (penPtr->classId() != classId) { Tcl_AppendResult(interp, "pen \"", name, "\" is the wrong type (is \"", - Blt_GraphClassName(penPtr->classId), "\"", ", wanted \"", + Blt_GraphClassName(penPtr->classId()), + "\"", ", wanted \"", Blt_GraphClassName(classId), "\")", (char *)NULL); return TCL_ERROR; } @@ -362,9 +344,8 @@ static int GetPenFromObj(Tcl_Interp* interp, Graph* graphPtr, Tcl_Obj *objPtr, Tcl_HashEntry *hPtr = Tcl_FindHashEntry(&graphPtr->penTable, name); if (hPtr != NULL) { penPtr = (Pen*)Tcl_GetHashValue(hPtr); - if (penPtr->flags & DELETE_PENDING) { + if (penPtr->flags & DELETE_PENDING) penPtr = NULL; - } } if (penPtr == NULL) { if (interp != NULL) { diff --git a/src/bltGrPenOp.h b/src/bltGrPenOp.h index b4f59a0..57e0360 100644 --- a/src/bltGrPenOp.h +++ b/src/bltGrPenOp.h @@ -32,5 +32,11 @@ extern int Blt_GetPenFromObj(Tcl_Interp* interp, Graph* graphPtr, Tcl_Obj *objPtr, ClassId classId, Pen **penPtrPtr); extern void Blt_FreePen(Pen* penPtr); +extern int Blt_PenOp(Graph* graphPtr, Tcl_Interp* interp, int objc, + Tcl_Obj* const objv[]); +extern int Blt_CreatePen(Graph* graphPtr, Tcl_Interp* interp, + const char* penName, ClassId classId, + int objc, Tcl_Obj* const objv[]); +extern void Blt_DestroyPens(Graph* graphPtr); #endif diff --git a/src/bltGrPenOption.C b/src/bltGrPenOption.C index 482ad7a..4b3576e 100644 --- a/src/bltGrPenOption.C +++ b/src/bltGrPenOption.C @@ -79,7 +79,7 @@ static Tcl_Obj* PenGetProc(ClientData clientData, Tk_Window tkwin, if (!penPtr) return Tcl_NewStringObj("", -1); - return Tcl_NewStringObj(penPtr->name, -1); + return Tcl_NewStringObj(penPtr->name(), -1); }; static void PenFreeProc(ClientData clientData, Tk_Window tkwin, char *ptr) diff --git a/src/bltGraph.C b/src/bltGraph.C index 64b1783..d395476 100644 --- a/src/bltGraph.C +++ b/src/bltGraph.C @@ -27,9 +27,6 @@ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include <X11/Xlib.h> -#include <X11/Xutil.h> - #include "bltC.h" #include "bltMath.h" @@ -40,6 +37,8 @@ extern "C" { #include "bltOp.h" } +#include "bltGrPen.h" +#include "bltGrPenOp.h" #include "bltGrElem.h" #include "bltGrElemOp.h" #include "bltGrMarker.h" diff --git a/src/bltGraph.h b/src/bltGraph.h index 8b6d848..4951a89 100644 --- a/src/bltGraph.h +++ b/src/bltGraph.h @@ -388,17 +388,7 @@ struct _Graph { extern int Blt_PointInPolygon(Point2d *samplePtr, Point2d *screenPts, int nScreenPts); -// Pens -extern int Blt_PenOp(Graph* graphPtr, Tcl_Interp* interp, int objc, - Tcl_Obj* const objv[]); -extern int Blt_CreatePen(Graph* graphPtr, Tcl_Interp* interp, - const char* penName, ClassId classId, - int objc, Tcl_Obj* const objv[]); -extern void Blt_DestroyPens(Graph* graphPtr); - // Elements - - extern void Blt_DestroyBarSets(Graph* graphPtr); extern void Blt_ResetBarGroups(Graph* graphPtr); extern void Blt_InitBarSetTable(Graph* graphPtr); |