diff options
author | joye <joye> | 2014-03-03 20:04:47 (GMT) |
---|---|---|
committer | joye <joye> | 2014-03-03 20:04:47 (GMT) |
commit | 46712b55900a85512f51c9e915fe2b32b9ce7ae5 (patch) | |
tree | a0c106059636d0d36bb9d50331e8a4c3d49337f9 /src | |
parent | 8a6d6847c88cdc585f7d77bb9ead010c45bd8283 (diff) | |
download | blt-46712b55900a85512f51c9e915fe2b32b9ce7ae5.zip blt-46712b55900a85512f51c9e915fe2b32b9ce7ae5.tar.gz blt-46712b55900a85512f51c9e915fe2b32b9ce7ae5.tar.bz2 |
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r-- | src/bltGrAxis.C | 2104 | ||||
-rw-r--r-- | src/bltGrAxis.h | 1 | ||||
-rw-r--r-- | src/bltGrBind.C | 2 | ||||
-rw-r--r-- | src/bltGrElemOp.C | 65 | ||||
-rw-r--r-- | src/bltGrHairs.C | 37 | ||||
-rw-r--r-- | src/bltGrLegd.C | 77 | ||||
-rw-r--r-- | src/bltGrLegd.h | 2 | ||||
-rw-r--r-- | src/bltGrMarker.C | 28 | ||||
-rw-r--r-- | src/bltGrPenOp.C | 54 | ||||
-rw-r--r-- | src/bltGraph.C | 53 | ||||
-rw-r--r-- | src/bltGraph.h | 20 | ||||
-rw-r--r-- | src/bltOp.h | 2 | ||||
-rw-r--r-- | src/bltSwitch.C | 2 | ||||
-rw-r--r-- | src/bltVecCmd.C | 66 | ||||
-rw-r--r-- | src/bltVector.C | 14 |
15 files changed, 1235 insertions, 1292 deletions
diff --git a/src/bltGrAxis.C b/src/bltGrAxis.C index d4cd041..c601d98 100644 --- a/src/bltGrAxis.C +++ b/src/bltGrAxis.C @@ -95,6 +95,17 @@ static int nAxisNames = sizeof(axisNames) / sizeof(AxisName); // Defs +static int GetAxisScrollInfo(Tcl_Interp* interp, int objc, Tcl_Obj* const objv[], + double *offsetPtr, double windowSize, + double scrollUnits, double scale); +static double Clamp(double x); +static int GetAxisFromObj(Tcl_Interp* interp, Graph* graphPtr, Tcl_Obj *objPtr, + Axis **axisPtrPtr); +static int AxisIsHorizontal(Axis *axisPtr); +static void FreeTickLabels(Blt_Chain chain); +static int ConfigureAxis(Axis *axisPtr); +static Blt_ConfigSpec configSpecs[]; +static Axis *NewAxis(Graph* graphPtr, const char *name, int margin); static void FreeTicksProc(ClientData clientData, Display *display, char *widgRec, int offset); static void ReleaseAxis(Axis *axisPtr); @@ -105,10 +116,10 @@ static Tcl_FreeProc FreeAxis; static void TimeScaleAxis(Axis *axisPtr, double min, double max); static int lastMargin; -typedef int (GraphAxisProc)(Tcl_Interp* interp, Axis *axisPtr, int objc, - Tcl_Obj *const *objv); -typedef int (GraphVirtualAxisProc)(Tcl_Interp* interp, Graph* graphPtr, - int objc, Tcl_Obj *const *objv); +typedef int (GraphDefAxisProc)(Tcl_Interp* interp, Axis *axisPtr, + int objc, Tcl_Obj* const objv[]); +typedef int (GraphAxisProc)(Tcl_Interp* interp, Graph* graphPtr, + int objc, Tcl_Obj* const objv[]); // OptionSpecs @@ -509,238 +520,806 @@ static Tk_OptionSpec optionSpecs[] = { {TK_OPTION_END, NULL, NULL, NULL, NULL, -1, 0, 0, NULL, 0} }; -static Blt_OptionParseProc ObjToLimitProc; -static Blt_OptionPrintProc LimitToObjProc; -static Blt_CustomOption limitOption = { - ObjToLimitProc, LimitToObjProc, NULL, (ClientData)0 -}; +// Create -static Blt_OptionFreeProc FreeTicksProc; -static Blt_OptionParseProc ObjToTicksProc; -static Blt_OptionPrintProc TicksToObjProc; -static Blt_CustomOption majorTicksOption = { - ObjToTicksProc, TicksToObjProc, FreeTicksProc, (ClientData)AXIS_AUTO_MAJOR, -}; -static Blt_CustomOption minorTicksOption = { - ObjToTicksProc, TicksToObjProc, FreeTicksProc, (ClientData)AXIS_AUTO_MINOR, -}; -static Blt_OptionFreeProc FreeAxisProc; -static Blt_OptionPrintProc AxisToObjProc; -static Blt_OptionParseProc ObjToAxisProc; -Blt_CustomOption bltXAxisOption = { - ObjToAxisProc, AxisToObjProc, FreeAxisProc, (ClientData)CID_AXIS_X -}; -Blt_CustomOption bltYAxisOption = { - ObjToAxisProc, AxisToObjProc, FreeAxisProc, (ClientData)CID_AXIS_Y -}; +int Blt_CreateAxes(Graph* graphPtr) +{ + int flags = Blt_GraphType(graphPtr); + for (int ii = 0; ii < 4; ii++) { + Blt_Chain chain = Blt_Chain_Create(); + graphPtr->axisChain[ii] = chain; -static Blt_OptionFreeProc FreeFormatProc; -static Blt_OptionParseProc ObjToFormatProc; -static Blt_OptionPrintProc FormatToObjProc; -static Blt_CustomOption formatOption = { - ObjToFormatProc, FormatToObjProc, FreeFormatProc, (ClientData)0, -}; -static Blt_OptionParseProc ObjToLooseProc; -static Blt_OptionPrintProc LooseToObjProc; -static Blt_CustomOption looseOption = { - ObjToLooseProc, LooseToObjProc, NULL, (ClientData)0, -}; + Axis* axisPtr = NewAxis(graphPtr, axisNames[ii].name, ii); + if (!axisPtr) + return TCL_ERROR; -static Blt_OptionParseProc ObjToUseProc; -static Blt_OptionPrintProc UseToObjProc; -static Blt_CustomOption useOption = { - ObjToUseProc, UseToObjProc, NULL, (ClientData)0 + axisPtr->refCount = 1; /* Default axes are assumed in use. */ + axisPtr->margin = ii; + axisPtr->flags |= AXIS_USE; + Blt_GraphSetObjectClass(&axisPtr->obj, axisNames[ii].classId); + /* + * Blt_ConfigureComponentFromObj creates a temporary child window + * by the name of the axis. It's used so that the Tk routines + * that access the X resource database can describe a single + * component and not the entire graph. + */ + if (Blt_ConfigureComponentFromObj(graphPtr->interp, graphPtr->tkwin, + axisPtr->obj.name, "Axis", + configSpecs, 0, (Tcl_Obj **)NULL, + (char*)axisPtr, flags) != TCL_OK) { + return TCL_ERROR; + } + if (ConfigureAxis(axisPtr) != TCL_OK) + return TCL_ERROR; + + axisPtr->link = Blt_Chain_Append(chain, axisPtr); + axisPtr->chain = chain; + } + return TCL_OK; +} + +static int CreateAxis(Tcl_Interp* interp, Graph* graphPtr, + int objc, Tcl_Obj* const objv[]) +{ + char *string = Tcl_GetString(objv[3]); + if (string[0] == '-') { + Tcl_AppendResult(graphPtr->interp, "name of axis \"", string, + "\" can't start with a '-'", NULL); + return TCL_ERROR; + } + + int isNew; + Tcl_HashEntry* hPtr = + Tcl_CreateHashEntry(&graphPtr->axes.table, string, &isNew); + if (!isNew) { + Tcl_AppendResult(graphPtr->interp, "axis \"", string, + "\" already exists in \"", Tcl_GetString(objv[0]), + "\"", NULL); + return TCL_ERROR; + } + + Axis* axisPtr = NewAxis(graphPtr, Tcl_GetString(objv[3]), MARGIN_NONE); + if (axisPtr == NULL) + return TCL_ERROR; + + if ((Tk_InitOptions(graphPtr->interp, (char*)axisPtr, axisPtr->optionTable, graphPtr->tkwin) != TCL_OK) || (AxisObjConfigure(interp, graphPtr, axisPtr, objc-4, objv+4) != TCL_OK)) { + DestroyAxis(axisPtr); + return TCL_ERROR; + } + + axisPtr->hashPtr = hPtr; + Tcl_SetHashValue(hPtr, axisPtr); + + graphPtr->flags |= CACHE_DIRTY; + Blt_EventuallyRedrawGraph(graphPtr); + + return TCL_OK; +} + +static Axis *NewAxis(Graph* graphPtr, const char *name, int margin) +{ + Axis *axisPtr = calloc(1, sizeof(Axis)); + axisPtr->obj.name = Blt_Strdup(name); + Blt_GraphSetObjectClass(&axisPtr->obj, CID_NONE); + axisPtr->obj.graphPtr = graphPtr; + axisPtr->looseMin = AXIS_TIGHT; + axisPtr->looseMax = AXIS_TIGHT; + axisPtr->reqNumMinorTicks = 2; + axisPtr->reqNumMajorTicks = 4; + axisPtr->margin = margin; + axisPtr->tickLength = 8; + axisPtr->scrollUnits = 10; + axisPtr->reqMin = NAN; + axisPtr->reqMax = NAN; + axisPtr->reqScrollMin = NAN; + axisPtr->reqScrollMax = NAN; + axisPtr->flags = (AXIS_AUTO_MAJOR|AXIS_AUTO_MINOR); + axisPtr->exterior =1; + axisPtr->hide =0; + axisPtr->showTicks =1; + axisPtr->showGridMinor =1; + axisPtr->showGrid =1; + axisPtr->checkLimits =0; + + if ((graphPtr->classId == CID_ELEM_BAR) && + ((margin == MARGIN_TOP) || (margin == MARGIN_BOTTOM))) { + axisPtr->reqStep = 1.0; + axisPtr->reqNumMinorTicks = 0; + } + if ((margin == MARGIN_RIGHT) || (margin == MARGIN_TOP)) + axisPtr->hide = 1; + + Blt_Ts_InitStyle(axisPtr->limitsTextStyle); + axisPtr->tickLabels = Blt_Chain_Create(); + axisPtr->lineWidth = 1; + + axisPtr->optionTable = + Tk_CreateOptionTable(graphPtr->interp, axisOptionSpecs); + return axisPtr; +} + +static void DestroyAxis(Axis *axisPtr) +{ + Graph* graphPtr = axisPtr->obj.graphPtr; + + if (graphPtr->bindTable) + Blt_DeleteBindings(graphPtr->bindTable, axisPtr); + + if (axisPtr->link) + Blt_Chain_DeleteLink(axisPtr->chain, axisPtr->link); + + if (axisPtr->obj.name) + free((void*)(axisPtr->obj.name)); + + if (axisPtr->hashPtr) + Tcl_DeleteHashEntry(axisPtr->hashPtr); + + Blt_Ts_FreeStyle(graphPtr->display, &axisPtr->limitsTextStyle); + + if (axisPtr->tickGC) + Tk_FreeGC(graphPtr->display, axisPtr->tickGC); + + if (axisPtr->activeTickGC) + Tk_FreeGC(graphPtr->display, axisPtr->activeTickGC); + + if (axisPtr->major.gc) + Blt_FreePrivateGC(graphPtr->display, axisPtr->major.gc); + + if (axisPtr->minor.gc) + Blt_FreePrivateGC(graphPtr->display, axisPtr->minor.gc); + + FreeTickLabels(axisPtr->tickLabels); + + Blt_Chain_Destroy(axisPtr->tickLabels); + + if (axisPtr->segments) + free(axisPtr->segments); + + Tk_FreeConfigOptions((char*)axisPtr, axisPtr->optionTable, graphPtr->tkwin); + free(axisPtr); +} + +// Configure + +static int CgetOp(Tcl_Interp* interp, Axis *axisPtr, + int objc, Tcl_Obj* const objv[]) +{ + Graph* graphPtr = axisPtr->obj.graphPtr; + + if (objc != 4) { + Tcl_WrongNumArgs(interp, 2, objv, "cget option"); + return TCL_ERROR; + } + + Tcl_Obj* objPtr = Tk_GetOptionValue(interp, (char*)axisPtr, + axisPtr->optionTable, + objv[3], graphPtr->tkwin); + if (objPtr == NULL) + return TCL_ERROR; + else + Tcl_SetObjResult(interp, objPtr); + return TCL_OK; +} + +static int AxisCgetOp(Tcl_Interp* interp, Graph* graphPtr, + int objc, Tcl_Obj* const objv[]) +{ + Axis *axisPtr; + if (GetAxisFromObj(interp, graphPtr, objv[3], &axisPtr) != TCL_OK) + return TCL_ERROR; + + return CgetOp(interp, axisPtr, objc-1, objv+1); +} + +static int ConfigureOp(Tcl_Interp* interp, Axis *axisPtr, + int objc, Tcl_Obj* const objv[]) +{ + Graph* graphPtr = axisPtr->obj.graphPtr; + + if (objc <= 4) { + Tcl_Obj* objPtr = Tk_GetOptionInfo(graphPtr->interp, (char*)axisPtr, + axisPtr->optionTable, + (objc == 4) ? objv[3] : NULL, + graphPtr->tkwin); + if (objPtr == NULL) + return TCL_ERROR; + else + Tcl_SetObjResult(interp, objPtr); + return TCL_OK; + } + else + return AxisObjConfigure(interp, graphPtr, axisPtr, objc-3, objv+3); +} + +static int AxisConfigureOp(Tcl_Interp* interp, Graph* graphPtr, int objc, + Tcl_Obj* const objv[]) +{ + Axis *axisPtr; + if (GetAxisFromObj(interp, graphPtr, objv[3], &axisPtr) != TCL_OK) + return TCL_ERROR; + + return ConfigureOp(interp, axisPtr, objc-1, objv+1); +} + +static int AxisObjConfigure(Tcl_Interp* interp, Graph* graphPtr, Axis* axis, + int objc, Tcl_Obj* const objv[]) +{ + Tk_SavedOptions savedOptions; + int mask =0; + int error; + Tcl_Obj* errorResult; + + for (error=0; error<=1; error++) { + if (!error) { + if (Tk_SetOptions(interp, (char*)axisPtr, axisPtr->optionTable, + objc, objv, graphPtr->tkwin, &savedOptions, &mask) + != TCL_OK) + continue; + } + else { + errorResult = Tcl_GetObjResult(interp); + Tcl_IncrRefCount(errorResult); + Tk_RestoreSavedOptions(&savedOptions); + } + + graphPtr->flags |= mask; + graphPtr->flags |= CACHE_DIRTY; + ConfigureAxis(graphPtr, axisPtr); + Blt_EventuallyRedrawGraph(graphPtr); + + break; + } + + if (!error) { + Tk_FreeSavedOptions(&savedOptions); + return TCL_OK; + } + else { + Tcl_SetObjResult(interp, errorResult); + Tcl_DecrRefCount(errorResult); + return TCL_ERROR; + } +} + +// Ops + +static int ActivateOp(Tcl_Interp* interp, Axis *axisPtr, + int objc, Tcl_Obj* const objv[]) +{ + Graph* graphPtr = axisPtr->obj.graphPtr; + const char *string; + + string = Tcl_GetString(objv[2]); + if (string[0] == 'a') + axisPtr->flags |= ACTIVE; + else + axisPtr->flags &= ~ACTIVE; + + if (!axisPtr->hide && (axisPtr->flags & AXIS_USE)) { + graphPtr->flags |= DRAW_MARGINS | CACHE_DIRTY; + Blt_EventuallyRedrawGraph(graphPtr); + } + + return TCL_OK; +} + +static int BindOp(Tcl_Interp* interp, Axis *axisPtr, + int objc, Tcl_Obj* const objv[]) +{ + Graph* graphPtr = axisPtr->obj.graphPtr; + + return Blt_ConfigureBindingsFromObj(interp, graphPtr->bindTable, Blt_MakeAxisTag(graphPtr, axisPtr->obj.name), objc-3, objv+3); +} + +static int InvTransformOp(Tcl_Interp* interp, Axis *axisPtr, + int objc, Tcl_Obj* const objv[]) +{ + Graph* graphPtr = axisPtr->obj.graphPtr; + + if (graphPtr->flags & RESET_AXES) + Blt_ResetAxes(graphPtr); + + int sy; + if (Tcl_GetIntFromObj(interp, objv[3], &sy) != TCL_OK) + return TCL_ERROR; + + /* + * Is the axis vertical or horizontal? + * + * Check the site where the axis was positioned. If the axis is + * virtual, all we have to go on is how it was mapped to an + * element (using either -mapx or -mapy options). + */ + double y; + if (AxisIsHorizontal(axisPtr)) + y = Blt_InvHMap(axisPtr, (double)sy); + else + y = Blt_InvVMap(axisPtr, (double)sy); + + Tcl_SetDoubleObj(Tcl_GetObjResult(interp), y); + return TCL_OK; +} + +static int LimitsOp(Tcl_Interp* interp, Axis *axisPtr, + int objc, Tcl_Obj* const objv[]) +{ + Graph* graphPtr = axisPtr->obj.graphPtr; + + if (graphPtr->flags & RESET_AXES) + Blt_ResetAxes(graphPtr); + + double min, max; + if (axisPtr->logScale) { + min = EXP10(axisPtr->axisRange.min); + max = EXP10(axisPtr->axisRange.max); + } + else { + min = axisPtr->axisRange.min; + max = axisPtr->axisRange.max; + } + + Tcl_Obj *listObjPtr = Tcl_NewListObj(0, (Tcl_Obj **)NULL); + Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewDoubleObj(min)); + Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewDoubleObj(max)); + + Tcl_SetObjResult(interp, listObjPtr); + return TCL_OK; +} + +static int MarginOp(Tcl_Interp* interp, Axis *axisPtr, + int objc, Tcl_Obj* const objv[]) +{ + const char *marginName = ""; + if (axisPtr->flags & AXIS_USE) + marginName = axisNames[axisPtr->margin].name; + + Tcl_SetStringObj(Tcl_GetObjResult(interp), marginName, -1); + return TCL_OK; +} + +static int TransformOp(Tcl_Interp* interp, Axis *axisPtr, + int objc, Tcl_Obj* const objv[]) +{ + Graph* graphPtr = axisPtr->obj.graphPtr; + + if (graphPtr->flags & RESET_AXES) + Blt_ResetAxes(graphPtr); + + double x; + if (Blt_ExprDoubleFromObj(interp, objv[3], &x) != TCL_OK) + return TCL_ERROR; + + if (AxisIsHorizontal(axisPtr)) + x = Blt_HMap(axisPtr, x); + else + x = Blt_VMap(axisPtr, x); + + Tcl_SetIntObj(Tcl_GetObjResult(interp), (int)x); + return TCL_OK; +} + +static int TypeOp(Tcl_Interp* interp, Axis *axisPtr, + int objc, Tcl_Obj* const objv[]) +{ + const char *typeName; + + typeName = ""; + if (axisPtr->flags & AXIS_USE) + if (axisNames[axisPtr->margin].classId == CID_AXIS_X) + typeName = "x"; + else if (axisNames[axisPtr->margin].classId == CID_AXIS_Y) + typeName = "y"; + + Tcl_SetStringObj(Tcl_GetObjResult(interp), typeName, -1); + return TCL_OK; +} + +static int UseOp(Tcl_Interp* interp, Axis *axisPtr, + int objc, Tcl_Obj* const objv[]) +{ + Graph* graphPtr = (Graph *)axisPtr; + + Blt_Chain chain = graphPtr->margins[lastMargin].axes; + if (objc == 0) { + Tcl_Obj *listObjPtr; + + listObjPtr = Tcl_NewListObj(0, (Tcl_Obj **)NULL); + for (Blt_ChainLink link = Blt_Chain_FirstLink(chain); link != NULL; + link = Blt_Chain_NextLink(link)) { + Axis *axisPtr = Blt_Chain_GetValue(link); + Tcl_ListObjAppendElement(interp, listObjPtr, + Tcl_NewStringObj(axisPtr->obj.name, -1)); + } + Tcl_SetObjResult(interp, listObjPtr); + return TCL_OK; + } + ClassId classId; + if ((lastMargin == MARGIN_BOTTOM) || (lastMargin == MARGIN_TOP)) { + classId = (graphPtr->inverted) ? CID_AXIS_Y : CID_AXIS_X; + } else { + classId = (graphPtr->inverted) ? CID_AXIS_X : CID_AXIS_Y; + } + int axisObjc; + Tcl_Obj **axisObjv; + if (Tcl_ListObjGetElements(interp, objv[3], &axisObjc, &axisObjv) + != TCL_OK) { + return TCL_ERROR; + } + for (link = Blt_Chain_FirstLink(chain); link!= NULL; + link = Blt_Chain_NextLink(link)) { + Axis *axisPtr; + + axisPtr = Blt_Chain_GetValue(link); + axisPtr->link = NULL; + axisPtr->flags &= ~AXIS_USE; + /* Clear the axis type if it's not currently used.*/ + if (axisPtr->refCount == 0) { + Blt_GraphSetObjectClass(&axisPtr->obj, CID_NONE); + } + } + Blt_Chain_Reset(chain); + for (int i=0; i<axisObjc; i++) { + Axis *axisPtr; + if (GetAxisFromObj(interp, graphPtr, axisObjv[i], &axisPtr) != TCL_OK) + return TCL_ERROR; + + if (axisPtr->obj.classId == CID_NONE) + Blt_GraphSetObjectClass(&axisPtr->obj, classId); + else if (axisPtr->obj.classId != classId) { + Tcl_AppendResult(interp, "wrong type axis \"", + axisPtr->obj.name, "\": can't use ", + axisPtr->obj.className, " type axis.", NULL); + return TCL_ERROR; + } + if (axisPtr->link != NULL) { + /* Move the axis from the old margin's "use" list to the new. */ + Blt_Chain_UnlinkLink(axisPtr->chain, axisPtr->link); + Blt_Chain_AppendLink(chain, axisPtr->link); + } else { + axisPtr->link = Blt_Chain_Append(chain, axisPtr); + } + axisPtr->chain = chain; + axisPtr->flags |= AXIS_USE; + } + graphPtr->flags |= (GET_AXIS_GEOMETRY | LAYOUT_NEEDED | RESET_AXES); + /* When any axis changes, we need to layout the entire graph. */ + graphPtr->flags |= (MAP_WORLD | REDRAW_WORLD); + Blt_EventuallyRedrawGraph(graphPtr); + + return TCL_OK; +} + +static int ViewOp(Tcl_Interp* interp, Axis *axisPtr, + int objc, Tcl_Obj* const objv[]) +{ + Graph* graphPtr = axisPtr->obj.graphPtr; + double worldMin = axisPtr->valueRange.min; + double worldMax = axisPtr->valueRange.max; + /* Override data dimensions with user-selected limits. */ + if (!isnan(axisPtr->scrollMin)) + worldMin = axisPtr->scrollMin; + + if (!isnan(axisPtr->scrollMax)) + worldMax = axisPtr->scrollMax; + + double viewMin = axisPtr->min; + double viewMax = axisPtr->max; + /* Bound the view within scroll region. */ + if (viewMin < worldMin) + viewMin = worldMin; + + if (viewMax > worldMax) + viewMax = worldMax; + + if (axisPtr->logScale) { + worldMin = log10(worldMin); + worldMax = log10(worldMax); + viewMin = log10(viewMin); + viewMax = log10(viewMax); + } + double worldWidth = worldMax - worldMin; + double viewWidth = viewMax - viewMin; + + /* Unlike horizontal axes, vertical axis values run opposite of the + * scrollbar first/last values. So instead of pushing the axis minimum + * around, we move the maximum instead. */ + double axisOffset; + double axisScale; + if (AxisIsHorizontal(axisPtr) != axisPtr->descending) { + axisOffset = viewMin - worldMin; + axisScale = graphPtr->hScale; + } else { + axisOffset = worldMax - viewMax; + axisScale = graphPtr->vScale; + } + if (objc == 4) { + double first = Clamp(axisOffset / worldWidth); + double last = Clamp((axisOffset + viewWidth) / worldWidth); + Tcl_Obj *listObjPtr = Tcl_NewListObj(0, NULL); + Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewDoubleObj(first)); + Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewDoubleObj(last)); + Tcl_SetObjResult(interp, listObjPtr); + return TCL_OK; + } + double fract = axisOffset / worldWidth; + if (GetAxisScrollInfo(interp, objc, objv, &fract, viewWidth / worldWidth, axisPtr->scrollUnits, axisScale) != TCL_OK) + return TCL_ERROR; + + if (AxisIsHorizontal(axisPtr) != axisPtr->descending) { + axisPtr->reqMin = (fract * worldWidth) + worldMin; + axisPtr->reqMax = axisPtr->reqMin + viewWidth; + } + else { + axisPtr->reqMax = worldMax - (fract * worldWidth); + axisPtr->reqMin = axisPtr->reqMax - viewWidth; + } + if (axisPtr->logScale) { + axisPtr->reqMin = EXP10(axisPtr->reqMin); + axisPtr->reqMax = EXP10(axisPtr->reqMax); + } + graphPtr->flags |= (GET_AXIS_GEOMETRY | LAYOUT_NEEDED | RESET_AXES); + Blt_EventuallyRedrawGraph(graphPtr); + + return TCL_OK; +} + +static Blt_OpSpec defAxisOps[] = { + {"activate", 1, ActivateOp, 3, 3, "",}, + {"bind", 1, BindOp, 2, 5, "sequence command",}, + {"cget", 2, CgetOp, 4, 4, "option",}, + {"configure", 2, ConfigureOp, 3, 0, "?option value?...",}, + {"deactivate", 1, ActivateOp, 3, 3, "",}, + {"invtransform", 1, InvTransformOp, 4, 4, "value",}, + {"limits", 1, LimitsOp, 3, 3, "",}, + {"transform", 1, TransformOp, 4, 4, "value",}, + {"use", 1, UseOp, 3, 4, "?axisName?",}, + {"view", 1, ViewOp, 3, 6, "?moveto fract? ",}, }; -Blt_CustomOption bitmaskGrAxisCheckLimitsOption = - { - ObjToBitmaskProc, BitmaskToObjProc, NULL, (ClientData)AXIS_CHECK_LIMITS - }; +static int nDefAxisOps = sizeof(defAxisOps) / sizeof(Blt_OpSpec); -Blt_CustomOption bitmaskGrAxisExteriorOption = - { - ObjToBitmaskProc, BitmaskToObjProc, NULL, (ClientData)AXIS_EXTERIOR - }; +int Blt_DefAxisOp(Tcl_Interp* interp, Graph* graphPtr, int margin, + int objc, Tcl_Obj* const objv[]) +{ + GraphDefAxisProc* proc = Blt_GetOpFromObj(interp, nDefAxisOps, axisOps, + BLT_OP_ARG2, objc, objv, 0); + if (proc == NULL) + return TCL_ERROR; -Blt_CustomOption bitmaskGrAxisGridOption = - { - ObjToBitmaskProc, BitmaskToObjProc, NULL, (ClientData)AXIS_GRID - }; + if (proc == UseOp) { + // Set global variable to the margin in the argument list + lastMargin = margin; + return (*proc)(interp, (Axis*)graphPtr, objc, objv); + } + else { + Axis* axisPtr = Blt_GetFirstAxis(graphPtr->margins[margin].axes); + if (axisPtr == NULL) + return TCL_OK; + return (*proc)(interp, axisPtr, objc, objv); + } +} -Blt_CustomOption bitmaskGrAxisGridMinorOption = - { - ObjToBitmaskProc, BitmaskToObjProc, NULL, (ClientData)AXIS_GRID_MINOR - }; +static int AxisActivateOp(Tcl_Interp* interp, Graph* graphPtr, + int objc, Tcl_Obj* const objv[]) +{ + Axis *axisPtr; + if (GetAxisFromObj(interp, graphPtr, objv[3], &axisPtr) != TCL_OK) + return TCL_ERROR; -Blt_CustomOption bitmaskGrAxisHideOption = - { - ObjToBitmaskProc, BitmaskToObjProc, NULL, (ClientData)HIDE - }; + return ActivateOp(interp, axisPtr, objc, objv); +} -Blt_CustomOption bitmaskGrAxisShowTicksOption = - { - ObjToBitmaskProc, BitmaskToObjProc, NULL, (ClientData)AXIS_SHOWTICKS - }; +static int AxisBindOp(Tcl_Interp* interp, Graph* graphPtr, int objc, + Tcl_Obj* const objv[]) +{ + if (objc == 3) { + Tcl_Obj *listObjPtr = Tcl_NewListObj(0, (Tcl_Obj **)NULL); + Tcl_HashSearch cursor; + for (Tcl_HashEntry *hPtr = Tcl_FirstHashEntry(&graphPtr->axes.tagTable, &cursor); hPtr != NULL; hPtr = Tcl_NextHashEntry(&cursor)) { + const char *tagName = Tcl_GetHashKey(&graphPtr->axes.tagTable, hPtr); + Tcl_Obj *objPtr = Tcl_NewStringObj(tagName, -1); + Tcl_ListObjAppendElement(interp, listObjPtr, objPtr); + } + Tcl_SetObjResult(interp, listObjPtr); + return TCL_OK; + } + else + return Blt_ConfigureBindingsFromObj(interp, graphPtr->bindTable, Blt_MakeAxisTag(graphPtr, Tcl_GetString(objv[3])), objc-4, objv+4); +} -static Blt_ConfigSpec configSpecs[] = { - {BLT_CONFIG_COLOR, "-activeforeground", "activeForeground", - "ActiveForeground", STD_ACTIVE_FOREGROUND, - Tk_Offset(Axis, activeFgColor), ALL_GRAPHS}, - {BLT_CONFIG_RELIEF, "-activerelief", "activeRelief", "Relief", - "flat", Tk_Offset(Axis, activeRelief), - ALL_GRAPHS | BLT_CONFIG_DONT_SET_DEFAULT}, - {BLT_CONFIG_DOUBLE, "-autorange", "autoRange", "AutoRange", - "0.0", Tk_Offset(Axis, windowSize), - ALL_GRAPHS | BLT_CONFIG_DONT_SET_DEFAULT}, - {BLT_CONFIG_BORDER, "-background", "background", "Background", - NULL, Tk_Offset(Axis, normalBg), - ALL_GRAPHS | BLT_CONFIG_NULL_OK}, - {BLT_CONFIG_SYNONYM, "-bg", "background", NULL, NULL, 0, 0}, - {BLT_CONFIG_CUSTOM, "-bindtags", "bindTags", "BindTags", "all", - Tk_Offset(Axis, obj.tags), ALL_GRAPHS | BLT_CONFIG_NULL_OK, - &listOption}, - {BLT_CONFIG_SYNONYM, "-bd", "borderWidth", NULL, NULL, - 0, ALL_GRAPHS}, - {BLT_CONFIG_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", - "0", Tk_Offset(Axis, borderWidth), - ALL_GRAPHS | BLT_CONFIG_DONT_SET_DEFAULT}, - {BLT_CONFIG_CUSTOM, "-checklimits", "checkLimits", "CheckLimits", - "0", Tk_Offset(Axis, flags), - ALL_GRAPHS | BLT_CONFIG_DONT_SET_DEFAULT, - &bitmaskGrAxisCheckLimitsOption}, - {BLT_CONFIG_COLOR, "-color", "color", "Color", - STD_NORMAL_FOREGROUND, Tk_Offset(Axis, tickColor), ALL_GRAPHS}, - {BLT_CONFIG_STRING, "-command", "command", "Command", - NULL, Tk_Offset(Axis, formatCmd), - BLT_CONFIG_NULL_OK | ALL_GRAPHS}, - {BLT_CONFIG_BOOLEAN, "-descending", "descending", "Descending", - "0", Tk_Offset(Axis, descending), - ALL_GRAPHS | BLT_CONFIG_DONT_SET_DEFAULT}, - {BLT_CONFIG_CUSTOM, "-exterior", "exterior", "exterior", "1", - Tk_Offset(Axis, flags), ALL_GRAPHS | BLT_CONFIG_DONT_SET_DEFAULT, - &bitmaskGrAxisExteriorOption}, - {BLT_CONFIG_SYNONYM, "-fg", "color", NULL, - NULL, 0, ALL_GRAPHS}, - {BLT_CONFIG_SYNONYM, "-foreground", "color", NULL, - NULL, 0, ALL_GRAPHS}, - {BLT_CONFIG_CUSTOM, "-grid", "grid", "Grid", "1", - Tk_Offset(Axis, flags), BARCHART, - &bitmaskGrAxisGridOption}, - {BLT_CONFIG_CUSTOM, "-grid", "grid", "Grid", "1", - Tk_Offset(Axis, flags), GRAPH | STRIPCHART, - &bitmaskGrAxisGridOption}, - {BLT_CONFIG_COLOR, "-gridcolor", "gridColor", "GridColor", - "gray64", Tk_Offset(Axis, major.color), ALL_GRAPHS}, - {BLT_CONFIG_CUSTOM, "-griddashes", "gridDashes", "GridDashes", - "dot", Tk_Offset(Axis, major.dashes), - BLT_CONFIG_NULL_OK | ALL_GRAPHS, &dashesOption}, - {BLT_CONFIG_PIXELS, "-gridlinewidth", "gridLineWidth", - "GridLineWidth", "0", - Tk_Offset(Axis, major.lineWidth), - BLT_CONFIG_DONT_SET_DEFAULT | ALL_GRAPHS}, - {BLT_CONFIG_CUSTOM, "-gridminor", "gridMinor", "GridMinor", - "1", Tk_Offset(Axis, flags), - BLT_CONFIG_DONT_SET_DEFAULT | ALL_GRAPHS, - &bitmaskGrAxisGridMinorOption}, - {BLT_CONFIG_COLOR, "-gridminorcolor", "gridMinorColor", "GridColor", - "gray64", Tk_Offset(Axis, minor.color), ALL_GRAPHS}, - {BLT_CONFIG_CUSTOM, "-gridminordashes", "gridMinorDashes", "GridDashes", - "dot", Tk_Offset(Axis, minor.dashes), - BLT_CONFIG_NULL_OK | ALL_GRAPHS, &dashesOption}, - {BLT_CONFIG_PIXELS, "-gridminorlinewidth", "gridMinorLineWidth", - "GridLineWidth", "0", - Tk_Offset(Axis, minor.lineWidth), - BLT_CONFIG_DONT_SET_DEFAULT | ALL_GRAPHS}, - {BLT_CONFIG_CUSTOM, "-hide", "hide", "Hide", "0", - Tk_Offset(Axis, flags), ALL_GRAPHS | BLT_CONFIG_DONT_SET_DEFAULT, - &bitmaskGrAxisHideOption}, - {BLT_CONFIG_JUSTIFY, "-justify", "justify", "Justify", - "c", Tk_Offset(Axis, titleJustify), - ALL_GRAPHS | BLT_CONFIG_DONT_SET_DEFAULT}, - {BLT_CONFIG_BOOLEAN, "-labeloffset", "labelOffset", "LabelOffset", - "no", Tk_Offset(Axis, labelOffset), ALL_GRAPHS}, - {BLT_CONFIG_COLOR, "-limitscolor", "limitsColor", "Color", - STD_NORMAL_FOREGROUND, Tk_Offset(Axis, limitsTextStyle.color), - ALL_GRAPHS}, - {BLT_CONFIG_FONT, "-limitsfont", "limitsFont", "Font", STD_FONT_SMALL, - Tk_Offset(Axis, limitsTextStyle.font), ALL_GRAPHS}, - {BLT_CONFIG_CUSTOM, "-limitsformat", "limitsFormat", "LimitsFormat", - NULL, Tk_Offset(Axis, limitsFormats), - BLT_CONFIG_NULL_OK | ALL_GRAPHS, &formatOption}, - {BLT_CONFIG_PIXELS, "-linewidth", "lineWidth", "LineWidth", - "1", Tk_Offset(Axis, lineWidth), - ALL_GRAPHS | BLT_CONFIG_DONT_SET_DEFAULT}, - {BLT_CONFIG_BOOLEAN, "-logscale", "logScale", "LogScale", - "0", Tk_Offset(Axis, logScale), - ALL_GRAPHS | BLT_CONFIG_DONT_SET_DEFAULT}, - {BLT_CONFIG_CUSTOM, "-loose", "loose", "Loose", "0", 0, - ALL_GRAPHS | BLT_CONFIG_DONT_SET_DEFAULT, &looseOption}, - {BLT_CONFIG_CUSTOM, "-majorticks", "majorTicks", "MajorTicks", - NULL, Tk_Offset(Axis, t1Ptr), - BLT_CONFIG_NULL_OK | ALL_GRAPHS, &majorTicksOption}, - {BLT_CONFIG_CUSTOM, "-max", "max", "Max", NULL, - Tk_Offset(Axis, reqMax), ALL_GRAPHS, &limitOption}, - {BLT_CONFIG_CUSTOM, "-min", "min", "Min", NULL, - Tk_Offset(Axis, reqMin), ALL_GRAPHS, &limitOption}, - {BLT_CONFIG_CUSTOM, "-minorticks", "minorTicks", "MinorTicks", - NULL, Tk_Offset(Axis, t2Ptr), - BLT_CONFIG_NULL_OK | ALL_GRAPHS, &minorTicksOption}, - {BLT_CONFIG_RELIEF, "-relief", "relief", "Relief", - "flat", Tk_Offset(Axis, relief), - ALL_GRAPHS | BLT_CONFIG_DONT_SET_DEFAULT}, - {BLT_CONFIG_DOUBLE, "-rotate", "rotate", "Rotate", "0", - Tk_Offset(Axis, tickAngle), ALL_GRAPHS | BLT_CONFIG_DONT_SET_DEFAULT}, - {BLT_CONFIG_CUSTOM, "-scrollcommand", "scrollCommand", "ScrollCommand", - NULL, Tk_Offset(Axis, scrollCmdObjPtr), - ALL_GRAPHS | BLT_CONFIG_NULL_OK, - &objectOption}, - {BLT_CONFIG_PIXELS, "-scrollincrement", "scrollIncrement", - "ScrollIncrement", "10", - Tk_Offset(Axis, scrollUnits), ALL_GRAPHS|BLT_CONFIG_DONT_SET_DEFAULT}, - {BLT_CONFIG_CUSTOM, "-scrollmax", "scrollMax", "ScrollMax", NULL, - Tk_Offset(Axis, reqScrollMax), ALL_GRAPHS, &limitOption}, - {BLT_CONFIG_CUSTOM, "-scrollmin", "scrollMin", "ScrollMin", NULL, - Tk_Offset(Axis, reqScrollMin), ALL_GRAPHS, &limitOption}, - {BLT_CONFIG_DOUBLE, "-shiftby", "shiftBy", "ShiftBy", - "0.0", Tk_Offset(Axis, shiftBy), - ALL_GRAPHS | BLT_CONFIG_DONT_SET_DEFAULT}, - {BLT_CONFIG_CUSTOM, "-showticks", "showTicks", "ShowTicks", - "1", Tk_Offset(Axis, flags), - ALL_GRAPHS | BLT_CONFIG_DONT_SET_DEFAULT, - &bitmaskGrAxisShowTicksOption}, - {BLT_CONFIG_DOUBLE, "-stepsize", "stepSize", "StepSize", - "0.0", Tk_Offset(Axis, reqStep), - ALL_GRAPHS | BLT_CONFIG_DONT_SET_DEFAULT}, - {BLT_CONFIG_INT, "-subdivisions", "subdivisions", "Subdivisions", - "2", Tk_Offset(Axis, reqNumMinorTicks), ALL_GRAPHS}, - {BLT_CONFIG_ANCHOR, "-tickanchor", "tickAnchor", "Anchor", - "c", Tk_Offset(Axis, reqTickAnchor), ALL_GRAPHS}, - {BLT_CONFIG_FONT, "-tickfont", "tickFont", "Font", - STD_FONT_SMALL, Tk_Offset(Axis, tickFont), - GRAPH | STRIPCHART}, - {BLT_CONFIG_FONT, "-tickfont", "tickFont", "Font", - STD_FONT_SMALL, Tk_Offset(Axis, tickFont), BARCHART}, - {BLT_CONFIG_PIXELS, "-ticklength", "tickLength", "TickLength", - "4", Tk_Offset(Axis, tickLength), - ALL_GRAPHS | BLT_CONFIG_DONT_SET_DEFAULT}, - {BLT_CONFIG_INT, "-tickdefault", "tickDefault", "TickDefault", - "10", Tk_Offset(Axis, reqNumMajorTicks), - ALL_GRAPHS | BLT_CONFIG_DONT_SET_DEFAULT}, - {BLT_CONFIG_STRING, "-title", "title", "Title", - NULL, Tk_Offset(Axis, title), - BLT_CONFIG_DONT_SET_DEFAULT | BLT_CONFIG_NULL_OK | ALL_GRAPHS}, - {BLT_CONFIG_BOOLEAN, "-titlealternate", "titleAlternate", "TitleAlternate", - "0", Tk_Offset(Axis, titleAlternate), - BLT_CONFIG_DONT_SET_DEFAULT | ALL_GRAPHS}, - {BLT_CONFIG_COLOR, "-titlecolor", "titleColor", "Color", - STD_NORMAL_FOREGROUND, Tk_Offset(Axis, titleColor), - ALL_GRAPHS}, - {BLT_CONFIG_FONT, "-titlefont", "titleFont", "Font", STD_FONT_NORMAL, - Tk_Offset(Axis, titleFont), ALL_GRAPHS}, - {BLT_CONFIG_CUSTOM, "-use", "use", "Use", NULL, 0, ALL_GRAPHS, - &useOption}, - {BLT_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0} +static int AxisCreateOp(Tcl_Interp* interp, Graph* graphPtr, + int objc, Tcl_Obj* const objv[]) +{ + if (CreateAxis(graphPtr, interp, Tcl_GetString(objv[3]), graphPtr->classId, objc, objv) != TCL_OK) + return TCL_ERROR; + Tcl_SetObjResult(interp, objv[3]); + return TCL_OK; +} + +static int AxisDeleteOp(Tcl_Interp* interp, Graph* graphPtr, + int objc, Tcl_Obj* const objv[]) +{ + Axis *axisPtr; + if (GetAxisFromObj(interp, graphPtr, objv[3], &axisPtr) != TCL_OK) + return TCL_ERROR; + + axisPtr->flags |= DELETE_PENDING; + if (axisPtr->refCount == 0) + Tcl_EventuallyFree(axisPtr, FreeAxis); + + return TCL_OK; +} + +static int AxisFocusOp(Tcl_Interp* interp, Graph* graphPtr, + int objc, Tcl_Obj* const objv[]) +{ + if (objc > 3) { + Axis *axisPtr = NULL; + const char *string = Tcl_GetString(objv[3]); + if ((string[0] != '\0') && + (GetAxisFromObj(interp, graphPtr, objv[3], &axisPtr) != TCL_OK)) + return TCL_ERROR; + + graphPtr->focusPtr = NULL; + 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. */ + if (graphPtr->focusPtr != NULL) + Tcl_SetStringObj(Tcl_GetObjResult(interp), graphPtr->focusPtr->obj.name,-1); + + return TCL_OK; +} + +static int AxisGetOp(Tcl_Interp* interp, Graph* graphPtr, + int objc, Tcl_Obj* const objv[]) +{ + Axis *axisPtr = Blt_GetCurrentItem(graphPtr->bindTable); + /* Report only on axes. */ + if ((axisPtr != NULL) && + ((axisPtr->obj.classId == CID_AXIS_X) || + (axisPtr->obj.classId == CID_AXIS_Y) || + (axisPtr->obj.classId == CID_NONE))) { + char *string = Tcl_GetString(objv[3]); + char c = string[0]; + if ((c == 'c') && (strcmp(string, "current") == 0)) + Tcl_SetStringObj(Tcl_GetObjResult(interp), axisPtr->obj.name,-1); + else if ((c == 'd') && (strcmp(string, "detail") == 0)) + Tcl_SetStringObj(Tcl_GetObjResult(interp), axisPtr->detail, -1); + } + + return TCL_OK; +} + +static int AxisInvTransformOp(Tcl_Interp* interp, Graph* graphPtr, + int objc, Tcl_Obj* const objv[]) +{ + Axis *axisPtr; + if (GetAxisFromObj(interp, graphPtr, objv[3], &axisPtr) != TCL_OK) + return TCL_ERROR; + + return InvTransformOp(interp, axisPtr, objc-1, objv+1); +} + +static int AxisLimitsOp(Tcl_Interp* interp, Graph* graphPtr, + int objc, Tcl_Obj* const objv[]) +{ + Axis *axisPtr; + if (GetAxisFromObj(interp, graphPtr, objv[3], &axisPtr) != TCL_OK) + return TCL_ERROR; + + return LimitsOp(interp, axisPtr, objc-1, objv+1); +} + +static int AxisMarginOp(Tcl_Interp* interp, Graph* graphPtr, + int objc, Tcl_Obj* const objv[]) +{ + Axis *axisPtr; + if (GetAxisFromObj(interp, graphPtr, objv[3], &axisPtr) != TCL_OK) + return TCL_ERROR; + + return MarginOp(interp, axisPtr, objc-1, objv+1); +} + +static int AxisNamesOp(Tcl_Interp* interp, Graph* graphPtr, + int objc, Tcl_Obj* const objv[]) +{ + Tcl_Obj *listObjPtr = Tcl_NewListObj(0, (Tcl_Obj **)NULL); + if (objc == 3) { + Tcl_HashSearch cursor; + for (Tcl_HashEntry *hPtr = Tcl_FirstHashEntry(&graphPtr->axes.table, &cursor); hPtr != NULL; hPtr = Tcl_NextHashEntry(&cursor)) { + Axis *axisPtr = Tcl_GetHashValue(hPtr); + if (axisPtr->flags & DELETE_PENDING) + continue; + + Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewStringObj(axisPtr->obj.name, -1)); + } + } + else { + Tcl_HashSearch cursor; + for (Tcl_HashEntry *hPtr = Tcl_FirstHashEntry(&graphPtr->axes.table, &cursor); hPtr != NULL; hPtr = Tcl_NextHashEntry(&cursor)) { + Axis *axisPtr = Tcl_GetHashValue(hPtr); + for (int ii=3; ii<objc; ii++) { + const char *pattern = Tcl_GetString(objv[ii]); + if (Tcl_StringMatch(axisPtr->obj.name, pattern)) { + Tcl_ListObjAppendElement(interp, listObjPtr, + Tcl_NewStringObj(axisPtr->obj.name, -1)); + break; + } + } + } + } + Tcl_SetObjResult(interp, listObjPtr); + + return TCL_OK; +} + +static int AxisTransformOp(Tcl_Interp* interp, Graph* graphPtr, + int objc, Tcl_Obj* const objv[]) +{ + Axis *axisPtr; + if (GetAxisFromObj(interp, graphPtr, objv[3], &axisPtr) != TCL_OK) + return TCL_ERROR; + + return TransformOp(interp, axisPtr, objc-1, objv+1); +} + +static int AxisTypeOp(Tcl_Interp* interp, Graph* graphPtr, + int objc, Tcl_Obj* const objv[]) +{ + Axis *axisPtr; + if (GetAxisFromObj(interp, graphPtr, objv[3], &axisPtr) != TCL_OK) + return TCL_ERROR; + + return TypeOp(interp, axisPtr, objc-1, objv+1); +} + +static int AxisViewOp(Tcl_Interp* interp, Graph* graphPtr, + int objc, Tcl_Obj* const objv[]) +{ + Axis *axisPtr; + if (GetAxisFromObj(interp, graphPtr, objv[3], &axisPtr) != TCL_OK) + return TCL_ERROR; + + return ViewOp(interp, axisPtr, objc-1, objv+1); +} + +static Blt_OpSpec axisOps[] = { + {"activate", 1, AxisActivateOp, 4, 4, "axisName"}, + {"bind", 1, AxisBindOp, 3, 6, "axisName sequence command"}, + {"cget", 2, AxisCgetOp, 5, 5, "axisName option"}, + {"configure", 2, AxisConfigureOp, 4, 0, "axisName ?axisName?... " + "?option value?..."}, + {"create", 2, AxisCreateOp, 4, 0, "axisName ?option value?..."}, + {"deactivate", 3, AxisActivateOp, 4, 4, "axisName"}, + {"delete", 3, AxisDeleteOp, 3, 0, "?axisName?..."}, + {"focus", 1, AxisFocusOp, 3, 4, "?axisName?"}, + {"get", 1, AxisGetOp, 4, 4, "name"}, + {"invtransform", 1, AxisInvTransformOp, 5, 5, "axisName value"}, + {"limits", 1, AxisLimitsOp, 4, 4, "axisName"}, + {"margin", 1, AxisMarginOp, 4, 4, "axisName"}, + {"names", 1, AxisNamesOp, 3, 0, "?pattern?..."}, + {"transform", 2, AxisTransformOp, 5, 5, "axisName value"}, + {"type", 2, AxisTypeOp, 4, 4, "axisName"}, + {"view", 1, AxisViewOp, 4, 7, "axisName ?moveto fract? " + "?scroll number what?"}, }; +static int nAxisOps = sizeof(axisOps) / sizeof(Blt_OpSpec); + +int Blt_AxisOp(Graph* graphPtr, Tcl_Interp* interp, + int objc, Tcl_Obj* const objv[]) +{ + GraphAxisProc* proc = + Blt_GetOpFromObj(interp, nAxisOps, axisOps, BLT_OP_ARG2, objc, objv, 0); + if (proc == NULL) + return TCL_ERROR; + + return (*proc)(interp, graphPtr, objc, objv); +} + +// Support static double Clamp(double x) { @@ -1803,48 +2382,6 @@ static void ResetTextStyles(Axis *axisPtr) axisPtr->minor.gc = newGC; } -static void DestroyAxis(Axis *axisPtr) -{ - Graph* graphPtr = axisPtr->obj.graphPtr; - int flags; - - flags = Blt_GraphType(graphPtr); - Blt_FreeOptions(configSpecs, (char*)axisPtr, graphPtr->display, flags); - if (graphPtr->bindTable != NULL) { - Blt_DeleteBindings(graphPtr->bindTable, axisPtr); - } - if (axisPtr->link != NULL) { - Blt_Chain_DeleteLink(axisPtr->chain, axisPtr->link); - } - if (axisPtr->obj.name != NULL) { - free((void*)(axisPtr->obj.name)); - } - if (axisPtr->hashPtr != NULL) { - Tcl_DeleteHashEntry(axisPtr->hashPtr); - } - Blt_Ts_FreeStyle(graphPtr->display, &axisPtr->limitsTextStyle); - - if (axisPtr->tickGC != NULL) { - Tk_FreeGC(graphPtr->display, axisPtr->tickGC); - } - if (axisPtr->activeTickGC != NULL) { - Tk_FreeGC(graphPtr->display, axisPtr->activeTickGC); - } - if (axisPtr->major.gc != NULL) { - Blt_FreePrivateGC(graphPtr->display, axisPtr->major.gc); - } - if (axisPtr->minor.gc != NULL) { - Blt_FreePrivateGC(graphPtr->display, axisPtr->minor.gc); - } - FreeTickLabels(axisPtr->tickLabels); - Blt_Chain_Destroy(axisPtr->tickLabels); - if (axisPtr->segments != NULL) { - free(axisPtr->segments); - } - free(axisPtr); - axisPtr = NULL; -} - static void FreeAxis(char* data) { Axis *axisPtr = (Axis *)data; @@ -2352,7 +2889,7 @@ static double AdjustViewport(double offset, double windowSize) return offset; } -static int GetAxisScrollInfo(Tcl_Interp* interp, int objc, Tcl_Obj *const *objv, +static int GetAxisScrollInfo(Tcl_Interp* interp, int objc, Tcl_Obj* const objv[], double *offsetPtr, double windowSize, double scrollUnits, double scale) { @@ -3323,70 +3860,6 @@ static int ConfigureAxis(Axis *axisPtr) return TCL_OK; } -static Axis *NewAxis(Graph* graphPtr, const char *name, int margin) -{ - Axis *axisPtr; - Tcl_HashEntry *hPtr; - int isNew; - - if (name[0] == '-') { - Tcl_AppendResult(graphPtr->interp, "name of axis \"", name, - "\" can't start with a '-'", NULL); - return NULL; - } - hPtr = Tcl_CreateHashEntry(&graphPtr->axes.table, name, &isNew); - if (!isNew) { - axisPtr = Tcl_GetHashValue(hPtr); - if ((axisPtr->flags & DELETE_PENDING) == 0) { - Tcl_AppendResult(graphPtr->interp, "axis \"", name, - "\" already exists in \"", - Tk_PathName(graphPtr->tkwin), "\"", - NULL); - return NULL; - } - axisPtr->flags &= ~DELETE_PENDING; - } - else { - axisPtr = calloc(1, sizeof(Axis)); - axisPtr->obj.name = Blt_Strdup(name); - axisPtr->hashPtr = hPtr; - Blt_GraphSetObjectClass(&axisPtr->obj, CID_NONE); - axisPtr->obj.graphPtr = graphPtr; - axisPtr->looseMin = AXIS_TIGHT; - axisPtr->looseMax = AXIS_TIGHT; - axisPtr->reqNumMinorTicks = 2; - axisPtr->reqNumMajorTicks = 4 /*10*/; - axisPtr->margin = MARGIN_NONE; - axisPtr->tickLength = 8; - axisPtr->scrollUnits = 10; - axisPtr->reqMin = NAN; - axisPtr->reqMax = NAN; - axisPtr->reqScrollMin = NAN; - axisPtr->reqScrollMax = NAN; - axisPtr->flags = (AXIS_AUTO_MAJOR|AXIS_AUTO_MINOR); - axisPtr->exterior =1; - axisPtr->hide =0; - axisPtr->showTicks =1; - axisPtr->showGridMinor =1; - axisPtr->showGrid =1; - axisPtr->checkLimits =0; - - if ((graphPtr->classId == CID_ELEM_BAR) && - ((margin == MARGIN_TOP) || (margin == MARGIN_BOTTOM))) { - axisPtr->reqStep = 1.0; - axisPtr->reqNumMinorTicks = 0; - } - if ((margin == MARGIN_RIGHT) || (margin == MARGIN_TOP)) - axisPtr->hide = 1; - - Blt_Ts_InitStyle(axisPtr->limitsTextStyle); - axisPtr->tickLabels = Blt_Chain_Create(); - axisPtr->lineWidth = 1; - Tcl_SetHashValue(hPtr, axisPtr); - } - return axisPtr; -} - static int GetAxisFromObj(Tcl_Interp* interp, Graph* graphPtr, Tcl_Obj *objPtr, Axis **axisPtrPtr) { @@ -3480,743 +3953,6 @@ void Blt_ConfigureAxes(Graph* graphPtr) } } -int Blt_DefaultAxes(Graph* graphPtr) -{ - int i; - int flags; - - flags = Blt_GraphType(graphPtr); - for (i = 0; i < 4; i++) { - Blt_Chain chain; - Axis *axisPtr; - - chain = Blt_Chain_Create(); - graphPtr->axisChain[i] = chain; - - /* Create a default axis for each chain. */ - axisPtr = NewAxis(graphPtr, axisNames[i].name, i); - if (axisPtr == NULL) { - return TCL_ERROR; - } - axisPtr->refCount = 1; /* Default axes are assumed in use. */ - axisPtr->margin = i; - axisPtr->flags |= AXIS_USE; - Blt_GraphSetObjectClass(&axisPtr->obj, axisNames[i].classId); - /* - * Blt_ConfigureComponentFromObj creates a temporary child window - * by the name of the axis. It's used so that the Tk routines - * that access the X resource database can describe a single - * component and not the entire graph. - */ - if (Blt_ConfigureComponentFromObj(graphPtr->interp, graphPtr->tkwin, - axisPtr->obj.name, "Axis", configSpecs, 0, (Tcl_Obj **)NULL, - (char*)axisPtr, flags) != TCL_OK) { - return TCL_ERROR; - } - if (ConfigureAxis(axisPtr) != TCL_OK) { - return TCL_ERROR; - } - axisPtr->link = Blt_Chain_Append(chain, axisPtr); - axisPtr->chain = chain; - } - return TCL_OK; -} - -static int ActivateOp(Tcl_Interp* interp, Axis *axisPtr, int objc, Tcl_Obj *const *objv) -{ - Graph* graphPtr = axisPtr->obj.graphPtr; - const char *string; - - string = Tcl_GetString(objv[2]); - if (string[0] == 'a') { - axisPtr->flags |= ACTIVE; - } else { - axisPtr->flags &= ~ACTIVE; - } - if (!axisPtr->hide && (axisPtr->flags & AXIS_USE)) { - graphPtr->flags |= DRAW_MARGINS | CACHE_DIRTY; - Blt_EventuallyRedrawGraph(graphPtr); - } - return TCL_OK; -} - -static int BindOp(Tcl_Interp* interp, Axis *axisPtr, int objc, Tcl_Obj *const *objv) -{ - Graph* graphPtr = axisPtr->obj.graphPtr; - - return Blt_ConfigureBindingsFromObj(interp, graphPtr->bindTable, - Blt_MakeAxisTag(graphPtr, axisPtr->obj.name), objc, objv); -} - -static int CgetOp(Tcl_Interp* interp, Axis *axisPtr, int objc, Tcl_Obj *const *objv) -{ - Graph* graphPtr = axisPtr->obj.graphPtr; - - return Blt_ConfigureValueFromObj(interp, graphPtr->tkwin, configSpecs, - (char*)axisPtr, objv[0], Blt_GraphType(graphPtr)); -} - -static int ConfigureOp(Tcl_Interp* interp, Axis *axisPtr, int objc, Tcl_Obj *const *objv) -{ - Graph* graphPtr = axisPtr->obj.graphPtr; - int flags; - - flags = BLT_CONFIG_OBJV_ONLY | Blt_GraphType(graphPtr); - if (objc == 0) { - return Blt_ConfigureInfoFromObj(interp, graphPtr->tkwin, configSpecs, - (char*)axisPtr, (Tcl_Obj *)NULL, flags); - } else if (objc == 1) { - return Blt_ConfigureInfoFromObj(interp, graphPtr->tkwin, configSpecs, - (char*)axisPtr, objv[0], flags); - } - if (Blt_ConfigureWidgetFromObj(interp, graphPtr->tkwin, configSpecs, - objc, objv, (char*)axisPtr, flags) != TCL_OK) { - return TCL_ERROR; - } - if (ConfigureAxis(axisPtr) != TCL_OK) { - return TCL_ERROR; - } - if (axisPtr->flags & AXIS_USE) { - if (!Blt_ConfigModified(configSpecs, "-*color", "-background", "-bg", - NULL)) { - graphPtr->flags |= CACHE_DIRTY; - } - Blt_EventuallyRedrawGraph(graphPtr); - } - return TCL_OK; -} - -static int LimitsOp(Tcl_Interp* interp, Axis *axisPtr, int objc, Tcl_Obj *const *objv) -{ - Graph* graphPtr = axisPtr->obj.graphPtr; - Tcl_Obj *listObjPtr; - double min, max; - - if (graphPtr->flags & RESET_AXES) { - Blt_ResetAxes(graphPtr); - } - if (axisPtr->logScale) { - min = EXP10(axisPtr->axisRange.min); - max = EXP10(axisPtr->axisRange.max); - } else { - min = axisPtr->axisRange.min; - max = axisPtr->axisRange.max; - } - listObjPtr = Tcl_NewListObj(0, (Tcl_Obj **)NULL); - Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewDoubleObj(min)); - Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewDoubleObj(max)); - Tcl_SetObjResult(interp, listObjPtr); - return TCL_OK; -} - -static int InvTransformOp(Tcl_Interp* interp, Axis *axisPtr, int objc, - Tcl_Obj *const *objv) -{ - Graph* graphPtr = axisPtr->obj.graphPtr; - double y; /* Real graph coordinate */ - int sy; /* Integer window coordinate*/ - - if (graphPtr->flags & RESET_AXES) { - Blt_ResetAxes(graphPtr); - } - if (Tcl_GetIntFromObj(interp, objv[0], &sy) != TCL_OK) { - return TCL_ERROR; - } - /* - * Is the axis vertical or horizontal? - * - * Check the site where the axis was positioned. If the axis is - * virtual, all we have to go on is how it was mapped to an - * element (using either -mapx or -mapy options). - */ - if (AxisIsHorizontal(axisPtr)) { - y = Blt_InvHMap(axisPtr, (double)sy); - } else { - y = Blt_InvVMap(axisPtr, (double)sy); - } - Tcl_SetDoubleObj(Tcl_GetObjResult(interp), y); - return TCL_OK; -} - -static int MarginOp(Tcl_Interp* interp, Axis *axisPtr, int objc, Tcl_Obj *const *objv) -{ - const char *marginName; - - marginName = ""; - if (axisPtr->flags & AXIS_USE) { - marginName = axisNames[axisPtr->margin].name; - } - Tcl_SetStringObj(Tcl_GetObjResult(interp), marginName, -1); - return TCL_OK; -} - -static int TransformOp(Tcl_Interp* interp, Axis *axisPtr, int objc, Tcl_Obj *const *objv) -{ - Graph* graphPtr = axisPtr->obj.graphPtr; - double x; - - if (graphPtr->flags & RESET_AXES) { - Blt_ResetAxes(graphPtr); - } - if (Blt_ExprDoubleFromObj(interp, objv[0], &x) != TCL_OK) { - return TCL_ERROR; - } - if (AxisIsHorizontal(axisPtr)) { - x = Blt_HMap(axisPtr, x); - } else { - x = Blt_VMap(axisPtr, x); - } - Tcl_SetIntObj(Tcl_GetObjResult(interp), (int)x); - return TCL_OK; -} - -static int TypeOp(Tcl_Interp* interp, Axis *axisPtr, int objc, Tcl_Obj *const *objv) -{ - const char *typeName; - - typeName = ""; - if (axisPtr->flags & AXIS_USE) { - if (axisNames[axisPtr->margin].classId == CID_AXIS_X) { - typeName = "x"; - } else if (axisNames[axisPtr->margin].classId == CID_AXIS_Y) { - typeName = "y"; - } - } - Tcl_SetStringObj(Tcl_GetObjResult(interp), typeName, -1); - return TCL_OK; -} - -static int UseOp(Tcl_Interp* interp, Axis *axisPtr, int objc, Tcl_Obj *const *objv) -{ - Graph* graphPtr = (Graph *)axisPtr; - Blt_Chain chain; - Blt_ChainLink link; - Tcl_Obj **axisObjv; - ClassId classId; - int axisObjc; - int i; - - chain = graphPtr->margins[lastMargin].axes; - if (objc == 0) { - Tcl_Obj *listObjPtr; - - listObjPtr = Tcl_NewListObj(0, (Tcl_Obj **)NULL); - for (link = Blt_Chain_FirstLink(chain); link != NULL; - link = Blt_Chain_NextLink(link)) { - Axis *axisPtr; - - axisPtr = Blt_Chain_GetValue(link); - Tcl_ListObjAppendElement(interp, listObjPtr, - Tcl_NewStringObj(axisPtr->obj.name, -1)); - } - Tcl_SetObjResult(interp, listObjPtr); - return TCL_OK; - } - if ((lastMargin == MARGIN_BOTTOM) || (lastMargin == MARGIN_TOP)) { - classId = (graphPtr->inverted) ? CID_AXIS_Y : CID_AXIS_X; - } else { - classId = (graphPtr->inverted) ? CID_AXIS_X : CID_AXIS_Y; - } - if (Tcl_ListObjGetElements(interp, objv[0], &axisObjc, &axisObjv) - != TCL_OK) { - return TCL_ERROR; - } - for (link = Blt_Chain_FirstLink(chain); link!= NULL; - link = Blt_Chain_NextLink(link)) { - Axis *axisPtr; - - axisPtr = Blt_Chain_GetValue(link); - axisPtr->link = NULL; - axisPtr->flags &= ~AXIS_USE; - /* Clear the axis type if it's not currently used.*/ - if (axisPtr->refCount == 0) { - Blt_GraphSetObjectClass(&axisPtr->obj, CID_NONE); - } - } - Blt_Chain_Reset(chain); - for (i = 0; i < axisObjc; i++) { - Axis *axisPtr; - - if (GetAxisFromObj(interp, graphPtr, axisObjv[i], &axisPtr) != TCL_OK){ - return TCL_ERROR; - } - if (axisPtr->obj.classId == CID_NONE) { - Blt_GraphSetObjectClass(&axisPtr->obj, classId); - } else if (axisPtr->obj.classId != classId) { - Tcl_AppendResult(interp, "wrong type axis \"", - axisPtr->obj.name, "\": can't use ", - axisPtr->obj.className, " type axis.", NULL); - return TCL_ERROR; - } - if (axisPtr->link != NULL) { - /* Move the axis from the old margin's "use" list to the new. */ - Blt_Chain_UnlinkLink(axisPtr->chain, axisPtr->link); - Blt_Chain_AppendLink(chain, axisPtr->link); - } else { - axisPtr->link = Blt_Chain_Append(chain, axisPtr); - } - axisPtr->chain = chain; - axisPtr->flags |= AXIS_USE; - } - graphPtr->flags |= (GET_AXIS_GEOMETRY | LAYOUT_NEEDED | RESET_AXES); - /* When any axis changes, we need to layout the entire graph. */ - graphPtr->flags |= (MAP_WORLD | REDRAW_WORLD); - Blt_EventuallyRedrawGraph(graphPtr); - return TCL_OK; -} - -static int ViewOp(Tcl_Interp* interp, Axis *axisPtr, int objc, Tcl_Obj *const *objv) -{ - Graph* graphPtr; - double axisOffset, axisScale; - double fract; - double viewMin, viewMax, worldMin, worldMax; - double viewWidth, worldWidth; - - graphPtr = axisPtr->obj.graphPtr; - worldMin = axisPtr->valueRange.min; - worldMax = axisPtr->valueRange.max; - /* Override data dimensions with user-selected limits. */ - if (!isnan(axisPtr->scrollMin)) { - worldMin = axisPtr->scrollMin; - } - if (!isnan(axisPtr->scrollMax)) { - worldMax = axisPtr->scrollMax; - } - viewMin = axisPtr->min; - viewMax = axisPtr->max; - /* Bound the view within scroll region. */ - if (viewMin < worldMin) { - viewMin = worldMin; - } - if (viewMax > worldMax) { - viewMax = worldMax; - } - if (axisPtr->logScale) { - worldMin = log10(worldMin); - worldMax = log10(worldMax); - viewMin = log10(viewMin); - viewMax = log10(viewMax); - } - worldWidth = worldMax - worldMin; - viewWidth = viewMax - viewMin; - - /* Unlike horizontal axes, vertical axis values run opposite of the - * scrollbar first/last values. So instead of pushing the axis minimum - * around, we move the maximum instead. */ - if (AxisIsHorizontal(axisPtr) != axisPtr->descending) { - axisOffset = viewMin - worldMin; - axisScale = graphPtr->hScale; - } else { - axisOffset = worldMax - viewMax; - axisScale = graphPtr->vScale; - } - if (objc == 4) { - Tcl_Obj *listObjPtr; - double first, last; - - first = Clamp(axisOffset / worldWidth); - last = Clamp((axisOffset + viewWidth) / worldWidth); - listObjPtr = Tcl_NewListObj(0, NULL); - Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewDoubleObj(first)); - Tcl_ListObjAppendElement(interp, listObjPtr, Tcl_NewDoubleObj(last)); - Tcl_SetObjResult(interp, listObjPtr); - return TCL_OK; - } - fract = axisOffset / worldWidth; - if (GetAxisScrollInfo(interp, objc, objv, &fract, - viewWidth / worldWidth, axisPtr->scrollUnits, axisScale) != TCL_OK) { - return TCL_ERROR; - } - if (AxisIsHorizontal(axisPtr) != axisPtr->descending) { - axisPtr->reqMin = (fract * worldWidth) + worldMin; - axisPtr->reqMax = axisPtr->reqMin + viewWidth; - } else { - axisPtr->reqMax = worldMax - (fract * worldWidth); - axisPtr->reqMin = axisPtr->reqMax - viewWidth; - } - if (axisPtr->logScale) { - axisPtr->reqMin = EXP10(axisPtr->reqMin); - axisPtr->reqMax = EXP10(axisPtr->reqMax); - } - graphPtr->flags |= (GET_AXIS_GEOMETRY | LAYOUT_NEEDED | RESET_AXES); - Blt_EventuallyRedrawGraph(graphPtr); - return TCL_OK; -} - -static int AxisCreateOp(Tcl_Interp* interp, Graph* graphPtr, int objc, - Tcl_Obj *const *objv) -{ - Axis *axisPtr; - int flags; - - axisPtr = NewAxis(graphPtr, Tcl_GetString(objv[3]), MARGIN_NONE); - if (axisPtr == NULL) { - return TCL_ERROR; - } - flags = Blt_GraphType(graphPtr); - if ((Blt_ConfigureComponentFromObj(interp, graphPtr->tkwin, - axisPtr->obj.name, "Axis", configSpecs, objc - 4, objv + 4, - (char*)axisPtr, flags) != TCL_OK) || - (ConfigureAxis(axisPtr) != TCL_OK)) { - DestroyAxis(axisPtr); - return TCL_ERROR; - } - Tcl_SetStringObj(Tcl_GetObjResult(interp), axisPtr->obj.name, -1); - return TCL_OK; -} - -static int AxisActivateOp(Tcl_Interp* interp, Graph* graphPtr, int objc, - Tcl_Obj *const *objv) -{ - Axis *axisPtr; - - if (GetAxisFromObj(interp, graphPtr, objv[3], &axisPtr) != TCL_OK) { - return TCL_ERROR; - } - return ActivateOp(interp, axisPtr, objc, objv); -} - -static int AxisBindOp(Tcl_Interp* interp, Graph* graphPtr, int objc, - Tcl_Obj *const *objv) -{ - if (objc == 3) { - Tcl_HashEntry *hPtr; - Tcl_HashSearch cursor; - Tcl_Obj *listObjPtr; - - listObjPtr = Tcl_NewListObj(0, (Tcl_Obj **)NULL); - for (hPtr = Tcl_FirstHashEntry(&graphPtr->axes.tagTable, &cursor); - hPtr != NULL; hPtr = Tcl_NextHashEntry(&cursor)) { - const char *tagName; - Tcl_Obj *objPtr; - - tagName = Tcl_GetHashKey(&graphPtr->axes.tagTable, hPtr); - objPtr = Tcl_NewStringObj(tagName, -1); - Tcl_ListObjAppendElement(interp, listObjPtr, objPtr); - } - Tcl_SetObjResult(interp, listObjPtr); - return TCL_OK; - } - return Blt_ConfigureBindingsFromObj(interp, graphPtr->bindTable, - Blt_MakeAxisTag(graphPtr, Tcl_GetString(objv[3])), objc - 4, objv + 4); -} - -static int AxisCgetOp(Tcl_Interp* interp, Graph* graphPtr, int objc, Tcl_Obj *const *objv) -{ - Axis *axisPtr; - - if (GetAxisFromObj(interp, graphPtr, objv[3], &axisPtr) != TCL_OK) { - return TCL_ERROR; - } - return CgetOp(interp, axisPtr, objc - 4, objv + 4); -} - -static int AxisConfigureOp(Tcl_Interp* interp, Graph* graphPtr, int objc, - Tcl_Obj *const *objv) -{ - Tcl_Obj *const *options; - int i; - int nNames, nOpts; - - /* Figure out where the option value pairs begin */ - objc -= 3; - objv += 3; - for (i = 0; i < objc; i++) { - Axis *axisPtr; - const char *string; - - string = Tcl_GetString(objv[i]); - if (string[0] == '-') { - break; - } - if (GetAxisFromObj(interp, graphPtr, objv[i], &axisPtr) != TCL_OK) { - return TCL_ERROR; - } - } - nNames = i; /* Number of pen names specified */ - nOpts = objc - i; /* Number of options specified */ - options = objv + i; /* Start of options in objv */ - - for (i = 0; i < nNames; i++) { - Axis *axisPtr; - - if (GetAxisFromObj(interp, graphPtr, objv[i], &axisPtr) != TCL_OK) { - return TCL_ERROR; - } - if (ConfigureOp(interp, axisPtr, nOpts, options) != TCL_OK) { - break; - } - } - if (i < nNames) { - return TCL_ERROR; - } - return TCL_OK; -} - -static int AxisDeleteOp(Tcl_Interp* interp, Graph* graphPtr, int objc, - Tcl_Obj *const *objv) -{ - int i; - - for (i = 3; i < objc; i++) { - Axis *axisPtr; - - if (GetAxisFromObj(interp, graphPtr, objv[i], &axisPtr) != TCL_OK) { - return TCL_ERROR; - } - axisPtr->flags |= DELETE_PENDING; - if (axisPtr->refCount == 0) { - Tcl_EventuallyFree(axisPtr, FreeAxis); - } - } - return TCL_OK; -} - -static int AxisFocusOp(Tcl_Interp* interp, Graph* graphPtr, int objc, Tcl_Obj *const *objv) -{ - if (objc > 3) { - Axis *axisPtr; - const char *string; - - axisPtr = NULL; - string = Tcl_GetString(objv[3]); - if ((string[0] != '\0') && - (GetAxisFromObj(interp, graphPtr, objv[3], &axisPtr) != TCL_OK)) { - return TCL_ERROR; - } - graphPtr->focusPtr = NULL; - 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. */ - if (graphPtr->focusPtr != NULL) { - Tcl_SetStringObj(Tcl_GetObjResult(interp), - graphPtr->focusPtr->obj.name, -1); - } - return TCL_OK; -} - -static int AxisGetOp(Tcl_Interp* interp, Graph* graphPtr, int objc, Tcl_Obj *const *objv) -{ - Axis *axisPtr; - - axisPtr = Blt_GetCurrentItem(graphPtr->bindTable); - /* Report only on axes. */ - if ((axisPtr != NULL) && - ((axisPtr->obj.classId == CID_AXIS_X) || - (axisPtr->obj.classId == CID_AXIS_Y) || - (axisPtr->obj.classId == CID_NONE))) { - char c; - char *string; - - string = Tcl_GetString(objv[3]); - c = string[0]; - if ((c == 'c') && (strcmp(string, "current") == 0)) { - Tcl_SetStringObj(Tcl_GetObjResult(interp), axisPtr->obj.name,-1); - } else if ((c == 'd') && (strcmp(string, "detail") == 0)) { - Tcl_SetStringObj(Tcl_GetObjResult(interp), axisPtr->detail, -1); - } - } - return TCL_OK; -} - -static int AxisInvTransformOp(Tcl_Interp* interp, Graph* graphPtr, int objc, - Tcl_Obj *const *objv) -{ - Axis *axisPtr; - - if (GetAxisFromObj(interp, graphPtr, objv[3], &axisPtr) != TCL_OK) { - return TCL_ERROR; - } - return InvTransformOp(interp, axisPtr, objc - 4, objv + 4); -} - -static int AxisLimitsOp(Tcl_Interp* interp, Graph* graphPtr, int objc, - Tcl_Obj *const *objv) -{ - Axis *axisPtr; - - if (GetAxisFromObj(interp, graphPtr, objv[3], &axisPtr) != TCL_OK) { - return TCL_ERROR; - } - return LimitsOp(interp, axisPtr, objc - 4, objv + 4); -} - -static int AxisMarginOp(Tcl_Interp* interp, Graph* graphPtr, int objc, - Tcl_Obj *const *objv) -{ - Axis *axisPtr; - - if (GetAxisFromObj(interp, graphPtr, objv[3], &axisPtr) != TCL_OK) { - return TCL_ERROR; - } - return MarginOp(interp, axisPtr, objc - 4, objv + 4); -} - -static int AxisNamesOp(Tcl_Interp* interp, Graph* graphPtr, int objc, Tcl_Obj *const *objv) -{ - Tcl_Obj *listObjPtr; - - listObjPtr = Tcl_NewListObj(0, (Tcl_Obj **)NULL); - if (objc == 3) { - Tcl_HashEntry *hPtr; - Tcl_HashSearch cursor; - - for (hPtr = Tcl_FirstHashEntry(&graphPtr->axes.table, &cursor); - hPtr != NULL; hPtr = Tcl_NextHashEntry(&cursor)) { - Axis *axisPtr; - - axisPtr = Tcl_GetHashValue(hPtr); - if (axisPtr->flags & DELETE_PENDING) { - continue; - } - Tcl_ListObjAppendElement(interp, listObjPtr, - Tcl_NewStringObj(axisPtr->obj.name, -1)); - } - } else { - Tcl_HashEntry *hPtr; - Tcl_HashSearch cursor; - - for (hPtr = Tcl_FirstHashEntry(&graphPtr->axes.table, &cursor); - hPtr != NULL; hPtr = Tcl_NextHashEntry(&cursor)) { - Axis *axisPtr; - int i; - - axisPtr = Tcl_GetHashValue(hPtr); - for (i = 3; i < objc; i++) { - const char *pattern; - - pattern = Tcl_GetString(objv[i]); - if (Tcl_StringMatch(axisPtr->obj.name, pattern)) { - Tcl_ListObjAppendElement(interp, listObjPtr, - Tcl_NewStringObj(axisPtr->obj.name, -1)); - break; - } - } - } - } - Tcl_SetObjResult(interp, listObjPtr); - return TCL_OK; -} - -static int AxisTransformOp(Tcl_Interp* interp, Graph* graphPtr, int objc, - Tcl_Obj *const *objv) -{ - Axis *axisPtr; - - if (GetAxisFromObj(interp, graphPtr, objv[3], &axisPtr) != TCL_OK) { - return TCL_ERROR; - } - return TransformOp(interp, axisPtr, objc - 4, objv + 4); -} - -static int AxisTypeOp(Tcl_Interp* interp, Graph* graphPtr, int objc, - Tcl_Obj *const *objv) -{ - Axis *axisPtr; - - if (GetAxisFromObj(interp, graphPtr, objv[3], &axisPtr) != TCL_OK) { - return TCL_ERROR; - } - return TypeOp(interp, axisPtr, objc - 4, objv + 4); -} - -static int -AxisViewOp(Tcl_Interp* interp, Graph* graphPtr, int objc, Tcl_Obj *const *objv) -{ - Axis *axisPtr; - - if (GetAxisFromObj(interp, graphPtr, objv[3], &axisPtr) != TCL_OK) { - return TCL_ERROR; - } - return ViewOp(interp, axisPtr, objc - 4, objv + 4); -} - -static Blt_OpSpec virtAxisOps[] = { - {"activate", 1, AxisActivateOp, 4, 4, "axisName"}, - {"bind", 1, AxisBindOp, 3, 6, "axisName sequence command"}, - {"cget", 2, AxisCgetOp, 5, 5, "axisName option"}, - {"configure", 2, AxisConfigureOp, 4, 0, "axisName ?axisName?... " - "?option value?..."}, - {"create", 2, AxisCreateOp, 4, 0, "axisName ?option value?..."}, - {"deactivate", 3, AxisActivateOp, 4, 4, "axisName"}, - {"delete", 3, AxisDeleteOp, 3, 0, "?axisName?..."}, - {"focus", 1, AxisFocusOp, 3, 4, "?axisName?"}, - {"get", 1, AxisGetOp, 4, 4, "name"}, - {"invtransform", 1, AxisInvTransformOp, 5, 5, "axisName value"}, - {"limits", 1, AxisLimitsOp, 4, 4, "axisName"}, - {"margin", 1, AxisMarginOp, 4, 4, "axisName"}, - {"names", 1, AxisNamesOp, 3, 0, "?pattern?..."}, - {"transform", 2, AxisTransformOp, 5, 5, "axisName value"}, - {"type", 2, AxisTypeOp, 4, 4, "axisName"}, - {"view", 1, AxisViewOp, 4, 7, "axisName ?moveto fract? " - "?scroll number what?"}, -}; -static int nVirtAxisOps = sizeof(virtAxisOps) / sizeof(Blt_OpSpec); - -int -Blt_VirtualAxisOp(Graph* graphPtr, Tcl_Interp* interp, int objc, - Tcl_Obj *const *objv) -{ - GraphVirtualAxisProc *proc; - int result; - - proc = Blt_GetOpFromObj(interp, nVirtAxisOps, virtAxisOps, BLT_OP_ARG2, - objc, objv, 0); - if (proc == NULL) { - return TCL_ERROR; - } - result = (*proc) (interp, graphPtr, objc, objv); - return result; -} - -static Blt_OpSpec axisOps[] = { - {"activate", 1, ActivateOp, 3, 3, "",}, - {"bind", 1, BindOp, 2, 5, "sequence command",}, - {"cget", 2, CgetOp, 4, 4, "option",}, - {"configure", 2, ConfigureOp, 3, 0, "?option value?...",}, - {"deactivate", 1, ActivateOp, 3, 3, "",}, - {"invtransform", 1, InvTransformOp, 4, 4, "value",}, - {"limits", 1, LimitsOp, 3, 3, "",}, - {"transform", 1, TransformOp, 4, 4, "value",}, - {"use", 1, UseOp, 3, 4, "?axisName?",}, - {"view", 1, ViewOp, 3, 6, "?moveto fract? ",}, -}; - -static int nAxisOps = sizeof(axisOps) / sizeof(Blt_OpSpec); - -int -Blt_AxisOp(Tcl_Interp* interp, Graph* graphPtr, int margin, int objc, - Tcl_Obj *const *objv) -{ - int result; - GraphAxisProc *proc; - - proc = Blt_GetOpFromObj(interp, nAxisOps, axisOps, BLT_OP_ARG2, - objc, objv, 0); - if (proc == NULL) { - return TCL_ERROR; - } - if (proc == UseOp) { - lastMargin = margin; /* Set global variable to the margin - * in the argument list. Needed only - * for UseOp. */ - result = (*proc)(interp, (Axis *)graphPtr, objc - 3, objv + 3); - } else { - Axis *axisPtr; - - axisPtr = Blt_GetFirstAxis(graphPtr->margins[margin].axes); - if (axisPtr == NULL) { - return TCL_OK; - } - result = (*proc)(interp, axisPtr, objc - 3, objv + 3); - } - return result; -} - void Blt_MapAxes(Graph* graphPtr) { @@ -4609,3 +4345,235 @@ static void TimeScaleAxis(Axis *axisPtr, double min, double max) } +static Blt_OptionParseProc ObjToLimitProc; +static Blt_OptionPrintProc LimitToObjProc; +static Blt_CustomOption limitOption = { + ObjToLimitProc, LimitToObjProc, NULL, (ClientData)0 +}; + +static Blt_OptionFreeProc FreeTicksProc; +static Blt_OptionParseProc ObjToTicksProc; +static Blt_OptionPrintProc TicksToObjProc; +static Blt_CustomOption majorTicksOption = { + ObjToTicksProc, TicksToObjProc, FreeTicksProc, (ClientData)AXIS_AUTO_MAJOR, +}; +static Blt_CustomOption minorTicksOption = { + ObjToTicksProc, TicksToObjProc, FreeTicksProc, (ClientData)AXIS_AUTO_MINOR, +}; +static Blt_OptionFreeProc FreeAxisProc; +static Blt_OptionPrintProc AxisToObjProc; +static Blt_OptionParseProc ObjToAxisProc; +Blt_CustomOption bltXAxisOption = { + ObjToAxisProc, AxisToObjProc, FreeAxisProc, (ClientData)CID_AXIS_X +}; +Blt_CustomOption bltYAxisOption = { + ObjToAxisProc, AxisToObjProc, FreeAxisProc, (ClientData)CID_AXIS_Y +}; + +static Blt_OptionFreeProc FreeFormatProc; +static Blt_OptionParseProc ObjToFormatProc; +static Blt_OptionPrintProc FormatToObjProc; +static Blt_CustomOption formatOption = { + ObjToFormatProc, FormatToObjProc, FreeFormatProc, (ClientData)0, +}; +static Blt_OptionParseProc ObjToLooseProc; +static Blt_OptionPrintProc LooseToObjProc; +static Blt_CustomOption looseOption = { + ObjToLooseProc, LooseToObjProc, NULL, (ClientData)0, +}; + +static Blt_OptionParseProc ObjToUseProc; +static Blt_OptionPrintProc UseToObjProc; +static Blt_CustomOption useOption = { + ObjToUseProc, UseToObjProc, NULL, (ClientData)0 +}; + +Blt_CustomOption bitmaskGrAxisCheckLimitsOption = + { + ObjToBitmaskProc, BitmaskToObjProc, NULL, (ClientData)AXIS_CHECK_LIMITS + }; + +Blt_CustomOption bitmaskGrAxisExteriorOption = + { + ObjToBitmaskProc, BitmaskToObjProc, NULL, (ClientData)AXIS_EXTERIOR + }; + +Blt_CustomOption bitmaskGrAxisGridOption = + { + ObjToBitmaskProc, BitmaskToObjProc, NULL, (ClientData)AXIS_GRID + }; + +Blt_CustomOption bitmaskGrAxisGridMinorOption = + { + ObjToBitmaskProc, BitmaskToObjProc, NULL, (ClientData)AXIS_GRID_MINOR + }; + +Blt_CustomOption bitmaskGrAxisHideOption = + { + ObjToBitmaskProc, BitmaskToObjProc, NULL, (ClientData)HIDE + }; + +Blt_CustomOption bitmaskGrAxisShowTicksOption = + { + ObjToBitmaskProc, BitmaskToObjProc, NULL, (ClientData)AXIS_SHOWTICKS + }; + +static Blt_ConfigSpec configSpecs[] = { + {BLT_CONFIG_COLOR, "-activeforeground", "activeForeground", + "ActiveForeground", STD_ACTIVE_FOREGROUND, + Tk_Offset(Axis, activeFgColor), ALL_GRAPHS}, + {BLT_CONFIG_RELIEF, "-activerelief", "activeRelief", "Relief", + "flat", Tk_Offset(Axis, activeRelief), + ALL_GRAPHS | BLT_CONFIG_DONT_SET_DEFAULT}, + {BLT_CONFIG_DOUBLE, "-autorange", "autoRange", "AutoRange", + "0.0", Tk_Offset(Axis, windowSize), + ALL_GRAPHS | BLT_CONFIG_DONT_SET_DEFAULT}, + {BLT_CONFIG_BORDER, "-background", "background", "Background", + NULL, Tk_Offset(Axis, normalBg), + ALL_GRAPHS | BLT_CONFIG_NULL_OK}, + {BLT_CONFIG_SYNONYM, "-bg", "background", NULL, NULL, 0, 0}, + {BLT_CONFIG_CUSTOM, "-bindtags", "bindTags", "BindTags", "all", + Tk_Offset(Axis, obj.tags), ALL_GRAPHS | BLT_CONFIG_NULL_OK, + &listOption}, + {BLT_CONFIG_SYNONYM, "-bd", "borderWidth", NULL, NULL, + 0, ALL_GRAPHS}, + {BLT_CONFIG_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", + "0", Tk_Offset(Axis, borderWidth), + ALL_GRAPHS | BLT_CONFIG_DONT_SET_DEFAULT}, + {BLT_CONFIG_CUSTOM, "-checklimits", "checkLimits", "CheckLimits", + "0", Tk_Offset(Axis, flags), + ALL_GRAPHS | BLT_CONFIG_DONT_SET_DEFAULT, + &bitmaskGrAxisCheckLimitsOption}, + {BLT_CONFIG_COLOR, "-color", "color", "Color", + STD_NORMAL_FOREGROUND, Tk_Offset(Axis, tickColor), ALL_GRAPHS}, + {BLT_CONFIG_STRING, "-command", "command", "Command", + NULL, Tk_Offset(Axis, formatCmd), + BLT_CONFIG_NULL_OK | ALL_GRAPHS}, + {BLT_CONFIG_BOOLEAN, "-descending", "descending", "Descending", + "0", Tk_Offset(Axis, descending), + ALL_GRAPHS | BLT_CONFIG_DONT_SET_DEFAULT}, + {BLT_CONFIG_CUSTOM, "-exterior", "exterior", "exterior", "1", + Tk_Offset(Axis, flags), ALL_GRAPHS | BLT_CONFIG_DONT_SET_DEFAULT, + &bitmaskGrAxisExteriorOption}, + {BLT_CONFIG_SYNONYM, "-fg", "color", NULL, + NULL, 0, ALL_GRAPHS}, + {BLT_CONFIG_SYNONYM, "-foreground", "color", NULL, + NULL, 0, ALL_GRAPHS}, + {BLT_CONFIG_CUSTOM, "-grid", "grid", "Grid", "1", + Tk_Offset(Axis, flags), BARCHART, + &bitmaskGrAxisGridOption}, + {BLT_CONFIG_CUSTOM, "-grid", "grid", "Grid", "1", + Tk_Offset(Axis, flags), GRAPH | STRIPCHART, + &bitmaskGrAxisGridOption}, + {BLT_CONFIG_COLOR, "-gridcolor", "gridColor", "GridColor", + "gray64", Tk_Offset(Axis, major.color), ALL_GRAPHS}, + {BLT_CONFIG_CUSTOM, "-griddashes", "gridDashes", "GridDashes", + "dot", Tk_Offset(Axis, major.dashes), + BLT_CONFIG_NULL_OK | ALL_GRAPHS, &dashesOption}, + {BLT_CONFIG_PIXELS, "-gridlinewidth", "gridLineWidth", + "GridLineWidth", "0", + Tk_Offset(Axis, major.lineWidth), + BLT_CONFIG_DONT_SET_DEFAULT | ALL_GRAPHS}, + {BLT_CONFIG_CUSTOM, "-gridminor", "gridMinor", "GridMinor", + "1", Tk_Offset(Axis, flags), + BLT_CONFIG_DONT_SET_DEFAULT | ALL_GRAPHS, + &bitmaskGrAxisGridMinorOption}, + {BLT_CONFIG_COLOR, "-gridminorcolor", "gridMinorColor", "GridColor", + "gray64", Tk_Offset(Axis, minor.color), ALL_GRAPHS}, + {BLT_CONFIG_CUSTOM, "-gridminordashes", "gridMinorDashes", "GridDashes", + "dot", Tk_Offset(Axis, minor.dashes), + BLT_CONFIG_NULL_OK | ALL_GRAPHS, &dashesOption}, + {BLT_CONFIG_PIXELS, "-gridminorlinewidth", "gridMinorLineWidth", + "GridLineWidth", "0", + Tk_Offset(Axis, minor.lineWidth), + BLT_CONFIG_DONT_SET_DEFAULT | ALL_GRAPHS}, + {BLT_CONFIG_CUSTOM, "-hide", "hide", "Hide", "0", + Tk_Offset(Axis, flags), ALL_GRAPHS | BLT_CONFIG_DONT_SET_DEFAULT, + &bitmaskGrAxisHideOption}, + {BLT_CONFIG_JUSTIFY, "-justify", "justify", "Justify", + "c", Tk_Offset(Axis, titleJustify), + ALL_GRAPHS | BLT_CONFIG_DONT_SET_DEFAULT}, + {BLT_CONFIG_BOOLEAN, "-labeloffset", "labelOffset", "LabelOffset", + "no", Tk_Offset(Axis, labelOffset), ALL_GRAPHS}, + {BLT_CONFIG_COLOR, "-limitscolor", "limitsColor", "Color", + STD_NORMAL_FOREGROUND, Tk_Offset(Axis, limitsTextStyle.color), + ALL_GRAPHS}, + {BLT_CONFIG_FONT, "-limitsfont", "limitsFont", "Font", STD_FONT_SMALL, + Tk_Offset(Axis, limitsTextStyle.font), ALL_GRAPHS}, + {BLT_CONFIG_CUSTOM, "-limitsformat", "limitsFormat", "LimitsFormat", + NULL, Tk_Offset(Axis, limitsFormats), + BLT_CONFIG_NULL_OK | ALL_GRAPHS, &formatOption}, + {BLT_CONFIG_PIXELS, "-linewidth", "lineWidth", "LineWidth", + "1", Tk_Offset(Axis, lineWidth), + ALL_GRAPHS | BLT_CONFIG_DONT_SET_DEFAULT}, + {BLT_CONFIG_BOOLEAN, "-logscale", "logScale", "LogScale", + "0", Tk_Offset(Axis, logScale), + ALL_GRAPHS | BLT_CONFIG_DONT_SET_DEFAULT}, + {BLT_CONFIG_CUSTOM, "-loose", "loose", "Loose", "0", 0, + ALL_GRAPHS | BLT_CONFIG_DONT_SET_DEFAULT, &looseOption}, + {BLT_CONFIG_CUSTOM, "-majorticks", "majorTicks", "MajorTicks", + NULL, Tk_Offset(Axis, t1Ptr), + BLT_CONFIG_NULL_OK | ALL_GRAPHS, &majorTicksOption}, + {BLT_CONFIG_CUSTOM, "-max", "max", "Max", NULL, + Tk_Offset(Axis, reqMax), ALL_GRAPHS, &limitOption}, + {BLT_CONFIG_CUSTOM, "-min", "min", "Min", NULL, + Tk_Offset(Axis, reqMin), ALL_GRAPHS, &limitOption}, + {BLT_CONFIG_CUSTOM, "-minorticks", "minorTicks", "MinorTicks", + NULL, Tk_Offset(Axis, t2Ptr), + BLT_CONFIG_NULL_OK | ALL_GRAPHS, &minorTicksOption}, + {BLT_CONFIG_RELIEF, "-relief", "relief", "Relief", + "flat", Tk_Offset(Axis, relief), + ALL_GRAPHS | BLT_CONFIG_DONT_SET_DEFAULT}, + {BLT_CONFIG_DOUBLE, "-rotate", "rotate", "Rotate", "0", + Tk_Offset(Axis, tickAngle), ALL_GRAPHS | BLT_CONFIG_DONT_SET_DEFAULT}, + {BLT_CONFIG_CUSTOM, "-scrollcommand", "scrollCommand", "ScrollCommand", + NULL, Tk_Offset(Axis, scrollCmdObjPtr), + ALL_GRAPHS | BLT_CONFIG_NULL_OK, + &objectOption}, + {BLT_CONFIG_PIXELS, "-scrollincrement", "scrollIncrement", + "ScrollIncrement", "10", + Tk_Offset(Axis, scrollUnits), ALL_GRAPHS|BLT_CONFIG_DONT_SET_DEFAULT}, + {BLT_CONFIG_CUSTOM, "-scrollmax", "scrollMax", "ScrollMax", NULL, + Tk_Offset(Axis, reqScrollMax), ALL_GRAPHS, &limitOption}, + {BLT_CONFIG_CUSTOM, "-scrollmin", "scrollMin", "ScrollMin", NULL, + Tk_Offset(Axis, reqScrollMin), ALL_GRAPHS, &limitOption}, + {BLT_CONFIG_DOUBLE, "-shiftby", "shiftBy", "ShiftBy", + "0.0", Tk_Offset(Axis, shiftBy), + ALL_GRAPHS | BLT_CONFIG_DONT_SET_DEFAULT}, + {BLT_CONFIG_CUSTOM, "-showticks", "showTicks", "ShowTicks", + "1", Tk_Offset(Axis, flags), + ALL_GRAPHS | BLT_CONFIG_DONT_SET_DEFAULT, + &bitmaskGrAxisShowTicksOption}, + {BLT_CONFIG_DOUBLE, "-stepsize", "stepSize", "StepSize", + "0.0", Tk_Offset(Axis, reqStep), + ALL_GRAPHS | BLT_CONFIG_DONT_SET_DEFAULT}, + {BLT_CONFIG_INT, "-subdivisions", "subdivisions", "Subdivisions", + "2", Tk_Offset(Axis, reqNumMinorTicks), ALL_GRAPHS}, + {BLT_CONFIG_ANCHOR, "-tickanchor", "tickAnchor", "Anchor", + "c", Tk_Offset(Axis, reqTickAnchor), ALL_GRAPHS}, + {BLT_CONFIG_FONT, "-tickfont", "tickFont", "Font", + STD_FONT_SMALL, Tk_Offset(Axis, tickFont), + GRAPH | STRIPCHART}, + {BLT_CONFIG_FONT, "-tickfont", "tickFont", "Font", + STD_FONT_SMALL, Tk_Offset(Axis, tickFont), BARCHART}, + {BLT_CONFIG_PIXELS, "-ticklength", "tickLength", "TickLength", + "4", Tk_Offset(Axis, tickLength), + ALL_GRAPHS | BLT_CONFIG_DONT_SET_DEFAULT}, + {BLT_CONFIG_INT, "-tickdefault", "tickDefault", "TickDefault", + "10", Tk_Offset(Axis, reqNumMajorTicks), + ALL_GRAPHS | BLT_CONFIG_DONT_SET_DEFAULT}, + {BLT_CONFIG_STRING, "-title", "title", "Title", + NULL, Tk_Offset(Axis, title), + BLT_CONFIG_DONT_SET_DEFAULT | BLT_CONFIG_NULL_OK | ALL_GRAPHS}, + {BLT_CONFIG_BOOLEAN, "-titlealternate", "titleAlternate", "TitleAlternate", + "0", Tk_Offset(Axis, titleAlternate), + BLT_CONFIG_DONT_SET_DEFAULT | ALL_GRAPHS}, + {BLT_CONFIG_COLOR, "-titlecolor", "titleColor", "Color", + STD_NORMAL_FOREGROUND, Tk_Offset(Axis, titleColor), + ALL_GRAPHS}, + {BLT_CONFIG_FONT, "-titlefont", "titleFont", "Font", STD_FONT_NORMAL, + Tk_Offset(Axis, titleFont), ALL_GRAPHS}, + {BLT_CONFIG_CUSTOM, "-use", "use", "Use", NULL, 0, ALL_GRAPHS, + &useOption}, + {BLT_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0} +}; diff --git a/src/bltGrAxis.h b/src/bltGrAxis.h index 3d458b0..4ff5139 100644 --- a/src/bltGrAxis.h +++ b/src/bltGrAxis.h @@ -83,6 +83,7 @@ typedef struct { int checkLimits; unsigned int flags; + Tk_OptionTable optionTable; /* Configuration specifications */ Tcl_HashEntry *hashPtr; /* Fields specific to axes. */ diff --git a/src/bltGrBind.C b/src/bltGrBind.C index 0c876ce..ed1e5b3 100644 --- a/src/bltGrBind.C +++ b/src/bltGrBind.C @@ -523,7 +523,7 @@ Blt_ConfigureBindingsFromObj( BindTable *bindPtr, ClientData item, int objc, - Tcl_Obj *const *objv) + Tcl_Obj* const objv[]) { const char *command; unsigned long mask; diff --git a/src/bltGrElemOp.C b/src/bltGrElemOp.C index 8682f8b..adbfc3e 100644 --- a/src/bltGrElemOp.C +++ b/src/bltGrElemOp.C @@ -290,7 +290,7 @@ static int CreateElement(Graph* graphPtr, Tcl_Interp* interp, int objc, char *string = Tcl_GetString(objv[3]); if (string[0] == '-') { Tcl_AppendResult(graphPtr->interp, "name of element \"", string, - "\" can't start with a '-'", (char *)NULL); + "\" can't start with a '-'", NULL); return TCL_ERROR; } @@ -415,6 +415,15 @@ static int ConfigureOp(Graph* graphPtr, Tcl_Interp* interp, return ElementObjConfigure(interp, graphPtr, elemPtr, objc-4, objv+4); } +static int CreateOp(Graph* graphPtr, Tcl_Interp* interp, + int objc, Tcl_Obj* const objv[], ClassId classId) +{ + if (CreateElement(graphPtr, interp, objc, objv, classId) != TCL_OK) + return TCL_ERROR; + Tcl_SetObjResult(interp, objv[3]); + return TCL_OK; +} + static int ElementObjConfigure(Tcl_Interp* interp, Graph* graphPtr, Element* elemPtr, int objc, Tcl_Obj* const objv[]) @@ -460,7 +469,7 @@ static int ElementObjConfigure(Tcl_Interp* interp, Graph* graphPtr, // Ops static int ActivateOp(Graph* graphPtr, Tcl_Interp* interp, - int objc, Tcl_Obj *const *objv) + int objc, Tcl_Obj* const objv[]) { Element* elemPtr; int i; @@ -514,7 +523,7 @@ static int ActivateOp(Graph* graphPtr, Tcl_Interp* interp, } static int BindOp(Graph* graphPtr, Tcl_Interp* interp, - int objc, Tcl_Obj *const *objv) + int objc, Tcl_Obj* const objv[]) { if (objc == 3) { Tcl_HashEntry *hPtr; @@ -536,15 +545,6 @@ static int BindOp(Graph* graphPtr, Tcl_Interp* interp, return Blt_ConfigureBindingsFromObj(interp, graphPtr->bindTable, Blt_MakeElementTag(graphPtr, Tcl_GetString(objv[3])), objc - 4, objv + 4); } -static int CreateOp(Graph* graphPtr, Tcl_Interp* interp, - int objc, Tcl_Obj* const objv[], ClassId classId) -{ - if (CreateElement(graphPtr, interp, objc, objv, classId) != TCL_OK) - return TCL_ERROR; - Tcl_SetObjResult(interp, objv[3]); - return TCL_OK; -} - static Blt_OptionParseProc ObjToAlong; static Blt_OptionPrintProc AlongToObj; static Blt_CustomOption alongOption = @@ -610,7 +610,7 @@ static Blt_ConfigSpec closestSpecs[] = { }; static int ClosestOp(Graph* graphPtr, Tcl_Interp* interp, - int objc, Tcl_Obj *const *objv) + int objc, Tcl_Obj* const objv[]) { Element* elemPtr; ClosestSearch search; @@ -721,7 +721,7 @@ static int ClosestOp(Graph* graphPtr, Tcl_Interp* interp, } static int DeactivateOp(Graph* graphPtr, Tcl_Interp* interp, - int objc, Tcl_Obj *const *objv) + int objc, Tcl_Obj* const objv[]) { int i; @@ -743,7 +743,7 @@ static int DeactivateOp(Graph* graphPtr, Tcl_Interp* interp, } static int DeleteOp(Graph* graphPtr, Tcl_Interp* interp, - int objc, Tcl_Obj *const *objv) + int objc, Tcl_Obj* const objv[]) { int i; @@ -761,7 +761,7 @@ static int DeleteOp(Graph* graphPtr, Tcl_Interp* interp, } static int ExistsOp(Graph* graphPtr, Tcl_Interp* interp, - int objc, Tcl_Obj *const *objv) + int objc, Tcl_Obj* const objv[]) { Tcl_HashEntry *hPtr; @@ -771,7 +771,7 @@ static int ExistsOp(Graph* graphPtr, Tcl_Interp* interp, } static int GetOp(Graph* graphPtr, Tcl_Interp* interp, - int objc, Tcl_Obj *const *objv) + int objc, Tcl_Obj* const objv[]) { char *string; @@ -841,7 +841,7 @@ static int LowerOp(Graph* graphPtr, Tcl_Interp* interp, } static int NamesOp(Graph* graphPtr, Tcl_Interp* interp, - int objc, Tcl_Obj *const *objv) + int objc, Tcl_Obj* const objv[]) { Tcl_Obj *listObjPtr; @@ -885,7 +885,7 @@ static int NamesOp(Graph* graphPtr, Tcl_Interp* interp, } static int RaiseOp(Graph* graphPtr, Tcl_Interp* interp, - int objc, Tcl_Obj *const *objv) + int objc, Tcl_Obj* const objv[]) { Blt_Chain chain; Blt_ChainLink link, prev; @@ -917,7 +917,7 @@ static int RaiseOp(Graph* graphPtr, Tcl_Interp* interp, } static int ShowOp(Graph* graphPtr, Tcl_Interp* interp, - int objc, Tcl_Obj *const *objv) + int objc, Tcl_Obj* const objv[]) { if (objc == 4) { Blt_Chain chain; @@ -1006,24 +1006,19 @@ static int numElemOps = sizeof(elemOps) / sizeof(Blt_OpSpec); int Blt_ElementOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[], ClassId classId) { - void *ptr; - int result; - - ptr = Blt_GetOpFromObj(interp, numElemOps, elemOps, BLT_OP_ARG2, - objc, objv, 0); - if (ptr == NULL) { + void *ptr = Blt_GetOpFromObj(interp, numElemOps, elemOps, BLT_OP_ARG2, + objc, objv, 0); + if (ptr == NULL) return TCL_ERROR; + + if (ptr == CreateOp) + retur CreateOp(graphPtr, interp, objc, objv, classId); + else { + GraphElementProc* proc = ptr; + return (*proc)(graphPtr, interp, objc, objv); } - if (ptr == CreateOp) { - result = CreateOp(graphPtr, interp, objc, objv, classId); - } else { - GraphElementProc *proc; - - proc = ptr; - result = (*proc) (graphPtr, interp, objc, objv); - } - return result; } + // Support static void FreeElement(char* data) diff --git a/src/bltGrHairs.C b/src/bltGrHairs.C index 48b2657..d792619 100644 --- a/src/bltGrHairs.C +++ b/src/bltGrHairs.C @@ -67,6 +67,8 @@ static int CrosshairsObjConfigure(Tcl_Interp* interp, Graph* graphPtr, static void ConfigureCrosshairs(Graph* graphPtr); static void TurnOffHairs(Tk_Window tkwin, Crosshairs *chPtr); static void TurnOnHairs(Graph* graphPtr, Crosshairs *chPtr); +typedef int (GraphCrosshairProc)(Graph* graphPtr, Tcl_Interp* interp, + int objc, Tcl_Obj* const objv[]); // OptionSpecs @@ -244,26 +246,8 @@ static void ConfigureCrosshairs(Graph* graphPtr) // Ops -static Blt_OpSpec xhairOps[]; -static int nXhairOps; -typedef int (GraphCrosshairProc)(Graph* graphPtr, Tcl_Interp* interp, - int objc, Tcl_Obj* const objv[]); - -int Blt_CrosshairsOp(Graph* graphPtr, Tcl_Interp* interp, - int objc, Tcl_Obj* const objv[]) -{ - GraphCrosshairProc* proc = Blt_GetOpFromObj(interp, nXhairOps, xhairOps, - BLT_OP_ARG2, objc, objv, 0); - if (proc == NULL) - return TCL_ERROR; - - return (*proc)(graphPtr, interp, objc, objv); -} - -// Widget commands - static int OnOp(Graph* graphPtr, Tcl_Interp* interp, - int objc, Tcl_Obj *const *objv) + int objc, Tcl_Obj* const objv[]) { Crosshairs *chPtr = graphPtr->crosshairs; @@ -275,7 +259,7 @@ static int OnOp(Graph* graphPtr, Tcl_Interp* interp, } static int OffOp(Graph* graphPtr, Tcl_Interp* interp, - int objc, Tcl_Obj *const *objv) + int objc, Tcl_Obj* const objv[]) { Crosshairs *chPtr = graphPtr->crosshairs; @@ -287,7 +271,7 @@ static int OffOp(Graph* graphPtr, Tcl_Interp* interp, } static int ToggleOp(Graph* graphPtr, Tcl_Interp* interp, - int objc, Tcl_Obj *const *objv) + int objc, Tcl_Obj* const objv[]) { Crosshairs *chPtr = graphPtr->crosshairs; @@ -310,6 +294,17 @@ static Blt_OpSpec xhairOps[] = }; static int nXhairOps = sizeof(xhairOps) / sizeof(Blt_OpSpec); +int Blt_CrosshairsOp(Graph* graphPtr, Tcl_Interp* interp, + int objc, Tcl_Obj* const objv[]) +{ + GraphCrosshairProc* proc = Blt_GetOpFromObj(interp, nXhairOps, xhairOps, + BLT_OP_ARG2, objc, objv, 0); + if (proc == NULL) + return TCL_ERROR; + + return (*proc)(graphPtr, interp, objc, objv); +} + // Support static void TurnOffHairs(Tk_Window tkwin, Crosshairs *chPtr) diff --git a/src/bltGrLegd.C b/src/bltGrLegd.C index 8a60683..6566905 100644 --- a/src/bltGrLegd.C +++ b/src/bltGrLegd.C @@ -650,22 +650,8 @@ static void ConfigureLegend(Graph* graphPtr) // Ops -static Blt_OpSpec legendOps[]; -static int nLegendOps; - -int Blt_LegendOp(Graph* graphPtr, Tcl_Interp* interp, - int objc, Tcl_Obj* const objv[]) -{ - GraphLegendProc *proc = Blt_GetOpFromObj(interp, nLegendOps, legendOps, - BLT_OP_ARG2, objc, objv,0); - if (proc == NULL) - return TCL_ERROR; - - return (*proc) (graphPtr, interp, objc, objv); -} - static int ActivateOp(Graph* graphPtr, Tcl_Interp* interp, - int objc, Tcl_Obj *const *objv) + int objc, Tcl_Obj* const objv[]) { Legend *legendPtr = graphPtr->legend; unsigned int active, redraw; @@ -745,7 +731,7 @@ static int ActivateOp(Graph* graphPtr, Tcl_Interp* interp, } static int BindOp(Graph* graphPtr, Tcl_Interp* interp, - int objc, Tcl_Obj *const *objv) + int objc, Tcl_Obj* const objv[]) { if (objc == 3) { Tcl_HashEntry *hPtr; @@ -769,7 +755,7 @@ static int BindOp(Graph* graphPtr, Tcl_Interp* interp, } static int CurselectionOp(Graph* graphPtr, Tcl_Interp* interp, - int objc, Tcl_Obj *const *objv) + int objc, Tcl_Obj* const objv[]) { Legend *legendPtr = graphPtr->legend; Tcl_Obj *listObjPtr; @@ -810,7 +796,7 @@ static int CurselectionOp(Graph* graphPtr, Tcl_Interp* interp, } static int FocusOp(Graph* graphPtr, Tcl_Interp* interp, - int objc, Tcl_Obj *const *objv) + int objc, Tcl_Obj* const objv[]) { Legend *legendPtr = graphPtr->legend; @@ -837,7 +823,7 @@ static int FocusOp(Graph* graphPtr, Tcl_Interp* interp, } static int GetOp(Graph* graphPtr, Tcl_Interp* interp, - int objc, Tcl_Obj *const *objv) + int objc, Tcl_Obj* const objv[]) { Legend *legendPtr = graphPtr->legend; @@ -854,24 +840,6 @@ static int GetOp(Graph* graphPtr, Tcl_Interp* interp, return TCL_OK; } -static Blt_OpSpec selectionOps[]; -static int nSelectionOps; - -static int SelectionOp(Graph* graphPtr, Tcl_Interp* interp, - int objc, Tcl_Obj *const *objv) -{ - GraphLegendProc *proc; - int result; - - proc = Blt_GetOpFromObj(interp, nSelectionOps, selectionOps, BLT_OP_ARG3, - objc, objv, 0); - if (proc == NULL) { - return TCL_ERROR; - } - result = (*proc) (graphPtr, interp, objc, objv); - return result; -} - static Blt_OpSpec legendOps[] = { {"activate", 1, ActivateOp, 3, 0, "?pattern?...",}, @@ -886,10 +854,21 @@ static Blt_OpSpec legendOps[] = }; static int nLegendOps = sizeof(legendOps) / sizeof(Blt_OpSpec); +int Blt_LegendOp(Graph* graphPtr, Tcl_Interp* interp, + int objc, Tcl_Obj* const objv[]) +{ + GraphLegendProc *proc = Blt_GetOpFromObj(interp, nLegendOps, legendOps, + BLT_OP_ARG2, objc, objv,0); + if (proc == NULL) + return TCL_ERROR; + + return (*proc)(graphPtr, interp, objc, objv); +} + // Selection Widget Ops static int SelectionAnchorOp(Graph* graphPtr, Tcl_Interp* interp, - int objc, Tcl_Obj *const *objv) + int objc, Tcl_Obj* const objv[]) { Legend *legendPtr = graphPtr->legend; Element* elemPtr; @@ -909,7 +888,7 @@ static int SelectionAnchorOp(Graph* graphPtr, Tcl_Interp* interp, } static int SelectionClearallOp(Graph* graphPtr, Tcl_Interp* interp, - int objc, Tcl_Obj *const *objv) + int objc, Tcl_Obj* const objv[]) { Legend *legendPtr = graphPtr->legend; @@ -918,7 +897,7 @@ static int SelectionClearallOp(Graph* graphPtr, Tcl_Interp* interp, } static int SelectionIncludesOp(Graph* graphPtr, Tcl_Interp* interp, - int objc, Tcl_Obj *const *objv) + int objc, Tcl_Obj* const objv[]) { Legend *legendPtr = graphPtr->legend; Element* elemPtr; @@ -933,7 +912,7 @@ static int SelectionIncludesOp(Graph* graphPtr, Tcl_Interp* interp, } static int SelectionMarkOp(Graph* graphPtr, Tcl_Interp* interp, - int objc, Tcl_Obj *const *objv) + int objc, Tcl_Obj* const objv[]) { Legend *legendPtr = graphPtr->legend; Element* elemPtr; @@ -976,7 +955,7 @@ static int SelectionMarkOp(Graph* graphPtr, Tcl_Interp* interp, } static int SelectionPresentOp(Graph* graphPtr, Tcl_Interp* interp, - int objc, Tcl_Obj *const *objv) + int objc, Tcl_Obj* const objv[]) { Legend *legendPtr = graphPtr->legend; int bool; @@ -987,7 +966,7 @@ static int SelectionPresentOp(Graph* graphPtr, Tcl_Interp* interp, } static int SelectionSetOp(Graph* graphPtr, Tcl_Interp* interp, - int objc, Tcl_Obj *const *objv) + int objc, Tcl_Obj* const objv[]) { Legend *legendPtr = graphPtr->legend; Element *firstPtr, *lastPtr; @@ -1059,6 +1038,18 @@ static Blt_OpSpec selectionOps[] = }; static int nSelectionOps = sizeof(selectionOps) / sizeof(Blt_OpSpec); +static int SelectionOp(Graph* graphPtr, Tcl_Interp* interp, + int objc, Tcl_Obj* const objv[]) +{ + GraphLegendProc* proc = Blt_GetOpFromObj(interp, nSelectionOps, + selectionOps, BLT_OP_ARG3, + objc, objv, 0); + if (proc == NULL) + return TCL_ERROR; + + return (*proc)(graphPtr, interp, objc, objv); +} + // Support static void DisplayLegend(ClientData clientData) diff --git a/src/bltGrLegd.h b/src/bltGrLegd.h index 500320b..425aaee 100644 --- a/src/bltGrLegd.h +++ b/src/bltGrLegd.h @@ -55,7 +55,7 @@ extern void Blt_DestroyLegend(Graph *graphPtr); extern void Blt_DrawLegend(Graph *graphPtr, Drawable drawable); extern void Blt_MapLegend(Graph *graphPtr, int width, int height); extern int Blt_LegendOp(Graph *graphPtr, Tcl_Interp* interp, int objc, - Tcl_Obj *const *objv); + Tcl_Obj* const objv[]); extern int Blt_Legend_Site(Graph *graphPtr); extern int Blt_Legend_Width(Graph *graphPtr); extern int Blt_Legend_Height(Graph *graphPtr); diff --git a/src/bltGrMarker.C b/src/bltGrMarker.C index 9a7cb61..edbaf7d 100644 --- a/src/bltGrMarker.C +++ b/src/bltGrMarker.C @@ -42,7 +42,7 @@ #include "bltConfig.h" typedef int (GraphMarkerProc)(Graph* graphPtr, Tcl_Interp* interp, int objc, - Tcl_Obj *const *objv); + Tcl_Obj* const objv[]); #define GETBITMAP(b) \ (((b)->destBitmap == None) ? (b)->srcBitmap : (b)->destBitmap) @@ -976,7 +976,7 @@ ParseCoordinates( Tcl_Interp* interp, Marker *markerPtr, int objc, - Tcl_Obj *const *objv) + Tcl_Obj* const objv[]) { int nWorldPts; int minArgs, maxArgs; @@ -3528,7 +3528,7 @@ RenameMarker(Graph* graphPtr, Marker *markerPtr, const char* oldName, *--------------------------------------------------------------------------- */ static int -NamesOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +NamesOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { Tcl_Obj *listObjPtr; @@ -3580,7 +3580,7 @@ NamesOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) */ /*ARGSUSED*/ static int -BindOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +BindOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { if (objc == 3) { Tcl_HashEntry *hp; @@ -3614,7 +3614,7 @@ BindOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) */ /*ARGSUSED*/ static int -CgetOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +CgetOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { Marker *markerPtr; @@ -3642,7 +3642,7 @@ CgetOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) *--------------------------------------------------------------------------- */ static int -ConfigureOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +ConfigureOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { Marker *markerPtr; Tcl_Obj *const *options; @@ -3726,7 +3726,7 @@ ConfigureOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) *--------------------------------------------------------------------------- */ static int -CreateOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +CreateOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { Marker *markerPtr; Tcl_HashEntry *hPtr; @@ -3830,7 +3830,7 @@ CreateOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) */ /*ARGSUSED*/ static int -DeleteOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +DeleteOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { int i; @@ -3866,7 +3866,7 @@ DeleteOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) */ /*ARGSUSED*/ static int -GetOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +GetOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { Marker *markerPtr; const char* string; @@ -3907,7 +3907,7 @@ GetOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) */ /*ARGSUSED*/ static int -RelinkOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +RelinkOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { Blt_ChainLink link, place; Marker *markerPtr; @@ -3959,7 +3959,7 @@ RelinkOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) */ /*ARGSUSED*/ static int -FindOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +FindOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { Blt_ChainLink link; Region2d extents; @@ -4039,7 +4039,7 @@ FindOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) */ /*ARGSUSED*/ static int -ExistsOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +ExistsOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { Tcl_HashEntry *hPtr; @@ -4063,7 +4063,7 @@ ExistsOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) */ /*ARGSUSED*/ static int -TypeOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +TypeOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { Marker *markerPtr; const char* type; @@ -4124,7 +4124,7 @@ static int nMarkerOps = sizeof(markerOps) / sizeof(Blt_OpSpec); /*ARGSUSED*/ int Blt_MarkerOp(Graph* graphPtr, Tcl_Interp* interp, int objc, - Tcl_Obj *const *objv) + Tcl_Obj* const objv[]) { GraphMarkerProc *proc; int result; diff --git a/src/bltGrPenOp.C b/src/bltGrPenOp.C index 916e140..b6c468f 100644 --- a/src/bltGrPenOp.C +++ b/src/bltGrPenOp.C @@ -49,7 +49,7 @@ static int GetPenFromObj(Tcl_Interp* interp, Graph* graphPtr, Tcl_Obj *objPtr, static int PenObjConfigure(Tcl_Interp* interp, Graph* graphPtr, Pen* penPtr, int objc, Tcl_Obj* const objv[]); typedef int (GraphPenProc)(Tcl_Interp* interp, Graph* graphPtr, int objc, - Tcl_Obj *const *objv); + Tcl_Obj* const objv[]); // OptionSpecs @@ -191,7 +191,7 @@ static int CgetOp(Tcl_Interp* interp, Graph* graphPtr, } static int ConfigureOp(Tcl_Interp* interp, Graph* graphPtr, - int objc, Tcl_Obj *const *objv) + int objc, Tcl_Obj* const objv[]) { Pen* penPtr; if (GetPenFromObj(interp, graphPtr, objv[3], &penPtr) != TCL_OK) @@ -256,7 +256,7 @@ static int PenObjConfigure(Tcl_Interp* interp, Graph* graphPtr, Pen* penPtr, // Ops static int CreateOp(Tcl_Interp* interp, Graph* graphPtr, - int objc, Tcl_Obj *const *objv) + int objc, Tcl_Obj* const objv[]) { if (Blt_CreatePen(graphPtr, interp, Tcl_GetString(objv[3]), graphPtr->classId, objc, objv) != TCL_OK) return TCL_ERROR; @@ -265,32 +265,27 @@ static int CreateOp(Tcl_Interp* interp, Graph* graphPtr, } static int DeleteOp(Tcl_Interp* interp, Graph* graphPtr, - int objc, Tcl_Obj *const *objv) + int objc, Tcl_Obj* const objv[]) { - int i; - - for (i = 3; i < objc; i++) { - Pen* penPtr; + Pen* penPtr; + if (GetPenFromObj(interp, graphPtr, objv[3], &penPtr) != TCL_OK) + return TCL_ERROR; - if (GetPenFromObj(interp, graphPtr, objv[i], &penPtr) != TCL_OK) { - return TCL_ERROR; - } - if (penPtr->flags & DELETE_PENDING) { - Tcl_AppendResult(interp, "can't find pen \"", - Tcl_GetString(objv[i]), "\" in \"", - Tk_PathName(graphPtr->tkwin), "\"", (char *)NULL); - return TCL_ERROR; - } - penPtr->flags |= DELETE_PENDING; - if (penPtr->refCount == 0) { - DestroyPen(penPtr); - } + if (penPtr->flags & DELETE_PENDING) { + Tcl_AppendResult(interp, "can't find pen \"", + Tcl_GetString(objv[i]), "\" in \"", + Tk_PathName(graphPtr->tkwin), "\"", (char *)NULL); + return TCL_ERROR; } + penPtr->flags |= DELETE_PENDING; + if (penPtr->refCount == 0) + DestroyPen(penPtr); + return TCL_OK; } static int NamesOp(Tcl_Interp* interp, Graph* graphPtr, - int objc, Tcl_Obj *const *objv) + int objc, Tcl_Obj* const objv[]) { Tcl_Obj *listObjPtr; @@ -339,10 +334,9 @@ static int NamesOp(Tcl_Interp* interp, Graph* graphPtr, } static int TypeOp(Tcl_Interp* interp, Graph* graphPtr, - int objc, Tcl_Obj *const *objv) + int objc, Tcl_Obj* const objv[]) { Pen* penPtr; - if (GetPenFromObj(interp, graphPtr, objv[3], &penPtr) != TCL_OK) return TCL_ERROR; @@ -362,19 +356,19 @@ static Blt_OpSpec penOps[] = }; static int nPenOps = sizeof(penOps) / sizeof(Blt_OpSpec); -// Extern - int Blt_PenOp(Graph* graphPtr, Tcl_Interp* interp, - int objc, Tcl_Obj *const *objv) + int objc, Tcl_Obj* const objv[]) { GraphPenProc *proc = Blt_GetOpFromObj(interp, nPenOps, penOps, BLT_OP_ARG2, objc, objv, 0); - if (proc == NULL) { + if (proc == NULL) return TCL_ERROR; - } - return (*proc) (interp, graphPtr, objc, objv); + + return (*proc)(interp, graphPtr, objc, objv); } +// Support + void Blt_DestroyPens(Graph* graphPtr) { Tcl_HashEntry *hPtr; diff --git a/src/bltGraph.C b/src/bltGraph.C index 122901f..a56a6da 100644 --- a/src/bltGraph.C +++ b/src/bltGraph.C @@ -81,6 +81,9 @@ static void ConfigureGraph(Graph* graphPtr); static void DrawPlot(Graph* graphPtr, Drawable drawable); static void UpdateMarginTraces(Graph* graphPtr); +typedef int (GraphCmdProc)(Graph* graphPtr, Tcl_Interp* interp, int objc, + Tcl_Obj* const objv[]); + // OptionSpecs static char* barmodeObjOption[] = @@ -300,6 +303,8 @@ static int NewGraph(ClientData clientData, Tcl_Interp*interp, if (Blt_CreatePen(graphPtr, interp, "activeBar", CID_ELEM_BAR, 0, NULL) != TCL_OK) goto error; + if (Blt_CreateAxes(graphPtr) != TCL_OK) + goto error; if (Blt_CreatePageSetup(graphPtr) != TCL_OK) goto error; @@ -322,8 +327,7 @@ static int NewGraph(ClientData clientData, Tcl_Interp*interp, if (Blt_ConfigurePageSetup(graphPtr) != TCL_OK) goto error; - if (Blt_DefaultAxes(graphPtr) != TCL_OK) - goto error; + AdjustAxisPointers(graphPtr); Tcl_SetStringObj(Tcl_GetObjResult(interp), @@ -335,26 +339,6 @@ static int NewGraph(ClientData clientData, Tcl_Interp*interp, return TCL_ERROR; } -static Blt_OpSpec graphOps[]; -static int nGraphOps; -typedef int (GraphCmdProc)(Graph* graphPtr, Tcl_Interp* interp, int objc, - Tcl_Obj* const objv[]); - -int Blt_GraphInstCmdProc(ClientData clientData, Tcl_Interp* interp, - int objc, Tcl_Obj* const objv[]) -{ - Graph* graphPtr = clientData; - GraphCmdProc* proc = Blt_GetOpFromObj(interp, nGraphOps, graphOps, - BLT_OP_ARG1, objc, objv, 0); - if (proc == NULL) - return TCL_ERROR; - - Tcl_Preserve(graphPtr); - int result = (*proc)(graphPtr, interp, objc, objv); - Tcl_Release(graphPtr); - return result; -} - // called by Tcl_DeleteCommand static void GraphInstCmdDeleteProc(ClientData clientData) { @@ -663,28 +647,28 @@ static int XAxisOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { int margin = (graphPtr->inverted) ? MARGIN_LEFT : MARGIN_BOTTOM; - return Blt_AxisOp(interp, graphPtr, margin, objc, objv); + return Blt_DefAxisOp(interp, graphPtr, margin, objc, objv); } static int X2AxisOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { int margin = (graphPtr->inverted) ? MARGIN_RIGHT : MARGIN_TOP; - return Blt_AxisOp(interp, graphPtr, margin, objc, objv); + return Blt_DefAxisOp(interp, graphPtr, margin, objc, objv); } static int YAxisOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { int margin = (graphPtr->inverted) ? MARGIN_BOTTOM : MARGIN_LEFT; - return Blt_AxisOp(interp, graphPtr, margin, objc, objv); + return Blt_DefAxisOp(interp, graphPtr, margin, objc, objv); } static int Y2AxisOp(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { int margin = (graphPtr->inverted) ? MARGIN_TOP : MARGIN_RIGHT; - return Blt_AxisOp(interp, graphPtr, margin, objc, objv); + return Blt_DefAxisOp(interp, graphPtr, margin, objc, objv); } static int BarOp(Graph* graphPtr, Tcl_Interp* interp, int objc, @@ -878,7 +862,7 @@ static int TransformOp(Graph* graphPtr, Tcl_Interp* interp, int objc, static Blt_OpSpec graphOps[] = { - {"axis", 1, Blt_VirtualAxisOp, 2, 0, "oper ?args?",}, + {"axis", 1, Blt_AxisOp, 2, 0, "oper ?args?",}, {"bar", 2, BarOp, 2, 0, "oper ?args?",}, {"cget", 2, CgetOp, 3, 3, "option",}, {"configure", 2, ConfigureOp, 2, 0, "?option value?...",}, @@ -900,6 +884,21 @@ static Blt_OpSpec graphOps[] = }; static int nGraphOps = sizeof(graphOps) / sizeof(Blt_OpSpec); +int Blt_GraphInstCmdProc(ClientData clientData, Tcl_Interp* interp, + int objc, Tcl_Obj* const objv[]) +{ + Graph* graphPtr = clientData; + GraphCmdProc* proc = Blt_GetOpFromObj(interp, nGraphOps, graphOps, + BLT_OP_ARG1, objc, objv, 0); + if (proc == NULL) + return TCL_ERROR; + + Tcl_Preserve(graphPtr); + int result = (*proc)(graphPtr, interp, objc, objv); + Tcl_Release(graphPtr); + return result; +} + // Support void Blt_EventuallyRedrawGraph(Graph* graphPtr) diff --git a/src/bltGraph.h b/src/bltGraph.h index 138473d..eb06e73 100644 --- a/src/bltGraph.h +++ b/src/bltGraph.h @@ -568,23 +568,23 @@ extern int Blt_InitBarPens(Graph* graphPtr); extern void Blt_FreePen(Pen* penPtr); -extern int Blt_VirtualAxisOp(Graph* graphPtr, Tcl_Interp* interp, - int objc, Tcl_Obj *const *objv); +extern int Blt_AxisOp(Graph* graphPtr, Tcl_Interp* interp, + int objc, Tcl_Obj* const objv[]); -extern int Blt_AxisOp(Tcl_Interp* interp, Graph* graphPtr, int margin, - int objc, Tcl_Obj *const *objv); +extern int Blt_DefAxisOp(Tcl_Interp* interp, Graph* graphPtr, int margin, + int objc, Tcl_Obj* const objv[]); extern int Blt_ElementOp(Graph* graphPtr, Tcl_Interp* interp, int objc, - Tcl_Obj *const *objv, ClassId classId); + Tcl_Obj* const objv[], ClassId classId); extern int Blt_CrosshairsOp(Graph* graphPtr, Tcl_Interp* interp, int objc, - Tcl_Obj *const *objv); + Tcl_Obj* const objv[]); extern int Blt_MarkerOp(Graph* graphPtr, Tcl_Interp* interp, int objc, - Tcl_Obj *const *objv); + Tcl_Obj* const objv[]); extern int Blt_PenOp(Graph* graphPtr, Tcl_Interp* interp, int objc, - Tcl_Obj *const *objv); + Tcl_Obj* const objv[]); extern int Blt_PointInPolygon(Point2d *samplePtr, Point2d *screenPts, int nScreenPts); @@ -596,11 +596,11 @@ extern int Blt_PointInSegments(Point2d *samplePtr, Segment2d *segments, int nSegments, double halo); extern int Blt_PostScriptOp(Graph* graphPtr, Tcl_Interp* interp, int objc, - Tcl_Obj *const *objv); + Tcl_Obj* const objv[]); extern int Blt_GraphUpdateNeeded(Graph* graphPtr); -extern int Blt_DefaultAxes(Graph* graphPtr); +extern int Blt_CreateAxes(Graph* graphPtr); extern Axis *Blt_GetFirstAxis(Blt_Chain chain); diff --git a/src/bltOp.h b/src/bltOp.h index 4722303..25db5c4 100644 --- a/src/bltOp.h +++ b/src/bltOp.h @@ -37,6 +37,6 @@ typedef enum { #define BLT_OP_LINEAR_SEARCH 1 extern void *Blt_GetOpFromObj(Tcl_Interp* interp, int nSpecs, - Blt_OpSpec *specs, int operPos, int objc, Tcl_Obj *const *objv, + Blt_OpSpec *specs, int operPos, int objc, Tcl_Obj* const objv[], int flags); diff --git a/src/bltSwitch.C b/src/bltSwitch.C index 753c765..891a47f 100644 --- a/src/bltSwitch.C +++ b/src/bltSwitch.C @@ -325,7 +325,7 @@ Blt_ParseSwitches( Tcl_Interp* interp, /* Interpreter for error reporting. */ Blt_SwitchSpec *specs, /* Describes legal switches. */ int objc, /* Number of elements in argv. */ - Tcl_Obj *const *objv, /* Command-line switches. */ + Tcl_Obj* const objv[], /* Command-line switches. */ void *record, /* Record whose fields are to be modified. * Values must be properly initialized. */ int flags) /* Used to specify additional flags that must diff --git a/src/bltVecCmd.C b/src/bltVecCmd.C index 12ad4e8..44cb1bf 100644 --- a/src/bltVecCmd.C +++ b/src/bltVecCmd.C @@ -61,7 +61,7 @@ #include "bltSwitch.h" typedef int (VectorCmdProc)(Vector *vPtr, Tcl_Interp* interp, int objc, - Tcl_Obj *const *objv); + Tcl_Obj* const objv[]); static Blt_SwitchParseProc ObjToFFTVector; static Blt_SwitchCustom fftVectorSwitch = { @@ -236,7 +236,7 @@ ReplicateValue(Vector *vPtr, int first, int last, double value) } static int -CopyList(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +CopyList(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { int i; @@ -274,7 +274,7 @@ AppendVector(Vector *destPtr, Vector *srcPtr) } static int -AppendList(Vector *vPtr, int objc, Tcl_Obj *const *objv) +AppendList(Vector *vPtr, int objc, Tcl_Obj* const objv[]) { Tcl_Interp* interp = vPtr->interp; int count; @@ -319,7 +319,7 @@ AppendList(Vector *vPtr, int objc, Tcl_Obj *const *objv) *--------------------------------------------------------------------------- */ static int -AppendOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +AppendOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { int i; int result; @@ -372,7 +372,7 @@ AppendOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) */ /*ARGSUSED*/ static int -ClearOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +ClearOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { Blt_Vec_FlushCache(vPtr); return TCL_OK; @@ -398,7 +398,7 @@ ClearOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) */ /*ARGSUSED*/ static int -DeleteOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +DeleteOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { unsigned char *unsetArr; int i, j; @@ -467,7 +467,7 @@ DeleteOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) */ /*ARGSUSED*/ static int -DupOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +DupOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { int i; @@ -503,7 +503,7 @@ DupOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) /* fft implementation */ /*ARGSUSED*/ static int -FFTOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +FFTOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { Vector *v2Ptr = NULL; int isNew; @@ -556,7 +556,7 @@ FFTOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) /*ARGSUSED*/ static int -InverseFFTOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +InverseFFTOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { int isNew; char *name; @@ -606,7 +606,7 @@ InverseFFTOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) *--------------------------------------------------------------------------- */ static int -IndexOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +IndexOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { int first, last; char *string; @@ -671,7 +671,7 @@ IndexOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) *--------------------------------------------------------------------------- */ static int -LengthOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +LengthOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { if (objc == 3) { int nElem; @@ -714,7 +714,7 @@ LengthOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) */ /*ARGSUSED*/ static int -MapOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +MapOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { if (objc > 2) { if (Blt_Vec_MapVariable(interp, vPtr, Tcl_GetString(objv[2])) @@ -742,7 +742,7 @@ MapOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) */ /*ARGSUSED*/ static int -MaxOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +MaxOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { Tcl_SetDoubleObj(Tcl_GetObjResult(interp), Blt_Vec_Max(vPtr)); return TCL_OK; @@ -764,7 +764,7 @@ MaxOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) */ /*ARGSUSED*/ static int -MergeOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +MergeOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { Vector **vecArr; int refSize, nElem; @@ -839,7 +839,7 @@ MergeOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) */ /*ARGSUSED*/ static int -MinOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +MinOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { Tcl_SetDoubleObj(Tcl_GetObjResult(interp), Blt_Vec_Min(vPtr)); return TCL_OK; @@ -860,7 +860,7 @@ MinOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) */ /*ARGSUSED*/ static int -NormalizeOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +NormalizeOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { int i; double range; @@ -928,7 +928,7 @@ NormalizeOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) */ /*ARGSUSED*/ static int -NotifyOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +NotifyOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { int option; int bool; @@ -990,7 +990,7 @@ NotifyOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) */ /*ARGSUSED*/ static int -PopulateOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +PopulateOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { Vector *v2Ptr; int size, density; @@ -1059,7 +1059,7 @@ PopulateOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) */ /*ARGSUSED*/ static int -ValuesOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +ValuesOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { PrintSwitches switches; @@ -1122,7 +1122,7 @@ ValuesOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) */ /*ARGSUSED*/ static int -RangeOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +RangeOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { Tcl_Obj *listObjPtr; int first, last; @@ -1389,7 +1389,7 @@ CopyValues(Vector *vPtr, char *byteArr, enum NativeFormats fmt, int size, */ /*ARGSUSED*/ static int -BinreadOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +BinreadOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { Tcl_Channel channel; char *byteArr; @@ -1537,7 +1537,7 @@ BinreadOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) */ /*ARGSUSED*/ static int -SearchOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +SearchOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { double min, max; int i; @@ -1605,7 +1605,7 @@ SearchOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) */ /*ARGSUSED*/ static int -OffsetOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +OffsetOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { if (objc == 3) { int newOffset; @@ -1633,7 +1633,7 @@ OffsetOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) */ /*ARGSUSED*/ static int -RandomOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +RandomOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { int i; @@ -1661,7 +1661,7 @@ RandomOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) */ /*ARGSUSED*/ static int -SeqOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +SeqOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { int n; double start, stop; @@ -1715,7 +1715,7 @@ SeqOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) */ /*ARGSUSED*/ static int -SetOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +SetOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { int result; Vector *v2Ptr; @@ -1783,7 +1783,7 @@ SetOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) */ /*ARGSUSED*/ static int -SimplifyOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +SimplifyOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { size_t i, n; int length, nPoints; @@ -1828,7 +1828,7 @@ SimplifyOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) */ /*ARGSUSED*/ static int -SplitOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +SplitOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { int nVectors; @@ -1936,7 +1936,7 @@ Blt_Vec_SortMap(Vector **vectors, int nVectors) } static size_t * -SortVectors(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +SortVectors(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { Vector **vectors, *v2Ptr; size_t *map; @@ -1985,7 +1985,7 @@ SortVectors(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) *--------------------------------------------------------------------------- */ static int -SortOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +SortOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { Vector *v2Ptr; double *copy; @@ -2091,7 +2091,7 @@ SortOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) */ /*ARGSUSED*/ static int -InstExprOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +InstExprOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { if (Blt_ExprVector(interp, Tcl_GetString(objv[2]), (Blt_Vector *)vPtr) @@ -2123,7 +2123,7 @@ InstExprOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) */ /*ARGSUSED*/ static int -ArithOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj *const *objv) +ArithOp(Vector *vPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { double value; int i; @@ -2276,7 +2276,7 @@ static int nInstOps = sizeof(vectorInstOps) / sizeof(Blt_OpSpec); int Blt_Vec_InstCmd(ClientData clientData, Tcl_Interp* interp, int objc, - Tcl_Obj *const *objv) + Tcl_Obj* const objv[]) { VectorCmdProc *proc; Vector *vPtr = clientData; diff --git a/src/bltVector.C b/src/bltVector.C index f149b35..bf69143 100644 --- a/src/bltVector.C +++ b/src/bltVector.C @@ -118,7 +118,7 @@ static Blt_SwitchSpec createSwitches[] = }; typedef int (VectorCmdProc)(Vector *vecObjPtr, Tcl_Interp* interp, - int objc, Tcl_Obj *const *objv); + int objc, Tcl_Obj* const objv[]); static Vector * FindVectorInNamespace( @@ -1385,7 +1385,7 @@ VectorNamesOp( ClientData clientData, /* Interpreter-specific data. */ Tcl_Interp* interp, int objc, - Tcl_Obj *const *objv) + Tcl_Obj* const objv[]) { VectorInterpData *dataPtr = clientData; Tcl_Obj *listObjPtr; @@ -1457,7 +1457,7 @@ VectorCreate2( Tcl_Interp* interp, int argStart, int objc, - Tcl_Obj *const *objv) + Tcl_Obj* const objv[]) { VectorInterpData *dataPtr = clientData; Vector *vPtr; @@ -1621,7 +1621,7 @@ VectorCreateOp( ClientData clientData, Tcl_Interp* interp, int objc, - Tcl_Obj *const *objv) + Tcl_Obj* const objv[]) { return VectorCreate2(clientData, interp, 2, objc, objv); } @@ -1648,7 +1648,7 @@ VectorDestroyOp( ClientData clientData, /* Interpreter-specific data. */ Tcl_Interp* interp, /* Not used. */ int objc, - Tcl_Obj *const *objv) + Tcl_Obj* const objv[]) { VectorInterpData *dataPtr = clientData; Vector *vPtr; @@ -1683,7 +1683,7 @@ VectorExprOp( ClientData clientData, /* Not Used. */ Tcl_Interp* interp, int objc, /* Not used. */ - Tcl_Obj *const *objv) + Tcl_Obj* const objv[]) { return Blt_ExprVector(interp, Tcl_GetString(objv[2]), (Blt_Vector *)NULL); } @@ -1706,7 +1706,7 @@ VectorCmd( ClientData clientData, /* Interpreter-specific data. */ Tcl_Interp* interp, int objc, - Tcl_Obj *const *objv) + Tcl_Obj* const objv[]) { VectorCmdProc *proc; /* |