Ignore:
Timestamp:
Feb 28, 2011 2:57:29 AM (13 years ago)
Author:
ldelgass
Message:

New features for vtk render server:

  • Add new ColorMap? supporting linear ramps with separate color and opacity control points
  • 3D camera modes with pan/rotate/zoom (FIXME: rotate uses Euler angles)
  • New axis commands, set titles/units, grid on 3D axes
  • New polydata command for rendering 3D meshes (to replace Tcl vtkviewer for drawing3d rappture element)
  • Pseudocolor can be applied to non-image datasets (tested with polydata) as long as point data is present. Added option to turn on edges.
File:
1 edited

Legend:

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

    r2100 r2112  
    1919PseudoColor::PseudoColor() :
    2020    _dataSet(NULL),
    21     _opacity(1.0)
    22 {
     21    _opacity(1.0),
     22    _edgeWidth(1.0)
     23{
     24    _edgeColor[0] = 0.0;
     25    _edgeColor[1] = 0.0;
     26    _edgeColor[2] = 0.0;
    2327}
    2428
     
    5862    _dsMapper->StaticOff();
    5963
    60     vtkLookupTable *lut = ds->GetPointData()->GetScalars()->GetLookupTable();
    61     TRACE("Data set scalars lookup table: %p\n", lut);
    62     if (_lut == NULL) {
    63         if (lut)
    64             _lut = lut;
    65         else
     64    if (ds->GetPointData() == NULL ||
     65        ds->GetPointData()->GetScalars() == NULL) {
     66        ERROR("No scalar point data in dataset %s", _dataSet->getName().c_str());
     67        if (_lut == NULL) {
    6668            _lut = vtkSmartPointer<vtkLookupTable>::New();
     69        }
    6770    } else {
    68        
    69     }
     71        vtkLookupTable *lut = ds->GetPointData()->GetScalars()->GetLookupTable();
     72        TRACE("Data set scalars lookup table: %p\n", lut);
     73        if (_lut == NULL) {
     74            if (lut)
     75                _lut = lut;
     76            else
     77                _lut = vtkSmartPointer<vtkLookupTable>::New();
     78        }
     79    }
     80
    7081    _lut->SetRange(dataRange);
    7182
     
    8192
    8293/**
    83  * \brief Get the VTK Actor for the colormap iamge
     94 * \brief Get the VTK Actor for the colormapped dataset
    8495 */
    8596vtkActor *PseudoColor::getActor()
     
    89100
    90101/**
    91  * \brief Create and initialize a VTK actor to render the colormap image
     102 * \brief Create and initialize a VTK actor to render the colormapped dataset
    92103 */
    93104void PseudoColor::initActor()
     
    96107        _dsActor = vtkSmartPointer<vtkActor>::New();
    97108        _dsActor->GetProperty()->SetOpacity(_opacity);
     109        _dsActor->GetProperty()->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]);
     110        _dsActor->GetProperty()->SetLineWidth(_edgeWidth);
     111        _dsActor->GetProperty()->EdgeVisibilityOff();
    98112    }
    99113}
     
    118132    }
    119133
     134    double dataRange[2];
    120135    if (_dataSet != NULL) {
    121         double dataRange[2];
    122136        _dataSet->getDataRange(dataRange);
    123137        _lut->SetRange(dataRange);
    124 
    125         if (_dataSet->getVtkDataSet()->GetPointData()->GetScalars()->GetLookupTable()) {
     138#ifdef notdef
     139        if (_dataSet->getVtkDataSet()->GetPointData() &&
     140            _dataSet->getVtkDataSet()->GetPointData()->GetScalars() &&
     141            _dataSet->getVtkDataSet()->GetPointData()->GetScalars()->GetLookupTable()) {
    126142            TRACE("Change scalar table: %p %p\n",
    127143                  _dataSet->getVtkDataSet()->GetPointData()->GetScalars()->GetLookupTable(),
     
    130146            TRACE("Scalar Table: %p\n", _dataSet->getVtkDataSet()->GetPointData()->GetScalars()->GetLookupTable());
    131147        }
     148#endif
    132149    }
    133150    if (_dsMapper != NULL) {
    134151        _dsMapper->SetLookupTable(_lut);
    135     }
    136 }
    137 
    138 /**
    139  * \brief Turn on/off rendering of this colormap image
     152        if (_dataSet != NULL) {
     153            _dsMapper->SetScalarRange(dataRange);
     154        }
     155    }
     156}
     157
     158/**
     159 * \brief Turn on/off rendering of this colormapped dataset
    140160 */
    141161void PseudoColor::setVisibility(bool state)
     
    147167
    148168/**
    149  * \brief Set opacity used to render the colormap image
     169 * \brief Get visibility state of the colormapped dataset
     170 *
     171 * \return Is PseudoColor visible?
     172 */
     173bool PseudoColor::getVisibility()
     174{
     175    if (_dsActor == NULL) {
     176        return false;
     177    } else {
     178        return (_dsActor->GetVisibility() != 0);
     179    }
     180}
     181
     182/**
     183 * \brief Set opacity used to render the colormapped dataset
    150184 */
    151185void PseudoColor::setOpacity(double opacity)
     
    157191
    158192/**
     193 * \brief Turn on/off rendering of mesh edges
     194 */
     195void PseudoColor::setEdgeVisibility(bool state)
     196{
     197    if (_dsActor != NULL) {
     198        _dsActor->GetProperty()->SetEdgeVisibility((state ? 1 : 0));
     199    }
     200}
     201
     202/**
     203 * \brief Set RGB color of polygon edges
     204 */
     205void PseudoColor::setEdgeColor(float color[3])
     206{
     207    _edgeColor[0] = color[0];
     208    _edgeColor[1] = color[1];
     209    _edgeColor[2] = color[2];
     210    if (_dsActor != NULL)
     211        _dsActor->GetProperty()->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]);
     212}
     213
     214/**
     215 * \brief Set pixel width of polygon edges (may be a no-op)
     216 */
     217void PseudoColor::setEdgeWidth(float edgeWidth)
     218{
     219    _edgeWidth = edgeWidth;
     220    if (_dsActor != NULL)
     221        _dsActor->GetProperty()->SetLineWidth(_edgeWidth);
     222}
     223
     224/**
    159225 * \brief Set a group of world coordinate planes to clip rendering
     226 *
     227 * Passing NULL for planes will remove all cliping planes
    160228 */
    161229void PseudoColor::setClippingPlanes(vtkPlaneCollection *planes)
    162230{
    163     if (_dsMapper != NULL)
    164         _dsMapper->SetClippingPlanes(planes);
    165 }
     231    if (_dsMapper != NULL) {
     232        if (planes == NULL)
     233            _dsMapper->RemoveAllClippingPlanes();
     234        else
     235            _dsMapper->SetClippingPlanes(planes);
     236    }
     237}
Note: See TracChangeset for help on using the changeset viewer.