diff options
author | joye <joye> | 2014-03-20 18:57:27 (GMT) |
---|---|---|
committer | joye <joye> | 2014-03-20 18:57:27 (GMT) |
commit | 246b47f0b90e9db7160cc7a266cdd81697bab949 (patch) | |
tree | 46905a58793fa1f90b428bbfd5ecf7005450cc00 /src/bltGrMarkerLine.C | |
parent | 728d5bf2094ca2919b3ee586912558cd78267298 (diff) | |
download | blt-246b47f0b90e9db7160cc7a266cdd81697bab949.zip blt-246b47f0b90e9db7160cc7a266cdd81697bab949.tar.gz blt-246b47f0b90e9db7160cc7a266cdd81697bab949.tar.bz2 |
*** empty log message ***
Diffstat (limited to 'src/bltGrMarkerLine.C')
-rw-r--r-- | src/bltGrMarkerLine.C | 130 |
1 files changed, 70 insertions, 60 deletions
diff --git a/src/bltGrMarkerLine.C b/src/bltGrMarkerLine.C index 8fbc552..916f585 100644 --- a/src/bltGrMarkerLine.C +++ b/src/bltGrMarkerLine.C @@ -33,51 +33,53 @@ extern "C" { #include "bltGrMarkerLine.h" -// Defs - // OptionSpecs static Tk_OptionSpec optionSpecs[] = { - {TK_OPTION_CUSTOM, "-bindtags", "bindTags", "BindTags", - "Line all", -1, Tk_Offset(LineMarker, obj.tags), - TK_OPTION_NULL_OK, &listObjOption, 0}, + // {TK_OPTION_CUSTOM, "-bindtags", "bindTags", "BindTags", + // "Line all", -1, Tk_Offset(LineMarkerOptions, obj.tags), + // TK_OPTION_NULL_OK, &listObjOption, 0}, {TK_OPTION_CUSTOM, "-cap", "cap", "Cap", - "butt", -1, Tk_Offset(LineMarker, capStyle), 0, &capStyleObjOption, 0}, + "butt", -1, Tk_Offset(LineMarkerOptions, capStyle), + 0, &capStyleObjOption, 0}, {TK_OPTION_CUSTOM, "-coords", "coords", "Coords", - NULL, -1, Tk_Offset(LineMarker, worldPts), + NULL, -1, Tk_Offset(LineMarkerOptions, worldPts), TK_OPTION_NULL_OK, &coordsObjOption, MAP_ITEM}, {TK_OPTION_CUSTOM, "-dashes", "dashes", "Dashes", - NULL, -1, Tk_Offset(LineMarker, dashes), + NULL, -1, Tk_Offset(LineMarkerOptions, dashes), TK_OPTION_NULL_OK, &dashesObjOption, 0}, {TK_OPTION_PIXELS, "-dashoffset", "dashOffset", "DashOffset", - "0", -1, Tk_Offset(LineMarker, dashes.offset), 0, NULL, 0}, + "0", -1, Tk_Offset(LineMarkerOptions, dashes.offset), 0, NULL, 0}, {TK_OPTION_STRING, "-element", "element", "Element", - NULL, -1, Tk_Offset(LineMarker, elemName), TK_OPTION_NULL_OK, NULL, 0}, + NULL, -1, Tk_Offset(LineMarkerOptions, elemName), + TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_COLOR, "-fill", "fill", "Fill", - NULL, -1, Tk_Offset(LineMarker, fillColor), TK_OPTION_NULL_OK, NULL, 0}, + NULL, -1, Tk_Offset(LineMarkerOptions, fillColor), + TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_CUSTOM, "-join", "join", "Join", - "miter", -1, Tk_Offset(LineMarker, joinStyle), 0, &joinStyleObjOption, 0}, + "miter", -1, Tk_Offset(LineMarkerOptions, joinStyle), + 0, &joinStyleObjOption, 0}, {TK_OPTION_PIXELS, "-linewidth", "lineWidth", "LineWidth", - "1", -1, Tk_Offset(LineMarker, lineWidth), 0, NULL, 0}, + "1", -1, Tk_Offset(LineMarkerOptions, lineWidth), 0, NULL, 0}, {TK_OPTION_BOOLEAN, "-hide", "hide", "Hide", - "no", -1, Tk_Offset(LineMarker, hide), 0, NULL, 0}, + "no", -1, Tk_Offset(LineMarkerOptions, hide), 0, NULL, 0}, {TK_OPTION_CUSTOM, "-mapx", "mapX", "MapX", - "x", -1, Tk_Offset(LineMarker, axes.x), 0, &xAxisObjOption, 0}, + "x", -1, Tk_Offset(LineMarkerOptions, axes.x), 0, &xAxisObjOption, 0}, {TK_OPTION_CUSTOM, "-mapy", "mapY", "MapY", - "y", -1, Tk_Offset(LineMarker, axes.y), 0, &yAxisObjOption, 0}, + "y", -1, Tk_Offset(LineMarkerOptions, axes.y), 0, &yAxisObjOption, 0}, {TK_OPTION_COLOR, "-outline", "outline", "Outline", - STD_NORMAL_FOREGROUND, -1, Tk_Offset(LineMarker, outlineColor), + STD_NORMAL_FOREGROUND, -1, Tk_Offset(LineMarkerOptions, outlineColor), TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_STRING_TABLE, "-state", "state", "State", - "normal", -1, Tk_Offset(LineMarker, state), 0, &stateObjOption, 0}, + "normal", -1, Tk_Offset(LineMarkerOptions, state), 0, &stateObjOption, 0}, {TK_OPTION_BOOLEAN, "-under", "under", "Under", - "no", -1, Tk_Offset(LineMarker, drawUnder), 0, NULL, 0}, + "no", -1, Tk_Offset(LineMarkerOptions, drawUnder), 0, NULL, 0}, {TK_OPTION_PIXELS, "-xoffset", "xOffset", "XOffset", - "0", -1, Tk_Offset(LineMarker, xOffset), 0, NULL, 0}, + "0", -1, Tk_Offset(LineMarkerOptions, xOffset), 0, NULL, 0}, {TK_OPTION_BOOLEAN, "-xor", "xor", "Xor", - "no", -1, Tk_Offset(LineMarker, xorr), 0, NULL, 0}, + "no", -1, Tk_Offset(LineMarkerOptions, xorr), 0, NULL, 0}, {TK_OPTION_PIXELS, "-yoffset", "yOffset", "YOffset", - "0", -1, Tk_Offset(LineMarker, yOffset), 0, NULL, 0}, + "0", -1, Tk_Offset(LineMarkerOptions, yOffset), 0, NULL, 0}, {TK_OPTION_END, NULL, NULL, NULL, NULL, -1, 0, 0, NULL, 0} }; @@ -105,7 +107,9 @@ Marker* Blt_CreateLineProc(Graph* graphPtr) { LineMarker* lmPtr = (LineMarker*)calloc(1, sizeof(LineMarker)); lmPtr->classPtr = &lineMarkerClass; - lmPtr->xorr = FALSE; + lmPtr->ops = (LineMarkerOptions*)calloc(1, sizeof(LineMarkerOptions)); + + lmPtr->ops->xorr = FALSE; lmPtr->optionTable = Tk_CreateOptionTable(graphPtr->interp, optionSpecs); return (Marker*)lmPtr; @@ -123,15 +127,15 @@ static int RegionInLineProc(Marker *markerPtr, Region2d *extsPtr, int enclosed) { LineMarker *lmPtr = (LineMarker*)markerPtr; - if (!lmPtr->worldPts || lmPtr->worldPts->num < 2) + if (!lmPtr->ops->worldPts || lmPtr->ops->worldPts->num < 2) return FALSE; if (enclosed) { Point2d *pp, *pend; - for (pp = lmPtr->worldPts->points, pend = pp + lmPtr->worldPts->num; + for (pp = lmPtr->ops->worldPts->points, pend = pp + lmPtr->ops->worldPts->num; pp < pend; pp++) { - Point2d p = Blt_MapPoint(pp, &markerPtr->axes); + Point2d p = Blt_MapPoint(pp, &markerPtr->ops->axes); if ((p.x < extsPtr->left) && (p.x > extsPtr->right) && (p.y < extsPtr->top) && (p.y > extsPtr->bottom)) { return FALSE; @@ -142,10 +146,10 @@ static int RegionInLineProc(Marker *markerPtr, Region2d *extsPtr, int enclosed) else { Point2d *pp, *pend; int count = 0; - for (pp = lmPtr->worldPts->points, pend = pp + (lmPtr->worldPts->num - 1); + for (pp = lmPtr->ops->worldPts->points, pend = pp + (lmPtr->ops->worldPts->num - 1); pp < pend; pp++) { - Point2d p = Blt_MapPoint(pp, &markerPtr->axes); - Point2d q = Blt_MapPoint(pp + 1, &markerPtr->axes); + Point2d p = Blt_MapPoint(pp, &markerPtr->ops->axes); + Point2d q = Blt_MapPoint(pp + 1, &markerPtr->ops->axes); if (Blt_LineRectClip(extsPtr, &p, &q)) count++; } @@ -163,7 +167,7 @@ static void DrawLineProc(Marker *markerPtr, Drawable drawable) Blt_Draw2DSegments(graphPtr->display, drawable, lmPtr->gc, lmPtr->segments, lmPtr->nSegments); - if (lmPtr->xorr) + if (lmPtr->ops->xorr) lmPtr->xorState = (lmPtr->xorState == 0); } } @@ -176,23 +180,23 @@ static int ConfigureLineProc(Marker *markerPtr) Drawable drawable = Tk_WindowId(graphPtr->tkwin); unsigned long gcMask = (GCLineWidth | GCLineStyle | GCCapStyle | GCJoinStyle); XGCValues gcValues; - if (lmPtr->outlineColor) { + if (lmPtr->ops->outlineColor) { gcMask |= GCForeground; - gcValues.foreground = lmPtr->outlineColor->pixel; + gcValues.foreground = lmPtr->ops->outlineColor->pixel; } - if (lmPtr->fillColor) { + if (lmPtr->ops->fillColor) { gcMask |= GCBackground; - gcValues.background = lmPtr->fillColor->pixel; + gcValues.background = lmPtr->ops->fillColor->pixel; } - gcValues.cap_style = lmPtr->capStyle; - gcValues.join_style = lmPtr->joinStyle; - gcValues.line_width = LineWidth(lmPtr->lineWidth); + gcValues.cap_style = lmPtr->ops->capStyle; + gcValues.join_style = lmPtr->ops->joinStyle; + gcValues.line_width = LineWidth(lmPtr->ops->lineWidth); gcValues.line_style = LineSolid; - if (LineIsDashed(lmPtr->dashes)) { + if (LineIsDashed(lmPtr->ops->dashes)) { gcValues.line_style = (gcMask & GCBackground) ? LineDoubleDash : LineOnOffDash; } - if (lmPtr->xorr) { + if (lmPtr->ops->xorr) { unsigned long pixel; gcValues.function = GXxor; @@ -210,11 +214,11 @@ static int ConfigureLineProc(Marker *markerPtr) if (lmPtr->gc) Blt_FreePrivateGC(graphPtr->display, lmPtr->gc); - if (LineIsDashed(lmPtr->dashes)) - Blt_SetDashes(graphPtr->display, newGC, &lmPtr->dashes); + if (LineIsDashed(lmPtr->ops->dashes)) + Blt_SetDashes(graphPtr->display, newGC, &lmPtr->ops->dashes); lmPtr->gc = newGC; - if (lmPtr->xorr) { + if (lmPtr->ops->xorr) { if (drawable != None) { MapLineProc(markerPtr); DrawLineProc(markerPtr, drawable); @@ -222,7 +226,7 @@ static int ConfigureLineProc(Marker *markerPtr) return TCL_OK; } markerPtr->flags |= MAP_ITEM; - if (markerPtr->drawUnder) + if (markerPtr->ops->drawUnder) graphPtr->flags |= CACHE_DIRTY; Blt_EventuallyRedrawGraph(graphPtr); @@ -234,21 +238,24 @@ static void LineToPostscriptProc(Marker *markerPtr, Blt_Ps ps) LineMarker *lmPtr = (LineMarker*)markerPtr; if (lmPtr->nSegments > 0) { - Blt_Ps_XSetLineAttributes(ps, lmPtr->outlineColor, - lmPtr->lineWidth, &lmPtr->dashes, lmPtr->capStyle, - lmPtr->joinStyle); - if ((LineIsDashed(lmPtr->dashes)) && (lmPtr->fillColor)) { + Blt_Ps_XSetLineAttributes(ps, lmPtr->ops->outlineColor, + lmPtr->ops->lineWidth, + &lmPtr->ops->dashes, + lmPtr->ops->capStyle, + lmPtr->ops->joinStyle); + if ((LineIsDashed(lmPtr->ops->dashes)) && (lmPtr->ops->fillColor)) { Blt_Ps_Append(ps, "/DashesProc {\n gsave\n "); - Blt_Ps_XSetBackground(ps, lmPtr->fillColor); + Blt_Ps_XSetBackground(ps, lmPtr->ops->fillColor); Blt_Ps_Append(ps, " "); Blt_Ps_XSetDashes(ps, (Blt_Dashes*)NULL); Blt_Ps_VarAppend(ps, "stroke\n", " grestore\n", "} def\n", (char*)NULL); - } else { + } + else Blt_Ps_Append(ps, "/DashesProc {} def\n"); - } + Blt_Ps_Draw2DSegments(ps, lmPtr->segments, lmPtr->nSegments); } } @@ -263,6 +270,9 @@ static void FreeLineProc(Marker *markerPtr) if (lmPtr->segments) free(lmPtr->segments); + + if (lmPtr->ops) + free(lmPtr->ops); } static void MapLineProc(Marker *markerPtr) @@ -274,7 +284,7 @@ static void MapLineProc(Marker *markerPtr) if (lmPtr->segments) free(lmPtr->segments); - if (!lmPtr->worldPts || (lmPtr->worldPts->num < 2)) + if (!lmPtr->ops->worldPts || (lmPtr->ops->worldPts->num < 2)) return; Region2d extents; @@ -287,19 +297,19 @@ static void MapLineProc(Marker *markerPtr) * disconnected segments. */ Segment2d* segments = - (Segment2d*)malloc(lmPtr->worldPts->num * sizeof(Segment2d)); - Point2d* srcPtr = lmPtr->worldPts->points; - Point2d p = Blt_MapPoint(srcPtr, &markerPtr->axes); - p.x += markerPtr->xOffset; - p.y += markerPtr->yOffset; + (Segment2d*)malloc(lmPtr->ops->worldPts->num * sizeof(Segment2d)); + Point2d* srcPtr = lmPtr->ops->worldPts->points; + Point2d p = Blt_MapPoint(srcPtr, &markerPtr->ops->axes); + p.x += markerPtr->ops->xOffset; + p.y += markerPtr->ops->yOffset; Segment2d* segPtr = segments; Point2d* pend; - for (srcPtr++, pend = lmPtr->worldPts->points + lmPtr->worldPts->num; + for (srcPtr++, pend = lmPtr->ops->worldPts->points + lmPtr->ops->worldPts->num; srcPtr < pend; srcPtr++) { - Point2d next = Blt_MapPoint(srcPtr, &markerPtr->axes); - next.x += lmPtr->xOffset; - next.y += lmPtr->yOffset; + Point2d next = Blt_MapPoint(srcPtr, &markerPtr->ops->axes); + next.x += lmPtr->ops->xOffset; + next.y += lmPtr->ops->yOffset; Point2d q = next; if (Blt_LineRectClip(&extents, &p, &q)) { |