From 807cee8a45e33554416ec91b7ac5514ae6883f6c Mon Sep 17 00:00:00 2001 From: joye Date: Thu, 27 Mar 2014 21:33:00 +0000 Subject: *** empty log message *** --- bltGrMarkerBitmap.C | 37 +++++----- bltGrMarkerBitmap.h | 3 + src/bltGrMarker.C | 4 +- src/bltGrMarker.h | 6 +- src/bltGrMarkerLine.C | 117 ++++++++++++++++---------------- src/bltGrMarkerLine.h | 3 + src/bltGrMarkerPolygon.C | 173 +++++++++++++++++++++++------------------------ src/bltGrMarkerPolygon.h | 3 + src/bltGrMarkerText.C | 25 +++---- src/bltGrMarkerText.h | 3 + 10 files changed, 189 insertions(+), 185 deletions(-) diff --git a/bltGrMarkerBitmap.C b/bltGrMarkerBitmap.C index 92e5640..a6de75a 100644 --- a/bltGrMarkerBitmap.C +++ b/bltGrMarkerBitmap.C @@ -81,7 +81,6 @@ static Tk_OptionSpec optionSpecs[] = { {TK_OPTION_END, NULL, NULL, NULL, NULL, -1, 0, 0, NULL, 0} }; -static MarkerConfigProc ConfigureBitmapProc; static MarkerDrawProc DrawBitmapProc; static MarkerMapProc MapBitmapProc; static MarkerPointProc PointInBitmapProc; @@ -90,7 +89,6 @@ static MarkerRegionProc RegionInBitmapProc; static MarkerClass bitmapMarkerClass = { optionSpecs, - ConfigureBitmapProc, DrawBitmapProc, MapBitmapProc, PointInBitmapProc, @@ -126,30 +124,29 @@ BitmapMarker::~BitmapMarker() Tk_FreeGC(graphPtr->display, fillGC); } -static int ConfigureBitmapProc(Marker* markerPtr) +int BitmapMarker::Configure() { - Graph* graphPtr = markerPtr->obj.graphPtr; - BitmapMarker* bmPtr = (BitmapMarker*)markerPtr; - BitmapMarkerOptions* ops = (BitmapMarkerOptions*)bmPtr->ops; + Graph* graphPtr = obj.graphPtr; + BitmapMarkerOptions* opp = (BitmapMarkerOptions*)ops; - if (ops->bitmap == None) + if (opp->bitmap == None) return TCL_OK; XGCValues gcValues; unsigned long gcMask = 0; - if (ops->outlineColor) { + if (opp->outlineColor) { gcMask |= GCForeground; - gcValues.foreground = ops->outlineColor->pixel; + gcValues.foreground = opp->outlineColor->pixel; } - if (ops->fillColor) { + if (opp->fillColor) { // Opaque bitmap: both foreground and background (fill) colors are used - gcValues.background = ops->fillColor->pixel; + gcValues.background = opp->fillColor->pixel; gcMask |= GCBackground; } else { // Transparent bitmap: set the clip mask to the current bitmap - gcValues.clip_mask = ops->bitmap; + gcValues.clip_mask = opp->bitmap; gcMask |= GCClipMask; } @@ -158,17 +155,17 @@ static int ConfigureBitmapProc(Marker* markerPtr) // no other client will be allocated this GC with the GCClipMask set to // this particular bitmap. GC newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues); - if (bmPtr->gc) - Tk_FreeGC(graphPtr->display, bmPtr->gc); - bmPtr->gc = newGC; + if (gc) + Tk_FreeGC(graphPtr->display, gc); + gc = newGC; // Create the background GC containing the fill color - if (ops->fillColor) { - gcValues.foreground = ops->fillColor->pixel; + if (opp->fillColor) { + gcValues.foreground = opp->fillColor->pixel; newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues); - if (bmPtr->fillGC) - Tk_FreeGC(graphPtr->display, bmPtr->fillGC); - bmPtr->fillGC = newGC; + if (fillGC) + Tk_FreeGC(graphPtr->display, fillGC); + fillGC = newGC; } return TCL_OK; diff --git a/bltGrMarkerBitmap.h b/bltGrMarkerBitmap.h index 4bf3bc9..5feb5ef 100644 --- a/bltGrMarkerBitmap.h +++ b/bltGrMarkerBitmap.h @@ -61,6 +61,9 @@ class BitmapMarker : public Marker { int width; int height; + private: + int Configure(); + public: BitmapMarker(Graph*, const char*); virtual ~BitmapMarker(); diff --git a/src/bltGrMarker.C b/src/bltGrMarker.C index 884880f..73ac27e 100644 --- a/src/bltGrMarker.C +++ b/src/bltGrMarker.C @@ -394,7 +394,7 @@ static int MarkerObjConfigure( Tcl_Interp* interp, Graph* graphPtr, markerPtr->flags |= mask; markerPtr->flags |= MAP_ITEM; graphPtr->flags |= CACHE_DIRTY; - if ((*markerPtr->classPtr->configProc)(markerPtr) != TCL_OK) + if (markerPtr->Configure() != TCL_OK) return TCL_ERROR; Blt_EventuallyRedrawGraph(graphPtr); @@ -825,7 +825,7 @@ void Blt_ConfigureMarkers(Graph* graphPtr) for (Blt_ChainLink link = Blt_Chain_FirstLink(graphPtr->markers.displayList); link; link = Blt_Chain_NextLink(link)) { Marker* markerPtr = (Marker*)Blt_Chain_GetValue(link); - (*markerPtr->classPtr->configProc)(markerPtr); + markerPtr->Configure(); } } diff --git a/src/bltGrMarker.h b/src/bltGrMarker.h index cb5971e..671b17f 100644 --- a/src/bltGrMarker.h +++ b/src/bltGrMarker.h @@ -45,7 +45,6 @@ typedef int (MarkerRegionProc)(Marker* markerPtr, Region2d *extsPtr, int enclose typedef struct { Tk_OptionSpec *optionSpecs; - MarkerConfigProc *configProc; MarkerDrawProc *drawProc; MarkerMapProc *mapProc; MarkerPointProc *pointProc; @@ -71,6 +70,8 @@ typedef struct { } MarkerOptions; class Marker { + protected: + public: GraphObj obj; MarkerClass *classPtr; @@ -82,9 +83,12 @@ typedef struct { void* ops; + public: Marker(Graph*, const char*); virtual ~Marker(); + + virtual int Configure() =0; }; }; diff --git a/src/bltGrMarkerLine.C b/src/bltGrMarkerLine.C index ca6e6fb..721e60f 100644 --- a/src/bltGrMarkerLine.C +++ b/src/bltGrMarkerLine.C @@ -87,7 +87,6 @@ static Tk_OptionSpec optionSpecs[] = { {TK_OPTION_END, NULL, NULL, NULL, NULL, -1, 0, 0, NULL, 0} }; -static MarkerConfigProc ConfigureLineProc; static MarkerDrawProc DrawLineProc; static MarkerMapProc MapLineProc; static MarkerPointProc PointInLineProc; @@ -96,7 +95,6 @@ static MarkerRegionProc RegionInLineProc; static MarkerClass lineMarkerClass = { optionSpecs, - ConfigureLineProc, DrawLineProc, MapLineProc, PointInLineProc, @@ -130,6 +128,63 @@ LineMarker::~LineMarker() free(segments); } +int LineMarker::Configure() +{ + Graph* graphPtr = obj.graphPtr; + LineMarkerOptions* opp = (LineMarkerOptions*)ops; + + Drawable drawable = Tk_WindowId(graphPtr->tkwin); + unsigned long gcMask = (GCLineWidth | GCLineStyle | GCCapStyle | GCJoinStyle); + XGCValues gcValues; + if (opp->outlineColor) { + gcMask |= GCForeground; + gcValues.foreground = opp->outlineColor->pixel; + } + if (opp->fillColor) { + gcMask |= GCBackground; + gcValues.background = opp->fillColor->pixel; + } + gcValues.cap_style = opp->capStyle; + gcValues.join_style = opp->joinStyle; + gcValues.line_width = LineWidth(opp->lineWidth); + gcValues.line_style = LineSolid; + if (LineIsDashed(opp->dashes)) { + gcValues.line_style = + (gcMask & GCBackground) ? LineDoubleDash : LineOnOffDash; + } + if (opp->xorr) { + unsigned long pixel; + gcValues.function = GXxor; + + gcMask |= GCFunction; + pixel = Tk_3DBorderColor(graphPtr->plotBg)->pixel; + if (gcMask & GCBackground) + gcValues.background ^= pixel; + + gcValues.foreground ^= pixel; + if (drawable != None) + DrawLineProc(this, drawable); + } + + GC newGC = Blt_GetPrivateGC(graphPtr->tkwin, gcMask, &gcValues); + if (gc) + Blt_FreePrivateGC(graphPtr->display, gc); + + if (LineIsDashed(opp->dashes)) + Blt_SetDashes(graphPtr->display, newGC, &opp->dashes); + + gc = newGC; + if (opp->xorr) { + if (drawable != None) { + MapLineProc(this); + DrawLineProc(this, drawable); + } + return TCL_OK; + } + + return TCL_OK; +} + static int PointInLineProc(Marker* markerPtr, Point2d *samplePtr) { LineMarker *lmPtr = (LineMarker*)markerPtr; @@ -189,64 +244,6 @@ static void DrawLineProc(Marker* markerPtr, Drawable drawable) } } -static int ConfigureLineProc(Marker* markerPtr) -{ - Graph* graphPtr = markerPtr->obj.graphPtr; - LineMarker *lmPtr = (LineMarker*)markerPtr; - LineMarkerOptions* ops = (LineMarkerOptions*)lmPtr->ops; - - Drawable drawable = Tk_WindowId(graphPtr->tkwin); - unsigned long gcMask = (GCLineWidth | GCLineStyle | GCCapStyle | GCJoinStyle); - XGCValues gcValues; - if (ops->outlineColor) { - gcMask |= GCForeground; - gcValues.foreground = ops->outlineColor->pixel; - } - if (ops->fillColor) { - gcMask |= GCBackground; - gcValues.background = ops->fillColor->pixel; - } - gcValues.cap_style = ops->capStyle; - gcValues.join_style = ops->joinStyle; - gcValues.line_width = LineWidth(ops->lineWidth); - gcValues.line_style = LineSolid; - if (LineIsDashed(ops->dashes)) { - gcValues.line_style = - (gcMask & GCBackground) ? LineDoubleDash : LineOnOffDash; - } - if (ops->xorr) { - unsigned long pixel; - gcValues.function = GXxor; - - gcMask |= GCFunction; - pixel = Tk_3DBorderColor(graphPtr->plotBg)->pixel; - if (gcMask & GCBackground) - gcValues.background ^= pixel; - - gcValues.foreground ^= pixel; - if (drawable != None) - DrawLineProc(markerPtr, drawable); - } - - GC newGC = Blt_GetPrivateGC(graphPtr->tkwin, gcMask, &gcValues); - if (lmPtr->gc) - Blt_FreePrivateGC(graphPtr->display, lmPtr->gc); - - if (LineIsDashed(ops->dashes)) - Blt_SetDashes(graphPtr->display, newGC, &ops->dashes); - - lmPtr->gc = newGC; - if (ops->xorr) { - if (drawable != None) { - MapLineProc(markerPtr); - DrawLineProc(markerPtr, drawable); - } - return TCL_OK; - } - - return TCL_OK; -} - static void LineToPostscriptProc(Marker* markerPtr, Blt_Ps ps) { LineMarker *lmPtr = (LineMarker*)markerPtr; diff --git a/src/bltGrMarkerLine.h b/src/bltGrMarkerLine.h index dcc7585..d4f3a8f 100644 --- a/src/bltGrMarkerLine.h +++ b/src/bltGrMarkerLine.h @@ -61,6 +61,9 @@ class LineMarker : public Marker { int nSegments; int xorState; + private: + int Configure(); + public: LineMarker(Graph*, const char*); virtual ~LineMarker(); diff --git a/src/bltGrMarkerPolygon.C b/src/bltGrMarkerPolygon.C index 71e0e6f..45184ae 100644 --- a/src/bltGrMarkerPolygon.C +++ b/src/bltGrMarkerPolygon.C @@ -95,7 +95,6 @@ static Tk_OptionSpec optionSpecs[] = { {TK_OPTION_END, NULL, NULL, NULL, NULL, -1, 0, 0, NULL, 0} }; -static MarkerConfigProc ConfigurePolygonProc; static MarkerDrawProc DrawPolygonProc; static MarkerMapProc MapPolygonProc; static MarkerPointProc PointInPolygonProc; @@ -104,7 +103,6 @@ static MarkerRegionProc RegionInPolygonProc; static MarkerClass polygonMarkerClass = { optionSpecs, - ConfigurePolygonProc, DrawPolygonProc, MapPolygonProc, PointInPolygonProc, @@ -147,6 +145,91 @@ PolygonMarker::~PolygonMarker() free(screenPts); } +int PolygonMarker::Configure() +{ + Graph* graphPtr = obj.graphPtr; + PolygonMarkerOptions* opp = (PolygonMarkerOptions*)ops; + + GC newGC; + XGCValues gcValues; + unsigned long gcMask; + Drawable drawable; + + drawable = Tk_WindowId(graphPtr->tkwin); + gcMask = (GCLineWidth | GCLineStyle); + if (opp->outline) { + gcMask |= GCForeground; + gcValues.foreground = opp->outline->pixel; + } + if (opp->outlineBg) { + gcMask |= GCBackground; + gcValues.background = opp->outlineBg->pixel; + } + gcMask |= (GCCapStyle | GCJoinStyle); + gcValues.cap_style = opp->capStyle; + gcValues.join_style = opp->joinStyle; + gcValues.line_style = LineSolid; + gcValues.dash_offset = 0; + gcValues.line_width = LineWidth(opp->lineWidth); + if (LineIsDashed(opp->dashes)) { + gcValues.line_style = (opp->outlineBg == NULL) + ? LineOnOffDash : LineDoubleDash; + } + if (opp->xorr) { + unsigned long pixel; + gcValues.function = GXxor; + + gcMask |= GCFunction; + pixel = Tk_3DBorderColor(graphPtr->plotBg)->pixel; + if (gcMask & GCBackground) { + gcValues.background ^= pixel; + } + gcValues.foreground ^= pixel; + if (drawable != None) { + DrawPolygonProc(this, drawable); + } + } + newGC = Blt_GetPrivateGC(graphPtr->tkwin, gcMask, &gcValues); + if (LineIsDashed(opp->dashes)) { + Blt_SetDashes(graphPtr->display, newGC, &opp->dashes); + } + if (outlineGC) { + Blt_FreePrivateGC(graphPtr->display, outlineGC); + } + outlineGC = newGC; + + gcMask = 0; + if (opp->fill) { + gcMask |= GCForeground; + gcValues.foreground = opp->fill->pixel; + } + if (opp->fillBg) { + gcMask |= GCBackground; + gcValues.background = opp->fillBg->pixel; + } + if (opp->stipple != None) { + gcValues.stipple = opp->stipple; + gcValues.fill_style = (opp->fillBg) + ? FillOpaqueStippled : FillStippled; + gcMask |= (GCStipple | GCFillStyle); + } + newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues); + if (fillGC) { + Tk_FreeGC(graphPtr->display, fillGC); + } + fillGC = newGC; + + if ((gcMask == 0) && !(graphPtr->flags & RESET_AXES) && (opp->xorr)) { + if (drawable != None) { + MapPolygonProc(this); + DrawPolygonProc(this, drawable); + } + return TCL_OK; + } + + return TCL_OK; +} + static int PointInPolygonProc(Marker* markerPtr, Point2d *samplePtr) { PolygonMarker *pmPtr = (PolygonMarker *)markerPtr; @@ -273,92 +356,6 @@ static void PolygonToPostscriptProc(Marker* markerPtr, Blt_Ps ps) } } -static int ConfigurePolygonProc(Marker* markerPtr) -{ - Graph* graphPtr = markerPtr->obj.graphPtr; - PolygonMarker *pmPtr = (PolygonMarker *)markerPtr; - PolygonMarkerOptions* ops = (PolygonMarkerOptions*)pmPtr->ops; - - GC newGC; - XGCValues gcValues; - unsigned long gcMask; - Drawable drawable; - - drawable = Tk_WindowId(graphPtr->tkwin); - gcMask = (GCLineWidth | GCLineStyle); - if (ops->outline) { - gcMask |= GCForeground; - gcValues.foreground = ops->outline->pixel; - } - if (ops->outlineBg) { - gcMask |= GCBackground; - gcValues.background = ops->outlineBg->pixel; - } - gcMask |= (GCCapStyle | GCJoinStyle); - gcValues.cap_style = ops->capStyle; - gcValues.join_style = ops->joinStyle; - gcValues.line_style = LineSolid; - gcValues.dash_offset = 0; - gcValues.line_width = LineWidth(ops->lineWidth); - if (LineIsDashed(ops->dashes)) { - gcValues.line_style = (ops->outlineBg == NULL) - ? LineOnOffDash : LineDoubleDash; - } - if (ops->xorr) { - unsigned long pixel; - gcValues.function = GXxor; - - gcMask |= GCFunction; - pixel = Tk_3DBorderColor(graphPtr->plotBg)->pixel; - if (gcMask & GCBackground) { - gcValues.background ^= pixel; - } - gcValues.foreground ^= pixel; - if (drawable != None) { - DrawPolygonProc(markerPtr, drawable); - } - } - newGC = Blt_GetPrivateGC(graphPtr->tkwin, gcMask, &gcValues); - if (LineIsDashed(ops->dashes)) { - Blt_SetDashes(graphPtr->display, newGC, &ops->dashes); - } - if (pmPtr->outlineGC) { - Blt_FreePrivateGC(graphPtr->display, pmPtr->outlineGC); - } - pmPtr->outlineGC = newGC; - - gcMask = 0; - if (ops->fill) { - gcMask |= GCForeground; - gcValues.foreground = ops->fill->pixel; - } - if (ops->fillBg) { - gcMask |= GCBackground; - gcValues.background = ops->fillBg->pixel; - } - if (ops->stipple != None) { - gcValues.stipple = ops->stipple; - gcValues.fill_style = (ops->fillBg) - ? FillOpaqueStippled : FillStippled; - gcMask |= (GCStipple | GCFillStyle); - } - newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues); - if (pmPtr->fillGC) { - Tk_FreeGC(graphPtr->display, pmPtr->fillGC); - } - pmPtr->fillGC = newGC; - - if ((gcMask == 0) && !(graphPtr->flags & RESET_AXES) && (ops->xorr)) { - if (drawable != None) { - MapPolygonProc(markerPtr); - DrawPolygonProc(markerPtr, drawable); - } - return TCL_OK; - } - - return TCL_OK; -} - static void MapPolygonProc(Marker* markerPtr) { Graph* graphPtr = markerPtr->obj.graphPtr; diff --git a/src/bltGrMarkerPolygon.h b/src/bltGrMarkerPolygon.h index 2e70e31..00df2f5 100644 --- a/src/bltGrMarkerPolygon.h +++ b/src/bltGrMarkerPolygon.h @@ -68,6 +68,9 @@ class PolygonMarker : public Marker { int nOutlinePts; int xorState; + private: + int Configure(); + public: PolygonMarker(Graph*, const char*); virtual ~PolygonMarker(); diff --git a/src/bltGrMarkerText.C b/src/bltGrMarkerText.C index 09b84c2..6e3015a 100644 --- a/src/bltGrMarkerText.C +++ b/src/bltGrMarkerText.C @@ -85,7 +85,6 @@ static Tk_OptionSpec optionSpecs[] = { {TK_OPTION_END, NULL, NULL, NULL, NULL, -1, 0, 0, NULL, 0} }; -static MarkerConfigProc ConfigureTextProc; static MarkerDrawProc DrawTextProc; static MarkerMapProc MapTextProc; static MarkerPointProc PointInTextProc; @@ -94,7 +93,6 @@ static MarkerRegionProc RegionInTextProc; static MarkerClass textMarkerClass = { optionSpecs, - ConfigureTextProc, DrawTextProc, MapTextProc, PointInTextProc, @@ -126,27 +124,26 @@ TextMarker::~TextMarker() Blt_Ts_FreeStyle(graphPtr->display, &((TextMarkerOptions*)ops)->style); } -static int ConfigureTextProc(Marker* markerPtr) +int TextMarker::Configure() { - Graph* graphPtr = markerPtr->obj.graphPtr; - TextMarker* tmPtr = (TextMarker*)markerPtr; - TextMarkerOptions* ops = (TextMarkerOptions*)tmPtr->ops; + Graph* graphPtr = obj.graphPtr; + TextMarkerOptions* opp = (TextMarkerOptions*)ops; - ops->style.angle = (float)fmod(ops->style.angle, 360.0); - if (ops->style.angle < 0.0f) - ops->style.angle += 360.0f; + opp->style.angle = (float)fmod(opp->style.angle, 360.0); + if (opp->style.angle < 0.0f) + opp->style.angle += 360.0f; GC newGC = NULL; XGCValues gcValues; unsigned long gcMask; - if (ops->fillColor) { + if (opp->fillColor) { gcMask = GCForeground; - gcValues.foreground = ops->fillColor->pixel; + gcValues.foreground = opp->fillColor->pixel; newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues); } - if (tmPtr->fillGC) - Tk_FreeGC(graphPtr->display, tmPtr->fillGC); - tmPtr->fillGC = newGC; + if (fillGC) + Tk_FreeGC(graphPtr->display, fillGC); + fillGC = newGC; return TCL_OK; } diff --git a/src/bltGrMarkerText.h b/src/bltGrMarkerText.h index b19df3a..1090258 100644 --- a/src/bltGrMarkerText.h +++ b/src/bltGrMarkerText.h @@ -59,6 +59,9 @@ class TextMarker : public Marker { GC fillGC; Point2d outline[5]; + private: + int Configure(); + public: TextMarker(Graph*, const char*); virtual ~TextMarker(); -- cgit v0.12