Changeset 1850 for trunk/packages


Ignore:
Timestamp:
Jul 30, 2010 8:34:57 AM (14 years ago)
Author:
dkearney
Message:

adding perl wrapper example to configure and make scripts

Location:
trunk/packages/vizservers/nanovis
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/nanovis/FlowCmd.cpp

    r1571 r1850  
    5555Rappture::SwitchSpec FlowCmd::_switches[] = {
    5656    {Rappture::SWITCH_BOOLEAN, "-arrows", "boolean",
    57         offsetof(FlowValues, showArrows), 0},
     57        offsetof(FlowValues, showArrows), 0},
    5858    {Rappture::SWITCH_CUSTOM, "-axis", "axis",
    59         offsetof(FlowValues, slicePos.axis), 0, 0, &axisSwitch},
     59        offsetof(FlowValues, slicePos.axis), 0, 0, &axisSwitch},
    6060    {Rappture::SWITCH_FLOAT, "-diffuse", "value",
    61         offsetof(FlowValues, diffuse), 0},
     61        offsetof(FlowValues, diffuse), 0},
    6262    {Rappture::SWITCH_BOOLEAN, "-hide", "boolean",
    63         offsetof(FlowValues, isHidden), 0},
     63        offsetof(FlowValues, isHidden), 0},
    6464    {Rappture::SWITCH_FLOAT, "-opacity", "value",
    65         offsetof(FlowValues, opacity), 0},
     65        offsetof(FlowValues, opacity), 0},
    6666    {Rappture::SWITCH_BOOLEAN, "-outline", "boolean",
    67         offsetof(FlowValues, showOutline), 0},
     67        offsetof(FlowValues, showOutline), 0},
    6868    {Rappture::SWITCH_CUSTOM, "-position", "number",
    69         offsetof(FlowValues, slicePos), 0, 0, &positionSwitch},
     69        offsetof(FlowValues, slicePos), 0, 0, &positionSwitch},
    7070    {Rappture::SWITCH_BOOLEAN, "-slice", "boolean",
    71         offsetof(FlowValues, sliceVisible), 0},
     71        offsetof(FlowValues, sliceVisible), 0},
    7272    {Rappture::SWITCH_FLOAT, "-specular", "value",
    73         offsetof(FlowValues, specular), 0},
     73        offsetof(FlowValues, specular), 0},
    7474    {Rappture::SWITCH_CUSTOM, "-transferfunction", "name",
    7575        offsetof(FlowValues, tfPtr), 0, 0, &transferFunctionSwitch},
    7676    {Rappture::SWITCH_BOOLEAN, "-volume", "boolean",
    77         offsetof(FlowValues, showVolume), 0},
     77        offsetof(FlowValues, showVolume), 0},
    7878    {Rappture::SWITCH_END}
    7979};
     
    8787        offsetof(FlowParticlesValues, isHidden), 0},
    8888    {Rappture::SWITCH_CUSTOM, "-position", "number",
    89         offsetof(FlowParticlesValues, position), 0, 0, &positionSwitch},
     89        offsetof(FlowParticlesValues, position), 0, 0, &positionSwitch},
    9090    {Rappture::SWITCH_FLOAT, "-size", "float",
    9191        offsetof(FlowParticlesValues, particleSize), 0},
     
    118118    _hashPtr = hPtr;
    119119    _sv.isHidden = false;
    120     _sv.position.axis = 0;              /* X_AXIS */
    121     _sv.position.value = 0.0f; 
     120    _sv.position.axis = 0;                /* X_AXIS */
     121    _sv.position.value = 0.0f;       
    122122    _sv.position.flags = RELPOS;
    123123    _sv.color.r = _sv.color.b = _sv.color.g = _sv.color.a = 1.0f;
    124124    _rendererPtr = new NvParticleRenderer(NMESH, NMESH,
    125                 /* Global nVidia Cg context */g_context);
     125                /* Global nVidia Cg context */g_context);
    126126}
    127127
     
    129129{
    130130    if (_rendererPtr != NULL) {
    131         delete _rendererPtr;
     131        delete _rendererPtr;
    132132    }
    133133    if (_hashPtr != NULL) {
    134         Tcl_DeleteHashEntry(_hashPtr);
     134        Tcl_DeleteHashEntry(_hashPtr);
    135135    }
    136136    Rappture::FreeSwitches(_switches, &_sv, 0);
     
    144144    Trace("rendering particles %s position=%g\n", _name, _sv.position.value);
    145145    Trace("rendering particles %s position=%g\n", _name,
    146           FlowCmd::GetRelativePosition(&_sv.position));
     146          FlowCmd::GetRelativePosition(&_sv.position));
    147147
    148148    _rendererPtr->setPos(FlowCmd::GetRelativePosition(&_sv.position));
     
    157157    _rendererPtr->setPos(FlowCmd::GetRelativePosition(&_sv.position));
    158158    _rendererPtr->setColor(Vector4(_sv.color.r, _sv.color.g, _sv.color.b,
    159                 _sv.color.a));
     159                _sv.color.a));
    160160    _rendererPtr->particleSize(_sv.particleSize);
    161161    _rendererPtr->setAxis(_sv.position.axis);
     
    168168    _hashPtr = hPtr;
    169169    _sv.isHidden = false;
    170     _sv.corner1.x = 0.0f;       
    171     _sv.corner1.y = 0.0f;       
    172     _sv.corner1.z = 0.0f;       
    173     _sv.corner2.x = 1.0f;       
    174     _sv.corner2.y = 1.0f;       
    175     _sv.corner2.z = 1.0f;       
     170    _sv.corner1.x = 0.0f;       
     171    _sv.corner1.y = 0.0f;       
     172    _sv.corner1.z = 0.0f;       
     173    _sv.corner2.x = 1.0f;       
     174    _sv.corner2.y = 1.0f;       
     175    _sv.corner2.z = 1.0f;       
    176176    _sv.lineWidth = 1.2f;
    177177    _sv.color.r = _sv.color.b = _sv.color.g = _sv.color.a = 1.0f;
     
    199199    sy = volPtr->height / (double)volPtr->width;
    200200    if (volPtr->depth > 0.0) {
    201         sz = volPtr->depth  / (double)volPtr->width;
     201        sz = volPtr->depth  / (double)volPtr->width;
    202202    }
    203203    glScaled(sx, sy, sz);
     
    209209
    210210    Trace("box is %g,%g %g,%g %g,%g\n",
    211           _sv.corner1.x, _sv.corner2.x,
    212           _sv.corner1.y, _sv.corner2.y,
    213           _sv.corner1.z, _sv.corner2.z);
     211          _sv.corner1.x, _sv.corner2.x,
     212          _sv.corner1.y, _sv.corner2.y,
     213          _sv.corner1.z, _sv.corner2.z);
    214214    Trace("world is %g,%g %g,%g %g,%g\n",
    215           min.x, max.x, min.y, max.y, min.z, max.z);
     215          min.x, max.x, min.y, max.y, min.z, max.z);
    216216
    217217    float x0, y0, z0, x1, y1, z1;
     
    219219    x1 = y1 = z1 = 0.0f;
    220220    if (max.y  > min.y) {
    221         y0 = (_sv.corner1.y - min.y) / (max.y - min.y);
    222         y1 = (_sv.corner2.y - min.y) / (max.y - min.y);
     221        y0 = (_sv.corner1.y - min.y) / (max.y - min.y);
     222        y1 = (_sv.corner2.y - min.y) / (max.y - min.y);
    223223    }
    224224    if (max.z > min.z) {
    225         z0 = (_sv.corner1.z - min.z) / (max.z - min.z);
    226         z1 = (_sv.corner2.z - min.z) / (max.z - min.z);
     225        z0 = (_sv.corner1.z - min.z) / (max.z - min.z);
     226        z1 = (_sv.corner2.z - min.z) / (max.z - min.z);
    227227    }
    228228    if (max.x > min.x) {
    229         x0 = (_sv.corner1.x - min.x) / (max.x - min.x);
    230         x1 = (_sv.corner2.x - min.x) / (max.x - min.x);
     229        x0 = (_sv.corner1.x - min.x) / (max.x - min.x);
     230        x1 = (_sv.corner2.x - min.x) / (max.x - min.x);
    231231    }
    232232    Trace("rendering box %g,%g %g,%g %g,%g\n", x0, x1, y0, y1, z0, z1);
     
    235235    glBegin(GL_LINE_LOOP);
    236236    {
    237         glVertex3d(x0, y0, z0);
    238         glVertex3d(x1, y0, z0);
    239         glVertex3d(x1, y1, z0);
    240         glVertex3d(x0, y1, z0);
     237        glVertex3d(x0, y0, z0);
     238        glVertex3d(x1, y0, z0);
     239        glVertex3d(x1, y1, z0);
     240        glVertex3d(x0, y1, z0);
    241241    }
    242242    glEnd();
    243243    glBegin(GL_LINE_LOOP);
    244244    {
    245         glVertex3d(x0, y0, z1);
    246         glVertex3d(x1, y0, z1);
    247         glVertex3d(x1, y1, z1);
    248         glVertex3d(x0, y1, z1);
     245        glVertex3d(x0, y0, z1);
     246        glVertex3d(x1, y0, z1);
     247        glVertex3d(x1, y1, z1);
     248        glVertex3d(x0, y1, z1);
    249249    }
    250250    glEnd();
     
    252252    glBegin(GL_LINE_LOOP);
    253253    {
    254         glVertex3d(x0, y0, z0);
    255         glVertex3d(x0, y0, z1);
    256         glVertex3d(x0, y1, z1);
    257         glVertex3d(x0, y1, z0);
     254        glVertex3d(x0, y0, z0);
     255        glVertex3d(x0, y0, z1);
     256        glVertex3d(x0, y1, z1);
     257        glVertex3d(x0, y1, z0);
    258258    }
    259259    glEnd();
     
    261261    glBegin(GL_LINE_LOOP);
    262262    {
    263         glVertex3d(x1, y0, z0);
    264         glVertex3d(x1, y0, z1);
    265         glVertex3d(x1, y1, z1);
    266         glVertex3d(x1, y1, z0);
     263        glVertex3d(x1, y0, z0);
     264        glVertex3d(x1, y0, z1);
     265        glVertex3d(x1, y1, z1);
     266        glVertex3d(x1, y1, z0);
    267267    }
    268268    glEnd();
     
    290290    _volPtr = NULL;
    291291    _cmdToken = Tcl_CreateObjCommand(interp, (char *)_name,
    292         (Tcl_ObjCmdProc *)FlowInstObjCmd, this, FlowInstDeleteProc);
     292        (Tcl_ObjCmdProc *)FlowInstObjCmd, this, FlowInstDeleteProc);
    293293    Tcl_InitHashTable(&_particlesTable, TCL_STRING_KEYS);
    294294    Tcl_InitHashTable(&_boxTable, TCL_STRING_KEYS);
     
    299299    Rappture::FreeSwitches(_switches, &_sv, 0);
    300300    if (_hashPtr != NULL) {
    301         Tcl_DeleteHashEntry(_hashPtr);
     301        Tcl_DeleteHashEntry(_hashPtr);
    302302    }
    303303    if (_fieldPtr != NULL) {
    304         delete _fieldPtr;
     304        delete _fieldPtr;
    305305    }
    306306    if (_dataPtr != NULL) {
    307         delete _dataPtr;
     307        delete _dataPtr;
    308308    }
    309309     if (_volPtr != NULL) {
    310         NanoVis::remove_volume(_volPtr);
    311         _volPtr = NULL;
     310        NanoVis::remove_volume(_volPtr);
     311        _volPtr = NULL;
    312312    }
    313313
     
    315315    FlowBoxIterator boxIter;
    316316    for (boxPtr = FirstBox(&boxIter); boxPtr != NULL;
    317         boxPtr = NextBox(&boxIter)) {
    318         boxPtr->disconnect();
    319         delete boxPtr;
    320     }   
     317        boxPtr = NextBox(&boxIter)) {
     318        boxPtr->disconnect();
     319        delete boxPtr;
     320    }       
    321321    FlowParticles *particlesPtr;
    322322    FlowParticlesIterator partIter;
    323323    for (particlesPtr = FirstParticles(&partIter); particlesPtr != NULL;
    324         particlesPtr = NextParticles(&partIter)) {
    325         particlesPtr->disconnect();
    326         delete particlesPtr;
    327     }   
     324        particlesPtr = NextParticles(&partIter)) {
     325        particlesPtr->disconnect();
     326        delete particlesPtr;
     327    }       
    328328    Tcl_DeleteHashTable(&_particlesTable);
    329329    Tcl_DeleteHashTable(&_boxTable);
     
    336336    FlowParticles *particlesPtr;
    337337    for (particlesPtr = FirstParticles(&iter); particlesPtr != NULL;
    338         particlesPtr = NextParticles(&iter)) {
    339         particlesPtr->Reset();
     338        particlesPtr = NextParticles(&iter)) {
     339        particlesPtr->Reset();
    340340    }
    341341}
     
    350350    FlowParticles *particlesPtr;
    351351    for (particlesPtr = FirstParticles(&iter); particlesPtr != NULL;
    352         particlesPtr = NextParticles(&iter)) {
    353         if (particlesPtr->visible()) {
    354             particlesPtr->Advect();
    355         }
     352        particlesPtr = NextParticles(&iter)) {
     353        if (particlesPtr->visible()) {
     354            particlesPtr->Advect();
     355        }
    356356    }
    357357}
     
    365365    FlowParticles *particlesPtr;
    366366    for (particlesPtr = FirstParticles(&iter); particlesPtr != NULL;
    367         particlesPtr = NextParticles(&iter)) {
    368         if (particlesPtr->visible()) {
    369             particlesPtr->Render();
    370         }
     367        particlesPtr = NextParticles(&iter)) {
     368        if (particlesPtr->visible()) {
     369            particlesPtr->Render();
     370        }
    371371    }
    372372    Trace("in Render before boxes %s\n", _name);
     
    382382    hPtr = Tcl_CreateHashEntry(&_particlesTable, particlesName, &isNew);
    383383    if (!isNew) {
    384         Tcl_AppendResult(interp, "particle injection plane \"",
    385                         particlesName, "\" already exists.", (char *)NULL);
    386         return TCL_ERROR;
     384        Tcl_AppendResult(interp, "particle injection plane \"",
     385                        particlesName, "\" already exists.", (char *)NULL);
     386        return TCL_ERROR;
    387387    }
    388388    particlesName = Tcl_GetHashKey(&_particlesTable, hPtr);
     
    390390    particlesPtr = new FlowParticles(particlesName, hPtr);
    391391    if (particlesPtr == NULL) {
    392         Tcl_AppendResult(interp, "can't allocate particle injection plane",
    393                 (char *)NULL);
    394         Tcl_DeleteHashEntry(hPtr);
    395         return TCL_ERROR;
     392        Tcl_AppendResult(interp, "can't allocate particle injection plane",
     393                (char *)NULL);
     394        Tcl_DeleteHashEntry(hPtr);
     395        return TCL_ERROR;
    396396    }
    397397    Tcl_SetHashValue(hPtr, particlesPtr);
     
    401401int
    402402FlowCmd::GetParticles(Tcl_Interp *interp, Tcl_Obj *objPtr,
    403                       FlowParticles **particlesPtrPtr)
     403                      FlowParticles **particlesPtrPtr)
    404404{
    405405    Tcl_HashEntry *hPtr;
    406406    hPtr = Tcl_FindHashEntry(&_particlesTable, Tcl_GetString(objPtr));
    407407    if (hPtr == NULL) {
    408         if (interp != NULL) {
    409             Tcl_AppendResult(interp, "can't find a particle injection plane \"",
    410                         Tcl_GetString(objPtr), "\"", (char *)NULL);
    411         }
    412         return TCL_ERROR;
     408        if (interp != NULL) {
     409            Tcl_AppendResult(interp, "can't find a particle injection plane \"",
     410                        Tcl_GetString(objPtr), "\"", (char *)NULL);
     411        }
     412        return TCL_ERROR;
    413413    }
    414414    *particlesPtrPtr = (FlowParticles *)Tcl_GetHashValue(hPtr);
     
    420420{
    421421    iterPtr->hashPtr = Tcl_FirstHashEntry(&_particlesTable,
    422         &iterPtr->hashSearch);
     422        &iterPtr->hashSearch);
    423423    if (iterPtr->hashPtr == NULL) {
    424         return NULL;
     424        return NULL;
    425425    }
    426426    return (FlowParticles *)Tcl_GetHashValue(iterPtr->hashPtr);
     
    431431{
    432432    if (iterPtr->hashPtr == NULL) {
    433         return NULL;
     433        return NULL;
    434434    }
    435435    iterPtr->hashPtr = Tcl_NextHashEntry(&iterPtr->hashSearch);
    436436    if (iterPtr->hashPtr == NULL) {
    437         return NULL;
     437        return NULL;
    438438    }
    439439    return (FlowParticles *)Tcl_GetHashValue(iterPtr->hashPtr);
     
    447447    hPtr = Tcl_CreateHashEntry(&_boxTable, Tcl_GetString(objPtr), &isNew);
    448448    if (!isNew) {
    449         Tcl_AppendResult(interp, "box \"", Tcl_GetString(objPtr),
    450                 "\" already exists in flow \"", name(), "\"", (char *)NULL);
    451         return TCL_ERROR;
     449        Tcl_AppendResult(interp, "box \"", Tcl_GetString(objPtr),
     450                "\" already exists in flow \"", name(), "\"", (char *)NULL);
     451        return TCL_ERROR;
    452452    }
    453453    const char *boxName;
     
    456456    boxPtr = new FlowBox(boxName, hPtr);
    457457    if (boxPtr == NULL) {
    458         Tcl_AppendResult(interp, "can't allocate box \"", boxName, "\"",
    459                         (char *)NULL);
    460         Tcl_DeleteHashEntry(hPtr);
    461         return TCL_ERROR;
     458        Tcl_AppendResult(interp, "can't allocate box \"", boxName, "\"",
     459                        (char *)NULL);
     460        Tcl_DeleteHashEntry(hPtr);
     461        return TCL_ERROR;
    462462    }
    463463    Tcl_SetHashValue(hPtr, boxPtr);
     
    471471    hPtr = Tcl_FindHashEntry(&_boxTable, Tcl_GetString(objPtr));
    472472    if (hPtr == NULL) {
    473         if (interp != NULL) {
    474             Tcl_AppendResult(interp, "can't find a box \"",
    475                 Tcl_GetString(objPtr), "\" in flow \"", name(), "\"",
    476                 (char *)NULL);
    477         }
    478         return TCL_ERROR;
     473        if (interp != NULL) {
     474            Tcl_AppendResult(interp, "can't find a box \"",
     475                Tcl_GetString(objPtr), "\" in flow \"", name(), "\"",
     476                (char *)NULL);
     477        }
     478        return TCL_ERROR;
    479479    }
    480480    *boxPtrPtr = (FlowBox *)Tcl_GetHashValue(hPtr);
     
    487487    iterPtr->hashPtr = Tcl_FirstHashEntry(&_boxTable, &iterPtr->hashSearch);
    488488    if (iterPtr->hashPtr == NULL) {
    489         return NULL;
     489        return NULL;
    490490    }
    491491    return (FlowBox *)Tcl_GetHashValue(iterPtr->hashPtr);
     
    496496{
    497497    if (iterPtr->hashPtr == NULL) {
    498         return NULL;
     498        return NULL;
    499499    }
    500500    iterPtr->hashPtr = Tcl_NextHashEntry(&iterPtr->hashSearch);
    501501    if (iterPtr->hashPtr == NULL) {
    502         return NULL;
     502        return NULL;
    503503    }
    504504    return (FlowBox *)Tcl_GetHashValue(iterPtr->hashPtr);
     
    512512    FlowParticlesIterator iter;
    513513    for (particlesPtr = FirstParticles(&iter); particlesPtr != NULL;
    514         particlesPtr = NextParticles(&iter)) {
    515         particlesPtr->Initialize();
    516     }   
     514        particlesPtr = NextParticles(&iter)) {
     515        particlesPtr->Initialize();
     516    }       
    517517}
    518518
     
    521521{
    522522    if (_volPtr != NULL) {
    523         fprintf(stderr, "from ScaleVectorField volId=%s\n", _volPtr->name());
    524         NanoVis::remove_volume(_volPtr);
    525         _volPtr = NULL;
     523        fprintf(stderr, "from ScaleVectorField volId=%s\n", _volPtr->name());
     524        NanoVis::remove_volume(_volPtr);
     525        _volPtr = NULL;
    526526    }
    527527    float *vdata;
    528528    vdata = GetScaledVector();
    529529    if (vdata == NULL) {
    530         return false;
     530        return false;
    531531    }
    532532    Volume *volPtr;
     
    534534    delete [] vdata;
    535535    if (volPtr == NULL) {
    536         return false;
     536        return false;
    537537    }
    538538    _volPtr = volPtr;
     
    540540    // Remove the associated vector field.
    541541    if (_fieldPtr != NULL) {
    542         delete _fieldPtr;
     542        delete _fieldPtr;
    543543    }
    544544    _fieldPtr = new NvVectorField();
    545545    if (_fieldPtr == NULL) {
    546         return false;
     546        return false;
    547547    }
    548548
     
    559559
    560560    _fieldPtr->setVectorField(_volPtr, loc,
    561         1.0f, height / width, depth  / width, NanoVis::magMax);
     561        1.0f, height / width, depth  / width, NanoVis::magMax);
    562562
    563563    if (NanoVis::licRenderer != NULL) {
    564564        NanoVis::licRenderer->setVectorField(_volPtr->id, loc,
    565                 1.0f / _volPtr->aspect_ratio_width,
    566                 1.0f / _volPtr->aspect_ratio_height,
    567                 1.0f / _volPtr->aspect_ratio_depth,
    568                 _volPtr->wAxis.max());
    569         SetCurrentPosition();
    570         SetAxis();
    571         SetActive();
     565                1.0f / _volPtr->aspect_ratio_width,
     566                1.0f / _volPtr->aspect_ratio_height,
     567                1.0f / _volPtr->aspect_ratio_depth,
     568                _volPtr->wAxis.max());
     569        SetCurrentPosition();
     570        SetAxis();
     571        SetActive();
    572572    }
    573573
     
    576576            //*(volPtr->get_location()),
    577577            1.0f,
    578             _volPtr->aspect_ratio_height / _volPtr->aspect_ratio_width,
    579             _volPtr->aspect_ratio_depth / _volPtr->aspect_ratio_width
     578            _volPtr->aspect_ratio_height / _volPtr->aspect_ratio_width,
     579            _volPtr->aspect_ratio_depth / _volPtr->aspect_ratio_width
    580580            //,volPtr->wAxis.max()
    581581            );
    582         Trace("Arrows enabled set to %d\n", _sv.showArrows);
    583         NanoVis::velocityArrowsSlice->axis(_sv.slicePos.axis);
    584         NanoVis::velocityArrowsSlice->slicePos(_sv.slicePos.value);
    585         NanoVis::velocityArrowsSlice->enabled(_sv.showArrows);
     582        Trace("Arrows enabled set to %d\n", _sv.showArrows);
     583        NanoVis::velocityArrowsSlice->axis(_sv.slicePos.axis);
     584        NanoVis::velocityArrowsSlice->slicePos(_sv.slicePos.value);
     585        NanoVis::velocityArrowsSlice->enabled(_sv.showArrows);
    586586    }
    587587    FlowParticles *particlesPtr;
    588588    FlowParticlesIterator partIter;
    589589    for (particlesPtr = FirstParticles(&partIter); particlesPtr != NULL;
    590         particlesPtr = NextParticles(&partIter)) {
    591         particlesPtr->SetVectorField(_volPtr);
    592     }   
     590        particlesPtr = NextParticles(&partIter)) {
     591        particlesPtr->SetVectorField(_volPtr);
     592    }       
    593593    return true;
    594594}
     
    600600    FlowBox *boxPtr;
    601601    for (boxPtr = FirstBox(&iter); boxPtr != NULL; boxPtr = NextBox(&iter)) {
    602         Trace("found box %s\n", boxPtr->name());
    603         if (boxPtr->visible()) {
    604             boxPtr->Render(_volPtr);
    605         }
     602        Trace("found box %s\n", boxPtr->name());
     603        if (boxPtr->visible()) {
     604            boxPtr->Render(_volPtr);
     605        }
    606606    }
    607607}
     
    614614    float *data = new float[n];
    615615    if (data == NULL) {
    616         return NULL;
     616        return NULL;
    617617    }
    618618    memset(data, 0, sizeof(float) * n);
     
    620620    const float *values = _dataPtr->values();
    621621    for (size_t iz=0; iz < _dataPtr->zNum(); iz++) {
    622         for (size_t iy=0; iy < _dataPtr->yNum(); iy++) {
    623             for (size_t ix=0; ix < _dataPtr->xNum(); ix++) {
    624                 double vx, vy, vz, vm;
    625                 vx = values[0];
    626                 vy = values[1];
    627                 vz = values[2];
    628                 vm = sqrt(vx*vx + vy*vy + vz*vz);
    629                 destPtr[0] = vm / NanoVis::magMax;
    630                 destPtr[1] = vx /(2.0*NanoVis::magMax) + 0.5;
    631                 destPtr[2] = vy /(2.0*NanoVis::magMax) + 0.5;
    632                 destPtr[3] = vz /(2.0*NanoVis::magMax) + 0.5;
    633                 values += 3;
    634                 destPtr += 4;
    635             }
    636         }
     622        for (size_t iy=0; iy < _dataPtr->yNum(); iy++) {
     623            for (size_t ix=0; ix < _dataPtr->xNum(); ix++) {
     624                double vx, vy, vz, vm;
     625                vx = values[0];
     626                vy = values[1];
     627                vz = values[2];
     628                vm = sqrt(vx*vx + vy*vy + vz*vz);
     629                destPtr[0] = vm / NanoVis::magMax;
     630                destPtr[1] = vx /(2.0*NanoVis::magMax) + 0.5;
     631                destPtr[2] = vy /(2.0*NanoVis::magMax) + 0.5;
     632                destPtr[3] = vz /(2.0*NanoVis::magMax) + 0.5;
     633                values += 3;
     634                destPtr += 4;
     635            }
     636        }
    637637    }
    638638    return data;
     
    645645
    646646    volPtr = NanoVis::load_volume(_name, _dataPtr->xNum(), _dataPtr->yNum(),
    647                                   _dataPtr->zNum(), 4, data,
    648                                   NanoVis::magMin, NanoVis::magMax, 0);
     647                                  _dataPtr->zNum(), 4, data,
     648                                  NanoVis::magMin, NanoVis::magMax, 0);
    649649    volPtr->xAxis.SetRange(_dataPtr->xMin(), _dataPtr->xMax());
    650650    volPtr->yAxis.SetRange(_dataPtr->yMin(), _dataPtr->yMax());
     
    655655    Vector3 physicalMax(NanoVis::xMax, NanoVis::yMax, NanoVis::zMax);
    656656    Trace("min=%g %g %g max=%g %g %g mag=%g %g\n",
    657             NanoVis::xMin, NanoVis::yMin, NanoVis::zMin,
    658             NanoVis::xMax, NanoVis::yMax, NanoVis::zMax,
    659             NanoVis::magMin, NanoVis::magMax);
     657            NanoVis::xMin, NanoVis::yMin, NanoVis::zMin,
     658            NanoVis::xMax, NanoVis::yMax, NanoVis::zMax,
     659            NanoVis::magMin, NanoVis::magMax);
    660660    volPtr->setPhysicalBBox(physicalMin, physicalMax);
    661661    //volPtr->set_n_slice(256 - _volIndex);
     
    689689static int
    690690FlowDataFileOp(ClientData clientData, Tcl_Interp *interp, int objc,
    691                Tcl_Obj *const *objv)
     691               Tcl_Obj *const *objv)
    692692{
    693693    Rappture::Outcome result;
     
    702702    }
    703703    if ((nComponents < 1) || (nComponents > 4)) {
    704         Tcl_AppendResult(interp, "bad # of components \"",
    705                         Tcl_GetString(objv[4]), "\"", (char *)NULL);
    706         return TCL_ERROR;
     704        Tcl_AppendResult(interp, "bad # of components \"",
     705                        Tcl_GetString(objv[4]), "\"", (char *)NULL);
     706        return TCL_ERROR;
    707707    }
    708708    Rappture::Buffer buf;
    709709    if (!buf.load(result, fileName)) {
    710         Tcl_AppendResult(interp, "can't load data from \"", fileName, "\": ",
    711                         result.remark(), (char *)NULL);
    712         return TCL_ERROR;
     710        Tcl_AppendResult(interp, "can't load data from \"", fileName, "\": ",
     711                        result.remark(), (char *)NULL);
     712        return TCL_ERROR;
    713713    }
    714714
     
    719719    char *bytes = (char *)buf.bytes();
    720720    if ((length > 4) && (strncmp(bytes, "<DX>", 4) == 0)) {
    721         if (!dataPtr->ImportDx(result, nComponents, length-4, bytes+4)) {
    722             Tcl_AppendResult(interp, result.remark(), (char *)NULL);
    723             delete dataPtr;
    724             return TCL_ERROR;
    725         }
     721        if (!dataPtr->ImportDx(result, nComponents, length-4, bytes+4)) {
     722            Tcl_AppendResult(interp, result.remark(), (char *)NULL);
     723            delete dataPtr;
     724            return TCL_ERROR;
     725        }
    726726    } else if ((length > 10) && (strncmp(bytes, "unirect3d ", 10) == 0)) {
    727         if (dataPtr->ParseBuffer(interp, buf) != TCL_OK) {
    728             delete dataPtr;
    729             return TCL_ERROR;
    730         }
     727        if (dataPtr->ParseBuffer(interp, buf) != TCL_OK) {
     728            delete dataPtr;
     729            return TCL_ERROR;
     730        }
    731731    } else if ((length > 10) && (strncmp(bytes, "unirect2d ", 10) == 0)) {
    732         Rappture::Unirect2d *u2dPtr;
    733         u2dPtr = new Rappture::Unirect2d(nComponents);
    734         if (u2dPtr->ParseBuffer(interp, buf) != TCL_OK) {
    735             delete u2dPtr;
    736             return TCL_ERROR;
    737         }
    738         dataPtr->Convert(u2dPtr);
    739         delete u2dPtr;
     732        Rappture::Unirect2d *u2dPtr;
     733        u2dPtr = new Rappture::Unirect2d(nComponents);
     734        if (u2dPtr->ParseBuffer(interp, buf) != TCL_OK) {
     735            delete u2dPtr;
     736            return TCL_ERROR;
     737        }
     738        dataPtr->Convert(u2dPtr);
     739        delete u2dPtr;
    740740    } else {
    741         fprintf(stderr, "header is %.14s\n", buf.bytes());
    742         if (!dataPtr->ImportDx(result, nComponents, length, bytes)) {
    743             Tcl_AppendResult(interp, result.remark(), (char *)NULL);
    744             delete dataPtr;
    745             return TCL_ERROR;
    746         }
     741        fprintf(stderr, "header is %.14s\n", buf.bytes());
     742        if (!dataPtr->ImportDx(result, nComponents, length, bytes)) {
     743            Tcl_AppendResult(interp, result.remark(), (char *)NULL);
     744            delete dataPtr;
     745            return TCL_ERROR;
     746        }
    747747    }
    748748    if (dataPtr->nValues() == 0) {
    749         delete dataPtr;
    750         Tcl_AppendResult(interp, "no data found in \"", fileName, "\"",
    751                         (char *)NULL);
    752         return TCL_ERROR;
     749        delete dataPtr;
     750        Tcl_AppendResult(interp, "no data found in \"", fileName, "\"",
     751                        (char *)NULL);
     752        return TCL_ERROR;
    753753    }
    754754    flowPtr->data(dataPtr);
     
    770770    int nBytes;
    771771    if (Tcl_GetIntFromObj(interp, objv[3], &nBytes) != TCL_OK) {
    772         Trace("Bad nBytes \"%s\"\n", Tcl_GetString(objv[3]));
     772        Trace("Bad nBytes \"%s\"\n", Tcl_GetString(objv[3]));
    773773        return TCL_ERROR;
    774774    }
    775775    if (nBytes <= 0) {
    776         Tcl_AppendResult(interp, "bad # bytes request \"",
    777                 Tcl_GetString(objv[3]), "\" for \"data follows\"", (char *)NULL);
    778         Trace("Bad nbytes %d\n", nBytes);
    779         return TCL_ERROR;
     776        Tcl_AppendResult(interp, "bad # bytes request \"",
     777                Tcl_GetString(objv[3]), "\" for \"data follows\"", (char *)NULL);
     778        Trace("Bad nbytes %d\n", nBytes);
     779        return TCL_ERROR;
    780780    }
    781781    int nComponents;
    782782    if (Tcl_GetIntFromObj(interp, objv[4], &nComponents) != TCL_OK) {
    783         Trace("Bad # of components \"%s\"\n", Tcl_GetString(objv[4]));
     783        Trace("Bad # of components \"%s\"\n", Tcl_GetString(objv[4]));
    784784        return TCL_ERROR;
    785785    }
    786786    if (nComponents <= 0) {
    787         Tcl_AppendResult(interp, "bad # of components request \"",
    788                 Tcl_GetString(objv[4]), "\" for \"data follows\"", (char *)NULL);
    789         Trace("Bad # of components %d\n", nComponents);
    790         return TCL_ERROR;
     787        Tcl_AppendResult(interp, "bad # of components request \"",
     788                Tcl_GetString(objv[4]), "\" for \"data follows\"", (char *)NULL);
     789        Trace("Bad # of components %d\n", nComponents);
     790        return TCL_ERROR;
    791791    }
    792792    Rappture::Buffer buf;
     
    802802    char *bytes = (char *)buf.bytes();
    803803    if ((length > 4) && (strncmp(bytes, "<DX>", 4) == 0)) {
    804         if (!dataPtr->ImportDx(result, nComponents, length - 4, bytes + 4)) {
    805             Tcl_AppendResult(interp, result.remark(), (char *)NULL);
    806             delete dataPtr;
    807             return TCL_ERROR;
    808         }
     804        if (!dataPtr->ImportDx(result, nComponents, length - 4, bytes + 4)) {
     805            Tcl_AppendResult(interp, result.remark(), (char *)NULL);
     806            delete dataPtr;
     807            return TCL_ERROR;
     808        }
    809809    } else if ((length > 10) && (strncmp(bytes, "unirect3d ", 10) == 0)) {
    810         if (dataPtr->ParseBuffer(interp, buf) != TCL_OK) {
    811             delete dataPtr;
    812             return TCL_ERROR;
    813         }
     810        if (dataPtr->ParseBuffer(interp, buf) != TCL_OK) {
     811            delete dataPtr;
     812            return TCL_ERROR;
     813        }
    814814    } else if ((length > 10) && (strncmp(bytes, "unirect2d ", 10) == 0)) {
    815         Rappture::Unirect2d *u2dPtr;
    816         u2dPtr = new Rappture::Unirect2d(nComponents);
    817         if (u2dPtr->ParseBuffer(interp, buf) != TCL_OK) {
    818             delete u2dPtr;
    819             return TCL_ERROR;
    820         }
    821         dataPtr->Convert(u2dPtr);
    822         delete u2dPtr;
     815        Rappture::Unirect2d *u2dPtr;
     816        u2dPtr = new Rappture::Unirect2d(nComponents);
     817        if (u2dPtr->ParseBuffer(interp, buf) != TCL_OK) {
     818            delete u2dPtr;
     819            return TCL_ERROR;
     820        }
     821        dataPtr->Convert(u2dPtr);
     822        delete u2dPtr;
    823823    } else {
    824         fprintf(stderr, "header is %.14s\n", buf.bytes());
    825         if (!dataPtr->ImportDx(result, nComponents, length, bytes)) {
    826             Tcl_AppendResult(interp, result.remark(), (char *)NULL);
    827             delete dataPtr;
    828             return TCL_ERROR;
    829         }
     824        fprintf(stderr, "header is %.14s\n", buf.bytes());
     825        if (!dataPtr->ImportDx(result, nComponents, length, bytes)) {
     826            Tcl_AppendResult(interp, result.remark(), (char *)NULL);
     827            delete dataPtr;
     828            return TCL_ERROR;
     829        }
    830830    }
    831831    if (dataPtr->nValues() == 0) {
    832         delete dataPtr;
    833         Tcl_AppendResult(interp, "no data found in stream", (char *)NULL);
    834         return TCL_ERROR;
     832        delete dataPtr;
     833        Tcl_AppendResult(interp, "no data found in stream", (char *)NULL);
     834        return TCL_ERROR;
    835835    }
    836836    flowPtr->data(dataPtr);
    837837    {
    838838        char info[1024];
    839         ssize_t nWritten;
    840         size_t length;
     839        ssize_t nWritten;
     840        size_t length;
    841841
    842842        length = sprintf(info, "nv>data tag %s min %g max %g\n",
    843                 flowPtr->name(), dataPtr->magMin(), dataPtr->magMax());
     843                flowPtr->name(), dataPtr->magMin(), dataPtr->magMax());
    844844        nWritten  = write(0, info, length);
    845         assert(nWritten == (ssize_t)strlen(info));
     845        assert(nWritten == (ssize_t)strlen(info));
    846846    }
    847847    NanoVis::EventuallyRedraw(NanoVis::MAP_FLOWS);
     
    857857static int
    858858FlowDataOp(ClientData clientData, Tcl_Interp *interp, int objc,
    859            Tcl_Obj *const *objv)
     859           Tcl_Obj *const *objv)
    860860{
    861861    Tcl_ObjCmdProc *proc;
     
    873873{
    874874    if (posPtr->flags == RELPOS) {
    875         return posPtr->value;
     875        return posPtr->value;
    876876    }
    877877    switch (posPtr->axis) {
    878878    case AXIS_X: 
    879         return (posPtr->value - NanoVis::xMin) /
    880             (NanoVis::xMax - NanoVis::xMin);
     879        return (posPtr->value - NanoVis::xMin) /
     880            (NanoVis::xMax - NanoVis::xMin);
    881881    case AXIS_Y: 
    882         return (posPtr->value - NanoVis::yMin) /
    883             (NanoVis::yMax - NanoVis::yMin);
     882        return (posPtr->value - NanoVis::yMin) /
     883            (NanoVis::yMax - NanoVis::yMin);
    884884    case AXIS_Z: 
    885         return (posPtr->value - NanoVis::zMin) /
    886             (NanoVis::zMax - NanoVis::zMin);
     885        return (posPtr->value - NanoVis::zMin) /
     886            (NanoVis::zMax - NanoVis::zMin);
    887887    }
    888888    return 0.0;
     
    908908    iterPtr->hashPtr = Tcl_FirstHashEntry(&flowTable, &iterPtr->hashSearch);
    909909    if (iterPtr->hashPtr == NULL) {
    910         return NULL;
     910        return NULL;
    911911    }
    912912    return (FlowCmd *)Tcl_GetHashValue(iterPtr->hashPtr);
     
    917917{
    918918    if (iterPtr->hashPtr == NULL) {
    919         return NULL;
     919        return NULL;
    920920    }
    921921    iterPtr->hashPtr = Tcl_NextHashEntry(&iterPtr->hashSearch);
    922922    if (iterPtr->hashPtr == NULL) {
    923         return NULL;
     923        return NULL;
    924924    }
    925925    return (FlowCmd *)Tcl_GetHashValue(iterPtr->hashPtr);
     
    932932    hPtr = Tcl_FindHashEntry(&flowTable, Tcl_GetString(objPtr));
    933933    if (hPtr == NULL) {
    934         if (interp != NULL) {
    935             Tcl_AppendResult(interp, "can't find a flow \"",
    936                              Tcl_GetString(objPtr), "\"", (char *)NULL);
    937         }
    938         return TCL_ERROR;
     934        if (interp != NULL) {
     935            Tcl_AppendResult(interp, "can't find a flow \"",
     936                             Tcl_GetString(objPtr), "\"", (char *)NULL);
     937        }
     938        return TCL_ERROR;
    939939    }
    940940    *flowPtrPtr = (FlowCmd *)Tcl_GetHashValue(hPtr);
     
    951951    hPtr = Tcl_CreateHashEntry(&flowTable, name, &isNew);
    952952    if (!isNew) {
    953         Tcl_AppendResult(interp, "flow \"", name, "\" already exists.",
    954                         (char *)NULL);
    955         return TCL_ERROR;
     953        Tcl_AppendResult(interp, "flow \"", name, "\" already exists.",
     954                        (char *)NULL);
     955        return TCL_ERROR;
    956956    }
    957957    Tcl_CmdInfo cmdInfo;
    958958    if (Tcl_GetCommandInfo(interp, name, &cmdInfo)) {
    959         Tcl_AppendResult(interp, "an another command \"", name,
    960                         "\" already exists.", (char *)NULL);
    961         return TCL_ERROR;
    962     }   
     959        Tcl_AppendResult(interp, "an another command \"", name,
     960                        "\" already exists.", (char *)NULL);
     961        return TCL_ERROR;
     962    }       
    963963    FlowCmd *flowPtr;
    964964    name = Tcl_GetHashKey(&flowTable, hPtr);
    965965    flowPtr = new FlowCmd(interp, name, hPtr);
    966966    if (flowPtr == NULL) {
    967         Tcl_AppendResult(interp, "can't allocate a flow object \"", name,
    968                         "\"", (char *)NULL);
    969         return TCL_ERROR;
     967        Tcl_AppendResult(interp, "can't allocate a flow object \"", name,
     968                        "\"", (char *)NULL);
     969        return TCL_ERROR;
    970970    }
    971971    Tcl_SetHashValue(hPtr, flowPtr);
     
    979979    FlowIterator iter;
    980980    for (flowPtr = FirstFlow(&iter); flowPtr != NULL;
    981         flowPtr = NextFlow(&iter)) {
    982         flowPtr->disconnect();          /* Don't disrupt the hash walk */
    983         Tcl_DeleteCommand(interp, flowPtr->name());
     981        flowPtr = NextFlow(&iter)) {
     982        flowPtr->disconnect();                /* Don't disrupt the hash walk */
     983        Tcl_DeleteCommand(interp, flowPtr->name());
    984984    }
    985985    Tcl_DeleteHashTable(&flowTable);
     
    994994    /*
    995995     * Step 1.  Get the overall min and max magnitudes of all the
    996      *          flow vectors.
     996     *                flow vectors.
    997997     */
    998998    magMin = DBL_MAX, magMax = -DBL_MAX;
     
    10011001    FlowIterator iter;
    10021002    for (flowPtr = FirstFlow(&iter); flowPtr != NULL;
    1003         flowPtr = NextFlow(&iter)) {
    1004         double min, max;
    1005         if (!flowPtr->isDataLoaded()) {
    1006             continue;
    1007         }
    1008         Rappture::Unirect3d *dataPtr;
    1009         dataPtr = flowPtr->data();
    1010         min = dataPtr->magMin();
    1011         max = dataPtr->magMax();
    1012         if (min < magMin) {
    1013             magMin = min;
    1014         }
    1015         if (max > magMax) {
    1016             magMax = max;
    1017         }
    1018         if (dataPtr->xMin() < xMin) {
    1019             xMin = dataPtr->xMin();
    1020         }
    1021         if (dataPtr->yMin() < yMin) {
    1022             yMin = dataPtr->yMin();
    1023         }
    1024         if (dataPtr->zMin() < zMin) {
    1025             zMin = dataPtr->zMin();
    1026         }
    1027         if (dataPtr->xMax() > xMax) {
    1028             xMax = dataPtr->xMax();
    1029         }
    1030         if (dataPtr->yMax() > yMax) {
    1031             yMax = dataPtr->yMax();
    1032         }
    1033         if (dataPtr->zMax() > zMax) {
    1034             zMax = dataPtr->zMax();
    1035         }
     1003        flowPtr = NextFlow(&iter)) {
     1004        double min, max;
     1005        if (!flowPtr->isDataLoaded()) {
     1006            continue;
     1007        }
     1008        Rappture::Unirect3d *dataPtr;
     1009        dataPtr = flowPtr->data();
     1010        min = dataPtr->magMin();
     1011        max = dataPtr->magMax();
     1012        if (min < magMin) {
     1013            magMin = min;
     1014        }
     1015        if (max > magMax) {
     1016            magMax = max;
     1017        }
     1018        if (dataPtr->xMin() < xMin) {
     1019            xMin = dataPtr->xMin();
     1020        }
     1021        if (dataPtr->yMin() < yMin) {
     1022            yMin = dataPtr->yMin();
     1023        }
     1024        if (dataPtr->zMin() < zMin) {
     1025            zMin = dataPtr->zMin();
     1026        }
     1027        if (dataPtr->xMax() > xMax) {
     1028            xMax = dataPtr->xMax();
     1029        }
     1030        if (dataPtr->yMax() > yMax) {
     1031            yMax = dataPtr->yMax();
     1032        }
     1033        if (dataPtr->zMax() > zMax) {
     1034            zMax = dataPtr->zMax();
     1035        }
    10361036    }
    10371037    Trace("MapFlows magMin=%g magMax=%g\n", NanoVis::magMin, NanoVis::magMax);
     
    10411041     */
    10421042    for (flowPtr = FirstFlow(&iter); flowPtr != NULL;
    1043         flowPtr = NextFlow(&iter)) {
    1044         if (!flowPtr->isDataLoaded()) {
    1045             continue;                   // Flow exists, but no data has
    1046                                         // been loaded yet.
    1047         }
    1048         if (flowPtr->visible()) {
    1049             flowPtr->InitializeParticles();
    1050         }
    1051         if (!flowPtr->ScaleVectorField()) {
    1052             return false;
    1053         }
    1054         // FIXME: This doesn't work when there is more than one flow.
    1055         licRenderer->set_offset(flowPtr->GetRelativePosition());
     1043        flowPtr = NextFlow(&iter)) {
     1044        if (!flowPtr->isDataLoaded()) {
     1045            continue;                        // Flow exists, but no data has
     1046                                        // been loaded yet.
     1047        }
     1048        if (flowPtr->visible()) {
     1049            flowPtr->InitializeParticles();
     1050        }
     1051        if (!flowPtr->ScaleVectorField()) {
     1052            return false;
     1053        }
     1054        // FIXME: This doesn't work when there is more than one flow.
     1055        licRenderer->set_offset(flowPtr->GetRelativePosition());
    10561056        NanoVis::velocityArrowsSlice->slicePos(flowPtr->GetRelativePosition());
    10571057       
     
    10671067    FlowIterator iter;
    10681068    for (flowPtr = FirstFlow(&iter); flowPtr != NULL;
    1069         flowPtr = NextFlow(&iter)) {
    1070         if ((flowPtr->isDataLoaded()) && (flowPtr->visible())) {
    1071             flowPtr->Render();
    1072         }
     1069        flowPtr = NextFlow(&iter)) {
     1070        if ((flowPtr->isDataLoaded()) && (flowPtr->visible())) {
     1071            flowPtr->Render();
     1072        }
    10731073    }
    10741074    flags &= ~REDRAW_PENDING;
     
    10821082
    10831083    if (licRenderer->active()) {
    1084         NanoVis::licRenderer->reset();
     1084        NanoVis::licRenderer->reset();
    10851085    }
    10861086    for (flowPtr = FirstFlow(&iter); flowPtr != NULL;
    1087         flowPtr = NextFlow(&iter)) {
    1088         if ((flowPtr->isDataLoaded()) && (flowPtr->visible())) {
    1089             flowPtr->ResetParticles();
    1090         }
     1087        flowPtr = NextFlow(&iter)) {
     1088        if ((flowPtr->isDataLoaded()) && (flowPtr->visible())) {
     1089            flowPtr->ResetParticles();
     1090        }
    10911091    }
    10921092}   
     
    10981098    FlowIterator iter;
    10991099    for (flowPtr = FirstFlow(&iter); flowPtr != NULL;
    1100         flowPtr = NextFlow(&iter)) {
    1101         if ((flowPtr->isDataLoaded()) && (flowPtr->visible())) {
    1102             flowPtr->Advect();
    1103         }
     1100        flowPtr = NextFlow(&iter)) {
     1101        if ((flowPtr->isDataLoaded()) && (flowPtr->visible())) {
     1102            flowPtr->Advect();
     1103        }
    11041104    }
    11051105}   
     
    11101110 * AxisSwitchProc --
    11111111 *
    1112  *      Convert a Tcl_Obj representing the label of a child node into its
    1113  *      integer node id.
     1112 *        Convert a Tcl_Obj representing the label of a child node into its
     1113 *        integer node id.
    11141114 *
    11151115 * Results:
    1116  *      The return value is a standard Tcl result.
     1116 *        The return value is a standard Tcl result.
    11171117 *
    11181118 *---------------------------------------------------------------------------
     
    11211121static int
    11221122AxisSwitchProc(
    1123     ClientData clientData,      /* Flag indicating if the node is considered
    1124                                 * before or after the insertion position. */
    1125     Tcl_Interp *interp,         /* Interpreter to send results back to */
    1126     const char *switchName,     /* Not used. */
    1127     Tcl_Obj *objPtr,            /* String representation */
    1128     char *record,               /* Structure record */
    1129     int offset,                 /* Not used. */
    1130     int flags)                  /* Not used. */
     1123    ClientData clientData,        /* Flag indicating if the node is considered
     1124                                * before or after the insertion position. */
     1125    Tcl_Interp *interp,                /* Interpreter to send results back to */
     1126    const char *switchName,        /* Not used. */
     1127    Tcl_Obj *objPtr,                /* String representation */
     1128    char *record,                /* Structure record */
     1129    int offset,                        /* Not used. */
     1130    int flags)                        /* Not used. */
    11311131{
    11321132    const char *string = Tcl_GetString(objPtr);
    11331133    if (string[1] == '\0') {
    1134         FlowCmd::SliceAxis *axisPtr = (FlowCmd::SliceAxis *)(record + offset);
     1134        FlowCmd::SliceAxis *axisPtr = (FlowCmd::SliceAxis *)(record + offset);
    11351135        char c;
    11361136        c = tolower((unsigned char)string[0]);
     
    11571157 * ColorSwitchProc --
    11581158 *
    1159  *      Convert a Tcl_Obj representing the label of a list of four color
    1160  *      components in to a RGBA color value.
     1159 *        Convert a Tcl_Obj representing the label of a list of four color
     1160 *        components in to a RGBA color value.
    11611161 *
    11621162 * Results:
    1163  *      The return value is a standard Tcl result.
     1163 *        The return value is a standard Tcl result.
    11641164 *
    11651165 *---------------------------------------------------------------------------
     
    11681168static int
    11691169ColorSwitchProc(
    1170     ClientData clientData,      /* Flag indicating if the node is considered
    1171                                 * before or after the insertion position. */
    1172     Tcl_Interp *interp,         /* Interpreter to send results back to */
    1173     const char *switchName,     /* Not used. */
    1174     Tcl_Obj *objPtr,            /* String representation */
    1175     char *record,               /* Structure record */
    1176     int offset,                 /* Not used. */
    1177     int flags)                  /* Not used. */
     1170    ClientData clientData,        /* Flag indicating if the node is considered
     1171                                * before or after the insertion position. */
     1172    Tcl_Interp *interp,                /* Interpreter to send results back to */
     1173    const char *switchName,        /* Not used. */
     1174    Tcl_Obj *objPtr,                /* String representation */
     1175    char *record,                /* Structure record */
     1176    int offset,                        /* Not used. */
     1177    int flags)                        /* Not used. */
    11781178{
    11791179    Tcl_Obj **objv;
     
    11821182
    11831183    if (Tcl_ListObjGetElements(interp, objPtr, &objc, &objv) != TCL_OK) {
    1184         return TCL_ERROR;
     1184        return TCL_ERROR;
    11851185    }
    11861186    if ((objc < 3) || (objc > 4)) {
    1187         Tcl_AppendResult(interp, "wrong # of elements in color definition",
    1188                         (char *)NULL);
    1189         return TCL_ERROR;
     1187        Tcl_AppendResult(interp, "wrong # of elements in color definition",
     1188                        (char *)NULL);
     1189        return TCL_ERROR;
    11901190    }
    11911191    float values[4];
     
    11931193    values[3] = 1.0f;
    11941194    for (i = 0; i < objc; i++) {
    1195         float value;
    1196 
    1197         if (GetFloatFromObj(interp, objv[i], &value) != TCL_OK) {
    1198             return TCL_ERROR;
    1199         }
    1200         if ((value < 0.0) || (value > 1.0)) {
    1201             Tcl_AppendResult(interp, "bad component value in \"",
    1202                 Tcl_GetString(objPtr), "\": color values must be [0..1]",
    1203                 (char *)NULL);
    1204             return TCL_ERROR;
    1205         }
    1206         values[i] = value;
    1207     }      
     1195        float value;
     1196
     1197        if (GetFloatFromObj(interp, objv[i], &value) != TCL_OK) {
     1198            return TCL_ERROR;
     1199        }
     1200        if ((value < 0.0) || (value > 1.0)) {
     1201            Tcl_AppendResult(interp, "bad component value in \"",
     1202                Tcl_GetString(objPtr), "\": color values must be [0..1]",
     1203                (char *)NULL);
     1204            return TCL_ERROR;
     1205        }
     1206        values[i] = value;
     1207    }           
    12081208    colorPtr->r = values[0];
    12091209    colorPtr->g = values[1];
     
    12181218 * PointSwitchProc --
    12191219 *
    1220  *      Convert a Tcl_Obj representing the a 3-D coordinate into
    1221  *      a point.
     1220 *        Convert a Tcl_Obj representing the a 3-D coordinate into
     1221 *        a point.
    12221222 *
    12231223 * Results:
    1224  *      The return value is a standard Tcl result.
     1224 *        The return value is a standard Tcl result.
    12251225 *
    12261226 *---------------------------------------------------------------------------
     
    12291229static int
    12301230PointSwitchProc(
    1231     ClientData clientData,      /* Flag indicating if the node is considered
    1232                                 * before or after the insertion position. */
    1233     Tcl_Interp *interp,         /* Interpreter to send results back to */
    1234     const char *switchName,     /* Not used. */
    1235     Tcl_Obj *objPtr,            /* String representation */
    1236     char *record,               /* Structure record */
    1237     int offset,                 /* Not used. */
    1238     int flags)                  /* Not used. */
     1231    ClientData clientData,        /* Flag indicating if the node is considered
     1232                                * before or after the insertion position. */
     1233    Tcl_Interp *interp,                /* Interpreter to send results back to */
     1234    const char *switchName,        /* Not used. */
     1235    Tcl_Obj *objPtr,                /* String representation */
     1236    char *record,                /* Structure record */
     1237    int offset,                        /* Not used. */
     1238    int flags)                        /* Not used. */
    12391239{
    12401240    FlowPoint *pointPtr = (FlowPoint *)(record + offset);
     
    12431243
    12441244    if (Tcl_ListObjGetElements(interp, objPtr, &objc, &objv) != TCL_OK) {
    1245         return TCL_ERROR;
     1245        return TCL_ERROR;
    12461246    }
    12471247    if (objc != 3) {
    1248         Tcl_AppendResult(interp, "wrong # of elements for box coordinates: "
    1249                         " should be \"x y z\"", (char *)NULL);
    1250         return TCL_ERROR;
     1248        Tcl_AppendResult(interp, "wrong # of elements for box coordinates: "
     1249                        " should be \"x y z\"", (char *)NULL);
     1250        return TCL_ERROR;
    12511251    }
    12521252    float values[3];
    12531253    int i;
    12541254    for (i = 0; i < objc; i++) {
    1255         float value;
    1256 
    1257         if (GetFloatFromObj(interp, objv[i], &value) != TCL_OK) {
    1258             return TCL_ERROR;
    1259         }
    1260         values[i] = value;
    1261     }      
     1255        float value;
     1256
     1257        if (GetFloatFromObj(interp, objv[i], &value) != TCL_OK) {
     1258            return TCL_ERROR;
     1259        }
     1260        values[i] = value;
     1261    }           
    12621262    pointPtr->x = values[0];
    12631263    pointPtr->y = values[1];
     
    12711271 * PositionSwitchProc --
    12721272 *
    1273  *      Convert a Tcl_Obj representing the a 3-D coordinate into
    1274  *      a point.
     1273 *        Convert a Tcl_Obj representing the a 3-D coordinate into
     1274 *        a point.
    12751275 *
    12761276 * Results:
    1277  *      The return value is a standard Tcl result.
     1277 *        The return value is a standard Tcl result.
    12781278 *
    12791279 *---------------------------------------------------------------------------
     
    12821282static int
    12831283PositionSwitchProc(
    1284     ClientData clientData,      /* Flag indicating if the node is considered
    1285                                 * before or after the insertion position. */
    1286     Tcl_Interp *interp,         /* Interpreter to send results back to */
    1287     const char *switchName,     /* Not used. */
    1288     Tcl_Obj *objPtr,            /* String representation */
    1289     char *record,               /* Structure record */
    1290     int offset,                 /* Not used. */
    1291     int flags)                  /* Not used. */
     1284    ClientData clientData,        /* Flag indicating if the node is considered
     1285                                * before or after the insertion position. */
     1286    Tcl_Interp *interp,                /* Interpreter to send results back to */
     1287    const char *switchName,        /* Not used. */
     1288    Tcl_Obj *objPtr,                /* String representation */
     1289    char *record,                /* Structure record */
     1290    int offset,                        /* Not used. */
     1291    int flags)                        /* Not used. */
    12921292{
    12931293    FlowPosition *posPtr = (FlowPosition *)(record + offset);
     
    12981298    p = strrchr((char *)string, '%');
    12991299    if (p == NULL) {
    1300         float value;
    1301 
    1302         if (GetFloatFromObj(interp, objPtr, &value) != TCL_OK) {
    1303             return TCL_ERROR;
    1304         }
    1305         posPtr->value = value;
    1306         posPtr->flags = ABSPOS;
     1300        float value;
     1301
     1302        if (GetFloatFromObj(interp, objPtr, &value) != TCL_OK) {
     1303            return TCL_ERROR;
     1304        }
     1305        posPtr->value = value;
     1306        posPtr->flags = ABSPOS;
    13071307    } else {
    1308         double value;
    1309 
    1310         *p = '\0';
    1311         if (Tcl_GetDouble(interp, string, &value) != TCL_OK) {
    1312             return TCL_ERROR;
    1313         }
    1314         posPtr->value = (float)value * 0.01;
    1315         posPtr->flags = RELPOS;
     1308        double value;
     1309
     1310        *p = '\0';
     1311        if (Tcl_GetDouble(interp, string, &value) != TCL_OK) {
     1312            return TCL_ERROR;
     1313        }
     1314        posPtr->value = (float)value * 0.01;
     1315        posPtr->flags = RELPOS;
    13161316    }
    13171317    return TCL_OK;
     
    13231323 * TransferFunctionSwitchProc --
    13241324 *
    1325  *      Convert a Tcl_Obj representing the transfer function into a
    1326  *      TransferFunction pointer.  The transfer function must have been
    1327  *      previously defined.
     1325 *        Convert a Tcl_Obj representing the transfer function into a
     1326 *        TransferFunction pointer.  The transfer function must have been
     1327 *        previously defined.
    13281328 *
    13291329 * Results:
    1330  *      The return value is a standard Tcl result.
     1330 *        The return value is a standard Tcl result.
    13311331 *
    13321332 *---------------------------------------------------------------------------
     
    13351335static int
    13361336TransferFunctionSwitchProc(
    1337     ClientData clientData,      /* Flag indicating if the node is considered
    1338                                 * before or after the insertion position. */
    1339     Tcl_Interp *interp,         /* Interpreter to send results back to */
    1340     const char *switchName,     /* Not used. */
    1341     Tcl_Obj *objPtr,            /* String representation */
    1342     char *record,               /* Structure record */
    1343     int offset,                 /* Not used. */
    1344     int flags)                  /* Not used. */
     1337    ClientData clientData,        /* Flag indicating if the node is considered
     1338                                * before or after the insertion position. */
     1339    Tcl_Interp *interp,                /* Interpreter to send results back to */
     1340    const char *switchName,        /* Not used. */
     1341    Tcl_Obj *objPtr,                /* String representation */
     1342    char *record,                /* Structure record */
     1343    int offset,                        /* Not used. */
     1344    int flags)                        /* Not used. */
    13451345{
    13461346    TransferFunction **funcPtrPtr = (TransferFunction **)(record + offset);
     
    13611361 * VideoFormatSwitchProc --
    13621362 *
    1363  *      Convert a Tcl_Obj representing the video format into its
    1364  *      integer id.
     1363 *        Convert a Tcl_Obj representing the video format into its
     1364 *        integer id.
    13651365 *
    13661366 * Results:
    1367  *      The return value is a standard Tcl result.
     1367 *        The return value is a standard Tcl result.
    13681368 *
    13691369 *---------------------------------------------------------------------------
     
    13721372static int
    13731373VideoFormatSwitchProc(
    1374     ClientData clientData,      /* Not used. */
    1375     Tcl_Interp *interp,         /* Interpreter to send results back to */
    1376     const char *switchName,     /* Not used. */
    1377     Tcl_Obj *objPtr,            /* String representation */
    1378     char *record,               /* Structure record */
    1379     int offset,                 /* Not used. */
    1380     int flags)                  /* Not used. */
     1374    ClientData clientData,        /* Not used. */
     1375    Tcl_Interp *interp,                /* Interpreter to send results back to */
     1376    const char *switchName,        /* Not used. */
     1377    Tcl_Obj *objPtr,                /* String representation */
     1378    char *record,                /* Structure record */
     1379    int offset,                        /* Not used. */
     1380    int flags)                        /* Not used. */
    13811381{
    13821382    Rappture::AVTranslate::VideoFormats *formatPtr =
    1383         (Rappture::AVTranslate::VideoFormats *)(record + offset);
     1383        (Rappture::AVTranslate::VideoFormats *)(record + offset);
    13841384    const char *string;
    13851385    char c;
     
    13881388    c = string[0];
    13891389    if ((c == 'm') && (strcmp(string, "mpeg") == 0)) {
    1390         *formatPtr =  Rappture::AVTranslate::MPEG1;
     1390        *formatPtr =  Rappture::AVTranslate::MPEG1;
    13911391    } else if ((c == 't') && (strcmp(string, "theora") == 0)) {
    1392         *formatPtr = Rappture::AVTranslate::THEORA;
     1392        *formatPtr = Rappture::AVTranslate::THEORA;
    13931393    } else if ((c == 'm') && (strcmp(string, "mov") == 0)) {
    1394         *formatPtr = Rappture::AVTranslate::QUICKTIME;
     1394        *formatPtr = Rappture::AVTranslate::QUICKTIME;
    13951395    } else {
    1396         Tcl_AppendResult(interp, "bad video format \"", string,
     1396        Tcl_AppendResult(interp, "bad video format \"", string,
    13971397                     "\": should be mpeg, theora, or mov", (char*)NULL);
    13981398    }
     
    14021402static int
    14031403FlowConfigureOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1404                 Tcl_Obj *const *objv)
     1404                Tcl_Obj *const *objv)
    14051405{
    14061406    FlowCmd *flowPtr = (FlowCmd *)clientData;
    14071407
    14081408    if (flowPtr->ParseSwitches(interp, objc - 2, objv + 2) != TCL_OK) {
    1409         return TCL_ERROR;
     1409        return TCL_ERROR;
    14101410    }
    14111411    NanoVis::EventuallyRedraw(NanoVis::MAP_FLOWS);
     
    14151415static int
    14161416FlowParticlesAddOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1417                    Tcl_Obj *const *objv)
     1417                   Tcl_Obj *const *objv)
    14181418{
    14191419    FlowCmd *flowPtr = (FlowCmd *)clientData;
    14201420
    14211421    if (flowPtr->CreateParticles(interp, objv[3]) != TCL_OK) {
    1422         return TCL_ERROR;
     1422        return TCL_ERROR;
    14231423    }
    14241424    FlowParticles *particlesPtr;
    14251425    if (flowPtr->GetParticles(interp, objv[3], &particlesPtr) != TCL_OK) {
    1426         return TCL_ERROR;
     1426        return TCL_ERROR;
    14271427    }
    14281428    if (particlesPtr->ParseSwitches(interp, objc - 4, objv + 4) != TCL_OK) {
    1429         delete particlesPtr;
    1430         return TCL_ERROR;
     1429        delete particlesPtr;
     1430        return TCL_ERROR;
    14311431    }
    14321432    particlesPtr->Configure();
     
    14381438static int
    14391439FlowParticlesConfigureOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1440                         Tcl_Obj *const *objv)
     1440                        Tcl_Obj *const *objv)
    14411441{
    14421442    FlowCmd *flowPtr = (FlowCmd *)clientData;
     
    14441444    FlowParticles *particlesPtr;
    14451445    if (flowPtr->GetParticles(interp, objv[3], &particlesPtr) != TCL_OK) {
    1446         return TCL_ERROR;
     1446        return TCL_ERROR;
    14471447    }
    14481448    if (particlesPtr->ParseSwitches(interp, objc - 4, objv + 4) != TCL_OK) {
    1449         return TCL_ERROR;
     1449        return TCL_ERROR;
    14501450    }
    14511451    particlesPtr->Configure();
     
    14561456static int
    14571457FlowParticlesDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1458                       Tcl_Obj *const *objv)
     1458                      Tcl_Obj *const *objv)
    14591459{
    14601460    FlowCmd *flowPtr = (FlowCmd *)clientData;
    14611461    int i;
    14621462    for (i = 3; i < objc; i++) {
    1463         FlowParticles *particlesPtr;
    1464 
    1465         if (flowPtr->GetParticles(NULL, objv[i], &particlesPtr) == TCL_OK) {
    1466             delete particlesPtr;
    1467         }
     1463        FlowParticles *particlesPtr;
     1464
     1465        if (flowPtr->GetParticles(NULL, objv[i], &particlesPtr) == TCL_OK) {
     1466            delete particlesPtr;
     1467        }
    14681468    }
    14691469    NanoVis::EventuallyRedraw();
     
    14731473static int
    14741474FlowParticlesNamesOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1475                      Tcl_Obj *const *objv)
     1475                     Tcl_Obj *const *objv)
    14761476{
    14771477    FlowCmd *flowPtr = (FlowCmd *)clientData;
     
    14811481    FlowParticles *particlesPtr;
    14821482    for (particlesPtr = flowPtr->FirstParticles(&iter); particlesPtr != NULL;
    1483         particlesPtr = flowPtr->NextParticles(&iter)) {
    1484         Tcl_Obj *objPtr;
    1485 
    1486         objPtr = Tcl_NewStringObj(particlesPtr->name(), -1);
    1487         Tcl_ListObjAppendElement(interp, listObjPtr, objPtr);
     1483        particlesPtr = flowPtr->NextParticles(&iter)) {
     1484        Tcl_Obj *objPtr;
     1485
     1486        objPtr = Tcl_NewStringObj(particlesPtr->name(), -1);
     1487        Tcl_ListObjAppendElement(interp, listObjPtr, objPtr);
    14881488    }
    14891489    Tcl_SetObjResult(interp, listObjPtr);
     
    14961496 * FlowParticlesObjCmd --
    14971497 *
    1498  *      This procedure is invoked to process commands on behalf of the flow
    1499  *      object.
     1498 *         This procedure is invoked to process commands on behalf of the flow
     1499 *         object.
    15001500 *
    15011501 * Results:
    1502  *      A standard Tcl result.
     1502 *        A standard Tcl result.
    15031503 *
    15041504 * Side effects:
    1505  *      See the user documentation.
     1505 *        See the user documentation.
    15061506 *
    15071507 * $flow particles oper $name
     
    15111511    {"add",        1, FlowParticlesAddOp,        4, 0, "name ?switches?",},
    15121512    {"configure",  1, FlowParticlesConfigureOp,  4, 0, "name ?switches?",},
    1513     {"delete",     1, FlowParticlesDeleteOp,     4, 0, "?name...?"},
     1513    {"delete",           1, FlowParticlesDeleteOp,     4, 0, "?name...?"},
    15141514    {"names",      1, FlowParticlesNamesOp,      3, 4, "?pattern?"},
    15151515};
     
    15191519static int
    15201520FlowParticlesOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1521                Tcl_Obj *const *objv)
     1521               Tcl_Obj *const *objv)
    15221522{
    15231523    Tcl_ObjCmdProc *proc;
    15241524    proc = Rappture::GetOpFromObj(interp, nFlowParticlesOps, flowParticlesOps,
    1525         Rappture::CMDSPEC_ARG2, objc, objv, 0);
     1525        Rappture::CMDSPEC_ARG2, objc, objv, 0);
    15261526    if (proc == NULL) {
    1527         return TCL_ERROR;
     1527        return TCL_ERROR;
    15281528    }
    15291529    FlowCmd *flowPtr = (FlowCmd *)clientData;
     
    15371537static int
    15381538FlowBoxAddOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1539                Tcl_Obj *const *objv)
     1539               Tcl_Obj *const *objv)
    15401540{
    15411541    FlowCmd *flowPtr = (FlowCmd *)clientData;
    15421542
    15431543    if (flowPtr->CreateBox(interp, objv[3]) != TCL_OK) {
    1544         return TCL_ERROR;
     1544        return TCL_ERROR;
    15451545    }
    15461546    FlowBox *boxPtr;
    15471547    if (flowPtr->GetBox(interp, objv[3], &boxPtr) != TCL_OK) {
    1548         return TCL_ERROR;
     1548        return TCL_ERROR;
    15491549    }
    15501550    if (boxPtr->ParseSwitches(interp, objc - 4, objv + 4) != TCL_OK) {
    1551         delete boxPtr;
    1552         return TCL_ERROR;
     1551        delete boxPtr;
     1552        return TCL_ERROR;
    15531553    }
    15541554    NanoVis::EventuallyRedraw();
     
    15591559static int
    15601560FlowBoxDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1561                    Tcl_Obj *const *objv)
     1561                   Tcl_Obj *const *objv)
    15621562{
    15631563    FlowCmd *flowPtr = (FlowCmd *)clientData;
    15641564    int i;
    15651565    for (i = 3; i < objc; i++) {
    1566         FlowBox *boxPtr;
    1567 
    1568         if (flowPtr->GetBox(NULL, objv[i], &boxPtr) == TCL_OK) {
    1569             delete boxPtr;
    1570         }
     1566        FlowBox *boxPtr;
     1567
     1568        if (flowPtr->GetBox(NULL, objv[i], &boxPtr) == TCL_OK) {
     1569            delete boxPtr;
     1570        }
    15711571    }
    15721572    NanoVis::EventuallyRedraw();
     
    15841584    FlowBox *boxPtr;
    15851585    for (boxPtr = flowPtr->FirstBox(&iter); boxPtr != NULL;
    1586         boxPtr = flowPtr->NextBox(&iter)) {
    1587         Tcl_Obj *objPtr;
    1588 
    1589         objPtr = Tcl_NewStringObj(boxPtr->name(), -1);
    1590         Tcl_ListObjAppendElement(interp, listObjPtr, objPtr);
     1586        boxPtr = flowPtr->NextBox(&iter)) {
     1587        Tcl_Obj *objPtr;
     1588
     1589        objPtr = Tcl_NewStringObj(boxPtr->name(), -1);
     1590        Tcl_ListObjAppendElement(interp, listObjPtr, objPtr);
    15911591    }
    15921592    Tcl_SetObjResult(interp, listObjPtr);
     
    15961596static int
    15971597FlowBoxConfigureOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1598                         Tcl_Obj *const *objv)
     1598                        Tcl_Obj *const *objv)
    15991599{
    16001600    FlowCmd *flowPtr = (FlowCmd *)clientData;
     
    16021602    FlowBox *boxPtr;
    16031603    if (flowPtr->GetBox(interp, objv[3], &boxPtr) != TCL_OK) {
    1604         return TCL_ERROR;
     1604        return TCL_ERROR;
    16051605    }
    16061606    if (boxPtr->ParseSwitches(interp, objc - 4, objv + 4) != TCL_OK) {
    1607         return TCL_ERROR;
     1607        return TCL_ERROR;
    16081608    }
    16091609    NanoVis::EventuallyRedraw();
     
    16161616 * FlowBoxOp--
    16171617 *
    1618  *      This procedure is invoked to process commands on behalf of the flow
    1619  *      object.
     1618 *         This procedure is invoked to process commands on behalf of the flow
     1619 *         object.
    16201620 *
    16211621 * Results:
    1622  *      A standard Tcl result.
     1622 *        A standard Tcl result.
    16231623 *
    16241624 * Side effects:
    1625  *      See the user documentation.
     1625 *        See the user documentation.
    16261626 *
    16271627 *---------------------------------------------------------------------------
     
    16301630    {"add",        1, FlowBoxAddOp,        4, 0, "name ?switches?",},
    16311631    {"configure",  1, FlowBoxConfigureOp,  4, 0, "name ?switches?",},
    1632     {"delete",     1, FlowBoxDeleteOp,     3, 0, "?name...?"},
     1632    {"delete",           1, FlowBoxDeleteOp,     3, 0, "?name...?"},
    16331633    {"names",      1, FlowBoxNamesOp,      3, 0, "?pattern?"},
    16341634};
     
    16381638static int
    16391639FlowBoxOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1640                Tcl_Obj *const *objv)
     1640               Tcl_Obj *const *objv)
    16411641{
    16421642    Tcl_ObjCmdProc *proc;
    16431643    proc = Rappture::GetOpFromObj(interp, nFlowBoxOps, flowBoxOps,
    1644         Rappture::CMDSPEC_ARG2, objc, objv, 0);
     1644        Rappture::CMDSPEC_ARG2, objc, objv, 0);
    16451645    if (proc == NULL) {
    1646         return TCL_ERROR;
     1646        return TCL_ERROR;
    16471647    }
    16481648    FlowCmd *flowPtr = (FlowCmd *)clientData;
     
    16671667static int
    16681668FlowLegendOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1669           Tcl_Obj *const *objv)
     1669          Tcl_Obj *const *objv)
    16701670{
    16711671    FlowCmd *flowPtr = (FlowCmd *)clientData;
     
    16981698 * FlowInstObjCmd --
    16991699 *
    1700  *      This procedure is invoked to process commands on behalf of the flow
    1701  *      object.
     1700 *         This procedure is invoked to process commands on behalf of the flow
     1701 *         object.
    17021702 *
    17031703 * Results:
    1704  *      A standard Tcl result.
     1704 *        A standard Tcl result.
    17051705 *
    17061706 * Side effects:
    1707  *      See the user documentation.
     1707 *        See the user documentation.
    17081708 *
    17091709 *---------------------------------------------------------------------------
     
    17121712    {"box",         1, FlowBoxOp,        2, 0, "oper ?args?"},
    17131713    {"configure",   1, FlowConfigureOp,  2, 0, "?switches?"},
    1714     {"data",        1, FlowDataOp,       2, 0, "oper ?args?"},
     1714    {"data",            1, FlowDataOp,       2, 0, "oper ?args?"},
    17151715    {"legend",      1, FlowLegendOp,     4, 4, "w h"},
    17161716    {"particles",   1, FlowParticlesOp,  2, 0, "oper ?args?"}
     
    17201720static int
    17211721FlowInstObjCmd(ClientData clientData, Tcl_Interp *interp, int objc,
    1722                Tcl_Obj *const *objv)
     1722               Tcl_Obj *const *objv)
    17231723{
    17241724    Tcl_ObjCmdProc *proc;
    17251725    proc = Rappture::GetOpFromObj(interp, nFlowInstOps, flowInstOps,
    1726         Rappture::CMDSPEC_ARG1, objc, objv, 0);
     1726        Rappture::CMDSPEC_ARG1, objc, objv, 0);
    17271727    if (proc == NULL) {
    1728         return TCL_ERROR;
     1728        return TCL_ERROR;
    17291729    }
    17301730    assert(CheckGL(AT));
     
    17421742 * FlowInstDeleteProc --
    17431743 *
    1744  *      Deletes the command associated with the tree.  This is called only
    1745  *      when the command associated with the tree is destroyed.
     1744 *        Deletes the command associated with the tree.  This is called only
     1745 *        when the command associated with the tree is destroyed.
    17461746 *
    17471747 * Results:
    1748  *      None.
     1748 *        None.
    17491749 *
    17501750 *---------------------------------------------------------------------------
     
    17671767static int
    17681768FlowAddOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1769           Tcl_Obj *const *objv)
     1769          Tcl_Obj *const *objv)
    17701770{
    17711771    if (NanoVis::CreateFlow(interp, objv[2]) != TCL_OK) {
    1772         return TCL_ERROR;
     1772        return TCL_ERROR;
    17731773    }
    17741774    FlowCmd *flowPtr;
    17751775    if (NanoVis::GetFlow(interp, objv[2], &flowPtr) != TCL_OK) {
    1776         return TCL_ERROR;
     1776        return TCL_ERROR;
    17771777    }
    17781778    if (flowPtr->ParseSwitches(interp, objc - 3, objv + 3) != TCL_OK) {
    1779         Tcl_DeleteCommand(interp, flowPtr->name());
    1780         return TCL_ERROR;
     1779        Tcl_DeleteCommand(interp, flowPtr->name());
     1780        return TCL_ERROR;
    17811781    }
    17821782    Tcl_SetObjResult(interp, objv[2]);
     
    17951795static int
    17961796FlowDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1797              Tcl_Obj *const *objv)
     1797             Tcl_Obj *const *objv)
    17981798{
    17991799    int i;
    18001800
    18011801    for (i = 2; i < objc; i++) {
    1802         FlowCmd *flowPtr;
    1803 
    1804         if (NanoVis::GetFlow(interp, objv[i], &flowPtr) != TCL_OK) {
    1805             return TCL_ERROR;
    1806         }
    1807         Tcl_DeleteCommand(interp, flowPtr->name());
     1802        FlowCmd *flowPtr;
     1803
     1804        if (NanoVis::GetFlow(interp, objv[i], &flowPtr) != TCL_OK) {
     1805            return TCL_ERROR;
     1806        }
     1807        Tcl_DeleteCommand(interp, flowPtr->name());
    18081808    }
    18091809    NanoVis::EventuallyRedraw(NanoVis::MAP_FLOWS);
     
    18211821static int
    18221822FlowExistsOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1823              Tcl_Obj *const *objv)
     1823             Tcl_Obj *const *objv)
    18241824{
    18251825    bool value;
     
    18281828    value = false;
    18291829    if (NanoVis::GetFlow(NULL, objv[2], &flowPtr) == TCL_OK) {
    1830         value = true;
     1830        value = true;
    18311831    }
    18321832    Tcl_SetBooleanObj(Tcl_GetObjResult(interp), (int)value);
     
    18391839 * FlowGotoOp --
    18401840 *
    1841  *      flow goto number
     1841 *        flow goto number
    18421842 *
    18431843 *---------------------------------------------------------------------------
     
    18521852    }
    18531853    if ((nSteps < 0) || (nSteps > SHRT_MAX)) {
    1854         Tcl_AppendResult(interp, "flow goto: bad # of steps \"",
    1855                         Tcl_GetString(objv[2]), "\"", (char *)NULL);
    1856         return TCL_ERROR;
     1854        Tcl_AppendResult(interp, "flow goto: bad # of steps \"",
     1855                        Tcl_GetString(objv[2]), "\"", (char *)NULL);
     1856        return TCL_ERROR;
    18571857    }
    18581858    NanoVis::ResetFlows();
    18591859    if (NanoVis::flags & NanoVis::MAP_FLOWS) {
    1860         NanoVis::MapFlows();
     1860        NanoVis::MapFlows();
    18611861    }
    18621862    int i;
    18631863    NanoVis::AdvectFlows();
    18641864    for (i = 0; i < nSteps; i++) {
    1865         if (NanoVis::licRenderer->active()) {
    1866             NanoVis::licRenderer->convolve();
    1867         }
    1868         NanoVis::AdvectFlows();
     1865        if (NanoVis::licRenderer->active()) {
     1866            NanoVis::licRenderer->convolve();
     1867        }
     1868        NanoVis::AdvectFlows();
    18691869    }
    18701870    NanoVis::EventuallyRedraw();
     
    18821882static int
    18831883FlowNamesOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1884             Tcl_Obj *const *objv)
     1884            Tcl_Obj *const *objv)
    18851885{
    18861886    Tcl_Obj *listObjPtr;
     
    18891889    FlowIterator iter;
    18901890    for (flowPtr = NanoVis::FirstFlow(&iter); flowPtr != NULL;
    1891         flowPtr = NanoVis::NextFlow(&iter)) {
    1892         Tcl_Obj *objPtr;
    1893 
    1894         objPtr = Tcl_NewStringObj(flowPtr->name(), -1);
    1895         Tcl_ListObjAppendElement(interp, listObjPtr, objPtr);
     1891        flowPtr = NanoVis::NextFlow(&iter)) {
     1892        Tcl_Obj *objPtr;
     1893
     1894        objPtr = Tcl_NewStringObj(flowPtr->name(), -1);
     1895        Tcl_ListObjAppendElement(interp, listObjPtr, objPtr);
    18961896    }
    18971897    Tcl_SetObjResult(interp, listObjPtr);
     
    19051905    assert(NanoVis::licRenderer != NULL);
    19061906    if (NanoVis::flags & NanoVis::MAP_FLOWS) {
    1907         NanoVis::MapFlows();
     1907        NanoVis::MapFlows();
    19081908    }
    19091909    NanoVis::EventuallyRedraw();
     
    19221922
    19231923struct FlowVideoValues {
    1924     float frameRate;                    /* Frame rate */
    1925     int bitRate;                        /* Video bitrate */
    1926     int width, height;                  /* Dimensions of video frame. */
     1924    float frameRate;                        /* Frame rate */
     1925    int bitRate;                        /* Video bitrate */
     1926    int width, height;                        /* Dimensions of video frame. */
    19271927    int nFrames;
    19281928    Rappture::AVTranslate::VideoFormats format;
     
    19361936Rappture::SwitchSpec FlowCmd::videoSwitches[] = {
    19371937    {Rappture::SWITCH_FLOAT, "-bitrate", "value",
    1938         offsetof(FlowVideoValues, bitRate), 0},
     1938        offsetof(FlowVideoValues, bitRate), 0},
    19391939    {Rappture::SWITCH_CUSTOM, "-format", "string",
    19401940        offsetof(FlowVideoValues, format), 0, 0, &videoFormatSwitch},
    19411941    {Rappture::SWITCH_FLOAT, "-framerate", "value",
    1942         offsetof(FlowVideoValues, frameRate), 0},
     1942        offsetof(FlowVideoValues, frameRate), 0},
    19431943    {Rappture::SWITCH_INT, "-height", "integer",
    1944         offsetof(FlowVideoValues, height), 0},
     1944        offsetof(FlowVideoValues, height), 0},
    19451945    {Rappture::SWITCH_INT, "-numframes", "count",
    1946         offsetof(FlowVideoValues, nFrames), 0},
     1946        offsetof(FlowVideoValues, nFrames), 0},
    19471947    {Rappture::SWITCH_INT, "-width", "integer",
    1948         offsetof(FlowVideoValues, width), 0},
     1948        offsetof(FlowVideoValues, width), 0},
    19491949    {Rappture::SWITCH_END}
    19501950};
     
    19521952static int
    19531953FlowVideoOp(ClientData clientData, Tcl_Interp *interp, int objc,
    1954             Tcl_Obj *const *objv)
     1954            Tcl_Obj *const *objv)
    19551955{
    19561956    struct pollfd pollResults;
     
    19601960    pollResults.events = POLLIN;
    19611961
    1962 #define PENDING_TIMEOUT         10  /* milliseconds. */
     1962#define PENDING_TIMEOUT                10  /* milliseconds. */
    19631963    timeout = PENDING_TIMEOUT;
    19641964
     
    19671967
    19681968    token = Tcl_GetString(objv[2]);
    1969     values.frameRate = 25.0f;           // Default frame rate 25 fps
    1970     values.bitRate = 6.0e+6f;           // Default video bit rate.
     1969    values.frameRate = 25.0f;                // Default frame rate 25 fps
     1970    values.bitRate = 6.0e+6f;                // Default video bit rate.
    19711971    values.width = NanoVis::win_width;
    19721972    values.height = NanoVis::win_height;
     
    19741974    values.format = Rappture::AVTranslate::MPEG1;
    19751975    if (Rappture::ParseSwitches(interp, FlowCmd::videoSwitches,
    1976         objc - 3, objv + 3, &values, SWITCH_DEFAULTS) < 0) {
    1977         return TCL_ERROR;
     1976        objc - 3, objv + 3, &values, SWITCH_DEFAULTS) < 0) {
     1977        return TCL_ERROR;
    19781978    }
    19791979    if ((values.width < 0) || (values.width > SHRT_MAX) ||
    1980         (values.height < 0) || (values.height > SHRT_MAX)) {
    1981         Tcl_AppendResult(interp, "bad dimensions for video", (char *)NULL);
    1982         return TCL_ERROR;
     1980        (values.height < 0) || (values.height > SHRT_MAX)) {
     1981        Tcl_AppendResult(interp, "bad dimensions for video", (char *)NULL);
     1982        return TCL_ERROR;
    19831983    }
    19841984    if ((values.frameRate < 0.0f) || (values.frameRate > 30.0f)) {
    1985         Tcl_AppendResult(interp, "bad frame rate.", (char *)NULL);
    1986         return TCL_ERROR;
     1985        Tcl_AppendResult(interp, "bad frame rate.", (char *)NULL);
     1986        return TCL_ERROR;
    19871987    }
    19881988    if (values.bitRate < 0.0f) {
    1989         Tcl_AppendResult(interp, "bad bit rate.", (char *)NULL);
    1990         return TCL_ERROR;
     1989        Tcl_AppendResult(interp, "bad bit rate.", (char *)NULL);
     1990        return TCL_ERROR;
    19911991    }
    19921992    if (NanoVis::licRenderer == NULL) {
    1993         Tcl_AppendResult(interp, "no lic renderer.", (char *)NULL);
    1994         return TCL_ERROR;
     1993        Tcl_AppendResult(interp, "no lic renderer.", (char *)NULL);
     1994        return TCL_ERROR;
    19951995    }
    19961996    // Save the old dimensions of the offscreen buffer.
     
    20042004
    20052005    Rappture::AVTranslate movie(values.width, values.height, values.bitRate,
    2006         values.frameRate);
     2006        values.frameRate);
    20072007    char tmpFileName[200];
    20082008    sprintf(tmpFileName,"/tmp/flow%d.mpeg", getpid());
    20092009    if (!movie.init(context, tmpFileName)) {
    20102010        Tcl_AppendResult(interp, "can't initialized movie \"", tmpFileName,
    2011                 "\": ", context.remark(), (char *)NULL);
    2012         return TCL_ERROR;
     2011                "\": ", context.remark(), (char *)NULL);
     2012        return TCL_ERROR;
    20132013    }
    20142014    if ((values.width != oldWidth) || (values.height != oldHeight)) {
    2015         // Resize to the requested size.
    2016         NanoVis::resize_offscreen_buffer(values.width, values.height);
     2015        // Resize to the requested size.
     2016        NanoVis::resize_offscreen_buffer(values.width, values.height);
    20172017    }
    20182018    // Now compute the line padding for the offscreen buffer.
     
    20242024    bool canceled = false;
    20252025    for (int i = 1; i <= values.nFrames; i++) {
    2026         if (((i & 0xF) == 0) && (poll(&pollResults, 1, 0) > 0)) {
    2027             /* If there's another command on stdin, that means the client is
    2028              * trying to cancel this operation. */
    2029             canceled = true;
    2030             break;
    2031         }
    2032         if (NanoVis::licRenderer->active()) {
    2033             NanoVis::licRenderer->convolve();
    2034         }
    2035         NanoVis::AdvectFlows();
    2036         NanoVis::offscreen_buffer_capture();
     2026        if (((i & 0xF) == 0) && (poll(&pollResults, 1, 0) > 0)) {
     2027            /* If there's another command on stdin, that means the client is
     2028             * trying to cancel this operation. */
     2029            canceled = true;
     2030            break;
     2031        }
     2032        if (NanoVis::licRenderer->active()) {
     2033            NanoVis::licRenderer->convolve();
     2034        }
     2035        NanoVis::AdvectFlows();
     2036        NanoVis::offscreen_buffer_capture();
    20372037        NanoVis::display();
    20382038        NanoVis::read_screen();
     
    20432043    Trace("FLOW end\n");
    20442044    if (!canceled) {
    2045         Rappture::Buffer data;
    2046 
    2047         /* FIXME: find a way to get the data from the movie object as a
    2048         * void* */
    2049         if (!data.load(context, tmpFileName)) {
    2050             Tcl_AppendResult(interp, "can't load data from temporary file \"",
    2051                 tmpFileName, "\": ", context.remark(), (char *)NULL);
    2052             return TCL_ERROR;
    2053         }
    2054 
    2055         char command[200];
    2056         sprintf(command,"nv>image -bytes %lu -type movie -token \"%s\"\n",
    2057                 (unsigned long)data.size(), token);
    2058         NanoVis::sendDataToClient(command, data.bytes(), data.size());
     2045        Rappture::Buffer data;
     2046
     2047        /* FIXME: find a way to get the data from the movie object as a
     2048        * void* */
     2049        if (!data.load(context, tmpFileName)) {
     2050            Tcl_AppendResult(interp, "can't load data from temporary file \"",
     2051                tmpFileName, "\": ", context.remark(), (char *)NULL);
     2052            return TCL_ERROR;
     2053        }
     2054
     2055        char command[200];
     2056        sprintf(command,"nv>image -bytes %lu -type movie -token \"%s\"\n",
     2057                (unsigned long)data.size(), token);
     2058        NanoVis::sendDataToClient(command, data.bytes(), data.size());
    20592059    }
    20602060    if ((values.width != oldWidth) || (values.height != oldHeight)) {
    2061         NanoVis::resize_offscreen_buffer(oldWidth, oldHeight);
     2061        NanoVis::resize_offscreen_buffer(oldWidth, oldHeight);
    20622062    }
    20632063    NanoVis::ResetFlows();
    20642064    if (unlink(tmpFileName) != 0) {
    20652065        Tcl_AppendResult(interp, "can't unlink temporary movie file \"",
    2066                 tmpFileName, "\": ", Tcl_PosixError(interp), (char *)NULL);
    2067         return TCL_ERROR;
     2066                tmpFileName, "\": ", Tcl_PosixError(interp), (char *)NULL);
     2067        return TCL_ERROR;
    20682068    }
    20692069    return TCL_OK;
     
    20932093static int
    20942094FlowCmdProc(ClientData clientData, Tcl_Interp *interp, int objc,
    2095             Tcl_Obj *const *objv)
     2095            Tcl_Obj *const *objv)
    20962096{
    20972097    Tcl_ObjCmdProc *proc;
    20982098
    20992099    proc = Rappture::GetOpFromObj(interp, nFlowCmdOps, flowCmdOps,
    2100         Rappture::CMDSPEC_ARG1, objc, objv, 0);
     2100        Rappture::CMDSPEC_ARG1, objc, objv, 0);
    21012101    if (proc == NULL) {
    2102         return TCL_ERROR;
     2102        return TCL_ERROR;
    21032103    }
    21042104    return (*proc) (clientData, interp, objc, objv);
     
    21102110 * FlowCmdInitProc --
    21112111 *
    2112  *      This procedure is invoked to initialize the "tree" command.
     2112 *        This procedure is invoked to initialize the "tree" command.
    21132113 *
    21142114 * Results:
    2115  *      None.
     2115 *        None.
    21162116 *
    21172117 * Side effects:
    2118  *      Creates the new command and adds a new entry into a global Tcl
    2119  *      associative array.
     2118 *        Creates the new command and adds a new entry into a global Tcl
     2119 *        associative array.
    21202120 *
    21212121 *---------------------------------------------------------------------------
     
    21412141  if (line == endPtr) {
    21422142      vtkErrorMacro(<<"Premature EOF reading first line! " << " for file: "
    2143                     << (this->FileName?this->FileName:"(Null FileName)"));
     2143                    << (this->FileName?this->FileName:"(Null FileName)"));
    21442144      return false;
    21452145  }
    21462146  if (sscanf(line, "# vtk DataFile Version %s", version) != 1) {
    21472147      vtkErrorMacro(<< "Unrecognized file type: "<< line << " for file: "
    2148                     << (this->FileName?this->FileName:"(Null FileName)"));
     2148                    << (this->FileName?this->FileName:"(Null FileName)"));
    21492149      return false;
    21502150  }   
     
    21532153  if (line == endPtr) {
    21542154      vtkErrorMacro(<<"Premature EOF reading title! " << " for file: "
    2155                     << (this->FileName?this->FileName:"(Null FileName)"));
     2155                    << (this->FileName?this->FileName:"(Null FileName)"));
    21562156      return false;
    21572157  }
     
    21662166  if (line == endPtr) {
    21672167      vtkErrorMacro(<<"Premature EOF reading file type!" << " for file: "
    2168                     << (this->FileName?this->FileName:"(Null FileName)"));
     2168                    << (this->FileName?this->FileName:"(Null FileName)"));
    21692169      return false;
    21702170  }
     
    21762176  } else {
    21772177      vtkErrorMacro(<< "Unrecognized file type: "<< line << " for file: "
    2178                     << (this->FileName?this->FileName:"(Null FileName)"));
     2178                    << (this->FileName?this->FileName:"(Null FileName)"));
    21792179      _fileType = 0;
    21802180      return false;
     
    21852185  if (line == endPtr) {
    21862186      vtkErrorMacro(<<"Premature EOF reading file type!" << " for file: "
    2187                     << (this->FileName?this->FileName:"(Null FileName)"));
     2187                    << (this->FileName?this->FileName:"(Null FileName)"));
    21882188      return false;
    21892189  }
     
    21932193      line = getline(&p, endPtr);
    21942194      if (line == endPtr) {
    2195           // EOF
     2195          // EOF
    21962196      }
    21972197      type = GetWord(line, &endPtr);
    21982198      if (strncasecmp(word, "structured_grid", 15) == 0) {
    2199           vtkErrorMacro(<< "Cannot read dataset type: " << line);
    2200           return 1;
     2199          vtkErrorMacro(<< "Cannot read dataset type: " << line);
     2200          return 1;
    22012201      }
    22022202    // Read keyword and dimensions
  • trunk/packages/vizservers/nanovis/RpAVTranslate.h

    r1825 r1850  
    5353    size_t _height;
    5454    size_t _bitRate;
    55     float _frameRate;           // frames/seconds
     55    float _frameRate;                // frames/seconds
    5656    size_t _videoOutbufSize;
    5757    uint8_t *_videoOutbuf;
    5858
    5959    size_t width(void) {
    60         return _width;
     60        return _width;
    6161    }
    6262    void width(size_t width) {
    63         _width = width;
     63        _width = width;
    6464    }
    6565    size_t height(void) {
    66         return _width;
     66        return _width;
    6767    }
    6868    void height(size_t width) {
    69         _width = width;
     69        _width = width;
    7070    }
    7171    size_t bitRate(void) {
    72         return _bitRate;
     72        return _bitRate;
    7373    }
    7474    void bitRate(size_t bitRate) {
    75         _bitRate = bitRate;
     75        _bitRate = bitRate;
    7676    }
    7777    float frameRate(void) {
    78         return _frameRate;
     78        return _frameRate;
    7979    }
    8080    void frameRate(size_t frameRate) {
    81         _frameRate = frameRate;
     81        _frameRate = frameRate;
    8282    }
    8383    AVOutputFormat *_fmtPtr;
Note: See TracChangeset for help on using the changeset viewer.