Ignore:
Timestamp:
Aug 23, 2012 2:35:43 PM (12 years ago)
Author:
ldelgass
Message:

Add Box and Sphere shapes and commands to vtkvis.

Location:
trunk/packages/vizservers/vtkvis
Files:
6 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/vtkvis/Makefile.in

    r3125 r3148  
    8383                PPMWriter.cpp \
    8484                ReadBuffer.cpp \
     85                RpBox.cpp \
    8586                RpContour2D.cpp \
    8687                RpContour3D.cpp \
     
    9293                RpPolyData.cpp \
    9394                RpPseudoColor.cpp \
     95                RpShape.cpp \
     96                RpSphere.cpp \
    9497                RpStreamlines.cpp \
    9598                RpVolume.cpp \
     
    150153ReadBuffer.o: ReadBuffer.h Trace.h
    151154ResponseQueue.o: ResponseQueue.h Trace.h
     155RpBox.o: RpBox.h RpShape.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h Trace.h
    152156RpContour2D.o: RpContour2D.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h Trace.h
    153157RpContour3D.o: RpContour3D.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h ColorMap.h Trace.h
     
    159163RpPolyData.o: RpPolyData.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h Trace.h
    160164RpPseudoColor.o: RpPseudoColor.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h ColorMap.h Trace.h
     165RpShape.o: RpShape.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h Trace.h
     166RpSphere.o: RpSphere.h RpShape.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h Trace.h
    161167RpStreamlines.o: RpStreamlines.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h ColorMap.h Trace.h
    162168RpVolume.o: RpVolume.h RpVtkGraphicsObject.h RpVtkDataSet.h RpVtkRenderer.h ColorMap.h Trace.h
    163169RpVtkDataSet.o: RpVtkDataSet.h Trace.h
    164 RpVtkGraphicsObject.o: RpVtkGraphicsObject.h RpVtkRenderer.h RpVtkDataSet.h RpContour2D.h RpContour3D.h RpCutplane.h RpGlyphs.h RpHeightMap.h RpLIC.h RpMolecule.h RpPolyData.h RpPseudoColor.h RpStreamlines.h RpVolume.h ColorMap.h Trace.h
    165 RpVtkRenderer.o: RpVtkRenderer.h RpMath.h vtkRpCubeAxesActor2D.h RpVtkDataSet.h RpContour2D.h RpContour3D.h RpCutplane.h RpGlyphs.h RpHeightMap.h RpLIC.h RpMolecule.h RpPolyData.h RpPseudoColor.h RpStreamlines.h RpVolume.h ColorMap.h Trace.h
    166 RpVtkRendererCmd.o: RpVtkRenderer.h RpVtkRendererGraphicsObjs.h vtkRpCubeAxesActor2D.h RpVtkDataSet.h RpContour2D.h RpContour3D.h RpCutplane.h RpGlyphs.h RpHeightMap.h RpLIC.h RpMolecule.h RpPolyData.h RpPseudoColor.h RpStreamlines.h RpVolume.h ColorMap.h ReadBuffer.h ResponseQueue.h Trace.h CmdProc.h PPMWriter.h TGAWriter.h
     170RpVtkGraphicsObject.o: RpVtkGraphicsObject.h RpVtkRenderer.h RpVtkDataSet.h ColorMap.h Trace.h
     171RpVtkRenderer.o: RpVtkRenderer.h RpMath.h vtkRpCubeAxesActor2D.h RpVtkDataSet.h RpBox.h RpContour2D.h RpContour3D.h RpCutplane.h RpGlyphs.h RpHeightMap.h RpLIC.h RpMolecule.h RpPolyData.h RpPseudoColor.h RpSphere.h RpStreamlines.h RpVolume.h ColorMap.h Trace.h
     172RpVtkRendererCmd.o: RpVtkRenderer.h RpVtkRendererGraphicsObjs.h vtkRpCubeAxesActor2D.h RpVtkDataSet.h RpBox.h RpContour2D.h RpContour3D.h RpCutplane.h RpGlyphs.h RpHeightMap.h RpLIC.h RpMolecule.h RpPolyData.h RpPseudoColor.h RpSphere.h RpStreamlines.h RpVolume.h ColorMap.h ReadBuffer.h ResponseQueue.h Trace.h CmdProc.h PPMWriter.h TGAWriter.h
    167173RpVtkRendererGraphicsObjs.o: RpVtkRenderer.h RpVtkRendererGraphicsObjs.h RpVtkDataSet.h RpContour2D.h RpContour3D.h RpCutplane.h RpGlyphs.h RpHeightMap.h RpLIC.h RpMolecule.h RpPolyData.h RpPseudoColor.h RpStreamlines.h RpVolume.h ColorMap.h Trace.h
    168174RpVtkRenderServer.o: RpVtkRenderServer.h RpVtkRendererCmd.h RpVtkRenderer.h vtkRpAxisActor.h vtkRpCubeAxesActor.h vtkRpAxisActor2D.h vtkRpCubeAxesActor2D.h ReadBuffer.h ResponseQueue.h Trace.h PPMWriter.h TGAWriter.h
  • trunk/packages/vizservers/vtkvis/RpGlyphs.cpp

    r3106 r3148  
    181181#endif
    182182
     183    //setQuality(0.8);
     184}
     185
     186void Glyphs::setQuality(double quality)
     187{
     188    switch (_glyphShape) {
     189    case ARROW: {
     190        vtkSmartPointer<vtkArrowSource> arrow = vtkArrowSource::SafeDownCast(_glyphSource);
     191        int res = (int)(quality * 25);
     192        if (res < 5) res = 5;
     193        arrow->SetTipResolution(res);
     194        arrow->SetShaftResolution(res);
     195    }
     196        break;
     197    case CONE: {
     198        vtkSmartPointer<vtkConeSource> cone = vtkConeSource::SafeDownCast(_glyphSource);
     199        int res = (int)(quality * 25);
     200        if (res < 5) res = 5;
     201        cone->SetResolution(res);
     202    }
     203        break;
     204    case SPHERE: {
     205        vtkSmartPointer<vtkSphereSource> sphere = vtkSphereSource::SafeDownCast(_glyphSource);
     206        int res = (int)(quality * 50);
     207        if (res < 5) res = 5;
     208        sphere->SetThetaResolution(res);
     209        sphere->SetPhiResolution(res);
     210    }
     211        break;
     212    case CYLINDER: {
     213        assert (vtkTransformPolyDataFilter::SafeDownCast(_glyphSource) != NULL);
     214        assert (vtkTransformPolyDataFilter::SafeDownCast(_glyphSource)->GetInput() != NULL);
     215        TRACE("gsource input: %s", vtkTransformPolyDataFilter::SafeDownCast(_glyphSource)->GetInput()->GetClassName());
     216        vtkSmartPointer<vtkCylinderSource> csource = vtkCylinderSource::SafeDownCast(vtkTransformPolyDataFilter::SafeDownCast(_glyphSource)->GetInput()->GetProducerPort());
     217        int res = (int)(quality * 25);
     218        if (res < 5) res = 5;
     219        csource->SetResolution(res);
     220    }
     221        break;
     222    default:
     223        break;
     224    }
    183225}
    184226
  • trunk/packages/vizservers/vtkvis/RpGlyphs.h

    r3095 r3148  
    7777    virtual void setClippingPlanes(vtkPlaneCollection *planes);
    7878
     79    void setQuality(double quality);
     80
    7981    void setOrient(bool state);
    8082
  • trunk/packages/vizservers/vtkvis/RpPolyData.cpp

    r2641 r3148  
    2727    VtkGraphicsObject()
    2828{
    29     _color[0] = 0.0f;
    30     _color[1] = 0.0f;
    31     _color[2] = 1.0f;
    3229}
    3330
  • trunk/packages/vizservers/vtkvis/RpVtkGraphicsObject.h

    r3131 r3148  
    7070     */
    7171    virtual const char *getClassName() const = 0;
    72 
    73     /**
    74      * \brief Specify input DataSet
    75      *
    76      * Default implementation calls update()
    77      *
    78      * \param[in] dataSet DataSet to use in rendering
    79      */
    80     virtual void setDataSet(DataSet *dataSet)
    81     {
    82         if (_dataSet != dataSet) {
    83             _dataSet = dataSet;
    84 
    85             update();
    86         }
    87     }
    8872
    8973    /**
  • trunk/packages/vizservers/vtkvis/RpVtkRenderer.cpp

    r3138 r3148  
    141141{
    142142    TRACE("Enter");
     143    TRACE("Deleting Boxes");
     144    for (BoxHashmap::iterator itr = _boxes.begin();
     145         itr != _boxes.end(); ++itr) {
     146        delete itr->second;
     147    }
     148    _boxes.clear();
    143149    TRACE("Deleting Contour2Ds");
    144150    for (Contour2DHashmap::iterator itr = _contour2Ds.begin();
     
    195201    }
    196202    _pseudoColors.clear();
     203    TRACE("Deleting Spheres");
     204    for (SphereHashmap::iterator itr = _spheres.begin();
     205         itr != _spheres.end(); ++itr) {
     206        delete itr->second;
     207    }
     208    _spheres.clear();
    197209    TRACE("Deleting Streamlines");
    198210    for (StreamlinesHashmap::iterator itr = _streamlines.begin();
     
    553565
    554566    _cubeAxesActor2D->ScalingOff();
    555     //_cubeAxesActor2D->SetShowActualBounds(0);
     567    _cubeAxesActor2D->SetShowActualBounds(1);
    556568    _cubeAxesActor2D->SetFontFactor(1.25);
    557569    // Use "nice" range and number of ticks/labels
     
    20242036    double offsetX = pxOffsetX * pxToWorld;
    20252037    double offsetY = pxOffsetY * pxToWorld;
     2038    double plotWidthWorld = imgWidthPx * pxToWorld;
     2039    double plotHeightWorld = imgHeightPx * pxToWorld;
    20262040
    20272041    TRACE("Window: %d %d", _windowWidth, _windowHeight);
     
    20582072        _cameraClipPlanes[1]->SetNormal(1, 0, 0);
    20592073        // top
    2060         _cameraClipPlanes[2]->SetOrigin(0, _imgWorldOrigin[1] + _imgWorldDims[1], 0);
     2074        _cameraClipPlanes[2]->SetOrigin(0, _imgWorldOrigin[1] + plotHeightWorld, 0);
    20612075        _cameraClipPlanes[2]->SetNormal(0, -1, 0);
    20622076        // right
    2063         _cameraClipPlanes[3]->SetOrigin(_imgWorldOrigin[0] + _imgWorldDims[0], 0, 0);
     2077        _cameraClipPlanes[3]->SetOrigin(_imgWorldOrigin[0] + plotWidthWorld, 0, 0);
    20642078        _cameraClipPlanes[3]->SetNormal(-1, 0, 0);
    2065         _cubeAxesActor2D->SetBounds(_imgWorldOrigin[0], _imgWorldOrigin[0] + _imgWorldDims[0],
    2066                                     _imgWorldOrigin[1], _imgWorldOrigin[1] + _imgWorldDims[1],
     2079        _cubeAxesActor2D->SetBounds(_imgWorldOrigin[0], _imgWorldOrigin[0] + plotWidthWorld,
     2080                                    _imgWorldOrigin[1], _imgWorldOrigin[1] + plotHeightWorld,
    20672081                                    _imgCameraOffset, _imgCameraOffset);
    20682082        _cubeAxesActor2D->XAxisVisibilityOn();
     
    20812095        _cameraClipPlanes[1]->SetNormal(0, 0, 1);
    20822096        // top
    2083         _cameraClipPlanes[2]->SetOrigin(0, _imgWorldOrigin[1] + _imgWorldDims[1], 0);
     2097        _cameraClipPlanes[2]->SetOrigin(0, _imgWorldOrigin[1] + plotHeightWorld, 0);
    20842098        _cameraClipPlanes[2]->SetNormal(0, -1, 0);
    20852099        // right
    2086         _cameraClipPlanes[3]->SetOrigin(0, 0, _imgWorldOrigin[0] + _imgWorldDims[0]);
     2100        _cameraClipPlanes[3]->SetOrigin(0, 0, _imgWorldOrigin[0] + plotWidthWorld);
    20872101        _cameraClipPlanes[3]->SetNormal(0, 0, -1);
    20882102        _cubeAxesActor2D->SetBounds(_imgCameraOffset, _imgCameraOffset,
    2089                                     _imgWorldOrigin[1], _imgWorldOrigin[1] + _imgWorldDims[1],
    2090                                     _imgWorldOrigin[0], _imgWorldOrigin[0] + _imgWorldDims[0]);
     2103                                    _imgWorldOrigin[1], _imgWorldOrigin[1] + plotHeightWorld,
     2104                                    _imgWorldOrigin[0], _imgWorldOrigin[0] + plotWidthWorld);
    20912105        _cubeAxesActor2D->XAxisVisibilityOff();
    20922106        _cubeAxesActor2D->YAxisVisibilityOn();
     
    21042118        _cameraClipPlanes[1]->SetNormal(1, 0, 0);
    21052119        // top
    2106         _cameraClipPlanes[2]->SetOrigin(0, 0, _imgWorldOrigin[1] + _imgWorldDims[1]);
     2120        _cameraClipPlanes[2]->SetOrigin(0, 0, _imgWorldOrigin[1] + plotHeightWorld);
    21072121        _cameraClipPlanes[2]->SetNormal(0, 0, -1);
    21082122        // right
    2109         _cameraClipPlanes[3]->SetOrigin(_imgWorldOrigin[0] + _imgWorldDims[0], 0, 0);
     2123        _cameraClipPlanes[3]->SetOrigin(_imgWorldOrigin[0] + plotWidthWorld, 0, 0);
    21102124        _cameraClipPlanes[3]->SetNormal(-1, 0, 0);
    2111         _cubeAxesActor2D->SetBounds(_imgWorldOrigin[0], _imgWorldOrigin[0] + _imgWorldDims[0],
     2125        _cubeAxesActor2D->SetBounds(_imgWorldOrigin[0], _imgWorldOrigin[0] + plotWidthWorld,
    21122126                                    _imgCameraOffset, _imgCameraOffset,
    2113                                     _imgWorldOrigin[1], _imgWorldOrigin[1] + _imgWorldDims[1]);
     2127                                    _imgWorldOrigin[1], _imgWorldOrigin[1] + plotHeightWorld);
    21142128        _cubeAxesActor2D->XAxisVisibilityOn();
    21152129        _cubeAxesActor2D->YAxisVisibilityOff();
     
    22942308            mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds());
    22952309    }
     2310    for (BoxHashmap::iterator itr = _boxes.begin();
     2311             itr != _boxes.end(); ++itr) {
     2312        if ((!onlyVisible || itr->second->getVisibility()) &&
     2313            itr->second->getProp() != NULL)
     2314            mergeBounds(bounds, bounds, itr->second->getBounds());
     2315    }
    22962316    for (Contour2DHashmap::iterator itr = _contour2Ds.begin();
    22972317             itr != _contour2Ds.end(); ++itr) {
     
    23442364    for (PseudoColorHashmap::iterator itr = _pseudoColors.begin();
    23452365             itr != _pseudoColors.end(); ++itr) {
     2366        if ((!onlyVisible || itr->second->getVisibility()) &&
     2367            itr->second->getProp() != NULL)
     2368            mergeBounds(bounds, bounds, itr->second->getBounds());
     2369    }
     2370    for (SphereHashmap::iterator itr = _spheres.begin();
     2371             itr != _spheres.end(); ++itr) {
    23462372        if ((!onlyVisible || itr->second->getVisibility()) &&
    23472373            itr->second->getProp() != NULL)
     
    24192445            mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds());
    24202446    }
     2447    for (BoxHashmap::iterator itr = _boxes.begin();
     2448             itr != _boxes.end(); ++itr) {
     2449        if ((!onlyVisible || itr->second->getVisibility()) &&
     2450            itr->second->getProp() != NULL)
     2451            mergeBounds(bounds, bounds, itr->second->getUnscaledBounds());
     2452    }
    24212453    for (Contour2DHashmap::iterator itr = _contour2Ds.begin();
    24222454             itr != _contour2Ds.end(); ++itr) {
     
    24692501    for (PseudoColorHashmap::iterator itr = _pseudoColors.begin();
    24702502             itr != _pseudoColors.end(); ++itr) {
     2503        if ((!onlyVisible || itr->second->getVisibility()) &&
     2504            itr->second->getProp() != NULL)
     2505            mergeBounds(bounds, bounds, itr->second->getUnscaledBounds());
     2506    }
     2507    for (SphereHashmap::iterator itr = _spheres.begin();
     2508             itr != _spheres.end(); ++itr) {
    24712509        if ((!onlyVisible || itr->second->getVisibility()) &&
    24722510            itr->second->getProp() != NULL)
     
    33253363     * Mappers already using the PlaneCollection
    33263364     */
     3365    for (BoxHashmap::iterator itr = _boxes.begin();
     3366         itr != _boxes.end(); ++itr) {
     3367        itr->second->setClippingPlanes(_activeClipPlanes);
     3368    }
    33273369    for (Contour2DHashmap::iterator itr = _contour2Ds.begin();
    33283370         itr != _contour2Ds.end(); ++itr) {
     
    33593401    for (PseudoColorHashmap::iterator itr = _pseudoColors.begin();
    33603402         itr != _pseudoColors.end(); ++itr) {
     3403        itr->second->setClippingPlanes(_activeClipPlanes);
     3404    }
     3405    for (SphereHashmap::iterator itr = _spheres.begin();
     3406         itr != _spheres.end(); ++itr) {
    33613407        itr->second->setClippingPlanes(_activeClipPlanes);
    33623408    }
  • trunk/packages/vizservers/vtkvis/RpVtkRenderer.h

    r3145 r3148  
    3030#include "RpTypes.h"
    3131#include "RpVtkDataSet.h"
     32#include "RpBox.h"
    3233#include "RpContour2D.h"
    3334#include "RpContour3D.h"
     
    3940#include "RpPolyData.h"
    4041#include "RpPseudoColor.h"
     42#include "RpSphere.h"
    4143#include "RpStreamlines.h"
    4244#include "RpVolume.h"
     
    541543    typedef std::tr1::unordered_map<FieldId, double *> FieldRangeHashmap;
    542544    typedef std::tr1::unordered_map<ColorMapId, ColorMap *> ColorMapHashmap;
     545    typedef std::tr1::unordered_map<DataSetId, Box *> BoxHashmap;
    543546    typedef std::tr1::unordered_map<DataSetId, Contour2D *> Contour2DHashmap;
    544547    typedef std::tr1::unordered_map<DataSetId, Contour3D *> Contour3DHashmap;
     
    550553    typedef std::tr1::unordered_map<DataSetId, PolyData *> PolyDataHashmap;
    551554    typedef std::tr1::unordered_map<DataSetId, PseudoColor *> PseudoColorHashmap;
     555    typedef std::tr1::unordered_map<DataSetId, Sphere *> SphereHashmap;
    552556    typedef std::tr1::unordered_map<DataSetId, Streamlines *> StreamlinesHashmap;
    553557    typedef std::tr1::unordered_map<DataSetId, Volume *> VolumeHashmap;
     
    620624    ColorMapHashmap _colorMaps;
    621625    DataSetHashmap _dataSets;
     626    BoxHashmap _boxes;
    622627    Contour2DHashmap _contour2Ds;
    623628    Contour3DHashmap _contour3Ds;
     
    629634    PolyDataHashmap _polyDatas;
    630635    PseudoColorHashmap _pseudoColors;
     636    SphereHashmap _spheres;
    631637    StreamlinesHashmap _streamlines;
    632638    VolumeHashmap _volumes;
  • trunk/packages/vizservers/vtkvis/RpVtkRendererCmd.cpp

    r3145 r3148  
    360360
    361361    proc = Rappture::GetOpFromObj(interp, nAxisOps, axisOps,
     362                                  Rappture::CMDSPEC_ARG1, objc, objv, 0);
     363    if (proc == NULL) {
     364        return TCL_ERROR;
     365    }
     366    return (*proc) (clientData, interp, objc, objv);
     367}
     368
     369static int
     370BoxAddOp(ClientData clientData, Tcl_Interp *interp, int objc,
     371         Tcl_Obj *const *objv)
     372{
     373    const char *name = Tcl_GetString(objv[2]);
     374    if (!g_renderer->addGraphicsObject<Box>(name)) {
     375        Tcl_AppendResult(interp, "Failed to create box", (char*)NULL);
     376        return TCL_ERROR;
     377    }
     378    return TCL_OK;
     379}
     380
     381static int
     382BoxDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc,
     383            Tcl_Obj *const *objv)
     384{
     385    if (objc == 3) {
     386        const char *name = Tcl_GetString(objv[2]);
     387        g_renderer->deleteGraphicsObject<Box>(name);
     388    } else {
     389        g_renderer->deleteGraphicsObject<Box>("all");
     390    }
     391    return TCL_OK;
     392}
     393
     394static int
     395BoxColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     396           Tcl_Obj *const *objv)
     397{
     398    float color[3];
     399    if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK ||
     400        GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK ||
     401        GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) {
     402        return TCL_ERROR;
     403    }
     404    if (objc == 6) {
     405        const char *name = Tcl_GetString(objv[5]);
     406        g_renderer->setGraphicsObjectColor<Box>(name, color);
     407    } else {
     408        g_renderer->setGraphicsObjectColor<Box>("all", color);
     409    }
     410    return TCL_OK;
     411}
     412
     413static int
     414BoxEdgeVisibilityOp(ClientData clientData, Tcl_Interp *interp, int objc,
     415                    Tcl_Obj *const *objv)
     416{
     417    bool state;
     418    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     419        return TCL_ERROR;
     420    }
     421    if (objc == 4) {
     422        const char *name = Tcl_GetString(objv[3]);
     423        g_renderer->setGraphicsObjectEdgeVisibility<Box>(name, state);
     424    } else {
     425        g_renderer->setGraphicsObjectEdgeVisibility<Box>("all", state);
     426    }
     427    return TCL_OK;
     428}
     429
     430static int
     431BoxLightingOp(ClientData clientData, Tcl_Interp *interp, int objc,
     432              Tcl_Obj *const *objv)
     433{
     434    bool state;
     435    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     436        return TCL_ERROR;
     437    }
     438    if (objc == 4) {
     439        const char *name = Tcl_GetString(objv[3]);
     440        g_renderer->setGraphicsObjectLighting<Box>(name, state);
     441    } else {
     442        g_renderer->setGraphicsObjectLighting<Box>("all", state);
     443    }
     444    return TCL_OK;
     445}
     446
     447static int
     448BoxLineColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     449               Tcl_Obj *const *objv)
     450{
     451    float color[3];
     452    if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK ||
     453        GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK ||
     454        GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) {
     455        return TCL_ERROR;
     456    }
     457    if (objc == 6) {
     458        const char *name = Tcl_GetString(objv[5]);
     459        g_renderer->setGraphicsObjectEdgeColor<Box>(name, color);
     460    } else {
     461        g_renderer->setGraphicsObjectEdgeColor<Box>("all", color);
     462    }
     463    return TCL_OK;
     464}
     465
     466static int
     467BoxLineWidthOp(ClientData clientData, Tcl_Interp *interp, int objc,
     468               Tcl_Obj *const *objv)
     469{
     470    float width;
     471    if (GetFloatFromObj(interp, objv[2], &width) != TCL_OK) {
     472        return TCL_ERROR;
     473    }
     474    if (objc == 4) {
     475        const char *name = Tcl_GetString(objv[3]);
     476        g_renderer->setGraphicsObjectEdgeWidth<Box>(name, width);
     477    } else {
     478        g_renderer->setGraphicsObjectEdgeWidth<Box>("all", width);
     479    }
     480    return TCL_OK;
     481}
     482
     483static int
     484BoxMaterialOp(ClientData clientData, Tcl_Interp *interp, int objc,
     485              Tcl_Obj *const *objv)
     486{
     487    double ambient, diffuse, specCoeff, specPower;
     488    if (Tcl_GetDoubleFromObj(interp, objv[2], &ambient) != TCL_OK ||
     489        Tcl_GetDoubleFromObj(interp, objv[3], &diffuse) != TCL_OK ||
     490        Tcl_GetDoubleFromObj(interp, objv[4], &specCoeff) != TCL_OK ||
     491        Tcl_GetDoubleFromObj(interp, objv[5], &specPower) != TCL_OK) {
     492        return TCL_ERROR;
     493    }
     494
     495    if (objc == 7) {
     496        const char *name = Tcl_GetString(objv[6]);
     497        g_renderer->setGraphicsObjectAmbient<Box>(name, ambient);
     498        g_renderer->setGraphicsObjectDiffuse<Box>(name, diffuse);
     499        g_renderer->setGraphicsObjectSpecular<Box>(name, specCoeff, specPower);
     500    } else {
     501        g_renderer->setGraphicsObjectAmbient<Box>("all", ambient);
     502        g_renderer->setGraphicsObjectDiffuse<Box>("all", diffuse);
     503        g_renderer->setGraphicsObjectSpecular<Box>("all", specCoeff, specPower);
     504    }
     505    return TCL_OK;
     506}
     507
     508static int
     509BoxOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc,
     510             Tcl_Obj *const *objv)
     511{
     512    double opacity;
     513    if (Tcl_GetDoubleFromObj(interp, objv[2], &opacity) != TCL_OK) {
     514        return TCL_ERROR;
     515    }
     516    if (objc == 4) {
     517        const char *name = Tcl_GetString(objv[3]);
     518        g_renderer->setGraphicsObjectOpacity<Box>(name, opacity);
     519    } else {
     520        g_renderer->setGraphicsObjectOpacity<Box>("all", opacity);
     521    }
     522    return TCL_OK;
     523}
     524
     525static int
     526BoxOrientOp(ClientData clientData, Tcl_Interp *interp, int objc,
     527            Tcl_Obj *const *objv)
     528{
     529    double quat[4];
     530    if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK ||
     531        Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK ||
     532        Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK ||
     533        Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) {
     534        return TCL_ERROR;
     535    }
     536    if (objc == 7) {
     537        const char *name = Tcl_GetString(objv[6]);
     538        g_renderer->setGraphicsObjectOrientation<Box>(name, quat);
     539    } else {
     540        g_renderer->setGraphicsObjectOrientation<Box>("all", quat);
     541    }
     542    return TCL_OK;
     543}
     544
     545static int
     546BoxPositionOp(ClientData clientData, Tcl_Interp *interp, int objc,
     547              Tcl_Obj *const *objv)
     548{
     549    double pos[3];
     550    if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK ||
     551        Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK ||
     552        Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) {
     553        return TCL_ERROR;
     554    }
     555    if (objc == 6) {
     556        const char *name = Tcl_GetString(objv[5]);
     557        g_renderer->setGraphicsObjectPosition<Box>(name, pos);
     558    } else {
     559        g_renderer->setGraphicsObjectPosition<Box>("all", pos);
     560    }
     561    return TCL_OK;
     562}
     563
     564static int
     565BoxScaleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     566           Tcl_Obj *const *objv)
     567{
     568    double scale[3];
     569    if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK ||
     570        Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK ||
     571        Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) {
     572        return TCL_ERROR;
     573    }
     574    if (objc == 6) {
     575        const char *name = Tcl_GetString(objv[5]);
     576        g_renderer->setGraphicsObjectScale<Box>(name, scale);
     577    } else {
     578        g_renderer->setGraphicsObjectScale<Box>("all", scale);
     579    }
     580    return TCL_OK;
     581}
     582
     583static int
     584BoxVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     585             Tcl_Obj *const *objv)
     586{
     587    bool state;
     588    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     589        return TCL_ERROR;
     590    }
     591    if (objc == 4) {
     592        const char *name = Tcl_GetString(objv[3]);
     593        g_renderer->setGraphicsObjectVisibility<Box>(name, state);
     594    } else {
     595        g_renderer->setGraphicsObjectVisibility<Box>("all", state);
     596    }
     597    return TCL_OK;
     598}
     599
     600static int
     601BoxWireframeOp(ClientData clientData, Tcl_Interp *interp, int objc,
     602               Tcl_Obj *const *objv)
     603{
     604    bool state;
     605    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     606        return TCL_ERROR;
     607    }
     608    if (objc == 4) {
     609        const char *name = Tcl_GetString(objv[3]);
     610        g_renderer->setGraphicsObjectWireframe<Box>(name, state);
     611    } else {
     612        g_renderer->setGraphicsObjectWireframe<Box>("all", state);
     613    }
     614    return TCL_OK;
     615}
     616
     617static Rappture::CmdSpec boxOps[] = {
     618    {"add",       1, BoxAddOp, 3, 3, "name"},
     619    {"color",     1, BoxColorOp, 5, 6, "r g b ?name?"},
     620    {"delete",    1, BoxDeleteOp, 2, 3, "?name?"},
     621    {"edges",     1, BoxEdgeVisibilityOp, 3, 4, "bool ?name?"},
     622    {"lighting",  3, BoxLightingOp, 3, 4, "bool ?name?"},
     623    {"linecolor", 5, BoxLineColorOp, 5, 6, "r g b ?name?"},
     624    {"linewidth", 5, BoxLineWidthOp, 3, 4, "width ?name?"},
     625    {"material",  1, BoxMaterialOp, 6, 7, "ambientCoeff diffuseCoeff specularCoeff specularPower ?name?"},
     626    {"opacity",   2, BoxOpacityOp, 3, 4, "value ?name?"},
     627    {"orient",    2, BoxOrientOp, 6, 7, "qw qx qy qz ?name?"},
     628    {"pos",       2, BoxPositionOp, 5, 6, "x y z ?name?"},
     629    {"scale",     1, BoxScaleOp, 5, 6, "sx sy sz ?name?"},
     630    {"visible",   1, BoxVisibleOp, 3, 4, "bool ?name?"},
     631    {"wireframe", 1, BoxWireframeOp, 3, 4, "bool ?name?"}
     632};
     633static int nBoxOps = NumCmdSpecs(boxOps);
     634
     635static int
     636BoxCmd(ClientData clientData, Tcl_Interp *interp, int objc,
     637       Tcl_Obj *const *objv)
     638{
     639    Tcl_ObjCmdProc *proc;
     640
     641    proc = Rappture::GetOpFromObj(interp, nBoxOps, boxOps,
    362642                                  Rappture::CMDSPEC_ARG1, objc, objv, 0);
    363643    if (proc == NULL) {
     
    40824362
    40834363static int
     4364PolyDataMaterialOp(ClientData clientData, Tcl_Interp *interp, int objc,
     4365                   Tcl_Obj *const *objv)
     4366{
     4367    double ambient, diffuse, specCoeff, specPower;
     4368    if (Tcl_GetDoubleFromObj(interp, objv[2], &ambient) != TCL_OK ||
     4369        Tcl_GetDoubleFromObj(interp, objv[3], &diffuse) != TCL_OK ||
     4370        Tcl_GetDoubleFromObj(interp, objv[4], &specCoeff) != TCL_OK ||
     4371        Tcl_GetDoubleFromObj(interp, objv[5], &specPower) != TCL_OK) {
     4372        return TCL_ERROR;
     4373    }
     4374
     4375    if (objc == 7) {
     4376        const char *name = Tcl_GetString(objv[6]);
     4377        g_renderer->setGraphicsObjectAmbient<PolyData>(name, ambient);
     4378        g_renderer->setGraphicsObjectDiffuse<PolyData>(name, diffuse);
     4379        g_renderer->setGraphicsObjectSpecular<PolyData>(name, specCoeff, specPower);
     4380    } else {
     4381        g_renderer->setGraphicsObjectAmbient<PolyData>("all", ambient);
     4382        g_renderer->setGraphicsObjectDiffuse<PolyData>("all", diffuse);
     4383        g_renderer->setGraphicsObjectSpecular<PolyData>("all", specCoeff, specPower);
     4384    }
     4385    return TCL_OK;
     4386}
     4387
     4388static int
    40844389PolyDataOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc,
    40854390                  Tcl_Obj *const *objv)
     
    42154520    {"linecolor", 5, PolyDataLineColorOp, 5, 6, "r g b ?dataSetName?"},
    42164521    {"linewidth", 5, PolyDataLineWidthOp, 3, 4, "width ?dataSetName?"},
     4522    {"material",  1, PolyDataMaterialOp, 6, 7, "ambientCoeff diffuseCoeff specularCoeff specularPower ?dataSetName?"},
    42174523    {"opacity",   2, PolyDataOpacityOp, 3, 4, "value ?dataSetName?"},
    42184524    {"orient",    2, PolyDataOrientOp, 6, 7, "qw qx qy qz ?dataSetName?"},
     
    46804986
    46814987    proc = Rappture::GetOpFromObj(interp, nScreenOps, screenOps,
     4988                                  Rappture::CMDSPEC_ARG1, objc, objv, 0);
     4989    if (proc == NULL) {
     4990        return TCL_ERROR;
     4991    }
     4992    return (*proc) (clientData, interp, objc, objv);
     4993}
     4994
     4995static int
     4996SphereAddOp(ClientData clientData, Tcl_Interp *interp, int objc,
     4997            Tcl_Obj *const *objv)
     4998{
     4999    const char *name = Tcl_GetString(objv[2]);
     5000    if (!g_renderer->addGraphicsObject<Sphere>(name)) {
     5001        Tcl_AppendResult(interp, "Failed to create box", (char*)NULL);
     5002        return TCL_ERROR;
     5003    }
     5004    return TCL_OK;
     5005}
     5006
     5007static int
     5008SphereDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc,
     5009               Tcl_Obj *const *objv)
     5010{
     5011    if (objc == 3) {
     5012        const char *name = Tcl_GetString(objv[2]);
     5013        g_renderer->deleteGraphicsObject<Sphere>(name);
     5014    } else {
     5015        g_renderer->deleteGraphicsObject<Sphere>("all");
     5016    }
     5017    return TCL_OK;
     5018}
     5019
     5020static int
     5021SphereColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     5022              Tcl_Obj *const *objv)
     5023{
     5024    float color[3];
     5025    if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK ||
     5026        GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK ||
     5027        GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) {
     5028        return TCL_ERROR;
     5029    }
     5030    if (objc == 6) {
     5031        const char *name = Tcl_GetString(objv[5]);
     5032        g_renderer->setGraphicsObjectColor<Sphere>(name, color);
     5033    } else {
     5034        g_renderer->setGraphicsObjectColor<Sphere>("all", color);
     5035    }
     5036    return TCL_OK;
     5037}
     5038
     5039static int
     5040SphereEdgeVisibilityOp(ClientData clientData, Tcl_Interp *interp, int objc,
     5041                       Tcl_Obj *const *objv)
     5042{
     5043    bool state;
     5044    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     5045        return TCL_ERROR;
     5046    }
     5047    if (objc == 4) {
     5048        const char *name = Tcl_GetString(objv[3]);
     5049        g_renderer->setGraphicsObjectEdgeVisibility<Sphere>(name, state);
     5050    } else {
     5051        g_renderer->setGraphicsObjectEdgeVisibility<Sphere>("all", state);
     5052    }
     5053    return TCL_OK;
     5054}
     5055
     5056static int
     5057SphereLightingOp(ClientData clientData, Tcl_Interp *interp, int objc,
     5058                 Tcl_Obj *const *objv)
     5059{
     5060    bool state;
     5061    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     5062        return TCL_ERROR;
     5063    }
     5064    if (objc == 4) {
     5065        const char *name = Tcl_GetString(objv[3]);
     5066        g_renderer->setGraphicsObjectLighting<Sphere>(name, state);
     5067    } else {
     5068        g_renderer->setGraphicsObjectLighting<Sphere>("all", state);
     5069    }
     5070    return TCL_OK;
     5071}
     5072
     5073static int
     5074SphereLineColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     5075                  Tcl_Obj *const *objv)
     5076{
     5077    float color[3];
     5078    if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK ||
     5079        GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK ||
     5080        GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) {
     5081        return TCL_ERROR;
     5082    }
     5083    if (objc == 6) {
     5084        const char *name = Tcl_GetString(objv[5]);
     5085        g_renderer->setGraphicsObjectEdgeColor<Sphere>(name, color);
     5086    } else {
     5087        g_renderer->setGraphicsObjectEdgeColor<Sphere>("all", color);
     5088    }
     5089    return TCL_OK;
     5090}
     5091
     5092static int
     5093SphereLineWidthOp(ClientData clientData, Tcl_Interp *interp, int objc,
     5094                  Tcl_Obj *const *objv)
     5095{
     5096    float width;
     5097    if (GetFloatFromObj(interp, objv[2], &width) != TCL_OK) {
     5098        return TCL_ERROR;
     5099    }
     5100    if (objc == 4) {
     5101        const char *name = Tcl_GetString(objv[3]);
     5102        g_renderer->setGraphicsObjectEdgeWidth<Sphere>(name, width);
     5103    } else {
     5104        g_renderer->setGraphicsObjectEdgeWidth<Sphere>("all", width);
     5105    }
     5106    return TCL_OK;
     5107}
     5108
     5109static int
     5110SphereMaterialOp(ClientData clientData, Tcl_Interp *interp, int objc,
     5111                 Tcl_Obj *const *objv)
     5112{
     5113    double ambient, diffuse, specCoeff, specPower;
     5114    if (Tcl_GetDoubleFromObj(interp, objv[2], &ambient) != TCL_OK ||
     5115        Tcl_GetDoubleFromObj(interp, objv[3], &diffuse) != TCL_OK ||
     5116        Tcl_GetDoubleFromObj(interp, objv[4], &specCoeff) != TCL_OK ||
     5117        Tcl_GetDoubleFromObj(interp, objv[5], &specPower) != TCL_OK) {
     5118        return TCL_ERROR;
     5119    }
     5120
     5121    if (objc == 7) {
     5122        const char *name = Tcl_GetString(objv[6]);
     5123        g_renderer->setGraphicsObjectAmbient<Sphere>(name, ambient);
     5124        g_renderer->setGraphicsObjectDiffuse<Sphere>(name, diffuse);
     5125        g_renderer->setGraphicsObjectSpecular<Sphere>(name, specCoeff, specPower);
     5126    } else {
     5127        g_renderer->setGraphicsObjectAmbient<Sphere>("all", ambient);
     5128        g_renderer->setGraphicsObjectDiffuse<Sphere>("all", diffuse);
     5129        g_renderer->setGraphicsObjectSpecular<Sphere>("all", specCoeff, specPower);
     5130    }
     5131    return TCL_OK;
     5132}
     5133
     5134static int
     5135SphereOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc,
     5136                Tcl_Obj *const *objv)
     5137{
     5138    double opacity;
     5139    if (Tcl_GetDoubleFromObj(interp, objv[2], &opacity) != TCL_OK) {
     5140        return TCL_ERROR;
     5141    }
     5142    if (objc == 4) {
     5143        const char *name = Tcl_GetString(objv[3]);
     5144        g_renderer->setGraphicsObjectOpacity<Sphere>(name, opacity);
     5145    } else {
     5146        g_renderer->setGraphicsObjectOpacity<Sphere>("all", opacity);
     5147    }
     5148    return TCL_OK;
     5149}
     5150
     5151static int
     5152SphereOrientOp(ClientData clientData, Tcl_Interp *interp, int objc,
     5153               Tcl_Obj *const *objv)
     5154{
     5155    double quat[4];
     5156    if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK ||
     5157        Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK ||
     5158        Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK ||
     5159        Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) {
     5160        return TCL_ERROR;
     5161    }
     5162    if (objc == 7) {
     5163        const char *name = Tcl_GetString(objv[6]);
     5164        g_renderer->setGraphicsObjectOrientation<Sphere>(name, quat);
     5165    } else {
     5166        g_renderer->setGraphicsObjectOrientation<Sphere>("all", quat);
     5167    }
     5168    return TCL_OK;
     5169}
     5170
     5171static int
     5172SpherePositionOp(ClientData clientData, Tcl_Interp *interp, int objc,
     5173                 Tcl_Obj *const *objv)
     5174{
     5175    double pos[3];
     5176    if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK ||
     5177        Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK ||
     5178        Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) {
     5179        return TCL_ERROR;
     5180    }
     5181    if (objc == 6) {
     5182        const char *name = Tcl_GetString(objv[5]);
     5183        g_renderer->setGraphicsObjectPosition<Sphere>(name, pos);
     5184    } else {
     5185        g_renderer->setGraphicsObjectPosition<Sphere>("all", pos);
     5186    }
     5187    return TCL_OK;
     5188}
     5189
     5190static int
     5191SphereScaleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     5192              Tcl_Obj *const *objv)
     5193{
     5194    double scale[3];
     5195    if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK ||
     5196        Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK ||
     5197        Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) {
     5198        return TCL_ERROR;
     5199    }
     5200    if (objc == 6) {
     5201        const char *name = Tcl_GetString(objv[5]);
     5202        g_renderer->setGraphicsObjectScale<Sphere>(name, scale);
     5203    } else {
     5204        g_renderer->setGraphicsObjectScale<Sphere>("all", scale);
     5205    }
     5206    return TCL_OK;
     5207}
     5208
     5209static int
     5210SphereVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     5211                Tcl_Obj *const *objv)
     5212{
     5213    bool state;
     5214    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     5215        return TCL_ERROR;
     5216    }
     5217    if (objc == 4) {
     5218        const char *name = Tcl_GetString(objv[3]);
     5219        g_renderer->setGraphicsObjectVisibility<Sphere>(name, state);
     5220    } else {
     5221        g_renderer->setGraphicsObjectVisibility<Sphere>("all", state);
     5222    }
     5223    return TCL_OK;
     5224}
     5225
     5226static int
     5227SphereWireframeOp(ClientData clientData, Tcl_Interp *interp, int objc,
     5228                  Tcl_Obj *const *objv)
     5229{
     5230    bool state;
     5231    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     5232        return TCL_ERROR;
     5233    }
     5234    if (objc == 4) {
     5235        const char *name = Tcl_GetString(objv[3]);
     5236        g_renderer->setGraphicsObjectWireframe<Sphere>(name, state);
     5237    } else {
     5238        g_renderer->setGraphicsObjectWireframe<Sphere>("all", state);
     5239    }
     5240    return TCL_OK;
     5241}
     5242
     5243static Rappture::CmdSpec sphereOps[] = {
     5244    {"add",       1, SphereAddOp, 3, 3, "name"},
     5245    {"color",     1, SphereColorOp, 5, 6, "r g b ?name?"},
     5246    {"delete",    1, SphereDeleteOp, 2, 3, "?name?"},
     5247    {"edges",     1, SphereEdgeVisibilityOp, 3, 4, "bool ?name?"},
     5248    {"lighting",  3, SphereLightingOp, 3, 4, "bool ?name?"},
     5249    {"linecolor", 5, SphereLineColorOp, 5, 6, "r g b ?name?"},
     5250    {"linewidth", 5, SphereLineWidthOp, 3, 4, "width ?name?"},
     5251    {"material",  1, SphereMaterialOp, 6, 7, "ambientCoeff diffuseCoeff specularCoeff specularPower ?name?"},
     5252    {"opacity",   2, SphereOpacityOp, 3, 4, "value ?name?"},
     5253    {"orient",    2, SphereOrientOp, 6, 7, "qw qx qy qz ?name?"},
     5254    {"pos",       2, SpherePositionOp, 5, 6, "x y z ?name?"},
     5255    {"scale",     1, SphereScaleOp, 5, 6, "sx sy sz ?name?"},
     5256    {"visible",   1, SphereVisibleOp, 3, 4, "bool ?name?"},
     5257    {"wireframe", 1, SphereWireframeOp, 3, 4, "bool ?name?"}
     5258};
     5259static int nSphereOps = NumCmdSpecs(sphereOps);
     5260
     5261static int
     5262SphereCmd(ClientData clientData, Tcl_Interp *interp, int objc,
     5263       Tcl_Obj *const *objv)
     5264{
     5265    Tcl_ObjCmdProc *proc;
     5266
     5267    proc = Rappture::GetOpFromObj(interp, nSphereOps, sphereOps,
    46825268                                  Rappture::CMDSPEC_ARG1, objc, objv, 0);
    46835269    if (proc == NULL) {
     
    60666652    Tcl_MakeSafe(interp);
    60676653    Tcl_CreateObjCommand(interp, "axis",        AxisCmd,        clientData, NULL);
     6654    Tcl_CreateObjCommand(interp, "box",         BoxCmd,         clientData, NULL);
    60686655    Tcl_CreateObjCommand(interp, "camera",      CameraCmd,      clientData, NULL);
    60696656    Tcl_CreateObjCommand(interp, "colormap",    ColorMapCmd,    clientData, NULL);
     
    60826669    Tcl_CreateObjCommand(interp, "renderer",    RendererCmd,    clientData, NULL);
    60836670    Tcl_CreateObjCommand(interp, "screen",      ScreenCmd,      clientData, NULL);
     6671    Tcl_CreateObjCommand(interp, "sphere",      SphereCmd,      clientData, NULL);
    60846672    Tcl_CreateObjCommand(interp, "streamlines", StreamlinesCmd, clientData, NULL);
    60856673    Tcl_CreateObjCommand(interp, "volume",      VolumeCmd,      clientData, NULL);
     
    60946682
    60956683    Tcl_DeleteCommand(interp, "axis");
     6684    Tcl_DeleteCommand(interp, "box");
    60966685    Tcl_DeleteCommand(interp, "camera");
    60976686    Tcl_DeleteCommand(interp, "colormap");
     
    61106699    Tcl_DeleteCommand(interp, "renderer");
    61116700    Tcl_DeleteCommand(interp, "screen");
     6701    Tcl_DeleteCommand(interp, "sphere");
    61126702    Tcl_DeleteCommand(interp, "streamlines");
    61136703    Tcl_DeleteCommand(interp, "volume");
  • trunk/packages/vizservers/vtkvis/RpVtkRendererGraphicsObjs.cpp

    r3145 r3148  
    1616#include "RpVtkRenderer.h"
    1717#include "RpVtkDataSet.h"
     18#include "RpBox.h"
    1819#include "RpContour2D.h"
    1920#include "RpContour3D.h"
     
    2526#include "RpPolyData.h"
    2627#include "RpPseudoColor.h"
     28#include "RpSphere.h"
    2729#include "RpStreamlines.h"
    2830#include "RpVolume.h"
     
    3537
    3638template<>
     39Renderer::BoxHashmap &
     40Renderer::getGraphicsObjectHashmap<Box>()
     41{ return _boxes; }
     42
     43template<>
    3744Renderer::Contour2DHashmap &
    3845Renderer::getGraphicsObjectHashmap<Contour2D>()
     
    8087
    8188template<>
     89Renderer::SphereHashmap &
     90Renderer::getGraphicsObjectHashmap<Sphere>()
     91{ return _spheres; }
     92
     93template<>
    8294Renderer::StreamlinesHashmap &
    8395Renderer::getGraphicsObjectHashmap<Streamlines>()
     
    93105Renderer::getGraphicsObjectHashmap<Warp>()
    94106{ return _warps; }
     107
     108template <>
     109bool Renderer::addGraphicsObject<Box>(const DataSetId& id)
     110{
     111    Box *gobj;
     112    if ((gobj = getGraphicsObject<Box>(id)) != NULL) {
     113        WARN("Replacing existing %s %s", gobj->getClassName(), id.c_str());
     114        deleteGraphicsObject<Box>(id);
     115    }
     116
     117    gobj = new Box();
     118 
     119    gobj->setDataSet(NULL, this);
     120
     121    if (gobj->getProp() == NULL &&
     122        gobj->getOverlayProp() == NULL) {
     123        delete gobj;
     124        return false;
     125    } else {
     126        if (gobj->getProp())
     127            _renderer->AddViewProp(gobj->getProp());
     128        if (gobj->getOverlayProp())
     129            _renderer->AddViewProp(gobj->getOverlayProp());
     130    }
     131
     132    getGraphicsObjectHashmap<Box>()[id] = gobj;
     133
     134    initCamera();
     135    _needsRedraw = true;
     136    return true;
     137}
     138
     139template <>
     140bool Renderer::addGraphicsObject<Sphere>(const DataSetId& id)
     141{
     142    Sphere *gobj;
     143    if ((gobj = getGraphicsObject<Sphere>(id)) != NULL) {
     144        WARN("Replacing existing %s %s", gobj->getClassName(), id.c_str());
     145        deleteGraphicsObject<Sphere>(id);
     146    }
     147
     148    gobj = new Sphere();
     149 
     150    gobj->setDataSet(NULL, this);
     151
     152    if (gobj->getProp() == NULL &&
     153        gobj->getOverlayProp() == NULL) {
     154        delete gobj;
     155        return false;
     156    } else {
     157        if (gobj->getProp())
     158            _renderer->AddViewProp(gobj->getProp());
     159        if (gobj->getOverlayProp())
     160            _renderer->AddViewProp(gobj->getOverlayProp());
     161    }
     162
     163    getGraphicsObjectHashmap<Sphere>()[id] = gobj;
     164
     165    initCamera();
     166    _needsRedraw = true;
     167    return true;
     168}
    95169
    96170/**
  • trunk/packages/vizservers/vtkvis/protocol.txt

    r3145 r3148  
    128128        Set the active vector field to plot
    129129dataset visible <bool> <?datasetName?>
     130
     131box add <name>
     132box color <r> <g> <b> <?name?>
     133box delete <?name?>
     134box edges <bool> <?name?>
     135box lighting <bool> <?name?>
     136box linecolor <r> <g> <b> <?name?>
     137box linewidth <val> <?name?>
     138box material <ambientCoeff> <diffuseCoeff> <specularCoeff> <specularExp>
     139box opacity <val> <?datasetName?>
     140box orient <qw> <qx> <qy> <qz> <?name?>
     141box pos <x> <y> <z> <?name?>
     142box scale <sx> <sy> <sz> <?name?>
     143box visible <bool> <?name?>
     144box wireframe <bool> <?name?>
    130145
    131146contour2d add numcontours <n> <?datasetName?>
     
    317332polydata linecolor <r> <g> <b> <?datasetName?>
    318333polydata linewidth <val> <?datasetName?>
     334polydata material <ambientCoeff> <diffuseCoeff> <specularCoeff> <specularExp>
    319335polydata opacity <val> <?datasetName?>
    320336polydata orient <qw> <qx> <qy> <qz> <?dataSetName?>
     
    345361pseudocolor visible <bool> <?datasetName?>
    346362pseudocolor wireframe <bool> <?datasetName?>
     363
     364sphere add <name>
     365sphere color <r> <g> <b> <?name?>
     366sphere delete <?name?>
     367sphere edges <bool> <?name?>
     368sphere lighting <bool> <?name?>
     369sphere linecolor <r> <g> <b> <?name?>
     370sphere linewidth <val> <?name?>
     371sphere material <ambientCoeff> <diffuseCoeff> <specularCoeff> <specularExp>
     372sphere opacity <val> <?datasetName?>
     373sphere orient <qw> <qx> <qy> <qz> <?name?>
     374sphere pos <x> <y> <z> <?name?>
     375sphere scale <sx> <sy> <sz> <?name?>
     376sphere visible <bool> <?name?>
     377sphere wireframe <bool> <?name?>
    347378
    348379streamlines add <?datasetName?>
Note: See TracChangeset for help on using the changeset viewer.