Changeset 2393 for trunk/packages
- Timestamp:
- Aug 17, 2011, 12:13:00 AM (13 years ago)
- Location:
- trunk/packages/vizservers/vtkvis
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/vtkvis/RpGlyphs.cpp
r2335 r2393 29 29 VtkGraphicsObject(), 30 30 _glyphShape(ARROW), 31 _scaleFactor(1.0) 32 { 33 _backfaceCulling = true; 31 _scaleFactor(1.0), 32 _colorMode(COLOR_BY_SCALAR) 33 { 34 _faceCulling = true; 34 35 } 35 36 … … 81 82 return; 82 83 } 84 85 if (_glyphShape == ICOSAHEDRON || 86 _glyphShape == TETRAHEDRON) { 87 // These shapes are created with front faces pointing inside 88 setCullFace(CULL_FRONT); 89 } else { 90 setCullFace(CULL_BACK); 91 } 92 83 93 if (_glyphGenerator != NULL) { 84 94 _glyphGenerator->SetSourceConnection(_glyphSource->GetOutputPort()); … … 96 106 97 107 vtkDataSet *ds = _dataSet->getVtkDataSet(); 98 double dataRange[2];99 _dataSet->getDataRange(dataRange);100 108 101 109 if (_glyphGenerator == NULL) { 102 110 _glyphGenerator = vtkSmartPointer<vtkGlyph3D>::New(); 103 111 } 112 113 initProp(); 104 114 105 115 setGlyphShape(_glyphShape); … … 134 144 135 145 if (ds->GetPointData()->GetScalars() == NULL) { 146 TRACE("Setting color mode to vector magnitude"); 136 147 _glyphGenerator->SetColorModeToColorByVector(); 137 } else { 148 _colorMode = COLOR_BY_VECTOR; 149 } else { 150 TRACE("Setting color mode to scalar"); 138 151 _glyphGenerator->SetColorModeToColorByScalar(); 139 } 152 _colorMode = COLOR_BY_SCALAR; 153 } 140 154 if (_glyphShape == SPHERE) { 141 155 _glyphGenerator->OrientOff(); … … 166 180 167 181 if (ds->GetPointData()->GetScalars() == NULL) { 168 _pdMapper->UseLookupTableScalarRangeOff();169 } else {182 double dataRange[2]; 183 _dataSet->getVectorMagnitudeRange(dataRange); 170 184 _lut->SetRange(dataRange); 171 _pdMapper->UseLookupTableScalarRangeOn(); 172 } 173 185 //_pdMapper->SetScalarModeToUsePointFieldData(); 186 //_pdMapper->SelectColorArray(ds->GetPointData()->GetVectors()->GetName()); 187 } else { 188 double dataRange[2]; 189 _dataSet->getDataRange(dataRange); 190 _lut->SetRange(dataRange); 191 //_pdMapper->SetScalarModeToDefault(); 192 } 193 194 //_lut->SetVectorModeToMagnitude(); 174 195 _pdMapper->SetLookupTable(_lut); 175 176 initProp(); 196 _pdMapper->UseLookupTableScalarRangeOn(); 177 197 178 198 getActor()->SetMapper(_pdMapper); … … 213 233 void Glyphs::setColorMode(ColorMode mode) 214 234 { 235 _colorMode = mode; 215 236 if (_glyphGenerator != NULL) { 216 237 switch (mode) { 217 238 case COLOR_BY_SCALE: 218 239 _glyphGenerator->SetColorModeToColorByScale(); 219 break; 220 case COLOR_BY_VECTOR: 240 _pdMapper->ScalarVisibilityOn(); 241 break; 242 case COLOR_BY_VECTOR: { 221 243 _glyphGenerator->SetColorModeToColorByVector(); 222 break; 223 case COLOR_BY_SCALAR: 244 _pdMapper->ScalarVisibilityOn(); 245 double dataRange[2]; 246 _dataSet->getVectorMagnitudeRange(dataRange); 247 _lut->SetRange(dataRange); 248 } 249 break; 250 case COLOR_BY_SCALAR: { 251 _glyphGenerator->SetColorModeToColorByScalar(); 252 _pdMapper->ScalarVisibilityOn(); 253 double dataRange[2]; 254 _dataSet->getDataRange(dataRange); 255 _lut->SetRange(dataRange); 256 } 257 break; 258 case COLOR_CONSTANT: 224 259 default: 225 _glyphGenerator->SetColorModeToColorByScalar(); 226 break; 260 _pdMapper->ScalarVisibilityOff(); 227 261 } 228 262 _pdMapper->Update(); … … 261 295 } 262 296 297 switch (_colorMode) { 298 case COLOR_BY_VECTOR: { 299 double dataRange[2]; 300 _dataSet->getVectorMagnitudeRange(dataRange); 301 _lut->SetRange(dataRange); 302 } 303 break; 304 case COLOR_BY_SCALAR: 305 default: { 306 double dataRange[2]; 307 _dataSet->getDataRange(dataRange); 308 _lut->SetRange(dataRange); 309 } 310 break; 311 } 312 263 313 if (_pdMapper != NULL) { 264 314 _pdMapper->SetLookupTable(_lut); -
trunk/packages/vizservers/vtkvis/RpGlyphs.h
r2335 r2393 52 52 COLOR_BY_SCALE, 53 53 COLOR_BY_SCALAR, 54 COLOR_BY_VECTOR 54 COLOR_BY_VECTOR, 55 COLOR_CONSTANT 55 56 }; 56 57 … … 82 83 GlyphShape _glyphShape; 83 84 double _scaleFactor; 85 ColorMode _colorMode; 84 86 85 87 vtkSmartPointer<vtkLookupTable> _lut; -
trunk/packages/vizservers/vtkvis/RpMolecule.cpp
r2332 r2393 29 29 _atomScaling(NO_ATOM_SCALING) 30 30 { 31 _ backfaceCulling = true;31 _faceCulling = true; 32 32 } 33 33 … … 49 49 if (_atomProp == NULL) { 50 50 _atomProp = vtkSmartPointer<vtkActor>::New(); 51 if (_ backfaceCulling && _opacity == 1.0)52 _atomProp->GetProperty()->BackfaceCullingOn();51 if (_faceCulling && _opacity == 1.0) 52 setCulling(_atomProp->GetProperty(), true); 53 53 _atomProp->GetProperty()->EdgeVisibilityOff(); 54 54 _atomProp->GetProperty()->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]); … … 61 61 if (_bondProp == NULL) { 62 62 _bondProp = vtkSmartPointer<vtkActor>::New(); 63 if (_ backfaceCulling && _opacity == 1.0)64 _bondProp->GetProperty()->BackfaceCullingOn();63 if (_faceCulling && _opacity == 1.0) 64 setCulling(_bondProp->GetProperty(), true); 65 65 _bondProp->GetProperty()->EdgeVisibilityOff(); 66 66 _bondProp->GetProperty()->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]); -
trunk/packages/vizservers/vtkvis/RpPolyData.cpp
r2328 r2393 91 91 vtkSmartPointer<vtkDelaunay2D> mesher = vtkSmartPointer<vtkDelaunay2D>::New(); 92 92 mesher->SetInput(pd); 93 mesher->ReleaseDataFlagOn(); 94 _pdMapper->SetInputConnection(mesher->GetOutputPort()); 93 95 #if defined(DEBUG) && defined(WANT_TRACE) 94 96 mesher->Update(); … … 100 102 outpd->GetNumberOfStrips()); 101 103 #endif 102 _pdMapper->SetInputConnection(mesher->GetOutputPort());103 104 } else { 104 105 vtkSmartPointer<vtkDelaunay3D> mesher = vtkSmartPointer<vtkDelaunay3D>::New(); 105 106 mesher->SetInput(pd); 107 mesher->ReleaseDataFlagOn(); 106 108 // Delaunay3D returns an UnstructuredGrid, so feed it through a surface filter 107 109 // to get the grid boundary as a PolyData 108 110 vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New(); 109 111 gf->SetInputConnection(mesher->GetOutputPort()); 112 gf->ReleaseDataFlagOn(); 110 113 _pdMapper->SetInputConnection(gf->GetOutputPort()); 111 114 } … … 116 119 } else { 117 120 // DataSet is NOT a vtkPolyData 118 WARN("DataSet is not a PolyData");121 TRACE("DataSet is not a PolyData"); 119 122 vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New(); 120 123 gf->SetInput(ds); 124 gf->ReleaseDataFlagOn(); 121 125 _pdMapper->SetInputConnection(gf->GetOutputPort()); 122 126 } -
trunk/packages/vizservers/vtkvis/RpStreamlines.cpp
r2349 r2393 35 35 VtkGraphicsObject(), 36 36 _lineType(LINES), 37 _colorMode(COLOR_BY_VECTOR_MAGNITUDE), 37 38 _seedVisible(true) 38 39 { 39 _backfaceCulling = true; 40 _faceCulling = true; 41 _color[0] = 1.0f; 42 _color[1] = 1.0f; 43 _color[2] = 1.0f; 40 44 _seedColor[0] = 1.0f; 41 45 _seedColor[1] = 1.0f; … … 56 60 if (_linesActor == NULL) { 57 61 _linesActor = vtkSmartPointer<vtkActor>::New(); 62 _linesActor->GetProperty()->SetColor(_color[0], _color[1], _color[2]); 58 63 _linesActor->GetProperty()->SetEdgeColor(_edgeColor[0], _edgeColor[1], _edgeColor[2]); 59 64 _linesActor->GetProperty()->SetLineWidth(_edgeWidth); … … 64 69 switch (_lineType) { 65 70 case LINES: 66 _linesActor->GetProperty()->BackfaceCullingOff();71 setCulling(_linesActor->GetProperty(), false); 67 72 _linesActor->GetProperty()->SetRepresentationToWireframe(); 68 73 _linesActor->GetProperty()->EdgeVisibilityOff(); 69 74 break; 70 75 case TUBES: 71 if (_ backfaceCulling && _opacity == 1.0)72 _linesActor->GetProperty()->BackfaceCullingOn();76 if (_faceCulling && _opacity == 1.0) 77 setCulling(_linesActor->GetProperty(), true); 73 78 _linesActor->GetProperty()->SetRepresentationToSurface(); 74 79 _linesActor->GetProperty()->EdgeVisibilityOff(); 75 80 break; 76 81 case RIBBONS: 77 _linesActor->GetProperty()->BackfaceCullingOff();82 setCulling(_linesActor->GetProperty(), false); 78 83 _linesActor->GetProperty()->SetRepresentationToSurface(); 79 84 _linesActor->GetProperty()->EdgeVisibilityOff(); … … 197 202 vtkDataSet *ds = _dataSet->getVtkDataSet(); 198 203 double dataRange[2]; 199 _dataSet->get DataRange(dataRange);204 _dataSet->getVectorMagnitudeRange(dataRange); 200 205 double bounds[6]; 201 206 _dataSet->getBounds(bounds); … … 215 220 if (ds->GetPointData() == NULL || 216 221 ds->GetPointData()->GetVectors() == NULL) { 217 WARN("No vector point data found in DataSet %s", _dataSet->getName().c_str());222 TRACE("No vector point data found in DataSet %s", _dataSet->getName().c_str()); 218 223 if (ds->GetCellData() == NULL || 219 224 ds->GetCellData()->GetVectors() == NULL) { … … 290 295 291 296 _lut = vtkSmartPointer<vtkLookupTable>::New(); 297 _lut->SetRange(dataRange); 292 298 _lut->SetVectorModeToMagnitude(); 293 299 … … 299 305 } 300 306 _pdMapper->SetColorModeToMapScalars(); 301 _pdMapper->UseLookupTableScalarRangeO ff();307 _pdMapper->UseLookupTableScalarRangeOn(); 302 308 _pdMapper->SetLookupTable(_lut); 303 309 … … 693 699 _pdMapper->SetInputConnection(_streamTracer->GetOutputPort()); 694 700 _lineFilter = NULL; 695 _linesActor->GetProperty()->BackfaceCullingOff();701 setCulling(_linesActor->GetProperty(), false); 696 702 _linesActor->GetProperty()->SetRepresentationToWireframe(); 697 703 _linesActor->GetProperty()->LightingOff(); … … 720 726 tubeFilter->SetRadius(radius); 721 727 _pdMapper->SetInputConnection(_lineFilter->GetOutputPort()); 722 if (_ backfaceCulling && _opacity == 1.0)723 _linesActor->GetProperty()->BackfaceCullingOn();728 if (_faceCulling && _opacity == 1.0) 729 setCulling(_linesActor->GetProperty(), true); 724 730 _linesActor->GetProperty()->SetRepresentationToSurface(); 725 731 _linesActor->GetProperty()->LightingOn(); … … 747 753 ribbonFilter->UseDefaultNormalOn(); 748 754 _pdMapper->SetInputConnection(_lineFilter->GetOutputPort()); 749 _linesActor->GetProperty()->BackfaceCullingOff();755 setCulling(_linesActor->GetProperty(), false); 750 756 _linesActor->GetProperty()->SetRepresentationToSurface(); 751 757 _linesActor->GetProperty()->LightingOn(); 758 } 759 } 760 761 void Streamlines::setColorMode(ColorMode mode) 762 { 763 _colorMode = mode; 764 if (_dataSet == NULL || _pdMapper == NULL) 765 return; 766 767 vtkDataSet *ds = _dataSet->getVtkDataSet(); 768 769 switch (mode) { 770 case COLOR_BY_SCALAR: { 771 _pdMapper->ScalarVisibilityOn(); 772 _pdMapper->SetScalarModeToDefault(); 773 if (_lut != NULL) { 774 double dataRange[2]; 775 _dataSet->getDataRange(dataRange); 776 _lut->SetRange(dataRange); 777 } 778 } 779 break; 780 case COLOR_BY_VECTOR_MAGNITUDE: { 781 _pdMapper->ScalarVisibilityOn(); 782 _pdMapper->SetScalarModeToUsePointFieldData(); 783 if (ds->GetPointData() != NULL && 784 ds->GetPointData()->GetVectors() != NULL) { 785 _pdMapper->SelectColorArray(ds->GetPointData()->GetVectors()->GetName()); 786 } 787 if (_lut != NULL) { 788 double dataRange[2]; 789 _dataSet->getVectorMagnitudeRange(dataRange); 790 TRACE("vmag range: %g %g", dataRange[0], dataRange[1]); 791 _lut->SetRange(dataRange); 792 _lut->SetVectorModeToMagnitude(); 793 } 794 } 795 break; 796 case COLOR_BY_VECTOR_X: 797 _pdMapper->ScalarVisibilityOn(); 798 _pdMapper->SetScalarModeToUsePointFieldData(); 799 if (ds->GetPointData() != NULL && 800 ds->GetPointData()->GetVectors() != NULL) { 801 _pdMapper->SelectColorArray(ds->GetPointData()->GetVectors()->GetName()); 802 } 803 if (_lut != NULL) { 804 double dataRange[2]; 805 _dataSet->getVectorComponentRange(dataRange, 0); 806 _lut->SetRange(dataRange); 807 _lut->SetVectorModeToComponent(); 808 _lut->SetVectorComponent(0); 809 } 810 break; 811 case COLOR_BY_VECTOR_Y: 812 _pdMapper->ScalarVisibilityOn(); 813 _pdMapper->SetScalarModeToUsePointFieldData(); 814 if (ds->GetPointData() != NULL && 815 ds->GetPointData()->GetVectors() != NULL) { 816 _pdMapper->SelectColorArray(ds->GetPointData()->GetVectors()->GetName()); 817 } 818 if (_lut != NULL) { 819 double dataRange[2]; 820 _dataSet->getVectorComponentRange(dataRange, 1); 821 _lut->SetRange(dataRange); 822 _lut->SetVectorModeToComponent(); 823 _lut->SetVectorComponent(1); 824 } 825 break; 826 case COLOR_BY_VECTOR_Z: 827 _pdMapper->ScalarVisibilityOn(); 828 _pdMapper->SetScalarModeToUsePointFieldData(); 829 if (ds->GetPointData() != NULL && 830 ds->GetPointData()->GetVectors() != NULL) { 831 _pdMapper->SelectColorArray(ds->GetPointData()->GetVectors()->GetName()); 832 } 833 if (_lut != NULL) { 834 double dataRange[2]; 835 _dataSet->getVectorComponentRange(dataRange, 2); 836 TRACE("vz range: %g %g", dataRange[0], dataRange[1]); 837 _lut->SetRange(dataRange); 838 _lut->SetVectorModeToComponent(); 839 _lut->SetVectorComponent(2); 840 } 841 break; 842 case COLOR_CONSTANT: 843 default: 844 _pdMapper->ScalarVisibilityOff(); 845 break; 752 846 } 753 847 } … … 772 866 } 773 867 774 _lut->SetVectorModeToMagnitude(); 868 switch (_colorMode) { 869 case COLOR_BY_VECTOR_MAGNITUDE: { 870 double dataRange[2]; 871 _dataSet->getVectorMagnitudeRange(dataRange); 872 _lut->SetVectorModeToMagnitude(); 873 _lut->SetRange(dataRange); 874 } 875 break; 876 case COLOR_BY_VECTOR_X: { 877 double dataRange[2]; 878 _dataSet->getVectorComponentRange(dataRange, 0); 879 _lut->SetVectorModeToComponent(); 880 _lut->SetVectorComponent(0); 881 _lut->SetRange(dataRange); 882 } 883 break; 884 case COLOR_BY_VECTOR_Y: { 885 double dataRange[2]; 886 _dataSet->getVectorComponentRange(dataRange, 1); 887 _lut->SetVectorModeToComponent(); 888 _lut->SetVectorComponent(1); 889 _lut->SetRange(dataRange); 890 } 891 break; 892 case COLOR_BY_VECTOR_Z: { 893 double dataRange[2]; 894 _dataSet->getVectorComponentRange(dataRange, 2); 895 _lut->SetVectorModeToComponent(); 896 _lut->SetVectorComponent(2); 897 _lut->SetRange(dataRange); 898 } 899 break; 900 default: 901 break; 902 } 775 903 776 904 if (_pdMapper != NULL) { … … 798 926 _linesActor->GetProperty()->SetOpacity(_opacity); 799 927 if (_opacity < 1.0) 800 _linesActor->GetProperty()->BackfaceCullingOff();801 else if (_ backfaceCulling && _lineType == TUBES)802 _linesActor->GetProperty()->BackfaceCullingOn();928 setCulling(_linesActor->GetProperty(), false); 929 else if (_faceCulling && _lineType == TUBES) 930 setCulling(_linesActor->GetProperty(), true); 803 931 } 804 932 if (_seedActor != NULL) { … … 860 988 /** 861 989 * \brief Set RGB color of stream lines 990 */ 991 void Streamlines::setColor(float color[3]) 992 { 993 _color[0] = color[0]; 994 _color[1] = color[1]; 995 _color[2] = color[2]; 996 if (_linesActor != NULL) 997 _linesActor->GetProperty()->SetColor(_color[0], _color[1], _color[2]); 998 } 999 1000 /** 1001 * \brief Set RGB color of stream line edges 862 1002 */ 863 1003 void Streamlines::setEdgeColor(float color[3]) -
trunk/packages/vizservers/vtkvis/RpStreamlines.h
r2349 r2393 35 35 RIBBONS 36 36 }; 37 enum ColorMode { 38 COLOR_BY_SCALAR, 39 COLOR_BY_VECTOR_MAGNITUDE, 40 COLOR_BY_VECTOR_X, 41 COLOR_BY_VECTOR_Y, 42 COLOR_BY_VECTOR_Z, 43 COLOR_CONSTANT 44 }; 37 45 38 46 Streamlines(); … … 51 59 52 60 virtual bool getVisibility(); 61 62 virtual void setColor(float color[3]); 53 63 54 64 virtual void setEdgeVisibility(bool state); … … 83 93 void setLineTypeToRibbons(double width, double angle); 84 94 95 void setColorMode(ColorMode mode); 96 85 97 void setLookupTable(vtkLookupTable *lut); 86 98 … … 107 119 108 120 LineType _lineType; 121 ColorMode _colorMode; 122 float _color[3]; 109 123 float _seedColor[3]; 110 124 bool _seedVisible; -
trunk/packages/vizservers/vtkvis/RpVtkDataSet.cpp
r2379 r2393 242 242 * \brief Set the ative scalar array to the named field 243 243 */ 244 bool DataSet::setActiveScalar (const char *name)244 bool DataSet::setActiveScalars(const char *name) 245 245 { 246 246 bool found = false; … … 261 261 * \brief Set the ative vector array to the named field 262 262 */ 263 bool DataSet::setActiveVector (const char *name)263 bool DataSet::setActiveVectors(const char *name) 264 264 { 265 265 bool found = false; -
trunk/packages/vizservers/vtkvis/RpVtkDataSet.h
r2332 r2393 45 45 const char *getVtkType() const; 46 46 47 bool setActiveScalar (const char *name);47 bool setActiveScalars(const char *name); 48 48 49 bool setActiveVector (const char *name);49 bool setActiveVectors(const char *name); 50 50 51 51 void getDataRange(double minmax[2]) const; -
trunk/packages/vizservers/vtkvis/RpVtkGraphicsObject.h
r2332 r2393 36 36 class VtkGraphicsObject { 37 37 public: 38 enum CullFace { 39 CULL_FRONT, 40 CULL_BACK, 41 CULL_FRONT_AND_BACK 42 }; 43 38 44 VtkGraphicsObject() : 39 45 _dataSet(NULL), … … 41 47 _edgeWidth(1.0f), 42 48 _lighting(true), 43 _backfaceCulling(false) 49 _cullFace(CULL_BACK), 50 _faceCulling(false) 44 51 { 45 52 _color[0] = 1.0f; … … 139 146 if (getProp3D() != NULL) { 140 147 getProp3D()->SetUserMatrix(matrix); 148 } 149 } 150 151 /** 152 * \brief Set the prop center of rotation 153 * 154 * \param[in] origin The point about which the object rotates 155 */ 156 virtual void setOrigin(double origin[3]) 157 { 158 if (getProp3D() != NULL) { 159 getProp3D()->SetOrigin(origin); 141 160 } 142 161 } … … 156 175 axis[1] = quat[2] / denom; 157 176 axis[2] = quat[3] / denom; 158 getProp3D()->SetOrientation(0, 0, 0); 159 getProp3D()->RotateWXYZ(angle, axis[0], axis[1], axis[2]); 177 setOrientation(angle, axis); 160 178 } 161 179 } … … 231 249 if (getActor() != NULL) { 232 250 getActor()->GetProperty()->SetOpacity(opacity); 233 if (_ backfaceCulling && _opacity < 1.0) {234 getActor()->GetProperty()->BackfaceCullingOff();235 TRACE(" Backface culling off");236 } else if (_ backfaceCulling && _opacity == 1.0) {237 getActor()->GetProperty()->BackfaceCullingOn();238 TRACE(" Backface culling on");251 if (_faceCulling && _opacity < 1.0) { 252 setCulling(getActor()->GetProperty(), false); 253 TRACE("Culling off"); 254 } else if (_faceCulling && _opacity == 1.0) { 255 setCulling(getActor()->GetProperty(), true); 256 TRACE("Culling on"); 239 257 } 240 258 } else if (getAssembly() != NULL) { … … 245 263 if (vtkActor::SafeDownCast(prop) != NULL) { 246 264 vtkActor::SafeDownCast(prop)->GetProperty()->SetOpacity(opacity); 247 if (_ backfaceCulling && _opacity < 1.0) {248 vtkActor::SafeDownCast(prop)->GetProperty()->BackfaceCullingOff();249 TRACE(" Backface culling off");250 } else if (_ backfaceCulling && _opacity == 1.0) {251 vtkActor::SafeDownCast(prop)->GetProperty()->BackfaceCullingOn();252 TRACE(" Backface culling on");265 if (_faceCulling && _opacity < 1.0) { 266 setCulling(vtkActor::SafeDownCast(prop)->GetProperty(), false); 267 TRACE("Culling off"); 268 } else if (_faceCulling && _opacity == 1.0) { 269 setCulling(vtkActor::SafeDownCast(prop)->GetProperty(), true); 270 TRACE("Culling on"); 253 271 } 254 272 } … … 573 591 574 592 /** 575 * \brief Toggle backface culling of prop 576 */ 577 virtual void setBackfaceCulling(bool state) 578 { 579 _backfaceCulling = state; 593 * \brief Convenience method to set culling state on a vtkProperty 594 * 595 * Note: Does not change the culling state flag of this VtkGraphicsObject 596 */ 597 virtual void setCulling(vtkProperty *property, bool state) 598 { 599 switch (_cullFace) { 600 case CULL_FRONT: 601 property->SetFrontfaceCulling((state ? 1 : 0)); 602 property->BackfaceCullingOff(); 603 break; 604 case CULL_BACK: 605 property->SetBackfaceCulling((state ? 1 : 0)); 606 property->FrontfaceCullingOff(); 607 break; 608 case CULL_FRONT_AND_BACK: 609 property->SetBackfaceCulling((state ? 1 : 0)); 610 property->SetFrontfaceCulling((state ? 1 : 0)); 611 break; 612 } 613 } 614 615 /** 616 * \brief Toggle culling of selected CullFace 617 */ 618 virtual void setCulling(bool state) 619 { 620 _faceCulling = state; 580 621 if (state && _opacity < 1.0) 581 622 return; 582 623 if (getActor() != NULL) { 583 getActor()->GetProperty()->SetBackfaceCulling((state ? 1 : 0));624 setCulling(getActor()->GetProperty(), state); 584 625 } else if (getAssembly() != NULL) { 585 626 vtkProp3DCollection *props = getAssembly()->GetParts(); … … 588 629 while ((prop = props->GetNextProp3D()) != NULL) { 589 630 if (vtkActor::SafeDownCast(prop) != NULL) { 590 vtkActor::SafeDownCast(prop)->GetProperty()->SetBackfaceCulling((state ? 1 : 0)); 591 } 592 } 593 } 631 setCulling(vtkActor::SafeDownCast(prop)->GetProperty(), state); 632 } 633 } 634 } 635 } 636 637 virtual void setCullFace(CullFace cull) 638 { 639 _cullFace = cull; 640 setCulling(_faceCulling); 594 641 } 595 642 … … 613 660 if (!_lighting) 614 661 property->LightingOff(); 615 if (_ backfaceCulling && _opacity == 1.0) {616 property->BackfaceCullingOn();662 if (_faceCulling && _opacity == 1.0) { 663 setCulling(property, true); 617 664 } 618 665 } … … 631 678 float _edgeWidth; 632 679 bool _lighting; 633 bool _backfaceCulling; 680 CullFace _cullFace; 681 bool _faceCulling; 634 682 635 683 vtkSmartPointer<vtkProp> _prop; -
trunk/packages/vizservers/vtkvis/RpVtkRenderer.cpp
r2352 r2393 687 687 } 688 688 689 bool Renderer::setDataSetActiveScalars(const DataSetId& id, const char *scalarName) 690 { 691 DataSetHashmap::iterator itr; 692 693 bool doAll = false; 694 695 if (id.compare("all") == 0) { 696 itr = _dataSets.begin(); 697 doAll = true; 698 } else { 699 itr = _dataSets.find(id); 700 } 701 if (itr == _dataSets.end()) { 702 ERROR("DataSet not found: %s", id.c_str()); 703 return false; 704 } 705 706 bool ret = true; 707 do { 708 if (!itr->second->setActiveScalars(scalarName)) { 709 ret = false; 710 } 711 } while (doAll && ++itr != _dataSets.end()); 712 713 if (ret) { 714 collectDataRanges(_cumulativeDataRange, _cumulativeRangeOnlyVisible); 715 updateRanges(_useCumulativeRange); 716 _needsRedraw = true; 717 } 718 719 return ret; 720 } 721 722 bool Renderer::setDataSetActiveVectors(const DataSetId& id, const char *vectorName) 723 { 724 DataSetHashmap::iterator itr; 725 726 bool doAll = false; 727 728 if (id.compare("all") == 0) { 729 itr = _dataSets.begin(); 730 doAll = true; 731 } else { 732 itr = _dataSets.find(id); 733 } 734 if (itr == _dataSets.end()) { 735 ERROR("DataSet not found: %s", id.c_str()); 736 return false; 737 } 738 739 bool ret = true; 740 do { 741 if (!itr->second->setActiveVectors(vectorName)) { 742 ret = false; 743 } 744 } while (doAll && ++itr != _dataSets.end()); 745 746 if (ret) { 747 collectDataRanges(_cumulativeDataRange, _cumulativeRangeOnlyVisible); 748 updateRanges(_useCumulativeRange); 749 _needsRedraw = true; 750 } 751 752 return ret; 753 } 754 689 755 /** 690 756 * \brief Control whether the cumulative data range of datasets is used for … … 2383 2449 2384 2450 /** 2451 * \brief Set the RGB polygon color for the specified DataSet 2452 */ 2453 void Renderer::setGlyphsColor(const DataSetId& id, float color[3]) 2454 { 2455 GlyphsHashmap::iterator itr; 2456 2457 bool doAll = false; 2458 2459 if (id.compare("all") == 0) { 2460 itr = _glyphs.begin(); 2461 doAll = true; 2462 } else { 2463 itr = _glyphs.find(id); 2464 } 2465 if (itr == _glyphs.end()) { 2466 ERROR("Glyphs not found: %s", id.c_str()); 2467 return; 2468 } 2469 2470 do { 2471 itr->second->setColor(color); 2472 } while (doAll && ++itr != _glyphs.end()); 2473 2474 _needsRedraw = true; 2475 } 2476 2477 /** 2385 2478 * \brief Associate an existing named color map with a Glyphs for the given DataSet 2386 2479 */ … … 5240 5333 ColorMap *cmap = getColorMap("default"); 5241 5334 lut->DeepCopy(cmap->getLookupTable()); 5242 #if 0 5243 // Currently lookup table/scalar data range not used, colormap is used to 5244 // color streamlines by vector magnitude 5335 5245 5336 if (_useCumulativeRange) { 5246 5337 lut->SetRange(_cumulativeDataRange); … … 5250 5341 lut->SetRange(range); 5251 5342 } 5252 #endif5253 5343 streamlines->setLookupTable(lut); 5254 5344 … … 5754 5844 5755 5845 /** 5846 * \brief Set the color mode for the specified DataSet 5847 */ 5848 void Renderer::setStreamlinesColorMode(const DataSetId& id, Streamlines::ColorMode mode) 5849 { 5850 StreamlinesHashmap::iterator itr; 5851 5852 bool doAll = false; 5853 5854 if (id.compare("all") == 0) { 5855 itr = _streamlines.begin(); 5856 doAll = true; 5857 } else { 5858 itr = _streamlines.find(id); 5859 } 5860 if (itr == _streamlines.end()) { 5861 ERROR("Streamlines not found: %s", id.c_str()); 5862 return; 5863 } 5864 5865 do { 5866 itr->second->setColorMode(mode); 5867 } while (doAll && ++itr != _streamlines.end()); 5868 5869 _needsRedraw = true; 5870 } 5871 5872 /** 5756 5873 * \brief Associate an existing named color map with a Streamlines for the given DataSet 5757 5874 */ … … 5790 5907 lut->DeepCopy(cmap->getLookupTable()); 5791 5908 5792 #if 05793 5909 if (_useCumulativeRange) { 5794 5910 lut->SetRange(_cumulativeDataRange); … … 5800 5916 } 5801 5917 } 5802 #endif5803 5918 5804 5919 itr->second->setLookupTable(lut); … … 5863 5978 } 5864 5979 5980 /** 5981 * \brief Set the RGB color for the specified DataSet 5982 */ 5983 void Renderer::setStreamlinesColor(const DataSetId& id, float color[3]) 5984 { 5985 StreamlinesHashmap::iterator itr; 5986 5987 bool doAll = false; 5988 5989 if (id.compare("all") == 0) { 5990 itr = _streamlines.begin(); 5991 doAll = true; 5992 } else { 5993 itr = _streamlines.find(id); 5994 } 5995 if (itr == _streamlines.end()) { 5996 ERROR("Streamlines not found: %s", id.c_str()); 5997 return; 5998 } 5999 6000 do { 6001 itr->second->setColor(color); 6002 } while (doAll && ++itr != _streamlines.end()); 6003 6004 _needsRedraw = true; 6005 } 5865 6006 5866 6007 /** … … 6491 6632 } 6492 6633 6493 inline void quaternionToMatrix4x4( double quat[4], vtkMatrix4x4& mat)6634 inline void quaternionToMatrix4x4(const double quat[4], vtkMatrix4x4& mat) 6494 6635 { 6495 6636 double ww = quat[0]*quat[0]; … … 6525 6666 } 6526 6667 6527 inline void quaternionToTransposeMatrix4x4( double quat[4], vtkMatrix4x4& mat)6668 inline void quaternionToTransposeMatrix4x4(const double quat[4], vtkMatrix4x4& mat) 6528 6669 { 6529 6670 double ww = quat[0]*quat[0]; … … 6559 6700 } 6560 6701 6561 inline double *quatMult( double q1[4],double q2[4], double result[4])6702 inline double *quatMult(const double q1[4], const double q2[4], double result[4]) 6562 6703 { 6563 6704 double q1w = q1[0]; … … 6576 6717 } 6577 6718 6578 inline double *quatConjugate( double quat[4], double result[4])6719 inline double *quatConjugate(const double quat[4], double result[4]) 6579 6720 { 6580 6721 result[1] = -quat[1]; … … 6584 6725 } 6585 6726 6586 inline double *quatReciprocal( double quat[4], double result[4])6727 inline double *quatReciprocal(const double quat[4], double result[4]) 6587 6728 { 6588 6729 double denom = … … 6603 6744 } 6604 6745 6605 inline void copyQuat( double quat[4], double result[4])6746 inline void copyQuat(const double quat[4], double result[4]) 6606 6747 { 6607 6748 memcpy(result, quat, sizeof(double)*4); … … 6615 6756 * \param[in] absolute Is rotation absolute or relative? 6616 6757 */ 6617 void Renderer::setCameraOrientation( double quat[4], bool absolute)6758 void Renderer::setCameraOrientation(const double quat[4], bool absolute) 6618 6759 { 6619 6760 if (_cameraMode == IMAGE) … … 6623 6764 vtkSmartPointer<vtkMatrix4x4> rotMat = vtkSmartPointer<vtkMatrix4x4>::New(); 6624 6765 6766 double q[4]; 6767 copyQuat(quat, q); 6768 6625 6769 if (absolute) { 6626 6770 double abs[4]; 6627 6771 // Save absolute rotation 6628 copyQuat(q uat, abs);6772 copyQuat(q, abs); 6629 6773 // Compute relative rotation 6630 quatMult(quatReciprocal(_cameraOrientation), q uat, quat);6774 quatMult(quatReciprocal(_cameraOrientation), q, q); 6631 6775 // Store absolute rotation 6632 6776 copyQuat(abs, _cameraOrientation); 6633 6777 } else { 6634 6778 // Compute new absolute rotation 6635 quatMult(_cameraOrientation, q uat, _cameraOrientation);6636 } 6637 6638 quaternionToTransposeMatrix4x4(q uat, *rotMat);6779 quatMult(_cameraOrientation, q, _cameraOrientation); 6780 } 6781 6782 quaternionToTransposeMatrix4x4(q, *rotMat); 6639 6783 #ifdef DEBUG 6640 6784 TRACE("Rotation matrix:\n %g %g %g\n %g %g %g\n %g %g %g", … … 6669 6813 * \param[in] viewUp x,y,z up vector of camera 6670 6814 */ 6671 void Renderer::setCameraOrientationAndPosition( double position[3],6672 double focalPoint[3],6673 double viewUp[3])6815 void Renderer::setCameraOrientationAndPosition(const double position[3], 6816 const double focalPoint[3], 6817 const double viewUp[3]) 6674 6818 { 6675 6819 vtkSmartPointer<vtkCamera> camera = _renderer->GetActiveCamera(); … … 6735 6879 } 6736 6880 6881 void Renderer::resetCameraClippingRange() 6882 { 6883 _renderer->ResetCameraClippingRange(); 6884 } 6885 6737 6886 /** 6738 6887 * \brief Perform a relative rotation to current camera orientation … … 6811 6960 } 6812 6961 6813 vtkSmartPointer<vtkCamera> camera = _renderer->GetActiveCamera(); 6814 double viewFocus[4], focalDepth, viewPoint[3]; 6815 double newPickPoint[4], oldPickPoint[4], motionVector[3]; 6816 6817 camera->GetFocalPoint(viewFocus); 6818 computeWorldToDisplay(viewFocus[0], viewFocus[1], viewFocus[2], 6819 viewFocus); 6820 focalDepth = viewFocus[2]; 6821 6822 computeDisplayToWorld(( x * 2. + 1.) * _windowWidth / 2.0, 6823 ( y * 2. + 1.) * _windowHeight / 2.0, 6824 focalDepth, 6825 newPickPoint); 6826 6827 computeDisplayToWorld(_windowWidth / 2.0, 6828 _windowHeight / 2.0, 6829 focalDepth, 6830 oldPickPoint); 6831 6832 // Camera motion is reversed 6833 motionVector[0] = oldPickPoint[0] - newPickPoint[0]; 6834 motionVector[1] = oldPickPoint[1] - newPickPoint[1]; 6835 motionVector[2] = oldPickPoint[2] - newPickPoint[2]; 6836 6837 camera->GetFocalPoint(viewFocus); 6838 camera->GetPosition(viewPoint); 6839 camera->SetFocalPoint(motionVector[0] + viewFocus[0], 6840 motionVector[1] + viewFocus[1], 6841 motionVector[2] + viewFocus[2]); 6842 6843 camera->SetPosition(motionVector[0] + viewPoint[0], 6844 motionVector[1] + viewPoint[1], 6845 motionVector[2] + viewPoint[2]); 6846 6847 _renderer->ResetCameraClippingRange(); 6848 //computeScreenWorldCoords(); 6962 if (x != 0.0 || y != 0.0) { 6963 vtkSmartPointer<vtkCamera> camera = _renderer->GetActiveCamera(); 6964 double viewFocus[4], focalDepth, viewPoint[3]; 6965 double newPickPoint[4], oldPickPoint[4], motionVector[3]; 6966 6967 camera->GetFocalPoint(viewFocus); 6968 computeWorldToDisplay(viewFocus[0], viewFocus[1], viewFocus[2], 6969 viewFocus); 6970 focalDepth = viewFocus[2]; 6971 6972 computeDisplayToWorld(( x * 2. + 1.) * _windowWidth / 2.0, 6973 ( y * 2. + 1.) * _windowHeight / 2.0, 6974 focalDepth, 6975 newPickPoint); 6976 6977 computeDisplayToWorld(_windowWidth / 2.0, 6978 _windowHeight / 2.0, 6979 focalDepth, 6980 oldPickPoint); 6981 6982 // Camera motion is reversed 6983 motionVector[0] = oldPickPoint[0] - newPickPoint[0]; 6984 motionVector[1] = oldPickPoint[1] - newPickPoint[1]; 6985 motionVector[2] = oldPickPoint[2] - newPickPoint[2]; 6986 6987 camera->GetFocalPoint(viewFocus); 6988 camera->GetPosition(viewPoint); 6989 camera->SetFocalPoint(motionVector[0] + viewFocus[0], 6990 motionVector[1] + viewFocus[1], 6991 motionVector[2] + viewFocus[2]); 6992 6993 camera->SetPosition(motionVector[0] + viewPoint[0], 6994 motionVector[1] + viewPoint[1], 6995 motionVector[2] + viewPoint[2]); 6996 6997 _renderer->ResetCameraClippingRange(); 6998 //computeScreenWorldCoords(); 6999 } 6849 7000 } 6850 7001 … … 7294 7445 } 7295 7446 } 7296 #if 07297 // Currently lookup table/scalar data range not used, colormap is used to7298 // color streamlines by vector magnitude7299 7447 for (StreamlinesHashmap::iterator itr = _streamlines.begin(); 7300 7448 itr != _streamlines.end(); ++itr) { … … 7312 7460 } 7313 7461 } 7314 #endif7315 7462 for (VolumeHashmap::iterator itr = _volumes.begin(); 7316 7463 itr != _volumes.end(); ++itr) { -
trunk/packages/vizservers/vtkvis/RpVtkRenderer.h
r2351 r2393 108 108 bool setDataFile(const DataSetId& id, const char *filename); 109 109 110 bool setDataSetActiveScalars(const DataSetId& id, const char *scalarName); 111 112 bool setDataSetActiveVectors(const DataSetId& id, const char *vectorName); 113 110 114 double getDataValueAtPixel(const DataSetId& id, int x, int y); 111 115 … … 142 146 void resetCamera(bool resetOrientation = true); 143 147 148 void resetCameraClippingRange(); 149 144 150 void setCameraZoomRegion(double x, double y, double width, double height); 145 151 … … 150 156 void rotateCamera(double yaw, double pitch, double roll); 151 157 152 void setCameraOrientation( double quat[4], bool absolute = true);158 void setCameraOrientation(const double quat[4], bool absolute = true); 153 159 154 160 void panCamera(double x, double y, bool absolute = true); … … 156 162 void zoomCamera(double z, bool absolute = true); 157 163 158 void setCameraOrientationAndPosition( double position[3],159 double focalPoint[3],160 double viewUp[3]);164 void setCameraOrientationAndPosition(const double position[3], 165 const double focalPoint[3], 166 const double viewUp[3]); 161 167 162 168 void getCameraOrientationAndPosition(double position[3], … … 314 320 void setGlyphsScale(const DataSetId& id, double scale[3]); 315 321 322 void setGlyphsColor(const DataSetId& id, float color[3]); 323 316 324 void setGlyphsEdgeVisibility(const DataSetId& id, bool state); 317 325 … … 544 552 545 553 void setStreamlinesScale(const DataSetId& id, double scale[3]); 554 555 void setStreamlinesColor(const DataSetId& id, float color[3]); 546 556 547 557 void setStreamlinesEdgeVisibility(const DataSetId& id, bool state); … … 587 597 588 598 void setStreamlinesSeedVisibility(const DataSetId& id, bool state); 599 600 void setStreamlinesColorMode(const DataSetId& id, Streamlines::ColorMode mode); 589 601 590 602 void setStreamlinesColorMap(const DataSetId& id, const ColorMapId& colorMapId); -
trunk/packages/vizservers/vtkvis/RpVtkRendererCmd.cpp
r2349 r2393 1157 1157 static Rappture::CmdSpec contour3dOps[] = { 1158 1158 {"add", 1, Contour3DAddOp, 4, 5, "oper value ?dataSetName?"}, 1159 {"c olor", 6, Contour3DColorOp, 5, 6, "r g b ?dataSetName?"},1160 {"colormap", 6, Contour3DColorMapOp, 3, 4, "colorMapName ?dataSetName?"},1159 {"ccolor", 2, Contour3DColorOp, 5, 6, "r g b ?dataSetName?"}, 1160 {"colormap", 2, Contour3DColorMapOp, 3, 4, "colorMapName ?dataSetName?"}, 1161 1161 {"delete", 1, Contour3DDeleteOp, 2, 3, "?dataSetName?"}, 1162 1162 {"edges", 1, Contour3DEdgeVisibilityOp, 3, 4, "bool ?dataSetName?"}, … … 1188 1188 1189 1189 static int 1190 DataSetActiveScalarsOp(ClientData clientData, Tcl_Interp *interp, int objc, 1191 Tcl_Obj *const *objv) 1192 { 1193 const char *scalarName = Tcl_GetString(objv[2]); 1194 if (objc == 4) { 1195 const char *name = Tcl_GetString(objv[3]); 1196 if (!g_renderer->setDataSetActiveScalars(name, scalarName)) { 1197 Tcl_AppendResult(interp, "scalar \"", scalarName, 1198 "\" not found", (char*)NULL); 1199 return TCL_ERROR; 1200 } 1201 } else { 1202 if (!g_renderer->setDataSetActiveScalars("all", scalarName)) { 1203 Tcl_AppendResult(interp, "scalar \"", scalarName, 1204 "\" not found in one or more data sets", (char*)NULL); 1205 return TCL_ERROR; 1206 } 1207 } 1208 return TCL_OK; 1209 } 1210 1211 static int 1212 DataSetActiveVectorsOp(ClientData clientData, Tcl_Interp *interp, int objc, 1213 Tcl_Obj *const *objv) 1214 { 1215 const char *vectorName = Tcl_GetString(objv[2]); 1216 if (objc == 4) { 1217 const char *name = Tcl_GetString(objv[3]); 1218 if (!g_renderer->setDataSetActiveVectors(name, vectorName)) { 1219 Tcl_AppendResult(interp, "vector \"", vectorName, 1220 "\" not found", (char*)NULL); 1221 return TCL_ERROR; 1222 } 1223 } else { 1224 if (!g_renderer->setDataSetActiveVectors("all", vectorName)) { 1225 Tcl_AppendResult(interp, "vector \"", vectorName, 1226 "\" not found in one or more data sets", (char*)NULL); 1227 return TCL_ERROR; 1228 } 1229 } 1230 return TCL_OK; 1231 } 1232 1233 static int 1190 1234 DataSetAddOp(ClientData clientData, Tcl_Interp *interp, int objc, 1191 1235 Tcl_Obj *const *objv) … … 1385 1429 {"maprange", 1, DataSetMapRangeOp, 3, 3, "value"}, 1386 1430 {"opacity", 1, DataSetOpacityOp, 3, 4, "value ?name?"}, 1387 {"visible", 1, DataSetVisibleOp, 3, 4, "bool ?name?"} 1431 {"scalar", 1, DataSetActiveScalarsOp, 3, 4, "scalarName ?name?"}, 1432 {"vector", 2, DataSetActiveVectorsOp, 3, 4, "vectorName ?name?"}, 1433 {"visible", 2, DataSetVisibleOp, 3, 4, "bool ?name?"} 1388 1434 }; 1389 1435 static int nDataSetOps = NumCmdSpecs(dataSetOps); … … 1446 1492 1447 1493 static int 1494 GlyphsColorOp(ClientData clientData, Tcl_Interp *interp, int objc, 1495 Tcl_Obj *const *objv) 1496 { 1497 float color[3]; 1498 if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK || 1499 GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK || 1500 GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) { 1501 return TCL_ERROR; 1502 } 1503 if (objc == 6) { 1504 const char *name = Tcl_GetString(objv[5]); 1505 g_renderer->setGlyphsColor(name, color); 1506 } else { 1507 g_renderer->setGlyphsColor("all", color); 1508 } 1509 return TCL_OK; 1510 } 1511 1512 static int 1448 1513 GlyphsColorMapOp(ClientData clientData, Tcl_Interp *interp, int objc, 1449 1514 Tcl_Obj *const *objv) … … 1465 1530 Glyphs::ColorMode mode; 1466 1531 const char *str = Tcl_GetString(objv[2]); 1467 if (str[0] == 's' && strcmp(str, "scale") == 0) { 1532 if (str[0] == 'c' && strcmp(str, "ccolor") == 0) { 1533 mode = Glyphs::COLOR_CONSTANT; 1534 } else if (str[0] == 's' && strcmp(str, "scale") == 0) { 1468 1535 mode = Glyphs::COLOR_BY_SCALE; 1469 1536 } else if (str[0] == 's' && strcmp(str, "scalar") == 0) { … … 1473 1540 } else { 1474 1541 Tcl_AppendResult(interp, "bad color mode option \"", str, 1475 "\": should be one of: 'scale', 'scalar', 'vector' ", (char*)NULL);1542 "\": should be one of: 'scale', 'scalar', 'vector', 'ccolor'", (char*)NULL); 1476 1543 return TCL_ERROR; 1477 1544 } … … 1764 1831 static Rappture::CmdSpec glyphsOps[] = { 1765 1832 {"add", 1, GlyphsAddOp, 3, 4, "shape ?dataSetNme?"}, 1833 {"ccolor", 2, GlyphsColorOp, 5, 6, "r g b ?dataSetName?"}, 1766 1834 {"colormap", 7, GlyphsColorMapOp, 3, 4, "colorMapName ?dataSetNme?"}, 1767 1835 {"colormode", 7, GlyphsColorModeOp, 3, 4, "mode ?dataSetNme?"}, … … 3479 3547 3480 3548 static int 3549 StreamlinesColorOp(ClientData clientData, Tcl_Interp *interp, int objc, 3550 Tcl_Obj *const *objv) 3551 { 3552 float color[3]; 3553 if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK || 3554 GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK || 3555 GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) { 3556 return TCL_ERROR; 3557 } 3558 if (objc == 6) { 3559 const char *name = Tcl_GetString(objv[5]); 3560 g_renderer->setStreamlinesColor(name, color); 3561 } else { 3562 g_renderer->setStreamlinesColor("all", color); 3563 } 3564 return TCL_OK; 3565 } 3566 3567 static int 3481 3568 StreamlinesColorMapOp(ClientData clientData, Tcl_Interp *interp, int objc, 3482 3569 Tcl_Obj *const *objv) … … 3488 3575 } else { 3489 3576 g_renderer->setStreamlinesColorMap("all", colorMapName); 3577 } 3578 return TCL_OK; 3579 } 3580 3581 static int 3582 StreamlinesColorModeOp(ClientData clientData, Tcl_Interp *interp, int objc, 3583 Tcl_Obj *const *objv) 3584 { 3585 Streamlines::ColorMode mode; 3586 const char *str = Tcl_GetString(objv[2]); 3587 if (str[0] == 's' && strcmp(str, "scalar") == 0) { 3588 mode = Streamlines::COLOR_BY_SCALAR; 3589 } else if (str[0] == 'v' && strcmp(str, "vmag") == 0) { 3590 mode = Streamlines::COLOR_BY_VECTOR_MAGNITUDE; 3591 } else if (str[0] == 'v' && strcmp(str, "vx") == 0) { 3592 mode = Streamlines::COLOR_BY_VECTOR_X; 3593 } else if (str[0] == 'v' && strcmp(str, "vy") == 0) { 3594 mode = Streamlines::COLOR_BY_VECTOR_Y; 3595 } else if (str[0] == 'v' && strcmp(str, "vz") == 0) { 3596 mode = Streamlines::COLOR_BY_VECTOR_Z; 3597 } else if (str[0] == 'c' && strcmp(str, "ccolor") == 0) { 3598 mode = Streamlines::COLOR_CONSTANT; 3599 } else { 3600 Tcl_AppendResult(interp, "bad color mode option \"", str, 3601 "\": should be one of: 'scalar', 'vmag', 'vx', 'vy', 'vz', 'ccolor'", (char*)NULL); 3602 return TCL_ERROR; 3603 } 3604 if (objc == 4) { 3605 const char *dataSetName = Tcl_GetString(objv[3]); 3606 g_renderer->setStreamlinesColorMode(dataSetName, mode); 3607 } else { 3608 g_renderer->setStreamlinesColorMode("all", mode); 3490 3609 } 3491 3610 return TCL_OK; … … 3953 4072 static Rappture::CmdSpec streamlinesOps[] = { 3954 4073 {"add", 1, StreamlinesAddOp, 2, 3, "?dataSetName?"}, 3955 {"colormap", 1, StreamlinesColorMapOp, 3, 4, "colorMapName ?dataSetName?"}, 4074 {"ccolor", 1, StreamlinesColorOp, 5, 6, "r g b ?dataSetName?"}, 4075 {"colormap", 7, StreamlinesColorMapOp, 3, 4, "colorMapName ?dataSetName?"}, 4076 {"colormode", 7, StreamlinesColorModeOp, 3, 4, "mode ?dataSetNme?"}, 3956 4077 {"delete", 1, StreamlinesDeleteOp, 2, 3, "?dataSetName?"}, 3957 4078 {"edges", 1, StreamlinesEdgeVisibilityOp, 3, 4, "bool ?dataSetName?"}, -
trunk/packages/vizservers/vtkvis/protocol.txt
r2351 r2393 85 85 "all" 86 86 dataset opacity <val> <?datasetName?> 87 dataset scalar <scalarName> <?datasetName?> 88 Set the active scalar field to plot 89 dataset vector <vectorName> <?datasetName?> 90 Set the active vector field to plot 87 91 dataset visible <bool> <?datasetName?> 88 92 … … 107 111 contour3d add contourlist <list> <?datasetName?> 108 112 list = {isoval1 isoval2 isoval3...} 109 contour3d c olor r g b <?datasetName?>113 contour3d ccolor r g b <?datasetName?> 110 114 contour3d colormap <colorMapName> <?dataSetName?> 111 115 contour3d delete <?datasetName?> … … 122 126 123 127 glyphs add <?dataSetName?> 128 glyphs ccolor r g b <?datasetName?> 124 129 glyphs colormap <colorMapName> <?dataSetName?> 125 glyphs colormode <scale|scalar|vector > <?dataSetName?>130 glyphs colormode <scale|scalar|vector|ccolor> <?dataSetName?> 126 131 Set the color mode: color by scale, scalar field or 127 132 vector magnitude -- uses the current color map … … 232 237 233 238 streamlines add <?datasetName?> 239 streamlines ccolor <r> <g> <b> <?datasetName?> 240 Set the constant color of streamlines used for color mode 'ccolor' 234 241 streamlines colormap <colormapName> <?datasetName?> 235 242 Colormap used to color streamlines/tubes/ribbons by vector magnitude 243 streamlines colormode <scalar|vmag|vx|vy|vz|ccolor> <?datasetName?> 244 Set the field used to color the streamlines. 'ccolor' means to use 245 the constant color defined by the ccolor subcommand. 'scalar' uses 246 the active scalar field. 'vmag' uses the magnitude of the current 247 vector field, and 'vx','vy','vz' use the corresponding component of 248 the active vector field. 236 249 streamlines delete <?datasetName?> 237 250 streamlines edges <bool> <?datasetName?>
Note: See TracChangeset
for help on using the changeset viewer.