Changeset 2455 for trunk/packages
- Timestamp:
- Sep 1, 2011, 11:40:10 AM (13 years ago)
- Location:
- trunk/packages/vizservers/vtkvis
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/vtkvis/RpVtkDataSet.cpp
r2454 r2455 32 32 _name(name), 33 33 _visible(true), 34 _opacity(1), 34 35 _cellSizeAverage(0) 35 36 { … … 43 44 44 45 /** 46 * \brief Create and initialize a VTK Prop to render the outline 47 */ 48 void DataSet::initProp() 49 { 50 if (_prop == NULL) { 51 _prop = vtkSmartPointer<vtkActor>::New(); 52 vtkProperty *property = _prop->GetProperty(); 53 property->EdgeVisibilityOff(); 54 property->SetOpacity(_opacity); 55 property->SetAmbient(.2); 56 property->LightingOff(); 57 _prop->SetVisibility((_visible ? 1 : 0)); 58 } 59 } 60 61 /** 62 * \brief Create and initialize a wireframe outline 63 */ 64 void DataSet::showOutline(bool state) 65 { 66 if (state) { 67 if (_outlineFilter == NULL) { 68 _outlineFilter = vtkSmartPointer<vtkOutlineFilter>::New(); 69 _outlineFilter->SetInput(_dataSet); 70 } 71 if (_outlineMapper == NULL) { 72 _outlineMapper = vtkSmartPointer<vtkPolyDataMapper>::New(); 73 _outlineMapper->SetInputConnection(_outlineFilter->GetOutputPort()); 74 } 75 initProp(); 76 _prop->SetMapper(_outlineMapper); 77 } else { 78 if (_prop != NULL) { 79 _prop->SetMapper(NULL); 80 } 81 if (_outlineMapper != NULL) { 82 _outlineMapper = NULL; 83 } 84 if (_outlineFilter != NULL) { 85 _outlineFilter = NULL; 86 } 87 } 88 } 89 90 /** 91 * \brief Set opacity of DataSet outline 92 * 93 * This method is used for record-keeping and opacity of the 94 * DataSet bounds outline. The renderer controls opacity 95 * of other related graphics objects. 96 */ 97 void DataSet::setOpacity(double opacity) 98 { 99 _opacity = opacity; 100 if (_prop != NULL) { 101 _prop->GetProperty()->SetOpacity(opacity); 102 } 103 } 104 105 /** 45 106 * \brief Set visibility flag in DataSet 46 107 * 47 * This method is used for record-keeping. The renderer controls 48 * the visibility of related graphics objects. 108 * This method is used for record-keeping and visibility of the 109 * DataSet bounds outline. The renderer controls visibility 110 * of other related graphics objects. 49 111 */ 50 112 void DataSet::setVisibility(bool state) 51 113 { 52 114 _visible = state; 115 if (_prop != NULL) { 116 _prop->SetVisibility((state ? 1 : 0)); 117 } 53 118 } 54 119 -
trunk/packages/vizservers/vtkvis/RpVtkDataSet.h
r2454 r2455 12 12 #include <vtkDataSet.h> 13 13 #include <vtkDataSetReader.h> 14 #include <vtkProp.h> 15 #include <vtkActor.h> 16 #include <vtkOutlineFilter.h> 17 #include <vtkPolyDataMapper.h> 14 18 15 19 #include <string> … … 74 78 bool getVectorValue(double x, double y, double z, double vector[3]) const; 75 79 80 void setOpacity(double opacity); 81 82 /** 83 * \brief Get the opacity setting for the DataSet 84 * 85 * This method is used for record-keeping. The renderer controls 86 * the visibility of related graphics objects. 87 */ 88 inline double getOpacity() 89 { 90 return _opacity; 91 } 92 76 93 void setVisibility(bool state); 77 94 78 95 bool getVisibility() const; 96 97 void showOutline(bool state); 98 99 /** 100 * \brief Return the VTK prop object for the outline 101 */ 102 inline vtkProp *getProp() 103 { 104 return _prop; 105 } 79 106 80 107 private: … … 84 111 void print() const; 85 112 113 void initProp(); 114 86 115 std::string _name; 87 116 vtkSmartPointer<vtkDataSet> _dataSet; 88 117 bool _visible; 118 double _opacity; 89 119 double _cellSizeRange[2]; 90 120 double _cellSizeAverage; 121 vtkSmartPointer<vtkOutlineFilter> _outlineFilter; 122 vtkSmartPointer<vtkActor> _prop; 123 vtkSmartPointer<vtkPolyDataMapper> _outlineMapper; 91 124 }; 92 125 -
trunk/packages/vizservers/vtkvis/RpVtkRenderer.cpp
r2453 r2455 646 646 deleteVolume(itr->second->getName()); 647 647 648 if (itr->second->getProp() != NULL) { 649 _renderer->RemoveViewProp(itr->second->getProp()); 650 } 651 648 652 TRACE("After deleting graphics objects"); 649 653 … … 7736 7740 bounds[5] = -DBL_MAX; 7737 7741 7742 for (DataSetHashmap::iterator itr = _dataSets.begin(); 7743 itr != _dataSets.end(); ++itr) { 7744 if ((!onlyVisible || itr->second->getVisibility()) && 7745 itr->second->getProp() != NULL) 7746 mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds()); 7747 } 7738 7748 for (Contour2DHashmap::iterator itr = _contour2Ds.begin(); 7739 7749 itr != _contour2Ds.end(); ++itr) { 7740 if (!onlyVisible || itr->second->getVisibility()) 7750 if ((!onlyVisible || itr->second->getVisibility()) && 7751 itr->second->getProp() != NULL) 7741 7752 mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds()); 7742 7753 } 7743 7754 for (Contour3DHashmap::iterator itr = _contour3Ds.begin(); 7744 7755 itr != _contour3Ds.end(); ++itr) { 7745 if (!onlyVisible || itr->second->getVisibility()) 7756 if ((!onlyVisible || itr->second->getVisibility()) && 7757 itr->second->getProp() != NULL) 7746 7758 mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds()); 7747 7759 } 7748 7760 for (GlyphsHashmap::iterator itr = _glyphs.begin(); 7749 7761 itr != _glyphs.end(); ++itr) { 7750 if (!onlyVisible || itr->second->getVisibility()) 7762 if ((!onlyVisible || itr->second->getVisibility()) && 7763 itr->second->getProp() != NULL) 7751 7764 mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds()); 7752 7765 } 7753 7766 for (HeightMapHashmap::iterator itr = _heightMaps.begin(); 7754 7767 itr != _heightMaps.end(); ++itr) { 7755 if (!onlyVisible || itr->second->getVisibility()) 7768 if ((!onlyVisible || itr->second->getVisibility()) && 7769 itr->second->getProp() != NULL) 7756 7770 mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds()); 7757 7771 } 7758 7772 for (LICHashmap::iterator itr = _lics.begin(); 7759 7773 itr != _lics.end(); ++itr) { 7760 if (!onlyVisible || itr->second->getVisibility()) 7774 if ((!onlyVisible || itr->second->getVisibility()) && 7775 itr->second->getProp() != NULL) 7761 7776 mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds()); 7762 7777 } 7763 7778 for (MoleculeHashmap::iterator itr = _molecules.begin(); 7764 7779 itr != _molecules.end(); ++itr) { 7765 if (!onlyVisible || itr->second->getVisibility()) 7780 if ((!onlyVisible || itr->second->getVisibility()) && 7781 itr->second->getProp() != NULL) 7766 7782 mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds()); 7767 7783 } 7768 7784 for (PolyDataHashmap::iterator itr = _polyDatas.begin(); 7769 7785 itr != _polyDatas.end(); ++itr) { 7770 if (!onlyVisible || itr->second->getVisibility()) 7786 if ((!onlyVisible || itr->second->getVisibility()) && 7787 itr->second->getProp() != NULL) 7771 7788 mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds()); 7772 7789 } 7773 7790 for (PseudoColorHashmap::iterator itr = _pseudoColors.begin(); 7774 7791 itr != _pseudoColors.end(); ++itr) { 7775 if (!onlyVisible || itr->second->getVisibility()) 7792 if ((!onlyVisible || itr->second->getVisibility()) && 7793 itr->second->getProp() != NULL) 7776 7794 mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds()); 7777 7795 } 7778 7796 for (StreamlinesHashmap::iterator itr = _streamlines.begin(); 7779 7797 itr != _streamlines.end(); ++itr) { 7780 if (!onlyVisible || itr->second->getVisibility()) 7798 if ((!onlyVisible || itr->second->getVisibility()) && 7799 itr->second->getProp() != NULL) 7781 7800 mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds()); 7782 7801 } 7783 7802 for (VolumeHashmap::iterator itr = _volumes.begin(); 7784 7803 itr != _volumes.end(); ++itr) { 7785 if (!onlyVisible || itr->second->getVisibility()) 7804 if ((!onlyVisible || itr->second->getVisibility()) && 7805 itr->second->getProp() != NULL) 7786 7806 mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds()); 7787 7807 } … … 8144 8164 * \brief Set the opacity of the specified DataSet's associated graphics objects 8145 8165 */ 8146 void Renderer::setOpacity(const DataSetId& id, double opacity) 8147 { 8166 void Renderer::setDataSetOpacity(const DataSetId& id, double opacity) 8167 { 8168 DataSetHashmap::iterator itr; 8169 8170 bool doAll = false; 8171 8172 if (id.compare("all") == 0) { 8173 itr = _dataSets.begin(); 8174 doAll = true; 8175 } else { 8176 itr = _dataSets.find(id); 8177 } 8178 if (itr == _dataSets.end()) { 8179 ERROR("Unknown dataset %s", id.c_str()); 8180 return; 8181 } 8182 8183 do { 8184 itr->second->setOpacity(opacity); 8185 } while (doAll && ++itr != _dataSets.end()); 8186 8148 8187 if (id.compare("all") == 0 || getContour2D(id) != NULL) 8149 8188 setContour2DOpacity(id, opacity); … … 8166 8205 if (id.compare("all") == 0 || getVolume(id) != NULL) 8167 8206 setVolumeOpacity(id, opacity); 8207 8208 _needsRedraw = true; 8168 8209 } 8169 8210 … … 8171 8212 * \brief Turn on/off rendering of the specified DataSet's associated graphics objects 8172 8213 */ 8173 void Renderer::set Visibility(const DataSetId& id, bool state)8214 void Renderer::setDataSetVisibility(const DataSetId& id, bool state) 8174 8215 { 8175 8216 DataSetHashmap::iterator itr; … … 8212 8253 if (id.compare("all") == 0 || getVolume(id) != NULL) 8213 8254 setVolumeVisibility(id, state); 8255 8256 _needsRedraw = true; 8214 8257 } 8215 8258 … … 8217 8260 * \brief Toggle rendering of actors' bounding box 8218 8261 */ 8219 void Renderer::showBounds(bool state) 8220 { 8221 if (state) { 8222 ; // TODO: Add bounding box actor/mapper 8223 } else { 8224 ; // TODO: Remove bounding box actor/mapper 8225 } 8262 void Renderer::setDataSetShowBounds(const DataSetId& id, bool state) 8263 { 8264 DataSetHashmap::iterator itr; 8265 8266 bool doAll = false; 8267 8268 if (id.compare("all") == 0) { 8269 itr = _dataSets.begin(); 8270 doAll = true; 8271 } else { 8272 itr = _dataSets.find(id); 8273 } 8274 if (itr == _dataSets.end()) { 8275 ERROR("Unknown dataset %s", id.c_str()); 8276 return; 8277 } 8278 8279 do { 8280 if (!state && itr->second->getProp()) { 8281 _renderer->RemoveViewProp(itr->second->getProp()); 8282 } 8283 8284 itr->second->showOutline(state); 8285 8286 if (state) { 8287 _renderer->AddViewProp(itr->second->getProp()); 8288 } 8289 } while (doAll && ++itr != _dataSets.end()); 8290 8291 initCamera(); 8292 _needsRedraw = true; 8226 8293 } 8227 8294 -
trunk/packages/vizservers/vtkvis/RpVtkRenderer.h
r2453 r2455 136 136 bool getVectorValue(const DataSetId& id, double x, double y, double z, double vector[3]); 137 137 138 void setOpacity(const DataSetId& id, double opacity); 139 140 void setVisibility(const DataSetId& id, bool state); 138 void setDataSetShowBounds(const DataSetId& id, bool state); 139 140 void setDataSetOpacity(const DataSetId& id, double opacity); 141 142 void setDataSetVisibility(const DataSetId& id, bool state); 141 143 142 144 void setUseCumulativeDataRange(bool state, bool onlyVisible = false); … … 195 197 196 198 void setBackgroundColor(float color[3]); 197 198 void showBounds(bool state);199 199 200 200 void setClipPlane(Axis axis, double ratio, int direction); -
trunk/packages/vizservers/vtkvis/RpVtkRendererCmd.cpp
r2453 r2455 1504 1504 if (objc == 4) { 1505 1505 const char *name = Tcl_GetString(objv[3]); 1506 g_renderer->setOpacity(name, opacity); 1507 } else { 1508 g_renderer->setOpacity("all", opacity); 1506 g_renderer->setDataSetOpacity(name, opacity); 1507 } else { 1508 g_renderer->setDataSetOpacity("all", opacity); 1509 } 1510 return TCL_OK; 1511 } 1512 1513 static int 1514 DataSetOutlineOp(ClientData clientData, Tcl_Interp *interp, int objc, 1515 Tcl_Obj *const *objv) 1516 { 1517 bool state; 1518 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 1519 return TCL_ERROR; 1520 } 1521 if (objc == 4) { 1522 const char *name = Tcl_GetString(objv[3]); 1523 g_renderer->setDataSetShowBounds(name, state); 1524 } else { 1525 g_renderer->setDataSetShowBounds("all", state); 1509 1526 } 1510 1527 return TCL_OK; … … 1569 1586 if (objc == 4) { 1570 1587 const char *name = Tcl_GetString(objv[3]); 1571 g_renderer->set Visibility(name, state);1572 } else { 1573 g_renderer->set Visibility("all", state);1588 g_renderer->setDataSetVisibility(name, state); 1589 } else { 1590 g_renderer->setDataSetVisibility("all", state); 1574 1591 } 1575 1592 return TCL_OK; … … 1583 1600 {"maprange", 1, DataSetMapRangeOp, 3, 3, "value"}, 1584 1601 {"names", 1, DataSetNamesOp, 2, 2, ""}, 1585 {"opacity", 1, DataSetOpacityOp, 3, 4, "value ?name?"}, 1602 {"opacity", 2, DataSetOpacityOp, 3, 4, "value ?name?"}, 1603 {"outline", 2, DataSetOutlineOp, 3, 4, "bool ?name?"}, 1586 1604 {"scalar", 1, DataSetActiveScalarsOp, 3, 4, "scalarName ?name?"}, 1587 1605 {"vector", 2, DataSetActiveVectorsOp, 3, 4, "vectorName ?name?"},
Note: See TracChangeset
for help on using the changeset viewer.