Changeset 2402 for trunk/packages
- Timestamp:
- Aug 22, 2011, 2:15:12 AM (13 years ago)
- Location:
- trunk/packages/vizservers/vtkvis
- Files:
-
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/vtkvis/ColorMap.cpp
r2332 r2402 219 219 } 220 220 if (itr2 == _controlPoints.end()) { 221 #ifdef DEBUG 221 222 TRACE("val: %g Range: %g - 1 Color: %g %g %g", value, itr->value, 222 223 itr->color[0], itr->color[1], itr->color[2]); 224 #endif 223 225 memcpy(color, itr->color, sizeof(double)*3); 224 226 } else { … … 226 228 assert(value >= itr->value && value <= itr2->value); 227 229 lerp(color, *itr, *itr2, value); 230 #ifdef DEBUG 228 231 TRACE("val: %g Range: %g - %g Color: %g %g %g", value, itr->value, itr2->value, 229 232 color[0], color[1], color[2]); 233 #endif 230 234 } 231 235 if (oitr2 == _opacityControlPoints.end()) { 236 #ifdef DEBUG 232 237 TRACE("val: %g Range: %g - 1 Alpha %g", value, oitr->value, 233 238 oitr->alpha); 239 #endif 234 240 color[3] = oitr->alpha; 235 241 } else { … … 237 243 assert(value >= oitr->value && value <= oitr2->value); 238 244 lerp(&color[3], *oitr, *oitr2, value); 245 #ifdef DEBUG 239 246 TRACE("val: %g Range: %g - %g Alpha: %g", value, oitr->value, oitr2->value, 240 247 color[3]); 248 #endif 241 249 } 242 250 _lookupTable->SetTableValue(i, color); -
trunk/packages/vizservers/vtkvis/Makefile.in
r2348 r2402 131 131 PPMWriter.o: PPMWriter.h Trace.h 132 132 RpContour2D.o: RpContour2D.h RpVtkGraphicsObject.h RpVtkDataSet.h Trace.h 133 RpContour3D.o: RpContour3D.h RpVtkGraphicsObject.h RpVtkDataSet.h Trace.h133 RpContour3D.o: RpContour3D.h RpVtkGraphicsObject.h RpVtkDataSet.h ColorMap.h Trace.h 134 134 RpGlyphs.o: RpGlyphs.h RpVtkGraphicsObject.h RpVtkDataSet.h ColorMap.h Trace.h 135 RpHeightMap.o: RpHeightMap.h RpVtkGraphicsObject.h RpVtkDataSet.h Trace.h136 RpLIC.o: RpLIC.h RpVtkGraphicsObject.h RpVtkDataSet.h Trace.h RpVtkRenderServer.h135 RpHeightMap.o: RpHeightMap.h RpVtkGraphicsObject.h RpVtkDataSet.h ColorMap.h Trace.h 136 RpLIC.o: RpLIC.h RpVtkGraphicsObject.h RpVtkDataSet.h ColorMap.h Trace.h RpVtkRenderServer.h 137 137 RpMolecule.o: RpMolecule.h RpMoleculeData.h RpVtkGraphicsObject.h RpVtkDataSet.h ColorMap.h Trace.h 138 138 RpPolyData.o: RpPolyData.h RpVtkGraphicsObject.h RpVtkDataSet.h Trace.h 139 RpPseudoColor.o: RpPseudoColor.h RpVtkGraphicsObject.h RpVtkDataSet.h Trace.h140 RpStreamlines.o: RpStreamlines.h RpVtkGraphicsObject.h RpVtkDataSet.h Trace.h139 RpPseudoColor.o: RpPseudoColor.h RpVtkGraphicsObject.h RpVtkDataSet.h ColorMap.h Trace.h 140 RpStreamlines.o: RpStreamlines.h RpVtkGraphicsObject.h RpVtkDataSet.h ColorMap.h Trace.h 141 141 RpVolume.o: RpVolume.h RpVtkGraphicsObject.h RpVtkDataSet.h ColorMap.h Trace.h 142 142 RpVtkDataSet.o: RpVtkDataSet.h Trace.h -
trunk/packages/vizservers/vtkvis/RpContour2D.cpp
r2328 r2402 25 25 using namespace Rappture::VtkVis; 26 26 27 Contour2D::Contour2D( ) :27 Contour2D::Contour2D(int numContours) : 28 28 VtkGraphicsObject(), 29 _numContours(0) 30 { 31 _dataRange[0] = 0; 32 _dataRange[1] = 1; 29 _numContours(numContours) 30 { 31 } 32 33 Contour2D::Contour2D(const std::vector<double>& contours) : 34 VtkGraphicsObject(), 35 _numContours(contours.size()), 36 _contours(contours) 37 { 33 38 } 34 39 … … 41 46 TRACE("Deleting Contour2D with NULL DataSet"); 42 47 #endif 43 }44 45 /**46 * \brief Specify input DataSet used to extract contours47 */48 void Contour2D::setDataSet(DataSet *dataSet)49 {50 if (_dataSet != dataSet) {51 _dataSet = dataSet;52 53 if (_dataSet != NULL) {54 double dataRange[2];55 _dataSet->getDataRange(dataRange);56 _dataRange[0] = dataRange[0];57 _dataRange[1] = dataRange[1];58 }59 60 update();61 }62 48 } 63 49 … … 175 161 } 176 162 163 void Contour2D::updateRanges(bool useCumulative, 164 double scalarRange[2], 165 double vectorMagnitudeRange[2], 166 double vectorComponentRange[3][2]) 167 { 168 if (useCumulative) { 169 _dataRange[0] = scalarRange[0]; 170 _dataRange[1] = scalarRange[1]; 171 } else if (_dataSet != NULL) { 172 _dataSet->getScalarRange(_dataRange); 173 } else { 174 WARN("updateRanges called before setDataSet"); 175 } 176 177 if (_contours.empty() && _numContours > 0) { 178 // Contour isovalues need to be recomputed 179 update(); 180 } 181 } 182 177 183 /** 178 184 * \brief Specify number of evenly spaced contour lines to render … … 185 191 _numContours = numContours; 186 192 187 if (_dataSet != NULL) {188 double dataRange[2];189 _dataSet->getDataRange(dataRange);190 _dataRange[0] = dataRange[0];191 _dataRange[1] = dataRange[1];192 }193 194 update();195 }196 197 /**198 * \brief Specify number of evenly spaced contour lines to render199 * between the given range (including range endpoints)200 *201 * Will override any existing contours202 */203 void Contour2D::setContours(int numContours, double range[2])204 {205 _contours.clear();206 _numContours = numContours;207 208 _dataRange[0] = range[0];209 _dataRange[1] = range[1];210 211 193 update(); 212 194 } -
trunk/packages/vizservers/vtkvis/RpContour2D.h
r2328 r2402 27 27 class Contour2D : public VtkGraphicsObject { 28 28 public: 29 Contour2D(); 29 Contour2D(int numContours); 30 31 Contour2D(const std::vector<double>& contours); 32 30 33 virtual ~Contour2D(); 31 34 … … 35 38 } 36 39 37 virtual void setDataSet(DataSet *dataset);38 39 40 virtual void setClippingPlanes(vtkPlaneCollection *planes); 40 41 41 42 void setContours(int numContours); 42 43 void setContours(int numContours, double range[2]);44 43 45 44 void setContourList(const std::vector<double>& contours); … … 49 48 const std::vector<double>& getContourList() const; 50 49 50 virtual void updateRanges(bool useCumulative, 51 double scalarRange[2], 52 double vectorMagnitudeRange[2], 53 double vectorComponentRange[3][2]); 54 51 55 private: 56 Contour2D(); 57 52 58 virtual void initProp(); 53 59 virtual void update(); … … 55 61 int _numContours; 56 62 std::vector<double> _contours; 57 double _dataRange[2];58 63 59 64 vtkSmartPointer<vtkContourFilter> _contourFilter; -
trunk/packages/vizservers/vtkvis/RpContour3D.cpp
r2328 r2402 25 25 using namespace Rappture::VtkVis; 26 26 27 Contour3D::Contour3D( ) :27 Contour3D::Contour3D(int numContours) : 28 28 VtkGraphicsObject(), 29 _numContours(0) 30 { 31 _dataRange[0] = 0; 32 _dataRange[1] = 1; 29 _numContours(numContours), 30 _colorMap(NULL) 31 { 32 _color[0] = 0.0f; 33 _color[1] = 0.0f; 34 _color[2] = 1.0f; 35 } 36 37 Contour3D::Contour3D(const std::vector<double>& contours) : 38 VtkGraphicsObject(), 39 _numContours(contours.size()), 40 _contours(contours), 41 _colorMap(NULL) 42 { 33 43 _color[0] = 0.0f; 34 44 _color[1] = 0.0f; … … 44 54 TRACE("Deleting Contour3D with NULL DataSet"); 45 55 #endif 46 }47 48 /**49 * \brief Specify input DataSet used to extract contours50 */51 void Contour3D::setDataSet(DataSet *dataSet)52 {53 if (_dataSet != dataSet) {54 _dataSet = dataSet;55 56 if (_dataSet != NULL) {57 double dataRange[2];58 _dataSet->getDataRange(dataRange);59 _dataRange[0] = dataRange[0];60 _dataRange[1] = dataRange[1];61 }62 63 update();64 }65 56 } 66 57 … … 85 76 86 77 /** 87 * \brief Get the VTK colormap lookup table in use88 */ 89 v tkLookupTable *Contour3D::getLookupTable()90 { 91 return _lut;78 * \brief Called when the color map has been edited 79 */ 80 void Contour3D::updateColorMap() 81 { 82 setColorMap(_colorMap); 92 83 } 93 84 … … 95 86 * \brief Associate a colormap lookup table with the DataSet 96 87 */ 97 void Contour3D::setLookupTable(vtkLookupTable *lut) 98 { 99 if (lut == NULL) { 88 void Contour3D::setColorMap(ColorMap *cmap) 89 { 90 if (cmap == NULL) 91 return; 92 93 _colorMap = cmap; 94 95 if (_lut == NULL) { 100 96 _lut = vtkSmartPointer<vtkLookupTable>::New(); 101 } else{102 _lut = lut;103 }104 105 if (_contourMapper != NULL) {106 _contourMapper->UseLookupTableScalarRangeOn(); 107 _contourMapper->SetLookupTable(_lut);108 }97 if (_contourMapper != NULL) { 98 _contourMapper->UseLookupTableScalarRangeOn(); 99 _contourMapper->SetLookupTable(_lut); 100 } 101 } 102 103 _lut->DeepCopy(cmap->getLookupTable()); 104 _lut->SetRange(_dataRange); 109 105 } 110 106 … … 198 194 } 199 195 200 if (ds->GetPointData() == NULL || 201 ds->GetPointData()->GetScalars() == NULL) { 202 if (_lut == NULL) { 203 _lut = vtkSmartPointer<vtkLookupTable>::New(); 204 } 205 } else { 206 vtkLookupTable *lut = ds->GetPointData()->GetScalars()->GetLookupTable(); 207 TRACE("Data set scalars lookup table: %p\n", lut); 208 if (_lut == NULL) { 209 if (lut) 210 _lut = lut; 211 else 212 _lut = vtkSmartPointer<vtkLookupTable>::New(); 213 } 214 } 215 216 if (_lut != NULL) { 217 _lut->SetRange(_dataRange); 218 219 _contourMapper->SetColorModeToMapScalars(); 220 _contourMapper->UseLookupTableScalarRangeOn(); 221 _contourMapper->SetLookupTable(_lut); 196 if (_lut == NULL) { 197 setColorMap(ColorMap::getDefault()); 222 198 } 223 199 … … 228 204 } 229 205 206 void Contour3D::updateRanges(bool useCumulative, 207 double scalarRange[2], 208 double vectorMagnitudeRange[2], 209 double vectorComponentRange[3][2]) 210 { 211 if (useCumulative) { 212 _dataRange[0] = scalarRange[0]; 213 _dataRange[1] = scalarRange[1]; 214 } else if (_dataSet != NULL) { 215 _dataSet->getScalarRange(_dataRange); 216 } 217 218 if (_lut != NULL) { 219 _lut->SetRange(_dataRange); 220 } 221 222 if (_contours.empty() && _numContours > 0) { 223 // Need to recompute isovalues 224 update(); 225 } 226 } 227 230 228 /** 231 229 * \brief Specify number of evenly spaced isosurfaces to render … … 238 236 _numContours = numContours; 239 237 240 if (_dataSet != NULL) {241 double dataRange[2];242 _dataSet->getDataRange(dataRange);243 _dataRange[0] = dataRange[0];244 _dataRange[1] = dataRange[1];245 }246 247 update();248 }249 250 /**251 * \brief Specify number of evenly spaced isosurfaces to render252 * between the given range (including range endpoints)253 *254 * Will override any existing contours255 */256 void Contour3D::setContours(int numContours, double range[2])257 {258 _contours.clear();259 _numContours = numContours;260 261 _dataRange[0] = range[0];262 _dataRange[1] = range[1];263 264 238 update(); 265 239 } -
trunk/packages/vizservers/vtkvis/RpContour3D.h
r2328 r2402 18 18 #include <vector> 19 19 20 #include "ColorMap.h" 20 21 #include "RpVtkGraphicsObject.h" 21 22 … … 28 29 class Contour3D : public VtkGraphicsObject { 29 30 public: 30 Contour3D(); 31 Contour3D(int numContours); 32 33 Contour3D(const std::vector<double>& contours); 34 31 35 virtual ~Contour3D(); 32 36 … … 36 40 } 37 41 38 virtual void setDataSet(DataSet *dataset);39 40 42 virtual void setClippingPlanes(vtkPlaneCollection *planes); 41 43 42 44 void setContours(int numContours); 43 44 void setContours(int numContours, double range[2]);45 45 46 46 void setContourList(const std::vector<double>& contours); … … 50 50 const std::vector<double>& getContourList() const; 51 51 52 void set LookupTable(vtkLookupTable *lut);52 void setColorMap(ColorMap *colorMap); 53 53 54 vtkLookupTable *getLookupTable(); 54 /** 55 * \brief Return the ColorMap in use 56 */ 57 ColorMap *getColorMap() 58 { 59 return _colorMap; 60 } 61 62 void updateColorMap(); 63 64 virtual void updateRanges(bool useCumulative, 65 double scalarRange[2], 66 double vectorMagnitudeRange[2], 67 double vectorComponentRange[3][2]); 55 68 56 69 private: 70 Contour3D(); 71 57 72 virtual void initProp(); 58 73 virtual void update(); … … 60 75 int _numContours; 61 76 std::vector<double> _contours; 62 double _dataRange[2];77 ColorMap *_colorMap; 63 78 64 79 vtkSmartPointer<vtkContourFilter> _contourFilter; -
trunk/packages/vizservers/vtkvis/RpGlyphs.cpp
r2393 r2402 14 14 #include <vtkProperty.h> 15 15 #include <vtkGlyph3D.h> 16 #include <vtkLineSource.h> 16 17 #include <vtkArrowSource.h> 17 18 #include <vtkConeSource.h> … … 19 20 #include <vtkPlatonicSolidSource.h> 20 21 #include <vtkSphereSource.h> 22 #include <vtkTransform.h> 21 23 #include <vtkPolyDataMapper.h> 24 #include <vtkTransformPolyDataFilter.h> 22 25 23 26 #include "RpGlyphs.h" … … 26 29 using namespace Rappture::VtkVis; 27 30 28 Glyphs::Glyphs( ) :31 Glyphs::Glyphs(GlyphShape shape) : 29 32 VtkGraphicsObject(), 30 _glyphShape(ARROW), 33 _glyphShape(shape), 34 _scalingMode(SCALE_BY_VECTOR_MAGNITUDE), 35 _dataScale(1.0), 31 36 _scaleFactor(1.0), 32 _colorMode(COLOR_BY_SCALAR) 37 _colorMode(COLOR_BY_SCALAR), 38 _colorMap(NULL) 33 39 { 34 40 _faceCulling = true; … … 39 45 } 40 46 47 void Glyphs::setDataSet(DataSet *dataSet, 48 bool useCumulative, 49 double scalarRange[2], 50 double vectorMagnitudeRange[2], 51 double vectorComponentRange[3][2]) 52 { 53 if (_dataSet != dataSet) { 54 _dataSet = dataSet; 55 56 if (useCumulative) { 57 _dataRange[0] = scalarRange[0]; 58 _dataRange[1] = scalarRange[1]; 59 _vectorMagnitudeRange[0] = vectorMagnitudeRange[0]; 60 _vectorMagnitudeRange[1] = vectorMagnitudeRange[1]; 61 for (int i = 0; i < 3; i++) { 62 _vectorComponentRange[i][0] = vectorComponentRange[i][0]; 63 _vectorComponentRange[i][1] = vectorComponentRange[i][1]; 64 } 65 } else { 66 _dataSet->getScalarRange(_dataRange); 67 _dataSet->getVectorRange(_vectorMagnitudeRange); 68 for (int i = 0; i < 3; i++) { 69 _dataSet->getVectorRange(_vectorComponentRange[i], i); 70 } 71 } 72 73 update(); 74 } 75 } 76 41 77 /** 42 78 * \brief Set the shape of the glyphs … … 45 81 { 46 82 _glyphShape = shape; 83 84 // Note: using vtkTransformPolyDataFilter instead of the vtkGlyph3D's 85 // SourceTransform because of a bug: vtkGlyph3D doesn't transform normals 86 // by the SourceTransform, so the lighting would be wrong 87 47 88 switch (_glyphShape) { 89 case LINE: 90 _glyphSource = vtkSmartPointer<vtkLineSource>::New(); 91 break; 48 92 case ARROW: 49 50 93 _glyphSource = vtkSmartPointer<vtkArrowSource>::New(); 94 break; 51 95 case CONE: 52 53 96 _glyphSource = vtkSmartPointer<vtkConeSource>::New(); 97 break; 54 98 case CUBE: 55 _glyphSource = vtkSmartPointer<vtkPlatonicSolidSource>::New(); 56 vtkPlatonicSolidSource::SafeDownCast(_glyphSource)->SetSolidTypeToCube(); 57 break; 58 case CYLINDER: 59 _glyphSource = vtkSmartPointer<vtkCylinderSource>::New(); 60 break; 99 _glyphSource = vtkSmartPointer<vtkPlatonicSolidSource>::New(); 100 vtkPlatonicSolidSource::SafeDownCast(_glyphSource)->SetSolidTypeToCube(); 101 break; 102 case CYLINDER: { 103 vtkSmartPointer<vtkCylinderSource> csource = vtkSmartPointer<vtkCylinderSource>::New(); 104 vtkCylinderSource::SafeDownCast(csource)->SetResolution(6); 105 _glyphSource = vtkSmartPointer<vtkTransformPolyDataFilter>::New(); 106 _glyphSource->SetInputConnection(csource->GetOutputPort()); 107 vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New(); 108 trans->RotateZ(-90.0); 109 vtkTransformPolyDataFilter::SafeDownCast(_glyphSource)->SetTransform(trans); 110 } 111 break; 61 112 case DODECAHEDRON: 62 63 64 113 _glyphSource = vtkSmartPointer<vtkPlatonicSolidSource>::New(); 114 vtkPlatonicSolidSource::SafeDownCast(_glyphSource)->SetSolidTypeToDodecahedron(); 115 break; 65 116 case ICOSAHEDRON: 66 67 68 117 _glyphSource = vtkSmartPointer<vtkPlatonicSolidSource>::New(); 118 vtkPlatonicSolidSource::SafeDownCast(_glyphSource)->SetSolidTypeToIcosahedron(); 119 break; 69 120 case OCTAHEDRON: 70 71 72 121 _glyphSource = vtkSmartPointer<vtkPlatonicSolidSource>::New(); 122 vtkPlatonicSolidSource::SafeDownCast(_glyphSource)->SetSolidTypeToOctahedron(); 123 break; 73 124 case SPHERE: 74 75 125 _glyphSource = vtkSmartPointer<vtkSphereSource>::New(); 126 break; 76 127 case TETRAHEDRON: 77 _glyphSource = vtkSmartPointer<vtkPlatonicSolidSource>::New(); 78 vtkPlatonicSolidSource::SafeDownCast(_glyphSource)->SetSolidTypeToTetrahedron(); 79 break; 128 // FIXME: need to rotate inital orientation 129 _glyphSource = vtkSmartPointer<vtkPlatonicSolidSource>::New(); 130 vtkPlatonicSolidSource::SafeDownCast(_glyphSource)->SetSolidTypeToTetrahedron(); 131 break; 80 132 default: 81 82 133 ERROR("Unknown glyph shape: %d", _glyphShape); 134 return; 83 135 } 84 136 … … 92 144 93 145 if (_glyphGenerator != NULL) { 94 146 _glyphGenerator->SetSourceConnection(_glyphSource->GetOutputPort()); 95 147 } 96 148 } … … 136 188 137 189 if (ds->GetPointData()->GetVectors() != NULL) { 138 _glyphGenerator->SetScaleModeToScaleByVector(); 190 TRACE("Setting scale mode to vector magnitude"); 191 _scalingMode = SCALE_BY_VECTOR_MAGNITUDE; 192 _glyphGenerator->SetScaleModeToScaleByVector(); 193 _glyphGenerator->SetRange(_vectorMagnitudeRange); 139 194 } else { 140 _glyphGenerator->SetScaleModeToScaleByScalar(); 141 } 142 _glyphGenerator->SetScaleFactor(_scaleFactor); 195 TRACE("Setting scale mode to scalar"); 196 _scalingMode = SCALE_BY_SCALAR; 197 _glyphGenerator->SetScaleModeToScaleByScalar(); 198 _glyphGenerator->SetRange(_dataRange); 199 } 200 201 // Normalize sizes to [0,1] * ScaleFactor 202 _glyphGenerator->ClampingOn(); 203 204 double cellSizeRange[2]; 205 double avgSize; 206 _dataSet->getCellSizeRange(cellSizeRange, &avgSize); 207 //_dataScale = cellSizeRange[0] + (cellSizeRange[1] - cellSizeRange[0])/2.; 208 _dataScale = avgSize; 209 210 TRACE("Cell size range: %g,%g, Data scale factor: %g", 211 cellSizeRange[0], cellSizeRange[1], _dataScale); 212 213 _glyphGenerator->SetScaleFactor(_scaleFactor * _dataScale); 143 214 _glyphGenerator->ScalingOn(); 144 215 … … 146 217 TRACE("Setting color mode to vector magnitude"); 147 218 _glyphGenerator->SetColorModeToColorByVector(); 148 _colorMode = COLOR_BY_VECTOR ;219 _colorMode = COLOR_BY_VECTOR_MAGNITUDE; 149 220 } else { 150 221 TRACE("Setting color mode to scalar"); … … 152 223 _colorMode = COLOR_BY_SCALAR; 153 224 } 154 if (_glyphShape == SPHERE) {155 _glyphGenerator->OrientOff();156 }157 225 158 226 if (_pdMapper == NULL) { … … 161 229 _pdMapper->ScalarVisibilityOn(); 162 230 } 231 163 232 _pdMapper->SetInputConnection(_glyphGenerator->GetOutputPort()); 164 233 165 if (ds->GetPointData() == NULL || 166 ds->GetPointData()->GetScalars() == NULL) { 167 if (_lut == NULL) { 168 _lut = vtkSmartPointer<vtkLookupTable>::New(); 169 } 170 } else { 171 vtkLookupTable *lut = ds->GetPointData()->GetScalars()->GetLookupTable(); 172 TRACE("Data set scalars lookup table: %p\n", lut); 173 if (_lut == NULL) { 174 if (lut) 175 _lut = lut; 176 else 177 _lut = vtkSmartPointer<vtkLookupTable>::New(); 178 } 179 } 180 181 if (ds->GetPointData()->GetScalars() == NULL) { 182 double dataRange[2]; 183 _dataSet->getVectorMagnitudeRange(dataRange); 184 _lut->SetRange(dataRange); 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(); 195 _pdMapper->SetLookupTable(_lut); 196 _pdMapper->UseLookupTableScalarRangeOn(); 234 if (_lut == NULL) { 235 setColorMap(ColorMap::getDefault()); 236 } 197 237 198 238 getActor()->SetMapper(_pdMapper); … … 205 245 void Glyphs::setScalingMode(ScalingMode mode) 206 246 { 247 _scalingMode = mode; 207 248 if (_glyphGenerator != NULL) { 208 249 switch (mode) { 209 case SCALE_BY_SCALAR: 250 case SCALE_BY_SCALAR: { 251 _glyphGenerator->SetRange(_dataRange); 210 252 _glyphGenerator->SetScaleModeToScaleByScalar(); 211 _glyphGenerator->ScalingOn(); 212 break; 213 case SCALE_BY_VECTOR: 253 } 254 break; 255 case SCALE_BY_VECTOR_MAGNITUDE: { 256 _glyphGenerator->SetRange(_vectorMagnitudeRange); 214 257 _glyphGenerator->SetScaleModeToScaleByVector(); 215 _glyphGenerator->ScalingOn(); 216 break; 217 case SCALE_BY_VECTOR_COMPONENTS: 258 } 259 break; 260 case SCALE_BY_VECTOR_COMPONENTS: { 261 double sizeRange[2]; 262 sizeRange[0] = _vectorComponentRange[0][0]; 263 sizeRange[1] = _vectorComponentRange[0][1]; 264 sizeRange[0] = min2(sizeRange[0], _vectorComponentRange[1][0]); 265 sizeRange[1] = max2(sizeRange[1], _vectorComponentRange[1][1]); 266 sizeRange[0] = min2(sizeRange[0], _vectorComponentRange[2][0]); 267 sizeRange[1] = max2(sizeRange[1], _vectorComponentRange[2][1]); 268 _glyphGenerator->SetRange(sizeRange); 218 269 _glyphGenerator->SetScaleModeToScaleByVectorComponents(); 219 _glyphGenerator->ScalingOn();270 } 220 271 break; 221 272 case SCALING_OFF: 222 273 default: 223 274 _glyphGenerator->SetScaleModeToDataScalingOff(); 224 _glyphGenerator->ScalingOff(); 225 } 226 _pdMapper->Update(); 275 } 227 276 } 228 277 } … … 239 288 _glyphGenerator->SetColorModeToColorByScale(); 240 289 _pdMapper->ScalarVisibilityOn(); 241 break; 242 case COLOR_BY_VECTOR: { 290 double dataRange[2]; 291 dataRange[0] = 0; 292 dataRange[1] = 1; 293 _lut->SetRange(dataRange); 294 break; 295 case COLOR_BY_VECTOR_MAGNITUDE: { 243 296 _glyphGenerator->SetColorModeToColorByVector(); 244 _pdMapper->ScalarVisibilityOn(); 245 double dataRange[2]; 246 _dataSet->getVectorMagnitudeRange(dataRange); 247 _lut->SetRange(dataRange); 297 _pdMapper->ScalarVisibilityOn(); 298 _lut->SetRange(_vectorMagnitudeRange); 248 299 } 249 300 break; 250 301 case COLOR_BY_SCALAR: { 251 302 _glyphGenerator->SetColorModeToColorByScalar(); 252 _pdMapper->ScalarVisibilityOn(); 253 double dataRange[2]; 254 _dataSet->getDataRange(dataRange); 255 _lut->SetRange(dataRange); 303 _pdMapper->ScalarVisibilityOn(); 304 _lut->SetRange(_dataRange); 256 305 } 257 306 break; … … 260 309 _pdMapper->ScalarVisibilityOff(); 261 310 } 262 _pdMapper->Update(); 263 } 311 } 264 312 } 265 313 … … 271 319 _scaleFactor = scale; 272 320 if (_glyphGenerator != NULL) { 273 _glyphGenerator->SetScaleFactor(scale); 274 _pdMapper->Update(); 275 } 276 } 277 278 /** 279 * \brief Get the VTK colormap lookup table in use 280 */ 281 vtkLookupTable *Glyphs::getLookupTable() 282 { 283 return _lut; 321 _glyphGenerator->SetScaleFactor(_scaleFactor * _dataScale); 322 } 323 } 324 325 void Glyphs::updateRanges(bool useCumulative, 326 double scalarRange[2], 327 double vectorMagnitudeRange[2], 328 double vectorComponentRange[3][2]) 329 { 330 if (useCumulative) { 331 _dataRange[0] = scalarRange[0]; 332 _dataRange[1] = scalarRange[1]; 333 _vectorMagnitudeRange[0] = vectorMagnitudeRange[0]; 334 _vectorMagnitudeRange[1] = vectorMagnitudeRange[1]; 335 for (int i = 0; i < 3; i++) { 336 _vectorComponentRange[i][0] = vectorComponentRange[i][0]; 337 _vectorComponentRange[i][1] = vectorComponentRange[i][1]; 338 } 339 } else { 340 _dataSet->getScalarRange(_dataRange); 341 _dataSet->getVectorRange(_vectorMagnitudeRange); 342 for (int i = 0; i < 3; i++) { 343 _dataSet->getVectorRange(_vectorComponentRange[i], i); 344 } 345 } 346 347 // Need to update color map ranges and/or active vector field 348 setColorMode(_colorMode); 349 setScalingMode(_scalingMode); 350 } 351 352 /** 353 * \brief Called when the color map has been edited 354 */ 355 void Glyphs::updateColorMap() 356 { 357 setColorMap(_colorMap); 284 358 } 285 359 … … 287 361 * \brief Associate a colormap lookup table with the DataSet 288 362 */ 289 void Glyphs::setLookupTable(vtkLookupTable *lut) 290 { 291 if (lut == NULL) { 363 void Glyphs::setColorMap(ColorMap *cmap) 364 { 365 if (cmap == NULL) 366 return; 367 368 _colorMap = cmap; 369 370 if (_lut == NULL) { 292 371 _lut = vtkSmartPointer<vtkLookupTable>::New(); 293 } else { 294 _lut = lut; 295 } 372 if (_pdMapper != NULL) { 373 _pdMapper->UseLookupTableScalarRangeOn(); 374 _pdMapper->SetLookupTable(_lut); 375 } 376 } 377 378 _lut->DeepCopy(cmap->getLookupTable()); 296 379 297 380 switch (_colorMode) { 298 case COLOR_BY_ VECTOR: {381 case COLOR_BY_SCALE: { 299 382 double dataRange[2]; 300 _dataSet->getVectorMagnitudeRange(dataRange); 383 dataRange[0] = 0; 384 dataRange[1] = 1; 301 385 _lut->SetRange(dataRange); 302 386 } 303 387 break; 388 case COLOR_BY_VECTOR_MAGNITUDE: 389 _lut->SetRange(_vectorMagnitudeRange); 390 break; 304 391 case COLOR_BY_SCALAR: 305 default: { 306 double dataRange[2]; 307 _dataSet->getDataRange(dataRange); 308 _lut->SetRange(dataRange); 309 } 310 break; 311 } 312 313 if (_pdMapper != NULL) { 314 _pdMapper->SetLookupTable(_lut); 392 default: 393 _lut->SetRange(_dataRange); 394 break; 315 395 } 316 396 } -
trunk/packages/vizservers/vtkvis/RpGlyphs.h
r2393 r2402 39 39 DODECAHEDRON, 40 40 ICOSAHEDRON, 41 LINE, 41 42 OCTAHEDRON, 42 43 SPHERE, … … 45 46 enum ScalingMode { 46 47 SCALE_BY_SCALAR, 47 SCALE_BY_VECTOR ,48 SCALE_BY_VECTOR_MAGNITUDE, 48 49 SCALE_BY_VECTOR_COMPONENTS, 49 50 SCALING_OFF … … 52 53 COLOR_BY_SCALE, 53 54 COLOR_BY_SCALAR, 54 COLOR_BY_VECTOR ,55 COLOR_BY_VECTOR_MAGNITUDE, 55 56 COLOR_CONSTANT 56 57 }; 57 58 58 Glyphs( );59 Glyphs(GlyphShape shape); 59 60 virtual ~Glyphs(); 60 61 … … 63 64 return "Glyphs"; 64 65 } 66 67 virtual void setDataSet(DataSet *dataSet, 68 bool useCumulative, 69 double scalarRange[2], 70 double vectorMagnitudeRange[2], 71 double vectorComponentRange[3][2]); 65 72 66 73 virtual void setClippingPlanes(vtkPlaneCollection *planes); … … 74 81 void setScaleFactor(double scale); 75 82 76 void set LookupTable(vtkLookupTable *lut);83 void setColorMap(ColorMap *colorMap); 77 84 78 vtkLookupTable *getLookupTable(); 85 /** 86 * \brief Return the ColorMap in use 87 */ 88 ColorMap *getColorMap() 89 { 90 return _colorMap; 91 } 92 93 void updateColorMap(); 94 95 virtual void updateRanges(bool useCumulative, 96 double scalarRange[2], 97 double vectorMagnitudeRange[2], 98 double vectorComponentRange[3][2]); 79 99 80 100 private: 101 Glyphs(); 81 102 virtual void update(); 103 static inline double min2(double a, double b) 104 { 105 return ((a < b) ? a : b); 106 } 107 static inline double max2(double a, double b) 108 { 109 return ((a > b) ? a : b); 110 } 82 111 83 112 GlyphShape _glyphShape; 113 ScalingMode _scalingMode; 114 double _dataScale; 84 115 double _scaleFactor; 85 116 ColorMode _colorMode; 117 ColorMap *_colorMap; 118 double _vectorMagnitudeRange[2]; 119 double _vectorComponentRange[3][2]; 86 120 87 121 vtkSmartPointer<vtkLookupTable> _lut; -
trunk/packages/vizservers/vtkvis/RpHeightMap.cpp
r2328 r2402 35 35 #define MESH_POINT_CLOUDS 36 36 37 HeightMap::HeightMap( ) :37 HeightMap::HeightMap(int numContours) : 38 38 VtkGraphicsObject(), 39 _numContours(0), 39 _numContours(numContours), 40 _colorMap(NULL), 40 41 _contourEdgeWidth(1.0), 41 42 _warpScale(1.0), … … 43 44 _pipelineInitialized(false) 44 45 { 45 _dataRange[0] = 0.0; 46 _dataRange[1] = 1.0; 46 _contourEdgeColor[0] = 1.0f; 47 _contourEdgeColor[1] = 0.0f; 48 _contourEdgeColor[2] = 0.0f; 49 } 50 51 HeightMap::HeightMap(const std::vector<double>& contours) : 52 VtkGraphicsObject(), 53 _numContours(contours.size()), 54 _contours(contours), 55 _colorMap(NULL), 56 _contourEdgeWidth(1.0), 57 _warpScale(1.0), 58 _sliceAxis(Z_AXIS), 59 _pipelineInitialized(false) 60 { 47 61 _contourEdgeColor[0] = 1.0f; 48 62 _contourEdgeColor[1] = 0.0f; … … 60 74 } 61 75 62 /** 63 * \brief Specify input DataSet with scalars to colormap 64 * 65 * Currently the DataSet must be image data (2D uniform grid) 66 */ 67 void HeightMap::setDataSet(DataSet *dataSet) 76 void HeightMap::setDataSet(DataSet *dataSet, 77 bool useCumulative, 78 double scalarRange[2], 79 double vectorMagnitudeRange[2], 80 double vectorComponentRange[3][2]) 68 81 { 69 82 if (_dataSet != dataSet) { … … 71 84 72 85 if (_dataSet != NULL) { 73 double dataRange[2]; 74 _dataSet->getDataRange(dataRange); 75 _dataRange[0] = dataRange[0]; 76 _dataRange[1] = dataRange[1]; 86 if (useCumulative) { 87 _dataRange[0] = scalarRange[0]; 88 _dataRange[1] = scalarRange[1]; 89 } else { 90 dataSet->getScalarRange(_dataRange); 91 } 77 92 78 93 // Compute a data scaling factor to make maximum … … 331 346 _pipelineInitialized = true; 332 347 333 if (ds->GetPointData() == NULL || 334 ds->GetPointData()->GetScalars() == NULL) { 335 ERROR("No scalar point data in dataset %s", _dataSet->getName().c_str()); 336 if (_lut == NULL) { 337 _lut = vtkSmartPointer<vtkLookupTable>::New(); 338 } 339 } else { 340 vtkLookupTable *lut = ds->GetPointData()->GetScalars()->GetLookupTable(); 341 TRACE("Data set scalars lookup table: %p\n", lut); 342 if (_lut == NULL) { 343 if (lut) 344 _lut = lut; 345 else { 346 _lut = vtkSmartPointer<vtkLookupTable>::New(); 347 } 348 } 349 } 350 351 _lut->SetRange(_dataRange); 348 if (_lut == NULL) { 349 setColorMap(ColorMap::getDefault()); 350 } 351 //_dsMapper->InterpolateScalarsBeforeMappingOn(); 352 352 353 353 initProp(); 354 355 _dsMapper->SetColorModeToMapScalars();356 _dsMapper->UseLookupTableScalarRangeOn();357 _dsMapper->SetLookupTable(_lut);358 //_dsMapper->InterpolateScalarsBeforeMappingOn();359 354 360 355 _contourFilter->ComputeNormalsOff(); … … 615 610 616 611 /** 617 * \brief Get the VTK colormap lookup table in use618 */ 619 v tkLookupTable *HeightMap::getLookupTable()620 { 621 return _lut;612 * \brief Called when the color map has been edited 613 */ 614 void HeightMap::updateColorMap() 615 { 616 setColorMap(_colorMap); 622 617 } 623 618 … … 625 620 * \brief Associate a colormap lookup table with the DataSet 626 621 */ 627 void HeightMap::setLookupTable(vtkLookupTable *lut) 628 { 629 if (lut == NULL) { 622 void HeightMap::setColorMap(ColorMap *cmap) 623 { 624 if (cmap == NULL) 625 return; 626 627 _colorMap = cmap; 628 629 if (_lut == NULL) { 630 630 _lut = vtkSmartPointer<vtkLookupTable>::New(); 631 } else { 632 _lut = lut; 633 } 634 635 if (_dsMapper != NULL) { 636 _dsMapper->UseLookupTableScalarRangeOn(); 637 _dsMapper->SetLookupTable(_lut); 631 if (_dsMapper != NULL) { 632 _dsMapper->UseLookupTableScalarRangeOn(); 633 _dsMapper->SetLookupTable(_lut); 634 } 635 } 636 637 _lut->DeepCopy(cmap->getLookupTable()); 638 _lut->SetRange(_dataRange); 639 } 640 641 void HeightMap::updateRanges(bool useCumulative, 642 double scalarRange[2], 643 double vectorMagnitudeRange[2], 644 double vectorComponentRange[3][2]) 645 { 646 if (useCumulative) { 647 _dataRange[0] = scalarRange[0]; 648 _dataRange[1] = scalarRange[1]; 649 } else if (_dataSet != NULL) { 650 _dataSet->getScalarRange(_dataRange); 651 } 652 653 if (_lut != NULL) { 654 _lut->SetRange(_dataRange); 655 } 656 657 if (_contours.empty() && _numContours > 0) { 658 // Need to recompute isovalues 659 update(); 638 660 } 639 661 } … … 644 666 * Will override any existing contours 645 667 */ 646 void 668 void HeightMap::setContours(int numContours) 647 669 { 648 670 _contours.clear(); 649 671 _numContours = numContours; 650 651 if (_dataSet != NULL) {652 double dataRange[2];653 _dataSet->getDataRange(dataRange);654 _dataRange[0] = dataRange[0];655 _dataRange[1] = dataRange[1];656 }657 658 update();659 }660 661 /**662 * \brief Specify number of evenly spaced contour lines to render663 * between the given range (including range endpoints)664 *665 * Will override any existing contours666 */667 void HeightMap::setContours(int numContours, double range[2])668 {669 _contours.clear();670 _numContours = numContours;671 672 _dataRange[0] = range[0];673 _dataRange[1] = range[1];674 672 675 673 update(); … … 681 679 * Will override any existing contours 682 680 */ 683 void 681 void HeightMap::setContourList(const std::vector<double>& contours) 684 682 { 685 683 _contours = contours; … … 692 690 * \brief Get the number of contours 693 691 */ 694 int 692 int HeightMap::getNumContours() const 695 693 { 696 694 return _numContours; … … 701 699 * was specified in place of a list) 702 700 */ 703 const std::vector<double>& 701 const std::vector<double>& HeightMap::getContourList() const 704 702 { 705 703 return _contours; -
trunk/packages/vizservers/vtkvis/RpHeightMap.h
r2328 r2402 25 25 #include <vector> 26 26 27 #include "ColorMap.h" 27 28 #include "RpVtkGraphicsObject.h" 28 29 … … 41 42 }; 42 43 43 HeightMap(); 44 HeightMap(int numContours); 45 46 HeightMap(const std::vector<double>& contours); 47 44 48 virtual ~HeightMap(); 45 49 … … 49 53 } 50 54 51 virtual void setDataSet(DataSet *dataset); 55 virtual void setDataSet(DataSet *dataset, 56 bool useCumulative, 57 double scalarRange[2], 58 double vectorMagnitudeRange[2], 59 double vectorComponentRange[3][2]); 52 60 53 61 virtual void setLighting(bool state); … … 75 83 const std::vector<double>& getContourList() const; 76 84 77 void set LookupTable(vtkLookupTable *lut);85 void setColorMap(ColorMap *colorMap); 78 86 79 vtkLookupTable *getLookupTable(); 87 /** 88 * \brief Return the ColorMap in use 89 */ 90 ColorMap *getColorMap() 91 { 92 return _colorMap; 93 } 94 95 void updateColorMap(); 96 97 virtual void updateRanges(bool useCumulative, 98 double scalarRange[2], 99 double vectorMagnitudeRange[2], 100 double vectorComponentRange[3][2]); 80 101 81 102 void setContourVisibility(bool state); … … 86 107 87 108 private: 109 HeightMap(); 110 88 111 virtual void initProp(); 89 112 virtual void update(); … … 94 117 int _numContours; 95 118 std::vector<double> _contours; 96 double _dataRange[2];119 ColorMap *_colorMap; 97 120 98 float _edgeColor[3];99 121 float _contourEdgeColor[3]; 100 float _edgeWidth;101 122 float _contourEdgeWidth; 102 123 double _warpScale; -
trunk/packages/vizservers/vtkvis/RpLIC.cpp
r2328 r2402 27 27 LIC::LIC() : 28 28 VtkGraphicsObject(), 29 _sliceAxis(Z_AXIS) 29 _sliceAxis(Z_AXIS), 30 _colorMap(NULL) 30 31 { 31 32 } … … 56 57 57 58 vtkDataSet *ds = _dataSet->getVtkDataSet(); 58 59 double dataRange[2];60 _dataSet->getDataRange(dataRange);61 62 TRACE("DataSet type: %s, range: %g - %g", _dataSet->getVtkType(),63 dataRange[0], dataRange[1]);64 59 65 60 vtkSmartPointer<vtkCellDataToPointData> cellToPtData; … … 189 184 } 190 185 186 if (_lut == NULL) { 187 setColorMap(ColorMap::getDefault()); 188 } 189 191 190 initProp(); 192 191 getActor()->SetMapper(_mapper); … … 311 310 312 311 /** 313 * \brief Get the VTK colormap lookup table in use314 */ 315 v tkLookupTable *LIC::getLookupTable()316 { 317 return _lut;312 * \brief Called when the color map has been edited 313 */ 314 void LIC::updateColorMap() 315 { 316 setColorMap(_colorMap); 318 317 } 319 318 … … 321 320 * \brief Associate a colormap lookup table with the DataSet 322 321 */ 323 void LIC::setLookupTable(vtkLookupTable *lut) 324 { 325 if (lut == NULL) { 322 void LIC::setColorMap(ColorMap *cmap) 323 { 324 if (cmap == NULL) 325 return; 326 327 _colorMap = cmap; 328 329 if (_lut == NULL) { 326 330 _lut = vtkSmartPointer<vtkLookupTable>::New(); 327 } else { 328 _lut = lut; 329 } 330 331 if (_mapper != NULL) { 332 _mapper->SetLookupTable(_lut); 331 if (_mapper != NULL) { 332 _mapper->UseLookupTableScalarRangeOn(); 333 _mapper->SetLookupTable(_lut); 334 } 335 } 336 337 _lut->DeepCopy(cmap->getLookupTable()); 338 _lut->SetRange(_dataRange); 339 } 340 341 void LIC::updateRanges(bool useCumulative, 342 double scalarRange[2], 343 double vectorMagnitudeRange[2], 344 double vectorComponentRange[3][2]) 345 { 346 if (useCumulative) { 347 _dataRange[0] = scalarRange[0]; 348 _dataRange[1] = scalarRange[1]; 349 } else if (_dataSet != NULL) { 350 _dataSet->getScalarRange(_dataRange); 351 } 352 353 if (_lut != NULL) { 354 _lut->SetRange(_dataRange); 333 355 } 334 356 } -
trunk/packages/vizservers/vtkvis/RpLIC.h
r2328 r2402 19 19 #include <vtkLookupTable.h> 20 20 21 #include "ColorMap.h" 21 22 #include "RpVtkGraphicsObject.h" 22 23 … … 49 50 void selectVolumeSlice(Axis axis, double ratio); 50 51 51 void set LookupTable(vtkLookupTable *lut);52 void setColorMap(ColorMap *colorMap); 52 53 53 vtkLookupTable *getLookupTable(); 54 /** 55 * \brief Return the ColorMap in use 56 */ 57 ColorMap *getColorMap() 58 { 59 return _colorMap; 60 } 61 62 void updateColorMap(); 63 64 virtual void updateRanges(bool useCumulative, 65 double scalarRange[2], 66 double vectorMagnitudeRange[2], 67 double vectorComponentRange[3][2]); 54 68 55 69 private: … … 58 72 59 73 Axis _sliceAxis; 74 ColorMap *_colorMap; 60 75 61 76 vtkSmartPointer<vtkLookupTable> _lut; -
trunk/packages/vizservers/vtkvis/RpMolecule.cpp
r2393 r2402 27 27 Molecule::Molecule() : 28 28 VtkGraphicsObject(), 29 _atomScaling(NO_ATOM_SCALING) 29 _atomScaling(NO_ATOM_SCALING), 30 _colorMap(NULL) 30 31 { 31 32 _faceCulling = true; … … 86 87 vtkDataSet *ds = _dataSet->getVtkDataSet(); 87 88 88 double dataRange[2];89 _dataSet->getDataRange(dataRange);90 91 if (ds->GetPointData() == NULL ||92 ds->GetPointData()->GetScalars() == NULL) {93 WARN("No scalar point data in dataset %s", _dataSet->getName().c_str());94 if (_lut == NULL) {95 _lut = vtkSmartPointer<vtkLookupTable>::New();96 _lut->DeepCopy(ColorMap::getDefault()->getLookupTable());97 _lut->SetRange(dataRange);98 }99 } else {100 vtkLookupTable *lut = ds->GetPointData()->GetScalars()->GetLookupTable();101 TRACE("Data set scalars lookup table: %p\n", lut);102 if (_lut == NULL) {103 if (lut) {104 _lut = lut;105 if (strcmp(ds->GetPointData()->GetScalars()->GetName(), "element") == 0) {106 double range[2];107 range[0] = 0;108 range[1] = NUM_ELEMENTS+1;109 _lut->SetRange(range);110 } else {111 _lut->SetRange(dataRange);112 }113 } else {114 if (strcmp(ds->GetPointData()->GetScalars()->GetName(), "element") == 0) {115 _lut = ColorMap::getElementDefault()->getLookupTable();116 } else {117 _lut = vtkSmartPointer<vtkLookupTable>::New();118 _lut->DeepCopy(ColorMap::getDefault()->getLookupTable());119 _lut->SetRange(dataRange);120 }121 }122 }123 }124 125 89 if (_atomMapper == NULL) { 126 90 _atomMapper = vtkSmartPointer<vtkPolyDataMapper>::New(); 127 91 _atomMapper->SetResolveCoincidentTopologyToPolygonOffset(); 128 92 _atomMapper->ScalarVisibilityOn(); 129 _atomMapper->SetColorModeToMapScalars();130 _atomMapper->UseLookupTableScalarRangeOn();131 _atomMapper->SetLookupTable(_lut);132 93 } 133 94 if (_bondMapper == NULL) { … … 135 96 _bondMapper->SetResolveCoincidentTopologyToPolygonOffset(); 136 97 _bondMapper->ScalarVisibilityOn(); 137 _bondMapper->SetColorModeToMapScalars(); 138 _bondMapper->UseLookupTableScalarRangeOn(); 139 _bondMapper->SetLookupTable(_lut); 98 } 99 100 if (_lut == NULL) { 101 if (ds->GetPointData() == NULL || 102 ds->GetPointData()->GetScalars() == NULL || 103 strcmp(ds->GetPointData()->GetScalars()->GetName(), "element") != 0) { 104 WARN("No element array in dataset %s", _dataSet->getName().c_str()); 105 setColorMap(ColorMap::getDefault()); 106 } else { 107 TRACE("Using element default colormap"); 108 setColorMap(ColorMap::getElementDefault()); 109 } 140 110 } 141 111 … … 197 167 } 198 168 199 /** 200 * \brief Get the VTK colormap lookup table in use 201 */ 202 vtkLookupTable *Molecule::getLookupTable() 203 { 204 return _lut; 169 void Molecule::updateRanges(bool useCumulative, 170 double scalarRange[2], 171 double vectorMagnitudeRange[2], 172 double vectorComponentRange[3][2]) 173 { 174 if (useCumulative) { 175 _dataRange[0] = scalarRange[0]; 176 _dataRange[1] = scalarRange[1]; 177 } else if (_dataSet != NULL) { 178 _dataSet->getScalarRange(_dataRange); 179 } 180 181 if (_lut != NULL) { 182 vtkDataSet *ds = _dataSet->getVtkDataSet(); 183 if (ds == NULL) 184 return; 185 if (ds->GetPointData() == NULL || 186 ds->GetPointData()->GetScalars() == NULL || 187 strcmp(ds->GetPointData()->GetScalars()->GetName(), "element") != 0) { 188 _lut->SetRange(_dataRange); 189 } 190 } 191 } 192 193 /** 194 * \brief Called when the color map has been edited 195 */ 196 void Molecule::updateColorMap() 197 { 198 setColorMap(_colorMap); 205 199 } 206 200 … … 208 202 * \brief Associate a colormap lookup table with the DataSet 209 203 */ 210 void Molecule::setLookupTable(vtkLookupTable *lut) 211 { 212 if (lut == NULL) { 204 void Molecule::setColorMap(ColorMap *cmap) 205 { 206 if (cmap == NULL) 207 return; 208 209 _colorMap = cmap; 210 211 if (_lut == NULL) { 213 212 _lut = vtkSmartPointer<vtkLookupTable>::New(); 214 } else { 215 _lut = lut; 216 } 217 218 if (_atomMapper != NULL) { 219 _atomMapper->UseLookupTableScalarRangeOn(); 220 _atomMapper->SetLookupTable(_lut); 221 } 222 if (_bondMapper != NULL) { 223 _bondMapper->UseLookupTableScalarRangeOn(); 224 _bondMapper->SetLookupTable(_lut); 213 if (_atomMapper != NULL) { 214 _atomMapper->UseLookupTableScalarRangeOn(); 215 _atomMapper->SetLookupTable(_lut); 216 } 217 if (_bondMapper != NULL) { 218 _bondMapper->UseLookupTableScalarRangeOn(); 219 _bondMapper->SetLookupTable(_lut); 220 } 221 } 222 223 _lut->DeepCopy(cmap->getLookupTable()); 224 _lut->Modified(); 225 226 // Element color maps need to retain their range 227 // Only set LUT range if we are not coloring by element 228 vtkDataSet *ds = _dataSet->getVtkDataSet(); 229 if (ds == NULL) 230 return; 231 if (ds->GetPointData() == NULL || 232 ds->GetPointData()->GetScalars() == NULL || 233 strcmp(ds->GetPointData()->GetScalars()->GetName(), "element") != 0) { 234 _lut->SetRange(_dataRange); 225 235 } 226 236 } … … 284 294 } 285 295 296 /** 297 * \brief Add a scalar array to dataSet with sizes for the elements 298 * specified in the "element" scalar array 299 */ 286 300 void Molecule::addRadiusArray(vtkDataSet *dataSet, AtomScaling scaling) 287 301 { … … 323 337 } 324 338 339 /** 340 * \brief Create a color map to map atomic numbers to element colors 341 */ 325 342 ColorMap *Molecule::createElementColorMap() 326 343 { 327 ColorMap *element LUT= new ColorMap("elementDefault");344 ColorMap *elementCmap = new ColorMap("elementDefault"); 328 345 ColorMap::ControlPoint cp[NUM_ELEMENTS+1]; 329 346 330 element LUT->setNumberOfTableEntries(NUM_ELEMENTS+1);347 elementCmap->setNumberOfTableEntries(NUM_ELEMENTS+1); 331 348 for (int i = 0; i <= NUM_ELEMENTS; i++) { 332 349 cp[i].value = i/((double)(NUM_ELEMENTS+1)); … … 334 351 cp[i].color[c] = ((double)g_elementColors[i][c])/255.; 335 352 } 336 element LUT->addControlPoint(cp[i]);353 elementCmap->addControlPoint(cp[i]); 337 354 } 338 355 ColorMap::OpacityControlPoint ocp[2]; … … 341 358 ocp[1].value = 1.0; 342 359 ocp[1].alpha = 1.0; 343 element LUT->addOpacityControlPoint(ocp[0]);344 element LUT->addOpacityControlPoint(ocp[1]);345 element LUT->build();360 elementCmap->addOpacityControlPoint(ocp[0]); 361 elementCmap->addOpacityControlPoint(ocp[1]); 362 elementCmap->build(); 346 363 double range[2]; 347 364 range[0] = 0; 348 365 range[1] = NUM_ELEMENTS+1; 349 element LUT->getLookupTable()->SetRange(range);350 351 return element LUT;352 } 366 elementCmap->getLookupTable()->SetRange(range); 367 368 return elementCmap; 369 } -
trunk/packages/vizservers/vtkvis/RpMolecule.h
r2328 r2402 52 52 virtual void setClippingPlanes(vtkPlaneCollection *planes); 53 53 54 void set LookupTable(vtkLookupTable *lut);54 void setColorMap(ColorMap *colorMap); 55 55 56 vtkLookupTable *getLookupTable(); 56 /** 57 * \brief Return the ColorMap in use 58 */ 59 ColorMap *getColorMap() 60 { 61 return _colorMap; 62 } 63 64 void updateColorMap(); 65 66 virtual void updateRanges(bool useCumulative, 67 double scalarRange[2], 68 double vectorMagnitudeRange[2], 69 double vectorComponentRange[3][2]); 57 70 58 71 void setAtomScaling(AtomScaling state); … … 71 84 72 85 AtomScaling _atomScaling; 86 ColorMap *_colorMap; 73 87 74 88 vtkSmartPointer<vtkLookupTable> _lut; -
trunk/packages/vizservers/vtkvis/RpPolyData.cpp
r2393 r2402 109 109 // to get the grid boundary as a PolyData 110 110 vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New(); 111 gf->UseStripsOn(); 111 112 gf->SetInputConnection(mesher->GetOutputPort()); 112 113 gf->ReleaseDataFlagOn(); … … 121 122 TRACE("DataSet is not a PolyData"); 122 123 vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New(); 124 gf->UseStripsOn(); 123 125 gf->SetInput(ds); 124 126 gf->ReleaseDataFlagOn(); -
trunk/packages/vizservers/vtkvis/RpPseudoColor.cpp
r2328 r2402 29 29 30 30 PseudoColor::PseudoColor() : 31 VtkGraphicsObject() 31 VtkGraphicsObject(), 32 _colorMap(NULL) 32 33 { 33 34 } … … 70 71 71 72 vtkDataSet *ds = _dataSet->getVtkDataSet(); 72 73 double dataRange[2];74 _dataSet->getDataRange(dataRange);75 73 76 74 // Mapper, actor to render color-mapped data set … … 136 134 } 137 135 138 if (ds->GetPointData() == NULL || 139 ds->GetPointData()->GetScalars() == NULL) { 140 WARN("No scalar point data in dataset %s", _dataSet->getName().c_str()); 141 if (_lut == NULL) { 142 _lut = vtkSmartPointer<vtkLookupTable>::New(); 143 } 144 } else { 145 vtkLookupTable *lut = ds->GetPointData()->GetScalars()->GetLookupTable(); 146 TRACE("Data set scalars lookup table: %p\n", lut); 147 if (_lut == NULL) { 148 if (lut) 149 _lut = lut; 150 else 151 _lut = vtkSmartPointer<vtkLookupTable>::New(); 152 } 153 } 154 155 _lut->SetRange(dataRange); 156 157 _dsMapper->SetColorModeToMapScalars(); 158 _dsMapper->UseLookupTableScalarRangeOn(); 159 _dsMapper->SetLookupTable(_lut); 136 if (_lut == NULL) { 137 setColorMap(ColorMap::getDefault()); 138 } 160 139 //_dsMapper->InterpolateScalarsBeforeMappingOn(); 161 140 … … 165 144 } 166 145 167 /** 168 * \brief Get the VTK colormap lookup table in use 169 */ 170 vtkLookupTable *PseudoColor::getLookupTable() 171 { 172 return _lut; 146 void PseudoColor::updateRanges(bool useCumulative, 147 double scalarRange[2], 148 double vectorMagnitudeRange[2], 149 double vectorComponentRange[3][2]) 150 { 151 if (useCumulative) { 152 _dataRange[0] = scalarRange[0]; 153 _dataRange[1] = scalarRange[1]; 154 } else if (_dataSet != NULL) { 155 _dataSet->getScalarRange(_dataRange); 156 } 157 158 if (_lut != NULL) { 159 _lut->SetRange(_dataRange); 160 } 161 } 162 163 /** 164 * \brief Called when the color map has been edited 165 */ 166 void PseudoColor::updateColorMap() 167 { 168 setColorMap(_colorMap); 173 169 } 174 170 … … 176 172 * \brief Associate a colormap lookup table with the DataSet 177 173 */ 178 void PseudoColor::setLookupTable(vtkLookupTable *lut) 179 { 180 if (lut == NULL) { 174 void PseudoColor::setColorMap(ColorMap *cmap) 175 { 176 if (cmap == NULL) 177 return; 178 179 _colorMap = cmap; 180 181 if (_lut == NULL) { 181 182 _lut = vtkSmartPointer<vtkLookupTable>::New(); 182 } else{183 _lut = lut;184 }185 186 if (_dsMapper != NULL) {187 _dsMapper->UseLookupTableScalarRangeOn(); 188 _dsMapper->SetLookupTable(_lut);189 }183 if (_dsMapper != NULL) { 184 _dsMapper->UseLookupTableScalarRangeOn(); 185 _dsMapper->SetLookupTable(_lut); 186 } 187 } 188 189 _lut->DeepCopy(cmap->getLookupTable()); 190 _lut->SetRange(_dataRange); 190 191 } 191 192 -
trunk/packages/vizservers/vtkvis/RpPseudoColor.h
r2328 r2402 15 15 #include <vtkPlaneCollection.h> 16 16 17 #include "ColorMap.h" 17 18 #include "RpVtkGraphicsObject.h" 18 #include "RpVtkDataSet.h"19 19 20 20 namespace Rappture { … … 38 38 virtual void setClippingPlanes(vtkPlaneCollection *planes); 39 39 40 void set LookupTable(vtkLookupTable *lut);40 void setColorMap(ColorMap *colorMap); 41 41 42 vtkLookupTable *getLookupTable(); 42 /** 43 * \brief Return the ColorMap in use 44 */ 45 ColorMap *getColorMap() 46 { 47 return _colorMap; 48 } 49 50 void updateColorMap(); 51 52 virtual void updateRanges(bool useCumulative, 53 double scalarRange[2], 54 double vectorMagnitudeRange[2], 55 double vectorComponentRange[3][2]); 43 56 44 57 private: 45 58 virtual void initProp(); 46 59 virtual void update(); 60 61 ColorMap *_colorMap; 47 62 48 63 vtkSmartPointer<vtkLookupTable> _lut; -
trunk/packages/vizservers/vtkvis/RpStreamlines.cpp
r2393 r2402 36 36 _lineType(LINES), 37 37 _colorMode(COLOR_BY_VECTOR_MAGNITUDE), 38 _colorMap(NULL), 38 39 _seedVisible(true) 39 40 { … … 51 52 Streamlines::~Streamlines() 52 53 { 54 } 55 56 void Streamlines::setDataSet(DataSet *dataSet, 57 bool useCumulative, 58 double scalarRange[2], 59 double vectorMagnitudeRange[2], 60 double vectorComponentRange[3][2]) 61 { 62 if (_dataSet != dataSet) { 63 _dataSet = dataSet; 64 65 if (useCumulative) { 66 _dataRange[0] = scalarRange[0]; 67 _dataRange[1] = scalarRange[1]; 68 _vectorMagnitudeRange[0] = vectorMagnitudeRange[0]; 69 _vectorMagnitudeRange[1] = vectorMagnitudeRange[1]; 70 for (int i = 0; i < 3; i++) { 71 _vectorComponentRange[i][0] = vectorComponentRange[i][0]; 72 _vectorComponentRange[i][1] = vectorComponentRange[i][1]; 73 } 74 } else { 75 _dataSet->getScalarRange(_dataRange); 76 _dataSet->getVectorRange(_vectorMagnitudeRange); 77 for (int i = 0; i < 3; i++) { 78 _dataSet->getVectorRange(_vectorComponentRange[i], i); 79 } 80 } 81 82 update(); 83 } 53 84 } 54 85 … … 201 232 202 233 vtkDataSet *ds = _dataSet->getVtkDataSet(); 203 double dataRange[2]; 204 _dataSet->getVectorMagnitudeRange(dataRange); 234 205 235 double bounds[6]; 206 236 _dataSet->getBounds(bounds); … … 294 324 _seedActor->SetMapper(_seedMapper); 295 325 296 _lut = vtkSmartPointer<vtkLookupTable>::New(); 297 _lut->SetRange(dataRange); 298 _lut->SetVectorModeToMagnitude(); 299 300 _pdMapper->SetScalarModeToUsePointFieldData(); 301 if (ds->GetPointData() != NULL && 302 ds->GetPointData()->GetVectors() != NULL) { 303 TRACE("Vector name: '%s'", ds->GetPointData()->GetVectors()->GetName()); 304 _pdMapper->SelectColorArray(ds->GetPointData()->GetVectors()->GetName()); 305 } 306 _pdMapper->SetColorModeToMapScalars(); 307 _pdMapper->UseLookupTableScalarRangeOn(); 308 _pdMapper->SetLookupTable(_lut); 326 if (_lut == NULL) { 327 setColorMap(ColorMap::getDefault()); 328 } 329 330 setColorMode(_colorMode); 309 331 310 332 _linesActor->SetMapper(_pdMapper); … … 759 781 } 760 782 783 void Streamlines::updateRanges(bool useCumulative, 784 double scalarRange[2], 785 double vectorMagnitudeRange[2], 786 double vectorComponentRange[3][2]) 787 { 788 if (useCumulative) { 789 _dataRange[0] = scalarRange[0]; 790 _dataRange[1] = scalarRange[1]; 791 _vectorMagnitudeRange[0] = vectorMagnitudeRange[0]; 792 _vectorMagnitudeRange[1] = vectorMagnitudeRange[1]; 793 for (int i = 0; i < 3; i++) { 794 _vectorComponentRange[i][0] = vectorComponentRange[i][0]; 795 _vectorComponentRange[i][1] = vectorComponentRange[i][1]; 796 } 797 } else { 798 _dataSet->getScalarRange(_dataRange); 799 _dataSet->getVectorRange(_vectorMagnitudeRange); 800 for (int i = 0; i < 3; i++) { 801 _dataSet->getVectorRange(_vectorComponentRange[i], i); 802 } 803 } 804 805 // Need to update color map ranges and/or active vector field 806 setColorMode(_colorMode); 807 } 808 761 809 void Streamlines::setColorMode(ColorMode mode) 762 810 { … … 772 820 _pdMapper->SetScalarModeToDefault(); 773 821 if (_lut != NULL) { 774 double dataRange[2]; 775 _dataSet->getDataRange(dataRange); 776 _lut->SetRange(dataRange); 822 _lut->SetRange(_dataRange); 777 823 } 778 824 } … … 786 832 } 787 833 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); 834 _lut->SetRange(_vectorMagnitudeRange); 792 835 _lut->SetVectorModeToMagnitude(); 793 836 } … … 802 845 } 803 846 if (_lut != NULL) { 804 double dataRange[2]; 805 _dataSet->getVectorComponentRange(dataRange, 0); 806 _lut->SetRange(dataRange); 847 _lut->SetRange(_vectorComponentRange[0]); 807 848 _lut->SetVectorModeToComponent(); 808 849 _lut->SetVectorComponent(0); … … 817 858 } 818 859 if (_lut != NULL) { 819 double dataRange[2]; 820 _dataSet->getVectorComponentRange(dataRange, 1); 821 _lut->SetRange(dataRange); 860 _lut->SetRange(_vectorComponentRange[1]); 822 861 _lut->SetVectorModeToComponent(); 823 862 _lut->SetVectorComponent(1); … … 832 871 } 833 872 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); 873 _lut->SetRange(_vectorComponentRange[2]); 838 874 _lut->SetVectorModeToComponent(); 839 875 _lut->SetVectorComponent(2); … … 848 884 849 885 /** 850 * \brief Get the VTK colormap lookup table in use851 */ 852 v tkLookupTable *Streamlines::getLookupTable()853 { 854 return _lut;886 * \brief Called when the color map has been edited 887 */ 888 void Streamlines::updateColorMap() 889 { 890 setColorMap(_colorMap); 855 891 } 856 892 … … 858 894 * \brief Associate a colormap lookup table with the DataSet 859 895 */ 860 void Streamlines::setLookupTable(vtkLookupTable *lut) 861 { 862 if (lut == NULL) { 896 void Streamlines::setColorMap(ColorMap *cmap) 897 { 898 if (cmap == NULL) 899 return; 900 901 _colorMap = cmap; 902 903 if (_lut == NULL) { 863 904 _lut = vtkSmartPointer<vtkLookupTable>::New(); 864 } else { 865 _lut = lut; 866 } 905 if (_pdMapper != NULL) { 906 _pdMapper->UseLookupTableScalarRangeOn(); 907 _pdMapper->SetLookupTable(_lut); 908 } 909 } 910 911 _lut->DeepCopy(cmap->getLookupTable()); 867 912 868 913 switch (_colorMode) { 869 case COLOR_BY_VECTOR_MAGNITUDE: { 870 double dataRange[2]; 871 _dataSet->getVectorMagnitudeRange(dataRange); 914 case COLOR_CONSTANT: 915 case COLOR_BY_SCALAR: 916 _lut->SetRange(_dataRange); 917 break; 918 case COLOR_BY_VECTOR_MAGNITUDE: 872 919 _lut->SetVectorModeToMagnitude(); 873 _lut->SetRange(dataRange); 874 } 875 break; 876 case COLOR_BY_VECTOR_X: { 877 double dataRange[2]; 878 _dataSet->getVectorComponentRange(dataRange, 0); 920 _lut->SetRange(_vectorMagnitudeRange); 921 break; 922 case COLOR_BY_VECTOR_X: 879 923 _lut->SetVectorModeToComponent(); 880 924 _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); 925 _lut->SetRange(_vectorComponentRange[0]); 926 break; 927 case COLOR_BY_VECTOR_Y: 887 928 _lut->SetVectorModeToComponent(); 888 929 _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); 930 _lut->SetRange(_vectorComponentRange[1]); 931 break; 932 case COLOR_BY_VECTOR_Z: 895 933 _lut->SetVectorModeToComponent(); 896 934 _lut->SetVectorComponent(2); 897 _lut->SetRange(dataRange); 898 } 935 _lut->SetRange(_vectorComponentRange[2]); 899 936 break; 900 937 default: 901 938 break; 902 }903 904 if (_pdMapper != NULL) {905 _pdMapper->SetLookupTable(_lut);906 939 } 907 940 } -
trunk/packages/vizservers/vtkvis/RpStreamlines.h
r2393 r2402 18 18 #include <vtkAssembly.h> 19 19 20 #include "ColorMap.h" 20 21 #include "RpVtkGraphicsObject.h" 21 22 … … 51 52 return "Streamlines"; 52 53 } 54 55 virtual void setDataSet(DataSet *dataSet, 56 bool useCumulative, 57 double scalarRange[2], 58 double vectorMagnitudeRange[2], 59 double vectorComponentRange[3][2]); 53 60 54 61 virtual void setLighting(bool state); … … 95 102 void setColorMode(ColorMode mode); 96 103 97 void set LookupTable(vtkLookupTable *lut);104 void setColorMap(ColorMap *colorMap); 98 105 99 vtkLookupTable *getLookupTable(); 106 /** 107 * \brief Return the ColorMap in use 108 */ 109 ColorMap *getColorMap() 110 { 111 return _colorMap; 112 } 113 114 void updateColorMap(); 115 116 virtual void updateRanges(bool useCumulative, 117 double scalarRange[2], 118 double vectorMagnitudeRange[2], 119 double vectorComponentRange[3][2]); 100 120 101 121 void setSeedVisibility(bool state); … … 120 140 LineType _lineType; 121 141 ColorMode _colorMode; 122 float _color[3];142 ColorMap *_colorMap; 123 143 float _seedColor[3]; 124 144 bool _seedVisible; 145 double _vectorMagnitudeRange[2]; 146 double _vectorComponentRange[3][2]; 125 147 126 148 vtkSmartPointer<vtkLookupTable> _lut; -
trunk/packages/vizservers/vtkvis/RpVolume.cpp
r2328 r2402 63 63 vtkDataSet *ds = _dataSet->getVtkDataSet(); 64 64 65 double dataRange[2];66 _dataSet->getDataRange(dataRange);67 68 TRACE("DataSet type: %s, range: %g - %g", _dataSet->getVtkType(),69 dataRange[0], dataRange[1]);70 71 65 if (vtkImageData::SafeDownCast(ds) != NULL) { 72 66 // Image data required for these mappers … … 113 107 WARN("No scalar point data in dataset %s", _dataSet->getName().c_str()); 114 108 } 109 115 110 if (_colorMap == NULL) { 116 _colorMap = ColorMap::getVolumeDefault();111 setColorMap(ColorMap::getVolumeDefault()); 117 112 } 118 119 vtkVolumeProperty *volProperty = getVolume()->GetProperty();120 volProperty->SetColor(_colorMap->getColorTransferFunction(dataRange));121 volProperty->SetScalarOpacity(_colorMap->getOpacityTransferFunction(dataRange));122 113 123 114 getVolume()->SetMapper(_volumeMapper); 124 115 _volumeMapper->Update(); 116 } 117 118 void Volume::updateRanges(bool useCumulative, 119 double scalarRange[2], 120 double vectorMagnitudeRange[2], 121 double vectorComponentRange[3][2]) 122 { 123 if (useCumulative) { 124 _dataRange[0] = scalarRange[0]; 125 _dataRange[1] = scalarRange[1]; 126 } else if (_dataSet != NULL) { 127 _dataSet->getScalarRange(_dataRange); 128 } 129 130 if (getVolume() != NULL) { 131 getVolume()->GetProperty()->SetColor(_colorMap->getColorTransferFunction(_dataRange)); 132 getVolume()->GetProperty()->SetScalarOpacity(_colorMap->getOpacityTransferFunction(_dataRange)); 133 } 134 } 135 void Volume::updateColorMap() 136 { 137 setColorMap(_colorMap); 125 138 } 126 139 … … 131 144 { 132 145 _colorMap = cmap; 146 133 147 if (getVolume() != NULL) { 134 double dataRange[2]; 135 _dataSet->getDataRange(dataRange); 136 getVolume()->GetProperty()->SetColor(_colorMap->getColorTransferFunction(dataRange)); 137 getVolume()->GetProperty()->SetScalarOpacity(_colorMap->getOpacityTransferFunction(dataRange)); 138 } 139 } 140 141 /** 142 * \brief Assign a color map (transfer function) to use in rendering the Volume and 143 * specify a scalar range for the map 144 */ 145 void Volume::setColorMap(ColorMap *cmap, double dataRange[2]) 146 { 147 _colorMap = cmap; 148 if (getVolume() != NULL) { 149 getVolume()->GetProperty()->SetColor(_colorMap->getColorTransferFunction(dataRange)); 150 getVolume()->GetProperty()->SetScalarOpacity(_colorMap->getOpacityTransferFunction(dataRange)); 148 getVolume()->GetProperty()->SetColor(_colorMap->getColorTransferFunction(_dataRange)); 149 getVolume()->GetProperty()->SetScalarOpacity(_colorMap->getOpacityTransferFunction(_dataRange)); 151 150 } 152 151 } -
trunk/packages/vizservers/vtkvis/RpVolume.h
r2328 r2402 49 49 void setColorMap(ColorMap *cmap); 50 50 51 void setColorMap(ColorMap *cmap, double dataRange[2]);51 ColorMap *getColorMap(); 52 52 53 ColorMap *getColorMap(); 53 void updateColorMap(); 54 55 virtual void updateRanges(bool useCumulative, 56 double scalarRange[2], 57 double vectorMagnitudeRange[2], 58 double vectorComponentRange[3][2]); 54 59 55 60 private: -
trunk/packages/vizservers/vtkvis/RpVtkDataSet.cpp
r2393 r2402 7 7 8 8 #include <cstring> 9 #include <cfloat> 10 #include <cmath> 9 11 10 12 #include <vtkCharArray.h> … … 18 20 #include <vtkPointData.h> 19 21 #include <vtkCellData.h> 22 #include <vtkCell.h> 20 23 #include <vtkLookupTable.h> 21 24 … … 69 72 70 73 reader->SetFileName(filename); 74 reader->ReadAllNormalsOn(); 75 //reader->ReadAllTCoordsOn(); 71 76 reader->ReadAllScalarsOn(); 77 //reader->ReadAllColorScalarsOn(); 72 78 reader->ReadAllVectorsOn(); 79 //reader->ReadAllTensorsOn(); 73 80 reader->ReadAllFieldsOn(); 74 81 return setData(reader); … … 93 100 reader->SetInputArray(dataSetString); 94 101 reader->ReadFromInputStringOn(); 102 reader->ReadAllNormalsOn(); 103 //reader->ReadAllTCoordsOn(); 95 104 reader->ReadAllScalarsOn(); 105 //reader->ReadAllColorScalarsOn(); 96 106 reader->ReadAllVectorsOn(); 107 //reader->ReadAllTensorsOn(); 97 108 reader->ReadAllFieldsOn(); 98 109 … … 103 114 } 104 115 105 /** 106 * \brief Read dataset using supplied reader 107 * 108 * Pipeline information is removed from the resulting 109 * vtkDataSet, so that the reader and its data can be 110 * released 111 */ 112 bool DataSet::setData(vtkDataSetReader *reader) 113 { 114 // Force reading data set 115 reader->SetLookupTableName(""); 116 reader->Update(); 117 118 _dataSet = reader->GetOutput(); 119 _dataSet->SetPipelineInformation(NULL); 120 116 void DataSet::print() const 117 { 121 118 TRACE("DataSet class: %s", _dataSet->GetClassName()); 122 #ifdef WANT_TRACE 123 double dataRange[2]; 124 getDataRange(dataRange); 119 125 120 double bounds[6]; 126 121 getBounds(bounds); 127 #endif 128 TRACE("Scalar Range: %.12e, %.12e", dataRange[0], dataRange[1]);122 123 // Topology 129 124 TRACE("DataSet bounds: %g %g %g %g %g %g", 130 125 bounds[0], bounds[1], … … 132 127 bounds[4], bounds[5]); 133 128 TRACE("Points: %d Cells: %d", _dataSet->GetNumberOfPoints(), _dataSet->GetNumberOfCells()); 129 130 double dataRange[2]; 131 if (_dataSet->GetPointData() != NULL) { 132 TRACE("PointData arrays: %d", _dataSet->GetPointData()->GetNumberOfArrays()); 133 for (int i = 0; i < _dataSet->GetPointData()->GetNumberOfArrays(); i++) { 134 _dataSet->GetPointData()->GetArray(i)->GetRange(dataRange, -1); 135 TRACE("PointData[%d]: '%s' comp:%d, (%g,%g)", i, 136 _dataSet->GetPointData()->GetArrayName(i), 137 _dataSet->GetPointData()->GetArray(i)->GetNumberOfComponents(), 138 dataRange[0], dataRange[1]); 139 } 140 } 141 if (_dataSet->GetCellData() != NULL) { 142 TRACE("CellData arrays: %d", _dataSet->GetCellData()->GetNumberOfArrays()); 143 for (int i = 0; i < _dataSet->GetCellData()->GetNumberOfArrays(); i++) { 144 _dataSet->GetCellData()->GetArray(i)->GetRange(dataRange, -1); 145 TRACE("CellData[%d]: '%s' comp:%d, (%g,%g)", i, 146 _dataSet->GetCellData()->GetArrayName(i), 147 _dataSet->GetCellData()->GetArray(i)->GetNumberOfComponents(), 148 dataRange[0], dataRange[1]); 149 } 150 } 151 if (_dataSet->GetFieldData() != NULL) { 152 TRACE("FieldData arrays: %d", _dataSet->GetFieldData()->GetNumberOfArrays()); 153 for (int i = 0; i < _dataSet->GetFieldData()->GetNumberOfArrays(); i++) { 154 _dataSet->GetFieldData()->GetArray(i)->GetRange(dataRange, -1); 155 TRACE("FieldData[%d]: '%s' comp:%d, tuples:%d (%g,%g)", i, 156 _dataSet->GetFieldData()->GetArrayName(i), 157 _dataSet->GetFieldData()->GetArray(i)->GetNumberOfComponents(), 158 _dataSet->GetFieldData()->GetArray(i)->GetNumberOfTuples(), 159 dataRange[0], dataRange[1]); 160 } 161 } 162 } 163 164 /** 165 * \brief Read dataset using supplied reader 166 * 167 * Pipeline information is removed from the resulting 168 * vtkDataSet, so that the reader and its data can be 169 * released 170 */ 171 bool DataSet::setData(vtkDataSetReader *reader) 172 { 173 // Force reading data set 174 reader->SetLookupTableName(""); 175 reader->Update(); 176 177 _dataSet = reader->GetOutput(); 178 _dataSet->SetPipelineInformation(NULL); 179 180 if (_dataSet->GetPointData() != NULL && 181 _dataSet->GetPointData()->GetScalars() != NULL && 182 _dataSet->GetPointData()->GetScalars()->GetLookupTable() != NULL) { 183 ERROR("No lookup table should be specified in DataSets"); 184 } 185 186 #ifdef WANT_TRACE 187 print(); 188 #endif 134 189 return true; 135 190 } … … 145 200 _dataSet->SetPipelineInformation(NULL); 146 201 147 TRACE("DataSet class: %s", _dataSet->GetClassName()); 202 if (_dataSet->GetPointData() != NULL && 203 _dataSet->GetPointData()->GetScalars() != NULL && 204 _dataSet->GetPointData()->GetScalars()->GetLookupTable() != NULL) { 205 ERROR("No lookup table should be specified in DataSets"); 206 } 207 148 208 #ifdef WANT_TRACE 149 double dataRange[2]; 150 getDataRange(dataRange); 151 double bounds[6]; 152 getBounds(bounds); 209 print(); 153 210 #endif 154 TRACE("Scalar Range: %.12e, %.12e", dataRange[0], dataRange[1]);155 TRACE("DataSet bounds: %g %g %g %g %g %g",156 bounds[0], bounds[1],157 bounds[2], bounds[3],158 bounds[4], bounds[5]);159 TRACE("Points: %d Cells: %d", _dataSet->GetNumberOfPoints(), _dataSet->GetNumberOfCells());160 211 return true; 161 212 } … … 190 241 } 191 242 192 TRACE("DataSet class: %s", _dataSet->GetClassName());193 243 #ifdef WANT_TRACE 194 double dataRange[2]; 195 getDataRange(dataRange); 196 double bounds[6]; 197 getBounds(bounds); 244 print(); 198 245 #endif 199 TRACE("Scalar Range: %.12e, %.12e", dataRange[0], dataRange[1]);200 TRACE("DataSet bounds: %g %g %g %g %g %g",201 bounds[0], bounds[1],202 bounds[2], bounds[3],203 bounds[4], bounds[5]);204 246 return _dataSet; 205 247 } … … 280 322 * \brief Get the range of scalar values in the DataSet 281 323 */ 324 void DataSet::getScalarRange(double minmax[2]) const 325 { 326 _dataSet->GetScalarRange(minmax); 327 } 328 329 #if 0 330 /** 331 * \brief Get the range of scalar values in the DataSet 332 */ 282 333 void DataSet::getDataRange(double minmax[2]) const 283 334 { 284 335 _dataSet->GetScalarRange(minmax); 285 336 } 286 287 /** 288 * \brief Get the range of scalar values (or vector magnitudes) for 289 * the named field in the DataSet 290 */ 291 void DataSet::getDataRange(double minmax[2], const char *fieldName) const 292 { 293 if (_dataSet == NULL) 294 return; 295 if (_dataSet->GetPointData() != NULL && 296 _dataSet->GetPointData()->GetArray(fieldName) != NULL) { 297 _dataSet->GetPointData()->GetArray(fieldName)->GetRange(minmax, -1); 298 } else if (_dataSet->GetCellData() != NULL && 299 _dataSet->GetCellData()->GetArray(fieldName) != NULL) { 300 _dataSet->GetCellData()->GetArray(fieldName)->GetRange(minmax, -1); 301 } else if (_dataSet->GetFieldData() != NULL && 302 _dataSet->GetFieldData()->GetArray(fieldName) != NULL) { 303 _dataSet->GetFieldData()->GetArray(fieldName)->GetRange(minmax, -1); 304 } 305 } 306 307 /** 308 * \brief Get the range of vector magnitudes in the DataSet 309 */ 310 void DataSet::getVectorMagnitudeRange(double minmax[2]) const 311 { 312 if (_dataSet == NULL) 313 return; 314 if (_dataSet->GetPointData() != NULL && 315 _dataSet->GetPointData()->GetVectors() != NULL) { 316 _dataSet->GetPointData()->GetVectors()->GetRange(minmax, -1); 317 } else if (_dataSet->GetCellData() != NULL && 318 _dataSet->GetCellData()->GetVectors() != NULL) { 319 _dataSet->GetCellData()->GetVectors()->GetRange(minmax, -1); 320 } 321 } 337 #endif 322 338 323 339 /** 324 340 * \brief Get the range of a vector component in the DataSet 325 */ 326 void DataSet::getVectorComponentRange(double minmax[2], int component) const 341 * 342 * \param[out] minmax The data range 343 * \param[in] component The field component, -1 means magnitude 344 */ 345 void DataSet::getVectorRange(double minmax[2], int component) const 327 346 { 328 347 if (_dataSet == NULL) … … 338 357 339 358 /** 359 * \brief Get the range of values for the named field in the DataSet 360 * 361 * \param[out] minmax The data range 362 * \param[in] fieldName The array name 363 * \param[in] component The field component, -1 means magnitude 364 */ 365 void DataSet::getDataRange(double minmax[2], const char *fieldName, int component) const 366 { 367 if (_dataSet == NULL) 368 return; 369 if (_dataSet->GetPointData() != NULL && 370 _dataSet->GetPointData()->GetArray(fieldName) != NULL) { 371 _dataSet->GetPointData()->GetArray(fieldName)->GetRange(minmax, component); 372 } else if (_dataSet->GetCellData() != NULL && 373 _dataSet->GetCellData()->GetArray(fieldName) != NULL) { 374 _dataSet->GetCellData()->GetArray(fieldName)->GetRange(minmax, component); 375 } else if (_dataSet->GetFieldData() != NULL && 376 _dataSet->GetFieldData()->GetArray(fieldName) != NULL) { 377 _dataSet->GetFieldData()->GetArray(fieldName)->GetRange(minmax, component); 378 } 379 } 380 381 /** 340 382 * \brief Get the bounds the DataSet 341 383 */ … … 343 385 { 344 386 _dataSet->GetBounds(bounds); 387 } 388 389 /** 390 * \brief Get the range of cell AABB diagonal lengths the DataSet 391 */ 392 void DataSet::getCellSizeRange(double minmax[6], double *average) const 393 { 394 if (_dataSet == NULL || 395 _dataSet->GetNumberOfCells() < 1) { 396 minmax[0] = 1; 397 minmax[1] = 1; 398 *average = 1; 399 return; 400 } 401 402 minmax[0] = DBL_MAX; 403 minmax[1] = -DBL_MAX; 404 405 *average = 0; 406 for (int i = 0; i < _dataSet->GetNumberOfCells(); i++) { 407 double length2 = _dataSet->GetCell(i)->GetLength2(); 408 if (length2 < minmax[0]) 409 minmax[0] = length2; 410 if (length2 > minmax[1]) 411 minmax[1] = length2; 412 *average += length2; 413 } 414 if (minmax[0] == DBL_MAX) 415 minmax[0] = 1; 416 if (minmax[1] == -DBL_MAX) 417 minmax[1] = 1; 418 419 minmax[0] = sqrt(minmax[0]); 420 minmax[1] = sqrt(minmax[1]); 421 *average = sqrt(*average/((double)_dataSet->GetNumberOfCells())); 345 422 } 346 423 -
trunk/packages/vizservers/vtkvis/RpVtkDataSet.h
r2393 r2402 49 49 bool setActiveVectors(const char *name); 50 50 51 void get DataRange(double minmax[2]) const;51 void getScalarRange(double minmax[2]) const; 52 52 53 void getDataRange(double minmax[2], const char *fieldName) const;53 //void getDataRange(double minmax[2]) const; 54 54 55 void get VectorMagnitudeRange(double minmax[2]) const;55 void getDataRange(double minmax[2], const char *fieldName, int component = -1) const; 56 56 57 void getVector ComponentRange(double minmax[2], int component) const;57 void getVectorRange(double minmax[2], int component = -1) const; 58 58 59 59 void getBounds(double bounds[6]) const; 60 61 void getCellSizeRange(double minmax[6], double *average) const; 60 62 61 63 double getDataValue(double x, double y, double z) const; … … 67 69 private: 68 70 DataSet(); 71 void print() const; 69 72 70 73 std::string _name; -
trunk/packages/vizservers/vtkvis/RpVtkGraphicsObject.h
r2393 r2402 50 50 _faceCulling(false) 51 51 { 52 _dataRange[0] = 0; 53 _dataRange[1] = 1; 52 54 _color[0] = 1.0f; 53 55 _color[1] = 1.0f; … … 70 72 * 71 73 * Default implementation calls update() 74 * 75 * \param[in] dataSet DataSet to use in rendering 72 76 */ 73 77 virtual void setDataSet(DataSet *dataSet) … … 75 79 if (_dataSet != dataSet) { 76 80 _dataSet = dataSet; 81 77 82 update(); 78 83 } 84 } 85 86 /** 87 * \brief Specify input DataSet and information on cumulative data ranges 88 * 89 * Default implementation calls update() and stores scalarRange to 90 * _dataRange based on cumulative range settings 91 * 92 * \param[in] dataSet DataSet to use in rendering 93 * \param[in] useCumulative Whether the cumulative data ranges should be 94 * used in place of the dataSet's ranges 95 * \param[in] scalarRange Current cumulative scalar data range 96 * \param[in] vectorMagnitudeRange Current cumulative vector magnitude data range 97 * \param[in] vectorComponentRange Current cumulative vector component data ranges 98 */ 99 virtual void setDataSet(DataSet *dataSet, 100 bool useCumulative, 101 double scalarRange[2], 102 double vectorMagnitudeRange[2], 103 double vectorComponentRange[3][2]) 104 { 105 if (_dataSet != dataSet) { 106 _dataSet = dataSet; 107 108 if (useCumulative) { 109 _dataRange[0] = scalarRange[0]; 110 _dataRange[1] = scalarRange[1]; 111 } else { 112 dataSet->getScalarRange(_dataRange); 113 } 114 115 update(); 116 } 117 } 118 119 /** 120 * \brief Called when scalar or vector field changes (e.g. active field) or 121 * cumulative ranges or settings change 122 * 123 * \param[in] useCumulative Whether the cumulative data ranges should be 124 * used in place of the dataSet's ranges 125 * \param[in] scalarRange Current cumulative scalar data range 126 * \param[in] vectorMagnitudeRange Current cumulative vector magnitude data range 127 * \param[in] vectorComponentRange Current cumulative vector component data ranges 128 */ 129 virtual void updateRanges(bool useCumulative, 130 double scalarRange[2], 131 double vectorMagnitudeRange[2], 132 double vectorComponentRange[3][2]) 133 { 79 134 } 80 135 … … 171 226 double angle = vtkMath::DegreesFromRadians(2.0 * acos(quat[0])); 172 227 double axis[3]; 173 double denom = sqrt(1. - quat[0] * quat[0]); 174 axis[0] = quat[1] / denom; 175 axis[1] = quat[2] / denom; 176 axis[2] = quat[3] / denom; 228 if (angle < 1.0e-6) { 229 axis[0] = 1; 230 axis[1] = 0; 231 axis[2] = 0; 232 } else { 233 double denom = sqrt(1. - quat[0] * quat[0]); 234 axis[0] = quat[1] / denom; 235 axis[1] = quat[2] / denom; 236 axis[2] = quat[3] / denom; 237 } 177 238 setOrientation(angle, axis); 178 239 } … … 589 650 } 590 651 } 652 653 /** 654 * \brief Toggle culling of selected CullFace 655 */ 656 virtual void setCulling(bool state) 657 { 658 _faceCulling = state; 659 if (state && _opacity < 1.0) 660 return; 661 if (getActor() != NULL) { 662 setCulling(getActor()->GetProperty(), state); 663 } else if (getAssembly() != NULL) { 664 vtkProp3DCollection *props = getAssembly()->GetParts(); 665 vtkProp3D *prop; 666 props->InitTraversal(); 667 while ((prop = props->GetNextProp3D()) != NULL) { 668 if (vtkActor::SafeDownCast(prop) != NULL) { 669 setCulling(vtkActor::SafeDownCast(prop)->GetProperty(), state); 670 } 671 } 672 } 673 } 674 675 /** 676 * \brief Specify which face(s) to cull when culling is enabled 677 */ 678 virtual void setCullFace(CullFace cull) 679 { 680 _cullFace = cull; 681 setCulling(_faceCulling); 682 } 683 684 /** 685 * \brief Subclasses need to implement setting clipping planes in their mappers 686 */ 687 virtual void setClippingPlanes(vtkPlaneCollection *planes) = 0; 688 689 protected: 690 /** 691 * \brief Create and initialize a VTK Prop to render the object 692 */ 693 virtual void initProp() 694 { 695 if (_prop == NULL) { 696 _prop = vtkSmartPointer<vtkActor>::New(); 697 vtkProperty *property = getActor()->GetProperty(); 698 property->EdgeVisibilityOff(); 699 property->SetOpacity(_opacity); 700 property->SetAmbient(.2); 701 if (!_lighting) 702 property->LightingOff(); 703 if (_faceCulling && _opacity == 1.0) { 704 setCulling(property, true); 705 } 706 } 707 } 708 709 /** 710 * \brief Subclasses implement this to create the VTK pipeline 711 * on a state change (e.g. new DataSet) 712 */ 713 virtual void update() = 0; 591 714 592 715 /** … … 613 736 } 614 737 615 /**616 * \brief Toggle culling of selected CullFace617 */618 virtual void setCulling(bool state)619 {620 _faceCulling = state;621 if (state && _opacity < 1.0)622 return;623 if (getActor() != NULL) {624 setCulling(getActor()->GetProperty(), state);625 } else if (getAssembly() != NULL) {626 vtkProp3DCollection *props = getAssembly()->GetParts();627 vtkProp3D *prop;628 props->InitTraversal();629 while ((prop = props->GetNextProp3D()) != NULL) {630 if (vtkActor::SafeDownCast(prop) != NULL) {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);641 }642 643 /**644 * \brief Subclasses need to implement setting clipping planes in their mappers645 */646 virtual void setClippingPlanes(vtkPlaneCollection *planes) = 0;647 648 protected:649 /**650 * \brief Create and initialize a VTK Prop to render the object651 */652 virtual void initProp()653 {654 if (_prop == NULL) {655 _prop = vtkSmartPointer<vtkActor>::New();656 vtkProperty *property = getActor()->GetProperty();657 property->EdgeVisibilityOff();658 property->SetOpacity(_opacity);659 property->SetAmbient(.2);660 if (!_lighting)661 property->LightingOff();662 if (_faceCulling && _opacity == 1.0) {663 setCulling(property, true);664 }665 }666 }667 668 /**669 * \brief Subclasses implement this to create the VTK pipeline670 * on a state change (e.g. new DataSet)671 */672 virtual void update() = 0;673 674 738 DataSet *_dataSet; 739 double _dataRange[2]; 675 740 double _opacity; 676 741 float _color[3]; -
trunk/packages/vizservers/vtkvis/RpVtkRenderer.cpp
r2393 r2402 69 69 _cameraOrientation[2] = 0.0; 70 70 _cameraOrientation[3] = 0.0; 71 _cumulativeDataRange[0] = 0.0; 72 _cumulativeDataRange[1] = 1.0; 71 _cumulativeScalarRange[0] = 0.0; 72 _cumulativeScalarRange[1] = 1.0; 73 _cumulativeVectorMagnitudeRange[0] = 0.0; 74 _cumulativeVectorMagnitudeRange[1] = 1.0; 75 for (int i = 0; i < 3; i++) { 76 _cumulativeVectorComponentRange[i][0] = 0.0; 77 _cumulativeVectorComponentRange[i][1] = 1.0; 78 } 73 79 // clipping planes to prevent overdrawing axes 74 80 _activeClipPlanes = vtkSmartPointer<vtkPlaneCollection>::New(); … … 263 269 } while (doAll && itr != _contour2Ds.end()); 264 270 271 initCamera(); 265 272 _needsRedraw = true; 266 273 } … … 299 306 } while (doAll && itr != _contour3Ds.end()); 300 307 308 initCamera(); 301 309 _needsRedraw = true; 302 310 } … … 335 343 } while (doAll && itr != _glyphs.end()); 336 344 345 initCamera(); 337 346 _needsRedraw = true; 338 347 } … … 371 380 } while (doAll && itr != _heightMaps.end()); 372 381 382 initCamera(); 373 383 _needsRedraw = true; 374 384 } … … 407 417 } while (doAll && itr != _lics.end()); 408 418 419 initCamera(); 409 420 _needsRedraw = true; 410 421 } … … 443 454 } while (doAll && itr != _molecules.end()); 444 455 456 initCamera(); 445 457 _needsRedraw = true; 446 458 } … … 479 491 } while (doAll && itr != _polyDatas.end()); 480 492 493 initCamera(); 481 494 _needsRedraw = true; 482 495 } … … 515 528 } while (doAll && itr != _pseudoColors.end()); 516 529 530 initCamera(); 517 531 _needsRedraw = true; 518 532 } … … 551 565 } while (doAll && itr != _streamlines.end()); 552 566 567 initCamera(); 553 568 _needsRedraw = true; 554 569 } … … 587 602 } while (doAll && itr != _volumes.end()); 588 603 604 initCamera(); 589 605 _needsRedraw = true; 590 606 } … … 634 650 635 651 // Update cumulative data range 636 collectDataRanges(_cumulativeDataRange, _cumulativeRangeOnlyVisible);637 updateRanges(_useCumulativeRange); 638 652 updateRanges(); 653 654 initCamera(); 639 655 _needsRedraw = true; 640 656 } … … 649 665 DataSetHashmap::iterator itr = _dataSets.find(id); 650 666 if (itr == _dataSets.end()) { 667 #ifdef DEBUG 651 668 TRACE("DataSet not found: %s", id.c_str()); 669 #endif 652 670 return NULL; 653 671 } else … … 663 681 if (ds) { 664 682 bool ret = ds->setDataFile(filename); 665 collectDataRanges(_cumulativeDataRange, _cumulativeRangeOnlyVisible); 666 updateRanges(_useCumulativeRange); 683 updateRanges(); 667 684 _needsRedraw = true; 668 685 return ret; … … 679 696 if (ds) { 680 697 bool ret = ds->setData(data, nbytes); 681 collectDataRanges(_cumulativeDataRange, _cumulativeRangeOnlyVisible); 682 updateRanges(_useCumulativeRange); 698 updateRanges(); 683 699 _needsRedraw = true; 684 700 return ret; … … 712 728 713 729 if (ret) { 714 collectDataRanges(_cumulativeDataRange, _cumulativeRangeOnlyVisible); 715 updateRanges(_useCumulativeRange); 730 updateRanges(); 716 731 _needsRedraw = true; 717 732 } … … 745 760 746 761 if (ret) { 747 collectDataRanges(_cumulativeDataRange, _cumulativeRangeOnlyVisible); 748 updateRanges(_useCumulativeRange); 762 updateRanges(); 749 763 _needsRedraw = true; 750 764 } … … 762 776 _useCumulativeRange = state; 763 777 _cumulativeRangeOnlyVisible = onlyVisible; 764 collectDataRanges(_cumulativeDataRange, _cumulativeRangeOnlyVisible); 765 updateRanges(_useCumulativeRange); 778 updateRanges(); 766 779 _needsRedraw = true; 767 780 } 768 781 } 769 782 770 void Renderer::resetAxes( )783 void Renderer::resetAxes(double bounds[6]) 771 784 { 772 785 TRACE("Resetting axes"); … … 793 806 _renderer->AddViewProp(_cubeAxesActor); 794 807 } 795 double bounds[6]; 796 collectBounds(bounds, false); 797 _cubeAxesActor->SetBounds(bounds); 808 if (bounds == NULL) { 809 double newBounds[6]; 810 collectBounds(newBounds, false); 811 _cubeAxesActor->SetBounds(newBounds); 812 } else { 813 _cubeAxesActor->SetBounds(bounds); 814 } 798 815 } 799 816 } … … 1137 1154 1138 1155 /** 1139 * \brief Add a color map for use in the Renderer 1156 * \brief Notify graphics objects that color map has changed 1157 */ 1158 void Renderer::updateColorMap(ColorMap *cmap) 1159 { 1160 for (Contour3DHashmap::iterator itr = _contour3Ds.begin(); 1161 itr != _contour3Ds.end(); ++itr) { 1162 if (itr->second->getColorMap() == cmap) { 1163 itr->second->updateColorMap(); 1164 _needsRedraw = true; 1165 } 1166 } 1167 for (GlyphsHashmap::iterator itr = _glyphs.begin(); 1168 itr != _glyphs.end(); ++itr) { 1169 if (itr->second->getColorMap() == cmap) { 1170 itr->second->updateColorMap(); 1171 _needsRedraw = true; 1172 } 1173 } 1174 for (HeightMapHashmap::iterator itr = _heightMaps.begin(); 1175 itr != _heightMaps.end(); ++itr) { 1176 if (itr->second->getColorMap() == cmap) { 1177 itr->second->updateColorMap(); 1178 _needsRedraw = true; 1179 } 1180 } 1181 for (LICHashmap::iterator itr = _lics.begin(); 1182 itr != _lics.end(); ++itr) { 1183 if (itr->second->getColorMap() == cmap) { 1184 itr->second->updateColorMap(); 1185 _needsRedraw = true; 1186 } 1187 } 1188 for (MoleculeHashmap::iterator itr = _molecules.begin(); 1189 itr != _molecules.end(); ++itr) { 1190 if (itr->second->getColorMap() == cmap) { 1191 itr->second->updateColorMap(); 1192 _needsRedraw = true; 1193 } 1194 } 1195 for (PseudoColorHashmap::iterator itr = _pseudoColors.begin(); 1196 itr != _pseudoColors.end(); ++itr) { 1197 if (itr->second->getColorMap() == cmap) { 1198 itr->second->updateColorMap(); 1199 _needsRedraw = true; 1200 } 1201 } 1202 for (StreamlinesHashmap::iterator itr = _streamlines.begin(); 1203 itr != _streamlines.end(); ++itr) { 1204 if (itr->second->getColorMap() == cmap) { 1205 itr->second->updateColorMap(); 1206 _needsRedraw = true; 1207 } 1208 } 1209 for (VolumeHashmap::iterator itr = _volumes.begin(); 1210 itr != _volumes.end(); ++itr) { 1211 if (itr->second->getColorMap() == cmap) { 1212 itr->second->updateColorMap(); 1213 _needsRedraw = true; 1214 } 1215 } 1216 } 1217 1218 /** 1219 * \brief Check if a ColorMap is in use by graphics objects 1220 */ 1221 bool Renderer::colorMapUsed(ColorMap *cmap) 1222 { 1223 for (Contour3DHashmap::iterator itr = _contour3Ds.begin(); 1224 itr != _contour3Ds.end(); ++itr) { 1225 if (itr->second->getColorMap() == cmap) 1226 return true; 1227 } 1228 for (GlyphsHashmap::iterator itr = _glyphs.begin(); 1229 itr != _glyphs.end(); ++itr) { 1230 if (itr->second->getColorMap() == cmap) 1231 return true; 1232 } 1233 for (HeightMapHashmap::iterator itr = _heightMaps.begin(); 1234 itr != _heightMaps.end(); ++itr) { 1235 if (itr->second->getColorMap() == cmap) 1236 return true; 1237 } 1238 for (LICHashmap::iterator itr = _lics.begin(); 1239 itr != _lics.end(); ++itr) { 1240 if (itr->second->getColorMap() == cmap) 1241 return true; 1242 } 1243 for (MoleculeHashmap::iterator itr = _molecules.begin(); 1244 itr != _molecules.end(); ++itr) { 1245 if (itr->second->getColorMap() == cmap) 1246 return true; 1247 } 1248 for (PseudoColorHashmap::iterator itr = _pseudoColors.begin(); 1249 itr != _pseudoColors.end(); ++itr) { 1250 if (itr->second->getColorMap() == cmap) 1251 return true; 1252 } 1253 for (StreamlinesHashmap::iterator itr = _streamlines.begin(); 1254 itr != _streamlines.end(); ++itr) { 1255 if (itr->second->getColorMap() == cmap) 1256 return true; 1257 } 1258 for (VolumeHashmap::iterator itr = _volumes.begin(); 1259 itr != _volumes.end(); ++itr) { 1260 if (itr->second->getColorMap() == cmap) 1261 return true; 1262 } 1263 return false; 1264 } 1265 1266 /** 1267 * \brief Add/replace a ColorMap for use in the Renderer 1140 1268 */ 1141 1269 void Renderer::addColorMap(const ColorMapId& id, ColorMap *colorMap) … … 1144 1272 colorMap->build(); 1145 1273 if (getColorMap(id) != NULL) { 1146 WARN("Replacing existing ColorMap %s", id.c_str()); 1147 deleteColorMap(id); 1148 } 1149 _colorMaps[id] = colorMap; 1274 TRACE("Replacing existing ColorMap %s", id.c_str()); 1275 // Copy to current colormap to avoid invalidating 1276 // pointers in graphics objects using the color map 1277 *_colorMaps[id] = *colorMap; 1278 delete colorMap; 1279 // Notify graphics objects of change 1280 updateColorMap(_colorMaps[id]); 1281 } else 1282 _colorMaps[id] = colorMap; 1150 1283 } else { 1151 1284 ERROR("NULL ColorMap"); … … 1191 1324 1192 1325 do { 1326 if (itr->second->getName().compare("default") == 0 || 1327 itr->second->getName().compare("volumeDefault") == 0 || 1328 itr->second->getName().compare("elementDefault") == 0) { 1329 if (id.compare("all") != 0) { 1330 WARN("Cannot delete a default color map"); 1331 } 1332 continue; 1333 } else if (colorMapUsed(itr->second)) { 1334 WARN("Cannot delete color map '%s', it is in use", itr->second->getName().c_str()); 1335 continue; 1336 } 1337 1193 1338 TRACE("Deleting ColorMap %s", itr->second->getName().c_str()); 1194 1339 1195 // TODO: Check if color map is used in PseudoColors?1196 1340 delete itr->second; 1197 1341 itr = _colorMaps.erase(itr); … … 1220 1364 _legendRenderWindow->DoubleBufferOff(); 1221 1365 _legendRenderWindow->OffScreenRenderingOn(); 1366 #else 1367 _legendRenderWindow->DoubleBufferOn(); 1368 _legendRenderWindow->SwapBuffersOff(); 1222 1369 #endif 1223 1370 } … … 1239 1386 vtkSmartPointer<vtkLookupTable> lut = colorMap->getLookupTable(); 1240 1387 if (dataSetID.compare("all") == 0) { 1241 lut->SetRange(_cumulative DataRange);1388 lut->SetRange(_cumulativeScalarRange); 1242 1389 } else { 1243 1390 DataSet *dataSet = getDataSet(dataSetID); 1244 1391 if (dataSet == NULL) { 1245 lut->SetRange(_cumulative DataRange);1392 lut->SetRange(_cumulativeScalarRange); 1246 1393 } else { 1247 1394 double range[2]; 1248 dataSet->get DataRange(range);1395 dataSet->getScalarRange(range); 1249 1396 lut->SetRange(range); 1250 1397 } … … 1310 1457 * \brief Create a new Contour2D and associate it with the named DataSet 1311 1458 */ 1312 void Renderer::addContour2D(const DataSetId& id )1459 void Renderer::addContour2D(const DataSetId& id, int numContours) 1313 1460 { 1314 1461 DataSetHashmap::iterator itr; … … 1335 1482 } 1336 1483 1337 Contour2D *contour = new Contour2D( );1484 Contour2D *contour = new Contour2D(numContours); 1338 1485 _contour2Ds[dsID] = contour; 1339 1486 1340 contour->setDataSet(ds); 1487 contour->setDataSet(ds, 1488 _useCumulativeRange, 1489 _cumulativeScalarRange, 1490 _cumulativeVectorMagnitudeRange, 1491 _cumulativeVectorComponentRange); 1341 1492 1342 1493 _renderer->AddViewProp(contour->getProp()); … … 1348 1499 1349 1500 /** 1501 * \brief Create a new Contour2D and associate it with the named DataSet 1502 */ 1503 void Renderer::addContour2D(const DataSetId& id, const std::vector<double>& contours) 1504 { 1505 DataSetHashmap::iterator itr; 1506 1507 bool doAll = false; 1508 1509 if (id.compare("all") == 0) { 1510 itr = _dataSets.begin(); 1511 } else { 1512 itr = _dataSets.find(id); 1513 } 1514 if (itr == _dataSets.end()) { 1515 ERROR("Unknown dataset %s", id.c_str()); 1516 return; 1517 } 1518 1519 do { 1520 DataSet *ds = itr->second; 1521 const DataSetId& dsID = ds->getName(); 1522 1523 if (getContour2D(dsID)) { 1524 WARN("Replacing existing Contour2D %s", dsID.c_str()); 1525 deleteContour2D(dsID); 1526 } 1527 1528 Contour2D *contour = new Contour2D(contours); 1529 _contour2Ds[dsID] = contour; 1530 1531 contour->setDataSet(ds, 1532 _useCumulativeRange, 1533 _cumulativeScalarRange, 1534 _cumulativeVectorMagnitudeRange, 1535 _cumulativeVectorComponentRange); 1536 1537 _renderer->AddViewProp(contour->getProp()); 1538 } while (doAll && ++itr != _dataSets.end()); 1539 1540 initCamera(); 1541 _needsRedraw = true; 1542 } 1543 1544 /** 1350 1545 * \brief Get the Contour2D associated with a named DataSet 1351 1546 */ … … 1355 1550 1356 1551 if (itr == _contour2Ds.end()) { 1552 #ifdef DEBUG 1357 1553 TRACE("Contour2D not found: %s", id.c_str()); 1554 #endif 1358 1555 return NULL; 1359 1556 } else … … 1522 1719 1523 1720 do { 1524 if (_useCumulativeRange) { 1525 itr->second->setContours(numContours, _cumulativeDataRange); 1526 } else { 1527 itr->second->setContours(numContours); 1528 } 1721 itr->second->setContours(numContours); 1529 1722 } while (doAll && ++itr != _contour2Ds.end()); 1530 1723 … … 1699 1892 * \brief Create a new Contour3D and associate it with the named DataSet 1700 1893 */ 1701 void Renderer::addContour3D(const DataSetId& id )1894 void Renderer::addContour3D(const DataSetId& id, int numContours) 1702 1895 { 1703 1896 DataSetHashmap::iterator itr; … … 1724 1917 } 1725 1918 1726 Contour3D *contour = new Contour3D( );1919 Contour3D *contour = new Contour3D(numContours); 1727 1920 _contour3Ds[dsID] = contour; 1728 1921 1729 contour->setDataSet(ds); 1730 1731 // Use the default color map 1732 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New(); 1733 ColorMap *cmap = getColorMap("default"); 1734 lut->DeepCopy(cmap->getLookupTable()); 1735 if (_useCumulativeRange) { 1736 lut->SetRange(_cumulativeDataRange); 1737 } else { 1738 double range[2]; 1739 ds->getDataRange(range); 1740 lut->SetRange(range); 1741 } 1742 1743 contour->setLookupTable(lut); 1922 contour->setDataSet(ds, 1923 _useCumulativeRange, 1924 _cumulativeScalarRange, 1925 _cumulativeVectorMagnitudeRange, 1926 _cumulativeVectorComponentRange); 1744 1927 1745 1928 _renderer->AddViewProp(contour->getProp()); … … 1753 1936 1754 1937 /** 1938 * \brief Create a new Contour3D and associate it with the named DataSet 1939 */ 1940 void Renderer::addContour3D(const DataSetId& id,const std::vector<double>& contours) 1941 { 1942 DataSetHashmap::iterator itr; 1943 1944 bool doAll = false; 1945 1946 if (id.compare("all") == 0) { 1947 itr = _dataSets.begin(); 1948 } else { 1949 itr = _dataSets.find(id); 1950 } 1951 if (itr == _dataSets.end()) { 1952 ERROR("Unknown dataset %s", id.c_str()); 1953 return; 1954 } 1955 1956 do { 1957 DataSet *ds = itr->second; 1958 const DataSetId& dsID = ds->getName(); 1959 1960 if (getContour3D(dsID)) { 1961 WARN("Replacing existing Contour3D %s", dsID.c_str()); 1962 deleteContour3D(dsID); 1963 } 1964 1965 Contour3D *contour = new Contour3D(contours); 1966 _contour3Ds[dsID] = contour; 1967 1968 contour->setDataSet(ds, 1969 _useCumulativeRange, 1970 _cumulativeScalarRange, 1971 _cumulativeVectorMagnitudeRange, 1972 _cumulativeVectorComponentRange); 1973 1974 _renderer->AddViewProp(contour->getProp()); 1975 } while (doAll && ++itr != _dataSets.end()); 1976 1977 if (_cameraMode == IMAGE) 1978 setCameraMode(PERSPECTIVE); 1979 initCamera(); 1980 _needsRedraw = true; 1981 } 1982 1983 /** 1755 1984 * \brief Get the Contour3D associated with a named DataSet 1756 1985 */ … … 1760 1989 1761 1990 if (itr == _contour3Ds.end()) { 1991 #ifdef DEBUG 1762 1992 TRACE("Contour3D not found: %s", id.c_str()); 1993 #endif 1763 1994 return NULL; 1764 1995 } else … … 1927 2158 1928 2159 do { 1929 if (_useCumulativeRange) { 1930 itr->second->setContours(numContours, _cumulativeDataRange); 1931 } else { 1932 itr->second->setContours(numContours); 1933 } 1934 } while (doAll && ++itr != _contour3Ds.end()); 2160 itr->second->setContours(numContours); 2161 } while (doAll && ++itr != _contour3Ds.end()); 1935 2162 1936 2163 initCamera(); … … 2052 2279 itr->second->getDataSet()->getName().c_str()); 2053 2280 2054 // Make a copy of the generic colormap lookup table, so 2055 // data range can be set in the copy table to match the 2056 // dataset being plotted 2057 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New(); 2058 lut->DeepCopy(cmap->getLookupTable()); 2059 2060 if (_useCumulativeRange) { 2061 lut->SetRange(_cumulativeDataRange); 2062 } else { 2063 if (itr->second->getDataSet() != NULL) { 2064 double range[2]; 2065 itr->second->getDataSet()->getDataRange(range); 2066 lut->SetRange(range); 2067 } 2068 } 2069 2070 itr->second->setLookupTable(lut); 2281 itr->second->setColorMap(cmap); 2071 2282 } while (doAll && ++itr != _contour3Ds.end()); 2072 2283 … … 2240 2451 * \brief Create a new Glyphs and associate it with the named DataSet 2241 2452 */ 2242 void Renderer::addGlyphs(const DataSetId& id )2453 void Renderer::addGlyphs(const DataSetId& id, Glyphs::GlyphShape shape) 2243 2454 { 2244 2455 DataSetHashmap::iterator itr; … … 2265 2476 } 2266 2477 2267 Glyphs *glyphs = new Glyphs( );2478 Glyphs *glyphs = new Glyphs(shape); 2268 2479 _glyphs[dsID] = glyphs; 2269 2480 2270 glyphs->setDataSet(ds); 2271 2272 // Use the default color map 2273 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New(); 2274 ColorMap *cmap = getColorMap("default"); 2275 lut->DeepCopy(cmap->getLookupTable()); 2276 if (_useCumulativeRange) { 2277 lut->SetRange(_cumulativeDataRange); 2278 } else { 2279 double range[2]; 2280 ds->getDataRange(range); 2281 lut->SetRange(range); 2282 } 2283 2284 glyphs->setLookupTable(lut); 2481 glyphs->setDataSet(ds, 2482 _useCumulativeRange, 2483 _cumulativeScalarRange, 2484 _cumulativeVectorMagnitudeRange, 2485 _cumulativeVectorComponentRange); 2285 2486 2286 2487 _renderer->AddViewProp(glyphs->getProp()); … … 2302 2503 2303 2504 if (itr == _glyphs.end()) { 2505 #ifdef DEBUG 2304 2506 TRACE("Glyphs not found: %s", id.c_str()); 2507 #endif 2305 2508 return NULL; 2306 2509 } else … … 2506 2709 itr->second->getDataSet()->getName().c_str()); 2507 2710 2508 // Make a copy of the generic colormap lookup table, so 2509 // data range can be set in the copy table to match the 2510 // dataset being plotted 2511 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New(); 2512 lut->DeepCopy(cmap->getLookupTable()); 2513 2514 if (_useCumulativeRange) { 2515 lut->SetRange(_cumulativeDataRange); 2516 } else { 2517 if (itr->second->getDataSet() != NULL) { 2518 double range[2]; 2519 itr->second->getDataSet()->getDataRange(range); 2520 lut->SetRange(range); 2521 } 2522 } 2523 2524 itr->second->setLookupTable(lut); 2711 itr->second->setColorMap(cmap); 2525 2712 } while (doAll && ++itr != _glyphs.end()); 2526 2713 … … 2833 3020 * \brief Create a new HeightMap and associate it with the named DataSet 2834 3021 */ 2835 void Renderer::addHeightMap(const DataSetId& id )3022 void Renderer::addHeightMap(const DataSetId& id, int numContours) 2836 3023 { 2837 3024 DataSetHashmap::iterator itr; … … 2858 3045 } 2859 3046 2860 HeightMap *hmap = new HeightMap( );3047 HeightMap *hmap = new HeightMap(numContours); 2861 3048 _heightMaps[dsID] = hmap; 2862 3049 2863 hmap->setDataSet(ds); 2864 2865 // Use the default color map 2866 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New(); 2867 ColorMap *cmap = getColorMap("default"); 2868 lut->DeepCopy(cmap->getLookupTable()); 2869 if (_useCumulativeRange) { 2870 lut->SetRange(_cumulativeDataRange); 2871 } else { 2872 double range[2]; 2873 ds->getDataRange(range); 2874 lut->SetRange(range); 2875 } 2876 2877 hmap->setLookupTable(lut); 3050 hmap->setDataSet(ds, 3051 _useCumulativeRange, 3052 _cumulativeScalarRange, 3053 _cumulativeVectorMagnitudeRange, 3054 _cumulativeVectorComponentRange); 2878 3055 2879 3056 _renderer->AddViewProp(hmap->getProp()); … … 2888 3065 2889 3066 /** 3067 * \brief Create a new HeightMap and associate it with the named DataSet 3068 */ 3069 void Renderer::addHeightMap(const DataSetId& id, const std::vector<double>& contours) 3070 { 3071 DataSetHashmap::iterator itr; 3072 3073 bool doAll = false; 3074 3075 if (id.compare("all") == 0) { 3076 itr = _dataSets.begin(); 3077 } else { 3078 itr = _dataSets.find(id); 3079 } 3080 if (itr == _dataSets.end()) { 3081 ERROR("Unknown dataset %s", id.c_str()); 3082 return; 3083 } 3084 3085 do { 3086 DataSet *ds = itr->second; 3087 const DataSetId& dsID = ds->getName(); 3088 3089 if (getHeightMap(dsID)) { 3090 WARN("Replacing existing HeightMap %s", dsID.c_str()); 3091 deleteHeightMap(dsID); 3092 } 3093 3094 HeightMap *hmap = new HeightMap(contours); 3095 _heightMaps[dsID] = hmap; 3096 3097 hmap->setDataSet(ds, 3098 _useCumulativeRange, 3099 _cumulativeScalarRange, 3100 _cumulativeVectorMagnitudeRange, 3101 _cumulativeVectorComponentRange); 3102 3103 _renderer->AddViewProp(hmap->getProp()); 3104 } while (doAll && ++itr != _dataSets.end()); 3105 3106 if (_cameraMode == IMAGE) 3107 setCameraMode(PERSPECTIVE); 3108 initCamera(); 3109 3110 _needsRedraw = true; 3111 } 3112 3113 /** 2890 3114 * \brief Get the HeightMap associated with a named DataSet 2891 3115 */ … … 2895 3119 2896 3120 if (itr == _heightMaps.end()) { 3121 #ifdef DEBUG 2897 3122 TRACE("HeightMap not found: %s", id.c_str()); 3123 #endif 2898 3124 return NULL; 2899 3125 } else … … 3131 3357 itr->second->getDataSet()->getName().c_str()); 3132 3358 3133 // Make a copy of the generic colormap lookup table, so 3134 // data range can be set in the copy table to match the 3135 // dataset being plotted 3136 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New(); 3137 lut->DeepCopy(cmap->getLookupTable()); 3138 3139 if (_useCumulativeRange) { 3140 lut->SetRange(_cumulativeDataRange); 3141 } else { 3142 if (itr->second->getDataSet() != NULL) { 3143 double range[2]; 3144 itr->second->getDataSet()->getDataRange(range); 3145 lut->SetRange(range); 3146 } 3147 } 3148 3149 itr->second->setLookupTable(lut); 3359 itr->second->setColorMap(cmap); 3150 3360 } while (doAll && ++itr != _heightMaps.end()); 3151 3361 … … 3174 3384 3175 3385 do { 3176 if (_useCumulativeRange) { 3177 itr->second->setContours(numContours, _cumulativeDataRange); 3178 } else { 3179 itr->second->setContours(numContours); 3180 } 3386 itr->second->setContours(numContours); 3181 3387 } while (doAll && ++itr != _heightMaps.end()); 3182 3388 … … 3490 3696 _lics[dsID] = lic; 3491 3697 3492 lic->setDataSet(ds); 3698 lic->setDataSet(ds, 3699 _useCumulativeRange, 3700 _cumulativeScalarRange, 3701 _cumulativeVectorMagnitudeRange, 3702 _cumulativeVectorComponentRange); 3493 3703 3494 3704 _renderer->AddViewProp(lic->getProp()); … … 3509 3719 3510 3720 if (itr == _lics.end()) { 3721 #ifdef DEBUG 3511 3722 TRACE("LIC not found: %s", id.c_str()); 3723 #endif 3512 3724 return NULL; 3513 3725 } else … … 3715 3927 itr->second->getDataSet()->getName().c_str()); 3716 3928 3717 // Make a copy of the generic colormap lookup table, so 3718 // data range can be set in the copy table to match the 3719 // dataset being plotted 3720 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New(); 3721 lut->DeepCopy(cmap->getLookupTable()); 3722 3723 if (_useCumulativeRange) { 3724 lut->SetRange(_cumulativeDataRange); 3725 } else { 3726 if (itr->second->getDataSet() != NULL) { 3727 double range[2]; 3728 itr->second->getDataSet()->getDataRange(range); 3729 lut->SetRange(range); 3730 } 3731 } 3732 3733 itr->second->setLookupTable(lut); 3929 itr->second->setColorMap(cmap); 3734 3930 } while (doAll && ++itr != _lics.end()); 3735 3931 … … 3952 4148 3953 4149 if (itr == _molecules.end()) { 4150 #ifdef DEBUG 3954 4151 TRACE("Molecule not found: %s", id.c_str()); 4152 #endif 3955 4153 return NULL; 3956 4154 } else … … 4129 4327 itr->second->getDataSet()->getName().c_str()); 4130 4328 4131 // Make a copy of the generic colormap lookup table, so 4132 // data range can be set in the copy table to match the 4133 // dataset being plotted 4134 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New(); 4135 lut->DeepCopy(cmap->getLookupTable()); 4136 4137 if (_useCumulativeRange) { 4138 lut->SetRange(_cumulativeDataRange); 4139 } else { 4140 if (itr->second->getDataSet() != NULL) { 4141 double range[2]; 4142 itr->second->getDataSet()->getDataRange(range); 4143 lut->SetRange(range); 4144 } 4145 } 4146 4147 itr->second->setLookupTable(lut); 4329 itr->second->setColorMap(cmap); 4148 4330 } while (doAll && ++itr != _molecules.end()); 4149 4331 … … 4474 4656 4475 4657 if (itr == _polyDatas.end()) { 4658 #ifdef DEBUG 4476 4659 TRACE("PolyData not found: %s", id.c_str()); 4660 #endif 4477 4661 return NULL; 4478 4662 } else … … 4868 5052 _pseudoColors[dsID] = pc; 4869 5053 4870 pc->setDataSet(ds); 4871 4872 // Use the default color map 4873 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New(); 4874 ColorMap *cmap = getColorMap("default"); 4875 lut->DeepCopy(cmap->getLookupTable()); 4876 if (_useCumulativeRange) { 4877 lut->SetRange(_cumulativeDataRange); 4878 } else { 4879 double range[2]; 4880 ds->getDataRange(range); 4881 lut->SetRange(range); 4882 } 4883 4884 pc->setLookupTable(lut); 5054 pc->setDataSet(ds, 5055 _useCumulativeRange, 5056 _cumulativeScalarRange, 5057 _cumulativeVectorMagnitudeRange, 5058 _cumulativeVectorComponentRange); 4885 5059 4886 5060 _renderer->AddViewProp(pc->getProp()); … … 4899 5073 4900 5074 if (itr == _pseudoColors.end()) { 5075 #ifdef DEBUG 4901 5076 TRACE("PseudoColor not found: %s", id.c_str()); 5077 #endif 4902 5078 return NULL; 4903 5079 } else … … 5076 5252 itr->second->getDataSet()->getName().c_str()); 5077 5253 5078 // Make a copy of the generic colormap lookup table, so 5079 // data range can be set in the copy table to match the 5080 // dataset being plotted 5081 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New(); 5082 lut->DeepCopy(cmap->getLookupTable()); 5083 5084 if (_useCumulativeRange) { 5085 lut->SetRange(_cumulativeDataRange); 5086 } else { 5087 if (itr->second->getDataSet() != NULL) { 5088 double range[2]; 5089 itr->second->getDataSet()->getDataRange(range); 5090 lut->SetRange(range); 5091 } 5092 } 5093 5094 itr->second->setLookupTable(lut); 5254 itr->second->setColorMap(cmap); 5095 5255 } while (doAll && ++itr != _pseudoColors.end()); 5096 5256 … … 5327 5487 _streamlines[dsID] = streamlines; 5328 5488 5329 streamlines->setDataSet(ds); 5330 5331 // Use the default color map 5332 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New(); 5333 ColorMap *cmap = getColorMap("default"); 5334 lut->DeepCopy(cmap->getLookupTable()); 5335 5336 if (_useCumulativeRange) { 5337 lut->SetRange(_cumulativeDataRange); 5338 } else { 5339 double range[2]; 5340 ds->getDataRange(range); 5341 lut->SetRange(range); 5342 } 5343 streamlines->setLookupTable(lut); 5489 streamlines->setDataSet(ds, 5490 _useCumulativeRange, 5491 _cumulativeScalarRange, 5492 _cumulativeVectorMagnitudeRange, 5493 _cumulativeVectorComponentRange); 5344 5494 5345 5495 _renderer->AddViewProp(streamlines->getProp()); … … 5358 5508 5359 5509 if (itr == _streamlines.end()) { 5510 #ifdef DEBUG 5360 5511 TRACE("Streamlines not found: %s", id.c_str()); 5512 #endif 5361 5513 return NULL; 5362 5514 } else … … 5901 6053 itr->second->getDataSet()->getName().c_str()); 5902 6054 5903 // Make a copy of the generic colormap lookup table, so 5904 // data range can be set in the copy table to match the 5905 // dataset being plotted 5906 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New(); 5907 lut->DeepCopy(cmap->getLookupTable()); 5908 5909 if (_useCumulativeRange) { 5910 lut->SetRange(_cumulativeDataRange); 5911 } else { 5912 if (itr->second->getDataSet() != NULL) { 5913 double range[2]; 5914 itr->second->getDataSet()->getDataRange(range); 5915 lut->SetRange(range); 5916 } 5917 } 5918 5919 itr->second->setLookupTable(lut); 6055 itr->second->setColorMap(cmap); 5920 6056 } while (doAll && ++itr != _streamlines.end()); 5921 6057 … … 6120 6256 _volumes[dsID] = volume; 6121 6257 6122 volume->setDataSet(ds); 6123 6124 if (_useCumulativeRange) { 6125 ColorMap *cmap = volume->getColorMap(); 6126 volume->setColorMap(cmap, _cumulativeDataRange); 6127 } 6258 volume->setDataSet(ds, 6259 _useCumulativeRange, 6260 _cumulativeScalarRange, 6261 _cumulativeVectorMagnitudeRange, 6262 _cumulativeVectorComponentRange ); 6128 6263 6129 6264 _renderer->AddViewProp(volume->getProp()); … … 6144 6279 6145 6280 if (itr == _volumes.end()) { 6281 #ifdef DEBUG 6146 6282 TRACE("Volume not found: %s", id.c_str()); 6283 #endif 6147 6284 return NULL; 6148 6285 } else … … 6321 6458 itr->second->getDataSet()->getName().c_str()); 6322 6459 6323 if (_useCumulativeRange) { 6324 itr->second->setColorMap(cmap, _cumulativeDataRange); 6325 } else { 6326 itr->second->setColorMap(cmap); 6327 } 6460 itr->second->setColorMap(cmap); 6328 6461 } while (doAll && ++itr != _volumes.end()); 6329 6462 … … 7350 7483 /** 7351 7484 * \brief Update data ranges for color-mapping and contours 7352 * 7353 * \param[in] useCumulative Use cumulative range of all DataSets 7354 */ 7355 void Renderer::updateRanges(bool useCumulative) 7356 { 7485 */ 7486 void Renderer::updateRanges() 7487 { 7488 collectDataRanges(); 7489 7357 7490 for (Contour2DHashmap::iterator itr = _contour2Ds.begin(); 7358 7491 itr != _contour2Ds.end(); ++itr) { 7359 // Only need to update range if using evenly spaced contours 7360 if (itr->second->getContourList().empty()) { 7361 if (useCumulative) { 7362 itr->second->setContours(itr->second->getNumContours(), _cumulativeDataRange); 7363 } else { 7364 itr->second->setContours(itr->second->getNumContours()); 7365 } 7366 } 7492 itr->second->updateRanges(_useCumulativeRange, 7493 _cumulativeScalarRange, 7494 _cumulativeVectorMagnitudeRange, 7495 _cumulativeVectorComponentRange); 7367 7496 } 7368 7497 for (Contour3DHashmap::iterator itr = _contour3Ds.begin(); 7369 7498 itr != _contour3Ds.end(); ++itr) { 7370 // Only need to update range if using evenly spaced contours 7371 if (itr->second->getContourList().empty()) { 7372 if (useCumulative) { 7373 itr->second->setContours(itr->second->getNumContours(), _cumulativeDataRange); 7374 } else { 7375 itr->second->setContours(itr->second->getNumContours()); 7376 } 7377 } 7499 itr->second->updateRanges(_useCumulativeRange, 7500 _cumulativeScalarRange, 7501 _cumulativeVectorMagnitudeRange, 7502 _cumulativeVectorComponentRange); 7378 7503 } 7379 7504 for (GlyphsHashmap::iterator itr = _glyphs.begin(); 7380 7505 itr != _glyphs.end(); ++itr) { 7381 vtkLookupTable *lut = itr->second->getLookupTable(); 7382 if (lut) { 7383 if (useCumulative) { 7384 lut->SetRange(_cumulativeDataRange); 7385 } else { 7386 double range[2]; 7387 if (itr->second->getDataSet()) { 7388 itr->second->getDataSet()->getDataRange(range); 7389 lut->SetRange(range); 7390 } 7391 } 7392 } 7506 itr->second->updateRanges(_useCumulativeRange, 7507 _cumulativeScalarRange, 7508 _cumulativeVectorMagnitudeRange, 7509 _cumulativeVectorComponentRange); 7393 7510 } 7394 7511 for (HeightMapHashmap::iterator itr = _heightMaps.begin(); 7395 7512 itr != _heightMaps.end(); ++itr) { 7396 vtkLookupTable *lut = itr->second->getLookupTable(); 7397 if (lut) { 7398 if (useCumulative) { 7399 lut->SetRange(_cumulativeDataRange); 7400 } else { 7401 double range[2]; 7402 if (itr->second->getDataSet()) { 7403 itr->second->getDataSet()->getDataRange(range); 7404 lut->SetRange(range); 7405 } 7406 } 7407 } 7408 // Only need to update contour range if using evenly spaced contours 7409 if (itr->second->getContourList().empty()) { 7410 if (useCumulative) { 7411 itr->second->setContours(itr->second->getNumContours(), _cumulativeDataRange); 7412 } else { 7413 itr->second->setContours(itr->second->getNumContours()); 7414 } 7415 } 7513 itr->second->updateRanges(_useCumulativeRange, 7514 _cumulativeScalarRange, 7515 _cumulativeVectorMagnitudeRange, 7516 _cumulativeVectorComponentRange); 7416 7517 } 7417 7518 for (LICHashmap::iterator itr = _lics.begin(); 7418 7519 itr != _lics.end(); ++itr) { 7419 vtkLookupTable *lut = itr->second->getLookupTable(); 7420 if (lut) { 7421 if (useCumulative) { 7422 lut->SetRange(_cumulativeDataRange); 7423 } else { 7424 double range[2]; 7425 if (itr->second->getDataSet()) { 7426 itr->second->getDataSet()->getDataRange(range); 7427 lut->SetRange(range); 7428 } 7429 } 7430 } 7520 itr->second->updateRanges(_useCumulativeRange, 7521 _cumulativeScalarRange, 7522 _cumulativeVectorMagnitudeRange, 7523 _cumulativeVectorComponentRange); 7524 } 7525 for (MoleculeHashmap::iterator itr = _molecules.begin(); 7526 itr != _molecules.end(); ++itr) { 7527 itr->second->updateRanges(_useCumulativeRange, 7528 _cumulativeScalarRange, 7529 _cumulativeVectorMagnitudeRange, 7530 _cumulativeVectorComponentRange); 7431 7531 } 7432 7532 for (PseudoColorHashmap::iterator itr = _pseudoColors.begin(); 7433 7533 itr != _pseudoColors.end(); ++itr) { 7434 vtkLookupTable *lut = itr->second->getLookupTable(); 7435 if (lut) { 7436 if (useCumulative) { 7437 lut->SetRange(_cumulativeDataRange); 7438 } else { 7439 double range[2]; 7440 if (itr->second->getDataSet()) { 7441 itr->second->getDataSet()->getDataRange(range); 7442 lut->SetRange(range); 7443 } 7444 } 7445 } 7534 itr->second->updateRanges(_useCumulativeRange, 7535 _cumulativeScalarRange, 7536 _cumulativeVectorMagnitudeRange, 7537 _cumulativeVectorComponentRange); 7446 7538 } 7447 7539 for (StreamlinesHashmap::iterator itr = _streamlines.begin(); 7448 7540 itr != _streamlines.end(); ++itr) { 7449 vtkLookupTable *lut = itr->second->getLookupTable(); 7450 if (lut) { 7451 if (useCumulative) { 7452 lut->SetRange(_cumulativeDataRange); 7453 } else { 7454 double range[2]; 7455 if (itr->second->getDataSet()) { 7456 itr->second->getDataSet()->getDataRange(range); 7457 lut->SetRange(range); 7458 } 7459 } 7460 } 7541 itr->second->updateRanges(_useCumulativeRange, 7542 _cumulativeScalarRange, 7543 _cumulativeVectorMagnitudeRange, 7544 _cumulativeVectorComponentRange); 7461 7545 } 7462 7546 for (VolumeHashmap::iterator itr = _volumes.begin(); 7463 7547 itr != _volumes.end(); ++itr) { 7464 ColorMap *cmap = itr->second->getColorMap(); 7465 if (cmap) { 7466 if (useCumulative) { 7467 itr->second->setColorMap(cmap, _cumulativeDataRange); 7468 } else { 7469 itr->second->setColorMap(cmap); 7470 } 7471 } 7548 itr->second->updateRanges(_useCumulativeRange, 7549 _cumulativeScalarRange, 7550 _cumulativeVectorMagnitudeRange, 7551 _cumulativeVectorComponentRange); 7552 } 7553 } 7554 7555 void Renderer::collectDataRanges() 7556 { 7557 collectScalarRanges(_cumulativeScalarRange, 7558 _cumulativeRangeOnlyVisible); 7559 collectVectorMagnitudeRanges(_cumulativeVectorMagnitudeRange, 7560 _cumulativeRangeOnlyVisible); 7561 for (int i = 0; i < 3; i++) { 7562 collectVectorComponentRanges(_cumulativeVectorComponentRange[i], i, 7563 _cumulativeRangeOnlyVisible); 7472 7564 } 7473 7565 } … … 7479 7571 * \param[in] onlyVisible Only collect range of visible DataSets 7480 7572 */ 7481 void Renderer::collect DataRanges(double *range, bool onlyVisible)7573 void Renderer::collectScalarRanges(double *range, bool onlyVisible) 7482 7574 { 7483 7575 range[0] = DBL_MAX; … … 7488 7580 if (!onlyVisible || itr->second->getVisibility()) { 7489 7581 double r[2]; 7490 itr->second->get DataRange(r);7582 itr->second->getScalarRange(r); 7491 7583 range[0] = min2(range[0], r[0]); 7492 7584 range[1] = max2(range[1], r[1]); … … 7498 7590 range[1] = 1; 7499 7591 } 7592 7593 /** 7594 * \brief Collect cumulative data range of all DataSets 7595 * 7596 * \param[inout] range Data range of all DataSets 7597 * \param[in] onlyVisible Only collect range of visible DataSets 7598 */ 7599 void Renderer::collectVectorMagnitudeRanges(double *range, bool onlyVisible) 7600 { 7601 range[0] = DBL_MAX; 7602 range[1] = -DBL_MAX; 7603 7604 for (DataSetHashmap::iterator itr = _dataSets.begin(); 7605 itr != _dataSets.end(); ++itr) { 7606 if (!onlyVisible || itr->second->getVisibility()) { 7607 double r[2]; 7608 itr->second->getVectorRange(r); 7609 range[0] = min2(range[0], r[0]); 7610 range[1] = max2(range[1], r[1]); 7611 } 7612 } 7613 if (range[0] == DBL_MAX) 7614 range[0] = 0; 7615 if (range[1] == -DBL_MAX) 7616 range[1] = 1; 7617 } 7618 7619 /** 7620 * \brief Collect cumulative data range of all DataSets 7621 * 7622 * \param[inout] range Data range of all DataSets 7623 * \param[in] onlyVisible Only collect range of visible DataSets 7624 */ 7625 void Renderer::collectVectorComponentRanges(double *range, int component, bool onlyVisible) 7626 { 7627 range[0] = DBL_MAX; 7628 range[1] = -DBL_MAX; 7629 7630 for (DataSetHashmap::iterator itr = _dataSets.begin(); 7631 itr != _dataSets.end(); ++itr) { 7632 if (!onlyVisible || itr->second->getVisibility()) { 7633 double r[2]; 7634 itr->second->getVectorRange(r, component); 7635 range[0] = min2(range[0], r[0]); 7636 range[1] = max2(range[1], r[1]); 7637 } 7638 } 7639 if (range[0] == DBL_MAX) 7640 range[0] = 0; 7641 if (range[1] == -DBL_MAX) 7642 range[1] = 1; 7643 } 7500 7644 7501 7645 /** … … 7538 7682 case ORTHO: 7539 7683 _renderer->GetActiveCamera()->ParallelProjectionOn(); 7540 resetAxes( );7684 resetAxes(bounds); 7541 7685 _renderer->ResetCamera(bounds); 7542 7686 //computeScreenWorldCoords(); … … 7544 7688 case PERSPECTIVE: 7545 7689 _renderer->GetActiveCamera()->ParallelProjectionOff(); 7546 resetAxes( );7690 resetAxes(bounds); 7547 7691 _renderer->ResetCamera(bounds); 7548 7692 //computeScreenWorldCoords(); -
trunk/packages/vizservers/vtkvis/RpVtkRenderer.h
r2393 r2402 232 232 // 2D Contour plots 233 233 234 void addContour2D(const DataSetId& id); 234 void addContour2D(const DataSetId& id, int numContours); 235 236 void addContour2D(const DataSetId& id, const std::vector<double>& contours); 235 237 236 238 void deleteContour2D(const DataSetId& id); … … 264 266 // 3D Contour (isosurface) plots 265 267 266 void addContour3D(const DataSetId& id); 268 void addContour3D(const DataSetId& id, int numContours); 269 270 void addContour3D(const DataSetId& id, const std::vector<double>& contours); 267 271 268 272 void deleteContour3D(const DataSetId& id); … … 304 308 // Glyphs 305 309 306 void addGlyphs(const DataSetId& id );310 void addGlyphs(const DataSetId& id, Glyphs::GlyphShape shape); 307 311 308 312 void deleteGlyphs(const DataSetId& id); … … 348 352 // Height maps 349 353 350 void addHeightMap(const DataSetId& id); 354 void addHeightMap(const DataSetId& id, int numContours); 355 356 void addHeightMap(const DataSetId& id, const std::vector<double>& contours); 351 357 352 358 void deleteHeightMap(const DataSetId& id); … … 650 656 void collectBounds(double *bounds, bool onlyVisible); 651 657 652 void collectDataRanges(double *range, bool onlyVisible); 653 654 void updateRanges(bool useCumulative); 658 void collectDataRanges(); 659 660 void collectScalarRanges(double *range, bool onlyVisible); 661 662 void collectVectorMagnitudeRanges(double *range, bool onlyVisible); 663 664 void collectVectorComponentRanges(double *range, int component, bool onlyVisible); 665 666 void updateRanges(); 667 668 void updateColorMap(ColorMap *cmap); 669 670 bool colorMapUsed(ColorMap *cmap); 655 671 656 672 void setCameraFromMatrix(vtkCamera *camera, vtkMatrix4x4 &mat); … … 664 680 void initCamera(); 665 681 void initAxes(); 666 void resetAxes( );682 void resetAxes(double bounds[6] = NULL); 667 683 void setCameraClippingPlanes(); 668 684 … … 678 694 bool _useCumulativeRange; 679 695 bool _cumulativeRangeOnlyVisible; 680 double _cumulativeDataRange[2]; 696 double _cumulativeScalarRange[2]; 697 double _cumulativeVectorMagnitudeRange[2]; 698 double _cumulativeVectorComponentRange[3][2]; 681 699 682 700 ColorMapHashmap _colorMaps; -
trunk/packages/vizservers/vtkvis/RpVtkRendererCmd.cpp
r2393 r2402 625 625 if (objc == 5) { 626 626 const char *name = Tcl_GetString(objv[4]); 627 g_renderer->addContour2D(name); 628 g_renderer->setContour2DContourList(name, contourList); 629 } else { 630 g_renderer->addContour2D("all"); 631 g_renderer->setContour2DContourList("all", contourList); 627 g_renderer->addContour2D(name, contourList); 628 } else { 629 g_renderer->addContour2D("all", contourList); 632 630 } 633 631 return TCL_OK; … … 644 642 if (objc == 5) { 645 643 const char *name = Tcl_GetString(objv[4]); 646 g_renderer->addContour2D(name); 647 g_renderer->setContour2DContours(name, numContours); 648 } else { 649 g_renderer->addContour2D("all"); 650 g_renderer->setContour2DContours("all", numContours); 644 g_renderer->addContour2D(name, numContours); 645 } else { 646 g_renderer->addContour2D("all", numContours); 651 647 } 652 648 return TCL_OK; … … 882 878 if (objc == 5) { 883 879 const char *name = Tcl_GetString(objv[4]); 884 g_renderer->addContour3D(name); 885 g_renderer->setContour3DContourList(name, contourList); 886 } else { 887 g_renderer->addContour3D("all"); 888 g_renderer->setContour3DContourList("all", contourList); 880 g_renderer->addContour3D(name, contourList); 881 } else { 882 g_renderer->addContour3D("all", contourList); 889 883 } 890 884 return TCL_OK; … … 901 895 if (objc == 5) { 902 896 const char *name = Tcl_GetString(objv[4]); 903 g_renderer->addContour3D(name); 904 g_renderer->setContour3DContours(name, numContours); 905 } else { 906 g_renderer->addContour3D("all"); 907 g_renderer->setContour3DContours("all", numContours); 897 g_renderer->addContour3D(name, numContours); 898 } else { 899 g_renderer->addContour3D("all", numContours); 908 900 } 909 901 return TCL_OK; … … 1271 1263 #else 1272 1264 size_t bytesRead = fread(data, 1, nbytes, g_fIn); 1273 TRACE("bytesRead: %d '%c'", bytesRead, data[0]);1265 TRACE("bytesRead: %d", bytesRead); 1274 1266 if (bytesRead < (size_t)nbytes) { 1275 1267 free(data); … … 1468 1460 } else if (shapeOpt[0] == 'i' && strcmp(shapeOpt, "icosahedron") == 0) { 1469 1461 shape = Glyphs::ICOSAHEDRON; 1462 } else if (shapeOpt[0] == 'l' && strcmp(shapeOpt, "line") == 0) { 1463 shape = Glyphs::LINE; 1470 1464 } else if (shapeOpt[0] == 'o' && strcmp(shapeOpt, "octahedron") == 0) { 1471 1465 shape = Glyphs::OCTAHEDRON; … … 1482 1476 if (objc == 4) { 1483 1477 const char *name = Tcl_GetString(objv[3]); 1484 g_renderer->addGlyphs(name); 1485 g_renderer->setGlyphsShape(name, shape); 1486 } else { 1487 g_renderer->addGlyphs("all"); 1488 g_renderer->setGlyphsShape("all", shape); 1478 g_renderer->addGlyphs(name, shape); 1479 } else { 1480 g_renderer->addGlyphs("all", shape); 1489 1481 } 1490 1482 return TCL_OK; … … 1536 1528 } else if (str[0] == 's' && strcmp(str, "scalar") == 0) { 1537 1529 mode = Glyphs::COLOR_BY_SCALAR; 1538 } else if (str[0] == 'v' && strcmp(str, "v ector") == 0) {1539 mode = Glyphs::COLOR_BY_VECTOR ;1530 } else if (str[0] == 'v' && strcmp(str, "vmag") == 0) { 1531 mode = Glyphs::COLOR_BY_VECTOR_MAGNITUDE; 1540 1532 } else { 1541 1533 Tcl_AppendResult(interp, "bad color mode option \"", str, 1542 "\": should be one of: 'scale', 'scalar', 'v ector', 'ccolor'", (char*)NULL);1534 "\": should be one of: 'scale', 'scalar', 'vmag', 'ccolor'", (char*)NULL); 1543 1535 return TCL_ERROR; 1544 1536 } … … 1735 1727 if (str[0] == 's' && strcmp(str, "scalar") == 0) { 1736 1728 mode = Glyphs::SCALE_BY_SCALAR; 1737 } else if (str[0] == 'v' && strcmp(str, "v ector") == 0) {1738 mode = Glyphs::SCALE_BY_VECTOR ;1739 } else if (str[0] == 'v' && strcmp(str, "v ector_comp") == 0) {1729 } else if (str[0] == 'v' && strcmp(str, "vmag") == 0) { 1730 mode = Glyphs::SCALE_BY_VECTOR_MAGNITUDE; 1731 } else if (str[0] == 'v' && strcmp(str, "vcomp") == 0) { 1740 1732 mode = Glyphs::SCALE_BY_VECTOR_COMPONENTS; 1741 1733 } else if (str[0] == 'o' && strcmp(str, "off") == 0) { … … 1743 1735 } else { 1744 1736 Tcl_AppendResult(interp, "bad scaling mode option \"", str, 1745 "\": should be one of: 'scalar', 'v ector', 'vector_comp', 'off'", (char*)NULL);1737 "\": should be one of: 'scalar', 'vmag', 'vcomp', 'off'", (char*)NULL); 1746 1738 return TCL_ERROR; 1747 1739 } … … 1774 1766 } else if (shapeOpt[0] == 'i' && strcmp(shapeOpt, "icosahedron") == 0) { 1775 1767 shape = Glyphs::ICOSAHEDRON; 1768 } else if (shapeOpt[0] == 'l' && strcmp(shapeOpt, "line") == 0) { 1769 shape = Glyphs::LINE; 1776 1770 } else if (shapeOpt[0] == 'o' && strcmp(shapeOpt, "octahedron") == 0) { 1777 1771 shape = Glyphs::OCTAHEDRON; … … 1782 1776 } else { 1783 1777 Tcl_AppendResult(interp, "bad shape option \"", shapeOpt, 1784 "\": should be one of: 'arrow', 'cone', 'cube', 'cylinder', 'dodecahedron', 'icosahedron', ' octahedron', 'sphere', 'tetrahedron'", (char*)NULL);1778 "\": should be one of: 'arrow', 'cone', 'cube', 'cylinder', 'dodecahedron', 'icosahedron', 'line', 'octahedron', 'sphere', 'tetrahedron'", (char*)NULL); 1785 1779 return TCL_ERROR; 1786 1780 } … … 1888 1882 if (objc == 5) { 1889 1883 const char *name = Tcl_GetString(objv[4]); 1890 g_renderer->addHeightMap(name); 1891 g_renderer->setHeightMapContourList(name, contourList); 1892 } else { 1893 g_renderer->addHeightMap("all"); 1894 g_renderer->setHeightMapContourList("all", contourList); 1884 g_renderer->addHeightMap(name, contourList); 1885 } else { 1886 g_renderer->addHeightMap("all", contourList); 1895 1887 } 1896 1888 return TCL_OK; … … 1907 1899 if (objc == 5) { 1908 1900 const char *name = Tcl_GetString(objv[4]); 1909 g_renderer->addHeightMap(name); 1910 g_renderer->setHeightMapContours(name, numContours); 1911 } else { 1912 g_renderer->addHeightMap("all"); 1913 g_renderer->setHeightMapContours("all", numContours); 1901 g_renderer->addHeightMap(name, numContours); 1902 } else { 1903 g_renderer->addHeightMap("all", numContours); 1914 1904 } 1915 1905 return TCL_OK; … … 4429 4419 iov[1].iov_len = nBytes; 4430 4420 iov[2].iov_base = (char *)"\n"; 4431 iov[2].iov_len = 1;4421 iov[2].iov_len = strlen((char *)iov[2].iov_base); 4432 4422 if (writev(fdOut, iov, 3) < 0) { 4433 4423 ERROR("write failed: %s", strerror(errno)); -
trunk/packages/vizservers/vtkvis/protocol.txt
r2393 r2402 128 128 glyphs ccolor r g b <?datasetName?> 129 129 glyphs colormap <colorMapName> <?dataSetName?> 130 glyphs colormode <scale|scalar|v ector|ccolor> <?dataSetName?>130 glyphs colormode <scale|scalar|vmag|ccolor> <?dataSetName?> 131 131 Set the color mode: color by scale, scalar field or 132 132 vector magnitude -- uses the current color map … … 142 142 glyphs pos <x> <y> <z> <?dataSetName?> 143 143 glyphs scale <sx> <sy> <sz> <?dataSetName?> 144 glyphs shape <arrow|cone|cube|cylinder|dodecahedron|icosahedron| octahedron|sphere|tetrahedron> <?datasetName?>145 glyphs smode <scalar|v ector|vector_comp|off> <?dataSetName?>144 glyphs shape <arrow|cone|cube|cylinder|dodecahedron|icosahedron|line|octahedron|sphere|tetrahedron> <?datasetName?> 145 glyphs smode <scalar|vmag|vcomp|off> <?dataSetName?> 146 146 Set the scaling mode: use the scalar field, vector magnitude 147 147 (uniform scale), vector components, or disable scaling
Note: See TracChangeset
for help on using the changeset viewer.