diff options
author | joye <joye> | 2014-02-27 23:18:16 (GMT) |
---|---|---|
committer | joye <joye> | 2014-02-27 23:18:16 (GMT) |
commit | 707d16345a1237c5efb987ff09da71bab100019e (patch) | |
tree | 54d10aa5201530a078fa0630f4709b05fd91b898 /src | |
parent | 0f1c642f49450db9f19e9eb52d256c680ab795c6 (diff) | |
download | blt-707d16345a1237c5efb987ff09da71bab100019e.zip blt-707d16345a1237c5efb987ff09da71bab100019e.tar.gz blt-707d16345a1237c5efb987ff09da71bab100019e.tar.bz2 |
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r-- | src/bltGrElemBar.C | 276 | ||||
-rw-r--r-- | src/bltGrElemLine.C | 204 | ||||
-rw-r--r-- | src/bltGrElemOp.C | 30 |
3 files changed, 225 insertions, 285 deletions
diff --git a/src/bltGrElemBar.C b/src/bltGrElemBar.C index f5547b5..1798c94 100644 --- a/src/bltGrElemBar.C +++ b/src/bltGrElemBar.C @@ -241,9 +241,9 @@ static Tk_OptionSpec barElemOptionSpecs[] = { TK_OPTION_NULL_OK, &barPenObjOption, 0}, {TK_OPTION_BORDER, "-background", "background", "Background", STD_NORMAL_FOREGROUND, -1, Tk_Offset(BarElement, builtinPen.fill), - 0, NULL, 0}, + TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_DOUBLE, "-barwidth", "barWidth", "BarWidth", - 0, -1, Tk_Offset(BarElement, barWidth), 0, NULL, 0}, + 0, -1, Tk_Offset(BarElement, barWidth), 0, NULL, MAP_ITEM}, {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_CUSTOM, "-bindtags", "bindTags", "BindTags", @@ -254,7 +254,7 @@ static Tk_OptionSpec barElemOptionSpecs[] = { 0, NULL, 0}, {TK_OPTION_SYNONYM, "-color", NULL, NULL, NULL, -1, 0, 0, "-background", 0}, {TK_OPTION_CUSTOM, "-data", "data", "Data", - NULL, -1, 0, 0, &pairsObjOption, 0}, + NULL, -1, 0, 0, &pairsObjOption, MAP_ITEM}, {TK_OPTION_COLOR, "-errorbarcolor", "errorBarColor", "ErrorBarColor", NULL, -1, Tk_Offset(BarElement, builtinPen.errorBarColor), TK_OPTION_NULL_OK, NULL, 0}, @@ -266,17 +266,17 @@ static Tk_OptionSpec barElemOptionSpecs[] = { {TK_OPTION_SYNONYM, "-fill", NULL, NULL, NULL, -1, 0, 0, "-background", 0}, {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", STD_NORMAL_FOREGROUND, -1, Tk_Offset(BarElement, builtinPen.outlineColor), - 0, NULL, 0}, + TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_BOOLEAN, "-hide", "hide", "Hide", - "no", -1, Tk_Offset(BarElement, hide), 0, NULL, 0}, + "no", -1, Tk_Offset(BarElement, hide), 0, NULL, MAP_ITEM}, {TK_OPTION_STRING, "-label", "label", "Label", - NULL, -1, Tk_Offset(BarElement, label), TK_OPTION_NULL_OK, NULL, 0}, + NULL, -1, Tk_Offset(BarElement, label), TK_OPTION_NULL_OK, NULL, MAP_ITEM}, {TK_OPTION_RELIEF, "-legendrelief", "legendRelief", "LegendRelief", "flat", -1, Tk_Offset(BarElement, legendRelief), 0, NULL, 0}, {TK_OPTION_CUSTOM, "-mapx", "mapX", "MapX", - "x", -1, Tk_Offset(BarElement, axes.x), 0, &xAxisObjOption, 0}, + "x", -1, Tk_Offset(BarElement, axes.x), 0, &xAxisObjOption, MAP_ITEM}, {TK_OPTION_CUSTOM, "-mapy", "mapY", "MapY", - "y", -1, Tk_Offset(BarElement, axes.y), 0, &yAxisObjOption, 0}, + "y", -1, Tk_Offset(BarElement, axes.y), 0, &yAxisObjOption, MAP_ITEM}, {TK_OPTION_SYNONYM, "-outline", NULL, NULL, NULL, -1, 0, 0, "-foreground", 0}, {TK_OPTION_CUSTOM, "-pen", "pen", "Pen", NULL, -1, Tk_Offset(BarElement, normalPenPtr), @@ -312,21 +312,21 @@ static Tk_OptionSpec barElemOptionSpecs[] = { {TK_OPTION_CUSTOM, "-weights", "weights", "Weights", NULL, -1, Tk_Offset(BarElement, w), 0, &valuesObjOption, 0}, {TK_OPTION_CUSTOM, "-x", "x", "X", - NULL, -1, Tk_Offset(BarElement, x), 0, &valuesObjOption, 0}, + NULL, -1, Tk_Offset(BarElement, x), 0, &valuesObjOption, MAP_ITEM}, {TK_OPTION_CUSTOM, "-xdata", "xData", "XData", - NULL, -1, Tk_Offset(BarElement, x), 0, &valuesObjOption, 0}, + NULL, -1, Tk_Offset(BarElement, x), 0, &valuesObjOption, MAP_ITEM}, {TK_OPTION_CUSTOM, "-xerror", "xError", "XError", - NULL, -1, Tk_Offset(BarElement, xError), 0, &valuesObjOption, 0}, + NULL, -1, Tk_Offset(BarElement, xError), 0, &valuesObjOption, MAP_ITEM}, {TK_OPTION_CUSTOM, "-xhigh", "xHigh", "XHigh", NULL, -1, Tk_Offset(BarElement, xHigh), 0, &valuesObjOption, 0}, {TK_OPTION_CUSTOM, "-xlow", "xLow", "XLow", NULL, -1, Tk_Offset(BarElement, xLow), 0, &valuesObjOption, 0}, {TK_OPTION_CUSTOM, "-y", "y", "Y", - NULL, -1, Tk_Offset(BarElement, y), 0, &valuesObjOption, 0}, + NULL, -1, Tk_Offset(BarElement, y), 0, &valuesObjOption, MAP_ITEM}, {TK_OPTION_CUSTOM, "-ydata", "yData", "YData", - NULL, -1, Tk_Offset(BarElement, y), 0, &valuesObjOption, 0}, + NULL, -1, Tk_Offset(BarElement, y), 0, &valuesObjOption, MAP_ITEM}, {TK_OPTION_CUSTOM, "-yerror", "yError", "YError", - NULL, -1, Tk_Offset(BarElement, yError), 0, &valuesObjOption, 0}, + NULL, -1, Tk_Offset(BarElement, yError), 0, &valuesObjOption, MAP_ITEM}, {TK_OPTION_CUSTOM, "-yhigh", "yHigh", "YHigh", NULL, -1, Tk_Offset(BarElement, yHigh), 0, &valuesObjOption, 0}, {TK_OPTION_CUSTOM, "-ylow", "yLow", "YLow", @@ -336,7 +336,8 @@ static Tk_OptionSpec barElemOptionSpecs[] = { static Tk_OptionSpec barPenOptionSpecs[] = { {TK_OPTION_BORDER, "-background", "background", "Background", - STD_NORMAL_FOREGROUND, -1, Tk_Offset(BarPen, fill), 0, NULL, 0}, + STD_NORMAL_FOREGROUND, -1, Tk_Offset(BarPen, fill), + TK_OPTION_NULL_OK, 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_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", @@ -350,7 +351,8 @@ static Tk_OptionSpec barPenOptionSpecs[] = { {TK_OPTION_SYNONYM, "-fg", NULL, NULL, NULL, -1, 0, 0, "-foreground", 0}, {TK_OPTION_SYNONYM, "-fill", NULL, NULL, NULL, -1, 0, 0, "-background", 0}, {TK_OPTION_COLOR, "-foreground", "foreground", "Foreground", - STD_NORMAL_FOREGROUND, -1, Tk_Offset(BarPen, outlineColor), 0, NULL, 0}, + STD_NORMAL_FOREGROUND, -1, Tk_Offset(BarPen, outlineColor), + TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_SYNONYM, "-outline", NULL, NULL, NULL, -1, 0, 0, "-foreground", 0}, {TK_OPTION_RELIEF, "-relief", "relief", "Relief", "raised", -1, Tk_Offset(BarPen, relief), 0, NULL, 0}, @@ -430,17 +432,17 @@ static void DestroyBarProc(Graph* graphPtr, Element* basePtr) BarElement* elemPtr = (BarElement*)basePtr; DestroyPenProc(graphPtr, (Pen*)&elemPtr->builtinPen); - if (elemPtr->activePenPtr != NULL) + if (elemPtr->activePenPtr) Blt_FreePen((Pen *)elemPtr->activePenPtr); - if (elemPtr->normalPenPtr != NULL) + if (elemPtr->normalPenPtr) Blt_FreePen((Pen *)elemPtr->normalPenPtr); ResetBar(elemPtr); - if (elemPtr->stylePalette != NULL) { + if (elemPtr->stylePalette) { Blt_FreeStylePalette(elemPtr->stylePalette); Blt_Chain_Destroy(elemPtr->stylePalette); } - if (elemPtr->activeIndices != NULL) { + if (elemPtr->activeIndices) { free(elemPtr->activeIndices); } @@ -452,15 +454,14 @@ static void DestroyPenProc(Graph* graphPtr, Pen* basePtr) BarPen* penPtr = (BarPen*)basePtr; Blt_Ts_FreeStyle(graphPtr->display, &penPtr->valueStyle); - if (penPtr->outlineGC != NULL) { + if (penPtr->outlineGC) Tk_FreeGC(graphPtr->display, penPtr->outlineGC); - } - if (penPtr->fillGC != NULL) { + + if (penPtr->fillGC) Tk_FreeGC(graphPtr->display, penPtr->fillGC); - } - if (penPtr->errorBarGC != NULL) { + + if (penPtr->errorBarGC) Tk_FreeGC(graphPtr->display, penPtr->errorBarGC); - } Tk_FreeConfigOptions((char*)penPtr, penPtr->optionTable, graphPtr->tkwin); } @@ -476,74 +477,61 @@ static int ConfigureBarProc(Graph *graphPtr, Element *basePtr) if (ConfigurePenProc(graphPtr, (Pen*)&elemPtr->builtinPen)!= TCL_OK) { return TCL_ERROR; } - /* - * Point to the static normal pen if no external pens have been selected. - */ + + // Point to the static normal pen if no external pens have been selected. link = Blt_Chain_FirstLink(elemPtr->stylePalette); - if (link == NULL) { + if (!link) { link = Blt_Chain_AllocLink(sizeof(BarStyle)); Blt_Chain_LinkAfter(elemPtr->stylePalette, link, NULL); } stylePtr = Blt_Chain_GetValue(link); stylePtr->penPtr = NORMALPEN(elemPtr); - /* - if (Blt_ConfigModified(elemPtr->configSpecs, "-barwidth", "-*data", - "-map*", "-label", "-hide", "-x", "-y", (char *)NULL)) { - elemPtr->flags |= MAP_ITEM; - } - */ return TCL_OK; } static int ConfigurePenProc(Graph *graphPtr, Pen *basePtr) { BarPen* penPtr = (BarPen*)basePtr; + int screenNum = Tk_ScreenNumber(graphPtr->tkwin); XGCValues gcValues; unsigned long gcMask; GC newGC; - long defColor; - int screenNum; - screenNum = Tk_ScreenNumber(graphPtr->tkwin); + // outlineGC gcMask = GCForeground | GCLineWidth; gcValues.line_width = LineWidth(penPtr->errorBarLineWidth); - if (penPtr->outlineColor != NULL) { - defColor = penPtr->outlineColor->pixel; + if (penPtr->outlineColor) gcValues.foreground = penPtr->outlineColor->pixel; - } else if (penPtr->fill != NULL) { - defColor = Tk_3DBorderColor(penPtr->fill)->pixel; - gcValues.foreground = defColor; - } else { - defColor = BlackPixel(graphPtr->display, screenNum); - } + else if (penPtr->fill) + gcValues.foreground = Tk_3DBorderColor(penPtr->fill)->pixel; + newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues); - if (penPtr->outlineGC != NULL) { + if (penPtr->outlineGC) Tk_FreeGC(graphPtr->display, penPtr->outlineGC); - } penPtr->outlineGC = newGC; newGC = NULL; if (penPtr->stipple != None) { - /* Handle old-style -stipple specially. */ + // Handle old-style -stipple specially gcMask = GCForeground | GCBackground | GCFillStyle | GCStipple; gcValues.foreground = BlackPixel(graphPtr->display, screenNum); gcValues.background = WhitePixel(graphPtr->display, screenNum); - if (penPtr->fill != NULL) { + if (penPtr->fill) gcValues.foreground = Tk_3DBorderColor(penPtr->fill)->pixel; - } else if (penPtr->outlineColor != NULL) { + else if (penPtr->outlineColor) gcValues.foreground = penPtr->outlineColor->pixel; - } + gcValues.stipple = penPtr->stipple; gcValues.fill_style = FillStippled; newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues); } - if (penPtr->fillGC != NULL) { + if (penPtr->fillGC) Tk_FreeGC(graphPtr->display, penPtr->fillGC); - } penPtr->fillGC = newGC; + // errorBarGC gcMask = GCForeground | GCLineWidth; XColor *colorPtr = penPtr->errorBarColor; if (!colorPtr) @@ -551,10 +539,10 @@ static int ConfigurePenProc(Graph *graphPtr, Pen *basePtr) gcValues.foreground = colorPtr->pixel; gcValues.line_width = LineWidth(penPtr->errorBarLineWidth); newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues); - if (penPtr->errorBarGC != NULL) { + if (penPtr->errorBarGC) Tk_FreeGC(graphPtr->display, penPtr->errorBarGC); - } penPtr->errorBarGC = newGC; + return TCL_OK; } @@ -564,7 +552,7 @@ static void ResetStylePalette(Blt_Chain stylePalette) { Blt_ChainLink link; - for (link = Blt_Chain_FirstLink(stylePalette); link != NULL; + for (link = Blt_Chain_FirstLink(stylePalette); link; link = Blt_Chain_NextLink(link)) { BarStyle *stylePtr; @@ -834,7 +822,7 @@ static void MergePens(BarElement *elemPtr, BarStyle **dataToStyle) bars = malloc(elemPtr->nBars * sizeof(XRectangle)); barToData = malloc(elemPtr->nBars * sizeof(int)); bp = bars, ip = barToData; - for (link = Blt_Chain_FirstLink(elemPtr->stylePalette); link != NULL; + for (link = Blt_Chain_FirstLink(elemPtr->stylePalette); link; link = Blt_Chain_NextLink(link)) { BarStyle *stylePtr; int i; @@ -868,7 +856,7 @@ static void MergePens(BarElement *elemPtr, BarStyle **dataToStyle) map = malloc(elemPtr->xeb.length * sizeof(int)); sp = bars, ip = map; for (link = Blt_Chain_FirstLink(elemPtr->stylePalette); - link != NULL; link = Blt_Chain_NextLink(link)) { + link; link = Blt_Chain_NextLink(link)) { BarStyle *stylePtr; int i; @@ -898,7 +886,7 @@ static void MergePens(BarElement *elemPtr, BarStyle **dataToStyle) bars = malloc(elemPtr->yeb.length * sizeof(Segment2d)); map = malloc(elemPtr->yeb.length * sizeof(int)); sp = bars, ip = map; - for (link = Blt_Chain_FirstLink(elemPtr->stylePalette); link != NULL; + for (link = Blt_Chain_FirstLink(elemPtr->stylePalette); link; link = Blt_Chain_NextLink(link)) { BarStyle *stylePtr; int i; @@ -925,11 +913,11 @@ static void MergePens(BarElement *elemPtr, BarStyle **dataToStyle) static void MapActiveBars(BarElement *elemPtr) { - if (elemPtr->activeRects != NULL) { + if (elemPtr->activeRects) { free(elemPtr->activeRects); elemPtr->activeRects = NULL; } - if (elemPtr->activeToData != NULL) { + if (elemPtr->activeToData) { free(elemPtr->activeToData); elemPtr->activeToData = NULL; } @@ -969,28 +957,28 @@ static void ResetBar(BarElement *elemPtr) { /* Release any storage associated with the display of the bar */ ResetStylePalette(elemPtr->stylePalette); - if (elemPtr->activeRects != NULL) { + if (elemPtr->activeRects) { free(elemPtr->activeRects); } - if (elemPtr->activeToData != NULL) { + if (elemPtr->activeToData) { free(elemPtr->activeToData); } - if (elemPtr->xeb.segments != NULL) { + if (elemPtr->xeb.segments) { free(elemPtr->xeb.segments); } - if (elemPtr->xeb.map != NULL) { + if (elemPtr->xeb.map) { free(elemPtr->xeb.map); } - if (elemPtr->yeb.segments != NULL) { + if (elemPtr->yeb.segments) { free(elemPtr->yeb.segments); } - if (elemPtr->yeb.map != NULL) { + if (elemPtr->yeb.map) { free(elemPtr->yeb.map); } - if (elemPtr->bars != NULL) { + if (elemPtr->bars) { free(elemPtr->bars); } - if (elemPtr->barToData != NULL) { + if (elemPtr->barToData) { free(elemPtr->barToData); } elemPtr->activeToData = elemPtr->xeb.map = elemPtr->yeb.map = @@ -1204,15 +1192,15 @@ static void MapBarProc(Graph *graphPtr, Element *basePtr) key.axes = elemPtr->axes; key.axes.y = NULL; hPtr = Tcl_FindHashEntry(&graphPtr->setTable, (char *)&key); - if (hPtr != NULL) { + if (hPtr) { Tcl_HashTable *tablePtr; const char *name; tablePtr = Tcl_GetHashValue(hPtr); - name = (elemPtr->groupName != NULL) ? elemPtr->groupName : + name = (elemPtr->groupName) ? elemPtr->groupName : elemPtr->axes.y->obj.name; hPtr = Tcl_FindHashEntry(tablePtr, name); - if (hPtr != NULL) { + if (hPtr) { BarGroup *groupPtr; double slice, width, offset; @@ -1350,7 +1338,7 @@ static void MapBarProc(Graph *graphPtr, Element *basePtr) Blt_ChainLink link; /* Set the symbol size of all the pen styles. */ - for (link = Blt_Chain_FirstLink(elemPtr->stylePalette); link != NULL; + for (link = Blt_Chain_FirstLink(elemPtr->stylePalette); link; link = Blt_Chain_NextLink(link)) { BarStyle *stylePtr; @@ -1380,29 +1368,28 @@ static void DrawSymbolProc(Graph *graphPtr, Drawable drawable, int radius; penPtr = NORMALPEN(elemPtr); - if ((penPtr->fill == NULL) && (penPtr->outlineColor == NULL)) { + if (!penPtr->fill && !penPtr->outlineColor) return; - } + radius = (size / 2); size--; x -= radius; y -= radius; - if (penPtr->fillGC != NULL) { + if (penPtr->fillGC) XSetTSOrigin(graphPtr->display, penPtr->fillGC, x, y); - } - if (penPtr->stipple != None) { + + if (penPtr->stipple != None) XFillRectangle(graphPtr->display, drawable, penPtr->fillGC, x, y, size, size); - } else { + else Tk_Fill3DRectangle(graphPtr->tkwin, drawable, penPtr->fill, x, y, size, size, penPtr->borderWidth, penPtr->relief); - } + XDrawRectangle(graphPtr->display, drawable, penPtr->outlineGC, x, y, size, size); - if (penPtr->fillGC != NULL) { + if (penPtr->fillGC) XSetTSOrigin(graphPtr->display, penPtr->fillGC, 0, 0); - } } static void SetBackgroundClipRegion(Tk_Window tkwin, Tk_3DBorder border, @@ -1448,49 +1435,51 @@ static void DrawBarSegments(Graph *graphPtr, Drawable drawable, BarPen *penPtr, rgn = TkCreateRegion(); TkUnionRectWithRegion(&clip, rgn, rgn); } - if (penPtr->fill != NULL) { - XRectangle *rp, *rend; - int hasOutline; - int relief; - relief = (penPtr->relief == TK_RELIEF_SOLID) - ? TK_RELIEF_FLAT: penPtr->relief; - hasOutline = ((relief == TK_RELIEF_FLAT) && - (penPtr->outlineColor != NULL)); - if (penPtr->stipple != None) { + if (penPtr->fill) { + int relief = (penPtr->relief == TK_RELIEF_SOLID) ? + TK_RELIEF_FLAT: penPtr->relief; + + int hasOutline = ((relief == TK_RELIEF_FLAT) && penPtr->outlineColor); + if (penPtr->stipple != None) TkSetRegion(graphPtr->display, penPtr->fillGC, rgn); - } + SetBackgroundClipRegion(graphPtr->tkwin, penPtr->fill, rgn); - if (hasOutline) { + + if (hasOutline) TkSetRegion(graphPtr->display, penPtr->outlineGC, rgn); - } + + XRectangle *rp, *rend; for (rp = bars, rend = rp + nBars; rp < rend; rp++) { - if (penPtr->stipple != None) { + if (penPtr->stipple != None) XFillRectangle(graphPtr->display, drawable, penPtr->fillGC, rp->x, rp->y, rp->width, rp->height); - } else { + else Tk_Fill3DRectangle(graphPtr->tkwin, drawable, penPtr->fill, rp->x, rp->y, rp->width, rp->height, penPtr->borderWidth, relief); - } - if (hasOutline) { + + if (hasOutline) XDrawRectangle(graphPtr->display, drawable, penPtr->outlineGC, rp->x, rp->y, rp->width, rp->height); - } } + UnsetBackgroundClipRegion(graphPtr->tkwin, penPtr->fill); - if (hasOutline) { + + if (hasOutline) XSetClipMask(graphPtr->display, penPtr->outlineGC, None); - } - if (penPtr->stipple != None) { + + if (penPtr->stipple != None) XSetClipMask(graphPtr->display, penPtr->fillGC, None); - } - } else if (penPtr->outlineColor != NULL) { + + } + else if (penPtr->outlineColor) { TkSetRegion(graphPtr->display, penPtr->outlineGC, rgn); XDrawRectangles(graphPtr->display, drawable, penPtr->outlineGC, bars, nBars); XSetClipMask(graphPtr->display, penPtr->outlineGC, None); } + TkDestroyRegion(rgn); } @@ -1504,7 +1493,7 @@ static void DrawBarValues(Graph *graphPtr, Drawable drawable, const char *fmt; fmt = penPtr->valueFormat; - if (fmt == NULL) { + if (!fmt) { fmt = "%g"; } count = 0; @@ -1552,7 +1541,7 @@ static void DrawNormalBarProc(Graph *graphPtr, Drawable drawable, Blt_ChainLink link; count = 0; - for (link = Blt_Chain_FirstLink(elemPtr->stylePalette); link != NULL; + for (link = Blt_Chain_FirstLink(elemPtr->stylePalette); link; link = Blt_Chain_NextLink(link)) { BarStyle *stylePtr; BarPen *penPtr; @@ -1585,7 +1574,7 @@ static void DrawActiveBarProc(Graph *graphPtr, Drawable drawable, { BarElement *elemPtr = (BarElement *)basePtr; - if (elemPtr->activePenPtr != NULL) { + if (elemPtr->activePenPtr) { BarPen *penPtr = elemPtr->activePenPtr; if (elemPtr->nActiveIndices > 0) { @@ -1617,9 +1606,9 @@ static void SymbolToPostScriptProc(Graph *graphPtr, Blt_Ps ps, Element *basePtr, BarPen *penPtr; penPtr = NORMALPEN(elemPtr); - if ((penPtr->fill == NULL) && (penPtr->outlineColor == NULL)) { + if (!penPtr->fill && !penPtr->outlineColor) return; - } + /* * Build a PostScript procedure to draw the fill and outline of the symbol * after the path of the symbol shape has been formed @@ -1628,17 +1617,17 @@ static void SymbolToPostScriptProc(Graph *graphPtr, Blt_Ps ps, Element *basePtr, "/DrawSymbolProc {\n" "gsave\n "); if (penPtr->stipple != None) { - if (penPtr->fill != NULL) { + if (penPtr->fill) { Blt_Ps_XSetBackground(ps, Tk_3DBorderColor(penPtr->fill)); Blt_Ps_Append(ps, " gsave fill grestore\n "); } - if (penPtr->outlineColor != NULL) { + if (penPtr->outlineColor) { Blt_Ps_XSetForeground(ps, penPtr->outlineColor); } else { Blt_Ps_XSetForeground(ps, Tk_3DBorderColor(penPtr->fill)); } Blt_Ps_XSetStipple(ps, graphPtr->display, penPtr->stipple); - } else if (penPtr->outlineColor != NULL) { + } else if (penPtr->outlineColor) { Blt_Ps_XSetForeground(ps, penPtr->outlineColor); Blt_Ps_Append(ps, " fill\n"); } @@ -1652,31 +1641,31 @@ static void SegmentsToPostScript(Graph *graphPtr, Blt_Ps ps, BarPen *penPtr, { XRectangle *rp, *rend; - if ((penPtr->fill == NULL) && (penPtr->outlineColor == NULL)) { + if (!penPtr->fill && !penPtr->outlineColor) return; - } + for (rp = bars, rend = rp + nBars; rp < rend; rp++) { if ((rp->width < 1) || (rp->height < 1)) { continue; } if (penPtr->stipple != None) { Blt_Ps_Rectangle(ps, rp->x, rp->y, rp->width - 1, rp->height - 1); - if (penPtr->fill != NULL) { + if (penPtr->fill) { Blt_Ps_XSetBackground(ps, Tk_3DBorderColor(penPtr->fill)); Blt_Ps_Append(ps, "gsave fill grestore\n"); } - if (penPtr->outlineColor != NULL) { + if (penPtr->outlineColor) { Blt_Ps_XSetForeground(ps, penPtr->outlineColor); } else { Blt_Ps_XSetForeground(ps, Tk_3DBorderColor(penPtr->fill)); } Blt_Ps_XSetStipple(ps, graphPtr->display, penPtr->stipple); - } else if (penPtr->outlineColor != NULL) { + } else if (penPtr->outlineColor) { Blt_Ps_XSetForeground(ps, penPtr->outlineColor); Blt_Ps_XFillRectangle(ps, (double)rp->x, (double)rp->y, (int)rp->width - 1, (int)rp->height - 1); } - if ((penPtr->fill != NULL) && (penPtr->borderWidth > 0) && + if ((penPtr->fill) && (penPtr->borderWidth > 0) && (penPtr->relief != TK_RELIEF_FLAT)) { Blt_Ps_Draw3DRectangle(ps, penPtr->fill, (double)rp->x, (double)rp->y, (int)rp->width, (int)rp->height, @@ -1699,9 +1688,9 @@ static void BarValuesToPostScript(Graph *graphPtr, Blt_Ps ps, count = 0; fmt = penPtr->valueFormat; - if (fmt == NULL) { + if (!fmt) fmt = "%g"; - } + for (rp = bars, rend = rp + nBars; rp < rend; rp++) { x = elemPtr->x.values[barToData[count]]; y = elemPtr->y.values[barToData[count]]; @@ -1738,7 +1727,7 @@ static void ActiveBarToPostScriptProc(Graph *graphPtr, Blt_Ps ps, { BarElement *elemPtr = (BarElement *)basePtr; - if (elemPtr->activePenPtr != NULL) { + if (elemPtr->activePenPtr) { BarPen *penPtr = elemPtr->activePenPtr; if (elemPtr->nActiveIndices > 0) { @@ -1770,7 +1759,7 @@ static void NormalBarToPostScriptProc(Graph *graphPtr, Blt_Ps ps, int count; count = 0; - for (link = Blt_Chain_FirstLink(elemPtr->stylePalette); link != NULL; + for (link = Blt_Chain_FirstLink(elemPtr->stylePalette); link; link = Blt_Chain_NextLink(link)) { BarStyle *stylePtr; BarPen *penPtr; @@ -1835,7 +1824,7 @@ void Blt_InitBarSetTable(Graph *graphPtr) Tcl_InitHashTable(&setTable, sizeof(BarSetKey) / sizeof(int)); nSegs = nStacks = 0; for (link = Blt_Chain_FirstLink(graphPtr->elements.displayList); - link != NULL; link = Blt_Chain_NextLink(link)) { + link; link = Blt_Chain_NextLink(link)) { BarElement *elemPtr; double *x, *xend; int nPoints; @@ -1865,7 +1854,7 @@ void Blt_InitBarSetTable(Graph *graphPtr) } else { tablePtr = Tcl_GetHashValue(hPtr); } - name = (elemPtr->groupName != NULL) ? elemPtr->groupName : + name = (elemPtr->groupName) ? elemPtr->groupName : elemPtr->axes.y->obj.name; hPtr = Tcl_CreateHashEntry(tablePtr, name, &isNew); if (isNew) { @@ -1881,7 +1870,7 @@ void Blt_InitBarSetTable(Graph *graphPtr) return; /* No bar elements to be displayed */ } sum = max = 0; - for (hPtr = Tcl_FirstHashEntry(&setTable, &iter); hPtr != NULL; + for (hPtr = Tcl_FirstHashEntry(&setTable, &iter); hPtr; hPtr = Tcl_NextHashEntry(&iter)) { Tcl_HashTable *tablePtr; Tcl_HashEntry *hPtr2; @@ -1906,7 +1895,7 @@ void Blt_InitBarSetTable(Graph *graphPtr) graphPtr->barGroups = calloc(sum, sizeof(BarGroup)); groupPtr = graphPtr->barGroups; for (hPtr = Tcl_FirstHashEntry(&graphPtr->setTable, &iter); - hPtr != NULL; hPtr = Tcl_NextHashEntry(&iter)) { + hPtr; hPtr = Tcl_NextHashEntry(&iter)) { BarSetKey *keyPtr; Tcl_HashTable *tablePtr; Tcl_HashEntry *hPtr2; @@ -1954,7 +1943,7 @@ void Blt_ComputeBarStacks(Graph *graphPtr) * abscissas. */ for (link = Blt_Chain_FirstLink(graphPtr->elements.displayList); - link != NULL; link = Blt_Chain_NextLink(link)) { + link; link = Blt_Chain_NextLink(link)) { BarElement *elemPtr; double *x, *y, *xend; @@ -1974,16 +1963,16 @@ void Blt_ComputeBarStacks(Graph *graphPtr) key.axes = elemPtr->axes; key.axes.y = NULL; hPtr = Tcl_FindHashEntry(&graphPtr->setTable, (char *)&key); - if (hPtr == NULL) { + if (!hPtr) continue; - } + tablePtr = Tcl_GetHashValue(hPtr); - name = (elemPtr->groupName != NULL) ? elemPtr->groupName : + name = (elemPtr->groupName) ? elemPtr->groupName : elemPtr->axes.y->obj.name; hPtr = Tcl_FindHashEntry(tablePtr, name); - if (hPtr == NULL) { + if (!hPtr) continue; - } + groupPtr = Tcl_GetHashValue(hPtr); groupPtr->sum += *y; } @@ -1992,8 +1981,8 @@ void Blt_ComputeBarStacks(Graph *graphPtr) void Blt_ResetBarGroups(Graph *graphPtr) { - BarGroup *gp, *gend; - + BarGroup* gp; + BarGroup* gend; for (gp = graphPtr->barGroups, gend = gp + graphPtr->nBarGroups; gp < gend; gp++) { gp->lastY = 0.0; @@ -2003,19 +1992,16 @@ void Blt_ResetBarGroups(Graph *graphPtr) void Blt_DestroyBarSets(Graph *graphPtr) { - Tcl_HashSearch iter; - Tcl_HashEntry *hPtr; - - if (graphPtr->barGroups != NULL) { + if (graphPtr->barGroups) { free(graphPtr->barGroups); graphPtr->barGroups = NULL; } + graphPtr->nBarGroups = 0; - for (hPtr = Tcl_FirstHashEntry(&graphPtr->setTable, &iter); - hPtr != NULL; hPtr = Tcl_NextHashEntry(&iter)) { - Tcl_HashTable *tablePtr; - - tablePtr = Tcl_GetHashValue(hPtr); + Tcl_HashSearch iter; + for (Tcl_HashEntry *hPtr = Tcl_FirstHashEntry(&graphPtr->setTable, &iter); + hPtr; hPtr = Tcl_NextHashEntry(&iter)) { + Tcl_HashTable* tablePtr = Tcl_GetHashValue(hPtr); Tcl_DeleteHashTable(tablePtr); free(tablePtr); } diff --git a/src/bltGrElemLine.C b/src/bltGrElemLine.C index 72c98d5..191ab1e 100644 --- a/src/bltGrElemLine.C +++ b/src/bltGrElemLine.C @@ -406,7 +406,7 @@ static int SymbolSetProc(ClientData clientData, Tcl_Interp *interp, } char c = string[0]; - for (GraphSymbolType* p = graphSymbols; p->name != NULL; p++) { + for (GraphSymbolType* p = graphSymbols; p->name; p++) { if (length < p->minChars) { continue; } @@ -424,7 +424,7 @@ static int SymbolSetProc(ClientData clientData, Tcl_Interp *interp, Tk_Image tkImage = Tk_GetImage(interp, tkwin, string, ImageChangedProc, elemPtr); - if (tkImage != NULL) { + if (tkImage) { DestroySymbol(Tk_Display(tkwin), symbolPtr); symbolPtr->image = tkImage; symbolPtr->type = SYMBOL_IMAGE; @@ -483,7 +483,7 @@ static Tcl_Obj* SymbolGetProc(ClientData clientData, Tk_Window tkwin, return Tcl_NewListObj(2, ll); } else { - for (GraphSymbolType* p = graphSymbols; p->name != NULL; p++) { + for (GraphSymbolType* p = graphSymbols; p->name; p++) { if (p->type == symbolPtr->type) return Tcl_NewStringObj(p->name, -1); } @@ -504,7 +504,8 @@ static Tk_OptionSpec lineElemOptionSpecs[] = { {TK_OPTION_COLOR, "-areaforeground", "areaForeground", "AreaForeground", NULL, -1, Tk_Offset(LineElement, fillFgColor), TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_BORDER, "-areabackground", "areaBackground", "AreaBackground", - NULL, -1, Tk_Offset(LineElement, fillBg), TK_OPTION_NULL_OK, NULL, 0}, + NULL, -1, Tk_Offset(LineElement, fillBg), + TK_OPTION_NULL_OK, NULL, MAP_ITEM}, {TK_OPTION_CUSTOM, "-bindtags", "bindTags", "BindTags", "all", -1, Tk_Offset(LineElement, obj.tags), TK_OPTION_NULL_OK, &listObjOption, 0}, @@ -515,7 +516,7 @@ static Tk_OptionSpec lineElemOptionSpecs[] = { NULL, -1, Tk_Offset(LineElement, builtinPen.traceDashes), TK_OPTION_NULL_OK, &dashesObjOption, 0}, {TK_OPTION_CUSTOM, "-data", "data", "Data", - NULL, -1, 0, 0, &pairsObjOption, 0}, + NULL, -1, 0, 0, &pairsObjOption, MAP_ITEM}, {TK_OPTION_COLOR, "-errorbarcolor", "errorBarColor", "ErrorBarColor", NULL, -1, Tk_Offset(LineElement, builtinPen.errorBarColor), TK_OPTION_NULL_OK, NULL, 0}, @@ -527,18 +528,18 @@ static Tk_OptionSpec lineElemOptionSpecs[] = { NULL, -1, Tk_Offset(LineElement, builtinPen.symbol.fillColor), TK_OPTION_NULL_OK, NULL, 0}, {TK_OPTION_BOOLEAN, "-hide", "hide", "Hide", - "no", -1, Tk_Offset(LineElement, hide), 0, NULL, 0}, + "no", -1, Tk_Offset(LineElement, hide), 0, NULL, MAP_ITEM}, {TK_OPTION_STRING, "-label", "label", "Label", NULL, -1, Tk_Offset(LineElement, label), - TK_OPTION_NULL_OK | TK_OPTION_DONT_SET_DEFAULT, NULL, 0}, + TK_OPTION_NULL_OK | TK_OPTION_DONT_SET_DEFAULT, NULL, MAP_ITEM}, {TK_OPTION_RELIEF, "-legendrelief", "legendRelief", "LegendRelief", "flat", -1, Tk_Offset(LineElement, legendRelief), 0, NULL, 0}, {TK_OPTION_PIXELS, "-linewidth", "lineWidth", "LineWidth", "1", -1, Tk_Offset(LineElement, builtinPen.traceWidth), 0, NULL, 0}, {TK_OPTION_CUSTOM, "-mapx", "mapX", "MapX", - "x", -1, Tk_Offset(LineElement, axes.x), 0, &xAxisObjOption, 0}, + "x", -1, Tk_Offset(LineElement, axes.x), 0, &xAxisObjOption, MAP_ITEM}, {TK_OPTION_CUSTOM, "-mapy", "mapY", "MapY", - "y", -1, Tk_Offset(LineElement, axes.y), 0, &yAxisObjOption, 0}, + "y", -1, Tk_Offset(LineElement, axes.y), 0, &yAxisObjOption, MAP_ITEM}, {TK_OPTION_INT, "-maxsymbols", "maxSymbols", "MaxSymbols", "0", -1, Tk_Offset(LineElement, reqMaxSymbols), 0, NULL, 0}, {TK_OPTION_COLOR, "-offdash", "offDash", "OffDash", @@ -553,11 +554,13 @@ static Tk_OptionSpec lineElemOptionSpecs[] = { NULL, -1, Tk_Offset(LineElement, normalPenPtr), TK_OPTION_NULL_OK, &linePenObjOption, 0}, {TK_OPTION_PIXELS, "-pixels", "pixels", "Pixels", - "0.1i", -1, Tk_Offset(LineElement, builtinPen.symbol.size), 0, NULL, 0}, + "0.1i", -1, Tk_Offset(LineElement, builtinPen.symbol.size), + 0, NULL, MAP_ITEM}, {TK_OPTION_DOUBLE, "-reduce", "reduce", "Reduce", "0", -1, Tk_Offset(LineElement, rTolerance), 0, NULL, 0}, {TK_OPTION_BOOLEAN, "-scalesymbols", "scaleSymbols", "ScaleSymbols", - "yes", -1, Tk_Offset(LineElement, scaleSymbols), 0, NULL, 0}, + "yes", -1, Tk_Offset(LineElement, scaleSymbols), + 0, NULL, (MAP_ITEM | SCALE_SYMBOL)}, {TK_OPTION_STRING_TABLE, "-showerrorbars", "showErrorBars", "ShowErrorBars", "both", -1, Tk_Offset(LineElement, builtinPen.errorBarShow), 0, &fillObjOption, 0}, @@ -565,7 +568,8 @@ static Tk_OptionSpec lineElemOptionSpecs[] = { "none", -1, Tk_Offset(LineElement, builtinPen.valueShow), 0, &fillObjOption, 0}, {TK_OPTION_STRING_TABLE, "-smooth", "smooth", "Smooth", - "linear", -1, Tk_Offset(LineElement, reqSmooth), 0, &smoothObjOption, 0}, + "linear", -1, Tk_Offset(LineElement, reqSmooth), + 0, &smoothObjOption, MAP_ITEM}, {TK_OPTION_STRING_TABLE, "-state", "state", "State", "normal", -1, Tk_Offset(LineElement, state), 0, &stateObjOption, 0}, {TK_OPTION_CUSTOM, "-styles", "styles", "Styles", @@ -574,7 +578,7 @@ static Tk_OptionSpec lineElemOptionSpecs[] = { "none", -1, Tk_Offset(LineElement, builtinPen.symbol), 0, &symbolObjOption, 0}, {TK_OPTION_STRING_TABLE, "-trace", "trace", "Trace", - "both", -1, Tk_Offset(LineElement, penDir), 0, &penDirObjOption, 0}, + "both", -1, Tk_Offset(LineElement, penDir), 0, &penDirObjOption, MAP_ITEM}, {TK_OPTION_ANCHOR, "-valueanchor", "valueAnchor", "ValueAnchor", "s", -1, Tk_Offset(LineElement, builtinPen.valueStyle.anchor), 0, NULL, 0}, {TK_OPTION_COLOR, "-valuecolor", "valueColor", "ValueColor", @@ -591,21 +595,21 @@ static Tk_OptionSpec lineElemOptionSpecs[] = { {TK_OPTION_CUSTOM, "-weights", "weights", "Weights", NULL, -1, Tk_Offset(LineElement, w), 0, &valuesObjOption, 0}, {TK_OPTION_CUSTOM, "-x", "x", "X", - NULL, -1, Tk_Offset(LineElement, x), 0, &valuesObjOption, 0}, + NULL, -1, Tk_Offset(LineElement, x), 0, &valuesObjOption, MAP_ITEM}, {TK_OPTION_CUSTOM, "-xdata", "xData", "XData", - NULL, -1, Tk_Offset(LineElement, x), 0, &valuesObjOption, 0}, + NULL, -1, Tk_Offset(LineElement, x), 0, &valuesObjOption, MAP_ITEM}, {TK_OPTION_CUSTOM, "-xerror", "xError", "XError", - NULL, -1, Tk_Offset(LineElement, xError), 0, &valuesObjOption, 0}, + NULL, -1, Tk_Offset(LineElement, xError), 0, &valuesObjOption, MAP_ITEM}, {TK_OPTION_CUSTOM, "-xhigh", "xHigh", "XHigh", NULL, -1, Tk_Offset(LineElement, xHigh), 0, &valuesObjOption, 0}, {TK_OPTION_CUSTOM, "-xlow", "xLow", "XLow", NULL, -1, Tk_Offset(LineElement, xLow), 0, &valuesObjOption, 0}, {TK_OPTION_CUSTOM, "-y", "y", "Y", - NULL, -1, Tk_Offset(LineElement, y), 0, &valuesObjOption, 0}, + NULL, -1, Tk_Offset(LineElement, y), 0, &valuesObjOption, MAP_ITEM}, {TK_OPTION_CUSTOM, "-ydata", "yData", "YData", - NULL, -1, Tk_Offset(LineElement, y), 0, &valuesObjOption, 0}, + NULL, -1, Tk_Offset(LineElement, y), 0, &valuesObjOption, MAP_ITEM}, {TK_OPTION_CUSTOM, "-yerror", "yError", "YError", - NULL, -1, Tk_Offset(LineElement, yError), 0, &valuesObjOption, 0}, + NULL, -1, Tk_Offset(LineElement, yError), 0, &valuesObjOption, MAP_ITEM}, {TK_OPTION_CUSTOM, "-yhigh", "yHigh", "YHigh", NULL, -1, Tk_Offset(LineElement, yHigh), 0, &valuesObjOption, 0}, {TK_OPTION_CUSTOM, "-ylow", "yLow", "YLow", @@ -775,58 +779,38 @@ static void DestroyPenProc(Graph* graphPtr, Pen* basePtr) static int ConfigureLineProc(Graph *graphPtr, Element *basePtr) { LineElement *elemPtr = (LineElement *)basePtr; - unsigned long gcMask; - XGCValues gcValues; - GC newGC; - Blt_ChainLink link; - LineStyle *stylePtr; - if (ConfigurePenProc(graphPtr, (Pen *)&elemPtr->builtinPen) != TCL_OK) { + if (ConfigurePenProc(graphPtr, (Pen *)&elemPtr->builtinPen) != TCL_OK) return TCL_ERROR; - } - /* - * Point to the static normal/active pens if no external pens have been - * selected. - */ - link = Blt_Chain_FirstLink(elemPtr->stylePalette); + + // Point to the static normal/active pens if no external pens have been + // selected. + Blt_ChainLink link = Blt_Chain_FirstLink(elemPtr->stylePalette); if (link == NULL) { link = Blt_Chain_AllocLink(sizeof(LineStyle)); Blt_Chain_LinkAfter(elemPtr->stylePalette, link, NULL); } - stylePtr = Blt_Chain_GetValue(link); + LineStyle* stylePtr = Blt_Chain_GetValue(link); stylePtr->penPtr = NORMALPEN(elemPtr); - /* - * Set the outline GC for this pen: GCForeground is outline color. - * GCBackground is the fill color (only used for bitmap symbols). - */ - gcMask = 0; - if (elemPtr->fillFgColor != NULL) { + // Set the outline GC for this pen: GCForeground is outline color. + // GCBackground is the fill color (only used for bitmap symbols). + unsigned long gcMask =0; + XGCValues gcValues; + if (elemPtr->fillFgColor) { gcMask |= GCForeground; gcValues.foreground = elemPtr->fillFgColor->pixel; } - if (elemPtr->fillBgColor != NULL) { + if (elemPtr->fillBgColor) { gcMask |= GCBackground; gcValues.background = elemPtr->fillBgColor->pixel; } - newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues); - if (elemPtr->fillGC != NULL) { + GC newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues); + if (elemPtr->fillGC) { Tk_FreeGC(graphPtr->display, elemPtr->fillGC); } elemPtr->fillGC = newGC; - // waj - /* - if (Blt_ConfigModified(elemPtr->configSpecs, "-scalesymbols", - (char *)NULL)) { - elemPtr->flags |= (MAP_ITEM | SCALE_SYMBOL); - } - if (Blt_ConfigModified(elemPtr->configSpecs, "-pixels", "-trace", - "-*data", "-smooth", "-map*", "-label", "-hide", "-x", "-y", - "-areabackground", (char *)NULL)) { - elemPtr->flags |= MAP_ITEM; - } - */ return TCL_OK; } @@ -838,13 +822,11 @@ static int ConfigurePenProc(Graph* graphPtr, Pen* basePtr) XGCValues gcValues; XColor *colorPtr; - /* - * Set the outline GC for this pen: GCForeground is outline color. - * GCBackground is the fill color (only used for bitmap symbols). - */ + // Set the outline GC for this pen: GCForeground is outline color. + // GCBackground is the fill color (only used for bitmap symbols). gcMask = (GCLineWidth | GCForeground); colorPtr = lpPtr->symbol.outlineColor; - if (colorPtr == NULL) + if (colorPtr) colorPtr = lpPtr->traceColor; gcValues.foreground = colorPtr->pixel; @@ -862,7 +844,7 @@ static int ConfigurePenProc(Graph* graphPtr, Pen* basePtr) * this makes it unlikely that anyone else will be sharing this GC when * we set the clip origin (at the time the bitmap is drawn). */ - if (colorPtr != NULL) { + if (colorPtr) { gcValues.background = colorPtr->pixel; gcMask |= GCBackground; if (lpPtr->symbol.mask != None) { @@ -876,30 +858,28 @@ static int ConfigurePenProc(Graph* graphPtr, Pen* basePtr) } gcValues.line_width = LineWidth(lpPtr->symbol.outlineWidth); newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues); - if (lpPtr->symbol.outlineGC != NULL) { + if (lpPtr->symbol.outlineGC) { Tk_FreeGC(graphPtr->display, lpPtr->symbol.outlineGC); } lpPtr->symbol.outlineGC = newGC; - /* Fill GC for symbols: GCForeground is fill color */ - + // Fill GC for symbols: GCForeground is fill color gcMask = (GCLineWidth | GCForeground); colorPtr = lpPtr->symbol.fillColor; if (!colorPtr) colorPtr = lpPtr->traceColor; newGC = NULL; - if (colorPtr != NULL) { + if (colorPtr) { gcValues.foreground = colorPtr->pixel; newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues); } - if (lpPtr->symbol.fillGC != NULL) { + if (lpPtr->symbol.fillGC) { Tk_FreeGC(graphPtr->display, lpPtr->symbol.fillGC); } lpPtr->symbol.fillGC = newGC; - /* Line segments */ - + // Line segments gcMask = (GCLineWidth | GCForeground | GCLineStyle | GCCapStyle | GCJoinStyle); gcValues.cap_style = CapButt; @@ -911,7 +891,7 @@ static int ConfigurePenProc(Graph* graphPtr, Pen* basePtr) if (!colorPtr) colorPtr = lpPtr->traceColor; - if (colorPtr != NULL) { + if (colorPtr) { gcMask |= GCBackground; gcValues.background = colorPtr->pixel; } @@ -922,7 +902,7 @@ static int ConfigurePenProc(Graph* graphPtr, Pen* basePtr) (colorPtr == NULL) ? LineOnOffDash : LineDoubleDash; } newGC = Blt_GetPrivateGC(graphPtr->tkwin, gcMask, &gcValues); - if (lpPtr->traceGC != NULL) { + if (lpPtr->traceGC) { Blt_FreePrivateGC(graphPtr->display, lpPtr->traceGC); } if (LineIsDashed(lpPtr->traceDashes)) { @@ -939,7 +919,7 @@ static int ConfigurePenProc(Graph* graphPtr, Pen* basePtr) gcValues.line_width = LineWidth(lpPtr->errorBarLineWidth); gcValues.foreground = colorPtr->pixel; newGC = Tk_GetGC(graphPtr->tkwin, gcMask, &gcValues); - if (lpPtr->errorBarGC != NULL) { + if (lpPtr->errorBarGC) { Tk_FreeGC(graphPtr->display, lpPtr->errorBarGC); } lpPtr->errorBarGC = newGC; @@ -951,7 +931,7 @@ static int ConfigurePenProc(Graph* graphPtr, Pen* basePtr) static void DestroySymbol(Display *display, Symbol *symbolPtr) { - if (symbolPtr->image != NULL) { + if (symbolPtr->image) { Tk_FreeImage(symbolPtr->image); symbolPtr->image = NULL; } @@ -988,7 +968,7 @@ static void ResetStylePalette(Blt_Chain styles) { Blt_ChainLink link; - for (link = Blt_Chain_FirstLink(styles); link != NULL; + for (link = Blt_Chain_FirstLink(styles); link; link = Blt_Chain_NextLink(link)) { LineStyle *stylePtr; @@ -1382,11 +1362,11 @@ static void MapActiveSymbols(Graph *graphPtr, LineElement *elemPtr) int *map; int count, i, np; - if (elemPtr->activePts.points != NULL) { + if (elemPtr->activePts.points) { free(elemPtr->activePts.points); elemPtr->activePts.points = NULL; } - if (elemPtr->activePts.map != NULL) { + if (elemPtr->activePts.map) { free(elemPtr->activePts.map); elemPtr->activePts.map = NULL; } @@ -1455,7 +1435,7 @@ static void MergePens(LineElement *elemPtr, LineStyle **styleMap) map = malloc(elemPtr->lines.length * sizeof(int)); sp = segments, ip = map; for (link = Blt_Chain_FirstLink(elemPtr->stylePalette); - link != NULL; link = Blt_Chain_NextLink(link)) { + link; link = Blt_Chain_NextLink(link)) { LineStyle *stylePtr; int i; @@ -1487,7 +1467,7 @@ static void MergePens(LineElement *elemPtr, LineStyle **styleMap) map = malloc(elemPtr->symbolPts.length * sizeof(int)); pp = points, ip = map; for (link = Blt_Chain_FirstLink(elemPtr->stylePalette); - link != NULL; link = Blt_Chain_NextLink(link)) { + link; link = Blt_Chain_NextLink(link)) { LineStyle *stylePtr; int i; @@ -1518,7 +1498,7 @@ static void MergePens(LineElement *elemPtr, LineStyle **styleMap) map = malloc(elemPtr->xeb.length * sizeof(int)); sp = segments, ip = map; for (link = Blt_Chain_FirstLink(elemPtr->stylePalette); - link != NULL; link = Blt_Chain_NextLink(link)) { + link; link = Blt_Chain_NextLink(link)) { LineStyle *stylePtr; int i; @@ -1549,7 +1529,7 @@ static void MergePens(LineElement *elemPtr, LineStyle **styleMap) map = malloc(elemPtr->yeb.length * sizeof(int)); sp = segments, ip = map; for (link = Blt_Chain_FirstLink(elemPtr->stylePalette); - link != NULL; link = Blt_Chain_NextLink(link)) { + link; link = Blt_Chain_NextLink(link)) { LineStyle *stylePtr; int i; @@ -1656,7 +1636,7 @@ static void SaveTrace(LineElement *elemPtr, int start, int length, /* Copy the screen coordinates of the trace into the point array */ - if (mapPtr->map != NULL) { + if (mapPtr->map) { for (i = 0, j = start; i < length; i++, j++) { screenPts[i].x = mapPtr->screenPts[j].x; screenPts[i].y = mapPtr->screenPts[j].y; @@ -1683,7 +1663,7 @@ static void FreeTraces(LineElement *elemPtr) { Blt_ChainLink link; - for (link = Blt_Chain_FirstLink(elemPtr->traces); link != NULL; + for (link = Blt_Chain_FirstLink(elemPtr->traces); link; link = Blt_Chain_NextLink(link)) { bltTrace *tracePtr; @@ -1766,7 +1746,7 @@ static void MapFillArea(Graph *graphPtr, LineElement *elemPtr, MapInfo *mapPtr) Region2d exts; int np; - if (elemPtr->fillPts != NULL) { + if (elemPtr->fillPts) { free(elemPtr->fillPts); elemPtr->fillPts = NULL; elemPtr->nFillPts = 0; @@ -1838,34 +1818,34 @@ static void ResetLine(LineElement *elemPtr) { FreeTraces(elemPtr); ResetStylePalette(elemPtr->stylePalette); - if (elemPtr->symbolPts.points != NULL) { + if (elemPtr->symbolPts.points) { free(elemPtr->symbolPts.points); } - if (elemPtr->symbolPts.map != NULL) { + if (elemPtr->symbolPts.map) { free(elemPtr->symbolPts.map); } - if (elemPtr->lines.segments != NULL) { + if (elemPtr->lines.segments) { free(elemPtr->lines.segments); } - if (elemPtr->lines.map != NULL) { + if (elemPtr->lines.map) { free(elemPtr->lines.map); } - if (elemPtr->activePts.points != NULL) { + if (elemPtr->activePts.points) { free(elemPtr->activePts.points); } - if (elemPtr->activePts.map != NULL) { + if (elemPtr->activePts.map) { free(elemPtr->activePts.map); } - if (elemPtr->xeb.segments != NULL) { + if (elemPtr->xeb.segments) { free(elemPtr->xeb.segments); } - if (elemPtr->xeb.map != NULL) { + if (elemPtr->xeb.map) { free(elemPtr->xeb.map); } - if (elemPtr->yeb.segments != NULL) { + if (elemPtr->yeb.segments) { free(elemPtr->yeb.segments); } - if (elemPtr->yeb.map != NULL) { + if (elemPtr->yeb.map) { free(elemPtr->yeb.map); } elemPtr->xeb.segments = elemPtr->yeb.segments = elemPtr->lines.segments = NULL; @@ -2072,7 +2052,7 @@ static void MapLineProc(Graph *graphPtr, Element *basePtr) if (elemPtr->rTolerance > 0.0) { ReducePoints(&mi, elemPtr->rTolerance); } - if (elemPtr->fillBg != NULL) { + if (elemPtr->fillBg) { MapFillArea(graphPtr, elemPtr, &mi); } MapTraces(graphPtr, elemPtr, &mi); @@ -2081,7 +2061,7 @@ static void MapLineProc(Graph *graphPtr, Element *basePtr) free(mi.map); /* Set the symbol size of all the pen styles. */ - for (link = Blt_Chain_FirstLink(elemPtr->stylePalette); link != NULL; + for (link = Blt_Chain_FirstLink(elemPtr->stylePalette); link; link = Blt_Chain_NextLink(link)) { LineStyle *stylePtr; LinePen *penPtr; @@ -2232,7 +2212,7 @@ static int ClosestTrace(Graph *graphPtr, LineElement *elemPtr, iClose = -1; /* Suppress compiler warning. */ dMin = searchPtr->dist; closest.x = closest.y = 0; /* Suppress compiler warning. */ - for (link = Blt_Chain_FirstLink(elemPtr->traces); link != NULL; + for (link = Blt_Chain_FirstLink(elemPtr->traces); link; link = Blt_Chain_NextLink(link)) { bltTrace *tracePtr; Point2d *p, *pend; @@ -2525,7 +2505,7 @@ static void DrawCircles(Display *display, Drawable drawable, int n; n = ((i + reqSize) > count) ? (count - i) : reqSize; - if (penPtr->symbol.fillGC != NULL) { + if (penPtr->symbol.fillGC) { XFillArcs(display, drawable, penPtr->symbol.fillGC, arcs + i, n); } if (penPtr->symbol.outlineWidth > 0) { @@ -2582,7 +2562,7 @@ static void DrawSquares(Display *display, Drawable drawable, if (n > reqSize) { n = reqSize; } - if (penPtr->symbol.fillGC != NULL) { + if (penPtr->symbol.fillGC) { XFillRectangles(display, drawable, penPtr->symbol.fillGC, rp, n); } if (penPtr->symbol.outlineWidth > 0) { @@ -2603,7 +2583,7 @@ static void DrawSymbols(Graph *graphPtr, Drawable drawable, #define S_RATIO 0.886226925452758 if (size < 3) { - if (penPtr->symbol.fillGC != NULL) { + if (penPtr->symbol.fillGC) { Point2d *pp, *endp; XPoint *points, *xpp; @@ -2797,7 +2777,7 @@ static void DrawSymbols(Graph *graphPtr, Drawable drawable, } count = nSymbolPts; } - if (penPtr->symbol.fillGC != NULL) { + if (penPtr->symbol.fillGC) { int i; XPoint *xpp; @@ -2880,7 +2860,7 @@ static void DrawSymbols(Graph *graphPtr, Drawable drawable, } count = nSymbolPts; } - if (penPtr->symbol.fillGC != NULL) { + if (penPtr->symbol.fillGC) { XPoint *xpp; int i; @@ -2983,7 +2963,7 @@ static void DrawSymbols(Graph *graphPtr, Drawable drawable, } count = nSymbolPts; } - if (penPtr->symbol.fillGC != NULL) { + if (penPtr->symbol.fillGC) { XPoint *xpp; int i; @@ -3158,7 +3138,7 @@ static void DrawTraces(Graph *graphPtr, Drawable drawable, np = Blt_MaxRequestSize(graphPtr->display, sizeof(XPoint)) - 1; points = malloc((np + 1) * sizeof(XPoint)); - for (link = Blt_Chain_FirstLink(elemPtr->traces); link != NULL; + for (link = Blt_Chain_FirstLink(elemPtr->traces); link; link = Blt_Chain_NextLink(link)) { XPoint *xpp; bltTrace *tracePtr; @@ -3320,7 +3300,7 @@ static void DrawNormalLineProc(Graph *graphPtr, Drawable drawable, unsigned int count; /* Fill area under the curve */ - if (elemPtr->fillPts != NULL) { + if (elemPtr->fillPts) { XPoint *points; Point2d *endp, *pp; @@ -3332,7 +3312,7 @@ static void DrawNormalLineProc(Graph *graphPtr, Drawable drawable, points[count].y = Round(pp->y); count++; } - if (elemPtr->fillBg != NULL) { + if (elemPtr->fillBg) { Tk_Fill3DPolygon(graphPtr->tkwin, drawable, elemPtr->fillBg, points, elemPtr->nFillPts, 0, TK_RELIEF_FLAT); @@ -3343,7 +3323,7 @@ static void DrawNormalLineProc(Graph *graphPtr, Drawable drawable, /* Lines: stripchart segments or graph traces. */ if (elemPtr->lines.length > 0) { for (link = Blt_Chain_FirstLink(elemPtr->stylePalette); - link != NULL; link = Blt_Chain_NextLink(link)) { + link; link = Blt_Chain_NextLink(link)) { LineStyle *stylePtr; LinePen *penPtr; @@ -3370,7 +3350,7 @@ static void DrawNormalLineProc(Graph *graphPtr, Drawable drawable, total = 0; for (link = Blt_Chain_FirstLink(elemPtr->stylePalette); - link != NULL; link = Blt_Chain_NextLink(link)) { + link; link = Blt_Chain_NextLink(link)) { LineStyle *stylePtr; stylePtr = Blt_Chain_GetValue(link); @@ -3383,7 +3363,7 @@ static void DrawNormalLineProc(Graph *graphPtr, Drawable drawable, /* Symbols, error bars, values. */ count = 0; - for (link = Blt_Chain_FirstLink(elemPtr->stylePalette); link != NULL; + for (link = Blt_Chain_FirstLink(elemPtr->stylePalette); link; link = Blt_Chain_NextLink(link)) { LineStyle *stylePtr; LinePen *penPtr; @@ -3561,7 +3541,7 @@ static void SetLineAttributes(Blt_Ps ps, LinePen *penPtr) Blt_Ps_XSetLineAttributes(ps, penPtr->traceColor, penPtr->traceWidth, &penPtr->traceDashes, CapButt, JoinMiter); if ((LineIsDashed(penPtr->traceDashes)) && - (penPtr->traceOffColor != NULL)) { + (penPtr->traceOffColor)) { Blt_Ps_Append(ps, "/DashesProc {\n gsave\n "); Blt_Ps_XSetBackground(ps, penPtr->traceOffColor); Blt_Ps_Append(ps, " "); @@ -3577,7 +3557,7 @@ static void TracesToPostScript(Blt_Ps ps, LineElement *elemPtr, LinePen *penPtr) Blt_ChainLink link; SetLineAttributes(ps, penPtr); - for (link = Blt_Chain_FirstLink(elemPtr->traces); link != NULL; + for (link = Blt_Chain_FirstLink(elemPtr->traces); link; link = Blt_Chain_NextLink(link)) { bltTrace *tracePtr; @@ -3677,19 +3657,19 @@ static void NormalLineToPostScriptProc(Graph *graphPtr, Blt_Ps ps, unsigned int count; /* Draw fill area */ - if (elemPtr->fillPts != NULL) { + if (elemPtr->fillPts) { /* Create a path to use for both the polygon and its outline. */ Blt_Ps_Append(ps, "% start fill area\n"); Blt_Ps_Polyline(ps, elemPtr->fillPts, elemPtr->nFillPts); /* If the background fill color was specified, draw the polygon in a * solid fashion with that color. */ - if (elemPtr->fillBgColor != NULL) { + if (elemPtr->fillBgColor) { Blt_Ps_XSetBackground(ps, elemPtr->fillBgColor); Blt_Ps_Append(ps, "gsave fill grestore\n"); } Blt_Ps_XSetForeground(ps, elemPtr->fillFgColor); - if (elemPtr->fillBg != NULL) { + if (elemPtr->fillBg) { Blt_Ps_Append(ps, "gsave fill grestore\n"); /* TBA: Transparent tiling is the hard part. */ } else { @@ -3700,7 +3680,7 @@ static void NormalLineToPostScriptProc(Graph *graphPtr, Blt_Ps ps, /* Draw lines (strip chart) or traces (xy graph) */ if (elemPtr->lines.length > 0) { - for (link = Blt_Chain_FirstLink(elemPtr->stylePalette); link != NULL; + for (link = Blt_Chain_FirstLink(elemPtr->stylePalette); link; link = Blt_Chain_NextLink(link)) { LineStyle *stylePtr; LinePen *penPtr; @@ -3728,7 +3708,7 @@ static void NormalLineToPostScriptProc(Graph *graphPtr, Blt_Ps ps, /* Draw symbols, error bars, values. */ count = 0; - for (link = Blt_Chain_FirstLink(elemPtr->stylePalette); link != NULL; + for (link = Blt_Chain_FirstLink(elemPtr->stylePalette); link; link = Blt_Chain_NextLink(link)) { LineStyle *stylePtr; LinePen *penPtr; diff --git a/src/bltGrElemOp.C b/src/bltGrElemOp.C index fda4f9e..8862adb 100644 --- a/src/bltGrElemOp.C +++ b/src/bltGrElemOp.C @@ -437,8 +437,8 @@ static int ElementObjConfigure(Tcl_Interp *interp, Graph* graphPtr, Tk_RestoreSavedOptions(&savedOptions); } - graphPtr->flags |= mask; - graphPtr->flags |= CACHE_DIRTY; + elemPtr->flags |= mask; + graphPtr->flags |= (RESET_WORLD | CACHE_DIRTY); if ((*elemPtr->procsPtr->configProc) (graphPtr, elemPtr) != TCL_OK) return TCL_ERROR; Blt_EventuallyRedrawGraph(graphPtr); @@ -1495,29 +1495,3 @@ ClientData Blt_MakeElementTag(Graph *graphPtr, const char *tagName) hPtr = Tcl_CreateHashEntry(&graphPtr->elements.tagTable, tagName, &isNew); return Tcl_GetHashKey(&graphPtr->elements.tagTable, hPtr); } - -// waj -/* - if (Blt_ConfigModified(elemPtr->configSpecs, "-hide", (char *)NULL)) { - graphPtr->flags |= RESET_AXES; - elemPtr->flags |= MAP_ITEM; - } -*/ -/* If data points or axes have changed, reset the axes (may - * affect autoscaling) and recalculate the screen points of - * the element. */ - -/* - if (Blt_ConfigModified(elemPtr->configSpecs, "-*data", "-map*", "-x", - "-y", (char *)NULL)) { - graphPtr->flags |= RESET_WORLD; - elemPtr->flags |= MAP_ITEM; - } -*/ -/* The new label may change the size of the legend */ -/* - if (Blt_ConfigModified(elemPtr->configSpecs, "-label", (char *)NULL)) { - graphPtr->flags |= (MAP_WORLD | REDRAW_WORLD); - } -*/ - |