diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bltGrMarker.C | 6 | ||||
-rw-r--r-- | src/bltGrMarker.h | 5 | ||||
-rw-r--r-- | src/bltGrMarkerLine.C | 35 | ||||
-rw-r--r-- | src/bltGrMarkerLine.h | 3 | ||||
-rw-r--r-- | src/bltGrMarkerPolygon.C | 73 | ||||
-rw-r--r-- | src/bltGrMarkerPolygon.h | 3 | ||||
-rw-r--r-- | src/bltGrMarkerText.C | 57 | ||||
-rw-r--r-- | src/bltGrMarkerText.h | 3 |
8 files changed, 88 insertions, 97 deletions
diff --git a/src/bltGrMarker.C b/src/bltGrMarker.C index 73ac27e..a7596ca 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->Configure() != TCL_OK) + if (markerPtr->configure() != TCL_OK) return TCL_ERROR; Blt_EventuallyRedrawGraph(graphPtr); @@ -816,7 +816,7 @@ void Blt_DrawMarkers(Graph* graphPtr, Drawable drawable, int under) if (IsElementHidden(markerPtr)) continue; - (*markerPtr->classPtr->drawProc) (markerPtr, drawable); + markerPtr->draw(drawable); } } @@ -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->Configure(); + markerPtr->configure(); } } diff --git a/src/bltGrMarker.h b/src/bltGrMarker.h index 671b17f..a0a957f 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; - MarkerDrawProc *drawProc; MarkerMapProc *mapProc; MarkerPointProc *pointProc; MarkerRegionProc *regionProc; @@ -83,12 +82,12 @@ typedef struct { void* ops; - public: Marker(Graph*, const char*); virtual ~Marker(); - virtual int Configure() =0; + virtual int configure() =0; + virtual void draw(Drawable) =0; }; }; diff --git a/src/bltGrMarkerLine.C b/src/bltGrMarkerLine.C index 721e60f..d540813 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 MarkerDrawProc DrawLineProc; static MarkerMapProc MapLineProc; static MarkerPointProc PointInLineProc; static MarkerPostscriptProc LineToPostscriptProc; @@ -95,7 +94,6 @@ static MarkerRegionProc RegionInLineProc; static MarkerClass lineMarkerClass = { optionSpecs, - DrawLineProc, MapLineProc, PointInLineProc, RegionInLineProc, @@ -128,7 +126,7 @@ LineMarker::~LineMarker() free(segments); } -int LineMarker::Configure() +int LineMarker::configure() { Graph* graphPtr = obj.graphPtr; LineMarkerOptions* opp = (LineMarkerOptions*)ops; @@ -163,7 +161,7 @@ int LineMarker::Configure() gcValues.foreground ^= pixel; if (drawable != None) - DrawLineProc(this, drawable); + draw(drawable); } GC newGC = Blt_GetPrivateGC(graphPtr->tkwin, gcMask, &gcValues); @@ -177,7 +175,7 @@ int LineMarker::Configure() if (opp->xorr) { if (drawable != None) { MapLineProc(this); - DrawLineProc(this, drawable); + draw(drawable); } return TCL_OK; } @@ -185,6 +183,18 @@ int LineMarker::Configure() return TCL_OK; } +void LineMarker::draw(Drawable drawable) +{ + Graph* graphPtr = obj.graphPtr; + LineMarkerOptions* opp = (LineMarkerOptions*)ops; + + if (nSegments > 0) { + Blt_Draw2DSegments(graphPtr->display, drawable, gc, segments, nSegments); + if (opp->xorr) + xorState = (xorState == 0); + } +} + static int PointInLineProc(Marker* markerPtr, Point2d *samplePtr) { LineMarker *lmPtr = (LineMarker*)markerPtr; @@ -229,21 +239,6 @@ static int RegionInLineProc(Marker* markerPtr, Region2d *extsPtr, int enclosed) } } -static void DrawLineProc(Marker* markerPtr, Drawable drawable) -{ - LineMarker *lmPtr = (LineMarker*)markerPtr; - LineMarkerOptions* ops = (LineMarkerOptions*)lmPtr->ops; - - if (lmPtr->nSegments > 0) { - Graph* graphPtr = markerPtr->obj.graphPtr; - - Blt_Draw2DSegments(graphPtr->display, drawable, lmPtr->gc, - lmPtr->segments, lmPtr->nSegments); - if (ops->xorr) - lmPtr->xorState = (lmPtr->xorState == 0); - } -} - static void LineToPostscriptProc(Marker* markerPtr, Blt_Ps ps) { LineMarker *lmPtr = (LineMarker*)markerPtr; diff --git a/src/bltGrMarkerLine.h b/src/bltGrMarkerLine.h index d4f3a8f..0e8d1b0 100644 --- a/src/bltGrMarkerLine.h +++ b/src/bltGrMarkerLine.h @@ -62,7 +62,8 @@ class LineMarker : public Marker { int xorState; private: - int Configure(); + int configure(); + void draw(Drawable); public: LineMarker(Graph*, const char*); diff --git a/src/bltGrMarkerPolygon.C b/src/bltGrMarkerPolygon.C index 45184ae..3a41615 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 MarkerDrawProc DrawPolygonProc; static MarkerMapProc MapPolygonProc; static MarkerPointProc PointInPolygonProc; static MarkerPostscriptProc PolygonToPostscriptProc; @@ -103,7 +102,6 @@ static MarkerRegionProc RegionInPolygonProc; static MarkerClass polygonMarkerClass = { optionSpecs, - DrawPolygonProc, MapPolygonProc, PointInPolygonProc, RegionInPolygonProc, @@ -145,7 +143,7 @@ PolygonMarker::~PolygonMarker() free(screenPts); } -int PolygonMarker::Configure() +int PolygonMarker::configure() { Graph* graphPtr = obj.graphPtr; PolygonMarkerOptions* opp = (PolygonMarkerOptions*)ops; @@ -186,7 +184,7 @@ int PolygonMarker::Configure() } gcValues.foreground ^= pixel; if (drawable != None) { - DrawPolygonProc(this, drawable); + draw(drawable); } } newGC = Blt_GetPrivateGC(graphPtr->tkwin, gcMask, &gcValues); @@ -222,7 +220,7 @@ int PolygonMarker::Configure() if ((gcMask == 0) && !(graphPtr->flags & RESET_AXES) && (opp->xorr)) { if (drawable != None) { MapPolygonProc(this); - DrawPolygonProc(this, drawable); + draw(drawable); } return TCL_OK; } @@ -230,6 +228,38 @@ int PolygonMarker::Configure() return TCL_OK; } +void PolygonMarker::draw(Drawable drawable) +{ + Graph* graphPtr = obj.graphPtr; + PolygonMarkerOptions* opp = (PolygonMarkerOptions*)ops; + + // fill region + if ((nFillPts > 0) && (opp->fill)) { + XPoint* points = (XPoint*)malloc(nFillPts * sizeof(XPoint)); + if (!points) + return; + + XPoint* dp = points; + Point2d *sp, *send; + for (sp = fillPts, send = sp + nFillPts; sp < send; sp++) { + dp->x = (short int)sp->x; + dp->y = (short int)sp->y; + dp++; + } + + XFillPolygon(graphPtr->display, drawable, fillGC, points, + nFillPts, Complex, CoordModeOrigin); + free(points); + } + + // outline + if ((nOutlinePts > 0) && (opp->lineWidth > 0) && + (opp->outline)) { + Blt_Draw2DSegments(graphPtr->display, drawable, outlineGC, + outlinePts, nOutlinePts); + } +} + static int PointInPolygonProc(Marker* markerPtr, Point2d *samplePtr) { PolygonMarker *pmPtr = (PolygonMarker *)markerPtr; @@ -259,39 +289,6 @@ static int RegionInPolygonProc(Marker* markerPtr, Region2d *extsPtr, return FALSE; } -static void DrawPolygonProc(Marker* markerPtr, Drawable drawable) -{ - Graph* graphPtr = markerPtr->obj.graphPtr; - PolygonMarker *pmPtr = (PolygonMarker *)markerPtr; - PolygonMarkerOptions* ops = (PolygonMarkerOptions*)pmPtr->ops; - - /* Draw polygon fill region */ - if ((pmPtr->nFillPts > 0) && (ops->fill)) { - XPoint* points = (XPoint*)malloc(pmPtr->nFillPts * sizeof(XPoint)); - if (!points) - return; - - XPoint* dp = points; - Point2d *sp, *send; - for (sp = pmPtr->fillPts, send = sp + pmPtr->nFillPts; sp < send; - sp++) { - dp->x = (short int)sp->x; - dp->y = (short int)sp->y; - dp++; - } - - XFillPolygon(graphPtr->display, drawable, pmPtr->fillGC, points, - pmPtr->nFillPts, Complex, CoordModeOrigin); - free(points); - } - /* and then the outline */ - if ((pmPtr->nOutlinePts > 0) && (ops->lineWidth > 0) && - (ops->outline)) { - Blt_Draw2DSegments(graphPtr->display, drawable, pmPtr->outlineGC, - pmPtr->outlinePts, pmPtr->nOutlinePts); - } -} - static void PolygonToPostscriptProc(Marker* markerPtr, Blt_Ps ps) { Graph* graphPtr = markerPtr->obj.graphPtr; diff --git a/src/bltGrMarkerPolygon.h b/src/bltGrMarkerPolygon.h index 00df2f5..96ab2c5 100644 --- a/src/bltGrMarkerPolygon.h +++ b/src/bltGrMarkerPolygon.h @@ -69,7 +69,8 @@ class PolygonMarker : public Marker { int xorState; private: - int Configure(); + int configure(); + void draw(Drawable); public: PolygonMarker(Graph*, const char*); diff --git a/src/bltGrMarkerText.C b/src/bltGrMarkerText.C index 6e3015a..648566a 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 MarkerDrawProc DrawTextProc; static MarkerMapProc MapTextProc; static MarkerPointProc PointInTextProc; static MarkerPostscriptProc TextToPostscriptProc; @@ -93,7 +92,6 @@ static MarkerRegionProc RegionInTextProc; static MarkerClass textMarkerClass = { optionSpecs, - DrawTextProc, MapTextProc, PointInTextProc, RegionInTextProc, @@ -124,7 +122,7 @@ TextMarker::~TextMarker() Blt_Ts_FreeStyle(graphPtr->display, &((TextMarkerOptions*)ops)->style); } -int TextMarker::Configure() +int TextMarker::configure() { Graph* graphPtr = obj.graphPtr; TextMarkerOptions* opp = (TextMarkerOptions*)ops; @@ -148,6 +146,32 @@ int TextMarker::Configure() return TCL_OK; } +void TextMarker::draw(Drawable drawable) +{ + Graph* graphPtr = obj.graphPtr; + TextMarkerOptions* opp = (TextMarkerOptions*)ops; + + if (!opp->string) + return; + + if (fillGC) { + // Simulate the rotated background of the bitmap by filling a bounding + // polygon with the background color. + XPoint points[4]; + for (int ii=0; ii<4; ii++) { + points[ii].x = (short int)(outline[ii].x + anchorPt.x); + points[ii].y = (short int)(outline[ii].y + anchorPt.y); + } + XFillPolygon(graphPtr->display, drawable, fillGC, points, 4, + Convex, CoordModeOrigin); + } + + // be sure to update style->gc, things might have changed + opp->style.flags |= UPDATE_GC; + Blt_Ts_DrawText(graphPtr->tkwin, drawable, opp->string, -1, + &opp->style, anchorPt.x, anchorPt.y); +} + static void MapTextProc(Marker* markerPtr) { Graph* graphPtr = markerPtr->obj.graphPtr; @@ -247,33 +271,6 @@ static int RegionInTextProc(Marker* markerPtr, Region2d *extsPtr, int enclosed) ((tmPtr->anchorPt.y + tmPtr->height) <= extsPtr->top)); } -static void DrawTextProc(Marker* markerPtr, Drawable drawable) -{ - Graph* graphPtr = markerPtr->obj.graphPtr; - TextMarker* tmPtr = (TextMarker*)markerPtr; - TextMarkerOptions* ops = (TextMarkerOptions*)tmPtr->ops; - - if (!ops->string) - return; - - if (tmPtr->fillGC) { - // Simulate the rotated background of the bitmap by filling a bounding - // polygon with the background color. - XPoint points[4]; - for (int ii=0; ii<4; ii++) { - points[ii].x = (short int)(tmPtr->outline[ii].x + tmPtr->anchorPt.x); - points[ii].y = (short int)(tmPtr->outline[ii].y + tmPtr->anchorPt.y); - } - XFillPolygon(graphPtr->display, drawable, tmPtr->fillGC, points, 4, - Convex, CoordModeOrigin); - } - - // be sure to update style->gc, things might have changed - ops->style.flags |= UPDATE_GC; - Blt_Ts_DrawText(graphPtr->tkwin, drawable, ops->string, -1, - &ops->style, tmPtr->anchorPt.x, tmPtr->anchorPt.y); -} - static void TextToPostscriptProc(Marker* markerPtr, Blt_Ps ps) { TextMarker* tmPtr = (TextMarker*)markerPtr; diff --git a/src/bltGrMarkerText.h b/src/bltGrMarkerText.h index 1090258..9d8d1f3 100644 --- a/src/bltGrMarkerText.h +++ b/src/bltGrMarkerText.h @@ -60,7 +60,8 @@ class TextMarker : public Marker { Point2d outline[5]; private: - int Configure(); + int configure(); + void draw(Drawable); public: TextMarker(Graph*, const char*); |