diff options
author | joye <joye> | 2014-02-28 20:14:01 (GMT) |
---|---|---|
committer | joye <joye> | 2014-02-28 20:14:01 (GMT) |
commit | 16eda28798302d56afc2264111db0abc27b80a16 (patch) | |
tree | c928f2115e61c33205fdc3fccd2c76c9f8368fa6 /src | |
parent | a4b94e6363036541d4cf86e935b90cd5e2fab691 (diff) | |
download | blt-16eda28798302d56afc2264111db0abc27b80a16.zip blt-16eda28798302d56afc2264111db0abc27b80a16.tar.gz blt-16eda28798302d56afc2264111db0abc27b80a16.tar.bz2 |
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r-- | src/bltGrAxis.C | 158 | ||||
-rw-r--r-- | src/bltGrAxis.h | 313 | ||||
-rw-r--r-- | src/bltGrLegd.C | 23 |
3 files changed, 220 insertions, 274 deletions
diff --git a/src/bltGrAxis.C b/src/bltGrAxis.C index 18d9e2a..8e34b83 100644 --- a/src/bltGrAxis.C +++ b/src/bltGrAxis.C @@ -40,44 +40,26 @@ #include "bltMath.h" #include "bltGraph.h" #include "bltOp.h" +#include "bltGrAxis.h" #include "bltGrElem.h" #include "bltConfig.h" -#define MAXTICKS 10001 +#define AXIS_PAD_TITLE 2 +#define MAXTICKS 10001 +#define NUMDIGITS 15 /* Specifies the number of digits of + * accuracy used when outputting axis + * tick labels. */ #define FCLAMP(x) ((((x) < 0.0) ? 0.0 : ((x) > 1.0) ? 1.0 : (x))) - -/* - * Round x in terms of units - */ #define UROUND(x,u) (Round((x)/(u))*(u)) #define UCEIL(x,u) (ceil((x)/(u))*(u)) #define UFLOOR(x,u) (floor((x)/(u))*(u)) +#define HORIZMARGIN(m) (!((m)->site & 0x1)) /* Even sites are horizontal */ -#define NUMDIGITS 15 /* Specifies the number of digits of - * accuracy used when outputting axis - * tick labels. */ enum TickRange { AXIS_TIGHT, AXIS_LOOSE, AXIS_ALWAYS_LOOSE }; -#define AXIS_PAD_TITLE 2 /* Padding for axis title. */ - -/* Axis flags: */ - -#define AXIS_AUTO_MAJOR (1<<16) /* Auto-generate major ticks. */ -#define AXIS_AUTO_MINOR (1<<17) /* Auto-generate minor ticks. */ -#define AXIS_USE (1<<18) /* Axis is displayed on the screen via - * the "use" operation */ -#define AXIS_GRID (1<<19) /* Display grid lines. */ -#define AXIS_GRIDMINOR (1<<20) /* Display grid lines for minor - * ticks. */ -#define AXIS_SHOWTICKS (1<<21) /* Display axis ticks. */ -#define AXIS_EXTERIOR (1<<22) /* Axis is exterior to the plot. */ -#define AXIS_CHECK_LIMITS (1<<23) /* Validate user-defined axis limits. */ - -#define HORIZMARGIN(m) (!((m)->site & 0x1)) /* Even sites are horizontal */ - typedef struct { int axis; /* Length of the axis. */ int t1; /* Length of a major tick (in @@ -190,6 +172,55 @@ static Tcl_Obj* LimitGetProc(ClientData clientData, Tk_Window tkwin, return objPtr; } +static Tk_CustomOptionSetProc FormatSetProc; +static Tk_CustomOptionGetProc FormatGetProc; +Tk_ObjCustomOption formatObjOption = + { + "format", FormatSetProc, FormatGetProc, NULL, NULL, NULL + }; + +static int FormatSetProc(ClientData clientData, Tcl_Interp* interp, + Tk_Window tkwin, Tcl_Obj** objPtr, char* widgRec, + int offset, char* save, int flags) +{ + Axis *axisPtr = (Axis*)(widgRec); + + const char **argv; + int argc; + if (Tcl_SplitList(interp, Tcl_GetString(*objPtr), &argc, &argv) != TCL_OK) + return TCL_ERROR; + + if (argc > 2) { + Tcl_AppendResult(interp, "too many elements in limits format list \"", + Tcl_GetString(*objPtr), "\"", NULL); + free(argv); + return TCL_ERROR; + } + if (axisPtr->limitsFormats) + free(axisPtr->limitsFormats); + + axisPtr->limitsFormats = argv; + axisPtr->nFormats = argc; + + return TCL_OK; +} + +static Tcl_Obj* FormatGetProc(ClientData clientData, Tk_Window tkwin, + char *widgRec, int offset) +{ + Axis *axisPtr = (Axis*)(widgRec); + Tcl_Obj* objPtr; + + if (axisPtr->nFormats == 0) + objPtr = Tcl_NewStringObj("", -1); + else { + char *string = Tcl_Merge(axisPtr->nFormats, axisPtr->limitsFormats); + objPtr = Tcl_NewStringObj(string, -1); + free(string); + } + return objPtr; +} + static Tk_OptionSpec optionSpecs[] = { {TK_OPTION_COLOR, "-activeforeground", "activeForeground", "ActiveForeground", STD_ACTIVE_FOREGROUND, -1, Tk_Offset(Axis, activeFgColor), 0, NULL, 0}, @@ -223,13 +254,7 @@ static Tk_OptionSpec optionSpecs[] = { {TK_OPTION_SYNONYM, "-foreground", NULL, NULL, NULL, -1, 0, 0, "-color", 0}, /* {TK_OPTION_CUSTOM, "-grid", "grid", "Grid", "1", - Tk_Offset(Axis, flags), BARCHART, - &bitmaskGrAxisGridOption}, - */ - /* - {TK_OPTION_CUSTOM, "-grid", "grid", "Grid", "1", - Tk_Offset(Axis, flags), GRAPH | STRIPCHART, - &bitmaskGrAxisGridOption}, + Tk_Offset(Axis, flags), BARCHART, &bitmaskGrAxisGridOption}, */ {TK_OPTION_COLOR, "-gridcolor", "gridColor", "GridColor", "gray64", -1, Tk_Offset(Axis, major.color), 0, NULL, 0}, @@ -240,8 +265,7 @@ static Tk_OptionSpec optionSpecs[] = { "0", -1, Tk_Offset(Axis, major.lineWidth), 0, NULL, 0}, /* {TK_OPTION_CUSTOM, "-gridminor", "gridMinor", "GridMinor", - "1", Tk_Offset(Axis, flags), - TK_OPTION_DONT_SET_DEFAULT | ALL_GRAPHS, + "1", Tk_Offset(Axis, flags), TK_OPTION_DONT_SET_DEFAULT | ALL_GRAPHS, &bitmaskGrAxisGridMinorOption}, */ {TK_OPTION_COLOR, "-gridminorcolor", "gridMinorColor", "GridMinorColor", @@ -252,11 +276,8 @@ static Tk_OptionSpec optionSpecs[] = { {TK_OPTION_PIXELS, "-gridminorlinewidth", "gridMinorLineWidth", "GridMinorLineWidth", "0", -1, Tk_Offset(Axis, minor.lineWidth), 0, NULL, 0}, - /* - {TK_OPTION_CUSTOM, "-hide", "hide", "Hide", "0", - Tk_Offset(Axis, flags), ALL_GRAPHS | TK_OPTION_DONT_SET_DEFAULT, - &bitmaskGrAxisHideOption}, - */ + {TK_OPTION_BOOLEAN, "-hide", "hide", "Hide", + "no", -1, Tk_Offset(Axis, hide), 0, NULL, 0}, {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify", "c", -1, Tk_Offset(Axis, titleJustify), 0, NULL, 0}, {TK_OPTION_BOOLEAN, "-labeloffset", "labelOffset", "LabelOffset", @@ -266,11 +287,9 @@ static Tk_OptionSpec optionSpecs[] = { 0, NULL, 0}, {TK_OPTION_FONT, "-limitsfont", "limitsFont", "LimitsFont", STD_FONT_SMALL, -1, Tk_Offset(Axis, limitsTextStyle.font), 0, NULL, 0}, - /* {TK_OPTION_CUSTOM, "-limitsformat", "limitsFormat", "LimitsFormat", - NULL, -1, Tk_Offset(Axis, limitsFormats), TK_OPTION_NULL_OK - ALL_GRAPHS, &formatOption}, - */ + NULL, -1, Tk_Offset(Axis, limitsFormats), + TK_OPTION_NULL_OK, &formatObjOption, 0}, {TK_OPTION_PIXELS, "-linewidth", "lineWidth", "LineWidth", "1", -1, Tk_Offset(Axis, lineWidth), 0, NULL, 0}, {TK_OPTION_BOOLEAN, "-logscale", "logScale", "LogScale", @@ -406,7 +425,7 @@ Blt_CustomOption bitmaskGrAxisGridOption = Blt_CustomOption bitmaskGrAxisGridMinorOption = { - ObjToBitmaskProc, BitmaskToObjProc, NULL, (ClientData)AXIS_GRIDMINOR + ObjToBitmaskProc, BitmaskToObjProc, NULL, (ClientData)AXIS_GRID_MINOR }; Blt_CustomOption bitmaskGrAxisHideOption = @@ -2475,7 +2494,7 @@ static void MapGridlines(Axis *axisPtr) t2Ptr = GenerateTicks(&axisPtr->minorSweep); } needed = t1Ptr->nTicks; - if (axisPtr->flags & AXIS_GRIDMINOR) { + if (axisPtr->flags & AXIS_GRID_MINOR) { needed += (t1Ptr->nTicks * t2Ptr->nTicks); } if (needed == 0) { @@ -2504,7 +2523,7 @@ static void MapGridlines(Axis *axisPtr) double value; value = t1Ptr->values[i]; - if (axisPtr->flags & AXIS_GRIDMINOR) { + if (axisPtr->flags & AXIS_GRID_MINOR) { int j; for (j = 0; j < t2Ptr->nTicks; j++) { @@ -2656,7 +2675,7 @@ static int GetMarginGeometry(Graph* graphPtr, Margin *marginPtr) Axis *axisPtr; axisPtr = Blt_Chain_GetValue(link); - if ((axisPtr->flags & (HIDE|AXIS_USE)) == AXIS_USE) { + if (!axisPtr->hide && (axisPtr->flags & AXIS_USE)) { nVisible++; if (graphPtr->flags & GET_AXIS_GEOMETRY) { GetAxisGeometry(graphPtr, axisPtr); @@ -2684,7 +2703,7 @@ static int GetMarginGeometry(Graph* graphPtr, Margin *marginPtr) Axis *axisPtr; axisPtr = Blt_Chain_GetValue(link); - if ((axisPtr->flags & (HIDE|AXIS_USE)) == AXIS_USE) { + if (!axisPtr->hide && (axisPtr->flags & AXIS_USE)) { nVisible++; if (graphPtr->flags & GET_AXIS_GEOMETRY) { GetAxisGeometry(graphPtr, axisPtr); @@ -3203,7 +3222,7 @@ static Axis *NewAxis(Graph* graphPtr, const char *name, int margin) axisPtr->scrollUnits = 10; axisPtr->reqMin = axisPtr->reqMax = NAN; axisPtr->reqScrollMin = axisPtr->reqScrollMax = NAN; - axisPtr->flags = (AXIS_SHOWTICKS|AXIS_GRIDMINOR|AXIS_AUTO_MAJOR| + axisPtr->flags = (AXIS_SHOWTICKS|AXIS_GRID_MINOR|AXIS_AUTO_MAJOR| AXIS_AUTO_MINOR | AXIS_EXTERIOR); if (graphPtr->classId == CID_ELEM_BAR) { axisPtr->flags |= AXIS_GRID; @@ -3213,9 +3232,9 @@ static Axis *NewAxis(Graph* graphPtr, const char *name, int margin) axisPtr->reqStep = 1.0; axisPtr->reqNumMinorTicks = 0; } - if ((margin == MARGIN_RIGHT) || (margin == MARGIN_TOP)) { - axisPtr->flags |= HIDE; - } + if ((margin == MARGIN_RIGHT) || (margin == MARGIN_TOP)) + axisPtr->hide = 1; + Blt_Ts_InitStyle(axisPtr->limitsTextStyle); axisPtr->tickLabels = Blt_Chain_Create(); axisPtr->lineWidth = 1; @@ -3370,7 +3389,7 @@ static int ActivateOp(Tcl_Interp* interp, Axis *axisPtr, int objc, Tcl_Obj *cons } else { axisPtr->flags &= ~ACTIVE; } - if ((axisPtr->flags & (AXIS_USE|HIDE)) == AXIS_USE) { + if (!axisPtr->hide && (axisPtr->flags & AXIS_USE)) { graphPtr->flags |= DRAW_MARGINS | CACHE_DIRTY; Blt_EventuallyRedrawGraph(graphPtr); } @@ -3823,10 +3842,9 @@ static int AxisFocusOp(Tcl_Interp* interp, Graph* graphPtr, int objc, Tcl_Obj *c return TCL_ERROR; } graphPtr->focusPtr = NULL; - if ((axisPtr != NULL) && - ((axisPtr->flags & (AXIS_USE|HIDE)) == AXIS_USE)) { + if (axisPtr && !axisPtr->hide && (axisPtr->flags & AXIS_USE)) graphPtr->focusPtr = axisPtr; - } + Blt_SetFocusItem(graphPtr->bindTable, graphPtr->focusPtr, NULL); } /* Return the name of the axis that has focus. */ @@ -4109,9 +4127,9 @@ Blt_DrawAxes(Graph* graphPtr, Drawable drawable) Axis *axisPtr; axisPtr = Blt_Chain_GetValue(link); - if ((axisPtr->flags & (DELETE_PENDING|HIDE|AXIS_USE)) == AXIS_USE) { + if (!axisPtr->hide && + ((axisPtr->flags & (DELETE_PENDING|AXIS_USE)) == AXIS_USE)) DrawAxis(axisPtr, drawable); - } } } } @@ -4128,14 +4146,14 @@ void Blt_DrawGrids(Graph* graphPtr, Drawable drawable) Axis *axisPtr; axisPtr = Blt_Chain_GetValue(link); - if (axisPtr->flags & (DELETE_PENDING|HIDE)) { + if (axisPtr->hide || (axisPtr->flags & DELETE_PENDING)) continue; - } + if ((axisPtr->flags & AXIS_USE) && (axisPtr->flags & AXIS_GRID)) { Blt_Draw2DSegments(graphPtr->display, drawable, axisPtr->major.gc, axisPtr->major.segments, axisPtr->major.nUsed); - if (axisPtr->flags & AXIS_GRIDMINOR) { + if (axisPtr->flags & AXIS_GRID_MINOR) { Blt_Draw2DSegments(graphPtr->display, drawable, axisPtr->minor.gc, axisPtr->minor.segments, axisPtr->minor.nUsed); @@ -4157,10 +4175,11 @@ void Blt_GridsToPostScript(Graph* graphPtr, Blt_Ps ps) Axis *axisPtr; axisPtr = Blt_Chain_GetValue(link); - if ((axisPtr->flags & (DELETE_PENDING|HIDE|AXIS_USE|AXIS_GRID)) != - (AXIS_GRID|AXIS_USE)) { + if (axisPtr->hide || + ((axisPtr->flags & (DELETE_PENDING|AXIS_USE|AXIS_GRID))) != + (AXIS_GRID|AXIS_USE)) continue; - } + Blt_Ps_Format(ps, "%% Axis %s: grid line attributes\n", axisPtr->obj.name); Blt_Ps_XSetLineAttributes(ps, axisPtr->major.color, @@ -4170,7 +4189,7 @@ void Blt_GridsToPostScript(Graph* graphPtr, Blt_Ps ps) axisPtr->obj.name); Blt_Ps_Draw2DSegments(ps, axisPtr->major.segments, axisPtr->major.nUsed); - if (axisPtr->flags & AXIS_GRIDMINOR) { + if (axisPtr->flags & AXIS_GRID_MINOR) { Blt_Ps_XSetLineAttributes(ps, axisPtr->minor.color, axisPtr->minor.lineWidth, &axisPtr->minor.dashes, CapButt, JoinMiter); @@ -4195,9 +4214,9 @@ void Blt_AxesToPostScript(Graph* graphPtr, Blt_Ps ps) Axis *axisPtr; axisPtr = Blt_Chain_GetValue(link); - if ((axisPtr->flags & (DELETE_PENDING|HIDE|AXIS_USE)) == AXIS_USE) { + if (!axisPtr->hide && + ((axisPtr->flags & (DELETE_PENDING|AXIS_USE)) == AXIS_USE)) AxisToPostScript(ps, axisPtr); - } } } } @@ -4370,9 +4389,10 @@ Axis *Blt_NearestAxis(Graph* graphPtr, int x, int y) Axis *axisPtr; axisPtr = Tcl_GetHashValue(hPtr); - if ((axisPtr->flags & (DELETE_PENDING|HIDE|AXIS_USE)) != AXIS_USE) { + if (axisPtr->hide || + ((axisPtr->flags & (DELETE_PENDING|AXIS_USE)) != AXIS_USE)) continue; - } + if (axisPtr->flags & AXIS_SHOWTICKS) { Blt_ChainLink link; diff --git a/src/bltGrAxis.h b/src/bltGrAxis.h index 27cfe82..92cc7b9 100644 --- a/src/bltGrAxis.h +++ b/src/bltGrAxis.h @@ -37,173 +37,115 @@ #include "bltList.h" -/* - *--------------------------------------------------------------------------- - * - * Grid -- - * - * Contains attributes of describing how to draw grids (at major ticks) - * in the graph. Grids may be mapped to either/both X and Y axis. - * - *--------------------------------------------------------------------------- - */ typedef struct { - Blt_Dashes dashes; /* Dash style of the grid. This represents an + Blt_Dashes dashes; /* Dash style of the grid. This represents an * array of alternatingly drawn pixel * values. */ - int lineWidth; /* Width of the grid lines */ - XColor* color; /* Color of the grid lines */ - GC gc; /* Graphics context for the grid. */ - - Segment2d *segments; /* Array of line segments representing the - * grid lines */ - int nUsed; /* # of axis segments in use. */ - int nAllocated; /* # of axis segments allocated. */ + int lineWidth; /* Width of the grid lines */ + XColor* color; /* Color of the grid lines */ + GC gc; /* Graphics context for the grid. */ + + Segment2d *segments; /* Array of line segments representing the + * grid lines */ + int nUsed; /* # of axis segments in use. */ + int nAllocated; /* # of axis segments allocated. */ } Grid; -/* - *--------------------------------------------------------------------------- - * - * AxisRange -- - * - * Designates a range of values by a minimum and maximum limit. - * - *--------------------------------------------------------------------------- - */ typedef struct { - double min, max, range, scale; + double min, max, range, scale; } AxisRange; -/* - *--------------------------------------------------------------------------- - * - * TickLabel -- - * - * Structure containing the X-Y screen coordinates of the tick - * label (anchored at its center). - * - *--------------------------------------------------------------------------- - */ typedef struct { - Point2d anchorPos; - unsigned int width, height; - char string[1]; + Point2d anchorPos; + unsigned int width, height; + char string[1]; } TickLabel; -/* - *--------------------------------------------------------------------------- - * - * Ticks -- - * - * Structure containing information where the ticks (major or - * minor) will be displayed on the graph. - * - *--------------------------------------------------------------------------- - */ typedef struct { - unsigned int nTicks; /* # of ticks on axis */ - double values[1]; /* Array of tick values (malloc-ed). */ + unsigned int nTicks; /* # of ticks on axis */ + double values[1]; /* Array of tick values (malloc-ed). */ } Ticks; -/* - *--------------------------------------------------------------------------- - * - * TickSweep -- - * - * Structure containing information where the ticks (major or - * minor) will be displayed on the graph. - * - *--------------------------------------------------------------------------- - */ typedef struct { - double initial; /* Initial value */ - double step; /* Size of interval */ - unsigned int nSteps; /* Number of intervals. */ + double initial; /* Initial value */ + double step; /* Size of interval */ + unsigned int nSteps; /* Number of intervals. */ } TickSweep; -/* - *--------------------------------------------------------------------------- - * - * Axis -- - * - * Structure contains options controlling how the axis will be - * displayed. - * - *--------------------------------------------------------------------------- - */ typedef struct { - GraphObj obj; /* Must be first field in axis. */ + GraphObj obj; /* Must be first field in axis. */ - unsigned int flags; + int hide; + unsigned int flags; - Tcl_HashEntry *hashPtr; + Tcl_HashEntry *hashPtr; - /* Fields specific to axes. */ + /* Fields specific to axes. */ - const char *detail; + const char *detail; - int refCount; /* Number of elements referencing this - * axis. */ - int logScale; /* If non-zero, generate log scale - * ticks for the axis. */ - int timeScale; /* If non-zero, generate time scale + int refCount; /* Number of elements referencing this + * axis. */ + int logScale; /* If non-zero, generate log scale + * ticks for the axis. */ + int timeScale; /* If non-zero, generate time scale * ticks for the axis. This option is * overridden by -logscale. */ - int descending; /* If non-zero, display the range of + int descending; /* If non-zero, display the range of * values on the axis in descending * order, from high to low. */ - int looseMin, looseMax; /* If non-zero, axis range extends to + int looseMin, looseMax; /* If non-zero, axis range extends to * the outer major ticks, otherwise at * the limits of the data values. This * is overriddened by setting the -min * and -max options. */ - const char *title; /* Title of the axis. */ + const char *title; /* Title of the axis. */ - int titleAlternate; /* Indicates whether to position the + int titleAlternate; /* Indicates whether to position the * title above/left of the axis. */ - Point2d titlePos; /* Position of the title */ + Point2d titlePos; /* Position of the title */ - unsigned short int titleWidth, titleHeight; + unsigned short int titleWidth, titleHeight; - int lineWidth; /* Width of lines representing axis + int lineWidth; /* Width of lines representing axis * (including ticks). If zero, then * no axis lines or ticks are * drawn. */ - const char **limitsFormats; /* One or two strings of sprintf-like + const char **limitsFormats; /* One or two strings of sprintf-like * formats describing how to display * virtual axis limits. If NULL, * display no limits. */ - int nFormats; + int nFormats; - TextStyle limitsTextStyle; /* Text attributes (color, font, + TextStyle limitsTextStyle; /* Text attributes (color, font, * rotation, etc.) of the limits. */ - double windowSize; /* Size of a sliding window of values + double windowSize; /* Size of a sliding window of values * used to scale the axis * automatically as new data values * are added. The axis will always * display the latest values in this * range. */ - double shiftBy; /* Shift maximum by this interval. */ + double shiftBy; /* Shift maximum by this interval. */ - int tickLength; /* Length of major ticks in pixels */ + int tickLength; /* Length of major ticks in pixels */ - const char *formatCmd; /* Specifies a TCL command, to be + const char *formatCmd; /* Specifies a TCL command, to be * invoked by the axis whenever it has * to generate tick labels. */ - Tcl_Obj *scrollCmdObjPtr; - int scrollUnits; + Tcl_Obj *scrollCmdObjPtr; + int scrollUnits; - double min, max; /* The actual axis range. */ + double min, max; /* The actual axis range. */ - double reqMin, reqMax; /* Requested axis bounds. Consult the + double reqMin, reqMax; /* Requested axis bounds. Consult the * axisPtr->flags field for * AXIS_CONFIG_MIN and AXIS_CONFIG_MAX * to see if the requested bound have @@ -211,126 +153,113 @@ typedef struct { * computed range of the axis * (determined by auto-scaling). */ - double reqScrollMin, reqScrollMax; + double reqScrollMin, reqScrollMax; - double scrollMin, scrollMax; /* Defines the scrolling reqion of the - * axis. Normally the region is - * determined from the data limits. If - * specified, these values override - * the data-range. */ + double scrollMin, scrollMax; /* Defines the scrolling reqion of the + * axis. Normally the region is + * determined from the data limits. If + * specified, these values override + * the data-range. */ - AxisRange valueRange; /* Range of data values of elements - * mapped to this axis. This is used - * to auto-scale the axis in "tight" - * mode. */ - AxisRange axisRange; /* Smallest and largest major tick - * values for the axis. The tick - * values lie outside the range of - * data values. This is used to - * auto-scale the axis in "loose" - * mode. */ + AxisRange valueRange; /* Range of data values of elements + * mapped to this axis. This is used + * to auto-scale the axis in "tight" + * mode. */ + AxisRange axisRange; /* Smallest and largest major tick + * values for the axis. The tick + * values lie outside the range of + * data values. This is used to + * auto-scale the axis in "loose" + * mode. */ - double prevMin, prevMax; + double prevMin, prevMax; - double reqStep; /* If > 0.0, overrides the computed major + double reqStep; /* If > 0.0, overrides the computed major * tick interval. Otherwise a stepsize * is automatically calculated, based * upon the range of elements mapped to the * axis. The default value is 0.0. */ - Ticks *t1Ptr; /* Array of major tick positions. May be - * set by the user or generated from the - * major sweep below. */ + Ticks *t1Ptr; /* Array of major tick positions. May be + * set by the user or generated from the + * major sweep below. */ - Ticks *t2Ptr; /* Array of minor tick positions. May be - * set by the user or generated from the - * minor sweep below. */ + Ticks *t2Ptr; /* Array of minor tick positions. May be + * set by the user or generated from the + * minor sweep below. */ - TickSweep minorSweep, majorSweep; + TickSweep minorSweep, majorSweep; - int reqNumMajorTicks; /* Default number of ticks to be displayed. */ - int reqNumMinorTicks; /* If non-zero, represents the - * requested the number of minor ticks - * to be uniformally displayed along - * each major tick. */ + int reqNumMajorTicks; /* Default number of ticks to be displayed. */ + int reqNumMinorTicks; /* If non-zero, represents the + * requested the number of minor ticks + * to be uniformally displayed along + * each major tick. */ - int labelOffset; /* If non-zero, indicates that the tick + int labelOffset; /* If non-zero, indicates that the tick * label should be offset to sit in the * middle of the next interval. */ - /* The following fields are specific to logical axes */ - - int margin; /* Margin that contains this axis. */ - Blt_ChainLink link; /* Axis link in margin list. */ - Blt_Chain chain; - Segment2d *segments; /* Array of line segments representing - * the major and minor ticks, but also - * the * axis line itself. The segment - * coordinates * are relative to the - * axis. */ - int nSegments; /* Number of segments in the above + /* The following fields are specific to logical axes */ + + int margin; /* Margin that contains this axis. */ + Blt_ChainLink link; /* Axis link in margin list. */ + Blt_Chain chain; + Segment2d *segments; /* Array of line segments representing + * the major and minor ticks, but also + * the * axis line itself. The segment + * coordinates * are relative to the + * axis. */ + int nSegments; /* Number of segments in the above * array. */ - Blt_Chain tickLabels; /* Contains major tick label strings - * and their offsets along the - * axis. */ - short int left, right, top, bottom; /* Region occupied by the of axis. */ - short int width, height; /* Extents of axis */ - short int maxTickWidth, maxTickHeight; - Tk_3DBorder normalBg; - XColor* activeFgColor; - - int relief; - int borderWidth; - int activeRelief; - - double tickAngle; - Tk_Font tickFont; - Tk_Anchor tickAnchor; - Tk_Anchor reqTickAnchor; - XColor* tickColor; - GC tickGC; /* Graphics context for axis and tick + Blt_Chain tickLabels; /* Contains major tick label strings + * and their offsets along the + * axis. */ + short int left, right, top, bottom; /* Region occupied by the of axis. */ + short int width, height; /* Extents of axis */ + short int maxTickWidth, maxTickHeight; + Tk_3DBorder normalBg; + XColor* activeFgColor; + + int relief; + int borderWidth; + int activeRelief; + + double tickAngle; + Tk_Font tickFont; + Tk_Anchor tickAnchor; + Tk_Anchor reqTickAnchor; + XColor* tickColor; + GC tickGC; /* Graphics context for axis and tick * labels */ - GC activeTickGC; + GC activeTickGC; - double titleAngle; - Tk_Font titleFont; - Tk_Anchor titleAnchor; - Tk_Justify titleJustify; - XColor* titleColor; + double titleAngle; + Tk_Font titleFont; + Tk_Anchor titleAnchor; + Tk_Justify titleJustify; + XColor* titleColor; - Grid major, minor; /* Axis grid information. */ + Grid major, minor; /* Axis grid information. */ - double screenScale; - int screenMin, screenRange; + double screenScale; + int screenMin, screenRange; } Axis; -/* - *--------------------------------------------------------------------------- - * - * Axis2d -- - * - * The pair of axes mapping a point onto the graph. - * - *--------------------------------------------------------------------------- - */ typedef struct { - Axis *x, *y; + Axis *x, *y; } Axis2d; -/* Axis flags: */ - #define AXIS_AUTO_MAJOR (1<<16) /* Auto-generate major ticks. */ #define AXIS_AUTO_MINOR (1<<17) /* Auto-generate minor ticks. */ -#define AXIS_ONSCREEN (1<<18) /* Axis is displayed on the screen via +#define AXIS_USE (1<<18) /* Axis is displayed on the screen via * the "use" operation */ #define AXIS_GRID (1<<19) #define AXIS_GRID_MINOR (1<<20) -#define AXIS_TICKS (1<<21) -#define AXIS_TICKS_INTERIOR (1<<22) +#define AXIS_SHOWTICKS (1<<21) +#define AXIS_EXTERIOR (1<<22) #define AXIS_CHECK_LIMITS (1<<23) -#define AXIS_LOGSCALE (1<<24) -#define AXIS_DECREASING (1<<25) #endif /* _BLT_GR_AXIS_H */ diff --git a/src/bltGrLegd.C b/src/bltGrLegd.C index 5f08907..8a60683 100644 --- a/src/bltGrLegd.C +++ b/src/bltGrLegd.C @@ -51,8 +51,7 @@ * SELECT_SET Set selection flag of entry. * * SELECT_TOGGLE Toggle selection flag of entry. - * - * SELECT_BLTMASK Mask of selection set/clear/toggle flags. + * Mask of selection set/clear/toggle flags. * * SELECT_SORTED Indicates if the entries in the selection * should be sorted or displayed in the order @@ -60,12 +59,11 @@ * */ -#define SELECT_CLEAR (1<<16) -#define SELECT_PENDING (1<<18) -#define SELECT_SET (1<<19) +#define SELECT_CLEAR (1<<24) +#define SELECT_PENDING (1<<25) +#define SELECT_SET (1<<26) +#define SELECT_SORTED (1<<27) #define SELECT_TOGGLE (SELECT_SET | SELECT_CLEAR) -#define SELECT_BLTMASK (SELECT_SET | SELECT_CLEAR) -#define SELECT_SORTED (1<<20) #define LABEL_PAD 2 @@ -963,7 +961,7 @@ static int SelectionMarkOp(Graph* graphPtr, Tcl_Interp* interp, } DeselectElement(legendPtr, selectPtr); } - legendPtr->flags &= ~SELECT_BLTMASK; + legendPtr->flags &= ~SELECT_TOGGLE; legendPtr->flags |= SELECT_SET; SelectRange(legendPtr, legendPtr->selAnchorPtr, elemPtr); Tcl_SetStringObj(Tcl_GetObjResult(interp), elemPtr->obj.name, -1); @@ -995,7 +993,7 @@ static int SelectionSetOp(Graph* graphPtr, Tcl_Interp* interp, Element *firstPtr, *lastPtr; const char *string; - legendPtr->flags &= ~SELECT_BLTMASK; + legendPtr->flags &= ~SELECT_TOGGLE; string = Tcl_GetString(objv[3]); switch (string[0]) { case 's': @@ -1011,7 +1009,7 @@ static int SelectionSetOp(Graph* graphPtr, Tcl_Interp* interp, if (GetElementFromObj(graphPtr, objv[4], &firstPtr) != TCL_OK) { return TCL_ERROR; } - if ((firstPtr->flags & HIDE) && ((legendPtr->flags & SELECT_CLEAR)==0)) { + if ((firstPtr->hide) && ((legendPtr->flags & SELECT_CLEAR)==0)) { Tcl_AppendResult(interp, "can't select hidden node \"", Tcl_GetString(objv[4]), "\"", (char *)NULL); return TCL_ERROR; @@ -1021,8 +1019,7 @@ static int SelectionSetOp(Graph* graphPtr, Tcl_Interp* interp, if (GetElementFromObj(graphPtr, objv[5], &lastPtr) != TCL_OK) { return TCL_ERROR; } - if ((lastPtr->flags & HIDE) && - ((legendPtr->flags & SELECT_CLEAR) == 0)) { + if (lastPtr->hide && ((legendPtr->flags & SELECT_CLEAR) == 0)) { Tcl_AppendResult(interp, "can't select hidden node \"", Tcl_GetString(objv[5]), "\"", (char *)NULL); return TCL_ERROR; @@ -1340,7 +1337,7 @@ static void SelectEntry(Legend *legendPtr, Element* elemPtr) { Tcl_HashEntry *hPtr; - switch (legendPtr->flags & SELECT_BLTMASK) { + switch (legendPtr->flags & SELECT_TOGGLE) { case SELECT_CLEAR: DeselectElement(legendPtr, elemPtr); break; |