Changeset 2269 for trunk/packages


Ignore:
Timestamp:
Jun 2, 2011 2:21:08 PM (13 years ago)
Author:
ldelgass
Message:

Add glyphs command/object for rendering 3D glyph objects at all points in a
data set with scaling and color mapping. Useful for vector field hedgehogs
and general 3D scatter plots. Still need to deal with data ranges better and
add options for using vector mag. vs. components for scaling, etc.
Also compute point data when only cell data is present and point data is needed.
Probably this should be done in the DataSet? class instead to minimize
duplicating work.

Location:
trunk/packages/vizservers/vtkvis
Files:
2 added
8 edited

Legend:

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

    r2261 r2269  
    7676                PPMWriter.cpp \
    7777                RpContour2D.cpp \
     78                RpGlyphs.cpp \
    7879                RpHeightMap.cpp \
    7980                RpPolyData.cpp \
     
    126127RpContour2D.o: RpContour2D.h RpVtkDataSet.h Trace.h
    127128RpPolyData.o: RpPolyData.h RpVtkDataSet.h Trace.h
     129RpGlyphs.o: RpGlyphs.h RpVtkDataSet.h ColorMap.h Trace.h
    128130RpHeightMap.o: RpHeightMap.h RpVtkDataSet.h Trace.h
    129131RpPseudoColor.o: RpPseudoColor.h RpVtkDataSet.h Trace.h
  • trunk/packages/vizservers/vtkvis/RpContour2D.cpp

    r2261 r2269  
    88#include <cassert>
    99
     10#include <vtkDataSet.h>
     11#include <vtkPointData.h>
     12#include <vtkCellData.h>
     13#include <vtkCellDataToPointData.h>
    1014#include <vtkContourFilter.h>
    1115#include <vtkPolyDataMapper.h>
    1216#include <vtkUnstructuredGrid.h>
    1317#include <vtkProperty.h>
    14 #include <vtkPointData.h>
    1518#include <vtkDelaunay2D.h>
    1619#include <vtkDelaunay3D.h>
     
    112115    }
    113116 
     117    vtkSmartPointer<vtkCellDataToPointData> cellToPtData;
     118
     119    if (ds->GetPointData() == NULL ||
     120        ds->GetPointData()->GetScalars() == NULL) {
     121        ERROR("No scalar point data in dataset %s", _dataSet->getName().c_str());
     122        if (ds->GetCellData() != NULL &&
     123            ds->GetCellData()->GetScalars() != NULL) {
     124            cellToPtData =
     125                vtkSmartPointer<vtkCellDataToPointData>::New();
     126            cellToPtData->SetInput(ds);
     127            ds = cellToPtData->GetOutput();
     128        } else {
     129            ERROR("No scalar cell data in dataset %s", _dataSet->getName().c_str());
     130        }
     131    }
     132
    114133    vtkPolyData *pd = vtkPolyData::SafeDownCast(ds);
    115134    if (pd) {
  • trunk/packages/vizservers/vtkvis/RpHeightMap.cpp

    r2263 r2269  
    99
    1010#include <vtkDataSet.h>
     11#include <vtkPointData.h>
     12#include <vtkCellData.h>
     13#include <vtkCellDataToPointData.h>
    1114#include <vtkDataSetMapper.h>
    1215#include <vtkPolyDataMapper.h>
    1316#include <vtkUnstructuredGrid.h>
    1417#include <vtkProperty.h>
    15 #include <vtkPointData.h>
    1618#include <vtkImageData.h>
    1719#include <vtkLookupTable.h>
     
    3032using namespace Rappture::VtkVis;
    3133
    32 #define MESH_POINTS
     34//#define MESH_POINTS
    3335
    3436HeightMap::HeightMap() :
     
    112114
    113115    if (_transformedData == NULL) {
     116        vtkSmartPointer<vtkCellDataToPointData> cellToPtData;
     117
     118        if (ds->GetPointData() == NULL ||
     119            ds->GetPointData()->GetScalars() == NULL) {
     120            ERROR("No scalar point data in dataset %s", _dataSet->getName().c_str());
     121            if (ds->GetCellData() != NULL &&
     122                ds->GetCellData()->GetScalars() != NULL) {
     123                cellToPtData =
     124                    vtkSmartPointer<vtkCellDataToPointData>::New();
     125                cellToPtData->SetInput(ds);
     126                ds = cellToPtData->GetOutput();
     127            } else {
     128                ERROR("No scalar cell data in dataset %s", _dataSet->getName().c_str());
     129            }
     130        }
     131
    114132        vtkPolyData *pd = vtkPolyData::SafeDownCast(ds);
    115133        if (pd != NULL) {
     
    214232                gf->SetInput(_volumeSlicer->GetOutput());
    215233            } else {
    216                 // structured grid, unstructured grid, or rectilinear grid
     234                // 2D image data, structured grid, unstructured grid, or rectilinear grid
    217235                gf->SetInput(ds);
    218236            }
     
    243261            if (lut)
    244262                _lut = lut;
    245             else
     263            else {
    246264                _lut = vtkSmartPointer<vtkLookupTable>::New();
     265            }
    247266        }
    248267    }
  • trunk/packages/vizservers/vtkvis/RpPseudoColor.cpp

    r2261 r2269  
    99
    1010#include <vtkDataSet.h>
     11#include <vtkPointData.h>
    1112#include <vtkDataSetMapper.h>
    1213#include <vtkUnstructuredGrid.h>
    1314#include <vtkProperty.h>
    14 #include <vtkPointData.h>
    1515#include <vtkImageData.h>
    1616#include <vtkLookupTable.h>
     
    152152    if (ds->GetPointData() == NULL ||
    153153        ds->GetPointData()->GetScalars() == NULL) {
    154         ERROR("No scalar point data in dataset %s", _dataSet->getName().c_str());
     154        WARN("No scalar point data in dataset %s", _dataSet->getName().c_str());
    155155        if (_lut == NULL) {
    156156            _lut = vtkSmartPointer<vtkLookupTable>::New();
  • trunk/packages/vizservers/vtkvis/RpVtkRenderer.cpp

    r2262 r2269  
    107107Renderer::~Renderer()
    108108{
    109     for (ColorMapHashmap::iterator itr = _colorMaps.begin();
    110              itr != _colorMaps.end(); ++itr) {
    111         delete itr->second;
    112     }
    113     _colorMaps.clear();
    114     for (PseudoColorHashmap::iterator itr = _pseudoColors.begin();
    115              itr != _pseudoColors.end(); ++itr) {
    116         delete itr->second;
    117     }
    118     _pseudoColors.clear();
    119109    for (Contour2DHashmap::iterator itr = _contours.begin();
    120110             itr != _contours.end(); ++itr) {
     
    122112    }
    123113    _contours.clear();
     114    for (GlyphsHashmap::iterator itr = _glyphs.begin();
     115             itr != _glyphs.end(); ++itr) {
     116        delete itr->second;
     117    }
     118    _glyphs.clear();
    124119    for (HeightMapHashmap::iterator itr = _heightMaps.begin();
    125120             itr != _heightMaps.end(); ++itr) {
     
    132127    }
    133128    _polyDatas.clear();
     129    for (PseudoColorHashmap::iterator itr = _pseudoColors.begin();
     130             itr != _pseudoColors.end(); ++itr) {
     131        delete itr->second;
     132    }
     133    _pseudoColors.clear();
    134134    for (VolumeHashmap::iterator itr = _volumes.begin();
    135135             itr != _volumes.end(); ++itr) {
     
    137137    }
    138138    _volumes.clear();
     139    // Delete color maps and data sets last in case references still
     140    // exist
     141    for (ColorMapHashmap::iterator itr = _colorMaps.begin();
     142             itr != _colorMaps.end(); ++itr) {
     143        delete itr->second;
     144    }
     145    _colorMaps.clear();
    139146    for (DataSetHashmap::iterator itr = _dataSets.begin();
    140147             itr != _dataSets.end(); ++itr) {
     
    161168
    162169/**
     170 * \brief Remove the Contour2D isolines for the specified DataSet
     171 *
     172 * The underlying Contour2D is deleted, freeing its memory
     173 */
     174void Renderer::deleteContour2D(const DataSetId& id)
     175{
     176    Contour2DHashmap::iterator itr;
     177
     178    bool doAll = false;
     179
     180    if (id.compare("all") == 0) {
     181        itr = _contours.begin();
     182        doAll = true;
     183    } else {
     184        itr = _contours.find(id);
     185    }
     186    if (itr == _contours.end()) {
     187        ERROR("Contour2D not found: %s", id.c_str());
     188        return;
     189    }
     190
     191    TRACE("Deleting Contour2Ds for %s", id.c_str());
     192
     193    do {
     194        Contour2D *contour = itr->second;
     195        if (contour->getProp())
     196            _renderer->RemoveViewProp(contour->getProp());
     197        delete contour;
     198
     199        _contours.erase(itr);
     200    } while (doAll && ++itr != _contours.end());
     201
     202    _needsRedraw = true;
     203}
     204
     205/**
     206 * \brief Remove the Glyphs for the specified DataSet
     207 *
     208 * The underlying Glyphs is deleted, freeing its memory
     209 */
     210void Renderer::deleteGlyphs(const DataSetId& id)
     211{
     212    GlyphsHashmap::iterator itr;
     213
     214    bool doAll = false;
     215
     216    if (id.compare("all") == 0) {
     217        itr = _glyphs.begin();
     218        doAll = true;
     219    } else {
     220        itr = _glyphs.find(id);
     221    }
     222    if (itr == _glyphs.end()) {
     223        ERROR("Glyphs not found: %s", id.c_str());
     224        return;
     225    }
     226
     227    TRACE("Deleting Glyphs for %s", id.c_str());
     228
     229    do {
     230        Glyphs *glyphs = itr->second;
     231        if (glyphs->getProp())
     232            _renderer->RemoveViewProp(glyphs->getProp());
     233        delete glyphs;
     234
     235        _glyphs.erase(itr);
     236    } while (doAll && ++itr != _glyphs.end());
     237
     238    _needsRedraw = true;
     239}
     240
     241/**
     242 * \brief Remove the HeightMap for the specified DataSet
     243 *
     244 * The underlying HeightMap is deleted, freeing its memory
     245 */
     246void Renderer::deleteHeightMap(const DataSetId& id)
     247{
     248    HeightMapHashmap::iterator itr;
     249
     250    bool doAll = false;
     251
     252    if (id.compare("all") == 0) {
     253        itr = _heightMaps.begin();
     254        doAll = true;
     255    } else {
     256        itr = _heightMaps.find(id);
     257    }
     258    if (itr == _heightMaps.end()) {
     259        ERROR("HeightMap not found: %s", id.c_str());
     260        return;
     261    }
     262
     263    TRACE("Deleting HeightMaps for %s", id.c_str());
     264
     265    do {
     266        HeightMap *hmap = itr->second;
     267        if (hmap->getProp())
     268            _renderer->RemoveViewProp(hmap->getProp());
     269        delete hmap;
     270
     271        _heightMaps.erase(itr);
     272    } while (doAll && ++itr != _heightMaps.end());
     273
     274    _needsRedraw = true;
     275}
     276
     277/**
     278 * \brief Remove the PolyData mesh for the specified DataSet
     279 *
     280 * The underlying PolyData is deleted, freeing its memory
     281 */
     282void Renderer::deletePolyData(const DataSetId& id)
     283{
     284    PolyDataHashmap::iterator itr;
     285
     286    bool doAll = false;
     287
     288    if (id.compare("all") == 0) {
     289        itr = _polyDatas.begin();
     290        doAll = true;
     291    } else {
     292        itr = _polyDatas.find(id);
     293    }
     294    if (itr == _polyDatas.end()) {
     295        ERROR("PolyData not found: %s", id.c_str());
     296        return;
     297    }
     298
     299    TRACE("Deleting PolyDatas for %s", id.c_str());
     300
     301    do {
     302        PolyData *polyData = itr->second;
     303        if (polyData->getProp())
     304            _renderer->RemoveViewProp(polyData->getProp());
     305        delete polyData;
     306
     307        _polyDatas.erase(itr);
     308    } while (doAll && ++itr != _polyDatas.end());
     309
     310    _needsRedraw = true;
     311}
     312
     313/**
    163314 * \brief Remove the PseudoColor mapping for the specified DataSet
    164315 *
     
    197348
    198349/**
    199  * \brief Remove the Contour2D isolines for the specified DataSet
    200  *
    201  * The underlying Contour2D is deleted, freeing its memory
    202  */
    203 void Renderer::deleteContour2D(const DataSetId& id)
    204 {
    205     Contour2DHashmap::iterator itr;
    206 
    207     bool doAll = false;
    208 
    209     if (id.compare("all") == 0) {
    210         itr = _contours.begin();
    211         doAll = true;
    212     } else {
    213         itr = _contours.find(id);
    214     }
    215     if (itr == _contours.end()) {
    216         ERROR("Contour2D not found: %s", id.c_str());
    217         return;
    218     }
    219 
    220     TRACE("Deleting Contour2Ds for %s", id.c_str());
    221 
    222     do {
    223         Contour2D *contour = itr->second;
    224         if (contour->getProp())
    225             _renderer->RemoveViewProp(contour->getProp());
    226         delete contour;
    227 
    228         _contours.erase(itr);
    229     } while (doAll && ++itr != _contours.end());
    230 
    231     _needsRedraw = true;
    232 }
    233 
    234 /**
    235  * \brief Remove the HeightMap for the specified DataSet
    236  *
    237  * The underlying HeightMap is deleted, freeing its memory
    238  */
    239 void Renderer::deleteHeightMap(const DataSetId& id)
    240 {
    241     HeightMapHashmap::iterator itr;
    242 
    243     bool doAll = false;
    244 
    245     if (id.compare("all") == 0) {
    246         itr = _heightMaps.begin();
    247         doAll = true;
    248     } else {
    249         itr = _heightMaps.find(id);
    250     }
    251     if (itr == _heightMaps.end()) {
    252         ERROR("HeightMap not found: %s", id.c_str());
    253         return;
    254     }
    255 
    256     TRACE("Deleting HeightMaps for %s", id.c_str());
    257 
    258     do {
    259         HeightMap *hmap = itr->second;
    260         if (hmap->getProp())
    261             _renderer->RemoveViewProp(hmap->getProp());
    262         delete hmap;
    263 
    264         _heightMaps.erase(itr);
    265     } while (doAll && ++itr != _heightMaps.end());
    266 
    267     _needsRedraw = true;
    268 }
    269 
    270 /**
    271  * \brief Remove the PolyData mesh for the specified DataSet
    272  *
    273  * The underlying PolyData is deleted, freeing its memory
    274  */
    275 void Renderer::deletePolyData(const DataSetId& id)
    276 {
    277     PolyDataHashmap::iterator itr;
    278 
    279     bool doAll = false;
    280 
    281     if (id.compare("all") == 0) {
    282         itr = _polyDatas.begin();
    283         doAll = true;
    284     } else {
    285         itr = _polyDatas.find(id);
    286     }
    287     if (itr == _polyDatas.end()) {
    288         ERROR("PolyData not found: %s", id.c_str());
    289         return;
    290     }
    291 
    292     TRACE("Deleting PolyDatas for %s", id.c_str());
    293 
    294     do {
    295         PolyData *polyData = itr->second;
    296         if (polyData->getProp())
    297             _renderer->RemoveViewProp(polyData->getProp());
    298         delete polyData;
    299 
    300         _polyDatas.erase(itr);
    301     } while (doAll && ++itr != _polyDatas.end());
    302 
    303     _needsRedraw = true;
    304 }
    305 
    306 /**
    307350 * \brief Remove the Volume for the specified DataSet
    308351 *
     
    366409        TRACE("Deleting dataset %s", itr->second->getName().c_str());
    367410
    368         deletePseudoColor(itr->second->getName());
    369411        deleteContour2D(itr->second->getName());
     412        deleteGlyphs(itr->second->getName());
    370413        deleteHeightMap(itr->second->getName());
    371414        deletePolyData(itr->second->getName());
     415        deletePseudoColor(itr->second->getName());
    372416        deleteVolume(itr->second->getName());
    373417   
     
    896940
    897941/**
    898  * \brief Create a new PseudoColor rendering for the specified DataSet
    899  */
    900 void Renderer::addPseudoColor(const DataSetId& id)
     942 * \brief Create a new Contour2D and associate it with the named DataSet
     943 */
     944void Renderer::addContour2D(const DataSetId& id)
    901945{
    902946    DataSetHashmap::iterator itr;
     
    918962        const DataSetId& dsID = ds->getName();
    919963
    920         if (getPseudoColor(dsID)) {
    921             WARN("Replacing existing pseudocolor %s", dsID.c_str());
    922             deletePseudoColor(dsID);
    923         }
    924         PseudoColor *pc = new PseudoColor();
    925         _pseudoColors[dsID] = pc;
    926 
    927         pc->setDataSet(ds);
     964        if (getContour2D(dsID)) {
     965            WARN("Replacing existing contour2d %s", dsID.c_str());
     966            deleteContour2D(dsID);
     967        }
     968
     969        Contour2D *contour = new Contour2D();
     970        _contours[dsID] = contour;
     971
     972        contour->setDataSet(ds);
     973
     974        _renderer->AddViewProp(contour->getProp());
     975    } while (doAll && ++itr != _dataSets.end());
     976
     977    initCamera();
     978    _needsRedraw = true;
     979}
     980
     981/**
     982 * \brief Get the Contour2D associated with a named DataSet
     983 */
     984Contour2D *Renderer::getContour2D(const DataSetId& id)
     985{
     986    Contour2DHashmap::iterator itr = _contours.find(id);
     987
     988    if (itr == _contours.end()) {
     989        TRACE("Contour2D not found: %s", id.c_str());
     990        return NULL;
     991    } else
     992        return itr->second;
     993}
     994
     995/**
     996 * \brief Set the number of equally spaced contour isolines for the given DataSet
     997 */
     998void Renderer::setContours(const DataSetId& id, int numContours)
     999{
     1000    Contour2DHashmap::iterator itr;
     1001
     1002    bool doAll = false;
     1003
     1004    if (id.compare("all") == 0) {
     1005        itr = _contours.begin();
     1006        doAll = true;
     1007    } else {
     1008        itr = _contours.find(id);
     1009    }
     1010    if (itr == _contours.end()) {
     1011        ERROR("Contour2D not found: %s", id.c_str());
     1012        return;
     1013    }
     1014
     1015    do {
     1016        if (_useCumulativeRange) {
     1017            itr->second->setContours(numContours, _cumulativeDataRange);
     1018        } else {
     1019            itr->second->setContours(numContours);
     1020        }
     1021    } while (doAll && ++itr != _contours.end());
     1022
     1023    _needsRedraw = true;
     1024}
     1025
     1026/**
     1027 * \brief Set a list of isovalues for the given DataSet
     1028 */
     1029void Renderer::setContourList(const DataSetId& id, const std::vector<double>& contours)
     1030{
     1031    Contour2DHashmap::iterator itr;
     1032
     1033    bool doAll = false;
     1034
     1035    if (id.compare("all") == 0) {
     1036        itr = _contours.begin();
     1037        doAll = true;
     1038    } else {
     1039        itr = _contours.find(id);
     1040    }
     1041    if (itr == _contours.end()) {
     1042        ERROR("Contour2D not found: %s", id.c_str());
     1043        return;
     1044    }
     1045
     1046    do {
     1047        itr->second->setContourList(contours);
     1048    } while (doAll && ++itr != _contours.end());
     1049
     1050     _needsRedraw = true;
     1051}
     1052
     1053/**
     1054 * \brief Set opacity of contour lines for the given DataSet
     1055 */
     1056void Renderer::setContourOpacity(const DataSetId& id, double opacity)
     1057{
     1058    Contour2DHashmap::iterator itr;
     1059
     1060    bool doAll = false;
     1061
     1062    if (id.compare("all") == 0) {
     1063        itr = _contours.begin();
     1064        doAll = true;
     1065    } else {
     1066        itr = _contours.find(id);
     1067    }
     1068    if (itr == _contours.end()) {
     1069        ERROR("Contour2D not found: %s", id.c_str());
     1070        return;
     1071    }
     1072
     1073    do {
     1074        itr->second->setOpacity(opacity);
     1075    } while (doAll && ++itr != _contours.end());
     1076
     1077    _needsRedraw = true;
     1078}
     1079
     1080/**
     1081 * \brief Turn on/off rendering contour lines for the given DataSet
     1082 */
     1083void Renderer::setContourVisibility(const DataSetId& id, bool state)
     1084{
     1085    Contour2DHashmap::iterator itr;
     1086
     1087    bool doAll = false;
     1088
     1089    if (id.compare("all") == 0) {
     1090        itr = _contours.begin();
     1091        doAll = true;
     1092    } else {
     1093        itr = _contours.find(id);
     1094    }
     1095    if (itr == _contours.end()) {
     1096        ERROR("Contour2D not found: %s", id.c_str());
     1097        return;
     1098    }
     1099
     1100    do {
     1101        itr->second->setVisibility(state);
     1102    } while (doAll && ++itr != _contours.end());
     1103
     1104    _needsRedraw = true;
     1105}
     1106
     1107/**
     1108 * \brief Set the RGB isoline color for the specified DataSet
     1109 */
     1110void Renderer::setContourEdgeColor(const DataSetId& id, float color[3])
     1111{
     1112    Contour2DHashmap::iterator itr;
     1113
     1114    bool doAll = false;
     1115
     1116    if (id.compare("all") == 0) {
     1117        itr = _contours.begin();
     1118        doAll = true;
     1119    } else {
     1120        itr = _contours.find(id);
     1121    }
     1122    if (itr == _contours.end()) {
     1123        ERROR("Contour2D not found: %s", id.c_str());
     1124        return;
     1125    }
     1126
     1127    do {
     1128        itr->second->setEdgeColor(color);
     1129    } while (doAll && ++itr != _contours.end());
     1130
     1131    _needsRedraw = true;
     1132}
     1133
     1134/**
     1135 * \brief Set the isoline width for the specified DataSet (may be a no-op)
     1136 *
     1137 * If the OpenGL implementation/hardware does not support wide lines,
     1138 * this function may not have an effect.
     1139 */
     1140void Renderer::setContourEdgeWidth(const DataSetId& id, float edgeWidth)
     1141{
     1142    Contour2DHashmap::iterator itr;
     1143
     1144    bool doAll = false;
     1145
     1146    if (id.compare("all") == 0) {
     1147        itr = _contours.begin();
     1148        doAll = true;
     1149    } else {
     1150        itr = _contours.find(id);
     1151    }
     1152    if (itr == _contours.end()) {
     1153        ERROR("Contour2D not found: %s", id.c_str());
     1154        return;
     1155    }
     1156
     1157    do {
     1158        itr->second->setEdgeWidth(edgeWidth);
     1159    } while (doAll && ++itr != _contours.end());
     1160
     1161    _needsRedraw = true;
     1162}
     1163
     1164/**
     1165 * \brief Turn contour lighting on/off for the specified DataSet
     1166 */
     1167void Renderer::setContourLighting(const DataSetId& id, bool state)
     1168{
     1169    Contour2DHashmap::iterator itr;
     1170
     1171    bool doAll = false;
     1172
     1173    if (id.compare("all") == 0) {
     1174        itr = _contours.begin();
     1175        doAll = true;
     1176    } else {
     1177        itr = _contours.find(id);
     1178    }
     1179    if (itr == _contours.end()) {
     1180        ERROR("Contour2D not found: %s", id.c_str());
     1181        return;
     1182    }
     1183
     1184    do {
     1185        itr->second->setLighting(state);
     1186    } while (doAll && ++itr != _contours.end());
     1187    _needsRedraw = true;
     1188}
     1189
     1190/**
     1191 * \brief Create a new Glyphs and associate it with the named DataSet
     1192 */
     1193void Renderer::addGlyphs(const DataSetId& id)
     1194{
     1195    DataSetHashmap::iterator itr;
     1196
     1197    bool doAll = false;
     1198
     1199    if (id.compare("all") == 0) {
     1200        itr = _dataSets.begin();
     1201    } else {
     1202        itr = _dataSets.find(id);
     1203    }
     1204    if (itr == _dataSets.end()) {
     1205        ERROR("Unknown dataset %s", id.c_str());
     1206        return;
     1207    }
     1208
     1209    do {
     1210        DataSet *ds = itr->second;
     1211        const DataSetId& dsID = ds->getName();
     1212
     1213        if (getGlyphs(dsID)) {
     1214            WARN("Replacing existing Glyphs %s", dsID.c_str());
     1215            deleteGlyphs(dsID);
     1216        }
     1217
     1218        Glyphs *glyphs = new Glyphs();
     1219        _glyphs[dsID] = glyphs;
     1220
     1221        glyphs->setDataSet(ds);
    9281222
    9291223        // Use the default color map
     
    9391233        }
    9401234
    941         pc->setLookupTable(lut);
    942 
    943         _renderer->AddViewProp(pc->getProp());
     1235        glyphs->setLookupTable(lut);
     1236
     1237        _renderer->AddViewProp(glyphs->getProp());
    9441238    } while (doAll && ++itr != _dataSets.end());
    9451239
    9461240    initCamera();
    947     _needsRedraw = true;
    948 }
    949 
    950 /**
    951  * \brief Get the PseudoColor associated with the specified DataSet
    952  */
    953 PseudoColor *Renderer::getPseudoColor(const DataSetId& id)
    954 {
    955     PseudoColorHashmap::iterator itr = _pseudoColors.find(id);
    956 
    957     if (itr == _pseudoColors.end()) {
    958         TRACE("PseudoColor not found: %s", id.c_str());
     1241
     1242    _needsRedraw = true;
     1243}
     1244
     1245/**
     1246 * \brief Get the Glyphs associated with a named DataSet
     1247 */
     1248Glyphs *Renderer::getGlyphs(const DataSetId& id)
     1249{
     1250    GlyphsHashmap::iterator itr = _glyphs.find(id);
     1251
     1252    if (itr == _glyphs.end()) {
     1253        TRACE("Glyphs not found: %s", id.c_str());
    9591254        return NULL;
    9601255    } else
     
    9631258
    9641259/**
    965  * \brief Associate an existing named color map with a PseudoColor for the given DataSet
    966  */
    967 void Renderer::setPseudoColorColorMap(const DataSetId& id, const ColorMapId& colorMapId)
    968 {
    969     PseudoColorHashmap::iterator itr;
    970 
    971     bool doAll = false;
    972 
    973     if (id.compare("all") == 0) {
    974         itr = _pseudoColors.begin();
    975         doAll = true;
    976     } else {
    977         itr = _pseudoColors.find(id);
    978     }
    979 
    980     if (itr == _pseudoColors.end()) {
    981         ERROR("PseudoColor not found: %s", id.c_str());
     1260 * \brief Associate an existing named color map with a Glyphs for the given DataSet
     1261 */
     1262void Renderer::setGlyphsColorMap(const DataSetId& id, const ColorMapId& colorMapId)
     1263{
     1264    GlyphsHashmap::iterator itr;
     1265
     1266    bool doAll = false;
     1267
     1268    if (id.compare("all") == 0) {
     1269        itr = _glyphs.begin();
     1270        doAll = true;
     1271    } else {
     1272        itr = _glyphs.find(id);
     1273    }
     1274
     1275    if (itr == _glyphs.end()) {
     1276        ERROR("Glyphs not found: %s", id.c_str());
    9821277        return;
    9831278    }
     
    9901285
    9911286    do {
    992         TRACE("Set PseudoColor color map: %s for dataset %s", colorMapId.c_str(),
     1287        TRACE("Set Glyphs color map: %s for dataset %s", colorMapId.c_str(),
    9931288              itr->second->getDataSet()->getName().c_str());
    9941289
     
    10101305
    10111306        itr->second->setLookupTable(lut);
    1012     } while (doAll && ++itr != _pseudoColors.end());
    1013 
    1014     _needsRedraw = true;
    1015 }
    1016 
    1017 /**
    1018  * \brief Set opacity of the PseudoColor for the given DataSet
    1019  */
    1020 void Renderer::setPseudoColorOpacity(const DataSetId& id, double opacity)
    1021 {
    1022     PseudoColorHashmap::iterator itr;
    1023 
    1024     bool doAll = false;
    1025 
    1026     if (id.compare("all") == 0) {
    1027         itr = _pseudoColors.begin();
    1028         doAll = true;
    1029     } else {
    1030         itr = _pseudoColors.find(id);
    1031     }
    1032 
    1033     if (itr == _pseudoColors.end()) {
    1034         ERROR("PseudoColor not found: %s", id.c_str());
     1307    } while (doAll && ++itr != _glyphs.end());
     1308
     1309    _needsRedraw = true;
     1310}
     1311
     1312/**
     1313 * \brief Set the shape of Glyphs for the given DataSet
     1314 */
     1315void Renderer::setGlyphsShape(const DataSetId& id, Glyphs::GlyphShape shape)
     1316{
     1317    GlyphsHashmap::iterator itr;
     1318
     1319    bool doAll = false;
     1320
     1321    if (id.compare("all") == 0) {
     1322        itr = _glyphs.begin();
     1323        doAll = true;
     1324    } else {
     1325        itr = _glyphs.find(id);
     1326    }
     1327    if (itr == _glyphs.end()) {
     1328        ERROR("Glyphs not found: %s", id.c_str());
     1329        return;
     1330    }
     1331
     1332    do {
     1333        itr->second->setGlyphShape(shape);
     1334    } while (doAll && ++itr != _glyphs.end());
     1335
     1336    _renderer->ResetCameraClippingRange();
     1337    _needsRedraw = true;
     1338}
     1339
     1340/**
     1341 * \brief Set the glyph scaling factor for the given DataSet
     1342 */
     1343void Renderer::setGlyphsScaleFactor(const DataSetId& id, double scale)
     1344{
     1345    GlyphsHashmap::iterator itr;
     1346
     1347    bool doAll = false;
     1348
     1349    if (id.compare("all") == 0) {
     1350        itr = _glyphs.begin();
     1351        doAll = true;
     1352    } else {
     1353        itr = _glyphs.find(id);
     1354    }
     1355    if (itr == _glyphs.end()) {
     1356        ERROR("Glyphs not found: %s", id.c_str());
     1357        return;
     1358    }
     1359
     1360    do {
     1361        itr->second->setScaleFactor(scale);
     1362    } while (doAll && ++itr != _glyphs.end());
     1363
     1364    _renderer->ResetCameraClippingRange();
     1365    _needsRedraw = true;
     1366}
     1367
     1368/**
     1369 * \brief Set opacity of Glyphs for the given DataSet
     1370 */
     1371void Renderer::setGlyphsOpacity(const DataSetId& id, double opacity)
     1372{
     1373    GlyphsHashmap::iterator itr;
     1374
     1375    bool doAll = false;
     1376
     1377    if (id.compare("all") == 0) {
     1378        itr = _glyphs.begin();
     1379        doAll = true;
     1380    } else {
     1381        itr = _glyphs.find(id);
     1382    }
     1383    if (itr == _glyphs.end()) {
     1384        ERROR("Glyphs not found: %s", id.c_str());
    10351385        return;
    10361386    }
     
    10381388    do {
    10391389        itr->second->setOpacity(opacity);
    1040     } while (doAll && ++itr != _pseudoColors.end());
    1041 
    1042     _needsRedraw = true;
    1043 }
    1044 
    1045 /**
    1046  * \brief Turn on/off rendering of the PseudoColor mapper for the given DataSet
    1047  */
    1048 void Renderer::setPseudoColorVisibility(const DataSetId& id, bool state)
    1049 {
    1050     PseudoColorHashmap::iterator itr;
    1051 
    1052     bool doAll = false;
    1053 
    1054     if (id.compare("all") == 0) {
    1055         itr = _pseudoColors.begin();
    1056         doAll = true;
    1057     } else {
    1058         itr = _pseudoColors.find(id);
    1059     }
    1060 
    1061     if (itr == _pseudoColors.end()) {
    1062         ERROR("PseudoColor not found: %s", id.c_str());
     1390    } while (doAll && ++itr != _glyphs.end());
     1391
     1392    _needsRedraw = true;
     1393}
     1394
     1395/**
     1396 * \brief Turn on/off rendering Glyphs for the given DataSet
     1397 */
     1398void Renderer::setGlyphsVisibility(const DataSetId& id, bool state)
     1399{
     1400    GlyphsHashmap::iterator itr;
     1401
     1402    bool doAll = false;
     1403
     1404    if (id.compare("all") == 0) {
     1405        itr = _glyphs.begin();
     1406        doAll = true;
     1407    } else {
     1408        itr = _glyphs.find(id);
     1409    }
     1410    if (itr == _glyphs.end()) {
     1411        ERROR("Glyphs not found: %s", id.c_str());
    10631412        return;
    10641413    }
     
    10661415    do {
    10671416        itr->second->setVisibility(state);
    1068     } while (doAll && ++itr != _pseudoColors.end());
    1069 
    1070     _needsRedraw = true;
    1071 }
    1072 
    1073 /**
    1074  * \brief Set the visibility of polygon edges for the specified DataSet
    1075  */
    1076 void Renderer::setPseudoColorEdgeVisibility(const DataSetId& id, bool state)
    1077 {
    1078     PseudoColorHashmap::iterator itr;
    1079 
    1080     bool doAll = false;
    1081 
    1082     if (id.compare("all") == 0) {
    1083         itr = _pseudoColors.begin();
    1084         doAll = true;
    1085     } else {
    1086         itr = _pseudoColors.find(id);
    1087     }
    1088 
    1089     if (itr == _pseudoColors.end()) {
    1090         ERROR("PseudoColor not found: %s", id.c_str());
    1091         return;
    1092     }
    1093 
    1094     do {
    1095         itr->second->setEdgeVisibility(state);
    1096     } while (doAll && ++itr != _pseudoColors.end());
    1097 
    1098     _needsRedraw = true;
    1099 }
    1100 
    1101 /**
    1102  * \brief Set the RGB polygon edge color for the specified DataSet
    1103  */
    1104 void Renderer::setPseudoColorEdgeColor(const DataSetId& id, float color[3])
    1105 {
    1106     PseudoColorHashmap::iterator itr;
    1107 
    1108     bool doAll = false;
    1109 
    1110     if (id.compare("all") == 0) {
    1111         itr = _pseudoColors.begin();
    1112         doAll = true;
    1113     } else {
    1114         itr = _pseudoColors.find(id);
    1115     }
    1116 
    1117     if (itr == _pseudoColors.end()) {
    1118         ERROR("PseudoColor not found: %s", id.c_str());
    1119         return;
    1120     }
    1121 
    1122     do {
    1123         itr->second->setEdgeColor(color);
    1124     } while (doAll && ++itr != _pseudoColors.end());
    1125 
    1126     _needsRedraw = true;
    1127 }
    1128 
    1129 /**
    1130  * \brief Set the polygon edge width for the specified DataSet (may be a no-op)
    1131  *
    1132  * If the OpenGL implementation/hardware does not support wide lines,
    1133  * this function may not have an effect.
    1134  */
    1135 void Renderer::setPseudoColorEdgeWidth(const DataSetId& id, float edgeWidth)
    1136 {
    1137     PseudoColorHashmap::iterator itr;
    1138 
    1139     bool doAll = false;
    1140 
    1141     if (id.compare("all") == 0) {
    1142         itr = _pseudoColors.begin();
    1143         doAll = true;
    1144     } else {
    1145         itr = _pseudoColors.find(id);
    1146     }
    1147 
    1148     if (itr == _pseudoColors.end()) {
    1149         ERROR("PseudoColor not found: %s", id.c_str());
    1150         return;
    1151     }
    1152 
    1153     do {
    1154         itr->second->setEdgeWidth(edgeWidth);
    1155     } while (doAll && ++itr != _pseudoColors.end());
    1156 
    1157     _needsRedraw = true;
    1158 }
    1159 
    1160 /**
    1161  * \brief Turn mesh lighting on/off for the specified DataSet
    1162  */
    1163 void Renderer::setPseudoColorLighting(const DataSetId& id, bool state)
    1164 {
    1165     PseudoColorHashmap::iterator itr;
    1166 
    1167     bool doAll = false;
    1168 
    1169     if (id.compare("all") == 0) {
    1170         itr = _pseudoColors.begin();
    1171         doAll = true;
    1172     } else {
    1173         itr = _pseudoColors.find(id);
    1174     }
    1175 
    1176     if (itr == _pseudoColors.end()) {
    1177         ERROR("PseudoColor not found: %s", id.c_str());
     1417    } while (doAll && ++itr != _glyphs.end());
     1418
     1419    _needsRedraw = true;
     1420}
     1421
     1422/**
     1423 * \brief Turn Glyphs lighting on/off for the specified DataSet
     1424 */
     1425void Renderer::setGlyphsLighting(const DataSetId& id, bool state)
     1426{
     1427    GlyphsHashmap::iterator itr;
     1428
     1429    bool doAll = false;
     1430
     1431    if (id.compare("all") == 0) {
     1432        itr = _glyphs.begin();
     1433        doAll = true;
     1434    } else {
     1435        itr = _glyphs.find(id);
     1436    }
     1437    if (itr == _glyphs.end()) {
     1438        ERROR("Glyphs not found: %s", id.c_str());
    11781439        return;
    11791440    }
     
    11811442    do {
    11821443        itr->second->setLighting(state);
    1183     } while (doAll && ++itr != _pseudoColors.end());
    1184 
    1185     _needsRedraw = true;
    1186 }
    1187 
    1188 /**
    1189  * \brief Create a new Contour2D and associate it with the named DataSet
    1190  */
    1191 void Renderer::addContour2D(const DataSetId& id)
    1192 {
    1193     DataSetHashmap::iterator itr;
    1194 
    1195     bool doAll = false;
    1196 
    1197     if (id.compare("all") == 0) {
    1198         itr = _dataSets.begin();
    1199     } else {
    1200         itr = _dataSets.find(id);
    1201     }
    1202     if (itr == _dataSets.end()) {
    1203         ERROR("Unknown dataset %s", id.c_str());
    1204         return;
    1205     }
    1206 
    1207     do {
    1208         DataSet *ds = itr->second;
    1209         const DataSetId& dsID = ds->getName();
    1210 
    1211         if (getContour2D(dsID)) {
    1212             WARN("Replacing existing contour2d %s", dsID.c_str());
    1213             deleteContour2D(dsID);
    1214         }
    1215 
    1216         Contour2D *contour = new Contour2D();
    1217         _contours[dsID] = contour;
    1218 
    1219         contour->setDataSet(ds);
    1220 
    1221         _renderer->AddViewProp(contour->getProp());
    1222     } while (doAll && ++itr != _dataSets.end());
    1223 
    1224     initCamera();
    1225     _needsRedraw = true;
    1226 }
    1227 
    1228 /**
    1229  * \brief Get the Contour2D associated with a named DataSet
    1230  */
    1231 Contour2D *Renderer::getContour2D(const DataSetId& id)
    1232 {
    1233     Contour2DHashmap::iterator itr = _contours.find(id);
    1234 
    1235     if (itr == _contours.end()) {
    1236         TRACE("Contour2D not found: %s", id.c_str());
    1237         return NULL;
    1238     } else
    1239         return itr->second;
    1240 }
    1241 
    1242 /**
    1243  * \brief Set the number of equally spaced contour isolines for the given DataSet
    1244  */
    1245 void Renderer::setContours(const DataSetId& id, int numContours)
    1246 {
    1247     Contour2DHashmap::iterator itr;
    1248 
    1249     bool doAll = false;
    1250 
    1251     if (id.compare("all") == 0) {
    1252         itr = _contours.begin();
    1253         doAll = true;
    1254     } else {
    1255         itr = _contours.find(id);
    1256     }
    1257     if (itr == _contours.end()) {
    1258         ERROR("Contour2D not found: %s", id.c_str());
    1259         return;
    1260     }
    1261 
    1262     do {
    1263         if (_useCumulativeRange) {
    1264             itr->second->setContours(numContours, _cumulativeDataRange);
    1265         } else {
    1266             itr->second->setContours(numContours);
    1267         }
    1268     } while (doAll && ++itr != _contours.end());
    1269 
    1270     _needsRedraw = true;
    1271 }
    1272 
    1273 /**
    1274  * \brief Set a list of isovalues for the given DataSet
    1275  */
    1276 void Renderer::setContourList(const DataSetId& id, const std::vector<double>& contours)
    1277 {
    1278     Contour2DHashmap::iterator itr;
    1279 
    1280     bool doAll = false;
    1281 
    1282     if (id.compare("all") == 0) {
    1283         itr = _contours.begin();
    1284         doAll = true;
    1285     } else {
    1286         itr = _contours.find(id);
    1287     }
    1288     if (itr == _contours.end()) {
    1289         ERROR("Contour2D not found: %s", id.c_str());
    1290         return;
    1291     }
    1292 
    1293     do {
    1294         itr->second->setContourList(contours);
    1295     } while (doAll && ++itr != _contours.end());
    1296 
    1297      _needsRedraw = true;
    1298 }
    1299 
    1300 /**
    1301  * \brief Set opacity of contour lines for the given DataSet
    1302  */
    1303 void Renderer::setContourOpacity(const DataSetId& id, double opacity)
    1304 {
    1305     Contour2DHashmap::iterator itr;
    1306 
    1307     bool doAll = false;
    1308 
    1309     if (id.compare("all") == 0) {
    1310         itr = _contours.begin();
    1311         doAll = true;
    1312     } else {
    1313         itr = _contours.find(id);
    1314     }
    1315     if (itr == _contours.end()) {
    1316         ERROR("Contour2D not found: %s", id.c_str());
    1317         return;
    1318     }
    1319 
    1320     do {
    1321         itr->second->setOpacity(opacity);
    1322     } while (doAll && ++itr != _contours.end());
    1323 
    1324     _needsRedraw = true;
    1325 }
    1326 
    1327 /**
    1328  * \brief Turn on/off rendering contour lines for the given DataSet
    1329  */
    1330 void Renderer::setContourVisibility(const DataSetId& id, bool state)
    1331 {
    1332     Contour2DHashmap::iterator itr;
    1333 
    1334     bool doAll = false;
    1335 
    1336     if (id.compare("all") == 0) {
    1337         itr = _contours.begin();
    1338         doAll = true;
    1339     } else {
    1340         itr = _contours.find(id);
    1341     }
    1342     if (itr == _contours.end()) {
    1343         ERROR("Contour2D not found: %s", id.c_str());
    1344         return;
    1345     }
    1346 
    1347     do {
    1348         itr->second->setVisibility(state);
    1349     } while (doAll && ++itr != _contours.end());
    1350 
    1351     _needsRedraw = true;
    1352 }
    1353 
    1354 /**
    1355  * \brief Set the RGB isoline color for the specified DataSet
    1356  */
    1357 void Renderer::setContourEdgeColor(const DataSetId& id, float color[3])
    1358 {
    1359     Contour2DHashmap::iterator itr;
    1360 
    1361     bool doAll = false;
    1362 
    1363     if (id.compare("all") == 0) {
    1364         itr = _contours.begin();
    1365         doAll = true;
    1366     } else {
    1367         itr = _contours.find(id);
    1368     }
    1369     if (itr == _contours.end()) {
    1370         ERROR("Contour2D not found: %s", id.c_str());
    1371         return;
    1372     }
    1373 
    1374     do {
    1375         itr->second->setEdgeColor(color);
    1376     } while (doAll && ++itr != _contours.end());
    1377 
    1378     _needsRedraw = true;
    1379 }
    1380 
    1381 /**
    1382  * \brief Set the isoline width for the specified DataSet (may be a no-op)
    1383  *
    1384  * If the OpenGL implementation/hardware does not support wide lines,
    1385  * this function may not have an effect.
    1386  */
    1387 void Renderer::setContourEdgeWidth(const DataSetId& id, float edgeWidth)
    1388 {
    1389     Contour2DHashmap::iterator itr;
    1390 
    1391     bool doAll = false;
    1392 
    1393     if (id.compare("all") == 0) {
    1394         itr = _contours.begin();
    1395         doAll = true;
    1396     } else {
    1397         itr = _contours.find(id);
    1398     }
    1399     if (itr == _contours.end()) {
    1400         ERROR("Contour2D not found: %s", id.c_str());
    1401         return;
    1402     }
    1403 
    1404     do {
    1405         itr->second->setEdgeWidth(edgeWidth);
    1406     } while (doAll && ++itr != _contours.end());
    1407 
    1408     _needsRedraw = true;
    1409 }
    1410 
    1411 /**
    1412  * \brief Turn contour lighting on/off for the specified DataSet
    1413  */
    1414 void Renderer::setContourLighting(const DataSetId& id, bool state)
    1415 {
    1416     Contour2DHashmap::iterator itr;
    1417 
    1418     bool doAll = false;
    1419 
    1420     if (id.compare("all") == 0) {
    1421         itr = _contours.begin();
    1422         doAll = true;
    1423     } else {
    1424         itr = _contours.find(id);
    1425     }
    1426     if (itr == _contours.end()) {
    1427         ERROR("Contour2D not found: %s", id.c_str());
    1428         return;
    1429     }
    1430 
    1431     do {
    1432         itr->second->setLighting(state);
    1433     } while (doAll && ++itr != _contours.end());
     1444    } while (doAll && ++itr != _glyphs.end());
    14341445    _needsRedraw = true;
    14351446}
     
    21922203        itr->second->setLighting(state);
    21932204    } while (doAll && ++itr != _polyDatas.end());
     2205
     2206    _needsRedraw = true;
     2207}
     2208
     2209/**
     2210 * \brief Create a new PseudoColor rendering for the specified DataSet
     2211 */
     2212void Renderer::addPseudoColor(const DataSetId& id)
     2213{
     2214    DataSetHashmap::iterator itr;
     2215
     2216    bool doAll = false;
     2217
     2218    if (id.compare("all") == 0) {
     2219        itr = _dataSets.begin();
     2220    } else {
     2221        itr = _dataSets.find(id);
     2222    }
     2223    if (itr == _dataSets.end()) {
     2224        ERROR("Unknown dataset %s", id.c_str());
     2225        return;
     2226    }
     2227
     2228    do {
     2229        DataSet *ds = itr->second;
     2230        const DataSetId& dsID = ds->getName();
     2231
     2232        if (getPseudoColor(dsID)) {
     2233            WARN("Replacing existing pseudocolor %s", dsID.c_str());
     2234            deletePseudoColor(dsID);
     2235        }
     2236        PseudoColor *pc = new PseudoColor();
     2237        _pseudoColors[dsID] = pc;
     2238
     2239        pc->setDataSet(ds);
     2240
     2241        // Use the default color map
     2242        vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New();
     2243        ColorMap *cmap = getColorMap("default");
     2244        lut->DeepCopy(cmap->getLookupTable());
     2245        if (_useCumulativeRange) {
     2246            lut->SetRange(_cumulativeDataRange);
     2247        } else {
     2248            double range[2];
     2249            ds->getDataRange(range);
     2250            lut->SetRange(range);
     2251        }
     2252
     2253        pc->setLookupTable(lut);
     2254
     2255        _renderer->AddViewProp(pc->getProp());
     2256    } while (doAll && ++itr != _dataSets.end());
     2257
     2258    initCamera();
     2259    _needsRedraw = true;
     2260}
     2261
     2262/**
     2263 * \brief Get the PseudoColor associated with the specified DataSet
     2264 */
     2265PseudoColor *Renderer::getPseudoColor(const DataSetId& id)
     2266{
     2267    PseudoColorHashmap::iterator itr = _pseudoColors.find(id);
     2268
     2269    if (itr == _pseudoColors.end()) {
     2270        TRACE("PseudoColor not found: %s", id.c_str());
     2271        return NULL;
     2272    } else
     2273        return itr->second;
     2274}
     2275
     2276/**
     2277 * \brief Associate an existing named color map with a PseudoColor for the given DataSet
     2278 */
     2279void Renderer::setPseudoColorColorMap(const DataSetId& id, const ColorMapId& colorMapId)
     2280{
     2281    PseudoColorHashmap::iterator itr;
     2282
     2283    bool doAll = false;
     2284
     2285    if (id.compare("all") == 0) {
     2286        itr = _pseudoColors.begin();
     2287        doAll = true;
     2288    } else {
     2289        itr = _pseudoColors.find(id);
     2290    }
     2291
     2292    if (itr == _pseudoColors.end()) {
     2293        ERROR("PseudoColor not found: %s", id.c_str());
     2294        return;
     2295    }
     2296
     2297    ColorMap *cmap = getColorMap(colorMapId);
     2298    if (cmap == NULL) {
     2299        ERROR("Unknown colormap: %s", colorMapId.c_str());
     2300        return;
     2301    }
     2302
     2303    do {
     2304        TRACE("Set PseudoColor color map: %s for dataset %s", colorMapId.c_str(),
     2305              itr->second->getDataSet()->getName().c_str());
     2306
     2307        // Make a copy of the generic colormap lookup table, so
     2308        // data range can be set in the copy table to match the
     2309        // dataset being plotted
     2310        vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New();
     2311        lut->DeepCopy(cmap->getLookupTable());
     2312
     2313        if (_useCumulativeRange) {
     2314            lut->SetRange(_cumulativeDataRange);
     2315        } else {
     2316            if (itr->second->getDataSet() != NULL) {
     2317                double range[2];
     2318                itr->second->getDataSet()->getDataRange(range);
     2319                lut->SetRange(range);
     2320            }
     2321        }
     2322
     2323        itr->second->setLookupTable(lut);
     2324    } while (doAll && ++itr != _pseudoColors.end());
     2325
     2326    _needsRedraw = true;
     2327}
     2328
     2329/**
     2330 * \brief Set opacity of the PseudoColor for the given DataSet
     2331 */
     2332void Renderer::setPseudoColorOpacity(const DataSetId& id, double opacity)
     2333{
     2334    PseudoColorHashmap::iterator itr;
     2335
     2336    bool doAll = false;
     2337
     2338    if (id.compare("all") == 0) {
     2339        itr = _pseudoColors.begin();
     2340        doAll = true;
     2341    } else {
     2342        itr = _pseudoColors.find(id);
     2343    }
     2344
     2345    if (itr == _pseudoColors.end()) {
     2346        ERROR("PseudoColor not found: %s", id.c_str());
     2347        return;
     2348    }
     2349
     2350    do {
     2351        itr->second->setOpacity(opacity);
     2352    } while (doAll && ++itr != _pseudoColors.end());
     2353
     2354    _needsRedraw = true;
     2355}
     2356
     2357/**
     2358 * \brief Turn on/off rendering of the PseudoColor mapper for the given DataSet
     2359 */
     2360void Renderer::setPseudoColorVisibility(const DataSetId& id, bool state)
     2361{
     2362    PseudoColorHashmap::iterator itr;
     2363
     2364    bool doAll = false;
     2365
     2366    if (id.compare("all") == 0) {
     2367        itr = _pseudoColors.begin();
     2368        doAll = true;
     2369    } else {
     2370        itr = _pseudoColors.find(id);
     2371    }
     2372
     2373    if (itr == _pseudoColors.end()) {
     2374        ERROR("PseudoColor not found: %s", id.c_str());
     2375        return;
     2376    }
     2377
     2378    do {
     2379        itr->second->setVisibility(state);
     2380    } while (doAll && ++itr != _pseudoColors.end());
     2381
     2382    _needsRedraw = true;
     2383}
     2384
     2385/**
     2386 * \brief Set the visibility of polygon edges for the specified DataSet
     2387 */
     2388void Renderer::setPseudoColorEdgeVisibility(const DataSetId& id, bool state)
     2389{
     2390    PseudoColorHashmap::iterator itr;
     2391
     2392    bool doAll = false;
     2393
     2394    if (id.compare("all") == 0) {
     2395        itr = _pseudoColors.begin();
     2396        doAll = true;
     2397    } else {
     2398        itr = _pseudoColors.find(id);
     2399    }
     2400
     2401    if (itr == _pseudoColors.end()) {
     2402        ERROR("PseudoColor not found: %s", id.c_str());
     2403        return;
     2404    }
     2405
     2406    do {
     2407        itr->second->setEdgeVisibility(state);
     2408    } while (doAll && ++itr != _pseudoColors.end());
     2409
     2410    _needsRedraw = true;
     2411}
     2412
     2413/**
     2414 * \brief Set the RGB polygon edge color for the specified DataSet
     2415 */
     2416void Renderer::setPseudoColorEdgeColor(const DataSetId& id, float color[3])
     2417{
     2418    PseudoColorHashmap::iterator itr;
     2419
     2420    bool doAll = false;
     2421
     2422    if (id.compare("all") == 0) {
     2423        itr = _pseudoColors.begin();
     2424        doAll = true;
     2425    } else {
     2426        itr = _pseudoColors.find(id);
     2427    }
     2428
     2429    if (itr == _pseudoColors.end()) {
     2430        ERROR("PseudoColor not found: %s", id.c_str());
     2431        return;
     2432    }
     2433
     2434    do {
     2435        itr->second->setEdgeColor(color);
     2436    } while (doAll && ++itr != _pseudoColors.end());
     2437
     2438    _needsRedraw = true;
     2439}
     2440
     2441/**
     2442 * \brief Set the polygon edge width for the specified DataSet (may be a no-op)
     2443 *
     2444 * If the OpenGL implementation/hardware does not support wide lines,
     2445 * this function may not have an effect.
     2446 */
     2447void Renderer::setPseudoColorEdgeWidth(const DataSetId& id, float edgeWidth)
     2448{
     2449    PseudoColorHashmap::iterator itr;
     2450
     2451    bool doAll = false;
     2452
     2453    if (id.compare("all") == 0) {
     2454        itr = _pseudoColors.begin();
     2455        doAll = true;
     2456    } else {
     2457        itr = _pseudoColors.find(id);
     2458    }
     2459
     2460    if (itr == _pseudoColors.end()) {
     2461        ERROR("PseudoColor not found: %s", id.c_str());
     2462        return;
     2463    }
     2464
     2465    do {
     2466        itr->second->setEdgeWidth(edgeWidth);
     2467    } while (doAll && ++itr != _pseudoColors.end());
     2468
     2469    _needsRedraw = true;
     2470}
     2471
     2472/**
     2473 * \brief Turn mesh lighting on/off for the specified DataSet
     2474 */
     2475void Renderer::setPseudoColorLighting(const DataSetId& id, bool state)
     2476{
     2477    PseudoColorHashmap::iterator itr;
     2478
     2479    bool doAll = false;
     2480
     2481    if (id.compare("all") == 0) {
     2482        itr = _pseudoColors.begin();
     2483        doAll = true;
     2484    } else {
     2485        itr = _pseudoColors.find(id);
     2486    }
     2487
     2488    if (itr == _pseudoColors.end()) {
     2489        ERROR("PseudoColor not found: %s", id.c_str());
     2490        return;
     2491    }
     2492
     2493    do {
     2494        itr->second->setLighting(state);
     2495    } while (doAll && ++itr != _pseudoColors.end());
    21942496
    21952497    _needsRedraw = true;
     
    30813383    bounds[5] = -DBL_MAX;
    30823384
    3083     for (PseudoColorHashmap::iterator itr = _pseudoColors.begin();
    3084              itr != _pseudoColors.end(); ++itr) {
    3085         if (!onlyVisible || itr->second->getVisibility())
    3086             mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds());
    3087     }
    30883385    for (Contour2DHashmap::iterator itr = _contours.begin();
    30893386             itr != _contours.end(); ++itr) {
     
    30913388            mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds());
    30923389    }
     3390    for (GlyphsHashmap::iterator itr = _glyphs.begin();
     3391             itr != _glyphs.end(); ++itr) {
     3392        if (!onlyVisible || itr->second->getVisibility())
     3393            mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds());
     3394    }
    30933395    for (HeightMapHashmap::iterator itr = _heightMaps.begin();
    30943396             itr != _heightMaps.end(); ++itr) {
     
    30983400    for (PolyDataHashmap::iterator itr = _polyDatas.begin();
    30993401             itr != _polyDatas.end(); ++itr) {
     3402        if (!onlyVisible || itr->second->getVisibility())
     3403            mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds());
     3404    }
     3405    for (PseudoColorHashmap::iterator itr = _pseudoColors.begin();
     3406             itr != _pseudoColors.end(); ++itr) {
    31003407        if (!onlyVisible || itr->second->getVisibility())
    31013408            mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds());
     
    31313438void Renderer::updateRanges(bool useCumulative)
    31323439{
    3133     for (PseudoColorHashmap::iterator itr = _pseudoColors.begin();
    3134          itr != _pseudoColors.end(); ++itr) {
     3440    for (Contour2DHashmap::iterator itr = _contours.begin();
     3441         itr != _contours.end(); ++itr) {
     3442        // Only need to update range if using evenly spaced contours
     3443        if (itr->second->getContourList().empty()) {
     3444            if (useCumulative) {
     3445                itr->second->setContours(itr->second->getNumContours(), _cumulativeDataRange);
     3446            } else {
     3447                itr->second->setContours(itr->second->getNumContours());
     3448            }
     3449        }
     3450    }
     3451    for (GlyphsHashmap::iterator itr = _glyphs.begin();
     3452         itr != _glyphs.end(); ++itr) {
    31353453        vtkLookupTable *lut = itr->second->getLookupTable();
    31363454        if (lut) {
     
    31433461                    lut->SetRange(range);
    31443462                }
    3145             }
    3146         }
    3147     }
    3148     for (Contour2DHashmap::iterator itr = _contours.begin();
    3149          itr != _contours.end(); ++itr) {
    3150         // Only need to update range if using evenly spaced contours
    3151         if (itr->second->getContourList().empty()) {
    3152             if (useCumulative) {
    3153                 itr->second->setContours(itr->second->getNumContours(), _cumulativeDataRange);
    3154             } else {
    3155                 itr->second->setContours(itr->second->getNumContours());
    31563463            }
    31573464        }
     
    31773484            } else {
    31783485                itr->second->setContours(itr->second->getNumContours());
     3486            }
     3487        }
     3488    }
     3489    for (PseudoColorHashmap::iterator itr = _pseudoColors.begin();
     3490         itr != _pseudoColors.end(); ++itr) {
     3491        vtkLookupTable *lut = itr->second->getLookupTable();
     3492        if (lut) {
     3493            if (useCumulative) {
     3494                lut->SetRange(_cumulativeDataRange);
     3495            } else {
     3496                double range[2];
     3497                if (itr->second->getDataSet()) {
     3498                    itr->second->getDataSet()->getDataRange(range);
     3499                    lut->SetRange(range);
     3500                }
    31793501            }
    31803502        }
     
    33143636void Renderer::setOpacity(const DataSetId& id, double opacity)
    33153637{
    3316     if (id.compare("all") == 0 || getPseudoColor(id) != NULL)
    3317         setPseudoColorOpacity(id, opacity);
    33183638    if (id.compare("all") == 0 || getContour2D(id) != NULL)
    33193639        setContourOpacity(id, opacity);
     3640    if (id.compare("all") == 0 || getGlyphs(id) != NULL)
     3641        setGlyphsOpacity(id, opacity);
    33203642    if (id.compare("all") == 0 || getHeightMap(id) != NULL)
    33213643        setHeightMapOpacity(id, opacity);
    33223644    if (id.compare("all") == 0 || getPolyData(id) != NULL)
    33233645        setPolyDataOpacity(id, opacity);
     3646    if (id.compare("all") == 0 || getPseudoColor(id) != NULL)
     3647        setPseudoColorOpacity(id, opacity);
    33243648    if (id.compare("all") == 0 || getVolume(id) != NULL)
    33253649        setVolumeOpacity(id, opacity);
     
    33503674    } while (doAll && ++itr != _dataSets.end());
    33513675
    3352     if (id.compare("all") == 0 || getPseudoColor(id) != NULL)
    3353         setPseudoColorVisibility(id, state);
    33543676    if (id.compare("all") == 0 || getContour2D(id) != NULL)
    33553677        setContourVisibility(id, state);
     3678    if (id.compare("all") == 0 || getGlyphs(id) != NULL)
     3679        setGlyphsVisibility(id, state);
    33563680    if (id.compare("all") == 0 || getHeightMap(id) != NULL)
    33573681        setHeightMapVisibility(id, state);
    33583682    if (id.compare("all") == 0 || getPolyData(id) != NULL)
    33593683        setPolyDataVisibility(id, state);
     3684    if (id.compare("all") == 0 || getPseudoColor(id) != NULL)
     3685        setPseudoColorVisibility(id, state);
    33603686    if (id.compare("all") == 0 || getVolume(id) != NULL)
    33613687        setVolumeVisibility(id, state);
     
    33723698    if (_needsRedraw) {
    33733699        if (_cameraMode == IMAGE) {
    3374             for (PseudoColorHashmap::iterator itr = _pseudoColors.begin();
    3375                  itr != _pseudoColors.end(); ++itr) {
     3700            for (Contour2DHashmap::iterator itr = _contours.begin();
     3701                 itr != _contours.end(); ++itr) {
    33763702                itr->second->setClippingPlanes(_clippingPlanes);
    33773703            }
    3378             for (Contour2DHashmap::iterator itr = _contours.begin();
    3379                  itr != _contours.end(); ++itr) {
     3704            for (GlyphsHashmap::iterator itr = _glyphs.begin();
     3705                 itr != _glyphs.end(); ++itr) {
    33803706                itr->second->setClippingPlanes(_clippingPlanes);
    33813707            }
     
    33883714                itr->second->setClippingPlanes(_clippingPlanes);
    33893715            }
     3716            for (PseudoColorHashmap::iterator itr = _pseudoColors.begin();
     3717                 itr != _pseudoColors.end(); ++itr) {
     3718                itr->second->setClippingPlanes(_clippingPlanes);
     3719            }
    33903720            for (VolumeHashmap::iterator itr = _volumes.begin();
    33913721                 itr != _volumes.end(); ++itr) {
     
    33933723            }
    33943724        } else {
    3395             for (PseudoColorHashmap::iterator itr = _pseudoColors.begin();
    3396                  itr != _pseudoColors.end(); ++itr) {
     3725            for (Contour2DHashmap::iterator itr = _contours.begin();
     3726                 itr != _contours.end(); ++itr) {
    33973727                itr->second->setClippingPlanes(NULL);
    33983728            }
    3399             for (Contour2DHashmap::iterator itr = _contours.begin();
    3400                  itr != _contours.end(); ++itr) {
     3729            for (GlyphsHashmap::iterator itr = _glyphs.begin();
     3730                 itr != _glyphs.end(); ++itr) {
    34013731                itr->second->setClippingPlanes(NULL);
    34023732            }
     
    34073737            for (PolyDataHashmap::iterator itr = _polyDatas.begin();
    34083738                 itr != _polyDatas.end(); ++itr) {
     3739                itr->second->setClippingPlanes(NULL);
     3740            }
     3741            for (PseudoColorHashmap::iterator itr = _pseudoColors.begin();
     3742                 itr != _pseudoColors.end(); ++itr) {
    34093743                itr->second->setClippingPlanes(NULL);
    34103744            }
  • trunk/packages/vizservers/vtkvis/RpVtkRenderer.h

    r2261 r2269  
    2727#include "ColorMap.h"
    2828#include "RpVtkDataSet.h"
    29 #include "RpPseudoColor.h"
    3029#include "RpContour2D.h"
     30#include "RpGlyphs.h"
    3131#include "RpHeightMap.h"
    3232#include "RpPolyData.h"
     33#include "RpPseudoColor.h"
    3334#include "RpVolume.h"
    3435#include "Trace.h"
     
    7475    typedef std::tr1::unordered_map<DataSetId, DataSet *> DataSetHashmap;
    7576    typedef std::tr1::unordered_map<ColorMapId, ColorMap *> ColorMapHashmap;
    76     typedef std::tr1::unordered_map<DataSetId, PseudoColor *> PseudoColorHashmap;
    7777    typedef std::tr1::unordered_map<DataSetId, Contour2D *> Contour2DHashmap;
     78    typedef std::tr1::unordered_map<DataSetId, Glyphs *> GlyphsHashmap;
    7879    typedef std::tr1::unordered_map<DataSetId, HeightMap *> HeightMapHashmap;
    7980    typedef std::tr1::unordered_map<DataSetId, PolyData *> PolyDataHashmap;
     81    typedef std::tr1::unordered_map<DataSetId, PseudoColor *> PseudoColorHashmap;
    8082    typedef std::tr1::unordered_map<DataSetId, Volume *> VolumeHashmap;
    8183
     
    180182                        vtkUnsignedCharArray *imgData);
    181183
    182     // Color-mapped surfaces
    183 
    184     void addPseudoColor(const DataSetId& id);
    185 
    186     void deletePseudoColor(const DataSetId& id);
    187 
    188     PseudoColor *getPseudoColor(const DataSetId& id);
    189 
    190     void setPseudoColorColorMap(const DataSetId& id, const ColorMapId& colorMapId);
    191 
    192     void setPseudoColorOpacity(const DataSetId& id, double opacity);
    193 
    194     void setPseudoColorVisibility(const DataSetId& id, bool state);
    195 
    196     void setPseudoColorEdgeVisibility(const DataSetId& id, bool state);
    197 
    198     void setPseudoColorEdgeColor(const DataSetId& id, float color[3]);
    199 
    200     void setPseudoColorEdgeWidth(const DataSetId& id, float edgeWidth);
    201 
    202     void setPseudoColorLighting(const DataSetId& id, bool state);
    203 
    204184    // Contour plots
    205185
     
    223203
    224204    void setContourLighting(const DataSetId& id, bool state);
     205
     206    // Glyphs
     207
     208    void addGlyphs(const DataSetId& id);
     209
     210    void deleteGlyphs(const DataSetId& id);
     211
     212    Glyphs *getGlyphs(const DataSetId& id);
     213
     214    void setGlyphsColorMap(const DataSetId& id, const ColorMapId& colorMapId);
     215
     216    void setGlyphsShape(const DataSetId& id, Glyphs::GlyphShape shape);
     217
     218    void setGlyphsScaleFactor(const DataSetId& id, double scale);
     219
     220    void setGlyphsOpacity(const DataSetId& id, double opacity);
     221
     222    void setGlyphsVisibility(const DataSetId& id, bool state);
     223
     224    void setGlyphsLighting(const DataSetId& id, bool state);
    225225
    226226    // Height maps
     
    283283
    284284    void setPolyDataLighting(const DataSetId& id, bool state);
     285
     286    // Color-mapped surfaces
     287
     288    void addPseudoColor(const DataSetId& id);
     289
     290    void deletePseudoColor(const DataSetId& id);
     291
     292    PseudoColor *getPseudoColor(const DataSetId& id);
     293
     294    void setPseudoColorColorMap(const DataSetId& id, const ColorMapId& colorMapId);
     295
     296    void setPseudoColorOpacity(const DataSetId& id, double opacity);
     297
     298    void setPseudoColorVisibility(const DataSetId& id, bool state);
     299
     300    void setPseudoColorEdgeVisibility(const DataSetId& id, bool state);
     301
     302    void setPseudoColorEdgeColor(const DataSetId& id, float color[3]);
     303
     304    void setPseudoColorEdgeWidth(const DataSetId& id, float edgeWidth);
     305
     306    void setPseudoColorLighting(const DataSetId& id, bool state);
    285307
    286308    // Volumes
     
    353375    ColorMapHashmap _colorMaps;
    354376    DataSetHashmap _dataSets;
    355     PseudoColorHashmap _pseudoColors;
    356377    Contour2DHashmap _contours;
     378    GlyphsHashmap _glyphs;
    357379    HeightMapHashmap _heightMaps;
    358380    PolyDataHashmap _polyDatas;
     381    PseudoColorHashmap _pseudoColors;
    359382    VolumeHashmap _volumes;
    360383
  • trunk/packages/vizservers/vtkvis/RpVtkRendererCmd.cpp

    r2261 r2269  
    930930
    931931    proc = Rappture::GetOpFromObj(interp, nDataSetOps, dataSetOps,
     932                                  Rappture::CMDSPEC_ARG1, objc, objv, 0);
     933    if (proc == NULL) {
     934        return TCL_ERROR;
     935    }
     936    return (*proc) (clientData, interp, objc, objv);
     937}
     938
     939static int
     940GlyphsAddOp(ClientData clientData, Tcl_Interp *interp, int objc,
     941            Tcl_Obj *const *objv)
     942{
     943    Glyphs::GlyphShape shape;
     944
     945    const char *shapeOpt = Tcl_GetString(objv[2]);
     946    if (shapeOpt[0] == 'a' && strcmp(shapeOpt, "arrow") == 0) {
     947        shape = Glyphs::ARROW;
     948    } else if (shapeOpt[0] == 'c' && strcmp(shapeOpt, "cone") == 0) {
     949        shape = Glyphs::CONE;
     950    } else if (shapeOpt[0] == 'c' && strcmp(shapeOpt, "cube") == 0) {
     951        shape = Glyphs::CUBE;
     952    } else if (shapeOpt[0] == 'c' && strcmp(shapeOpt, "cylinder") == 0) {
     953        shape = Glyphs::CYLINDER;
     954    } else if (shapeOpt[0] == 'd' && strcmp(shapeOpt, "dodecahedron") == 0) {
     955        shape = Glyphs::DODECAHEDRON;
     956    } else if (shapeOpt[0] == 'i' && strcmp(shapeOpt, "icosahedron") == 0) {
     957        shape = Glyphs::ICOSAHEDRON;
     958    } else if (shapeOpt[0] == 'o' && strcmp(shapeOpt, "octahedron") == 0) {
     959        shape = Glyphs::OCTAHEDRON;
     960    } else if (shapeOpt[0] == 's' && strcmp(shapeOpt, "sphere") == 0) {
     961        shape = Glyphs::SPHERE;
     962    } else if (shapeOpt[0] == 't' && strcmp(shapeOpt, "tetrahedron") == 0) {
     963        shape = Glyphs::TETRAHEDRON;
     964    } else {
     965        Tcl_AppendResult(interp, "bad shape option \"", shapeOpt,
     966                         "\": should be one of: 'arrow', 'cone', 'cube', 'cylinder', 'dodecahedron', 'icosahedron', 'octahedron', 'sphere', 'tetrahedron'", (char*)NULL);
     967        return TCL_ERROR;
     968    }
     969
     970    if (objc == 4) {
     971        const char *name = Tcl_GetString(objv[3]);
     972        g_renderer->addGlyphs(name);
     973        g_renderer->setGlyphsShape(name, shape);
     974    } else {
     975        g_renderer->addGlyphs("all");
     976        g_renderer->setGlyphsShape("all", shape);
     977    }
     978    return TCL_OK;
     979}
     980
     981static int
     982GlyphsColorMapOp(ClientData clientData, Tcl_Interp *interp, int objc,
     983                 Tcl_Obj *const *objv)
     984{
     985    const char *colorMapName = Tcl_GetString(objv[2]);
     986    if (objc == 4) {
     987        const char *dataSetName = Tcl_GetString(objv[3]);
     988        g_renderer->setGlyphsColorMap(dataSetName, colorMapName);
     989    } else {
     990        g_renderer->setGlyphsColorMap("all", colorMapName);
     991    }
     992    return TCL_OK;
     993}
     994
     995static int
     996GlyphsDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc,
     997               Tcl_Obj *const *objv)
     998{
     999    if (objc == 3) {
     1000        const char *name = Tcl_GetString(objv[2]);
     1001        g_renderer->deleteGlyphs(name);
     1002    } else {
     1003        g_renderer->deleteGlyphs("all");
     1004    }
     1005    return TCL_OK;
     1006}
     1007
     1008static int
     1009GlyphsLightingOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1010                 Tcl_Obj *const *objv)
     1011{
     1012    bool state;
     1013    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     1014        return TCL_ERROR;
     1015    }
     1016    if (objc == 4) {
     1017        const char *name = Tcl_GetString(objv[3]);
     1018        g_renderer->setGlyphsLighting(name, state);
     1019    } else {
     1020        g_renderer->setGlyphsLighting("all", state);
     1021    }
     1022    return TCL_OK;
     1023}
     1024
     1025static int
     1026GlyphsOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1027                Tcl_Obj *const *objv)
     1028{
     1029    double opacity;
     1030    if (Tcl_GetDoubleFromObj(interp, objv[2], &opacity) != TCL_OK) {
     1031        return TCL_ERROR;
     1032    }
     1033    if (objc == 4) {
     1034        const char *name = Tcl_GetString(objv[3]);
     1035        g_renderer->setGlyphsOpacity(name, opacity);
     1036    } else {
     1037        g_renderer->setGlyphsOpacity("all", opacity);
     1038    }
     1039    return TCL_OK;
     1040}
     1041
     1042static int
     1043GlyphsScaleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1044              Tcl_Obj *const *objv)
     1045{
     1046    double scale;
     1047    if (Tcl_GetDoubleFromObj(interp, objv[2], &scale) != TCL_OK) {
     1048        return TCL_ERROR;
     1049    }
     1050    if (objc == 4) {
     1051        const char *name = Tcl_GetString(objv[3]);
     1052        g_renderer->setGlyphsScaleFactor(name, scale);
     1053    } else {
     1054        g_renderer->setGlyphsScaleFactor("all", scale);
     1055    }
     1056    return TCL_OK;
     1057}
     1058
     1059static int
     1060GlyphsShapeOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1061              Tcl_Obj *const *objv)
     1062{
     1063    Glyphs::GlyphShape shape;
     1064
     1065    const char *shapeOpt = Tcl_GetString(objv[2]);
     1066    if (shapeOpt[0] == 'a' && strcmp(shapeOpt, "arrow") == 0) {
     1067        shape = Glyphs::ARROW;
     1068    } else if (shapeOpt[0] == 'c' && strcmp(shapeOpt, "cone") == 0) {
     1069        shape = Glyphs::CONE;
     1070    } else if (shapeOpt[0] == 'c' && strcmp(shapeOpt, "cube") == 0) {
     1071        shape = Glyphs::CUBE;
     1072    } else if (shapeOpt[0] == 'c' && strcmp(shapeOpt, "cylinder") == 0) {
     1073        shape = Glyphs::CYLINDER;
     1074    } else if (shapeOpt[0] == 'd' && strcmp(shapeOpt, "dodecahedron") == 0) {
     1075        shape = Glyphs::DODECAHEDRON;
     1076    } else if (shapeOpt[0] == 'i' && strcmp(shapeOpt, "icosahedron") == 0) {
     1077        shape = Glyphs::ICOSAHEDRON;
     1078    } else if (shapeOpt[0] == 'o' && strcmp(shapeOpt, "octahedron") == 0) {
     1079        shape = Glyphs::OCTAHEDRON;
     1080    } else if (shapeOpt[0] == 's' && strcmp(shapeOpt, "sphere") == 0) {
     1081        shape = Glyphs::SPHERE;
     1082    } else if (shapeOpt[0] == 't' && strcmp(shapeOpt, "tetrahedron") == 0) {
     1083        shape = Glyphs::TETRAHEDRON;
     1084    } else {
     1085        Tcl_AppendResult(interp, "bad shape option \"", shapeOpt,
     1086                         "\": should be one of: 'arrow', 'cone', 'cube', 'cylinder', 'dodecahedron', 'icosahedron', 'octahedron', 'sphere', 'tetrahedron'", (char*)NULL);
     1087        return TCL_ERROR;
     1088    }
     1089
     1090    if (objc == 4) {
     1091        const char *name = Tcl_GetString(objv[3]);
     1092        g_renderer->setGlyphsShape(name, shape);
     1093    } else {
     1094        g_renderer->setGlyphsShape("all", shape);
     1095    }
     1096    return TCL_OK;
     1097}
     1098
     1099static int
     1100GlyphsVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1101                Tcl_Obj *const *objv)
     1102{
     1103    bool state;
     1104    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     1105        return TCL_ERROR;
     1106    }
     1107    if (objc == 4) {
     1108        const char *name = Tcl_GetString(objv[3]);
     1109        g_renderer->setGlyphsVisibility(name, state);
     1110    } else {
     1111        g_renderer->setGlyphsVisibility("all", state);
     1112    }
     1113    return TCL_OK;
     1114}
     1115
     1116static Rappture::CmdSpec glyphsOps[] = {
     1117    {"add",      1, GlyphsAddOp, 3, 4, "shape ?dataSetNme?"},
     1118    {"colormap", 1, GlyphsColorMapOp, 3, 4, "colorMapName ?dataSetNme?"},
     1119    {"delete",   1, GlyphsDeleteOp, 2, 3, "?dataSetName?"},
     1120    {"lighting", 1, GlyphsLightingOp, 3, 4, "bool ?dataSetName?"},
     1121    {"opacity",  1, GlyphsOpacityOp, 3, 4, "value ?dataSetName?"},
     1122    {"scale",    2, GlyphsScaleOp, 3, 4, "scaleFactor ?dataSetName?"},
     1123    {"shape",    2, GlyphsShapeOp, 3, 4, "shapeVal ?dataSetName?"},
     1124    {"visible",  1, GlyphsVisibleOp, 3, 4, "bool ?dataSetName?"}
     1125};
     1126static int nGlyphsOps = NumCmdSpecs(glyphsOps);
     1127
     1128static int
     1129GlyphsCmd(ClientData clientData, Tcl_Interp *interp, int objc,
     1130          Tcl_Obj *const *objv)
     1131{
     1132    Tcl_ObjCmdProc *proc;
     1133
     1134    proc = Rappture::GetOpFromObj(interp, nGlyphsOps, glyphsOps,
    9321135                                  Rappture::CMDSPEC_ARG1, objc, objv, 0);
    9331136    if (proc == NULL) {
     
    20302233    Tcl_CreateObjCommand(interp, "contour2d",   Contour2DCmd,   NULL, NULL);
    20312234    Tcl_CreateObjCommand(interp, "dataset",     DataSetCmd,     NULL, NULL);
     2235    Tcl_CreateObjCommand(interp, "glyphs",      GlyphsCmd,      NULL, NULL);
    20322236    Tcl_CreateObjCommand(interp, "heightmap",   HeightMapCmd,   NULL, NULL);
    20332237    Tcl_CreateObjCommand(interp, "legend",      LegendCmd,      NULL, NULL);
  • trunk/packages/vizservers/vtkvis/protocol.txt

    r2261 r2269  
    6262dataset visible <bool> <?datasetName?>
    6363
    64 pseudocolor add <?datasetName?>
    65 pseudocolor colormap <colormapName> <?datasetName?>
    66 pseudocolor delete <?datasetName?>
    67 pseudocolor edges <bool> <?datasetName?>
    68 pseudocolor lighting <bool> <?datasetName?>
    69 pseudocolor linecolor <r> <g> <b> <?datasetName?>
    70 pseudocolor linewidth <val> <?datasetName?>
    71 pseudocolor opacity <val> <?datasetName?>
    72 pseudocolor visible <bool> <?datasetName?>
    73 
    7464contour2d add numcontours <n> <?datasetName?>
    7565          Generate evenly spaced contours including range endpoints.  See also
     
    8373contour2d opacity <val> <?datasetName?>
    8474contour2d visible <bool> <?datasetName?>
     75
     76glyphs add <?dataSetName?>
     77glyphs colormap <colorMapName> <?dataSetName?>
     78glyphs delete <?dataSetName?>
     79glyphs lighting <bool> <?datasetName?>
     80glyphs opacity <val> <?datasetName?>
     81glyphs scale <scaleFactor> <?datasetName?>
     82glyphs shape <arrow|cone|cube|cylinder|dodecahedron|icosahedron|octahedron|sphere|tetrahedron> <?datasetName?>
     83glyphs visible <bool> <?datasetName?>
    8584
    8685heightmap add numcontours <n> <?dataSetName?>
     
    116115polydata wireframe <bool> <?datasetName?>
    117116
     117pseudocolor add <?datasetName?>
     118pseudocolor colormap <colormapName> <?datasetName?>
     119pseudocolor delete <?datasetName?>
     120pseudocolor edges <bool> <?datasetName?>
     121pseudocolor lighting <bool> <?datasetName?>
     122pseudocolor linecolor <r> <g> <b> <?datasetName?>
     123pseudocolor linewidth <val> <?datasetName?>
     124pseudocolor opacity <val> <?datasetName?>
     125pseudocolor visible <bool> <?datasetName?>
     126
    118127volume add <?datasetName?>
    119128volume colormap <colorMapName> <?datasetName?>
Note: See TracChangeset for help on using the changeset viewer.