diff options
author | joye <joye> | 2014-04-23 21:42:29 (GMT) |
---|---|---|
committer | joye <joye> | 2014-04-23 21:42:29 (GMT) |
commit | 930a8fe1233c690bf375a2add02fd610d4bbf3d1 (patch) | |
tree | 2a2d235bf523b88edb9cb15e1115a44a0d627aa5 /src/bltGraphOp.C | |
parent | b3f411d7071668e8b88df080cd0bcf9a6b404a72 (diff) | |
download | blt-930a8fe1233c690bf375a2add02fd610d4bbf3d1.zip blt-930a8fe1233c690bf375a2add02fd610d4bbf3d1.tar.gz blt-930a8fe1233c690bf375a2add02fd610d4bbf3d1.tar.bz2 |
*** empty log message ***
Diffstat (limited to 'src/bltGraphOp.C')
-rw-r--r-- | src/bltGraphOp.C | 102 |
1 files changed, 53 insertions, 49 deletions
diff --git a/src/bltGraphOp.C b/src/bltGraphOp.C index f6caeef..d374306 100644 --- a/src/bltGraphOp.C +++ b/src/bltGraphOp.C @@ -56,6 +56,7 @@ using namespace Blt; static Tcl_ObjCmdProc BarchartObjCmd; static Tcl_ObjCmdProc GraphObjCmd; + static Axis* GetFirstAxis(Blt_Chain chain); #define ROUND(x) ((int)((x) + (((x)<0.0) ? -0.5 : 0.5))) @@ -63,45 +64,6 @@ static Axis* GetFirstAxis(Blt_Chain chain); (((x) <= (e)->right) && ((x) >= (e)->left) && \ ((y) <= (e)->bottom) && ((y) >= (e)->top)) -int Blt_GraphCmdInitProc(Tcl_Interp* interp) -{ - static Blt_InitCmdSpec graphSpec = - {"graph", GraphObjCmd, NULL, NULL}; - static Blt_InitCmdSpec barchartSpec = - {"barchart", BarchartObjCmd, NULL, NULL}; - - if (Blt_InitCmd(interp, "::blt", &graphSpec) != TCL_OK) - return TCL_ERROR; - if (Blt_InitCmd(interp, "::blt", &barchartSpec) != TCL_OK) - return TCL_ERROR; - - return TCL_OK; -} - -static int GraphObjCmd(ClientData clientData, Tcl_Interp* interp, int objc, - Tcl_Obj* const objv[]) -{ - if (objc < 2) { - Tcl_WrongNumArgs(interp, 1, objv, "pathName ?options?"); - return TCL_ERROR; - } - - Graph* graphPtr = new LineGraph(clientData, interp, objc, objv); - return graphPtr->valid_ ? TCL_OK : TCL_ERROR; -} - -static int BarchartObjCmd(ClientData clientData, Tcl_Interp* interp, int objc, - Tcl_Obj* const objv[]) -{ - if (objc < 2) { - Tcl_WrongNumArgs(interp, 1, objv, "pathName ?options?"); - return TCL_ERROR; - } - - Graph* graphPtr = new BarGraph(clientData, interp, objc, objv); - return graphPtr->valid_ ? TCL_OK : TCL_ERROR; -} - int GraphObjConfigure(Graph* graphPtr, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { @@ -370,6 +332,58 @@ static const TkEnsemble graphEnsemble[] = { { 0,0,0 } }; +// Support + +static Axis* GetFirstAxis(Blt_Chain chain) +{ + Blt_ChainLink link = Blt_Chain_FirstLink(chain); + if (!link) + return NULL; + + return (Axis*)Blt_Chain_GetValue(link); +} + +// Tk Interface + +int Blt_GraphCmdInitProc(Tcl_Interp* interp) +{ + static Blt_InitCmdSpec graphSpec = + {"graph", GraphObjCmd, NULL, NULL}; + static Blt_InitCmdSpec barchartSpec = + {"barchart", BarchartObjCmd, NULL, NULL}; + + if (Blt_InitCmd(interp, "::blt", &graphSpec) != TCL_OK) + return TCL_ERROR; + if (Blt_InitCmd(interp, "::blt", &barchartSpec) != TCL_OK) + return TCL_ERROR; + + return TCL_OK; +} + +static int GraphObjCmd(ClientData clientData, Tcl_Interp* interp, int objc, + Tcl_Obj* const objv[]) +{ + if (objc < 2) { + Tcl_WrongNumArgs(interp, 1, objv, "pathName ?options?"); + return TCL_ERROR; + } + + Graph* graphPtr = new LineGraph(clientData, interp, objc, objv); + return graphPtr->valid_ ? TCL_OK : TCL_ERROR; +} + +static int BarchartObjCmd(ClientData clientData, Tcl_Interp* interp, int objc, + Tcl_Obj* const objv[]) +{ + if (objc < 2) { + Tcl_WrongNumArgs(interp, 1, objv, "pathName ?options?"); + return TCL_ERROR; + } + + Graph* graphPtr = new BarGraph(clientData, interp, objc, objv); + return graphPtr->valid_ ? TCL_OK : TCL_ERROR; +} + int GraphInstCmdProc(ClientData clientData, Tcl_Interp* interp, int objc, Tcl_Obj* const objv[]) { @@ -380,7 +394,6 @@ int GraphInstCmdProc(ClientData clientData, Tcl_Interp* interp, return result; } - // called by Tcl_DeleteCommand void GraphInstCmdDeleteProc(ClientData clientData) { @@ -439,12 +452,3 @@ void DestroyGraph(char* dataPtr) delete graphPtr; } -static Axis* GetFirstAxis(Blt_Chain chain) -{ - Blt_ChainLink link = Blt_Chain_FirstLink(chain); - if (!link) - return NULL; - - return (Axis*)Blt_Chain_GetValue(link); -} - |