Ignore:
Timestamp:
Aug 17, 2011 12:13:00 AM (13 years ago)
Author:
ldelgass
Message:
  • Color mode for streamlines to allow color mapping by scalar or vector data
  • Set active scalar/vector arrays on data sets
  • Constant color option for glyphs/streamlines
  • Fixes for face culling (2 glyph shapes have flipped faces)

Note that these changes will require some fixes for cumulative ranges on multiple data sets as well as legend rendering.

Location:
trunk/packages/vizservers/vtkvis
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/vtkvis/RpGlyphs.cpp

    r2335 r2393  
    2929    VtkGraphicsObject(),
    3030    _glyphShape(ARROW),
    31     _scaleFactor(1.0)
    32 {
    33     _backfaceCulling = true;
     31    _scaleFactor(1.0),
     32    _colorMode(COLOR_BY_SCALAR)
     33{
     34    _faceCulling = true;
    3435}
    3536
     
    8182        return;
    8283    }
     84
     85    if (_glyphShape == ICOSAHEDRON ||
     86        _glyphShape == TETRAHEDRON) {
     87        // These shapes are created with front faces pointing inside
     88        setCullFace(CULL_FRONT);
     89    } else {
     90        setCullFace(CULL_BACK);
     91    }
     92
    8393    if (_glyphGenerator != NULL) {
    8494        _glyphGenerator->SetSourceConnection(_glyphSource->GetOutputPort());
     
    96106
    97107    vtkDataSet *ds = _dataSet->getVtkDataSet();
    98     double dataRange[2];
    99     _dataSet->getDataRange(dataRange);
    100108
    101109    if (_glyphGenerator == NULL) {
    102110        _glyphGenerator = vtkSmartPointer<vtkGlyph3D>::New();
    103111    }
     112
     113    initProp();
    104114
    105115    setGlyphShape(_glyphShape);
     
    134144
    135145    if (ds->GetPointData()->GetScalars() == NULL) {
     146        TRACE("Setting color mode to vector magnitude");
    136147        _glyphGenerator->SetColorModeToColorByVector();
    137     } else {
     148        _colorMode = COLOR_BY_VECTOR;
     149    } else {
     150        TRACE("Setting color mode to scalar");
    138151        _glyphGenerator->SetColorModeToColorByScalar();
    139      }
     152        _colorMode = COLOR_BY_SCALAR;
     153    }
    140154    if (_glyphShape == SPHERE) {
    141155        _glyphGenerator->OrientOff();
     
    166180
    167181    if (ds->GetPointData()->GetScalars() == NULL) {
    168         _pdMapper->UseLookupTableScalarRangeOff();
    169     } else {
     182        double dataRange[2];
     183        _dataSet->getVectorMagnitudeRange(dataRange);
    170184        _lut->SetRange(dataRange);
    171         _pdMapper->UseLookupTableScalarRangeOn();
    172     }
    173 
     185        //_pdMapper->SetScalarModeToUsePointFieldData();
     186        //_pdMapper->SelectColorArray(ds->GetPointData()->GetVectors()->GetName());
     187    } else {
     188        double dataRange[2];
     189        _dataSet->getDataRange(dataRange);
     190        _lut->SetRange(dataRange);
     191        //_pdMapper->SetScalarModeToDefault();
     192    }
     193
     194    //_lut->SetVectorModeToMagnitude();
    174195    _pdMapper->SetLookupTable(_lut);
    175 
    176     initProp();
     196    _pdMapper->UseLookupTableScalarRangeOn();
    177197
    178198    getActor()->SetMapper(_pdMapper);
     
    213233void Glyphs::setColorMode(ColorMode mode)
    214234{
     235    _colorMode = mode;
    215236    if (_glyphGenerator != NULL) {
    216237        switch (mode) {
    217238        case COLOR_BY_SCALE:
    218239            _glyphGenerator->SetColorModeToColorByScale();
    219             break;
    220         case COLOR_BY_VECTOR:
     240            _pdMapper->ScalarVisibilityOn();
     241            break;
     242        case COLOR_BY_VECTOR: {
    221243            _glyphGenerator->SetColorModeToColorByVector();
    222             break;
    223         case COLOR_BY_SCALAR:
     244           _pdMapper->ScalarVisibilityOn();
     245            double dataRange[2];
     246            _dataSet->getVectorMagnitudeRange(dataRange);
     247            _lut->SetRange(dataRange);
     248        }
     249            break;
     250        case COLOR_BY_SCALAR: {
     251            _glyphGenerator->SetColorModeToColorByScalar();
     252           _pdMapper->ScalarVisibilityOn();
     253            double dataRange[2];
     254            _dataSet->getDataRange(dataRange);
     255            _lut->SetRange(dataRange);
     256        }
     257            break;
     258        case COLOR_CONSTANT:
    224259        default:
    225             _glyphGenerator->SetColorModeToColorByScalar();
    226             break;
     260            _pdMapper->ScalarVisibilityOff();
    227261        }
    228262        _pdMapper->Update();
     
    261295    }
    262296
     297    switch (_colorMode) {
     298    case COLOR_BY_VECTOR: {
     299        double dataRange[2];
     300        _dataSet->getVectorMagnitudeRange(dataRange);
     301        _lut->SetRange(dataRange);
     302    }
     303        break;
     304    case COLOR_BY_SCALAR:
     305    default: {
     306        double dataRange[2];
     307        _dataSet->getDataRange(dataRange);
     308        _lut->SetRange(dataRange);
     309    }
     310        break;
     311    }
     312
    263313    if (_pdMapper != NULL) {
    264314        _pdMapper->SetLookupTable(_lut);
  • trunk/packages/vizservers/vtkvis/RpGlyphs.h

    r2335 r2393  
    5252        COLOR_BY_SCALE,
    5353        COLOR_BY_SCALAR,
    54         COLOR_BY_VECTOR
     54        COLOR_BY_VECTOR,
     55        COLOR_CONSTANT
    5556    };
    5657
     
    8283    GlyphShape _glyphShape;
    8384    double _scaleFactor;
     85    ColorMode _colorMode;
    8486
    8587    vtkSmartPointer<vtkLookupTable> _lut;
  • trunk/packages/vizservers/vtkvis/RpMolecule.cpp

    r2332 r2393  
    2929    _atomScaling(NO_ATOM_SCALING)
    3030{
    31     _backfaceCulling = true;
     31    _faceCulling = true;
    3232}
    3333
     
    4949    if (_atomProp == NULL) {
    5050        _atomProp = vtkSmartPointer<vtkActor>::New();
    51         if (_backfaceCulling && _opacity == 1.0)
    52             _atomProp->GetProperty()->BackfaceCullingOn();
     51        if (_faceCulling && _opacity == 1.0)
     52            setCulling(_atomProp->GetProperty(), true);
    5353        _atomProp->GetProperty()->EdgeVisibilityOff();
    5454        _atomProp->GetProperty()->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]);
     
    6161    if (_bondProp == NULL) {
    6262        _bondProp = vtkSmartPointer<vtkActor>::New();
    63         if (_backfaceCulling && _opacity == 1.0)
    64             _bondProp->GetProperty()->BackfaceCullingOn();
     63        if (_faceCulling && _opacity == 1.0)
     64            setCulling(_bondProp->GetProperty(), true);
    6565        _bondProp->GetProperty()->EdgeVisibilityOff();
    6666        _bondProp->GetProperty()->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]);
  • trunk/packages/vizservers/vtkvis/RpPolyData.cpp

    r2328 r2393  
    9191                vtkSmartPointer<vtkDelaunay2D> mesher = vtkSmartPointer<vtkDelaunay2D>::New();
    9292                mesher->SetInput(pd);
     93                mesher->ReleaseDataFlagOn();
     94                _pdMapper->SetInputConnection(mesher->GetOutputPort());
    9395#if defined(DEBUG) && defined(WANT_TRACE)
    9496                mesher->Update();
     
    100102                      outpd->GetNumberOfStrips());
    101103#endif
    102                 _pdMapper->SetInputConnection(mesher->GetOutputPort());
    103104            } else {
    104105                vtkSmartPointer<vtkDelaunay3D> mesher = vtkSmartPointer<vtkDelaunay3D>::New();
    105106                mesher->SetInput(pd);
     107                mesher->ReleaseDataFlagOn();
    106108                // Delaunay3D returns an UnstructuredGrid, so feed it through a surface filter
    107109                // to get the grid boundary as a PolyData
    108110                vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New();
    109111                gf->SetInputConnection(mesher->GetOutputPort());
     112                gf->ReleaseDataFlagOn();
    110113                _pdMapper->SetInputConnection(gf->GetOutputPort());
    111114            }
     
    116119    } else {
    117120        // DataSet is NOT a vtkPolyData
    118         WARN("DataSet is not a PolyData");
     121        TRACE("DataSet is not a PolyData");
    119122        vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New();
    120123        gf->SetInput(ds);
     124        gf->ReleaseDataFlagOn();
    121125        _pdMapper->SetInputConnection(gf->GetOutputPort());
    122126    }
  • trunk/packages/vizservers/vtkvis/RpStreamlines.cpp

    r2349 r2393  
    3535    VtkGraphicsObject(),
    3636    _lineType(LINES),
     37    _colorMode(COLOR_BY_VECTOR_MAGNITUDE),
    3738    _seedVisible(true)
    3839{
    39     _backfaceCulling = true;
     40    _faceCulling = true;
     41    _color[0] = 1.0f;
     42    _color[1] = 1.0f;
     43    _color[2] = 1.0f;
    4044    _seedColor[0] = 1.0f;
    4145    _seedColor[1] = 1.0f;
     
    5660    if (_linesActor == NULL) {
    5761        _linesActor = vtkSmartPointer<vtkActor>::New();
     62        _linesActor->GetProperty()->SetColor(_color[0], _color[1], _color[2]);
    5863        _linesActor->GetProperty()->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]);
    5964        _linesActor->GetProperty()->SetLineWidth(_edgeWidth);
     
    6469        switch (_lineType) {
    6570        case LINES:
    66             _linesActor->GetProperty()->BackfaceCullingOff();
     71            setCulling(_linesActor->GetProperty(), false);
    6772            _linesActor->GetProperty()->SetRepresentationToWireframe();
    6873            _linesActor->GetProperty()->EdgeVisibilityOff();
    6974            break;
    7075        case TUBES:
    71             if (_backfaceCulling && _opacity == 1.0)
    72                 _linesActor->GetProperty()->BackfaceCullingOn();
     76            if (_faceCulling && _opacity == 1.0)
     77                setCulling(_linesActor->GetProperty(), true);
    7378            _linesActor->GetProperty()->SetRepresentationToSurface();
    7479            _linesActor->GetProperty()->EdgeVisibilityOff();
    7580            break;
    7681        case RIBBONS:
    77             _linesActor->GetProperty()->BackfaceCullingOff();
     82            setCulling(_linesActor->GetProperty(), false);
    7883            _linesActor->GetProperty()->SetRepresentationToSurface();
    7984            _linesActor->GetProperty()->EdgeVisibilityOff();
     
    197202    vtkDataSet *ds = _dataSet->getVtkDataSet();
    198203    double dataRange[2];
    199     _dataSet->getDataRange(dataRange);
     204    _dataSet->getVectorMagnitudeRange(dataRange);
    200205    double bounds[6];
    201206    _dataSet->getBounds(bounds);
     
    215220    if (ds->GetPointData() == NULL ||
    216221        ds->GetPointData()->GetVectors() == NULL) {
    217         WARN("No vector point data found in DataSet %s", _dataSet->getName().c_str());
     222        TRACE("No vector point data found in DataSet %s", _dataSet->getName().c_str());
    218223        if (ds->GetCellData() == NULL ||
    219224            ds->GetCellData()->GetVectors() == NULL) {
     
    290295
    291296    _lut = vtkSmartPointer<vtkLookupTable>::New();
     297    _lut->SetRange(dataRange);
    292298    _lut->SetVectorModeToMagnitude();
    293299
     
    299305    }
    300306    _pdMapper->SetColorModeToMapScalars();
    301     _pdMapper->UseLookupTableScalarRangeOff();
     307    _pdMapper->UseLookupTableScalarRangeOn();
    302308    _pdMapper->SetLookupTable(_lut);
    303309
     
    693699        _pdMapper->SetInputConnection(_streamTracer->GetOutputPort());
    694700        _lineFilter = NULL;
    695         _linesActor->GetProperty()->BackfaceCullingOff();
     701        setCulling(_linesActor->GetProperty(), false);
    696702        _linesActor->GetProperty()->SetRepresentationToWireframe();
    697703        _linesActor->GetProperty()->LightingOff();
     
    720726        tubeFilter->SetRadius(radius);
    721727        _pdMapper->SetInputConnection(_lineFilter->GetOutputPort());
    722         if (_backfaceCulling && _opacity == 1.0)
    723             _linesActor->GetProperty()->BackfaceCullingOn();
     728        if (_faceCulling && _opacity == 1.0)
     729            setCulling(_linesActor->GetProperty(), true);
    724730        _linesActor->GetProperty()->SetRepresentationToSurface();
    725731        _linesActor->GetProperty()->LightingOn();
     
    747753        ribbonFilter->UseDefaultNormalOn();
    748754        _pdMapper->SetInputConnection(_lineFilter->GetOutputPort());
    749         _linesActor->GetProperty()->BackfaceCullingOff();
     755        setCulling(_linesActor->GetProperty(), false);
    750756        _linesActor->GetProperty()->SetRepresentationToSurface();
    751757        _linesActor->GetProperty()->LightingOn();
     758    }
     759}
     760
     761void Streamlines::setColorMode(ColorMode mode)
     762{
     763    _colorMode = mode;
     764    if (_dataSet == NULL || _pdMapper == NULL)
     765        return;
     766
     767    vtkDataSet *ds = _dataSet->getVtkDataSet();
     768
     769    switch (mode) {
     770    case COLOR_BY_SCALAR: {
     771        _pdMapper->ScalarVisibilityOn();
     772        _pdMapper->SetScalarModeToDefault();
     773        if (_lut != NULL) {
     774            double dataRange[2];
     775            _dataSet->getDataRange(dataRange);
     776            _lut->SetRange(dataRange);
     777        }
     778    }
     779        break;
     780    case COLOR_BY_VECTOR_MAGNITUDE: {
     781        _pdMapper->ScalarVisibilityOn();
     782        _pdMapper->SetScalarModeToUsePointFieldData();
     783        if (ds->GetPointData() != NULL &&
     784            ds->GetPointData()->GetVectors() != NULL) {
     785            _pdMapper->SelectColorArray(ds->GetPointData()->GetVectors()->GetName());
     786        }
     787        if (_lut != NULL) {
     788            double dataRange[2];
     789            _dataSet->getVectorMagnitudeRange(dataRange);
     790            TRACE("vmag range: %g %g", dataRange[0], dataRange[1]);
     791            _lut->SetRange(dataRange);
     792            _lut->SetVectorModeToMagnitude();
     793        }
     794    }
     795        break;
     796    case COLOR_BY_VECTOR_X:
     797        _pdMapper->ScalarVisibilityOn();
     798        _pdMapper->SetScalarModeToUsePointFieldData();
     799        if (ds->GetPointData() != NULL &&
     800            ds->GetPointData()->GetVectors() != NULL) {
     801            _pdMapper->SelectColorArray(ds->GetPointData()->GetVectors()->GetName());
     802        }
     803        if (_lut != NULL) {
     804            double dataRange[2];
     805            _dataSet->getVectorComponentRange(dataRange, 0);
     806            _lut->SetRange(dataRange);
     807            _lut->SetVectorModeToComponent();
     808            _lut->SetVectorComponent(0);
     809        }
     810        break;
     811    case COLOR_BY_VECTOR_Y:
     812        _pdMapper->ScalarVisibilityOn();
     813        _pdMapper->SetScalarModeToUsePointFieldData();
     814        if (ds->GetPointData() != NULL &&
     815            ds->GetPointData()->GetVectors() != NULL) {
     816            _pdMapper->SelectColorArray(ds->GetPointData()->GetVectors()->GetName());
     817        }
     818        if (_lut != NULL) {
     819            double dataRange[2];
     820            _dataSet->getVectorComponentRange(dataRange, 1);
     821            _lut->SetRange(dataRange);
     822            _lut->SetVectorModeToComponent();
     823            _lut->SetVectorComponent(1);
     824        }
     825        break;
     826    case COLOR_BY_VECTOR_Z:
     827        _pdMapper->ScalarVisibilityOn();
     828        _pdMapper->SetScalarModeToUsePointFieldData();
     829        if (ds->GetPointData() != NULL &&
     830            ds->GetPointData()->GetVectors() != NULL) {
     831            _pdMapper->SelectColorArray(ds->GetPointData()->GetVectors()->GetName());
     832        }
     833        if (_lut != NULL) {
     834            double dataRange[2];
     835            _dataSet->getVectorComponentRange(dataRange, 2);
     836            TRACE("vz range: %g %g", dataRange[0], dataRange[1]);
     837            _lut->SetRange(dataRange);
     838            _lut->SetVectorModeToComponent();
     839            _lut->SetVectorComponent(2);
     840        }
     841        break;
     842    case COLOR_CONSTANT:
     843    default:
     844        _pdMapper->ScalarVisibilityOff();
     845        break;
    752846    }
    753847}
     
    772866    }
    773867
    774     _lut->SetVectorModeToMagnitude();
     868    switch (_colorMode) {
     869    case COLOR_BY_VECTOR_MAGNITUDE: {
     870        double dataRange[2];
     871        _dataSet->getVectorMagnitudeRange(dataRange);
     872        _lut->SetVectorModeToMagnitude();
     873        _lut->SetRange(dataRange);
     874    }
     875        break;
     876    case COLOR_BY_VECTOR_X: {
     877        double dataRange[2];
     878        _dataSet->getVectorComponentRange(dataRange, 0);
     879        _lut->SetVectorModeToComponent();
     880        _lut->SetVectorComponent(0);
     881        _lut->SetRange(dataRange);
     882    }
     883        break;
     884    case COLOR_BY_VECTOR_Y: {
     885        double dataRange[2];
     886        _dataSet->getVectorComponentRange(dataRange, 1);
     887        _lut->SetVectorModeToComponent();
     888        _lut->SetVectorComponent(1);
     889        _lut->SetRange(dataRange);
     890    }
     891        break;
     892    case COLOR_BY_VECTOR_Z: {
     893        double dataRange[2];
     894        _dataSet->getVectorComponentRange(dataRange, 2);
     895        _lut->SetVectorModeToComponent();
     896        _lut->SetVectorComponent(2);
     897        _lut->SetRange(dataRange);
     898    }
     899        break;
     900    default:
     901         break;
     902    }
    775903
    776904    if (_pdMapper != NULL) {
     
    798926        _linesActor->GetProperty()->SetOpacity(_opacity);
    799927        if (_opacity < 1.0)
    800             _linesActor->GetProperty()->BackfaceCullingOff();
    801         else if (_backfaceCulling && _lineType == TUBES)
    802             _linesActor->GetProperty()->BackfaceCullingOn();
     928            setCulling(_linesActor->GetProperty(), false);
     929        else if (_faceCulling && _lineType == TUBES)
     930            setCulling(_linesActor->GetProperty(), true);
    803931    }
    804932    if (_seedActor != NULL) {
     
    860988/**
    861989 * \brief Set RGB color of stream lines
     990 */
     991void Streamlines::setColor(float color[3])
     992{
     993    _color[0] = color[0];
     994    _color[1] = color[1];
     995    _color[2] = color[2];
     996    if (_linesActor != NULL)
     997        _linesActor->GetProperty()->SetColor(_color[0], _color[1], _color[2]);
     998}
     999
     1000/**
     1001 * \brief Set RGB color of stream line edges
    8621002 */
    8631003void Streamlines::setEdgeColor(float color[3])
  • trunk/packages/vizservers/vtkvis/RpStreamlines.h

    r2349 r2393  
    3535        RIBBONS
    3636    };
     37    enum ColorMode {
     38        COLOR_BY_SCALAR,
     39        COLOR_BY_VECTOR_MAGNITUDE,
     40        COLOR_BY_VECTOR_X,
     41        COLOR_BY_VECTOR_Y,
     42        COLOR_BY_VECTOR_Z,
     43        COLOR_CONSTANT
     44    };
    3745
    3846    Streamlines();
     
    5159
    5260    virtual bool getVisibility();
     61
     62    virtual void setColor(float color[3]);
    5363
    5464    virtual void setEdgeVisibility(bool state);
     
    8393    void setLineTypeToRibbons(double width, double angle);
    8494
     95    void setColorMode(ColorMode mode);
     96
    8597    void setLookupTable(vtkLookupTable *lut);
    8698
     
    107119
    108120    LineType _lineType;
     121    ColorMode _colorMode;
     122    float _color[3];
    109123    float _seedColor[3];
    110124    bool _seedVisible;
  • trunk/packages/vizservers/vtkvis/RpVtkDataSet.cpp

    r2379 r2393  
    242242 * \brief Set the ative scalar array to the named field
    243243 */
    244 bool DataSet::setActiveScalar(const char *name)
     244bool DataSet::setActiveScalars(const char *name)
    245245{
    246246    bool found = false;
     
    261261 * \brief Set the ative vector array to the named field
    262262 */
    263 bool DataSet::setActiveVector(const char *name)
     263bool DataSet::setActiveVectors(const char *name)
    264264{
    265265    bool found = false;
  • trunk/packages/vizservers/vtkvis/RpVtkDataSet.h

    r2332 r2393  
    4545    const char *getVtkType() const;
    4646
    47     bool setActiveScalar(const char *name);
     47    bool setActiveScalars(const char *name);
    4848
    49     bool setActiveVector(const char *name);
     49    bool setActiveVectors(const char *name);
    5050
    5151    void getDataRange(double minmax[2]) const;
  • trunk/packages/vizservers/vtkvis/RpVtkGraphicsObject.h

    r2332 r2393  
    3636class VtkGraphicsObject {
    3737public:
     38    enum CullFace {
     39        CULL_FRONT,
     40        CULL_BACK,
     41        CULL_FRONT_AND_BACK
     42    };
     43
    3844    VtkGraphicsObject() :
    3945        _dataSet(NULL),
     
    4147        _edgeWidth(1.0f),
    4248        _lighting(true),
    43         _backfaceCulling(false)
     49        _cullFace(CULL_BACK),
     50        _faceCulling(false)
    4451    {
    4552        _color[0] = 1.0f;
     
    139146        if (getProp3D() != NULL) {
    140147            getProp3D()->SetUserMatrix(matrix);
     148        }
     149    }
     150
     151    /**
     152     * \brief Set the prop center of rotation
     153     *
     154     * \param[in] origin The point about which the object rotates
     155     */
     156    virtual void setOrigin(double origin[3])
     157    {
     158        if (getProp3D() != NULL) {
     159            getProp3D()->SetOrigin(origin);
    141160        }
    142161    }
     
    156175            axis[1] = quat[2] / denom;
    157176            axis[2] = quat[3] / denom;
    158             getProp3D()->SetOrientation(0, 0, 0);
    159             getProp3D()->RotateWXYZ(angle, axis[0], axis[1], axis[2]);
     177            setOrientation(angle, axis);
    160178        }
    161179    }
     
    231249        if (getActor() != NULL) {
    232250            getActor()->GetProperty()->SetOpacity(opacity);
    233             if (_backfaceCulling && _opacity < 1.0) {
    234                 getActor()->GetProperty()->BackfaceCullingOff();
    235                 TRACE("Backface culling off");
    236             } else if (_backfaceCulling && _opacity == 1.0) {
    237                 getActor()->GetProperty()->BackfaceCullingOn();
    238                 TRACE("Backface culling on");
     251            if (_faceCulling && _opacity < 1.0) {
     252                setCulling(getActor()->GetProperty(), false);
     253                TRACE("Culling off");
     254            } else if (_faceCulling && _opacity == 1.0) {
     255                setCulling(getActor()->GetProperty(), true);
     256                TRACE("Culling on");
    239257            }
    240258        } else if (getAssembly() != NULL) {
     
    245263                if (vtkActor::SafeDownCast(prop) != NULL) {
    246264                    vtkActor::SafeDownCast(prop)->GetProperty()->SetOpacity(opacity);
    247                     if (_backfaceCulling && _opacity < 1.0) {
    248                         vtkActor::SafeDownCast(prop)->GetProperty()->BackfaceCullingOff();
    249                         TRACE("Backface culling off");
    250                     } else if (_backfaceCulling && _opacity == 1.0) {
    251                         vtkActor::SafeDownCast(prop)->GetProperty()->BackfaceCullingOn();
    252                         TRACE("Backface culling on");
     265                    if (_faceCulling && _opacity < 1.0) {
     266                        setCulling(vtkActor::SafeDownCast(prop)->GetProperty(), false);
     267                        TRACE("Culling off");
     268                    } else if (_faceCulling && _opacity == 1.0) {
     269                        setCulling(vtkActor::SafeDownCast(prop)->GetProperty(), true);
     270                        TRACE("Culling on");
    253271                    }
    254272                }
     
    573591
    574592    /**
    575      * \brief Toggle backface culling of prop
    576      */
    577     virtual void setBackfaceCulling(bool state)
    578     {
    579         _backfaceCulling = state;
     593     * \brief Convenience method to set culling state on a vtkProperty
     594     *
     595     * Note: Does not change the culling state flag of this VtkGraphicsObject
     596     */
     597    virtual void setCulling(vtkProperty *property, bool state)
     598    {
     599        switch (_cullFace) {
     600        case CULL_FRONT:
     601            property->SetFrontfaceCulling((state ? 1 : 0));
     602            property->BackfaceCullingOff();
     603            break;
     604        case CULL_BACK:
     605            property->SetBackfaceCulling((state ? 1 : 0));
     606            property->FrontfaceCullingOff();
     607            break;
     608        case CULL_FRONT_AND_BACK:
     609            property->SetBackfaceCulling((state ? 1 : 0));
     610            property->SetFrontfaceCulling((state ? 1 : 0));
     611            break;
     612        }
     613    }
     614
     615    /**
     616     * \brief Toggle culling of selected CullFace
     617     */
     618    virtual void setCulling(bool state)
     619    {
     620        _faceCulling = state;
    580621        if (state && _opacity < 1.0)
    581622            return;
    582623        if (getActor() != NULL) {
    583             getActor()->GetProperty()->SetBackfaceCulling((state ? 1 : 0));
     624            setCulling(getActor()->GetProperty(), state);
    584625         } else if (getAssembly() != NULL) {
    585626            vtkProp3DCollection *props = getAssembly()->GetParts();
     
    588629            while ((prop = props->GetNextProp3D()) != NULL) {
    589630                if (vtkActor::SafeDownCast(prop) != NULL) {
    590                     vtkActor::SafeDownCast(prop)->GetProperty()->SetBackfaceCulling((state ? 1 : 0));
    591                 }
    592             }
    593         }
     631                    setCulling(vtkActor::SafeDownCast(prop)->GetProperty(), state);
     632                }
     633            }
     634        }
     635    }
     636
     637    virtual void setCullFace(CullFace cull)
     638    {
     639        _cullFace = cull;
     640        setCulling(_faceCulling);
    594641    }
    595642
     
    613660            if (!_lighting)
    614661                property->LightingOff();
    615             if (_backfaceCulling && _opacity == 1.0) {
    616                 property->BackfaceCullingOn();
     662            if (_faceCulling && _opacity == 1.0) {
     663                setCulling(property, true);
    617664            }
    618665        }
     
    631678    float _edgeWidth;
    632679    bool _lighting;
    633     bool _backfaceCulling;
     680    CullFace _cullFace;
     681    bool _faceCulling;
    634682
    635683    vtkSmartPointer<vtkProp> _prop;
  • trunk/packages/vizservers/vtkvis/RpVtkRenderer.cpp

    r2352 r2393  
    687687}
    688688
     689bool Renderer::setDataSetActiveScalars(const DataSetId& id, const char *scalarName)
     690{
     691    DataSetHashmap::iterator itr;
     692
     693    bool doAll = false;
     694
     695    if (id.compare("all") == 0) {
     696        itr = _dataSets.begin();
     697        doAll = true;
     698    } else {
     699        itr = _dataSets.find(id);
     700    }
     701    if (itr == _dataSets.end()) {
     702        ERROR("DataSet not found: %s", id.c_str());
     703        return false;
     704    }
     705
     706    bool ret = true;
     707    do {
     708        if (!itr->second->setActiveScalars(scalarName)) {
     709            ret = false;
     710        }
     711    } while (doAll && ++itr != _dataSets.end());
     712
     713    if (ret) {
     714        collectDataRanges(_cumulativeDataRange, _cumulativeRangeOnlyVisible);
     715        updateRanges(_useCumulativeRange);
     716        _needsRedraw = true;
     717    }
     718
     719    return ret;
     720}
     721
     722bool Renderer::setDataSetActiveVectors(const DataSetId& id, const char *vectorName)
     723{
     724    DataSetHashmap::iterator itr;
     725
     726    bool doAll = false;
     727
     728    if (id.compare("all") == 0) {
     729        itr = _dataSets.begin();
     730        doAll = true;
     731    } else {
     732        itr = _dataSets.find(id);
     733    }
     734    if (itr == _dataSets.end()) {
     735        ERROR("DataSet not found: %s", id.c_str());
     736        return false;
     737    }
     738
     739    bool ret = true;
     740    do {
     741        if (!itr->second->setActiveVectors(vectorName)) {
     742            ret = false;
     743        }
     744    } while (doAll && ++itr != _dataSets.end());
     745
     746    if (ret) {
     747        collectDataRanges(_cumulativeDataRange, _cumulativeRangeOnlyVisible);
     748        updateRanges(_useCumulativeRange);
     749        _needsRedraw = true;
     750    }
     751
     752    return ret;
     753}
     754
    689755/**
    690756 * \brief Control whether the cumulative data range of datasets is used for
     
    23832449
    23842450/**
     2451 * \brief Set the RGB polygon color for the specified DataSet
     2452 */
     2453void Renderer::setGlyphsColor(const DataSetId& id, float color[3])
     2454{
     2455    GlyphsHashmap::iterator itr;
     2456
     2457    bool doAll = false;
     2458
     2459    if (id.compare("all") == 0) {
     2460        itr = _glyphs.begin();
     2461        doAll = true;
     2462    } else {
     2463        itr = _glyphs.find(id);
     2464    }
     2465    if (itr == _glyphs.end()) {
     2466        ERROR("Glyphs not found: %s", id.c_str());
     2467        return;
     2468    }
     2469
     2470    do {
     2471        itr->second->setColor(color);
     2472    } while (doAll && ++itr != _glyphs.end());
     2473
     2474    _needsRedraw = true;
     2475}
     2476
     2477/**
    23852478 * \brief Associate an existing named color map with a Glyphs for the given DataSet
    23862479 */
     
    52405333        ColorMap *cmap = getColorMap("default");
    52415334        lut->DeepCopy(cmap->getLookupTable());
    5242 #if 0
    5243         // Currently lookup table/scalar data range not used, colormap is used to
    5244         // color streamlines by vector magnitude
     5335
    52455336        if (_useCumulativeRange) {
    52465337            lut->SetRange(_cumulativeDataRange);
     
    52505341            lut->SetRange(range);
    52515342        }
    5252 #endif
    52535343        streamlines->setLookupTable(lut);
    52545344
     
    57545844
    57555845/**
     5846 * \brief Set the color mode for the specified DataSet
     5847 */
     5848void Renderer::setStreamlinesColorMode(const DataSetId& id, Streamlines::ColorMode mode)
     5849{
     5850    StreamlinesHashmap::iterator itr;
     5851
     5852    bool doAll = false;
     5853
     5854    if (id.compare("all") == 0) {
     5855        itr = _streamlines.begin();
     5856        doAll = true;
     5857    } else {
     5858        itr = _streamlines.find(id);
     5859    }
     5860    if (itr == _streamlines.end()) {
     5861        ERROR("Streamlines not found: %s", id.c_str());
     5862        return;
     5863    }
     5864
     5865    do {
     5866        itr->second->setColorMode(mode);
     5867    } while (doAll && ++itr != _streamlines.end());
     5868
     5869    _needsRedraw = true;
     5870}
     5871
     5872/**
    57565873 * \brief Associate an existing named color map with a Streamlines for the given DataSet
    57575874 */
     
    57905907        lut->DeepCopy(cmap->getLookupTable());
    57915908
    5792 #if 0
    57935909        if (_useCumulativeRange) {
    57945910            lut->SetRange(_cumulativeDataRange);
     
    58005916            }
    58015917        }
    5802 #endif
    58035918
    58045919        itr->second->setLookupTable(lut);
     
    58635978}
    58645979
     5980/**
     5981 * \brief Set the RGB color for the specified DataSet
     5982 */
     5983void Renderer::setStreamlinesColor(const DataSetId& id, float color[3])
     5984{
     5985    StreamlinesHashmap::iterator itr;
     5986
     5987    bool doAll = false;
     5988
     5989    if (id.compare("all") == 0) {
     5990        itr = _streamlines.begin();
     5991        doAll = true;
     5992    } else {
     5993        itr = _streamlines.find(id);
     5994    }
     5995    if (itr == _streamlines.end()) {
     5996        ERROR("Streamlines not found: %s", id.c_str());
     5997        return;
     5998    }
     5999
     6000    do {
     6001        itr->second->setColor(color);
     6002    } while (doAll && ++itr != _streamlines.end());
     6003
     6004    _needsRedraw = true;
     6005}
    58656006
    58666007/**
     
    64916632}
    64926633
    6493 inline void quaternionToMatrix4x4(double quat[4], vtkMatrix4x4& mat)
     6634inline void quaternionToMatrix4x4(const double quat[4], vtkMatrix4x4& mat)
    64946635{
    64956636    double ww = quat[0]*quat[0];
     
    65256666}
    65266667
    6527 inline void quaternionToTransposeMatrix4x4(double quat[4], vtkMatrix4x4& mat)
     6668inline void quaternionToTransposeMatrix4x4(const double quat[4], vtkMatrix4x4& mat)
    65286669{
    65296670    double ww = quat[0]*quat[0];
     
    65596700}
    65606701
    6561 inline double *quatMult(double q1[4], double q2[4], double result[4])
     6702inline double *quatMult(const double q1[4], const double q2[4], double result[4])
    65626703{
    65636704    double q1w = q1[0];
     
    65766717}
    65776718
    6578 inline double *quatConjugate(double quat[4], double result[4])
     6719inline double *quatConjugate(const double quat[4], double result[4])
    65796720{
    65806721    result[1] = -quat[1];
     
    65846725}
    65856726
    6586 inline double *quatReciprocal(double quat[4], double result[4])
     6727inline double *quatReciprocal(const double quat[4], double result[4])
    65876728{
    65886729    double denom =
     
    66036744}
    66046745
    6605 inline void copyQuat(double quat[4], double result[4])
     6746inline void copyQuat(const double quat[4], double result[4])
    66066747{
    66076748    memcpy(result, quat, sizeof(double)*4);
     
    66156756 * \param[in] absolute Is rotation absolute or relative?
    66166757 */
    6617 void Renderer::setCameraOrientation(double quat[4], bool absolute)
     6758void Renderer::setCameraOrientation(const double quat[4], bool absolute)
    66186759{
    66196760    if (_cameraMode == IMAGE)
     
    66236764    vtkSmartPointer<vtkMatrix4x4> rotMat = vtkSmartPointer<vtkMatrix4x4>::New();
    66246765
     6766    double q[4];
     6767    copyQuat(quat, q);
     6768
    66256769    if (absolute) {
    66266770        double abs[4];
    66276771        // Save absolute rotation
    6628         copyQuat(quat, abs);
     6772        copyQuat(q, abs);
    66296773        // Compute relative rotation
    6630         quatMult(quatReciprocal(_cameraOrientation), quat, quat);
     6774        quatMult(quatReciprocal(_cameraOrientation), q, q);
    66316775        // Store absolute rotation
    66326776        copyQuat(abs, _cameraOrientation);
    66336777    } else {
    66346778        // Compute new absolute rotation
    6635         quatMult(_cameraOrientation, quat, _cameraOrientation);
    6636     }
    6637 
    6638     quaternionToTransposeMatrix4x4(quat, *rotMat);
     6779        quatMult(_cameraOrientation, q, _cameraOrientation);
     6780    }
     6781
     6782    quaternionToTransposeMatrix4x4(q, *rotMat);
    66396783#ifdef DEBUG
    66406784    TRACE("Rotation matrix:\n %g %g %g\n %g %g %g\n %g %g %g",
     
    66696813 * \param[in] viewUp x,y,z up vector of camera
    66706814 */
    6671 void Renderer::setCameraOrientationAndPosition(double position[3],
    6672                                                double focalPoint[3],
    6673                                                double viewUp[3])
     6815void Renderer::setCameraOrientationAndPosition(const double position[3],
     6816                                               const double focalPoint[3],
     6817                                               const double viewUp[3])
    66746818{
    66756819    vtkSmartPointer<vtkCamera> camera = _renderer->GetActiveCamera();
     
    67356879}
    67366880
     6881void Renderer::resetCameraClippingRange()
     6882{
     6883    _renderer->ResetCameraClippingRange();
     6884}
     6885
    67376886/**
    67386887 * \brief Perform a relative rotation to current camera orientation
     
    68116960        }
    68126961
    6813         vtkSmartPointer<vtkCamera> camera = _renderer->GetActiveCamera();
    6814         double viewFocus[4], focalDepth, viewPoint[3];
    6815         double newPickPoint[4], oldPickPoint[4], motionVector[3];
    6816 
    6817         camera->GetFocalPoint(viewFocus);
    6818         computeWorldToDisplay(viewFocus[0], viewFocus[1], viewFocus[2],
    6819                               viewFocus);
    6820         focalDepth = viewFocus[2];
    6821 
    6822         computeDisplayToWorld(( x * 2. + 1.) * _windowWidth / 2.0,
    6823                               ( y * 2. + 1.) * _windowHeight / 2.0,
    6824                               focalDepth,
    6825                               newPickPoint);
    6826 
    6827         computeDisplayToWorld(_windowWidth / 2.0,
    6828                               _windowHeight / 2.0,
    6829                               focalDepth,
    6830                               oldPickPoint);
    6831 
    6832         // Camera motion is reversed
    6833         motionVector[0] = oldPickPoint[0] - newPickPoint[0];
    6834         motionVector[1] = oldPickPoint[1] - newPickPoint[1];
    6835         motionVector[2] = oldPickPoint[2] - newPickPoint[2];
    6836 
    6837         camera->GetFocalPoint(viewFocus);
    6838         camera->GetPosition(viewPoint);
    6839         camera->SetFocalPoint(motionVector[0] + viewFocus[0],
    6840                               motionVector[1] + viewFocus[1],
    6841                               motionVector[2] + viewFocus[2]);
    6842 
    6843         camera->SetPosition(motionVector[0] + viewPoint[0],
    6844                             motionVector[1] + viewPoint[1],
    6845                             motionVector[2] + viewPoint[2]);
    6846 
    6847         _renderer->ResetCameraClippingRange();
    6848         //computeScreenWorldCoords();
     6962        if (x != 0.0 || y != 0.0) {
     6963            vtkSmartPointer<vtkCamera> camera = _renderer->GetActiveCamera();
     6964            double viewFocus[4], focalDepth, viewPoint[3];
     6965            double newPickPoint[4], oldPickPoint[4], motionVector[3];
     6966
     6967            camera->GetFocalPoint(viewFocus);
     6968            computeWorldToDisplay(viewFocus[0], viewFocus[1], viewFocus[2],
     6969                                  viewFocus);
     6970            focalDepth = viewFocus[2];
     6971
     6972            computeDisplayToWorld(( x * 2. + 1.) * _windowWidth / 2.0,
     6973                                  ( y * 2. + 1.) * _windowHeight / 2.0,
     6974                                  focalDepth,
     6975                                  newPickPoint);
     6976
     6977            computeDisplayToWorld(_windowWidth / 2.0,
     6978                                  _windowHeight / 2.0,
     6979                                  focalDepth,
     6980                                  oldPickPoint);
     6981
     6982            // Camera motion is reversed
     6983            motionVector[0] = oldPickPoint[0] - newPickPoint[0];
     6984            motionVector[1] = oldPickPoint[1] - newPickPoint[1];
     6985            motionVector[2] = oldPickPoint[2] - newPickPoint[2];
     6986
     6987            camera->GetFocalPoint(viewFocus);
     6988            camera->GetPosition(viewPoint);
     6989            camera->SetFocalPoint(motionVector[0] + viewFocus[0],
     6990                                  motionVector[1] + viewFocus[1],
     6991                                  motionVector[2] + viewFocus[2]);
     6992
     6993            camera->SetPosition(motionVector[0] + viewPoint[0],
     6994                                motionVector[1] + viewPoint[1],
     6995                                motionVector[2] + viewPoint[2]);
     6996
     6997            _renderer->ResetCameraClippingRange();
     6998            //computeScreenWorldCoords();
     6999        }
    68497000    }
    68507001
     
    72947445        }
    72957446    }
    7296 #if 0
    7297     // Currently lookup table/scalar data range not used, colormap is used to
    7298     // color streamlines by vector magnitude
    72997447    for (StreamlinesHashmap::iterator itr = _streamlines.begin();
    73007448         itr != _streamlines.end(); ++itr) {
     
    73127460        }
    73137461    }
    7314 #endif
    73157462    for (VolumeHashmap::iterator itr = _volumes.begin();
    73167463         itr != _volumes.end(); ++itr) {
  • trunk/packages/vizservers/vtkvis/RpVtkRenderer.h

    r2351 r2393  
    108108    bool setDataFile(const DataSetId& id, const char *filename);
    109109
     110    bool setDataSetActiveScalars(const DataSetId& id, const char *scalarName);
     111
     112    bool setDataSetActiveVectors(const DataSetId& id, const char *vectorName);
     113
    110114    double getDataValueAtPixel(const DataSetId& id, int x, int y);
    111115
     
    142146    void resetCamera(bool resetOrientation = true);
    143147
     148    void resetCameraClippingRange();
     149
    144150    void setCameraZoomRegion(double x, double y, double width, double height);
    145151
     
    150156    void rotateCamera(double yaw, double pitch, double roll);
    151157
    152     void setCameraOrientation(double quat[4], bool absolute = true);
     158    void setCameraOrientation(const double quat[4], bool absolute = true);
    153159
    154160    void panCamera(double x, double y, bool absolute = true);
     
    156162    void zoomCamera(double z, bool absolute = true);
    157163
    158     void setCameraOrientationAndPosition(double position[3],
    159                                          double focalPoint[3],
    160                                          double viewUp[3]);
     164    void setCameraOrientationAndPosition(const double position[3],
     165                                         const double focalPoint[3],
     166                                         const double viewUp[3]);
    161167
    162168    void getCameraOrientationAndPosition(double position[3],
     
    314320    void setGlyphsScale(const DataSetId& id, double scale[3]);
    315321
     322    void setGlyphsColor(const DataSetId& id, float color[3]);
     323
    316324    void setGlyphsEdgeVisibility(const DataSetId& id, bool state);
    317325
     
    544552
    545553    void setStreamlinesScale(const DataSetId& id, double scale[3]);
     554
     555    void setStreamlinesColor(const DataSetId& id, float color[3]);
    546556
    547557    void setStreamlinesEdgeVisibility(const DataSetId& id, bool state);
     
    587597
    588598    void setStreamlinesSeedVisibility(const DataSetId& id, bool state);
     599
     600    void setStreamlinesColorMode(const DataSetId& id, Streamlines::ColorMode mode);
    589601
    590602    void setStreamlinesColorMap(const DataSetId& id, const ColorMapId& colorMapId);
  • trunk/packages/vizservers/vtkvis/RpVtkRendererCmd.cpp

    r2349 r2393  
    11571157static Rappture::CmdSpec contour3dOps[] = {
    11581158    {"add",       1, Contour3DAddOp, 4, 5, "oper value ?dataSetName?"},
    1159     {"color",     6, Contour3DColorOp, 5, 6, "r g b ?dataSetName?"},
    1160     {"colormap",  6, Contour3DColorMapOp, 3, 4, "colorMapName ?dataSetName?"},
     1159    {"ccolor",    2, Contour3DColorOp, 5, 6, "r g b ?dataSetName?"},
     1160    {"colormap",  2, Contour3DColorMapOp, 3, 4, "colorMapName ?dataSetName?"},
    11611161    {"delete",    1, Contour3DDeleteOp, 2, 3, "?dataSetName?"},
    11621162    {"edges",     1, Contour3DEdgeVisibilityOp, 3, 4, "bool ?dataSetName?"},
     
    11881188
    11891189static int
     1190DataSetActiveScalarsOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1191                       Tcl_Obj *const *objv)
     1192{
     1193    const char *scalarName = Tcl_GetString(objv[2]);
     1194    if (objc == 4) {
     1195        const char *name = Tcl_GetString(objv[3]);
     1196        if (!g_renderer->setDataSetActiveScalars(name, scalarName)) {
     1197            Tcl_AppendResult(interp, "scalar \"", scalarName,
     1198                         "\" not found", (char*)NULL);
     1199            return TCL_ERROR;
     1200        }
     1201    } else {
     1202        if (!g_renderer->setDataSetActiveScalars("all", scalarName)) {
     1203            Tcl_AppendResult(interp, "scalar \"", scalarName,
     1204                         "\" not found in one or more data sets", (char*)NULL);
     1205            return TCL_ERROR;
     1206        }
     1207    }
     1208    return TCL_OK;
     1209}
     1210
     1211static int
     1212DataSetActiveVectorsOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1213                       Tcl_Obj *const *objv)
     1214{
     1215    const char *vectorName = Tcl_GetString(objv[2]);
     1216    if (objc == 4) {
     1217        const char *name = Tcl_GetString(objv[3]);
     1218        if (!g_renderer->setDataSetActiveVectors(name, vectorName)) {
     1219            Tcl_AppendResult(interp, "vector \"", vectorName,
     1220                         "\" not found", (char*)NULL);
     1221            return TCL_ERROR;
     1222        }
     1223    } else {
     1224        if (!g_renderer->setDataSetActiveVectors("all", vectorName)) {
     1225            Tcl_AppendResult(interp, "vector \"", vectorName,
     1226                         "\" not found in one or more data sets", (char*)NULL);
     1227            return TCL_ERROR;
     1228        }
     1229    }
     1230    return TCL_OK;
     1231}
     1232
     1233static int
    11901234DataSetAddOp(ClientData clientData, Tcl_Interp *interp, int objc,
    11911235             Tcl_Obj *const *objv)
     
    13851429    {"maprange", 1, DataSetMapRangeOp, 3, 3, "value"},
    13861430    {"opacity",  1, DataSetOpacityOp, 3, 4, "value ?name?"},
    1387     {"visible",  1, DataSetVisibleOp, 3, 4, "bool ?name?"}
     1431    {"scalar",   1, DataSetActiveScalarsOp, 3, 4, "scalarName ?name?"},
     1432    {"vector",   2, DataSetActiveVectorsOp, 3, 4, "vectorName ?name?"},
     1433    {"visible",  2, DataSetVisibleOp, 3, 4, "bool ?name?"}
    13881434};
    13891435static int nDataSetOps = NumCmdSpecs(dataSetOps);
     
    14461492
    14471493static int
     1494GlyphsColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1495              Tcl_Obj *const *objv)
     1496{
     1497    float color[3];
     1498    if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK ||
     1499        GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK ||
     1500        GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) {
     1501        return TCL_ERROR;
     1502    }
     1503    if (objc == 6) {
     1504        const char *name = Tcl_GetString(objv[5]);
     1505        g_renderer->setGlyphsColor(name, color);
     1506    } else {
     1507        g_renderer->setGlyphsColor("all", color);
     1508    }
     1509    return TCL_OK;
     1510}
     1511
     1512static int
    14481513GlyphsColorMapOp(ClientData clientData, Tcl_Interp *interp, int objc,
    14491514                 Tcl_Obj *const *objv)
     
    14651530    Glyphs::ColorMode mode;
    14661531    const char *str = Tcl_GetString(objv[2]);
    1467     if (str[0] == 's' && strcmp(str, "scale") == 0) {
     1532    if (str[0] == 'c' && strcmp(str, "ccolor") == 0) {
     1533        mode = Glyphs::COLOR_CONSTANT;
     1534    } else if (str[0] == 's' && strcmp(str, "scale") == 0) {
    14681535        mode = Glyphs::COLOR_BY_SCALE;
    14691536    } else if (str[0] == 's' && strcmp(str, "scalar") == 0) {
     
    14731540    } else {
    14741541        Tcl_AppendResult(interp, "bad color mode option \"", str,
    1475                          "\": should be one of: 'scale', 'scalar', 'vector'", (char*)NULL);
     1542                         "\": should be one of: 'scale', 'scalar', 'vector', 'ccolor'", (char*)NULL);
    14761543        return TCL_ERROR;
    14771544    }
     
    17641831static Rappture::CmdSpec glyphsOps[] = {
    17651832    {"add",       1, GlyphsAddOp, 3, 4, "shape ?dataSetNme?"},
     1833    {"ccolor",    2, GlyphsColorOp, 5, 6, "r g b ?dataSetName?"},
    17661834    {"colormap",  7, GlyphsColorMapOp, 3, 4, "colorMapName ?dataSetNme?"},
    17671835    {"colormode", 7, GlyphsColorModeOp, 3, 4, "mode ?dataSetNme?"},
     
    34793547
    34803548static int
     3549StreamlinesColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     3550                   Tcl_Obj *const *objv)
     3551{
     3552    float color[3];
     3553    if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK ||
     3554        GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK ||
     3555        GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) {
     3556        return TCL_ERROR;
     3557    }
     3558    if (objc == 6) {
     3559        const char *name = Tcl_GetString(objv[5]);
     3560        g_renderer->setStreamlinesColor(name, color);
     3561    } else {
     3562        g_renderer->setStreamlinesColor("all", color);
     3563    }
     3564    return TCL_OK;
     3565}
     3566
     3567static int
    34813568StreamlinesColorMapOp(ClientData clientData, Tcl_Interp *interp, int objc,
    34823569                      Tcl_Obj *const *objv)
     
    34883575    } else {
    34893576        g_renderer->setStreamlinesColorMap("all", colorMapName);
     3577    }
     3578    return TCL_OK;
     3579}
     3580
     3581static int
     3582StreamlinesColorModeOp(ClientData clientData, Tcl_Interp *interp, int objc,
     3583                       Tcl_Obj *const *objv)
     3584{
     3585    Streamlines::ColorMode mode;
     3586    const char *str = Tcl_GetString(objv[2]);
     3587    if (str[0] == 's' && strcmp(str, "scalar") == 0) {
     3588        mode = Streamlines::COLOR_BY_SCALAR;
     3589    } else if (str[0] == 'v' && strcmp(str, "vmag") == 0) {
     3590        mode = Streamlines::COLOR_BY_VECTOR_MAGNITUDE;
     3591    } else if (str[0] == 'v' && strcmp(str, "vx") == 0) {
     3592        mode = Streamlines::COLOR_BY_VECTOR_X;
     3593    } else if (str[0] == 'v' && strcmp(str, "vy") == 0) {
     3594        mode = Streamlines::COLOR_BY_VECTOR_Y;
     3595    } else if (str[0] == 'v' && strcmp(str, "vz") == 0) {
     3596        mode = Streamlines::COLOR_BY_VECTOR_Z;
     3597    } else if (str[0] == 'c' && strcmp(str, "ccolor") == 0) {
     3598        mode = Streamlines::COLOR_CONSTANT;
     3599    } else {
     3600        Tcl_AppendResult(interp, "bad color mode option \"", str,
     3601                         "\": should be one of: 'scalar', 'vmag', 'vx', 'vy', 'vz', 'ccolor'", (char*)NULL);
     3602        return TCL_ERROR;
     3603    }
     3604    if (objc == 4) {
     3605        const char *dataSetName = Tcl_GetString(objv[3]);
     3606        g_renderer->setStreamlinesColorMode(dataSetName, mode);
     3607    } else {
     3608        g_renderer->setStreamlinesColorMode("all", mode);
    34903609    }
    34913610    return TCL_OK;
     
    39534072static Rappture::CmdSpec streamlinesOps[] = {
    39544073    {"add",       1, StreamlinesAddOp, 2, 3, "?dataSetName?"},
    3955     {"colormap",  1, StreamlinesColorMapOp, 3, 4, "colorMapName ?dataSetName?"},
     4074    {"ccolor",    1, StreamlinesColorOp, 5, 6, "r g b ?dataSetName?"},
     4075    {"colormap",  7, StreamlinesColorMapOp, 3, 4, "colorMapName ?dataSetName?"},
     4076    {"colormode", 7, StreamlinesColorModeOp, 3, 4, "mode ?dataSetNme?"},
    39564077    {"delete",    1, StreamlinesDeleteOp, 2, 3, "?dataSetName?"},
    39574078    {"edges",     1, StreamlinesEdgeVisibilityOp, 3, 4, "bool ?dataSetName?"},
  • trunk/packages/vizservers/vtkvis/protocol.txt

    r2351 r2393  
    8585        "all"
    8686dataset opacity <val> <?datasetName?>
     87dataset scalar <scalarName> <?datasetName?>
     88        Set the active scalar field to plot
     89dataset vector <vectorName> <?datasetName?>
     90        Set the active vector field to plot
    8791dataset visible <bool> <?datasetName?>
    8892
     
    107111contour3d add contourlist <list> <?datasetName?>
    108112          list = {isoval1 isoval2 isoval3...}
    109 contour3d color r g b <?datasetName?>
     113contour3d ccolor r g b <?datasetName?>
    110114contour3d colormap <colorMapName> <?dataSetName?>
    111115contour3d delete <?datasetName?>
     
    122126
    123127glyphs add <?dataSetName?>
     128glyphs ccolor r g b <?datasetName?>
    124129glyphs colormap <colorMapName> <?dataSetName?>
    125 glyphs colormode <scale|scalar|vector> <?dataSetName?>
     130glyphs colormode <scale|scalar|vector|ccolor> <?dataSetName?>
    126131       Set the color mode: color by scale, scalar field or
    127132       vector magnitude -- uses the current color map
     
    232237
    233238streamlines add <?datasetName?>
     239streamlines ccolor <r> <g> <b> <?datasetName?>
     240            Set the constant color of streamlines used for color mode 'ccolor'
    234241streamlines colormap <colormapName> <?datasetName?>
    235242            Colormap used to color streamlines/tubes/ribbons by vector magnitude
     243streamlines colormode <scalar|vmag|vx|vy|vz|ccolor> <?datasetName?>
     244            Set the field used to color the streamlines.  'ccolor' means to use
     245            the constant color defined by the ccolor subcommand.  'scalar' uses
     246            the active scalar field.  'vmag' uses the magnitude of the current
     247            vector field, and 'vx','vy','vz' use the corresponding component of
     248            the active vector field.
    236249streamlines delete <?datasetName?>
    237250streamlines edges <bool> <?datasetName?>
Note: See TracChangeset for help on using the changeset viewer.