Changeset 913


Ignore:
Timestamp:
Mar 4, 2008 2:14:33 PM (16 years ago)
Author:
gah
Message:

created R2 and newmat11 libraries

Location:
trunk/vizservers/nanovis
Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/vizservers/nanovis/Command.cpp

    r911 r913  
    2424/*
    2525 * TODO:  In no particular order...
    26  *        o Convert to Tcl_CmdObj interface.
     26 *        o Convert to Tcl_CmdObj interface. (done)
    2727 *        o Use Tcl command option parser to reduce size of procedures, remove
    2828 *          lots of extra error checking code.
     
    3636 */
    3737
    38 #define ISO_TEST                0
     38#define ISO_TEST                1
    3939#define PLANE_CMDS              0
    4040#define __TEST_CODE__           0
     
    4242#define _LOCAL_ZINC_TEST_       0
    4343
     44#include <tcl.h>
     45#include "Trace.h"
    4446#include "Command.h"
    45 #include "Trace.h"
    46 
    4747#include "nanovis.h"
     48#include "CmdProc.h"
    4849
    4950#include "RpField1D.h"
     
    129130}";
    130131
    131 static Tcl_CmdProc AxisCmd;
    132 static Tcl_CmdProc CameraCmd;
    133 static Tcl_CmdProc CutplaneCmd;
    134 static Tcl_CmdProc GridCmd;
    135 static Tcl_CmdProc LegendCmd;
     132static Tcl_ObjCmdProc AxisCmd;
     133static Tcl_ObjCmdProc CameraCmd;
     134static Tcl_ObjCmdProc CutplaneCmd;
     135static Tcl_ObjCmdProc GridCmd;
     136static Tcl_ObjCmdProc LegendCmd;
    136137#if PLANE_CMDS
    137 static Tcl_CmdProc PlaneEnableCmd;
    138 static Tcl_CmdProc PlaneLinkCmd;
    139 static Tcl_CmdProc PlaneNewCmd;
     138static Tcl_ObjCmdProc PlaneEnableCmd;
     139static Tcl_ObjCmdProc PlaneLinkCmd;
     140static Tcl_ObjCmdProc PlaneNewCmd;
    140141#endif
    141 static Tcl_CmdProc ScreenCmd;
    142 static Tcl_CmdProc ScreenShotCmd;
    143 static Tcl_CmdProc TransfuncCmd;
    144 static Tcl_CmdProc UniRect2dCmd;
    145 static Tcl_CmdProc UpCmd;
    146 static Tcl_CmdProc VolumeCmd;
    147 static Tcl_CmdProc FlowCmd;
    148 
    149 static int GetVolumeIndices(Tcl_Interp *interp, int argc, const char *argv[],
     142static Tcl_ObjCmdProc ScreenCmd;
     143static Tcl_ObjCmdProc ScreenShotCmd;
     144static Tcl_ObjCmdProc TransfuncCmd;
     145static Tcl_ObjCmdProc UniRect2dCmd;
     146static Tcl_ObjCmdProc UpCmd;
     147static Tcl_ObjCmdProc VolumeCmd;
     148static Tcl_ObjCmdProc FlowCmd;
     149
     150static int GetVolumeIndices(Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv,
    150151        vector<unsigned int>* vectorPtr);
    151 static int GetVolumes(Tcl_Interp *interp, int argc, const char *argv[],
     152static int GetVolumes(Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv,
    152153        vector<Volume *>* vectorPtr);
    153 static int GetVolume(Tcl_Interp *interp, const char *string,
    154         Volume **volPtrPtr);
    155 static int GetVolumeIndex(Tcl_Interp *interp, const char *string,
    156         unsigned int *indexPtr);
    157 static int GetHeightMap(Tcl_Interp *interp, const char *string,
    158         HeightMap **hmPtrPtr);
    159 static int GetIndices(Tcl_Interp *interp, int argc, const char *argv[],
     154static int GetVolumeFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr,
     155        Volume **volPtrPtr);
     156static int GetVolumeIndex(Tcl_Interp *interp, Tcl_Obj *objPtr,
     157        unsigned int *indexPtr);
     158static int GetHeightMap(Tcl_Interp *interp, Tcl_Obj *objPtr, HeightMap **hmPtrPtr);
     159static int GetIndices(Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv,
    160160        vector<unsigned int>* vectorPtr);
    161 static int GetAxis(Tcl_Interp *interp, const char *string, int *valPtr);
    162 static int GetColor(Tcl_Interp *interp, int argc, const char *argv[],
     161static int GetAxisFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, int *indexPtr);
     162static int GetAxisDirFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, int *indexPtr,
     163        int *dirPtr);
     164static int GetColor(Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv,
    163165        float *rgbPtr);
    164166static int GetDataStream(Tcl_Interp *interp, Rappture::Buffer &buf,
    165167        int nBytes);
    166168static HeightMap *CreateHeightMap(ClientData clientData, Tcl_Interp *interp,
    167         int argc, const char *argv[]);
    168 
    169 static int
    170 GetFloat(Tcl_Interp *interp, const char *string, float *valuePtr)
     169        int objc, Tcl_Obj *CONST *objv);
     170
     171static int
     172GetFloatFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, float *valuePtr)
    171173{
    172174    double value;
    173175
    174     if (Tcl_GetDouble(interp, string, &value) != TCL_OK) {
     176    if (Tcl_GetDoubleFromObj(interp, objPtr, &value) != TCL_OK) {
    175177        return TCL_ERROR;
    176178    }
     
    180182
    181183static int
    182 GetCullMode(Tcl_Interp *interp, const char *string,
    183             graphics::RenderContext::CullMode *modePtr)
    184 {
     184GetCullMode(Tcl_Interp *interp, Tcl_Obj *objPtr,
     185        graphics::RenderContext::CullMode *modePtr)
     186{
     187    char *string = Tcl_GetString(objPtr);
    185188    if (strcmp(string, "none") == 0) {
    186189        *modePtr = graphics::RenderContext::NO_CULL;
     
    198201
    199202static int
    200 GetShadingModel(Tcl_Interp *interp, const char *string,
     203GetShadingModel(Tcl_Interp *interp, Tcl_Obj *objPtr,
    201204                graphics::RenderContext::ShadingModel *modelPtr)
    202205{
     206    char *string = Tcl_GetString(objPtr);
    203207    if (strcmp(string,"flat") == 0) {
    204208        *modelPtr = graphics::RenderContext::FLAT;
     
    214218
    215219static int
    216 GetPolygonMode(Tcl_Interp *interp, const char *string,
     220GetPolygonMode(Tcl_Interp *interp, Tcl_Obj *objPtr,
    217221               graphics::RenderContext::PolygonMode *modePtr)
    218222{
     223    char *string = Tcl_GetString(objPtr);
    219224    if (strcmp(string,"wireframe") == 0) {
    220225        *modePtr = graphics::RenderContext::LINE;
     
    281286 */
    282287static int
    283 CameraCmd(ClientData cdata, Tcl_Interp *interp, int argc, const char *argv[])
    284 {
    285     if (argc < 2) {
    286         Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    287                          " option arg arg...\"", (char*)NULL);
    288         return TCL_ERROR;
    289     }
    290 
    291     char c = argv[1][0];
    292     if ((c == 'a') && (strcmp(argv[1],"angle") == 0)) {
    293         if (argc != 5) {
    294             Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    295                              " angle xangle yangle zangle\"", (char*)NULL);
     288CameraCmd(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv)
     289{
     290    if (objc < 2) {
     291        Tcl_AppendResult(interp, "wrong # args: should be \"",
     292                Tcl_GetString(objv[0]), " option arg arg...\"", (char*)NULL);
     293        return TCL_ERROR;
     294    }
     295
     296    char *string = Tcl_GetString(objv[1]);
     297    char c = string[0];
     298    if ((c == 'a') && (strcmp(string, "angle") == 0)) {
     299        if (objc != 5) {
     300            Tcl_AppendResult(interp, "wrong # args: should be \"",
     301                Tcl_GetString(objv[0]), " angle xangle yangle zangle\"",
     302                (char*)NULL);
    296303            return TCL_ERROR;
    297304        }
    298305        double xangle, yangle, zangle;
    299         if ((Tcl_GetDouble(interp, argv[2], &xangle) != TCL_OK) ||
    300             (Tcl_GetDouble(interp, argv[3], &yangle) != TCL_OK) ||
    301             (Tcl_GetDouble(interp, argv[4], &zangle) != TCL_OK)) {
     306        if ((Tcl_GetDoubleFromObj(interp, objv[2], &xangle) != TCL_OK) ||
     307            (Tcl_GetDoubleFromObj(interp, objv[3], &yangle) != TCL_OK) ||
     308            (Tcl_GetDoubleFromObj(interp, objv[4], &zangle) != TCL_OK)) {
    302309            return TCL_ERROR;
    303310        }
    304311        NanoVis::cam->rotate(xangle, yangle, zangle);
    305     } else if ((c == 'a') && (strcmp(argv[1], "aim") == 0)) {
    306         if (argc != 5) {
    307             Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    308                              " aim x y z\"", (char*)NULL);
    309             return TCL_ERROR;
    310         }
    311        
     312    } else if ((c == 'a') && (strcmp(string, "aim") == 0)) {
     313        if (objc != 5) {
     314            Tcl_AppendResult(interp, "wrong # args: should be \"",
     315                Tcl_GetString(objv[0]), " aim x y z\"", (char*)NULL);
     316            return TCL_ERROR;
     317        }
    312318        double x0, y0, z0;
    313         if ((Tcl_GetDouble(interp, argv[2], &x0) != TCL_OK) ||
    314             (Tcl_GetDouble(interp, argv[3], &y0) != TCL_OK) ||
    315             (Tcl_GetDouble(interp, argv[4], &z0) != TCL_OK)) {
     319        if ((Tcl_GetDoubleFromObj(interp, objv[2], &x0) != TCL_OK) ||
     320            (Tcl_GetDoubleFromObj(interp, objv[3], &y0) != TCL_OK) ||
     321            (Tcl_GetDoubleFromObj(interp, objv[4], &z0) != TCL_OK)) {
    316322            return TCL_ERROR;
    317323        }
    318324        NanoVis::cam->aim(x0, y0, z0);
    319     } else if ((c == 'z') && (strcmp(argv[1],"zoom") == 0)) {
    320         if (argc != 3) {
    321             Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    322                             " zoom factor\"", (char*)NULL);
     325    } else if ((c == 'z') && (strcmp(string, "zoom") == 0)) {
     326        if (objc != 3) {
     327            Tcl_AppendResult(interp, "wrong # args: should be \"",
     328                Tcl_GetString(objv[0]), " zoom factor\"", (char*)NULL);
    323329            return TCL_ERROR;
    324330        }
    325331       
    326332        double zoom;
    327         if (Tcl_GetDouble(interp, argv[2], &zoom) != TCL_OK) {
     333        if (Tcl_GetDoubleFromObj(interp, objv[2], &zoom) != TCL_OK) {
    328334            return TCL_ERROR;
    329335        }
    330336        NanoVis::zoom(zoom);
    331337    } else {
    332         Tcl_AppendResult(interp, "bad camera option \"", argv[1],
     338        Tcl_AppendResult(interp, "bad camera option \"", string,
    333339                     "\": should be aim, angle, or zoom", (char*)NULL);
    334340        return TCL_ERROR;
     
    350356
    351357static int
    352 ScreenShotCmd(ClientData cdata, Tcl_Interp *interp, int argc,
    353               const char *argv[])
     358ScreenShotCmd(ClientData cdata, Tcl_Interp *interp, int objc,
     359              Tcl_Obj *CONST *objv)
    354360{
    355361#ifdef XINETD
     
    400406 */
    401407static int
    402 CutplaneCmd(ClientData cdata, Tcl_Interp *interp, int argc,
    403             const char *argv[])
    404 {
    405     if (argc < 2) {
    406         Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    407             " option ?arg arg...?\"", (char*)NULL);
    408         return TCL_ERROR;
    409     }
    410 
    411     char c = argv[1][0];
    412     if ((c == 's') && (strcmp(argv[1],"state") == 0)) {
    413         if (argc < 4) {
    414             Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    415                 " state on|off axis ?volume ...? \"", (char*)NULL);
     408CutplaneCmd(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv)
     409{
     410    if (objc < 2) {
     411        Tcl_AppendResult(interp, "wrong # args: should be \"",
     412                Tcl_GetString(objv[0]), " option ?arg arg...?\"", (char*)NULL);
     413        return TCL_ERROR;
     414    }
     415
     416    char *string = Tcl_GetString(objv[1]);
     417    char c = string[0];
     418    if ((c == 's') && (strcmp(string, "state") == 0)) {
     419        if (objc < 4) {
     420            Tcl_AppendResult(interp, "wrong # args: should be \"",
     421                Tcl_GetString(objv[0]), " state on|off axis ?volume ...? \"",
     422                (char*)NULL);
    416423            return TCL_ERROR;
    417424        }
    418425
    419426        int state;
    420         if (Tcl_GetBoolean(interp, argv[2], &state) != TCL_OK) {
     427        if (Tcl_GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
    421428            return TCL_ERROR;
    422429        }
    423430
    424431        int axis;
    425         if (GetAxis(interp, (char*) argv[3], &axis) != TCL_OK) {
     432        if (GetAxisFromObj(interp, objv[3], &axis) != TCL_OK) {
    426433            return TCL_ERROR;
    427434        }
    428435
    429436        vector<Volume *> ivol;
    430         if (GetVolumes(interp, argc-4, argv+4, &ivol) != TCL_OK) {
     437        if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) {
    431438            return TCL_ERROR;
    432439        }
     
    442449            }
    443450        }
    444     } else if ((c == 'p') && (strcmp(argv[1],"position") == 0)) {
    445         if (argc < 4) {
    446             Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    447                 " position relval axis ?volume ...? \"", (char*)NULL);
     451    } else if ((c == 'p') && (strcmp(string, "position") == 0)) {
     452        if (objc < 4) {
     453            Tcl_AppendResult(interp, "wrong # args: should be \"",
     454                Tcl_GetString(objv[0]), " position relval axis ?volume ...? \"",
     455                (char*)NULL);
    448456            return TCL_ERROR;
    449457        }
    450458
    451459        float relval;
    452         if (GetFloat(interp, argv[2], &relval) != TCL_OK) {
     460        if (GetFloatFromObj(interp, objv[2], &relval) != TCL_OK) {
    453461            return TCL_ERROR;
    454462        }
     
    462470
    463471        int axis;
    464         if (GetAxis(interp, argv[3], &axis) != TCL_OK) {
     472        if (GetAxisFromObj(interp, objv[3], &axis) != TCL_OK) {
    465473            return TCL_ERROR;
    466474        }
    467475
    468476        vector<Volume *> ivol;
    469         if (GetVolumes(interp, argc-4, argv+4, &ivol) != TCL_OK) {
     477        if (GetVolumes(interp, objc-4, objv+4, &ivol) != TCL_OK) {
    470478            return TCL_ERROR;
    471479        }
     
    475483        }
    476484    } else {
    477         Tcl_AppendResult(interp, "bad option \"", argv[1],
     485        Tcl_AppendResult(interp, "bad option \"", string,
    478486                         "\": should be position or state", (char*)NULL);
    479487        return TCL_ERROR;
     
    494502 */
    495503static int
    496 LegendCmd(ClientData cdata, Tcl_Interp *interp, int argc, const char *argv[])
    497 {
    498     if (argc != 4) {
    499         Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    500             " transfunc width height\"", (char*)NULL);
     504LegendCmd(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv)
     505{
     506    if (objc != 4) {
     507        Tcl_AppendResult(interp, "wrong # args: should be \"",
     508                Tcl_GetString(objv[0]), " transfunc width height\"", (char*)NULL);
    501509        return TCL_ERROR;
    502510    }
    503511
    504512    Volume *volPtr;
    505     if (GetVolume(interp, argv[1], &volPtr) != TCL_OK) {
     513    if (GetVolumeFromObj(interp, objv[1], &volPtr) != TCL_OK) {
    506514        return TCL_ERROR;
    507515    }
     
    510518    if (tf == NULL) {
    511519        Tcl_AppendResult(interp, "no transfer function defined for volume \"",
    512                 argv[1], "\"", (char*)NULL);
    513         return TCL_ERROR;
    514     }
    515 
    516     int width, height;
    517     if ((Tcl_GetInt(interp, argv[2], &width) != TCL_OK) ||
    518         (Tcl_GetInt(interp, argv[3], &height) != TCL_OK)) {
     520                Tcl_GetString(objv[1]), "\"", (char*)NULL);
     521        return TCL_ERROR;
     522    }
     523    char *label;
     524    label = Tcl_GetString(objv[1]);
     525
     526    int w, h;
     527    if ((Tcl_GetIntFromObj(interp, objv[2], &w) != TCL_OK) ||
     528        (Tcl_GetIntFromObj(interp, objv[3], &h) != TCL_OK)) {
    519529        return TCL_ERROR;
    520530    }
     
    523533        return TCL_ERROR;
    524534    }
    525     NanoVis::render_legend(tf, vmin, vmax, width, height, argv[1]);
     535    NanoVis::render_legend(tf, vmin, vmax, w, h, label);
    526536    return TCL_OK;
    527537}
     
    537547 */
    538548static int
    539 ScreenCmd(ClientData cdata, Tcl_Interp *interp, int argc, const char *argv[])
    540 {
     549ScreenCmd(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv)
     550{
     551    if (objc != 3) {
     552        Tcl_AppendResult(interp, "wrong # args: should be \"",
     553                Tcl_GetString(objv[0]), " width height\"", (char*)NULL);
     554        return TCL_ERROR;
     555    }
     556
    541557    int w, h;
    542 
    543     if (argc != 3) {
    544         Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    545             " width height\"", (char*)NULL);
    546         return TCL_ERROR;
    547     }
    548     if (Tcl_GetInt(interp, argv[1], &w) != TCL_OK) {
    549         return TCL_ERROR;
    550     }
    551     if (Tcl_GetInt(interp, argv[2], &h) != TCL_OK) {
     558    if ((Tcl_GetIntFromObj(interp, objv[1], &w) != TCL_OK) ||
     559        (Tcl_GetIntFromObj(interp, objv[2], &h) != TCL_OK)) {
    552560        return TCL_ERROR;
    553561    }
     
    567575 */
    568576static int
    569 TransfuncCmd(ClientData cdata, Tcl_Interp *interp, int argc,
    570              const char *argv[])
    571 {
    572     if (argc < 2) {
    573         Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    574                          " option arg arg...\"", (char*)NULL);
    575         return TCL_ERROR;
    576     }
    577 
    578     char c = argv[1][0];
    579     if ((c == 'd') && (strcmp(argv[1],"define") == 0)) {
    580         if (argc != 5) {
    581             Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    582                 " define name colormap alphamap\"", (char*)NULL);
     577TransfuncCmd(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv)
     578{
     579    if (objc < 2) {
     580        Tcl_AppendResult(interp, "wrong # args: should be \"",
     581                Tcl_GetString(objv[0]), " option arg arg...\"", (char*)NULL);
     582        return TCL_ERROR;
     583    }
     584
     585    char *string = Tcl_GetString(objv[1]);
     586    char c = string[0];
     587    if ((c == 'd') && (strcmp(string, "define") == 0)) {
     588        if (objc != 5) {
     589            Tcl_AppendResult(interp, "wrong # args: should be \"",
     590                Tcl_GetString(objv[0]), " define name colormap alphamap\"",
     591                (char*)NULL);
    583592            return TCL_ERROR;
    584593        }
     
    587596        Rappture::Field1D rFunc, gFunc, bFunc, wFunc;
    588597        int cmapc, wmapc, i;
    589         const char **cmapv;
    590         const char **wmapv;
     598        Tcl_Obj **cmapv;
     599        Tcl_Obj **wmapv;
    591600
    592601        wmapv = cmapv = NULL;
    593         if (Tcl_SplitList(interp, argv[3], &cmapc, &cmapv) != TCL_OK) {
     602        if (Tcl_ListObjGetElements(interp, objv[3], &cmapc, &cmapv) != TCL_OK) {
    594603            return TCL_ERROR;
    595604        }
     
    597606            Tcl_AppendResult(interp, "bad colormap in transfunc: should be ",
    598607                "{ v r g b ... }", (char*)NULL);
    599             Tcl_Free((char*)cmapv);
    600             return TCL_ERROR;
    601         }
    602 
    603         if (Tcl_SplitList(interp, argv[4], &wmapc, &wmapv) != TCL_OK) {
    604             Tcl_Free((char*)cmapv);
     608            return TCL_ERROR;
     609        }
     610        if (Tcl_ListObjGetElements(interp, objv[4], &wmapc, &wmapv) != TCL_OK) {
    605611            return TCL_ERROR;
    606612        }
     
    608614            Tcl_AppendResult(interp, "wrong # elements in alphamap: should be ",
    609615                        " { v w ... }", (char*)NULL);
    610             Tcl_Free((char*)cmapv);
    611             Tcl_Free((char*)wmapv);
    612             return TCL_ERROR;
    613         }
    614         for (i=0; i < cmapc; i += 4) {
     616            return TCL_ERROR;
     617        }
     618        for (i = 0; i < cmapc; i += 4) {
    615619            int j;
    616620            double vals[4];
    617621
    618622            for (j=0; j < 4; j++) {
    619                 if (Tcl_GetDouble(interp, cmapv[i+j], &vals[j]) != TCL_OK) {
    620                     Tcl_Free((char*)cmapv);
    621                     Tcl_Free((char*)wmapv);
     623                if (Tcl_GetDoubleFromObj(interp, cmapv[i+j], &vals[j]) != TCL_OK) {
    622624                    return TCL_ERROR;
    623625                }
     
    625627                    Tcl_AppendResult(interp, "bad value \"", cmapv[i+j],
    626628                        "\": should be in the range 0-1", (char*)NULL);
    627                     Tcl_Free((char*)cmapv);
    628                     Tcl_Free((char*)wmapv);
    629629                    return TCL_ERROR;
    630630                }
     
    639639
    640640            for (j=0; j < 2; j++) {
    641                 if (Tcl_GetDouble(interp, wmapv[i+j], &vals[j]) != TCL_OK) {
    642                     Tcl_Free((char*)cmapv);
    643                     Tcl_Free((char*)wmapv);
     641                if (Tcl_GetDoubleFromObj(interp, wmapv[i+j], &vals[j]) != TCL_OK) {
    644642                    return TCL_ERROR;
    645643                }
     
    647645                    Tcl_AppendResult(interp, "bad value \"", wmapv[i+j],
    648646                        "\": should be in the range 0-1", (char*)NULL);
    649                     Tcl_Free((char*)cmapv);
    650                     Tcl_Free((char*)wmapv);
    651647                    return TCL_ERROR;
    652648                }
     
    654650            wFunc.define(vals[0], vals[1]);
    655651        }
    656         Tcl_Free((char*)cmapv);
    657         Tcl_Free((char*)wmapv);
    658 
    659652        // sample the given function into discrete slots
    660653        const int nslots = 256;
     
    668661        }
    669662
    670 #if ISO_TEST
    671 /*
    672         for (i=0; i < nslots; i++) {
    673             if (i == 0) data[4*i + 3] = 0.0f;
    674             else if (i == (nslots - 1)) data[4*i + 3] = 0.0f;
    675             //else if (i >= 245 && i < (nslots - 1))
    676             else if (i >= 50 && i < (nslots - 1))
    677             {
    678                 //data[4*i + 3] = 1.0;
    679                 data[4*i + 3] = 0.5;
    680             }
    681             else
    682             {
    683                 data[4*i + 3] = 0.0f;
    684             }
    685         }
    686         */
    687 #endif
    688 
    689663        // find or create this transfer function
    690664        TransferFunction *tf;
    691         tf = NanoVis::get_transfunc(argv[2]);
     665        tf = NanoVis::get_transfunc(Tcl_GetString(objv[2]));
    692666        if (tf != NULL) {
    693667            tf->update(data);
    694668        } else {
    695             tf = NanoVis::set_transfunc(argv[2], nslots, data);
     669            tf = NanoVis::set_transfunc(Tcl_GetString(objv[2]), nslots, data);
    696670        }
    697671    } else {
    698         Tcl_AppendResult(interp, "bad option \"", argv[1],
     672        Tcl_AppendResult(interp, "bad option \"", string,
    699673                "\": should be define", (char*)NULL);
    700674        return TCL_ERROR;
     
    713687 */
    714688static int
    715 UpCmd(ClientData cdata, Tcl_Interp *interp, int argc, const char *argv[])
    716 {
    717     if (argc != 2) {
    718         Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    719             " x|y|z|-x|-y|-z\"", (char*)NULL);
    720         return TCL_ERROR;
    721     }
    722 
    723     int sign = 1;
    724 
    725     char *axisName = (char*)argv[1];
    726     if (*axisName == '-') {
    727         sign = -1;
    728         axisName++;
    729     }
    730 
     689UpCmd(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv)
     690{
     691    if (objc != 2) {
     692        Tcl_AppendResult(interp, "wrong # args: should be \"",
     693                Tcl_GetString(objv[0]), " x|y|z|-x|-y|-z\"", (char*)NULL);
     694        return TCL_ERROR;
     695    }
     696
     697    int sign;
    731698    int axis;
    732     if (GetAxis(interp, axisName, &axis) != TCL_OK) {
     699    if (GetAxisDirFromObj(interp, objv[1], &axis, &sign) != TCL_OK) {
    733700        return TCL_ERROR;
    734701    }
     
    754721 */
    755722static int
    756 VolumeCmd(ClientData cdata, Tcl_Interp *interp, int argc, const char *argv[])
    757 {
    758     if (argc < 2) {
    759         Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    760             " option arg arg...\"", (char*)NULL);
    761         return TCL_ERROR;
    762     }
    763 
    764     char c = argv[1][0];
    765     if ((c == 'a') && (strcmp(argv[1],"axis") == 0)) {
    766         if (argc < 3) {
    767             Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    768                 " axis option ?arg arg...?\"", (char*)NULL);
    769             return TCL_ERROR;
    770         }
    771         c = argv[2][0];
    772         if ((c == 'l') && (strcmp(argv[2],"label") == 0)) {
    773             if (argc < 5) {
    774                 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    775                     " axis label x|y|z string ?volume ...?\"", (char*)NULL);
     723VolumeCmd(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv)
     724{
     725    if (objc < 2) {
     726        Tcl_AppendResult(interp, "wrong # args: should be \"",
     727                Tcl_GetString(objv[0]), " option arg arg...\"", (char*)NULL);
     728        return TCL_ERROR;
     729    }
     730
     731    char *string = Tcl_GetString(objv[1]);
     732    char c = string[0];
     733    if ((c == 'a') && (strcmp(string, "axis") == 0)) {
     734        if (objc < 3) {
     735            Tcl_AppendResult(interp, "wrong # args: should be \"",
     736                Tcl_GetString(objv[0]), " axis option ?arg arg...?\"",
     737                (char*)NULL);
     738            return TCL_ERROR;
     739        }
     740        char *string = Tcl_GetString(objv[2]);
     741        c = string[0];
     742        if ((c == 'l') && (strcmp(string, "label") == 0)) {
     743            if (objc < 5) {
     744                Tcl_AppendResult(interp, "wrong # args: should be \"",
     745                        Tcl_GetString(objv[0]),
     746                        " axis label x|y|z string ?volume ...?\"", (char*)NULL);
    776747                return TCL_ERROR;
    777748            }
    778749            int axis;
    779             if (GetAxis(interp, (char*)argv[3], &axis) != TCL_OK) {
     750            if (GetAxisFromObj(interp, objv[3], &axis) != TCL_OK) {
    780751                return TCL_ERROR;
    781752            }
    782753            vector<Volume *> ivol;
    783             if (GetVolumes(interp, argc-5, argv+5, &ivol) != TCL_OK) {
     754            if (GetVolumes(interp, objc - 5, objv + 5, &ivol) != TCL_OK) {
    784755                return TCL_ERROR;
    785756            }
    786757            vector<Volume *>::iterator iter;
     758            char *label;
     759            label = Tcl_GetString(objv[4]);
    787760            for (iter = ivol.begin(); iter != ivol.end(); iter++) {
    788                 (*iter)->set_label(axis, argv[4]);
     761                (*iter)->set_label(axis, label);
    789762            }
    790763        } else {
    791             Tcl_AppendResult(interp, "bad option \"", argv[2],
    792                 "\": should be label", (char*)NULL);
    793             return TCL_ERROR;
    794         }
    795     } else if ((c == 'd') && (strcmp(argv[1],"data") == 0)) {
    796         if (argc < 3) {
    797             Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    798                 " data option ?arg arg...?\"", (char*)NULL);
    799             return TCL_ERROR;
    800         }
    801         c = argv[2][0];
    802         if ((c == 's') && (strcmp(argv[2],"state") == 0)) {
    803             if (argc < 4) {
    804                 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    805                     " data state on|off ?volume ...?\"", (char*)NULL);
     764            Tcl_AppendResult(interp, "bad option \"", string,
     765                "\": should be label", (char*)NULL);
     766            return TCL_ERROR;
     767        }
     768    } else if ((c == 'd') && (strcmp(string, "data") == 0)) {
     769        if (objc < 3) {
     770            Tcl_AppendResult(interp, "wrong # args: should be \"",
     771                Tcl_GetString(objv[0]), " data option ?arg arg...?\"",
     772                (char*)NULL);
     773            return TCL_ERROR;
     774        }
     775        char *string = Tcl_GetString(objv[2]);
     776        c = string[0];
     777        if ((c == 's') && (strcmp(string, "state") == 0)) {
     778            if (objc < 4) {
     779                Tcl_AppendResult(interp, "wrong # args: should be \"",
     780                        Tcl_GetString(objv[0])," data state on|off ?volume...?\"",
     781                        (char*)NULL);
    806782                return TCL_ERROR;
    807783            }
    808784            int state;
    809             if (Tcl_GetBoolean(interp, argv[3], &state) != TCL_OK) {
     785            if (Tcl_GetBooleanFromObj(interp, objv[3], &state) != TCL_OK) {
    810786                return TCL_ERROR;
    811787            }
    812788            vector<Volume *> ivol;
    813             if (GetVolumes(interp, argc-4, argv+4, &ivol) != TCL_OK) {
     789            if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) {
    814790                return TCL_ERROR;
    815791            }
     
    825801                }
    826802            }
    827         } else if (c == 'f' && strcmp(argv[2], "follows") == 0) {
    828             if (argc < 4) {
    829                 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    830                     " data follows size", (char*)NULL);
     803        } else if (c == 'f' && strcmp(string, "follows") == 0) {
     804            if (objc < 4) {
     805                Tcl_AppendResult(interp, "wrong # args: should be \"",
     806                        Tcl_GetString(objv[0]), " data follows size", (char*)NULL);
    831807                return TCL_ERROR;
    832808            }
     
    835811
    836812            int nbytes;
    837             if (Tcl_GetInt(interp, argv[3], &nbytes) != TCL_OK) {
     813            if (Tcl_GetIntFromObj(interp, objv[3], &nbytes) != TCL_OK) {
    838814                return TCL_ERROR;
    839815            }
     
    930906                std::stringstream fdata;
    931907                fdata.write(buf.bytes(),buf.size());
     908               
    932909#if ISO_TEST
    933910                err = load_volume_stream2(n, fdata);
     
    972949            }
    973950        } else {
    974             Tcl_AppendResult(interp, "bad data option \"", argv[2],
     951            Tcl_AppendResult(interp, "bad data option \"", string,
    975952                "\": should be follows or state", (char*)NULL);
    976953            return TCL_ERROR;
    977954        }
    978     } else if (c == 'o' && strcmp(argv[1],"outline") == 0) {
    979         if (argc < 3) {
    980             Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    981                 " outline option ?arg arg...?\"", (char*)NULL);
    982             return TCL_ERROR;
    983         }
    984         c = argv[2][0];
    985         if ((c == 's') && (strcmp(argv[2],"state") == 0)) {
    986             if (argc < 3) {
    987                 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    988                     " outline state on|off ?volume ...? \"", (char*)NULL);
     955    } else if (c == 'o' && strcmp(string, "outline") == 0) {
     956        if (objc < 3) {
     957            Tcl_AppendResult(interp, "wrong # args: should be \"",
     958                Tcl_GetString(objv[0]), " outline option ?arg arg...?\"",
     959                (char*)NULL);
     960            return TCL_ERROR;
     961        }
     962        char *string = Tcl_GetString(objv[2]);
     963        c = string[0];
     964        if ((c == 's') && (strcmp(string, "state") == 0)) {
     965            if (objc < 3) {
     966                Tcl_AppendResult(interp, "wrong # args: should be \"",
     967                        Tcl_GetString(objv[0]),
     968                        " outline state on|off ?volume ...? \"", (char*)NULL);
    989969                return TCL_ERROR;
    990970            }
    991971
    992972            int state;
    993             if (Tcl_GetBoolean(interp, argv[3], &state) != TCL_OK) {
     973            if (Tcl_GetBooleanFromObj(interp, objv[3], &state) != TCL_OK) {
    994974                return TCL_ERROR;
    995975            }
    996976            vector<Volume *> ivol;
    997             if (GetVolumes(interp, argc-4, argv+4, &ivol) != TCL_OK) {
     977            if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) {
    998978                return TCL_ERROR;
    999979            }
     
    1009989                }
    1010990            }
    1011         } else if (c == 'v' && strcmp(argv[2],"visible") == 0) {
     991        } else if ((c == 'v') && (strcmp(string, "visible") == 0)) {
    1012992            int ivisible;
    1013993
    1014             if (Tcl_GetBoolean(interp, argv[3], &ivisible) != TCL_OK) {
     994            if (Tcl_GetBooleanFromObj(interp, objv[3], &ivisible) != TCL_OK) {
    1015995                return TCL_ERROR;
    1016996            }           
     
    10281008                }
    10291009            }
    1030         } else if ((c == 'c') && (strcmp(argv[2],"color") == 0)) {
    1031             if (argc < 6) {
    1032                 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    1033                     " outline color R G B ?volume ...? \"", (char*)NULL);
     1010        } else if ((c == 'c') && (strcmp(string, "color") == 0)) {
     1011            if (objc < 6) {
     1012                Tcl_AppendResult(interp, "wrong # args: should be \"",
     1013                        Tcl_GetString(objv[0]),
     1014                        " outline color R G B ?volume ...? \"", (char*)NULL);
    10341015                return TCL_ERROR;
    10351016            }
    10361017            float rgb[3];
    1037             if (GetColor(interp, argc - 3, argv + 3, rgb) != TCL_OK) {
     1018            if (GetColor(interp, objc - 3, objv + 3, rgb) != TCL_OK) {
    10381019                return TCL_ERROR;
    10391020            }
    10401021            vector<Volume *> ivol;
    1041             if (GetVolumes(interp, argc - 6, argv + 6, &ivol) != TCL_OK) {
     1022            if (GetVolumes(interp, objc - 6, objv + 6, &ivol) != TCL_OK) {
    10421023                return TCL_ERROR;
    10431024            }
     
    10481029        }
    10491030        else {
    1050             Tcl_AppendResult(interp, "bad outline option \"", argv[2],
     1031            Tcl_AppendResult(interp, "bad outline option \"", string,
    10511032                "\": should be color, visible, or state", (char*)NULL);
    10521033            return TCL_ERROR;
    10531034        }
    1054     } else if ((c == 's') && (strcmp(argv[1],"shading") == 0)) {
    1055         if (argc < 3) {
    1056             Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    1057                 " shading option ?arg arg...?\"", (char*)NULL);
    1058             return TCL_ERROR;
    1059         }
    1060         c = argv[2][0];
    1061         if ((c == 't') && (strcmp(argv[2],"transfunc") == 0)) {
    1062             if (argc < 4) {
    1063                 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    1064                     " shading transfunc name ?volume ...?\"", (char*)NULL);
     1035    } else if ((c == 's') && (strcmp(string, "shading") == 0)) {
     1036        if (objc < 3) {
     1037            Tcl_AppendResult(interp, "wrong # args: should be \"",
     1038                Tcl_GetString(objv[0]), " shading option ?arg arg...?\"",
     1039                (char*)NULL);
     1040            return TCL_ERROR;
     1041        }
     1042        char *string = Tcl_GetString(objv[2]);
     1043        c = string[0];
     1044        if ((c == 't') && (strcmp(string, "transfunc") == 0)) {
     1045            if (objc < 4) {
     1046                Tcl_AppendResult(interp, "wrong # args: should be \"",
     1047                        Tcl_GetString(objv[0]),
     1048                        " shading transfunc name ?volume ...?\"", (char*)NULL);
    10651049                return TCL_ERROR;
    10661050            }
    10671051            TransferFunction *tf;
    1068             tf = NanoVis::get_transfunc(argv[3]);
     1052            char *name = Tcl_GetString(objv[3]);
     1053            tf = NanoVis::get_transfunc(name);
    10691054            if (tf == NULL) {
    1070                 Tcl_AppendResult(interp, "transfer function \"", argv[3],
     1055                Tcl_AppendResult(interp, "transfer function \"", name,
    10711056                    "\" is not defined", (char*)NULL);
    10721057                return TCL_ERROR;
    10731058            }
    10741059            vector<Volume *> ivol;
    1075             if (GetVolumes(interp, argc-4, argv+4, &ivol) != TCL_OK) {
     1060            if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) {
    10761061                return TCL_ERROR;
    10771062            }
     
    10881073                */
    10891074            }
    1090         } else if ((c == 'd') && (strcmp(argv[2], "diffuse") == 0)) {
    1091             if (argc < 4) {
    1092                 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    1093                     " shading diffuse value ?volume ...?\"", (char*)NULL);
     1075        } else if ((c == 'd') && (strcmp(string, "diffuse") == 0)) {
     1076            if (objc < 4) {
     1077                Tcl_AppendResult(interp, "wrong # args: should be \"",
     1078                        Tcl_GetString(objv[0]),
     1079                        " shading diffuse value ?volume ...?\"", (char*)NULL);
    10941080                return TCL_ERROR;
    10951081            }
    10961082
    10971083            float diffuse;
    1098             if (GetFloat(interp, argv[3], &diffuse) != TCL_OK) {
     1084            if (GetFloatFromObj(interp, objv[3], &diffuse) != TCL_OK) {
    10991085                return TCL_ERROR;
    11001086            }
    11011087            vector<Volume *> ivol;
    1102             if (GetVolumes(interp, argc-4, argv+4, &ivol) != TCL_OK) {
     1088            if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) {
    11031089                return TCL_ERROR;
    11041090            }
     
    11071093                (*iter)->set_diffuse(diffuse);
    11081094            }
    1109         } else if ((c == 'o') && (strcmp(argv[2], "opacity") == 0)) {
    1110             if (argc < 4) {
    1111                 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    1112                     " shading opacity value ?volume ...?\"", (char*)NULL);
     1095        } else if ((c == 'o') && (strcmp(string, "opacity") == 0)) {
     1096            if (objc < 4) {
     1097                Tcl_AppendResult(interp, "wrong # args: should be \"",
     1098                        Tcl_GetString(objv[0]),
     1099                        " shading opacity value ?volume ...?\"", (char*)NULL);
    11131100                return TCL_ERROR;
    11141101            }
    11151102            float opacity;
    1116             if (GetFloat(interp, argv[3], &opacity) != TCL_OK) {
     1103            if (GetFloatFromObj(interp, objv[3], &opacity) != TCL_OK) {
    11171104                return TCL_ERROR;
    11181105            }
    11191106            vector<Volume *> ivol;
    1120             if (GetVolumes(interp, argc-4, argv+4, &ivol) != TCL_OK) {
     1107            if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) {
    11211108                return TCL_ERROR;
    11221109            }
     
    11251112                (*iter)->set_opacity_scale(opacity);
    11261113            }
    1127         } else if ((c == 's') && (strcmp(argv[2], "specular") == 0)) {
    1128             if (argc < 4) {
    1129                 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    1130                     " shading specular value ?volume ...?\"", (char*)NULL);
     1114        } else if ((c == 's') && (strcmp(string, "specular") == 0)) {
     1115            if (objc < 4) {
     1116                Tcl_AppendResult(interp, "wrong # args: should be \"",
     1117                        Tcl_GetString(objv[0]),
     1118                        " shading specular value ?volume ...?\"", (char*)NULL);
    11311119                return TCL_ERROR;
    11321120            }
    11331121            float specular;
    1134             if (GetFloat(interp, argv[3], &specular) != TCL_OK) {
     1122            if (GetFloatFromObj(interp, objv[3], &specular) != TCL_OK) {
    11351123                return TCL_ERROR;
    11361124            }
    11371125            vector<Volume *> ivol;
    1138             if (GetVolumes(interp, argc-4, argv+4, &ivol) != TCL_OK) {
     1126            if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) {
    11391127                return TCL_ERROR;
    11401128            }
     
    11431131                (*iter)->set_specular(specular);
    11441132            }
    1145         } else if ((c == 'i') && (strcmp(argv[2], "isosurface") == 0)) {
    1146             if (argc < 4) {
    1147                 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    1148                     " shading isosurface on|off ?volume ...?\"", (char*)NULL);
     1133        } else if ((c == 'i') && (strcmp(string, "isosurface") == 0)) {
     1134            if (objc < 4) {
     1135                Tcl_AppendResult(interp, "wrong # args: should be \"",
     1136                        Tcl_GetString(objv[0]),
     1137                        " shading isosurface on|off ?volume ...?\"", (char*)NULL);
    11491138                return TCL_ERROR;
    11501139            }
    11511140            int iso_surface;
    1152             if (Tcl_GetBoolean(interp, argv[3], &iso_surface) != TCL_OK) {
     1141            if (Tcl_GetBooleanFromObj(interp, objv[3], &iso_surface) != TCL_OK) {
    11531142                return TCL_ERROR;
    11541143            }
    11551144            vector<Volume *> ivol;
    1156             if (GetVolumes(interp, argc-4, argv+4, &ivol) != TCL_OK) {
     1145            if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) {
    11571146                return TCL_ERROR;
    11581147            }
     
    11621151            }
    11631152        } else {
    1164             Tcl_AppendResult(interp, "bad shading option \"", argv[2],
     1153            Tcl_AppendResult(interp, "bad shading option \"", string,
    11651154                "\": should be diffuse, opacity, specular, transfunc, or ",
    11661155                "isosurface", (char*)NULL);
    11671156            return TCL_ERROR;
    11681157        }
    1169     } else if ((c == 's') && (strcmp(argv[1], "state") == 0)) {
    1170         if (argc < 3) {
    1171             Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    1172                 " state on|off ?volume...?\"", (char*)NULL);
     1158    } else if ((c == 's') && (strcmp(string, "state") == 0)) {
     1159        if (objc < 3) {
     1160            Tcl_AppendResult(interp, "wrong # args: should be \"",
     1161                Tcl_GetString(objv[0]), " state on|off ?volume...?\"",
     1162                (char*)NULL);
    11731163            return TCL_ERROR;
    11741164        }
    11751165        int state;
    1176         if (Tcl_GetBoolean(interp, argv[2], &state) != TCL_OK) {
     1166        if (Tcl_GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
    11771167            return TCL_ERROR;
    11781168        }
    11791169        vector<Volume *> ivol;
    1180         if (GetVolumes(interp, argc-3, argv+3, &ivol) != TCL_OK) {
     1170        if (GetVolumes(interp, objc - 3, objv + 3, &ivol) != TCL_OK) {
    11811171            return TCL_ERROR;
    11821172        }
     
    11921182            }
    11931183        }
    1194     } else if (strcmp(argv[1],"animation") == 0) {
    1195         if (argc < 3) {
    1196             Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    1197                 " animation option ?args...?\"", (char*)NULL);
    1198             return TCL_ERROR;
    1199         }
    1200         if (strcmp(argv[2],"volumes") == 0) {
     1184    } else if (strcmp(string, "animation") == 0) {
     1185        if (objc < 3) {
     1186            Tcl_AppendResult(interp, "wrong # args: should be \"",
     1187                Tcl_GetString(objv[0]), " animation option ?args...?\"",
     1188                (char*)NULL);
     1189            return TCL_ERROR;
     1190        }
     1191        char *string = Tcl_GetString(objv[2]);
     1192        char c = string[0];
     1193        if ((c == 'v') && (strcmp(string,"volumes") == 0)) {
    12011194            vector<unsigned int> ivol;
    1202             if (GetVolumeIndices(interp, argc-3, argv+3, &ivol) != TCL_OK) {
     1195            if (GetVolumeIndices(interp, objc - 3, objv + 3, &ivol) != TCL_OK) {
    12031196                return TCL_ERROR;
    12041197            }
     
    12101203                        *iter);
    12111204            }
    1212         } else if (strcmp(argv[2],"capture") == 0) {
    1213 
    1214             int total_frame_count;
    1215 
    1216             if (Tcl_GetInt(interp, argv[3], &total_frame_count) != TCL_OK)
    1217             {
    1218                 return TCL_ERROR;
    1219             }
    1220 
    1221             VolumeInterpolator* interpolator = NanoVis::vol_renderer->getVolumeInterpolator();
     1205        } else if ((c == 'c') && (strcmp(string,"capture") == 0)) {
     1206            int total;
     1207
     1208            if (Tcl_GetIntFromObj(interp, objv[3], &total) != TCL_OK) {
     1209                return TCL_ERROR;
     1210            }
     1211            VolumeInterpolator* interpolator;
     1212            interpolator = NanoVis::vol_renderer->getVolumeInterpolator();
    12221213            interpolator->start();
    1223             if (interpolator->is_started())
    1224             {
    1225                 float fraction;
    1226                 for (int frame_num = 0; frame_num < total_frame_count; ++frame_num)
    1227                 {
    1228                     fraction = ((float)frame_num) / (total_frame_count - 1);
     1214            if (interpolator->is_started()) {
     1215                char *fileName = (objc < 5) ? NULL : Tcl_GetString(objv[4]);
     1216                for (int frame_num = 0; frame_num < total; ++frame_num) {
     1217                    float fraction;
     1218
     1219                    fraction = ((float)frame_num) / (total - 1);
    12291220                    Trace("fraction : %f\n", fraction);
    1230                     //interpolator->update(((float)frame_num) / (total_frame_count - 1));
     1221                    //interpolator->update(((float)frame_num) / (total - 1));
    12311222                    interpolator->update(fraction);
    12321223
     
    12381229                    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
    12391230           
    1240                     if (argc < 5)
    1241                         NanoVis::bmp_write_to_file(frame_num, NULL);
    1242                     else
    1243                         NanoVis::bmp_write_to_file(frame_num, (char*) argv[4]);
     1231                    NanoVis::bmp_write_to_file(frame_num, fileName);
    12441232                }
    12451233            }
    1246 
    1247         } else if (strcmp(argv[2],"start") == 0) {
     1234        } else if ((c == 's') && (strcmp(string, "start") == 0)) {
    12481235            NanoVis::vol_renderer->startVolumeAnimation();
    1249         } else if (strcmp(argv[2],"stop") == 0) {
    1250                 NanoVis::vol_renderer->stopVolumeAnimation();
    1251         } else if (strcmp(argv[2],"clear") == 0) {
    1252                 NanoVis::vol_renderer->clearAnimatedVolumeInfo();
     1236        } else if ((c == 's') && (strcmp(string, "stop") == 0)) {
     1237            NanoVis::vol_renderer->stopVolumeAnimation();
     1238        } else if ((c == 'c') && (strcmp(string, "clear") == 0)) {
     1239            NanoVis::vol_renderer->clearAnimatedVolumeInfo();
    12531240        } else {
    1254             Tcl_AppendResult(interp, "bad animation option \"", argv[2],
     1241            Tcl_AppendResult(interp, "bad animation option \"", string,
    12551242                "\": should be volumes, start, stop,  or clear", (char*)NULL);
    12561243            return TCL_ERROR;
    12571244        }
    1258     } else if ((c == 't') && (strcmp(argv[1],"test2") == 0)) {
     1245    } else if ((c == 't') && (strcmp(string, "test2") == 0)) {
    12591246        NanoVis::volume[1]->disable_data();
    12601247        NanoVis::volume[1]->disable();
    12611248    } else {
    1262         Tcl_AppendResult(interp, "bad option \"", argv[1], "\": should be ",
     1249        Tcl_AppendResult(interp, "bad option \"", string, "\": should be ",
    12631250                "data, outline, shading, or state", (char*)NULL);
    12641251        return TCL_ERROR;
     
    12681255
    12691256static int
    1270 FlowCmd(ClientData cdata, Tcl_Interp *interp, int argc, const char *argv[])
     1257FlowCmd(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv)
    12711258{
    12721259    Rappture::Outcome err;
    12731260
    1274     if (argc < 2) {
    1275         Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    1276                          " option ?arg arg?", (char *)NULL);
    1277         return TCL_ERROR;
    1278     }
    1279     char c = argv[1][0];
    1280     if ((c == 'v') && (strcmp(argv[1], "vectorid") == 0)) {
    1281         if (argc != 3) {
    1282             Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    1283                 " vectorid volume", (char *)NULL);
     1261    if (objc < 2) {
     1262        Tcl_AppendResult(interp, "wrong # args: should be \"",
     1263                Tcl_GetString(objv[0]), " option ?arg arg?", (char *)NULL);
     1264        return TCL_ERROR;
     1265    }
     1266    char *string = Tcl_GetString(objv[1]);
     1267    char c = string[0];
     1268    if ((c == 'v') && (strcmp(string, "vectorid") == 0)) {
     1269        if (objc != 3) {
     1270            Tcl_AppendResult(interp, "wrong # args: should be \"",
     1271                Tcl_GetString(objv[0]), " vectorid volume", (char *)NULL);
    12841272            return TCL_ERROR;
    12851273        }
    12861274        Volume *volPtr;
    12871275
    1288         if (GetVolume(interp, argv[2], &volPtr) != TCL_OK) {
     1276        if (GetVolumeFromObj(interp, objv[2], &volPtr) != TCL_OK) {
    12891277            return TCL_ERROR;
    12901278        }
     
    13041292            NanoVis::licRenderer->set_offset(NanoVis::lic_slice_z);
    13051293        }
    1306     } else if (c == 'l' && strcmp(argv[1], "lic") == 0) {
    1307         if (argc != 3) {
    1308             Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    1309                 " lic on|off\"", (char*)NULL);
     1294    } else if (c == 'l' && strcmp(string, "lic") == 0) {
     1295        if (objc != 3) {
     1296            Tcl_AppendResult(interp, "wrong # args: should be \"",
     1297                Tcl_GetString(objv[0]), " lic on|off\"", (char*)NULL);
    13101298            return TCL_ERROR;
    13111299        }
    13121300        int ibool;
    1313         if (Tcl_GetBoolean(interp, argv[2], &ibool) != TCL_OK) {
     1301        if (Tcl_GetBooleanFromObj(interp, objv[2], &ibool) != TCL_OK) {
    13141302            return TCL_ERROR;
    13151303        }
    13161304        NanoVis::lic_on = (bool)ibool;
    1317     } else if ((c == 'p') && (strcmp(argv[1], "particle") == 0)) {
    1318         if (argc < 3) {
    1319             Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    1320                 " particle visible|slice|slicepos arg \"", (char*)NULL);
    1321             return TCL_ERROR;
    1322         }
    1323         c = argv[2][0];
    1324         if ((c == 'v') && (strcmp(argv[2], "visible") == 0)) {
    1325             if (argc != 4) {
    1326                 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    1327                         " particle visible on|off\"", (char*)NULL);
     1305    } else if ((c == 'p') && (strcmp(string, "particle") == 0)) {
     1306        if (objc < 3) {
     1307            Tcl_AppendResult(interp, "wrong # args: should be \"",
     1308                Tcl_GetString(objv[0]), " particle visible|slice|slicepos arg \"",
     1309                (char*)NULL);
     1310            return TCL_ERROR;
     1311        }
     1312        char *string = Tcl_GetString(objv[2]);
     1313        c = string[0];
     1314        if ((c == 'v') && (strcmp(string, "visible") == 0)) {
     1315            if (objc != 4) {
     1316                Tcl_AppendResult(interp, "wrong # args: should be \"",
     1317                        Tcl_GetString(objv[0]), " particle visible on|off\"",
     1318                        (char*)NULL);
    13281319                return TCL_ERROR;
    13291320            }
    13301321            int state;
    1331             if (Tcl_GetBoolean(interp, argv[3], &state) != TCL_OK) {
     1322            if (Tcl_GetBooleanFromObj(interp, objv[3], &state) != TCL_OK) {
    13321323                return TCL_ERROR;
    13331324            }
    13341325            NanoVis::particle_on = state;
    1335         } else if ((c == 's') && (strcmp(argv[2], "slice") == 0)) {
    1336             if (argc != 4) {
    1337                 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
     1326        } else if ((c == 's') && (strcmp(string, "slice") == 0)) {
     1327            if (objc != 4) {
     1328                Tcl_AppendResult(interp, "wrong # args: should be \"",
     1329                        Tcl_GetString(objv[0]),
    13381330                        " particle slice volume\"", (char*)NULL);
    13391331                return TCL_ERROR;
    13401332            }
    13411333            int axis;
    1342             if (GetAxis(interp, argv[3], &axis) != TCL_OK) {
     1334            if (GetAxisFromObj(interp, objv[3], &axis) != TCL_OK) {
    13431335                return TCL_ERROR;
    13441336            }
    13451337            NanoVis::lic_axis = axis;
    1346         } else if ((c == 's') && (strcmp(argv[2], "slicepos") == 0)) {
    1347             if (argc != 4) {
    1348                 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    1349                         " particle slicepos value\"", (char*)NULL);
     1338        } else if ((c == 's') && (strcmp(string, "slicepos") == 0)) {
     1339            if (objc != 4) {
     1340                Tcl_AppendResult(interp, "wrong # args: should be \"",
     1341                        Tcl_GetString(objv[0]), " particle slicepos value\"",
     1342                        (char*)NULL);
    13501343                return TCL_ERROR;
    13511344            }
    13521345            float pos;
    1353             if (GetFloat(interp, argv[2], &pos) != TCL_OK) {
     1346            if (GetFloatFromObj(interp, objv[2], &pos) != TCL_OK) {
    13541347                return TCL_ERROR;
    13551348            }
     
    13711364            }
    13721365        } else {
    1373             Tcl_AppendResult(interp, "unknown option \"", argv[2],
    1374                 "\": should be \"", argv[0], " visible, slice, or slicepos\"",
     1366            Tcl_AppendResult(interp, "unknown option \"",string,"\": should be \"",
     1367                Tcl_GetString(objv[0]), " visible, slice, or slicepos\"",
    13751368                (char *)NULL);
    13761369            return TCL_ERROR;
    13771370        }
    1378     } else if ((c == 'r') && (strcmp(argv[1],"reset") == 0)) {
     1371    } else if ((c == 'r') && (strcmp(string, "reset") == 0)) {
    13791372        NanoVis::initParticle();
    1380     } else if ((c == 'c') && (strcmp(argv[1],"capture") == 0)) {
    1381         if (argc > 4 || argc < 3) {
    1382             Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    1383                 " capture numframes [directory]\"", (char*)NULL);
     1373    } else if ((c == 'c') && (strcmp(string, "capture") == 0)) {
     1374        if (objc > 4 || objc < 3) {
     1375            Tcl_AppendResult(interp, "wrong # args: should be \"",
     1376                Tcl_GetString(objv[0]), " capture numframes [directory]\"",
     1377                (char*)NULL);
    13841378            return TCL_ERROR;
    13851379        }
    13861380        int total_frame_count;
    13871381
    1388         if (Tcl_GetInt(interp, argv[2], &total_frame_count) != TCL_OK) {
     1382        if (Tcl_GetIntFromObj(interp, objv[2], &total_frame_count) != TCL_OK) {
    13891383            return TCL_ERROR;
    13901384        }
     
    13981392        //
    13991393        Trace("FLOW started\n");
     1394        char *fileName;
     1395        fileName = (objc < 4) ? NULL : Tcl_GetString(objv[3]);
    14001396        for (int frame_count = 0; frame_count < total_frame_count;
    14011397             frame_count++) {
     
    14181414            glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
    14191415
    1420             if (argc < 4)
    1421                 NanoVis::bmp_write_to_file(frame_count, NULL);
    1422             else
    1423                 NanoVis::bmp_write_to_file(frame_count, (char*) argv[3]);
    1424            
     1416            NanoVis::bmp_write_to_file(frame_count, fileName);
    14251417        }
    14261418        Trace("FLOW end\n");
     
    14331425        }
    14341426        NanoVis::initParticle();
    1435     } else if (c == 'd' && strcmp(argv[1],"data") == 0) {
    1436         if (argc < 3) {
    1437             Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    1438                 " data follows ?args?", (char *)NULL);
    1439             return TCL_ERROR;
    1440         }
    1441         c = argv[2][0];
    1442         if ((c == 'f') && (strcmp(argv[2],"follows") == 0)) {
    1443             if (argc != 4) {
    1444                 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    1445                                  " data follows length", (char *)NULL);
     1427    } else if ((c == 'd') && (strcmp(string, "data") == 0)) {
     1428        if (objc < 3) {
     1429            Tcl_AppendResult(interp, "wrong # args: should be \"",
     1430                Tcl_GetString(objv[0]), " data follows ?args?", (char *)NULL);
     1431            return TCL_ERROR;
     1432        }
     1433        char *string = Tcl_GetString(objv[2]);;
     1434        c = string[0];
     1435        if ((c == 'f') && (strcmp(string,"follows") == 0)) {
     1436            if (objc != 4) {
     1437                Tcl_AppendResult(interp, "wrong # args: should be \"",
     1438                        Tcl_GetString(objv[0]), " data follows length",
     1439                        (char *)NULL);
    14461440                return TCL_ERROR;
    14471441            }
    14481442            int nbytes;
    1449             if (Tcl_GetInt(interp, argv[3], &nbytes) != TCL_OK) {
     1443            if (Tcl_GetIntFromObj(interp, objv[3], &nbytes) != TCL_OK) {
    14501444                return TCL_ERROR;
    14511445            }
     
    14841478}
    14851479
     1480
     1481static int
     1482HeightMapDataFollowsOp(ClientData cdata, Tcl_Interp *interp, int objc,
     1483                       Tcl_Obj *CONST *objv)
     1484{
     1485    Rappture::Buffer buf;
     1486    int nBytes;
     1487   
     1488    if (Tcl_GetIntFromObj(interp, objv[3], &nBytes) != TCL_OK) {
     1489        return TCL_ERROR;
     1490    }
     1491    if (GetDataStream(interp, buf, nBytes) != TCL_OK) {
     1492        return TCL_ERROR;
     1493    }
     1494    buf.append("\0", 1);
     1495    int result;
     1496    result = Tcl_Eval(interp, buf.bytes());
     1497    if (result != TCL_OK) {
     1498        fprintf(stderr, "error in command: %s\n",
     1499                Tcl_GetStringResult(interp));
     1500        fflush(stderr);
     1501    }
     1502    return result;
     1503}
     1504
     1505static int
     1506HeightMapDataVisibleOp(ClientData cdata, Tcl_Interp *interp, int objc,
     1507                       Tcl_Obj *CONST *objv)
     1508{
     1509    int ivisible;
     1510    if (Tcl_GetBooleanFromObj(interp, objv[3], &ivisible) != TCL_OK) {
     1511        return TCL_ERROR;
     1512    }
     1513    vector<unsigned int> indices;
     1514    if (GetIndices(interp, objc - 4, objv + 4, &indices) != TCL_OK) {
     1515        return TCL_ERROR;
     1516    }
     1517    bool visible;
     1518    visible = (bool)ivisible;
     1519    for (unsigned int i = 0; i < indices.size(); ++i) {
     1520        if ((indices[i] < NanoVis::heightMap.size()) &&
     1521            (NanoVis::heightMap[indices[i]] != NULL)) {
     1522            NanoVis::heightMap[indices[i]]->setVisible(visible);
     1523        }
     1524    }
     1525    return TCL_OK;
     1526}
     1527
     1528static Rappture::CmdSpec heightMapDataOps[] =
     1529{
     1530    {"follows",      1, HeightMapDataFollowsOp, 4, 4, "length",},
     1531    {"visible",      1, HeightMapDataVisibleOp, 4, 0, "bool ?indices?",},
     1532};
     1533static int nHeightMapDataOps = NumCmdSpecs(heightMapDataOps);
     1534
    14861535static int
    1487 HeightMapCmd(ClientData cdata, Tcl_Interp *interp, int argc,
    1488              const char *argv[])
    1489 {
    1490     if (argc < 2) {
    1491         srand((unsigned)time(NULL));
    1492         int size = 20 * 200;
    1493         double sigma = 5.0;
    1494         double mean = exp(0.0) / (sigma * sqrt(2.0));
    1495         float* data = (float*) malloc(sizeof(float) * size);
    1496        
    1497         float x;
    1498         for (int i = 0; i < size; ++i) {
    1499             x = - 10 + i%20;
    1500             data[i] = exp(- (x * x)/(2 * sigma * sigma)) /
    1501                 (sigma * sqrt(2.0)) / mean * 2 + 1000;
    1502         }
    1503 
    1504         HeightMap* heightMap = new HeightMap();
    1505         float minx = 0.0f;
    1506         float maxx = 1.0f;
    1507         float miny = 0.5f;
    1508         float maxy = 3.5f;
    1509         heightMap->setHeight(minx, miny, maxx, maxy, 20, 200, data);
    1510         heightMap->setColorMap(NanoVis::get_transfunc("default"));
    1511         heightMap->setVisible(true);
    1512         heightMap->setLineContourVisible(true);
    1513         NanoVis::heightMap.push_back(heightMap);
    1514 
    1515 
    1516         Vector3 min(minx, (float) heightMap->range_min(), miny);
    1517         Vector3 max(maxx, (float) heightMap->range_max(), maxy);
    1518        
    1519         NanoVis::grid->setMinMax(min, max);
    1520         NanoVis::grid->setVisible(true);
    1521        
    1522         return TCL_OK;
    1523     }
     1536HeightMapDataOp(ClientData cdata, Tcl_Interp *interp, int objc,
     1537                 Tcl_Obj *CONST *objv)
     1538{
     1539    Tcl_ObjCmdProc *proc;
     1540
     1541    proc = Rappture::GetOpFromObj(interp, nHeightMapDataOps, heightMapDataOps,
     1542                Rappture::CMDSPEC_ARG2, objc, objv, 0);
     1543    if (proc == NULL) {
     1544        return TCL_ERROR;
     1545    }
     1546    return (*proc) (cdata, interp, objc, objv);
     1547}
     1548
     1549
     1550static int
     1551HeightMapLineContourColorOp(ClientData cdata, Tcl_Interp *interp, int objc,
     1552                              Tcl_Obj *CONST *objv)
     1553{
     1554    float rgb[3];
     1555    if (GetColor(interp, objc - 3, objv + 3, rgb) != TCL_OK) {
     1556        return TCL_ERROR;
     1557    }           
     1558    vector<unsigned int> indices;
     1559    if (GetIndices(interp, objc-6, objv + 6, &indices) != TCL_OK) {
     1560        return TCL_ERROR;
     1561    }
     1562    for (unsigned int i = 0; i < indices.size(); ++i) {
     1563        if ((indices[i] < NanoVis::heightMap.size()) &&
     1564            (NanoVis::heightMap[indices[i]] != NULL)) {
     1565            NanoVis::heightMap[indices[i]]->setLineContourColor(rgb);
     1566        }
     1567    }
     1568    return TCL_OK;
     1569}
     1570
     1571static int
     1572HeightMapLineContourVisibleOp(ClientData cdata, Tcl_Interp *interp, int objc,
     1573                              Tcl_Obj *CONST *objv)
     1574{
     1575    int ivisible;
     1576    bool visible;
     1577    if (Tcl_GetBooleanFromObj(interp, objv[3], &ivisible) != TCL_OK) {
     1578        return TCL_ERROR;
     1579    }
     1580    visible = (bool)ivisible;
     1581    vector<unsigned int> indices;
     1582    if (GetIndices(interp, objc-4, objv+4, &indices) != TCL_OK) {
     1583        return TCL_ERROR;
     1584    }
     1585    for (unsigned int i = 0; i < indices.size(); ++i) {
     1586        if ((indices[i] < NanoVis::heightMap.size()) &&
     1587            (NanoVis::heightMap[indices[i]] != NULL)) {
     1588            NanoVis::heightMap[indices[i]]->setLineContourVisible(visible);
     1589        }
     1590    }
     1591    return TCL_OK;
     1592}
     1593
     1594static Rappture::CmdSpec heightMapLineContourOps[] =
     1595{
     1596    {"color",   1, HeightMapLineContourColorOp,   4, 4, "length",},
     1597    {"visible", 1, HeightMapLineContourVisibleOp, 4, 0, "bool ?indices?",},
     1598};
     1599static int nHeightMapLineContourOps = NumCmdSpecs(heightMapLineContourOps);
     1600
     1601static int
     1602HeightMapLineContourOp(ClientData cdata, Tcl_Interp *interp, int objc,
     1603                        Tcl_Obj *CONST *objv)
     1604{
     1605    Tcl_ObjCmdProc *proc;
     1606
     1607    proc = Rappture::GetOpFromObj(interp, nHeightMapLineContourOps,
     1608        heightMapLineContourOps, Rappture::CMDSPEC_ARG2, objc, objv, 0);
     1609    if (proc == NULL) {
     1610        return TCL_ERROR;
     1611    }
     1612    return (*proc) (cdata, interp, objc, objv);
     1613}
     1614
     1615static int
     1616HeightMapCullOp(ClientData cdata, Tcl_Interp *interp, int objc,
     1617                   Tcl_Obj *CONST *objv)
     1618{
     1619    graphics::RenderContext::CullMode mode;
     1620    if (GetCullMode(interp, objv[2], &mode) != TCL_OK) {
     1621        return TCL_ERROR;
     1622    }
     1623    NanoVis::renderContext->setCullMode(mode);
     1624    return TCL_OK;
     1625}
     1626
     1627static int
     1628HeightMapCreateOp(ClientData cdata, Tcl_Interp *interp, int objc,
     1629                  Tcl_Obj *CONST *objv)
     1630{
     1631    HeightMap *hMap;
    15241632   
    1525     char c = argv[1][0];
    1526     if ((c == 'c') && (strcmp(argv[1], "create") == 0)) {
    1527         HeightMap *hMap;
    1528 
    1529         /* heightmap create xmin ymin xmax ymax xnum ynum values */
    1530         hMap = CreateHeightMap(cdata, interp, argc - 2, argv + 2);
    1531         if (hMap == NULL) {
    1532             return TCL_ERROR;
    1533         }
    1534         NanoVis::heightMap.push_back(hMap);
    1535         /* FIXME: Convert this file to use Tcl_CmdObjProc */
    1536         sprintf(interp->result, "%d", NanoVis::heightMap.size() - 1);
    1537         return TCL_OK;
    1538     } else if ((c == 'd') && (strcmp(argv[1],"data") == 0)) {
    1539         if (argc < 3) {
    1540             Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    1541                 " data follows|visible ?args?", (char *)NULL);
    1542             return TCL_ERROR;
    1543         }
    1544         //bytes
    1545         char c;
    1546         c = argv[2][0];
    1547         if ((c == 'v') && (strcmp(argv[2],"visible") == 0)) {
    1548             if (argc < 4) {
    1549                 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    1550                         " data visible bool ?indices?", (char *)NULL);
    1551                 return TCL_ERROR;
    1552             }
    1553             int ivisible;
    1554             vector<unsigned int> indices;
    1555 
    1556             if (Tcl_GetBoolean(interp, argv[3], &ivisible) != TCL_OK) {
    1557                 return TCL_ERROR;
    1558             }
    1559             if (GetIndices(interp, argc-4, argv+4, &indices) != TCL_OK) {
    1560                return TCL_ERROR;
    1561             }
    1562             bool visible;
    1563             visible = (bool)ivisible;
    1564             for (unsigned int i = 0; i < indices.size(); ++i) {
    1565                 if ((indices[i] < NanoVis::heightMap.size()) &&
    1566                     (NanoVis::heightMap[indices[i]] != NULL)) {
    1567                     NanoVis::heightMap[indices[i]]->setVisible(visible);
    1568                 }
    1569             }
    1570         } else if ((c == 'f') && (strcmp(argv[2],"follows") == 0)) {
    1571             if (argc != 4) {
    1572                 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    1573                         " data follow length", (char *)NULL);
    1574                 return TCL_ERROR;
    1575             }
    1576             Rappture::Buffer buf;
    1577             int nBytes;
    1578 
    1579             if (Tcl_GetInt(interp, argv[3], &nBytes) != TCL_OK) {
    1580                 return TCL_ERROR;
    1581             }
    1582             if (GetDataStream(interp, buf, nBytes) != TCL_OK) {
    1583                 return TCL_ERROR;
    1584             }
    1585             buf.append("\0", 1);
    1586             if (Tcl_Eval(interp, buf.bytes()) != TCL_OK) {
    1587                 fprintf(stderr, "error in command: %s\n",
    1588                         Tcl_GetStringResult(interp));
    1589                 fflush(stderr);
    1590                 return TCL_ERROR;
    1591             }
    1592         } else {
    1593             Tcl_AppendResult(interp, "unknown option \"", argv[2], "\": ",
    1594                              "should be visible or follows", (char *)NULL);
    1595             return TCL_ERROR;
    1596         }
    1597     } else if ((c == 'l') && (strcmp(argv[1], "linecontour") == 0)) {
    1598         if (argc < 3) {
    1599             Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    1600                 " linecontour visible|color ?args?", (char *)NULL);
    1601             return TCL_ERROR;
    1602         }
    1603         vector<unsigned int> indices;
    1604         char c;
    1605         c = argv[2][0];
    1606         if ((c == 'v') && (strcmp(argv[2],"visible") == 0)) {
    1607             if (argc < 4) {
    1608                 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    1609                         " linecontour visible boolean ?indices?", (char *)NULL);
    1610                 return TCL_ERROR;
    1611             }
    1612             int ivisible;
    1613             bool visible;
    1614             if (Tcl_GetBoolean(interp, argv[3], &ivisible) != TCL_OK) {
    1615                 return TCL_ERROR;
    1616             }
    1617             visible = (bool)ivisible;
    1618             if (GetIndices(interp, argc-4, argv+4, &indices) != TCL_OK) {
    1619                 return TCL_ERROR;
    1620             }
    1621             for (unsigned int i = 0; i < indices.size(); ++i) {
    1622                 if ((indices[i] < NanoVis::heightMap.size()) &&
    1623                     (NanoVis::heightMap[indices[i]] != NULL)) {
    1624                     NanoVis::heightMap[indices[i]]->setLineContourVisible(visible);
    1625                 }
    1626             }
    1627         } else if ((c == 'c') && (strcmp(argv[2],"color") == 0)) {
    1628             if (argc < 6) {
    1629                 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    1630                         " linecontour color r g b ?indices?", (char *)NULL);
    1631                 return TCL_ERROR;
    1632             }
    1633             float r, g, b;
    1634             if ((GetFloat(interp, argv[3], &r) != TCL_OK) ||
    1635                 (GetFloat(interp, argv[4], &g) != TCL_OK) ||
    1636                 (GetFloat(interp, argv[5], &b) != TCL_OK)) {
    1637                 return TCL_ERROR;
    1638             }           
    1639             vector<unsigned int> indices;
    1640             if (GetIndices(interp, argc-6, argv+6, &indices) != TCL_OK) {
    1641                 return TCL_ERROR;
    1642             }
    1643             for (unsigned int i = 0; i < indices.size(); ++i) {
    1644                 if ((indices[i] < NanoVis::heightMap.size()) &&
    1645                     (NanoVis::heightMap[indices[i]] != NULL)) {
    1646                     NanoVis::heightMap[indices[i]]->setLineContourColor(r, g, b);
    1647                 }
    1648             }
    1649         } else {
    1650             Tcl_AppendResult(interp, "unknown option \"", argv[2], "\": ",
    1651                 "should be visible or color", (char *)NULL);
    1652             return TCL_ERROR;
    1653         }
    1654     } else if ((c == 't') && (strcmp(argv[1], "transfunc") == 0)) {
    1655         if (argc < 3) {
    1656             Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    1657                 " transfunc name ?indices?", (char *)NULL);
    1658             return TCL_ERROR;
    1659         }
    1660         TransferFunction *tf;
    1661 
    1662         tf = NanoVis::get_transfunc(argv[2]);
    1663         if (tf == NULL) {
    1664             Tcl_AppendResult(interp, "transfer function \"", argv[2],
    1665                 "\" is not defined", (char*)NULL);
    1666             return TCL_ERROR;
    1667         }
    1668         vector<unsigned int> indices;
    1669         if (GetIndices(interp, argc - 3, argv + 3, &indices) != TCL_OK) {
    1670                 return TCL_ERROR;
    1671         }
    1672         for (unsigned int i = 0; i < indices.size(); ++i) {
    1673             if ((indices[i] < NanoVis::heightMap.size()) &&
    1674                 (NanoVis::heightMap[indices[i]] != NULL)) {
    1675                 NanoVis::heightMap[indices[i]]->setColorMap(tf);
    1676             }
    1677         }
    1678     } else if ((c == 'l') && (strcmp(argv[1], "legend") == 0)) {
    1679         if (argc != 5) {
    1680             Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    1681                              " legend index width height\"", (char*)NULL);
    1682             return TCL_ERROR;
    1683         }
    1684         HeightMap *hMap;
    1685         if (GetHeightMap(interp, argv[2], &hMap) != TCL_OK) {
    1686             return TCL_ERROR;
    1687         }
    1688         TransferFunction *tf;
    1689         tf = hMap->getColorMap();
    1690         if (tf == NULL) {
    1691             Tcl_AppendResult(interp,
    1692                 "no transfer function defined for heightmap \"", argv[1], "\"",
    1693                 (char*)NULL);
    1694             return TCL_ERROR;
    1695         }
    1696         int width, height;
    1697         if ((Tcl_GetInt(interp, argv[3], &width) != TCL_OK) ||
    1698             (Tcl_GetInt(interp, argv[4], &height) != TCL_OK)) {
    1699             return TCL_ERROR;
    1700         }
    1701         NanoVis::render_legend(tf, hMap->range_min(), hMap->range_max(),
    1702                 width, height, argv[1]);
    1703     } else if ((c == 'p') && (strcmp(argv[1], "polygon") == 0)) {
    1704         if (argc != 3) {
    1705             Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    1706                 " polygon mode", (char *)NULL);
    1707             return TCL_ERROR;
    1708         }
    1709         graphics::RenderContext::PolygonMode mode;
    1710         if (GetPolygonMode(interp, argv[2], &mode) != TCL_OK) {
    1711             return TCL_ERROR;
    1712         }
    1713         NanoVis::renderContext->setPolygonMode(mode);
    1714     } else if ((c == 'c') && (strcmp(argv[1], "cull") == 0)) {
    1715         if (argc != 3) {
    1716             Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    1717                 " cull mode", (char *)NULL);
    1718             return TCL_ERROR;
    1719         }
    1720         graphics::RenderContext::CullMode mode;
    1721         if (GetCullMode(interp, argv[2], &mode) != TCL_OK) {
    1722             return TCL_ERROR;
    1723         }
    1724         NanoVis::renderContext->setCullMode(mode);
    1725     } else if ((c == 's') && (strcmp(argv[1], "shade") == 0)) {
    1726         if (argc != 3) {
    1727             Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    1728                 " shade model", (char *)NULL);
    1729             return TCL_ERROR;
    1730         }
    1731         graphics::RenderContext::ShadingModel model;
    1732         if (GetShadingModel(interp, argv[2], &model) != TCL_OK) {
    1733             return TCL_ERROR;
    1734         }
    1735         NanoVis::renderContext->setShadingModel(model);
    1736     } else {
    1737         Tcl_AppendResult(interp, "bad option \"", argv[1],
    1738                 "\": should be data, linecontour, legend, or transfunc",
    1739                 (char*)NULL);
    1740         return TCL_ERROR;
    1741     }
    1742     return TCL_OK;
    1743 }
     1633    /* heightmap create xmin ymin xmax ymax xnum ynum values */
     1634    hMap = CreateHeightMap(cdata, interp, objc - 2, objv + 2);
     1635    if (hMap == NULL) {
     1636        return TCL_ERROR;
     1637    }
     1638    NanoVis::heightMap.push_back(hMap);
     1639    Tcl_SetIntObj(Tcl_GetObjResult(interp), NanoVis::heightMap.size() - 1);;
     1640    return TCL_OK;
     1641}
     1642
     1643static int
     1644HeightMapLegendOp(ClientData cdata, Tcl_Interp *interp, int objc,
     1645                  Tcl_Obj *CONST *objv)
     1646{
     1647    HeightMap *hMap;
     1648    if (GetHeightMap(interp, objv[2], &hMap) != TCL_OK) {
     1649        return TCL_ERROR;
     1650    }
     1651    TransferFunction *tf;
     1652    tf = hMap->getColorMap();
     1653    if (tf == NULL) {
     1654        Tcl_AppendResult(interp, "no transfer function defined for heightmap \"",
     1655                Tcl_GetString(objv[2]), "\"", (char*)NULL);
     1656        return TCL_ERROR;
     1657    }
     1658    int w, h;
     1659    if ((Tcl_GetIntFromObj(interp, objv[3], &w) != TCL_OK) ||
     1660        (Tcl_GetIntFromObj(interp, objv[4], &h) != TCL_OK)) {
     1661        return TCL_ERROR;
     1662    }
     1663    NanoVis::render_legend(tf, hMap->range_min(), hMap->range_max(),
     1664                           w, h, "label");
     1665    return TCL_OK;
     1666}
     1667
     1668static int
     1669HeightMapPolygonOp(ClientData cdata, Tcl_Interp *interp, int objc,
     1670                   Tcl_Obj *CONST *objv)
     1671{
     1672    graphics::RenderContext::PolygonMode mode;
     1673    if (GetPolygonMode(interp, objv[2], &mode) != TCL_OK) {
     1674        return TCL_ERROR;
     1675    }
     1676    NanoVis::renderContext->setPolygonMode(mode);
     1677    return TCL_OK;
     1678}
     1679
     1680static int
     1681HeightMapShadeOp(ClientData cdata, Tcl_Interp *interp, int objc,
     1682                   Tcl_Obj *CONST *objv)
     1683{
     1684    graphics::RenderContext::ShadingModel model;
     1685    if (GetShadingModel(interp, objv[2], &model) != TCL_OK) {
     1686        return TCL_ERROR;
     1687    }
     1688    NanoVis::renderContext->setShadingModel(model);
     1689    return TCL_OK;
     1690}
     1691
     1692static int
     1693HeightMapTestOp(ClientData cdata, Tcl_Interp *interp, int objc,
     1694        Tcl_Obj *CONST *objv)
     1695{
     1696    srand((unsigned)time(NULL));
     1697
     1698    int size = 20 * 200;
     1699    double sigma = 5.0;
     1700    double mean = exp(0.0) / (sigma * sqrt(2.0));
     1701    float* data = (float*) malloc(sizeof(float) * size);
     1702   
     1703    float x;
     1704    for (int i = 0; i < size; ++i) {
     1705        x = - 10 + i%20;
     1706        data[i] = exp(- (x * x)/(2 * sigma * sigma)) /
     1707            (sigma * sqrt(2.0)) / mean * 2 + 1000;
     1708    }
     1709   
     1710    HeightMap* heightMap = new HeightMap();
     1711    float minx = 0.0f;
     1712    float maxx = 1.0f;
     1713    float miny = 0.5f;
     1714    float maxy = 3.5f;
     1715    heightMap->setHeight(minx, miny, maxx, maxy, 20, 200, data);
     1716    heightMap->setColorMap(NanoVis::get_transfunc("default"));
     1717    heightMap->setVisible(true);
     1718    heightMap->setLineContourVisible(true);
     1719    NanoVis::heightMap.push_back(heightMap);
     1720
     1721
     1722    Vector3 min(minx, (float) heightMap->range_min(), miny);
     1723    Vector3 max(maxx, (float) heightMap->range_max(), maxy);
     1724   
     1725    NanoVis::grid->setMinMax(min, max);
     1726    NanoVis::grid->setVisible(true);
     1727   
     1728    return TCL_OK;
     1729}
     1730
     1731static int
     1732HeightMapTransFuncOp(ClientData cdata, Tcl_Interp *interp, int objc,
     1733                     Tcl_Obj *CONST *objv)
     1734{
     1735    char *name;
     1736    name = Tcl_GetString(objv[2]);
     1737    TransferFunction *tf;
     1738    tf = NanoVis::get_transfunc(name);
     1739    if (tf == NULL) {
     1740        Tcl_AppendResult(interp, "transfer function \"", name,
     1741                         "\" is not defined", (char*)NULL);
     1742        return TCL_ERROR;
     1743    }
     1744    vector<unsigned int> indices;
     1745    if (GetIndices(interp, objc - 3, objv + 3, &indices) != TCL_OK) {
     1746        return TCL_ERROR;
     1747    }
     1748    for (unsigned int i = 0; i < indices.size(); ++i) {
     1749        if ((indices[i] < NanoVis::heightMap.size()) &&
     1750            (NanoVis::heightMap[indices[i]] != NULL)) {
     1751            NanoVis::heightMap[indices[i]]->setColorMap(tf);
     1752        }
     1753    }
     1754    return TCL_OK;
     1755}
     1756
     1757static Rappture::CmdSpec heightMapOps[] =
     1758{
     1759    {"create",       2, HeightMapCreateOp,      9, 9,
     1760        "xmin ymin xmax ymax xnum ynum values",},
     1761    {"cull",         2, HeightMapCullOp,        3, 3, "mode",},
     1762    {"data",         1, HeightMapDataOp,        3, 0, "oper ?args?",},
     1763    {"legend",       2, HeightMapLegendOp,      5, 5, "index width height",},
     1764    {"linecontour",  2, HeightMapLineContourOp, 2, 0, "oper ?args?",},
     1765    {"polygon",      1, HeightMapPolygonOp,     3, 3, "mode",},
     1766    {"shade",        1, HeightMapShadeOp,       3, 3, "model",},
     1767    {"test",         2, HeightMapTestOp,        2, 2, "",},
     1768    {"transfunc",    2, HeightMapTransFuncOp,   3, 0, "name ?indices?",},
     1769};
     1770static int nHeightMapOps = NumCmdSpecs(heightMapOps);
    17441771
    17451772static int
    1746 GridCmd(ClientData cdata, Tcl_Interp *interp, int argc, const char *argv[])
    1747 {
    1748     if (argc < 2) {
    1749         Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    1750                          " option ?args?", (char *)NULL);
    1751         return TCL_ERROR;
    1752     }
    1753     char c = argv[1][0];
    1754     if ((c == 'v') && (strcmp(argv[1],"visible") == 0)) {
     1773HeightMapCmd(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv)
     1774{
     1775    Tcl_ObjCmdProc *proc;
     1776
     1777    proc = Rappture::GetOpFromObj(interp, nHeightMapOps, heightMapOps,
     1778        Rappture::CMDSPEC_ARG1, objc, objv, 0);
     1779    if (proc == NULL) {
     1780        return TCL_ERROR;
     1781    }
     1782    return (*proc) (cdata, interp, objc, objv);
     1783}
     1784
     1785static int
     1786GridCmd(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv)
     1787{
     1788    if (objc < 2) {
     1789        Tcl_AppendResult(interp, "wrong # args: should be \"",
     1790                Tcl_GetString(objv[0]), " option ?args?", (char *)NULL);
     1791        return TCL_ERROR;
     1792    }
     1793    char *string = Tcl_GetString(objv[1]);
     1794    char c = string[0];
     1795    if ((c == 'v') && (strcmp(string,"visible") == 0)) {
    17551796        int ivisible;
    17561797
    1757         if (Tcl_GetBoolean(interp, argv[2], &ivisible) != TCL_OK) {
     1798        if (Tcl_GetBooleanFromObj(interp, objv[2], &ivisible) != TCL_OK) {
    17581799            return TCL_ERROR;
    17591800        }
    17601801        NanoVis::grid->setVisible((bool)ivisible);
    1761     } else if ((c == 'l') && (strcmp(argv[1],"linecount") == 0)) {
     1802    } else if ((c == 'l') && (strcmp(string, "linecount") == 0)) {
    17621803        int x, y, z;
    17631804
    1764         if ((Tcl_GetInt(interp, argv[2], &x) != TCL_OK) ||
    1765             (Tcl_GetInt(interp, argv[3], &y) != TCL_OK) ||
    1766             (Tcl_GetInt(interp, argv[4], &z) != TCL_OK)) {
     1805        if ((Tcl_GetIntFromObj(interp, objv[2], &x) != TCL_OK) ||
     1806            (Tcl_GetIntFromObj(interp, objv[3], &y) != TCL_OK) ||
     1807            (Tcl_GetIntFromObj(interp, objv[4], &z) != TCL_OK)) {
    17671808            return TCL_ERROR;
    17681809        }
     
    17701811            NanoVis::grid->setGridLineCount(x, y, z);
    17711812        }
    1772     } else if ((c == 'a') && (strcmp(argv[1],"axiscolor") == 0)) {
     1813    } else if ((c == 'a') && (strcmp(string, "axiscolor") == 0)) {
    17731814        float r, g, b, a;
    1774         if ((GetFloat(interp, argv[2], &r) != TCL_OK) ||
    1775             (GetFloat(interp, argv[3], &g) != TCL_OK) ||
    1776             (GetFloat(interp, argv[4], &b) != TCL_OK)) {
     1815        if ((GetFloatFromObj(interp, objv[2], &r) != TCL_OK) ||
     1816            (GetFloatFromObj(interp, objv[3], &g) != TCL_OK) ||
     1817            (GetFloatFromObj(interp, objv[4], &b) != TCL_OK)) {
    17771818            return TCL_ERROR;
    17781819        }
    17791820        a = 1.0f;
    1780         if ((argc == 6) && (GetFloat(interp, argv[5], &a) != TCL_OK)) {
     1821        if ((objc == 6) && (GetFloatFromObj(interp, objv[5], &a) != TCL_OK)) {
    17811822            return TCL_ERROR;
    17821823        }           
     
    17841825            NanoVis::grid->setAxisColor(r, g, b, a);
    17851826        }
    1786     } else if ((c == 'l') && (strcmp(argv[1],"linecolor") == 0)) {
     1827    } else if ((c == 'l') && (strcmp(string, "linecolor") == 0)) {
    17871828        float r, g, b, a;
    1788         if ((GetFloat(interp, argv[2], &r) != TCL_OK) ||
    1789             (GetFloat(interp, argv[3], &g) != TCL_OK) ||
    1790             (GetFloat(interp, argv[4], &b) != TCL_OK)) {
     1829        if ((GetFloatFromObj(interp, objv[2], &r) != TCL_OK) ||
     1830            (GetFloatFromObj(interp, objv[3], &g) != TCL_OK) ||
     1831            (GetFloatFromObj(interp, objv[4], &b) != TCL_OK)) {
    17911832            return TCL_ERROR;
    17921833        }
    17931834        a = 1.0f;
    1794         if ((argc == 6) && (GetFloat(interp, argv[5], &a) != TCL_OK)) {
     1835        if ((objc == 6) && (GetFloatFromObj(interp, objv[5], &a) != TCL_OK)) {
    17951836            return TCL_ERROR;
    17961837        }           
     
    17981839            NanoVis::grid->setGridLineColor(r, g, b, a);
    17991840        }
    1800     } else if ((c == 'm') && (strcmp(argv[1],"minmax") == 0)) {
     1841    } else if ((c == 'm') && (strcmp(string, "minmax") == 0)) {
    18011842        double x1, y1, z1, x2, y2, z2;
    1802         if ((Tcl_GetDouble(interp, argv[2], &x1) != TCL_OK) ||
    1803             (Tcl_GetDouble(interp, argv[3], &y1) != TCL_OK) ||
    1804             (Tcl_GetDouble(interp, argv[4], &z1) != TCL_OK) ||
    1805             (Tcl_GetDouble(interp, argv[5], &x2) != TCL_OK) ||
    1806             (Tcl_GetDouble(interp, argv[6], &y2) != TCL_OK) ||
    1807             (Tcl_GetDouble(interp, argv[7], &z2) != TCL_OK)) {
     1843        if ((Tcl_GetDoubleFromObj(interp, objv[2], &x1) != TCL_OK) ||
     1844            (Tcl_GetDoubleFromObj(interp, objv[3], &y1) != TCL_OK) ||
     1845            (Tcl_GetDoubleFromObj(interp, objv[4], &z1) != TCL_OK) ||
     1846            (Tcl_GetDoubleFromObj(interp, objv[5], &x2) != TCL_OK) ||
     1847            (Tcl_GetDoubleFromObj(interp, objv[6], &y2) != TCL_OK) ||
     1848            (Tcl_GetDoubleFromObj(interp, objv[7], &z2) != TCL_OK)) {
    18081849            return TCL_ERROR;
    18091850        }
     
    18111852            NanoVis::grid->setMinMax(Vector3(x1, y1, z1), Vector3(x2, y2, z2));
    18121853        }
    1813     } else if ((c == 'a') && (strcmp(argv[1],"axisname") == 0)) {
     1854    } else if ((c == 'a') && (strcmp(string, "axisname") == 0)) {
    18141855        int axisId;
    1815         if (GetAxis(interp, argv[2], &axisId) != TCL_OK) {
     1856        if (GetAxisFromObj(interp, objv[2], &axisId) != TCL_OK) {
    18161857            return TCL_ERROR;
    18171858        }
    18181859        if (NanoVis::grid) {
    1819             NanoVis::grid->setAxisName(axisId, argv[3]);
     1860            NanoVis::grid->setAxisName(axisId, Tcl_GetString(objv[3]));
    18201861        }
    18211862    } else {
    1822         Tcl_AppendResult(interp, "bad option \"", argv[1],
     1863        Tcl_AppendResult(interp, "bad option \"", Tcl_GetString(objv[1]),
    18231864                         "\": should be data, outline, shading, or state",
    18241865                         (char*)NULL);
     
    18291870
    18301871static int
    1831 AxisCmd(ClientData cdata, Tcl_Interp *interp, int argc, const char *argv[])
    1832 {
    1833     if (argc < 2) {
    1834         Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    1835             " option arg arg...\"", (char*)NULL);
    1836         return TCL_ERROR;
    1837     }
    1838     char c = argv[1][0];
    1839     if ((c == 'v') && (strcmp(argv[1], "visible") == 0)) {
     1872AxisCmd(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv)
     1873{
     1874    if (objc < 2) {
     1875        Tcl_AppendResult(interp, "wrong # args: should be \"",
     1876                Tcl_GetString(objv[0]), " option arg arg...\"", (char*)NULL);
     1877        return TCL_ERROR;
     1878    }
     1879    char *string = Tcl_GetString(objv[1]);
     1880    char c = string[0];
     1881    if ((c == 'v') && (strcmp(string, "visible") == 0)) {
    18401882        int ivisible;
    18411883
    1842         if (Tcl_GetBoolean(interp, argv[2], &ivisible) != TCL_OK) {
     1884        if (Tcl_GetBooleanFromObj(interp, objv[2], &ivisible) != TCL_OK) {
    18431885            return TCL_ERROR;
    18441886        }
    18451887        NanoVis::axis_on = (bool)ivisible;
    18461888    } else {
    1847         Tcl_AppendResult(interp, "bad axis option \"", argv[1],
     1889        Tcl_AppendResult(interp, "bad axis option \"", string,
    18481890                         "\": should be visible", (char*)NULL);
    18491891        return TCL_ERROR;
     
    18661908 */
    18671909static int
    1868 GetHeightMap(Tcl_Interp *interp, const char *string, HeightMap **hmPtrPtr)
     1910GetHeightMap(Tcl_Interp *interp, Tcl_Obj *objPtr, HeightMap **hmPtrPtr)
    18691911{
    18701912    int mapIndex;
    1871     if (Tcl_GetInt(interp, string, &mapIndex) != TCL_OK) {
     1913    if (Tcl_GetIntFromObj(interp, objPtr, &mapIndex) != TCL_OK) {
    18721914        return TCL_ERROR;
    18731915    }
    18741916    if ((mapIndex < 0) || (mapIndex >= (int)NanoVis::heightMap.size()) ||
    18751917        (NanoVis::heightMap[mapIndex] == NULL)) {
    1876         Tcl_AppendResult(interp, "invalid heightmap index \"", string, "\"",
    1877                         (char *)NULL);
     1918        Tcl_AppendResult(interp, "invalid heightmap index \"",
     1919                Tcl_GetString(objPtr), "\"", (char *)NULL);
    18781920        return TCL_ERROR;
    18791921    }
     
    18961938 */
    18971939static int
    1898 GetVolumeIndex(Tcl_Interp *interp, const char *string, unsigned int *indexPtr)
     1940GetVolumeIndex(Tcl_Interp *interp, Tcl_Obj *objPtr, unsigned int *indexPtr)
    18991941{
    19001942    int index;
    1901     if (Tcl_GetInt(interp, string, &index) != TCL_OK) {
     1943    if (Tcl_GetIntFromObj(interp, objPtr, &index) != TCL_OK) {
    19021944        return TCL_ERROR;
    19031945    }
    19041946    if (index < 0) {
    1905         Tcl_AppendResult(interp, "can't have negative index \"", string,
    1906                         "\"", (char*)NULL);
     1947        Tcl_AppendResult(interp, "can't have negative index \"",
     1948                Tcl_GetString(objPtr), "\"", (char*)NULL);
    19071949        return TCL_ERROR;
    19081950    }
    19091951    if (index >= (int)NanoVis::volume.size()) {
    1910         Tcl_AppendResult(interp, "index \"", string,
     1952        Tcl_AppendResult(interp, "index \"", Tcl_GetString(objPtr),
    19111953                         "\" is out of range", (char*)NULL);
    19121954        return TCL_ERROR;
     
    19181960/*
    19191961 * ----------------------------------------------------------------------
    1920  * FUNCTION: GetVolume
     1962 * FUNCTION: GetVolumeFromObj
    19211963 *
    19221964 * Used internally to decode a series of volume index values and
     
    19301972 */
    19311973static int
    1932 GetVolume(Tcl_Interp *interp, const char *string, Volume **volPtrPtr)
     1974GetVolumeFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, Volume **volPtrPtr)
    19331975{
    19341976    unsigned int index;
    1935     if (GetVolumeIndex(interp, string, &index) != TCL_OK) {
     1977    if (GetVolumeIndex(interp, objPtr, &index) != TCL_OK) {
    19361978        return TCL_ERROR;
    19371979    }
     
    19391981    vol = NanoVis::volume[index];
    19401982    if (vol == NULL) {
    1941         Tcl_AppendResult(interp, "no volume defined for index \"", string,
    1942                         "\"", (char*)NULL);
     1983        Tcl_AppendResult(interp, "no volume defined for index \"",
     1984                Tcl_GetString(objPtr), "\"", (char*)NULL);
    19431985        return TCL_ERROR;
    19441986    }
     
    19612003 */
    19622004static int
    1963 GetVolumeIndices(Tcl_Interp *interp, int argc, const char *argv[],
     2005GetVolumeIndices(Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv,
    19642006    vector<unsigned int>* vectorPtr)
    19652007{
    1966     if (argc == 0) {
     2008    if (objc == 0) {
    19672009        for (unsigned int n = 0; n < NanoVis::volume.size(); n++) {
    19682010            if (NanoVis::volume[n] != NULL) {
     
    19712013        }
    19722014    } else {
    1973         for (int n = 0; n < argc; n++) {
     2015        for (int n = 0; n < objc; n++) {
    19742016            unsigned int index;
    19752017
    1976             if (GetVolumeIndex(interp, argv[n], &index) != TCL_OK) {
     2018            if (GetVolumeIndex(interp, objv[n], &index) != TCL_OK) {
    19772019                return TCL_ERROR;
    19782020            }
     
    19862028
    19872029static int
    1988 GetIndices(Tcl_Interp *interp, int argc, const char *argv[],
     2030GetIndices(Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv,
    19892031    vector<unsigned int>* vectorPtr)
    19902032{
    1991     for (int n = 0; n < argc; n++) {
     2033    for (int n = 0; n < objc; n++) {
    19922034        int index;
    19932035
    1994         if (Tcl_GetInt(interp, argv[n], &index) != TCL_OK) {
     2036        if (Tcl_GetIntFromObj(interp, objv[n], &index) != TCL_OK) {
    19952037            return TCL_ERROR;
    19962038        }
    19972039        if (index < 0) {
    1998             Tcl_AppendResult(interp, "can't have negative index \"", argv[n],
    1999                             "\"", (char *)NULL);
     2040            Tcl_AppendResult(interp, "can't have negative index \"",
     2041                Tcl_GetString(objv[n]), "\"", (char *)NULL);
    20002042            return TCL_ERROR;
    20012043        }
     
    20202062 */
    20212063static int
    2022 GetVolumes(Tcl_Interp *interp, int argc, const char *argv[],
     2064GetVolumes(Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv,
    20232065    vector<Volume *>* vectorPtr)
    20242066{
    2025     if (argc == 0) {
     2067    if (objc == 0) {
    20262068        for (unsigned int n = 0; n < NanoVis::volume.size(); n++) {
    20272069            if (NanoVis::volume[n] != NULL) {
     
    20302072        }
    20312073    } else {
    2032         for (int n = 0; n < argc; n++) {
     2074        for (int n = 0; n < objc; n++) {
    20332075            Volume *volPtr;
    20342076
    2035             if (GetVolume(interp, argv[n], &volPtr) != TCL_OK) {
     2077            if (GetVolumeFromObj(interp, objv[n], &volPtr) != TCL_OK) {
    20362078                return TCL_ERROR;
    20372079            }
     
    20432085    return TCL_OK;
    20442086}
     2087
    20452088
    20462089/*
     
    20552098 */
    20562099static int
    2057 GetAxis(Tcl_Interp *interp, const char *string, int *valPtr)
     2100GetAxis(Tcl_Interp *interp, const char *string, int *indexPtr)
    20582101{
    20592102    if (string[1] == '\0') {
     
    20622105        c = tolower((unsigned char)string[0]);
    20632106        if (c == 'x') {
    2064             *valPtr = 0;
     2107            *indexPtr = 0;
    20652108            return TCL_OK;
    20662109        } else if (c == 'y') {
    2067             *valPtr = 1;
     2110            *indexPtr = 1;
    20682111            return TCL_OK;
    20692112        } else if (c == 'z') {
    2070             *valPtr = 2;
     2113            *indexPtr = 2;
    20712114            return TCL_OK;
    20722115        }
     
    20782121}
    20792122
     2123
     2124/*
     2125 * ----------------------------------------------------------------------
     2126 * FUNCTION: GetAxisFromObj()
     2127 *
     2128 * Used internally to decode an axis value from a string ("x", "y",
     2129 * or "z") to its index (0, 1, or 2).  Returns TCL_OK if successful,
     2130 * along with a value in indexPtr.  Otherwise, it returns TCL_ERROR
     2131 * and an error message in the interpreter.
     2132 * ----------------------------------------------------------------------
     2133 */
     2134static int
     2135GetAxisFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, int *indexPtr)
     2136{
     2137    return GetAxis(interp, Tcl_GetString(objPtr), indexPtr);
     2138}
     2139
     2140/*
     2141 * ----------------------------------------------------------------------
     2142 * FUNCTION: GetAxisDirFromObj()
     2143 *
     2144 * Used internally to decode an axis value from a string ("x", "y",
     2145 * or "z") to its index (0, 1, or 2).  Returns TCL_OK if successful,
     2146 * along with a value in indexPtr.  Otherwise, it returns TCL_ERROR
     2147 * and an error message in the interpreter.
     2148 * ----------------------------------------------------------------------
     2149 */
     2150static int
     2151GetAxisDirFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, int *indexPtr, int *dirPtr)
     2152{
     2153    char *string = Tcl_GetString(objPtr);
     2154
     2155    int sign = 1;
     2156    if (*string == '-') {
     2157        sign = -1;
     2158        string++;
     2159    }
     2160    if (GetAxis(interp, string, indexPtr) != TCL_OK) {
     2161        return TCL_ERROR;
     2162    }
     2163    if (dirPtr != NULL) {
     2164        *dirPtr = sign;
     2165    }
     2166    return TCL_OK;
     2167}
     2168
    20802169/*
    20812170 * ----------------------------------------------------------------------
     
    20842173 * Used internally to decode a color value from a string ("R G B")
    20852174 * as a list of three numbers 0-1.  Returns TCL_OK if successful,
    2086  * along with RGB values in valPtr.  Otherwise, it returns TCL_ERROR
     2175 * along with RGB values in rgbPtr.  Otherwise, it returns TCL_ERROR
    20872176 * and an error message in the interpreter.
    20882177 * ----------------------------------------------------------------------
    20892178 */
    20902179static int
    2091 GetColor(Tcl_Interp *interp, int argc, const char *argv[], float *rgbPtr)
    2092 {
    2093     if (argc < 3) {
     2180GetColor(Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv, float *rgbPtr)
     2181{
     2182    if (objc < 3) {
    20942183        Tcl_AppendResult(interp, "missing color values\": ",
    20952184                "should list of R G B values 0.0 - 1.0", (char*)NULL);
    20962185        return TCL_ERROR;
    20972186    }
    2098     if ((GetFloat(interp, argv[0], rgbPtr + 0) != TCL_OK) ||
    2099         (GetFloat(interp, argv[1], rgbPtr + 1) != TCL_OK) ||
    2100         (GetFloat(interp, argv[2], rgbPtr + 2) != TCL_OK)) {
     2187    if ((GetFloatFromObj(interp, objv[0], rgbPtr + 0) != TCL_OK) ||
     2188        (GetFloatFromObj(interp, objv[1], rgbPtr + 1) != TCL_OK) ||
     2189        (GetFloatFromObj(interp, objv[2], rgbPtr + 2) != TCL_OK)) {
    21012190        return TCL_ERROR;
    21022191    }
     
    21072196#if PLANE_CMDS
    21082197static int
    2109 PlaneNewCmd(ClientData cdata, Tcl_Interp *interp, int argc,
    2110             const char *argv[])
     2198PlaneNewCmd(ClientData cdata, Tcl_Interp *interp, int objc,
     2199            Tcl_Obj *CONST *objv)
    21112200{
    21122201    fprintf(stderr, "load plane for 2D visualization command\n");
    2113    
    21142202    int index, w, h;
    2115    
    2116     if (argc != 4) {
    2117         Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    2118                          " plane_index w h \"", (char*)NULL);
    2119         return TCL_ERROR;
    2120     }
    2121     if (Tcl_GetInt(interp, argv[1], &index) != TCL_OK) {
    2122         return TCL_ERROR;
    2123     }
    2124     if (Tcl_GetInt(interp, argv[2], &w) != TCL_OK) {
    2125         return TCL_ERROR;
    2126     }
    2127     if (Tcl_GetInt(interp, argv[3], &h) != TCL_OK) {
     2203    if (objc != 4) {
     2204        Tcl_AppendResult(interp, "wrong # args: should be \"",
     2205                Tcl_GetString(objv[0]), " plane_index w h \"", (char*)NULL);
     2206        return TCL_ERROR;
     2207    }
     2208    if (Tcl_GetIntFromObj(interp, objv[1], &index) != TCL_OK) {
     2209        return TCL_ERROR;
     2210    }
     2211    if (Tcl_GetIntFromObj(interp, objv[2], &w) != TCL_OK) {
     2212        return TCL_ERROR;
     2213    }
     2214    if (Tcl_GetIntFromObj(interp, objv[3], &h) != TCL_OK) {
    21282215        return TCL_ERROR;
    21292216    }
     
    21482235
    21492236static int
    2150 PlaneLinkCmd(ClientData cdata, Tcl_Interp *interp, int argc,
    2151              const char *argv[])
     2237PlaneLinkCmd(ClientData cdata, Tcl_Interp *interp, int objc,
     2238             Tcl_Obj *CONST *objv)
    21522239{
    21532240    fprintf(stderr, "link the plane to the 2D renderer command\n");
     
    21552242    int plane_index, tf_index;
    21562243   
    2157     if (argc != 3) {
    2158         Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    2159                         " plane_index tf_index \"", (char*)NULL);
    2160         return TCL_ERROR;
    2161     }
    2162     if (Tcl_GetInt(interp, argv[1], &plane_index) != TCL_OK) {
    2163         return TCL_ERROR;
    2164     }
    2165     if (Tcl_GetInt(interp, argv[2], &tf_index) != TCL_OK) {
     2244    if (objc != 3) {
     2245        Tcl_AppendResult(interp, "wrong # args: should be \"",
     2246                Tcl_GetString(objv[0]), " plane_index tf_index \"", (char*)NULL);
     2247        return TCL_ERROR;
     2248    }
     2249    if (Tcl_GetIntFromObj(interp, objv[1], &plane_index) != TCL_OK) {
     2250        return TCL_ERROR;
     2251    }
     2252    if (Tcl_GetIntFromObj(interp, objv[2], &tf_index) != TCL_OK) {
    21662253        return TCL_ERROR;
    21672254    }
     
    21732260//The plane_index is the index mantained in the 2D plane renderer
    21742261static int
    2175 PlaneEnableCmd(ClientData cdata, Tcl_Interp *interp, int argc,
    2176                const char *argv[])
     2262PlaneEnableCmd(ClientData cdata, Tcl_Interp *interp, int objc,
     2263        Tcl_Obj *CONST *objv)
    21772264{
    21782265    fprintf(stderr,"enable a plane so the 2D renderer can render it command\n");
    21792266   
    2180     if (argc != 3) {
    2181         Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    2182                         " plane_index mode \"", (char*)NULL);
     2267    if (objc != 3) {
     2268        Tcl_AppendResult(interp, "wrong # args: should be \"",
     2269                Tcl_GetString(objv[0]), " plane_index mode \"", (char*)NULL);
    21832270        return TCL_ERROR;
    21842271    }
    21852272    int plane_index;
    2186     if (Tcl_GetInt(interp, argv[1], &plane_index) != TCL_OK) {
     2273    if (Tcl_GetIntFromObj(interp, objv[1], &plane_index) != TCL_OK) {
    21872274        return TCL_ERROR;
    21882275    }
    21892276    int mode;
    2190     if (Tcl_GetInt(interp, argv[2], &mode) != TCL_OK) {
     2277    if (Tcl_GetIntFromObj(interp, objv[2], &mode) != TCL_OK) {
    21912278        return TCL_ERROR;
    21922279    }
     
    22082295
    22092296    // manipulate the viewpoint
    2210     Tcl_CreateCommand(interp, "camera", CameraCmd,
    2211         (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
     2297    Tcl_CreateObjCommand(interp, "camera", CameraCmd,
     2298        NULL, (Tcl_CmdDeleteProc*)NULL);
    22122299
    22132300    // turn on/off cut planes in x/y/z directions
    2214     Tcl_CreateCommand(interp, "cutplane", CutplaneCmd,
    2215         (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
     2301    Tcl_CreateObjCommand(interp, "cutplane", CutplaneCmd,
     2302        NULL, (Tcl_CmdDeleteProc*)NULL);
    22162303
    22172304    // request the legend for a plot (transfer function)
    2218     Tcl_CreateCommand(interp, "legend", LegendCmd,
    2219         (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
     2305    Tcl_CreateObjCommand(interp, "legend", LegendCmd,
     2306        NULL, (Tcl_CmdDeleteProc*)NULL);
    22202307
    22212308    // change the size of the screen (size of picture generated)
    2222     Tcl_CreateCommand(interp, "screen", ScreenCmd,
    2223         (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
     2309    Tcl_CreateObjCommand(interp, "screen", ScreenCmd,
     2310        NULL, (Tcl_CmdDeleteProc*)NULL);
    22242311
    22252312    // manipulate transfer functions
    2226     Tcl_CreateCommand(interp, "transfunc", TransfuncCmd,
    2227         (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
     2313    Tcl_CreateObjCommand(interp, "transfunc", TransfuncCmd,
     2314        NULL, (Tcl_CmdDeleteProc*)NULL);
    22282315
    22292316    // set the "up" direction for volumes
    2230     Tcl_CreateCommand(interp, "up", UpCmd,
    2231         (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
     2317    Tcl_CreateObjCommand(interp, "up", UpCmd,
     2318        NULL, (Tcl_CmdDeleteProc*)NULL);
    22322319
    22332320    // manipulate volume data
    2234     Tcl_CreateCommand(interp, "volume", VolumeCmd,
    2235         (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
    2236 
    2237     Tcl_CreateCommand(interp, "flow", FlowCmd,
    2238         (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
    2239 
    2240     Tcl_CreateCommand(interp, "axis", AxisCmd,
    2241         (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
    2242 
    2243     Tcl_CreateCommand(interp, "grid", GridCmd,
    2244         (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
    2245 
    2246     Tcl_CreateCommand(interp, "heightmap", HeightMapCmd,
    2247         (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
     2321    Tcl_CreateObjCommand(interp, "volume", VolumeCmd,
     2322        NULL, (Tcl_CmdDeleteProc*)NULL);
     2323
     2324    Tcl_CreateObjCommand(interp, "flow", FlowCmd,
     2325        NULL, (Tcl_CmdDeleteProc*)NULL);
     2326
     2327    Tcl_CreateObjCommand(interp, "axis", AxisCmd,
     2328        NULL, (Tcl_CmdDeleteProc*)NULL);
     2329
     2330    Tcl_CreateObjCommand(interp, "grid", GridCmd,
     2331        NULL, (Tcl_CmdDeleteProc*)NULL);
     2332
     2333    Tcl_CreateObjCommand(interp, "heightmap", HeightMapCmd,
     2334        NULL, (Tcl_CmdDeleteProc*)NULL);
    22482335
    22492336    // get screenshot
    2250     Tcl_CreateCommand(interp, "screenshot", ScreenShotCmd,
    2251         (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
    2252 
    2253     Tcl_CreateCommand(interp, "unirect2d", UniRect2dCmd,
    2254         (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
    2255 
    2256     Tcl_CreateCommand(interp, "axis", AxisCmd,
    2257         (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
    2258 
    2259     Tcl_CreateCommand(interp, "grid", GridCmd,
    2260         (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
    2261 
    2262     Tcl_CreateCommand(interp, "heightmap", HeightMapCmd,
    2263         (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
     2337    Tcl_CreateObjCommand(interp, "screenshot", ScreenShotCmd,
     2338        NULL, (Tcl_CmdDeleteProc*)NULL);
     2339
     2340    Tcl_CreateObjCommand(interp, "unirect2d", UniRect2dCmd,
     2341        NULL, (Tcl_CmdDeleteProc*)NULL);
     2342
     2343    Tcl_CreateObjCommand(interp, "axis", AxisCmd,
     2344        NULL, (Tcl_CmdDeleteProc*)NULL);
     2345
     2346    Tcl_CreateObjCommand(interp, "grid", GridCmd,
     2347        NULL, (Tcl_CmdDeleteProc*)NULL);
     2348
     2349    Tcl_CreateObjCommand(interp, "heightmap", HeightMapCmd,
     2350        NULL, (Tcl_CmdDeleteProc*)NULL);
    22642351
    22652352    // get screenshot
    2266     Tcl_CreateCommand(interp, "screenshot", ScreenShotCmd,
    2267         (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
    2268 
    2269     Tcl_CreateCommand(interp, "unirect2d", UniRect2dCmd,
    2270         (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
     2353    Tcl_CreateObjCommand(interp, "screenshot", ScreenShotCmd,
     2354        NULL, (Tcl_CmdDeleteProc*)NULL);
     2355
     2356    Tcl_CreateObjCommand(interp, "unirect2d", UniRect2dCmd,
     2357        NULL, (Tcl_CmdDeleteProc*)NULL);
    22712358
    22722359#if __TEST_CODE__
    2273     Tcl_CreateCommand(interp, "test", TestCmd,
    2274         (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
    2275 
    2276 
    2277 //    Tcl_CreateCommand(interp, "flow", FlowCmd,
    2278  //       (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
     2360    Tcl_CreateObjCommand(interp, "test", TestCmd,
     2361        NULL, (Tcl_CmdDeleteProc*)NULL);
     2362
     2363
     2364//    Tcl_CreateObjCommand(interp, "flow", FlowCmd,
     2365 //       NULL, (Tcl_CmdDeleteProc*)NULL);
    22792366#endif
    22802367
     
    24592546 */
    24602547static HeightMap *
    2461 CreateHeightMap(ClientData clientData, Tcl_Interp *interp, int argc,
    2462         const char *argv[])
     2548CreateHeightMap(ClientData clientData, Tcl_Interp *interp, int objc,
     2549                Tcl_Obj *CONST *objv)
    24632550{
    24642551    float xMin, yMin, xMax, yMax;
    24652552    int xNum, yNum;
    24662553
    2467     if (argc != 7) {
     2554    if (objc != 7) {
    24682555        Tcl_AppendResult(interp,
    24692556        "wrong # of values: should be xMin yMin xMax yMax xNum yNum heights",
     
    24712558        return NULL;
    24722559    }
    2473     if ((GetFloat(interp, argv[0], &xMin) != TCL_OK) ||
    2474         (GetFloat(interp, argv[1], &yMin) != TCL_OK) ||
    2475         (GetFloat(interp, argv[2], &xMax) != TCL_OK) ||
    2476         (GetFloat(interp, argv[3], &yMax) != TCL_OK) ||
    2477         (Tcl_GetInt(interp, argv[4], &xNum) != TCL_OK) ||
    2478         (Tcl_GetInt(interp, argv[5], &yNum) != TCL_OK)) {
     2560    if ((GetFloatFromObj(interp, objv[0], &xMin) != TCL_OK) ||
     2561        (GetFloatFromObj(interp, objv[1], &yMin) != TCL_OK) ||
     2562        (GetFloatFromObj(interp, objv[2], &xMax) != TCL_OK) ||
     2563        (GetFloatFromObj(interp, objv[3], &yMax) != TCL_OK) ||
     2564        (Tcl_GetIntFromObj(interp, objv[4], &xNum) != TCL_OK) ||
     2565        (Tcl_GetIntFromObj(interp, objv[5], &yNum) != TCL_OK)) {
    24792566        return NULL;
    24802567    }
    24812568    int nValues;
    2482     const char **elem;
    2483     if (Tcl_SplitList(interp, argv[6], &nValues, &elem) != TCL_OK) {
     2569    Tcl_Obj **elem;
     2570    if (Tcl_ListObjGetElements(interp, objv[6], &nValues, &elem) != TCL_OK) {
    24842571        return NULL;
    24852572    }
    24862573    if ((xNum <= 0) || (yNum <= 0)) {
    24872574        Tcl_AppendResult(interp, "bad number of x or y values", (char *)NULL);
    2488         goto error;
     2575        return NULL;
    24892576    }
    24902577    if (nValues != (xNum * yNum)) {
    24912578        Tcl_AppendResult(interp, "wrong # of heights", (char *)NULL);
    2492         goto error;
     2579        return NULL;
    24932580    }
    24942581
     
    24982585        Tcl_AppendResult(interp, "can't allocate array of heights",
    24992586                (char *)NULL);
    2500         goto error;
     2587        return NULL;
    25012588    }
    25022589
    25032590    int i;
    25042591    for (i = 0; i < nValues; i++) {
    2505         if (GetFloat(interp, elem[i], heights + i) != TCL_OK) {
     2592        if (GetFloatFromObj(interp, elem[i], heights + i) != TCL_OK) {
    25062593            delete [] heights;
    2507             goto error;
     2594            return NULL;
    25082595        }
    25092596    }
     
    25142601    hMap->setVisible(true);
    25152602    hMap->setLineContourVisible(true);
    2516 
    2517     Tcl_Free((char *)elem);
    25182603    delete [] heights;
    25192604    return hMap;
    2520  error:
    2521     Tcl_Free((char *)elem);
    2522     return NULL;
    25232605}
    25242606
     
    25352617 */
    25362618static int
    2537 UniRect2dCmd(ClientData, Tcl_Interp *interp, int argc, const char *argv[])
     2619UniRect2dCmd(ClientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv)
    25382620{   
    25392621    int xNum, yNum, zNum;
     
    25412623    float *zValues;
    25422624
    2543     if ((argc & 0x01) == 0) {
    2544         Tcl_AppendResult(interp,
     2625    if ((objc & 0x01) == 0) {
     2626        Tcl_AppendResult(interp, Tcl_GetString(objv[0]), ": ",
    25452627                "wrong number of arguments: should be key-value pairs",
    25462628                (char *)NULL);
     
    25512633    xMin = yMin = xMax = yMax = 0.0f;
    25522634    int i;
    2553     for (i = 1; i < argc; i += 2) {
    2554         if (strcmp(argv[i], "xmin") == 0) {
    2555             if (GetFloat(interp, argv[i+1], &xMin) != TCL_OK) {
    2556                 return TCL_ERROR;
    2557             }
    2558         } else if (strcmp(argv[i], "xmax") == 0) {
    2559             if (GetFloat(interp, argv[i+1], &xMax) != TCL_OK) {
    2560                 return TCL_ERROR;
    2561             }
    2562         } else if (strcmp(argv[i], "xnum") == 0) {
    2563             if (Tcl_GetInt(interp, argv[i+1], &xNum) != TCL_OK) {
     2635    for (i = 1; i < objc; i += 2) {
     2636        char *string;
     2637
     2638        string = Tcl_GetString(objv[i]);
     2639        if (strcmp(string, "xmin") == 0) {
     2640            if (GetFloatFromObj(interp, objv[i+1], &xMin) != TCL_OK) {
     2641                return TCL_ERROR;
     2642            }
     2643        } else if (strcmp(string, "xmax") == 0) {
     2644            if (GetFloatFromObj(interp, objv[i+1], &xMax) != TCL_OK) {
     2645                return TCL_ERROR;
     2646            }
     2647        } else if (strcmp(string, "xnum") == 0) {
     2648            if (Tcl_GetIntFromObj(interp, objv[i+1], &xNum) != TCL_OK) {
    25642649                return TCL_ERROR;
    25652650            }
     
    25692654                return TCL_ERROR;
    25702655            }
    2571         } else if (strcmp(argv[i], "ymin") == 0) {
    2572             if (GetFloat(interp, argv[i+1], &yMin) != TCL_OK) {
    2573                 return TCL_ERROR;
    2574             }
    2575         } else if (strcmp(argv[i], "ymax") == 0) {
    2576             if (GetFloat(interp, argv[i+1], &yMax) != TCL_OK) {
    2577                 return TCL_ERROR;
    2578             }
    2579         } else if (strcmp(argv[i], "ynum") == 0) {
    2580             if (Tcl_GetInt(interp, argv[i+1], &yNum) != TCL_OK) {
     2656        } else if (strcmp(string, "ymin") == 0) {
     2657            if (GetFloatFromObj(interp, objv[i+1], &yMin) != TCL_OK) {
     2658                return TCL_ERROR;
     2659            }
     2660        } else if (strcmp(string, "ymax") == 0) {
     2661            if (GetFloatFromObj(interp, objv[i+1], &yMax) != TCL_OK) {
     2662                return TCL_ERROR;
     2663            }
     2664        } else if (strcmp(string, "ynum") == 0) {
     2665            if (Tcl_GetIntFromObj(interp, objv[i+1], &yNum) != TCL_OK) {
    25812666                return TCL_ERROR;
    25822667            }
     
    25862671                return TCL_ERROR;
    25872672            }
    2588         } else if (strcmp(argv[i], "zvalues") == 0) {
    2589             const char **zlist;
    2590 
    2591             if (Tcl_SplitList(interp, argv[i+1], &zNum, &zlist) != TCL_OK) {
     2673        } else if (strcmp(string, "zvalues") == 0) {
     2674            Tcl_Obj **zObj;
     2675
     2676            if (Tcl_ListObjGetElements(interp, objv[i+1], &zNum, &zObj)!= TCL_OK) {
    25922677                return TCL_ERROR;
    25932678            }
     
    25952680            zValues = new float[zNum];
    25962681            for (j = 0; j < zNum; j++) {
    2597                 if (GetFloat(interp, zlist[j], zValues + j) != TCL_OK) {
    2598                     Tcl_Free((char *)zlist);
     2682                if (GetFloatFromObj(interp, zObj[j], zValues + j) != TCL_OK) {
    25992683                    return TCL_ERROR;
    26002684                }
    26012685            }
    2602             Tcl_Free((char *)zlist);
    26032686        } else {
    2604             Tcl_AppendResult(interp, "unknown key \"", argv[i],
     2687            Tcl_AppendResult(interp, "unknown key \"", string,
    26052688                "\": should be xmin, xmax, xnum, ymin, ymax, ynum, or zvalues",
    26062689                (char *)NULL);
  • trunk/vizservers/nanovis/HeightMap.h

    r838 r913  
    104104     *@brief Defind the color of the line contour
    105105     */
    106     void setLineContourColor(float r, float g, float b);
     106    void setLineContourColor(float *rgb);
    107107
    108108    double range_min(void);
     
    125125}
    126126
    127 inline void HeightMap::setLineContourColor(float r, float g, float b)
     127inline void HeightMap::setLineContourColor(float rgb[])
    128128{
    129     _contourColor.x = r;
    130     _contourColor.y = g;
    131     _contourColor.z = b;
     129    _contourColor.x = rgb[0];
     130    _contourColor.y = rgb[1];
     131    _contourColor.z = rgb[2];
    132132}
    133133
  • trunk/vizservers/nanovis/Makefile.in

    r888 r913  
    22#
    33# FIXME: I can see at least 3 possible candidates for separate libraries.
    4 #         R2, mat, and Image. 
     4#         R2, mat, and Image.  (First 2 are done.)
    55#
    66SHELL = /bin/sh
     
    2828AUXSRC = config.h define.h global.h
    2929
    30 RP_DIR =  @RP_DIR@
    31 R2INC = ./R2/include
    32 MATINC = ./newmat11
    33 
    34 DX_DIR  = /usr/lib/dx
    35 DX_INC_SPEC = -I$(DX_DIR)/include
    36 DX_LIB_SPEC = -L$(DX_DIR)/lib_linux -lDXcallm -lm
    37 GL_INC_SPEC = -I/usr/include/GL
    38 GL_LIB_SPEC = -lGL -lglut -lglui -lGLEW -lCg -lCgGL -lpthread
    39 MAT_INC_SPEC = -I$(MATINC)
    40 R2_INC_SPEC = -I$(R2INC)
    41 RP_INC_SPEC = -I$(RP_DIR)/include -I$(RP_DIR)/include/rappture2
    42 RP_LIB_SPEC = -L$(RP_DIR)/lib -lrappture2 -lb64 -lz
     30DX_DIR          = /usr/lib/dx
     31DX_INC_SPEC     = -I$(DX_DIR)/include
     32DX_LIB_SPEC     = -L$(DX_DIR)/lib_linux -lDXcallm -lm
     33GL_INC_SPEC     = -I/usr/include/GL
     34GL_LIB_SPEC     = -lGL -lglut -lglui -lGLEW -lCg -lCgGL -lpthread
     35MAT_DIR         = ./newmat11
     36MAT_INC_SPEC    = -I$(srcdir)/$(MAT_DIR)
     37MAT_LIB         = $(MAT_DIR)/libnewmat11.a
     38MAT_LIB_SPEC    = $(MAT_LIB)
     39R2_DIR          = ./R2
     40R2_INC_SPEC     = -I$(srcdir)/$(R2_DIR)/include
     41R2_LIB          = $(R2_DIR)/src/libR2.a
     42R2_LIB_SPEC     = $(R2_LIB)
     43RP_DIR          =  @RP_DIR@
     44RP_INC_SPEC     = -I$(RP_DIR)/include -I$(RP_DIR)/include/rappture2
     45RP_LIB_SPEC     = -L$(RP_DIR)/lib -lrappture2 -lb64 -lz
    4346
    4447LIBS = \
     
    4649        -ltcl8.4 \
    4750        $(GL_LIB_SPEC) \
    48         $(DX_LIB_SPEC)
     51        $(DX_LIB_SPEC) \
     52        $(R2_LIB_SPEC) \
     53        $(MAT_LIB_SPEC)
    4954
    5055INCLUDES = \
     
    6469        BucketSort.o \
    6570        NvCamera.o \
     71        CmdProc.o \
    6672        Color.o \
    6773        ColorGradient.o \
     
    104110        PointSetRenderer.o \
    105111        PointShader.o \
    106         R2FilePath.o \
    107         R2Fonts.o \
    108         R2Geometry.o \
    109         R2IndexBuffer.o \
    110         R2Object.o \
    111         R2VertexBuffer.o \
    112         R2string.o \
    113112        RenderContext.o \
    114113        RenderVertexArray.o \
     
    130129        VolumeRenderer.o \
    131130        ZincBlendeVolume.o \
    132         bandmat.o \
    133         cholesky.o \
    134131        dxReader.o \
    135132        dxReader2.o \
    136         evalue.o \
    137         fft.o \
    138         hholder.o \
    139         jacobi.o \
    140         myexcept.o \
    141         nanovis.o \
    142         newfft.o \
    143         newmat1.o \
    144         newmat2.o \
    145         newmat3.o \
    146         newmat4.o \
    147         newmat5.o \
    148         newmat6.o \
    149         newmat7.o \
    150         newmat8.o \
    151         newmat9.o \
    152         newmatex.o \
    153         newmatnl.o \
    154         newmatrm.o \
    155         nm_misc.o \
    156         solution.o \
    157         sort.o \
    158         submat.o \
    159         svd.o
     133        nanovis.o
     134
    160135
    161136all: nanovis
     
    172147
    173148clean:
     149        make -C $(MAT_DIR) clean
    174150        rm -f nanovis client $(OBJS)
    175151
     
    177153        rm -f Makefile *~
    178154
    179 nanovis: $(OBJS)
     155$(MAT_LIB):
     156        make -C $(MAT_DIR) all
     157
     158$(R2_LIB):
     159        make -C $(R2_DIR)/src all
     160
     161nanovis: $(MAT_LIB) $(R2_LIB) $(OBJS)
    180162        $(CC) $(CC_SWITCHES) -o $@ $^ $(LIBS)
    181163
     
    208190        $(CC) $(CC_SWITCHES) -o $@ -c $<
    209191RenderClient.o: socket/RenderClient.cpp socket/RenderClient.h
    210         $(CC) $(CC_SWITCHES) -o $@ -c $<
    211 R2string.o: R2/src/R2string.cpp $(R2INC)/R2/R2string.h
    212         $(CC) $(CC_SWITCHES) -o $@ -c $<
    213 R2FilePath.o: R2/src/R2FilePath.cpp $(R2INC)/R2/R2FilePath.h
    214         $(CC) $(CC_SWITCHES) -o $@ -c $<
    215 R2Fonts.o: R2/src/R2Fonts.cpp $(R2INC)/R2/R2Fonts.h
    216         $(CC) $(CC_SWITCHES) -o $@ -c $<
    217 R2Object.o: R2/src/R2Object.cpp $(R2INC)/R2/R2Object.h
    218         $(CC) $(CC_SWITCHES) -o $@ -c $<
    219 R2Geometry.o: R2/src/R2Geometry.cpp $(R2INC)/R2/graphics/R2Geometry.h
    220         $(CC) $(CC_SWITCHES) -o $@ -c $<
    221 R2VertexBuffer.o: R2/src/R2VertexBuffer.cpp $(R2INC)/R2/graphics/R2VertexBuffer.h
    222         $(CC) $(CC_SWITCHES) -o $@ -c $<
    223 R2IndexBuffer.o: R2/src/R2IndexBuffer.cpp $(R2INC)/R2/graphics/R2IndexBuffer.h
    224192        $(CC) $(CC_SWITCHES) -o $@ -c $<
    225193
     
    266234PointSetRenderer.o: PointSetRenderer.cpp PointSetRenderer.h
    267235PointSet.o: PointSet.cpp PointSet.h
    268 bandmat.o: newmat11/bandmat.cpp
    269         $(CC) $(CC_SWITCHES) -o $@ -c $<
    270 cholesky.o: newmat11/cholesky.cpp
    271         $(CC) $(CC_SWITCHES) -o $@ -c $<
    272 evalue.o: newmat11/evalue.cpp
    273         $(CC) $(CC_SWITCHES) -o $@ -c $<
    274 fft.o: newmat11/fft.cpp
    275         $(CC) $(CC_SWITCHES) -o $@ -c $<
    276 hholder.o: newmat11/hholder.cpp
    277         $(CC) $(CC_SWITCHES) -o $@ -c $<
    278 jacobi.o: newmat11/jacobi.cpp
    279         $(CC) $(CC_SWITCHES) -o $@ -c $<
    280 myexcept.o: newmat11/myexcept.cpp
    281         $(CC) $(CC_SWITCHES) -o $@ -c $<
    282 newfft.o: newmat11/newfft.cpp
    283         $(CC) $(CC_SWITCHES) -o $@ -c $<
    284 newmat1.o: newmat11/newmat1.cpp
    285         $(CC) $(CC_SWITCHES) -o $@ -c $<
    286 newmat2.o: newmat11/newmat2.cpp
    287         $(CC) $(CC_SWITCHES) -o $@ -c $<
    288 newmat3.o: newmat11/newmat3.cpp
    289         $(CC) $(CC_SWITCHES) -o $@ -c $<
    290 newmat4.o: newmat11/newmat4.cpp
    291         $(CC) $(CC_SWITCHES) -o $@ -c $<
    292 newmat5.o: newmat11/newmat5.cpp
    293         $(CC) $(CC_SWITCHES) -o $@ -c $<
    294 newmat6.o: newmat11/newmat6.cpp
    295         $(CC) $(CC_SWITCHES) -o $@ -c $<
    296 newmat7.o: newmat11/newmat7.cpp
    297         $(CC) $(CC_SWITCHES) -o $@ -c $<
    298 newmat8.o: newmat11/newmat8.cpp
    299         $(CC) $(CC_SWITCHES) -o $@ -c $<
    300 newmat9.o: newmat11/newmat9.cpp
    301         $(CC) $(CC_SWITCHES) -o $@ -c $<
    302 newmatex.o: newmat11/newmatex.cpp
    303         $(CC) $(CC_SWITCHES) -o $@ -c $<
    304 newmatnl.o: newmat11/newmatnl.cpp
    305         $(CC) $(CC_SWITCHES) -o $@ -c $<
    306 newmatrm.o: newmat11/newmatrm.cpp
    307         $(CC) $(CC_SWITCHES) -o $@ -c $<
    308 nm_misc.o: newmat11/nm_misc.cpp
    309         $(CC) $(CC_SWITCHES) -o $@ -c $<
    310 solution.o: newmat11/solution.cpp
    311         $(CC) $(CC_SWITCHES) -o $@ -c $<
    312 sort.o: newmat11/sort.cpp
    313         $(CC) $(CC_SWITCHES) -o $@ -c $<
    314 svd.o: newmat11/svd.cpp
    315         $(CC) $(CC_SWITCHES) -o $@ -c $<
    316 submat.o: newmat11/submat.cpp
    317         $(CC) $(CC_SWITCHES) -o $@ -c $<
    318 
    319236Image.o: imgLoaders/Image.cpp
    320237        $(CC) $(CC_SWITCHES) -o $@ -c $<
Note: See TracChangeset for help on using the changeset viewer.