Changeset 2261 for trunk/packages
- Timestamp:
- May 26, 2011 11:29:27 PM (13 years ago)
- Location:
- trunk/packages/vizservers/vtkvis
- Files:
-
- 2 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/vtkvis/ColorMap.cpp
r2194 r2261 10 10 #include <cassert> 11 11 #include <vtkLookupTable.h> 12 #include <vtkColorTransferFunction.h> 13 #include <vtkPiecewiseFunction.h> 12 14 13 15 #include "ColorMap.h" … … 15 17 16 18 using namespace Rappture::VtkVis; 19 20 ColorMap *ColorMap::_default = NULL; 21 ColorMap *ColorMap::_volumeDefault = NULL; 17 22 18 23 ColorMap::ColorMap(const std::string& name) : … … 21 26 _numTableEntries(256) 22 27 { 28 _colorTF = vtkSmartPointer<vtkColorTransferFunction>::New(); 29 _colorTF->ClampingOn(); 30 _opacityTF = vtkSmartPointer<vtkPiecewiseFunction>::New(); 31 _opacityTF->ClampingOn(); 23 32 } 24 33 … … 43 52 assert(_lookupTable != NULL); 44 53 return _lookupTable; 54 } 55 56 /** 57 * \brief Return a newly allocated color transfer function with values 58 * scaled to the given data range 59 */ 60 vtkSmartPointer<vtkColorTransferFunction> 61 ColorMap::getColorTransferFunction(double range[2]) 62 { 63 vtkSmartPointer<vtkColorTransferFunction> tf = vtkSmartPointer<vtkColorTransferFunction>::New(); 64 tf->DeepCopy(_colorTF); 65 double tmp[6]; 66 for (int i = 0; i < tf->GetSize(); i++) { 67 tf->GetNodeValue(i, tmp); 68 tmp[0] = range[0] + tmp[0] * (range[1] - range[0]); 69 tf->SetNodeValue(i, tmp); 70 } 71 return tf; 72 } 73 74 /** 75 * \brief Return a newly allocated opacity transfer function with values 76 * scaled to the given data range 77 */ 78 vtkSmartPointer<vtkPiecewiseFunction> 79 ColorMap::getOpacityTransferFunction(double range[2]) 80 { 81 vtkSmartPointer<vtkPiecewiseFunction> tf = vtkSmartPointer<vtkPiecewiseFunction>::New(); 82 tf->DeepCopy(_opacityTF); 83 double tmp[4]; 84 for (int i = 0; i < tf->GetSize(); i++) { 85 tf->GetNodeValue(i, tmp); 86 tmp[0] = range[0] + tmp[0] * (range[1] - range[0]); 87 tf->SetNodeValue(i, tmp); 88 } 89 return tf; 45 90 } 46 91 … … 72 117 // If we reach here, our control point goes at the end 73 118 _controlPoints.insert(_controlPoints.end(), cp); 119 _colorTF->AddRGBPoint(cp.value, cp.color[0], cp.color[1], cp.color[2]); 74 120 } 75 121 … … 101 147 // If we reach here, our control point goes at the end 102 148 _opacityControlPoints.insert(_opacityControlPoints.end(), cp); 149 _opacityTF->AddPoint(cp.value, cp.alpha); 103 150 } 104 151 … … 195 242 } 196 243 244 /** 245 * \brief Perform linear interpolation of two color control points 246 */ 197 247 void ColorMap::lerp(double *result, const ControlPoint& cp1, const ControlPoint& cp2, double value) 198 248 { … … 203 253 } 204 254 255 /** 256 * \brief Perform linear interpolation of two opacity control points 257 */ 205 258 void ColorMap::lerp(double *result, const OpacityControlPoint& cp1, const OpacityControlPoint& cp2, double value) 206 259 { … … 215 268 { 216 269 _controlPoints.clear(); 270 _colorTF->RemoveAllPoints(); 217 271 _opacityControlPoints.clear(); 272 _opacityTF->RemoveAllPoints(); 218 273 _lookupTable = NULL; 219 274 } … … 222 277 * \brief Create a default ColorMap with a blue-cyan-green-yellow-red ramp 223 278 */ 224 ColorMap * ColorMap::createDefault() 225 { 226 ColorMap *colorMap = new ColorMap("default"); 279 ColorMap * ColorMap::getDefault() 280 { 281 if (_default != NULL) { 282 return _default; 283 } 284 285 _default = new ColorMap("default"); 227 286 ControlPoint cp[5]; 228 287 cp[0].value = 0.0; … … 247 306 cp[4].color[2] = 0.0; 248 307 for (int i = 0; i < 5; i++) { 249 colorMap->addControlPoint(cp[i]);308 _default->addControlPoint(cp[i]); 250 309 } 251 310 OpacityControlPoint ocp[2]; … … 254 313 ocp[1].value = 1.0; 255 314 ocp[1].alpha = 1.0; 256 colorMap->addOpacityControlPoint(ocp[0]); 257 colorMap->addOpacityControlPoint(ocp[1]); 258 colorMap->build(); 259 return colorMap; 260 } 315 _default->addOpacityControlPoint(ocp[0]); 316 _default->addOpacityControlPoint(ocp[1]); 317 _default->build(); 318 return _default; 319 } 320 321 /** 322 * \brief Create a default ColorMap with a blue-cyan-green-yellow-red ramp 323 * and transparent to opaque ramp 324 */ 325 ColorMap * ColorMap::getVolumeDefault() 326 { 327 if (_volumeDefault != NULL) { 328 return _volumeDefault; 329 } 330 331 _volumeDefault = new ColorMap("volumeDefault"); 332 ControlPoint cp[5]; 333 cp[0].value = 0.0; 334 cp[0].color[0] = 0.0; 335 cp[0].color[1] = 0.0; 336 cp[0].color[2] = 1.0; 337 cp[1].value = 0.25; 338 cp[1].color[0] = 0.0; 339 cp[1].color[1] = 1.0; 340 cp[1].color[2] = 1.0; 341 cp[2].value = 0.5; 342 cp[2].color[0] = 0.0; 343 cp[2].color[1] = 1.0; 344 cp[2].color[2] = 0.0; 345 cp[3].value = 0.75; 346 cp[3].color[0] = 1.0; 347 cp[3].color[1] = 1.0; 348 cp[3].color[2] = 0.0; 349 cp[4].value = 1.0; 350 cp[4].color[0] = 1.0; 351 cp[4].color[1] = 0.0; 352 cp[4].color[2] = 0.0; 353 for (int i = 0; i < 5; i++) { 354 _volumeDefault->addControlPoint(cp[i]); 355 } 356 OpacityControlPoint ocp[2]; 357 ocp[0].value = 0.0; 358 ocp[0].alpha = 0.0; 359 ocp[1].value = 1.0; 360 ocp[1].alpha = 1.0; 361 _volumeDefault->addOpacityControlPoint(ocp[0]); 362 _volumeDefault->addOpacityControlPoint(ocp[1]); 363 _volumeDefault->build(); 364 return _volumeDefault; 365 } -
trunk/packages/vizservers/vtkvis/ColorMap.h
r2194 r2261 13 13 #include <cstring> 14 14 #include <vtkSmartPointer.h> 15 #include <vtkColorTransferFunction.h> 16 #include <vtkPiecewiseFunction.h> 15 17 #include <vtkLookupTable.h> 16 18 … … 84 86 85 87 const std::string& getName(); 88 86 89 vtkLookupTable *getLookupTable(); 90 91 vtkSmartPointer<vtkColorTransferFunction> getColorTransferFunction(double range[2]); 92 93 vtkSmartPointer<vtkPiecewiseFunction> getOpacityTransferFunction(double range[2]); 87 94 88 95 void setNumberOfTableEntries(int numEntries); … … 96 103 void clear(); 97 104 98 static ColorMap* createDefault(); 105 static ColorMap *getDefault(); 106 static ColorMap *getVolumeDefault(); 99 107 100 108 private: 109 static ColorMap *_default; 110 static ColorMap *_volumeDefault; 111 101 112 ColorMap(); 102 113 … … 109 120 bool _needsBuild; 110 121 int _numTableEntries; 122 vtkSmartPointer<vtkColorTransferFunction> _colorTF; 123 vtkSmartPointer<vtkPiecewiseFunction> _opacityTF; 111 124 vtkSmartPointer<vtkLookupTable> _lookupTable; 112 125 }; -
trunk/packages/vizservers/vtkvis/Makefile.in
r2260 r2261 29 29 30 30 VTK_LIB_DIR = @VTK_LIB_DIR@ 31 VTK_LIB_SPEC = -L$(VTK_LIB_DIR) -lvtkIO -lvtkWidgets -lvtk Rendering -lvtkGraphics-lvtkCommon31 VTK_LIB_SPEC = -L$(VTK_LIB_DIR) -lvtkIO -lvtkWidgets -lvtkFiltering -lvtkVolumeRendering -lvtkRendering -lvtkHybrid -lvtkGraphics -lvtkImaging -lvtkCommon 32 32 VTK_INC_SPEC = @VTK_INC_SPEC@ 33 33 … … 45 45 $(VTK_INC_SPEC) 46 46 47 USE_CUSTOM_AXES = #yes48 USE_OFFSCREEN_RENDERING = yes49 47 DEBUG = #yes 50 48 TRACE = #yes 49 USE_CUSTOM_AXES = #yes 50 USE_GPU_RAYCASTING = yes 51 USE_OFFSCREEN_RENDERING = yes 51 52 52 53 EXTRA_CFLAGS = -Wall -Wno-deprecated #vtk uses deprecated strstream header (instead of sstream) … … 65 66 DEFINES += -DUSE_OFFSCREEN_RENDERING 66 67 endif 68 ifdef USE_GPU_RAYCASTING 69 DEFINES += -DUSE_GPU_RAYCAST_MAPPER 70 endif 67 71 CXX_SWITCHES = $(CXXFLAGS) $(EXTRA_CFLAGS) $(DEFINES) $(INCLUDES) 68 72 … … 75 79 RpPolyData.cpp \ 76 80 RpPseudoColor.cpp \ 81 RpVolume.cpp \ 77 82 RpVtkDataSet.cpp \ 78 83 RpVtkRenderer.cpp\ … … 123 128 RpHeightMap.o: RpHeightMap.h RpVtkDataSet.h Trace.h 124 129 RpPseudoColor.o: RpPseudoColor.h RpVtkDataSet.h Trace.h 130 RpVolume.o: RpVolume.h RpVtkDataSet.h ColorMap.h Trace.h 125 131 RpVtkDataSet.o: RpVtkDataSet.h Trace.h 126 132 RpVtkRenderer.o: RpVtkRenderer.h RpVtkDataSet.h RpPolyData.h RpPseudoColor.h RpContour2D.h ColorMap.h Trace.h -
trunk/packages/vizservers/vtkvis/RpContour2D.cpp
r2260 r2261 73 73 74 74 /** 75 * \brief Get the VTK Actorfor the contour lines76 */ 77 vtkProp *Contour2D::get Actor()75 * \brief Get the VTK Prop for the contour lines 76 */ 77 vtkProp *Contour2D::getProp() 78 78 { 79 79 return _contourActor; … … 81 81 82 82 /** 83 * \brief Create and initialize a VTK actorto render isolines84 */ 85 void Contour2D::init Actor()83 * \brief Create and initialize a VTK Prop to render isolines 84 */ 85 void Contour2D::initProp() 86 86 { 87 87 if (_contourActor == NULL) { … … 105 105 vtkDataSet *ds = _dataSet->getVtkDataSet(); 106 106 107 init Actor();107 initProp(); 108 108 109 109 // Contour filter to generate isolines -
trunk/packages/vizservers/vtkvis/RpContour2D.h
r2260 r2261 34 34 DataSet *getDataSet(); 35 35 36 vtkProp *get Actor();36 vtkProp *getProp(); 37 37 38 38 void setContours(int numContours); … … 61 61 62 62 private: 63 void init Actor();63 void initProp(); 64 64 void update(); 65 65 -
trunk/packages/vizservers/vtkvis/RpHeightMap.cpp
r2260 r2261 40 40 _warpScale(1.0) 41 41 { 42 _dataRange[0] = 0.0; 43 _dataRange[1] = 1.0; 42 44 _edgeColor[0] = 0.0; 43 45 _edgeColor[1] = 0.0; … … 245 247 _lut->SetRange(_dataRange); 246 248 247 init Actors();249 initProp(); 248 250 249 251 _dsMapper->UseLookupTableScalarRangeOn(); … … 384 386 385 387 /** 386 * \brief Get the VTK Actorfor the colormapped dataset387 */ 388 vtkProp *HeightMap::get Actor()388 * \brief Get the VTK Prop for the colormapped dataset 389 */ 390 vtkProp *HeightMap::getProp() 389 391 { 390 392 return _props; … … 392 394 393 395 /** 394 * \brief Create and initialize a VTK actorto render the colormapped dataset395 */ 396 void HeightMap::init Actors()396 * \brief Create and initialize VTK Props to render the colormapped dataset 397 */ 398 void HeightMap::initProp() 397 399 { 398 400 if (_dsActor == NULL) { -
trunk/packages/vizservers/vtkvis/RpHeightMap.h
r2260 r2261 46 46 DataSet *getDataSet(); 47 47 48 vtkProp *get Actor();48 vtkProp *getProp(); 49 49 50 50 void selectVolumeSlice(Axis axis, double ratio); … … 90 90 private: 91 91 vtkPolyData *initWarp(vtkPolyData *input); 92 void init Actors();92 void initProp(); 93 93 void update(); 94 94 -
trunk/packages/vizservers/vtkvis/RpPolyData.cpp
r2260 r2261 17 17 #include <vtkDelaunay2D.h> 18 18 #include <vtkDelaunay3D.h> 19 #include <vtkDataSetSurfaceFilter.h> 19 20 20 21 #include "RpPolyData.h" … … 48 49 49 50 /** 50 * \brief Get the VTK Actorfor the mesh51 */ 52 vtkProp *PolyData::get Actor()51 * \brief Get the VTK Prop for the mesh 52 */ 53 vtkProp *PolyData::getProp() 53 54 { 54 55 return _pdActor; … … 56 57 57 58 /** 58 * \brief Create and initialize a VTK actorto render a mesh59 */ 60 void PolyData::init Actor()59 * \brief Create and initialize a VTK Prop to render a mesh 60 */ 61 void PolyData::initProp() 61 62 { 62 63 if (_pdActor == NULL) { … … 80 81 { 81 82 if (_dataSet != dataSet) { 82 vtkDataSet *ds = dataSet->getVtkDataSet(); 83 if (!ds->IsA("vtkPolyData")) { 84 ERROR("DataSet is not a PolyData"); 85 return; 86 } else { 87 TRACE("DataSet is a vtkPolyData"); 88 vtkPolyData *pd = vtkPolyData::SafeDownCast(ds); 89 assert(pd); 90 TRACE("Verts: %d Lines: %d Polys: %d Strips: %d", 83 _dataSet = dataSet; 84 update(); 85 } 86 } 87 88 /** 89 * \brief Returns the DataSet this PolyData renders 90 */ 91 DataSet *PolyData::getDataSet() 92 { 93 return _dataSet; 94 } 95 96 /** 97 * \brief Internal method to re-compute contours after a state change 98 */ 99 void PolyData::update() 100 { 101 if (_dataSet == NULL) { 102 return; 103 } 104 105 if (_pdMapper == NULL) { 106 _pdMapper = vtkSmartPointer<vtkPolyDataMapper>::New(); 107 _pdMapper->SetResolveCoincidentTopologyToPolygonOffset(); 108 _pdMapper->ScalarVisibilityOff(); 109 } 110 111 initProp(); 112 _pdActor->SetMapper(_pdMapper); 113 114 vtkDataSet *ds = _dataSet->getVtkDataSet(); 115 vtkPolyData *pd = vtkPolyData::SafeDownCast(ds); 116 if (pd) { 117 TRACE("Verts: %d Lines: %d Polys: %d Strips: %d", 91 118 pd->GetNumberOfVerts(), 92 119 pd->GetNumberOfLines(), 93 120 pd->GetNumberOfPolys(), 94 121 pd->GetNumberOfStrips()); 95 } 96 _dataSet = dataSet; 97 update(); 98 } 99 } 100 101 /** 102 * \brief Returns the DataSet this PolyData renders 103 */ 104 DataSet *PolyData::getDataSet() 105 { 106 return _dataSet; 107 } 108 109 /** 110 * \brief Internal method to re-compute contours after a state change 111 */ 112 void PolyData::update() 113 { 114 if (_dataSet == NULL) { 115 return; 116 } 117 118 if (_pdMapper == NULL) { 119 _pdMapper = vtkSmartPointer<vtkPolyDataMapper>::New(); 120 _pdMapper->SetResolveCoincidentTopologyToPolygonOffset(); 121 _pdMapper->ScalarVisibilityOff(); 122 } 123 124 initActor(); 125 _pdActor->SetMapper(_pdMapper); 126 127 vtkPolyData *pd = vtkPolyData::SafeDownCast(_dataSet->getVtkDataSet()); 128 assert(pd); 129 130 if (pd->GetNumberOfLines() == 0 && 131 pd->GetNumberOfPolys() == 0 && 132 pd->GetNumberOfStrips() == 0) { 133 // Point cloud 134 if (_dataSet->is2D()) { 135 vtkSmartPointer<vtkDelaunay2D> mesher = vtkSmartPointer<vtkDelaunay2D>::New(); 136 mesher->SetInput(pd); 137 _pdMapper->SetInput(mesher->GetOutput()); 122 // DataSet is a vtkPolyData 123 if (pd->GetNumberOfLines() == 0 && 124 pd->GetNumberOfPolys() == 0 && 125 pd->GetNumberOfStrips() == 0) { 126 // DataSet is a point cloud 127 if (_dataSet->is2D()) { 128 vtkSmartPointer<vtkDelaunay2D> mesher = vtkSmartPointer<vtkDelaunay2D>::New(); 129 mesher->SetInput(pd); 130 _pdMapper->SetInput(mesher->GetOutput()); 131 } else { 132 vtkSmartPointer<vtkDelaunay3D> mesher = vtkSmartPointer<vtkDelaunay3D>::New(); 133 mesher->SetInput(pd); 134 // Delaunay3D returns an UnstructuredGrid, so feed it through a generic mapper 135 // to get the grid boundary as a PolyData 136 vtkSmartPointer<vtkDataSetMapper> dsMapper = vtkSmartPointer<vtkDataSetMapper>::New(); 137 dsMapper->SetInput(mesher->GetOutput()); 138 dsMapper->StaticOn(); 139 _pdMapper = dsMapper->GetPolyDataMapper(); 140 _pdMapper->SetResolveCoincidentTopologyToPolygonOffset(); 141 _pdMapper->ScalarVisibilityOff(); 142 } 138 143 } else { 139 vtkSmartPointer<vtkDelaunay3D> mesher = vtkSmartPointer<vtkDelaunay3D>::New(); 140 mesher->SetInput(pd); 141 // Delaunay3D returns an UnstructuredGrid, so feed it through a generic mapper 142 // to get the grid boundary as a PolyData 143 vtkSmartPointer<vtkDataSetMapper> dsMapper = vtkSmartPointer<vtkDataSetMapper>::New(); 144 dsMapper->SetInput(mesher->GetOutput()); 145 dsMapper->StaticOn(); 146 _pdMapper = dsMapper->GetPolyDataMapper(); 147 _pdMapper->SetResolveCoincidentTopologyToPolygonOffset(); 148 _pdMapper->ScalarVisibilityOff(); 144 // DataSet is a vtkPolyData with lines and/or polygons 145 _pdMapper->SetInput(pd); 146 _pdMapper->StaticOn(); 149 147 } 150 148 } else { 149 // DataSet is NOT a vtkPolyData 150 WARN("DataSet is not a PolyData"); 151 vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New(); 152 gf->SetInput(ds); 153 gf->Update(); 154 pd = gf->GetOutput(); 155 assert(pd); 151 156 _pdMapper->SetInput(pd); 152 _pdMapper->StaticOn();153 157 } 154 158 } -
trunk/packages/vizservers/vtkvis/RpPolyData.h
r2260 r2261 32 32 DataSet *getDataSet(); 33 33 34 vtkProp *get Actor();34 vtkProp *getProp(); 35 35 36 36 void setVisibility(bool state); … … 55 55 56 56 private: 57 void init Actor();57 void initProp(); 58 58 void update(); 59 59 -
trunk/packages/vizservers/vtkvis/RpPseudoColor.cpp
r2260 r2261 173 173 //_dsMapper->InterpolateScalarsBeforeMappingOn(); 174 174 175 init Actor();175 initProp(); 176 176 _dsActor->SetMapper(_dsMapper); 177 177 } 178 178 179 179 /** 180 * \brief Get the VTK Actorfor the colormapped dataset181 */ 182 vtkProp *PseudoColor::get Actor()180 * \brief Get the VTK Prop for the colormapped dataset 181 */ 182 vtkProp *PseudoColor::getProp() 183 183 { 184 184 return _dsActor; … … 186 186 187 187 /** 188 * \brief Create and initialize a VTK actorto render the colormapped dataset189 */ 190 void PseudoColor::init Actor()188 * \brief Create and initialize a VTK Prop to render the colormapped dataset 189 */ 190 void PseudoColor::initProp() 191 191 { 192 192 if (_dsActor == NULL) { -
trunk/packages/vizservers/vtkvis/RpPseudoColor.h
r2260 r2261 34 34 DataSet *getDataSet(); 35 35 36 vtkProp *get Actor();36 vtkProp *getProp(); 37 37 38 38 void setLookupTable(vtkLookupTable *lut); … … 57 57 58 58 private: 59 void init Actor();59 void initProp(); 60 60 void update(); 61 61 -
trunk/packages/vizservers/vtkvis/RpVtkDataSet.cpp
r2260 r2261 22 22 _visible(true) 23 23 { 24 _name = name;25 24 _dataRange[0] = 0; 26 25 _dataRange[1] = 1; -
trunk/packages/vizservers/vtkvis/RpVtkRenderer.cpp
r2260 r2261 101 101 _renderWindow->SetSize(_windowWidth, _windowHeight); 102 102 _renderWindow->AddRenderer(_renderer); 103 addColorMap("default", ColorMap::createDefault()); 103 addColorMap("default", ColorMap::getDefault()); 104 addColorMap("volumeDefault", ColorMap::getVolumeDefault()); 104 105 } 105 106 … … 131 132 } 132 133 _polyDatas.clear(); 134 for (VolumeHashmap::iterator itr = _volumes.begin(); 135 itr != _volumes.end(); ++itr) { 136 delete itr->second; 137 } 138 _volumes.clear(); 133 139 for (DataSetHashmap::iterator itr = _dataSets.begin(); 134 140 itr != _dataSets.end(); ++itr) { … … 180 186 do { 181 187 PseudoColor *ps = itr->second; 182 if (ps->get Actor())183 _renderer->RemoveViewProp(ps->get Actor());188 if (ps->getProp()) 189 _renderer->RemoveViewProp(ps->getProp()); 184 190 delete ps; 185 191 … … 216 222 do { 217 223 Contour2D *contour = itr->second; 218 if (contour->get Actor())219 _renderer->RemoveViewProp(contour->get Actor());224 if (contour->getProp()) 225 _renderer->RemoveViewProp(contour->getProp()); 220 226 delete contour; 221 227 … … 252 258 do { 253 259 HeightMap *hmap = itr->second; 254 if (hmap->get Actor())255 _renderer->RemoveViewProp(hmap->get Actor());260 if (hmap->getProp()) 261 _renderer->RemoveViewProp(hmap->getProp()); 256 262 delete hmap; 257 263 … … 270 276 { 271 277 PolyDataHashmap::iterator itr; 272 278 273 279 bool doAll = false; 274 280 … … 288 294 do { 289 295 PolyData *polyData = itr->second; 290 if (polyData->get Actor())291 _renderer->RemoveViewProp(polyData->get Actor());296 if (polyData->getProp()) 297 _renderer->RemoveViewProp(polyData->getProp()); 292 298 delete polyData; 293 299 294 300 _polyDatas.erase(itr); 295 301 } while (doAll && ++itr != _polyDatas.end()); 302 303 _needsRedraw = true; 304 } 305 306 /** 307 * \brief Remove the Volume for the specified DataSet 308 * 309 * The underlying Volume is deleted, freeing its memory 310 */ 311 void Renderer::deleteVolume(const DataSetId& id) 312 { 313 VolumeHashmap::iterator itr; 314 315 bool doAll = false; 316 317 if (id.compare("all") == 0) { 318 itr = _volumes.begin(); 319 doAll = true; 320 } else { 321 itr = _volumes.find(id); 322 } 323 if (itr == _volumes.end()) { 324 ERROR("Volume not found: %s", id.c_str()); 325 return; 326 } 327 328 TRACE("Deleting Volumes for %s", id.c_str()); 329 330 do { 331 Volume *volume = itr->second; 332 if (volume->getProp()) 333 _renderer->RemoveViewProp(volume->getProp()); 334 delete volume; 335 336 _volumes.erase(itr); 337 } while (doAll && ++itr != _volumes.end()); 296 338 297 339 _needsRedraw = true; … … 328 370 deleteHeightMap(itr->second->getName()); 329 371 deletePolyData(itr->second->getName()); 372 deleteVolume(itr->second->getName()); 330 373 331 374 TRACE("After deleting graphics objects"); … … 898 941 pc->setLookupTable(lut); 899 942 900 _renderer->AddViewProp(pc->get Actor());943 _renderer->AddViewProp(pc->getProp()); 901 944 } while (doAll && ++itr != _dataSets.end()); 902 945 … … 920 963 921 964 /** 922 * \brief Associate an existing named color map with a DataSet965 * \brief Associate an existing named color map with a PseudoColor for the given DataSet 923 966 */ 924 967 void Renderer::setPseudoColorColorMap(const DataSetId& id, const ColorMapId& colorMapId) … … 947 990 948 991 do { 949 TRACE("Set color map: %s for dataset %s", colorMapId.c_str(),992 TRACE("Set PseudoColor color map: %s for dataset %s", colorMapId.c_str(), 950 993 itr->second->getDataSet()->getName().c_str()); 951 994 … … 973 1016 974 1017 /** 975 * \brief Get the color map (vtkLookupTable) for the given DataSet976 *977 * \return The associated lookup table or NULL if not found978 */979 vtkLookupTable *Renderer::getPseudoColorColorMap(const DataSetId& id)980 {981 PseudoColor *pc = getPseudoColor(id);982 if (pc)983 return pc->getLookupTable();984 else985 return NULL;986 }987 988 /**989 1018 * \brief Set opacity of the PseudoColor for the given DataSet 990 1019 */ … … 1190 1219 contour->setDataSet(ds); 1191 1220 1192 _renderer->AddViewProp(contour->get Actor());1221 _renderer->AddViewProp(contour->getProp()); 1193 1222 } while (doAll && ++itr != _dataSets.end()); 1194 1223 … … 1453 1482 hmap->setLookupTable(lut); 1454 1483 1455 _renderer->AddViewProp(hmap->get Actor());1484 _renderer->AddViewProp(hmap->getProp()); 1456 1485 } while (doAll && ++itr != _dataSets.end()); 1457 1486 … … 1535 1564 1536 1565 /** 1537 * \brief Associate an existing named color map with a DataSet1566 * \brief Associate an existing named color map with a HeightMap for the given DataSet 1538 1567 */ 1539 1568 void Renderer::setHeightMapColorMap(const DataSetId& id, const ColorMapId& colorMapId) … … 1562 1591 1563 1592 do { 1564 TRACE("Set color map: %s for dataset %s", colorMapId.c_str(),1593 TRACE("Set HeightMap color map: %s for dataset %s", colorMapId.c_str(), 1565 1594 itr->second->getDataSet()->getName().c_str()); 1566 1595 … … 1588 1617 1589 1618 /** 1590 * \brief Get the height map's color map (vtkLookupTable) for the given DataSet1591 *1592 * \return The associated lookup table or NULL if not found1593 */1594 vtkLookupTable *Renderer::getHeightMapColorMap(const DataSetId& id)1595 {1596 HeightMap *hm = getHeightMap(id);1597 if (hm)1598 return hm->getLookupTable();1599 else1600 return NULL;1601 }1602 1603 /**1604 1619 * \brief Set the number of equally spaced contour isolines for the given DataSet 1605 1620 */ … … 1940 1955 polyData->setDataSet(ds); 1941 1956 1942 _renderer->AddViewProp(polyData->get Actor());1957 _renderer->AddViewProp(polyData->getProp()); 1943 1958 } while (doAll && ++itr != _dataSets.end()); 1944 1959 … … 1969 1984 { 1970 1985 PolyDataHashmap::iterator itr; 1971 1986 1972 1987 bool doAll = false; 1973 1988 … … 1996 2011 { 1997 2012 PolyDataHashmap::iterator itr; 1998 2013 1999 2014 bool doAll = false; 2000 2015 … … 2023 2038 { 2024 2039 PolyDataHashmap::iterator itr; 2025 2040 2026 2041 bool doAll = false; 2027 2042 … … 2049 2064 { 2050 2065 PolyDataHashmap::iterator itr; 2051 2066 2052 2067 bool doAll = false; 2053 2068 … … 2076 2091 { 2077 2092 PolyDataHashmap::iterator itr; 2078 2093 2079 2094 bool doAll = false; 2080 2095 … … 2106 2121 { 2107 2122 PolyDataHashmap::iterator itr; 2108 2123 2109 2124 bool doAll = false; 2110 2125 … … 2133 2148 { 2134 2149 PolyDataHashmap::iterator itr; 2135 2150 2136 2151 bool doAll = false; 2137 2152 … … 2160 2175 { 2161 2176 PolyDataHashmap::iterator itr; 2162 2177 2163 2178 bool doAll = false; 2164 2179 … … 2177 2192 itr->second->setLighting(state); 2178 2193 } while (doAll && ++itr != _polyDatas.end()); 2194 2195 _needsRedraw = true; 2196 } 2197 2198 /** 2199 * \brief Create a new Volume and associate it with the named DataSet 2200 */ 2201 void Renderer::addVolume(const DataSetId& id) 2202 { 2203 DataSetHashmap::iterator itr; 2204 2205 bool doAll = false; 2206 2207 if (id.compare("all") == 0) { 2208 itr = _dataSets.begin(); 2209 } else { 2210 itr = _dataSets.find(id); 2211 } 2212 if (itr == _dataSets.end()) { 2213 ERROR("Unknown dataset %s", id.c_str()); 2214 return; 2215 } 2216 2217 do { 2218 DataSet *ds = itr->second; 2219 const DataSetId& dsID = ds->getName(); 2220 2221 if (getVolume(dsID)) { 2222 WARN("Replacing existing volume %s", dsID.c_str()); 2223 deleteVolume(dsID); 2224 } 2225 2226 Volume *volume = new Volume(); 2227 _volumes[dsID] = volume; 2228 2229 volume->setDataSet(ds); 2230 2231 if (_useCumulativeRange) { 2232 ColorMap *cmap = volume->getColorMap(); 2233 volume->setColorMap(cmap, _cumulativeDataRange); 2234 } 2235 2236 _renderer->AddViewProp(volume->getProp()); 2237 } while (doAll && ++itr != _dataSets.end()); 2238 2239 if (_cameraMode == IMAGE) 2240 setCameraMode(PERSPECTIVE); 2241 initCamera(); 2242 _needsRedraw = true; 2243 } 2244 2245 /** 2246 * \brief Get the Volume associated with a named DataSet 2247 */ 2248 Volume *Renderer::getVolume(const DataSetId& id) 2249 { 2250 VolumeHashmap::iterator itr = _volumes.find(id); 2251 2252 if (itr == _volumes.end()) { 2253 TRACE("Volume not found: %s", id.c_str()); 2254 return NULL; 2255 } else 2256 return itr->second; 2257 } 2258 2259 /** 2260 * \brief Associate an existing named color map with a Volume for the given DataSet 2261 */ 2262 void Renderer::setVolumeColorMap(const DataSetId& id, const ColorMapId& colorMapId) 2263 { 2264 VolumeHashmap::iterator itr; 2265 2266 bool doAll = false; 2267 2268 if (id.compare("all") == 0) { 2269 itr = _volumes.begin(); 2270 doAll = true; 2271 } else { 2272 itr = _volumes.find(id); 2273 } 2274 2275 if (itr == _volumes.end()) { 2276 ERROR("Volume not found: %s", id.c_str()); 2277 return; 2278 } 2279 2280 ColorMap *cmap = getColorMap(colorMapId); 2281 if (cmap == NULL) { 2282 ERROR("Unknown colormap: %s", colorMapId.c_str()); 2283 return; 2284 } 2285 2286 do { 2287 TRACE("Set Volume color map: %s for dataset %s", colorMapId.c_str(), 2288 itr->second->getDataSet()->getName().c_str()); 2289 #ifdef notdef 2290 // Make a copy of the generic colormap lookup table, so 2291 // data range can be set in the copy table to match the 2292 // dataset being plotted 2293 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New(); 2294 lut->DeepCopy(cmap->getLookupTable()); 2295 2296 if (_useCumulativeRange) { 2297 lut->SetRange(_cumulativeDataRange); 2298 } else { 2299 if (itr->second->getDataSet() != NULL) { 2300 double range[2]; 2301 itr->second->getDataSet()->getDataRange(range); 2302 lut->SetRange(range); 2303 } 2304 } 2305 #endif 2306 itr->second->setColorMap(cmap); 2307 } while (doAll && ++itr != _volumes.end()); 2308 2309 _needsRedraw = true; 2310 } 2311 2312 /** 2313 * \brief Set Volume opacity scaling for the specified DataSet 2314 */ 2315 void Renderer::setVolumeOpacity(const DataSetId& id, double opacity) 2316 { 2317 VolumeHashmap::iterator itr; 2318 2319 bool doAll = false; 2320 2321 if (id.compare("all") == 0) { 2322 itr = _volumes.begin(); 2323 doAll = true; 2324 } else { 2325 itr = _volumes.find(id); 2326 } 2327 if (itr == _volumes.end()) { 2328 ERROR("Volume not found: %s", id.c_str()); 2329 return; 2330 } 2331 2332 do { 2333 itr->second->setOpacity(opacity); 2334 } while (doAll && ++itr != _volumes.end()); 2335 2336 _needsRedraw = true; 2337 } 2338 2339 /** 2340 * \brief Turn on/off rendering of the Volume mapper for the given DataSet 2341 */ 2342 void Renderer::setVolumeVisibility(const DataSetId& id, bool state) 2343 { 2344 VolumeHashmap::iterator itr; 2345 2346 bool doAll = false; 2347 2348 if (id.compare("all") == 0) { 2349 itr = _volumes.begin(); 2350 doAll = true; 2351 } else { 2352 itr = _volumes.find(id); 2353 } 2354 if (itr == _volumes.end()) { 2355 ERROR("Volume not found: %s", id.c_str()); 2356 return; 2357 } 2358 2359 do { 2360 itr->second->setVisibility(state); 2361 } while (doAll && ++itr != _volumes.end()); 2362 2363 _needsRedraw = true; 2364 } 2365 2366 /** 2367 * \brief Set volume ambient lighting/shading coefficient for the specified DataSet 2368 */ 2369 void Renderer::setVolumeAmbient(const DataSetId& id, double coeff) 2370 { 2371 VolumeHashmap::iterator itr; 2372 2373 bool doAll = false; 2374 2375 if (id.compare("all") == 0) { 2376 itr = _volumes.begin(); 2377 doAll = true; 2378 } else { 2379 itr = _volumes.find(id); 2380 } 2381 if (itr == _volumes.end()) { 2382 ERROR("Volume not found: %s", id.c_str()); 2383 return; 2384 } 2385 2386 do { 2387 itr->second->setAmbient(coeff); 2388 } while (doAll && ++itr != _volumes.end()); 2389 2390 _needsRedraw = true; 2391 } 2392 2393 /** 2394 * \brief Set volume diffuse lighting/shading coefficient for the specified DataSet 2395 */ 2396 void Renderer::setVolumeDiffuse(const DataSetId& id, double coeff) 2397 { 2398 VolumeHashmap::iterator itr; 2399 2400 bool doAll = false; 2401 2402 if (id.compare("all") == 0) { 2403 itr = _volumes.begin(); 2404 doAll = true; 2405 } else { 2406 itr = _volumes.find(id); 2407 } 2408 if (itr == _volumes.end()) { 2409 ERROR("Volume not found: %s", id.c_str()); 2410 return; 2411 } 2412 2413 do { 2414 itr->second->setDiffuse(coeff); 2415 } while (doAll && ++itr != _volumes.end()); 2416 2417 _needsRedraw = true; 2418 } 2419 2420 /** 2421 * \brief Set volume specular lighting/shading coefficient and power for the specified DataSet 2422 */ 2423 void Renderer::setVolumeSpecular(const DataSetId& id, double coeff, double power) 2424 { 2425 VolumeHashmap::iterator itr; 2426 2427 bool doAll = false; 2428 2429 if (id.compare("all") == 0) { 2430 itr = _volumes.begin(); 2431 doAll = true; 2432 } else { 2433 itr = _volumes.find(id); 2434 } 2435 if (itr == _volumes.end()) { 2436 ERROR("Volume not found: %s", id.c_str()); 2437 return; 2438 } 2439 2440 do { 2441 itr->second->setSpecular(coeff, power); 2442 } while (doAll && ++itr != _volumes.end()); 2443 2444 _needsRedraw = true; 2445 } 2446 2447 /** 2448 * \brief Turn volume lighting/shading on/off for the specified DataSet 2449 */ 2450 void Renderer::setVolumeLighting(const DataSetId& id, bool state) 2451 { 2452 VolumeHashmap::iterator itr; 2453 2454 bool doAll = false; 2455 2456 if (id.compare("all") == 0) { 2457 itr = _volumes.begin(); 2458 doAll = true; 2459 } else { 2460 itr = _volumes.find(id); 2461 } 2462 if (itr == _volumes.end()) { 2463 ERROR("Volume not found: %s", id.c_str()); 2464 return; 2465 } 2466 2467 do { 2468 itr->second->setLighting(state); 2469 } while (doAll && ++itr != _volumes.end()); 2179 2470 2180 2471 _needsRedraw = true; … … 2805 3096 itr != _pseudoColors.end(); ++itr) { 2806 3097 if (!onlyVisible || itr->second->getVisibility()) 2807 mergeBounds(bounds, bounds, itr->second->get Actor()->GetBounds());3098 mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds()); 2808 3099 } 2809 3100 for (Contour2DHashmap::iterator itr = _contours.begin(); 2810 3101 itr != _contours.end(); ++itr) { 2811 3102 if (!onlyVisible || itr->second->getVisibility()) 2812 mergeBounds(bounds, bounds, itr->second->get Actor()->GetBounds());3103 mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds()); 2813 3104 } 2814 3105 for (HeightMapHashmap::iterator itr = _heightMaps.begin(); 2815 3106 itr != _heightMaps.end(); ++itr) { 2816 3107 if (!onlyVisible || itr->second->getVisibility()) 2817 mergeBounds(bounds, bounds, itr->second->get Actor()->GetBounds());3108 mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds()); 2818 3109 } 2819 3110 for (PolyDataHashmap::iterator itr = _polyDatas.begin(); 2820 3111 itr != _polyDatas.end(); ++itr) { 2821 3112 if (!onlyVisible || itr->second->getVisibility()) 2822 mergeBounds(bounds, bounds, itr->second->getActor()->GetBounds()); 3113 mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds()); 3114 } 3115 for (VolumeHashmap::iterator itr = _volumes.begin(); 3116 itr != _volumes.end(); ++itr) { 3117 if (!onlyVisible || itr->second->getVisibility()) 3118 mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds()); 2823 3119 } 2824 3120 for (int i = 0; i < 6; i++) { … … 2893 3189 } else { 2894 3190 itr->second->setContours(itr->second->getNumContours()); 3191 } 3192 } 3193 } 3194 for (VolumeHashmap::iterator itr = _volumes.begin(); 3195 itr != _volumes.end(); ++itr) { 3196 ColorMap *cmap = itr->second->getColorMap(); 3197 if (cmap) { 3198 if (useCumulative) { 3199 itr->second->setColorMap(cmap, _cumulativeDataRange); 3200 } else { 3201 itr->second->setColorMap(cmap); 2895 3202 } 2896 3203 } … … 3027 3334 if (id.compare("all") == 0 || getPolyData(id) != NULL) 3028 3335 setPolyDataOpacity(id, opacity); 3336 if (id.compare("all") == 0 || getVolume(id) != NULL) 3337 setVolumeOpacity(id, opacity); 3029 3338 } 3030 3339 … … 3061 3370 if (id.compare("all") == 0 || getPolyData(id) != NULL) 3062 3371 setPolyDataVisibility(id, state); 3372 if (id.compare("all") == 0 || getVolume(id) != NULL) 3373 setVolumeVisibility(id, state); 3063 3374 } 3064 3375 … … 3087 3398 for (PolyDataHashmap::iterator itr = _polyDatas.begin(); 3088 3399 itr != _polyDatas.end(); ++itr) { 3400 itr->second->setClippingPlanes(_clippingPlanes); 3401 } 3402 for (VolumeHashmap::iterator itr = _volumes.begin(); 3403 itr != _volumes.end(); ++itr) { 3089 3404 itr->second->setClippingPlanes(_clippingPlanes); 3090 3405 } … … 3106 3421 itr->second->setClippingPlanes(NULL); 3107 3422 } 3423 for (VolumeHashmap::iterator itr = _volumes.begin(); 3424 itr != _volumes.end(); ++itr) { 3425 itr->second->setClippingPlanes(NULL); 3426 } 3108 3427 } 3109 3428 _renderWindow->Render(); -
trunk/packages/vizservers/vtkvis/RpVtkRenderer.h
r2260 r2261 10 10 11 11 #include <vtkSmartPointer.h> 12 #include <vtkLookupTable.h>13 12 #include <vtkCubeAxesActor.h> 14 13 #ifdef USE_CUSTOM_AXES … … 32 31 #include "RpHeightMap.h" 33 32 #include "RpPolyData.h" 33 #include "RpVolume.h" 34 34 #include "Trace.h" 35 35 … … 78 78 typedef std::tr1::unordered_map<DataSetId, HeightMap *> HeightMapHashmap; 79 79 typedef std::tr1::unordered_map<DataSetId, PolyData *> PolyDataHashmap; 80 typedef std::tr1::unordered_map<DataSetId, Volume *> VolumeHashmap; 80 81 81 82 // Data sets … … 189 190 void setPseudoColorColorMap(const DataSetId& id, const ColorMapId& colorMapId); 190 191 191 vtkLookupTable *getPseudoColorColorMap(const DataSetId& id);192 193 192 void setPseudoColorOpacity(const DataSetId& id, double opacity); 194 193 … … 238 237 239 238 void setHeightMapColorMap(const DataSetId& id, const ColorMapId& colorMapId); 240 241 vtkLookupTable *getHeightMapColorMap(const DataSetId& id);242 239 243 240 void setHeightMapContours(const DataSetId& id, int numContours); … … 286 283 287 284 void setPolyDataLighting(const DataSetId& id, bool state); 285 286 // Volumes 287 288 void addVolume(const DataSetId& id); 289 290 void deleteVolume(const DataSetId& id); 291 292 Volume *getVolume(const DataSetId& id); 293 294 void setVolumeColorMap(const DataSetId& id, const ColorMapId& colorMapId); 295 296 void setVolumeOpacity(const DataSetId& id, double opacity); 297 298 void setVolumeVisibility(const DataSetId& id, bool state); 299 300 void setVolumeAmbient(const DataSetId& id, double coeff); 301 302 void setVolumeDiffuse(const DataSetId& id, double coeff); 303 304 void setVolumeSpecular(const DataSetId& id, double coeff, double power); 305 306 void setVolumeLighting(const DataSetId& id, bool state); 288 307 289 308 private: … … 338 357 HeightMapHashmap _heightMaps; 339 358 PolyDataHashmap _polyDatas; 359 VolumeHashmap _volumes; 340 360 341 361 CameraMode _cameraMode; -
trunk/packages/vizservers/vtkvis/RpVtkRendererCmd.cpp
r2260 r2261 1734 1734 1735 1735 proc = Rappture::GetOpFromObj(interp, nScreenOps, screenOps, 1736 Rappture::CMDSPEC_ARG1, objc, objv, 0); 1737 if (proc == NULL) { 1738 return TCL_ERROR; 1739 } 1740 return (*proc) (clientData, interp, objc, objv); 1741 } 1742 1743 static int 1744 VolumeAddOp(ClientData clientData, Tcl_Interp *interp, int objc, 1745 Tcl_Obj *const *objv) 1746 { 1747 if (objc == 3) { 1748 const char *name = Tcl_GetString(objv[2]); 1749 g_renderer->addVolume(name); 1750 } else { 1751 g_renderer->addVolume("all"); 1752 } 1753 return TCL_OK; 1754 } 1755 1756 static int 1757 VolumeColorMapOp(ClientData clientData, Tcl_Interp *interp, int objc, 1758 Tcl_Obj *const *objv) 1759 { 1760 const char *colorMapName = Tcl_GetString(objv[2]); 1761 if (objc == 4) { 1762 const char *dataSetName = Tcl_GetString(objv[3]); 1763 g_renderer->setVolumeColorMap(dataSetName, colorMapName); 1764 } else { 1765 g_renderer->setVolumeColorMap("all", colorMapName); 1766 } 1767 return TCL_OK; 1768 } 1769 1770 static int 1771 VolumeDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc, 1772 Tcl_Obj *const *objv) 1773 { 1774 if (objc == 3) { 1775 const char *name = Tcl_GetString(objv[2]); 1776 g_renderer->deleteVolume(name); 1777 } else { 1778 g_renderer->deleteVolume("all"); 1779 } 1780 return TCL_OK; 1781 } 1782 1783 static int 1784 VolumeLightingOp(ClientData clientData, Tcl_Interp *interp, int objc, 1785 Tcl_Obj *const *objv) 1786 { 1787 bool state; 1788 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 1789 return TCL_ERROR; 1790 } 1791 if (objc == 4) { 1792 const char *name = Tcl_GetString(objv[3]); 1793 g_renderer->setVolumeLighting(name, state); 1794 } else { 1795 g_renderer->setVolumeLighting("all", state); 1796 } 1797 return TCL_OK; 1798 } 1799 1800 static int 1801 VolumeOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc, 1802 Tcl_Obj *const *objv) 1803 { 1804 double opacity; 1805 if (Tcl_GetDoubleFromObj(interp, objv[2], &opacity) != TCL_OK) { 1806 return TCL_ERROR; 1807 } 1808 if (objc == 4) { 1809 const char *name = Tcl_GetString(objv[3]); 1810 g_renderer->setVolumeOpacity(name, opacity); 1811 } else { 1812 g_renderer->setVolumeOpacity("all", opacity); 1813 } 1814 return TCL_OK; 1815 } 1816 1817 static int 1818 VolumeShadingAmbientOp(ClientData clientData, Tcl_Interp *interp, int objc, 1819 Tcl_Obj *const *objv) 1820 { 1821 double coeff; 1822 if (Tcl_GetDoubleFromObj(interp, objv[3], &coeff) != TCL_OK) { 1823 return TCL_ERROR; 1824 } 1825 1826 if (objc == 5) { 1827 const char *name = Tcl_GetString(objv[4]); 1828 g_renderer->setVolumeAmbient(name, coeff); 1829 } else { 1830 g_renderer->setVolumeAmbient("all", coeff); 1831 } 1832 return TCL_OK; 1833 } 1834 1835 static int 1836 VolumeShadingDiffuseOp(ClientData clientData, Tcl_Interp *interp, int objc, 1837 Tcl_Obj *const *objv) 1838 { 1839 double coeff; 1840 if (Tcl_GetDoubleFromObj(interp, objv[3], &coeff) != TCL_OK) { 1841 return TCL_ERROR; 1842 } 1843 1844 if (objc == 5) { 1845 const char *name = Tcl_GetString(objv[4]); 1846 g_renderer->setVolumeDiffuse(name, coeff); 1847 } else { 1848 g_renderer->setVolumeDiffuse("all", coeff); 1849 } 1850 return TCL_OK; 1851 } 1852 1853 static int 1854 VolumeShadingSpecularOp(ClientData clientData, Tcl_Interp *interp, int objc, 1855 Tcl_Obj *const *objv) 1856 { 1857 double coeff, power; 1858 if (Tcl_GetDoubleFromObj(interp, objv[3], &coeff) != TCL_OK || 1859 Tcl_GetDoubleFromObj(interp, objv[4], &power) != TCL_OK) { 1860 return TCL_ERROR; 1861 } 1862 1863 if (objc == 6) { 1864 const char *name = Tcl_GetString(objv[5]); 1865 g_renderer->setVolumeSpecular(name, coeff, power); 1866 } else { 1867 g_renderer->setVolumeSpecular("all", coeff, power); 1868 } 1869 return TCL_OK; 1870 } 1871 1872 static Rappture::CmdSpec volumeShadingOps[] = { 1873 {"ambient", 1, VolumeShadingAmbientOp, 4, 5, "coeff ?dataSetName?"}, 1874 {"diffuse", 1, VolumeShadingDiffuseOp, 4, 5, "coeff ?dataSetName?"}, 1875 {"specular", 1, VolumeShadingSpecularOp, 5, 6, "coeff power ?dataSetName?"} 1876 }; 1877 static int nVolumeShadingOps = NumCmdSpecs(volumeShadingOps); 1878 1879 static int 1880 VolumeShadingOp(ClientData clientData, Tcl_Interp *interp, int objc, 1881 Tcl_Obj *const *objv) 1882 { 1883 Tcl_ObjCmdProc *proc; 1884 1885 proc = Rappture::GetOpFromObj(interp, nVolumeShadingOps, volumeShadingOps, 1886 Rappture::CMDSPEC_ARG2, objc, objv, 0); 1887 if (proc == NULL) { 1888 return TCL_ERROR; 1889 } 1890 return (*proc) (clientData, interp, objc, objv); 1891 } 1892 1893 static int 1894 VolumeVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc, 1895 Tcl_Obj *const *objv) 1896 { 1897 bool state; 1898 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 1899 return TCL_ERROR; 1900 } 1901 if (objc == 4) { 1902 const char *name = Tcl_GetString(objv[3]); 1903 g_renderer->setVolumeVisibility(name, state); 1904 } else { 1905 g_renderer->setVolumeVisibility("all", state); 1906 } 1907 return TCL_OK; 1908 } 1909 1910 static Rappture::CmdSpec volumeOps[] = { 1911 {"add", 1, VolumeAddOp, 2, 3, "?dataSetName?"}, 1912 {"colormap", 1, VolumeColorMapOp, 3, 4, "colorMapName ?dataSetName?"}, 1913 {"delete", 1, VolumeDeleteOp, 2, 3, "?dataSetName?"}, 1914 {"lighting", 1, VolumeLightingOp, 3, 4, "bool ?dataSetName?"}, 1915 {"opacity", 1, VolumeOpacityOp, 3, 4, "val ?dataSetName?"}, 1916 {"shading", 1, VolumeShadingOp, 4, 6, "oper val ?dataSetName?"}, 1917 {"visible", 1, VolumeVisibleOp, 3, 4, "bool ?dataSetName?"} 1918 }; 1919 static int nVolumeOps = NumCmdSpecs(volumeOps); 1920 1921 static int 1922 VolumeCmd(ClientData clientData, Tcl_Interp *interp, int objc, 1923 Tcl_Obj *const *objv) 1924 { 1925 Tcl_ObjCmdProc *proc; 1926 1927 proc = Rappture::GetOpFromObj(interp, nVolumeOps, volumeOps, 1736 1928 Rappture::CMDSPEC_ARG1, objc, objv, 0); 1737 1929 if (proc == NULL) { … … 1843 2035 Tcl_CreateObjCommand(interp, "pseudocolor", PseudoColorCmd, NULL, NULL); 1844 2036 Tcl_CreateObjCommand(interp, "screen", ScreenCmd, NULL, NULL); 2037 Tcl_CreateObjCommand(interp, "volume", VolumeCmd, NULL, NULL); 1845 2038 return interp; 1846 2039 } -
trunk/packages/vizservers/vtkvis/protocol.txt
r2260 r2261 116 116 polydata wireframe <bool> <?datasetName?> 117 117 118 volume add <?datasetName?> 119 volume colormap <colorMapName> <?datasetName?> 120 volume delete <?datasetName?> 121 volume lighting <bool> <?datasetName?> 122 volume shading ambient <coeff> <?datasetName?> 123 volume shading diffuse <coeff> <?datasetName?> 124 volume shading specular <coeff> <power> <?datasetName?> 125 volume visible <bool> <?datasetName?> 126 118 127 ================================================================================ 119 128 Replies:
Note: See TracChangeset
for help on using the changeset viewer.