Changeset 2423
- Timestamp:
- Aug 27, 2011, 1:59:23 AM (13 years ago)
- Location:
- trunk/packages/vizservers/vtkvis
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/vtkvis/Makefile.in
r2402 r2423 47 47 DEBUG = #yes 48 48 TRACE = #yes 49 USE_CUSTOM_AXES = #yes49 USE_CUSTOM_AXES = yes 50 50 USE_GPU_RAYCASTING = yes 51 51 USE_OFFSCREEN_RENDERING = yes -
trunk/packages/vizservers/vtkvis/RpContour2D.cpp
r2402 r2423 13 13 #include <vtkCellDataToPointData.h> 14 14 #include <vtkContourFilter.h> 15 #include <vtkStripper.h> 15 16 #include <vtkPolyDataMapper.h> 16 17 #include <vtkUnstructuredGrid.h> 17 18 #include <vtkProperty.h> 19 #include <vtkTransform.h> 18 20 #include <vtkDelaunay2D.h> 19 21 #include <vtkDelaunay3D.h> … … 107 109 pd->GetNumberOfStrips() == 0) { 108 110 // DataSet is a point cloud 109 if (_dataSet->is2D()) { 111 DataSet::PrincipalPlane plane; 112 double offset; 113 if (_dataSet->is2D(&plane, &offset)) { 110 114 vtkSmartPointer<vtkDelaunay2D> mesher = vtkSmartPointer<vtkDelaunay2D>::New(); 115 if (plane == DataSet::PLANE_ZY) { 116 vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New(); 117 trans->RotateWXYZ(90, 0, 1, 0); 118 if (offset != 0.0) { 119 trans->Translate(-offset, 0, 0); 120 } 121 mesher->SetTransform(trans); 122 } else if (plane == DataSet::PLANE_XZ) { 123 vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New(); 124 trans->RotateWXYZ(-90, 1, 0, 0); 125 if (offset != 0.0) { 126 trans->Translate(0, -offset, 0); 127 } 128 mesher->SetTransform(trans); 129 } else if (offset != 0.0) { 130 // XY with Z offset 131 vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New(); 132 trans->Translate(0, 0, -offset); 133 mesher->SetTransform(trans); 134 } 111 135 mesher->SetInput(pd); 112 136 _contourFilter->SetInputConnection(mesher->GetOutputPort()); … … 154 178 _contourMapper = vtkSmartPointer<vtkPolyDataMapper>::New(); 155 179 _contourMapper->SetResolveCoincidentTopologyToPolygonOffset(); 156 _contourMapper->SetInputConnection(_contourFilter->GetOutputPort()); 180 vtkSmartPointer<vtkStripper> stripper = vtkSmartPointer<vtkStripper>::New(); 181 stripper->SetInputConnection(_contourFilter->GetOutputPort()); 182 _contourMapper->SetInputConnection(stripper->GetOutputPort()); 157 183 getActor()->SetMapper(_contourMapper); 158 184 } -
trunk/packages/vizservers/vtkvis/RpGlyphs.h
r2402 r2423 27 27 * \brief Oriented and scaled 3D glyph shapes 28 28 * 29 * The DataSet must be a PolyData point set 30 * with vectors and/or scalars 29 * The DataSet must have vectors and/or scalars 31 30 */ 32 31 class Glyphs : public VtkGraphicsObject { -
trunk/packages/vizservers/vtkvis/RpHeightMap.cpp
r2402 r2423 18 18 #include <vtkImageData.h> 19 19 #include <vtkLookupTable.h> 20 #include <vtkTransform.h> 20 21 #include <vtkDelaunay2D.h> 21 22 #include <vtkDelaunay3D.h> … … 25 26 #include <vtkDataSetSurfaceFilter.h> 26 27 #include <vtkContourFilter.h> 28 #include <vtkStripper.h> 27 29 #include <vtkWarpScalar.h> 28 30 #include <vtkPropAssembly.h> … … 35 37 #define MESH_POINT_CLOUDS 36 38 37 HeightMap::HeightMap(int numContours ) :39 HeightMap::HeightMap(int numContours, double heightScale) : 38 40 VtkGraphicsObject(), 39 41 _numContours(numContours), 40 42 _colorMap(NULL), 41 43 _contourEdgeWidth(1.0), 42 _warpScale( 1.0),44 _warpScale(heightScale), 43 45 _sliceAxis(Z_AXIS), 44 46 _pipelineInitialized(false) … … 49 51 } 50 52 51 HeightMap::HeightMap(const std::vector<double>& contours ) :53 HeightMap::HeightMap(const std::vector<double>& contours, double heightScale) : 52 54 VtkGraphicsObject(), 53 55 _numContours(contours.size()), … … 55 57 _colorMap(NULL), 56 58 _contourEdgeWidth(1.0), 57 _warpScale( 1.0),59 _warpScale(heightScale), 58 60 _sliceAxis(Z_AXIS), 59 61 _pipelineInitialized(false) … … 194 196 pd->GetNumberOfStrips() == 0) { 195 197 // DataSet is a point cloud 196 if (_dataSet->is2D()) { 198 DataSet::PrincipalPlane plane; 199 double offset; 200 if (_dataSet->is2D(&plane, &offset)) { 197 201 #ifdef MESH_POINT_CLOUDS 198 202 // Result of Delaunay2D is a PolyData 199 203 vtkSmartPointer<vtkDelaunay2D> mesher = vtkSmartPointer<vtkDelaunay2D>::New(); 204 if (plane == DataSet::PLANE_ZY) { 205 vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New(); 206 trans->RotateWXYZ(90, 0, 1, 0); 207 if (offset != 0.0) { 208 trans->Translate(-offset, 0, 0); 209 } 210 mesher->SetTransform(trans); 211 _sliceAxis = X_AXIS; 212 } else if (plane == DataSet::PLANE_XZ) { 213 vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New(); 214 trans->RotateWXYZ(-90, 1, 0, 0); 215 if (offset != 0.0) { 216 trans->Translate(0, -offset, 0); 217 } 218 mesher->SetTransform(trans); 219 _sliceAxis = Y_AXIS; 220 } else if (offset != 0.0) { 221 // XY with Z offset 222 vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New(); 223 trans->Translate(0, 0, -offset); 224 mesher->SetTransform(trans); 225 } 200 226 mesher->SetInput(pd); 201 227 vtkAlgorithmOutput *warpOutput = initWarp(mesher->GetOutputPort()); … … 205 231 if (_pointSplatter == NULL) 206 232 _pointSplatter = vtkSmartPointer<vtkGaussianSplatter>::New(); 233 if (_volumeSlicer == NULL) 234 _volumeSlicer = vtkSmartPointer<vtkExtractVOI>::New(); 207 235 _pointSplatter->SetInput(pd); 208 236 int dims[3]; 209 237 _pointSplatter->GetSampleDimensions(dims); 210 238 TRACE("Sample dims: %d %d %d", dims[0], dims[1], dims[2]); 211 dims[2] = 3; 239 if (plane == DataSet::PLANE_ZY) { 240 dims[0] = 3; 241 _volumeSlicer->SetVOI(1, 1, 0, dims[1]-1, 0, dims[1]-1); 242 _sliceAxis = X_AXIS; 243 } else if (plane == DataSet::PLANE_XZ) { 244 dims[1] = 3; 245 _volumeSlicer->SetVOI(0, dims[0]-1, 1, 1, 0, dims[2]-1); 246 _sliceAxis = Y_AXIS; 247 } else { 248 dims[2] = 3; 249 _volumeSlicer->SetVOI(0, dims[0]-1, 0, dims[1]-1, 1, 1); 250 } 212 251 _pointSplatter->SetSampleDimensions(dims); 213 252 double bounds[6]; … … 218 257 bounds[2], bounds[3], 219 258 bounds[4], bounds[5]); 220 if (_volumeSlicer == NULL)221 _volumeSlicer = vtkSmartPointer<vtkExtractVOI>::New();222 259 _volumeSlicer->SetInputConnection(_pointSplatter->GetOutputPort()); 223 _volumeSlicer->SetVOI(0, dims[0]-1, 0, dims[1]-1, 1, 1);224 260 _volumeSlicer->SetSampleRate(1, 1, 1); 225 261 vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New(); … … 324 360 _probeFilter->SetSource(ds); 325 361 vtkSmartPointer<vtkImageData> imageData = vtkSmartPointer<vtkImageData>::New(); 362 DataSet::PrincipalPlane plane; 363 double offset; 326 364 int xdim = 256; 327 365 int ydim = 256; 328 366 int zdim = 1; 367 double origin[3]; 368 double spacing[3]; 369 origin[0] = bounds[0]; 370 origin[1] = bounds[2]; 371 origin[2] = bounds[4] + (bounds[5]-bounds[4])/2.; 372 spacing[0] = (bounds[1]-bounds[0])/((double)(xdim-1)); 373 spacing[1] = (bounds[3]-bounds[2])/((double)(ydim-1)); 374 spacing[2] = 0; 375 if (_dataSet->is2D(&plane, &offset)) { 376 if (plane == DataSet::PLANE_ZY) { 377 xdim = 1; 378 zdim = 256; 379 origin[2] = bounds[4]; 380 spacing[0] = 0; 381 spacing[2] = (bounds[5]-bounds[4])/((double)(zdim-1)); 382 _sliceAxis = X_AXIS; 383 } else if (plane == DataSet::PLANE_XZ) { 384 ydim = 1; 385 zdim = 256; 386 origin[2] = bounds[4]; 387 spacing[1] = 0; 388 spacing[2] = (bounds[5]-bounds[4])/((double)(zdim-1)); 389 _sliceAxis = Y_AXIS; 390 } 391 } 329 392 imageData->SetDimensions(xdim, ydim, zdim); 330 imageData->SetOrigin(bounds[0], bounds[2], bounds[4] + (bounds[5]-bounds[4])/2.); 331 imageData->SetSpacing((bounds[1]-bounds[0])/((double)(xdim-1)), 332 (bounds[3]-bounds[2])/((double)(ydim-1)), 333 0); 393 imageData->SetOrigin(origin); 394 imageData->SetSpacing(spacing); 334 395 _probeFilter->SetInput(imageData); 335 396 gf->SetInputConnection(_probeFilter->GetOutputPort()); … … 377 438 _contourMapper = vtkSmartPointer<vtkPolyDataMapper>::New(); 378 439 _contourMapper->SetResolveCoincidentTopologyToPolygonOffset(); 379 _contourMapper->SetInputConnection(_contourFilter->GetOutputPort()); 440 vtkSmartPointer<vtkStripper> stripper = vtkSmartPointer<vtkStripper>::New(); 441 stripper->SetInputConnection(_contourFilter->GetOutputPort()); 442 _contourMapper->SetInputConnection(stripper->GetOutputPort()); 380 443 _contourActor->SetMapper(_contourMapper); 381 444 } … … 582 645 break; 583 646 case Y_AXIS: 584 voi[2] = voi[3] = (int)((dims[1]-1) * ratio);585 647 voi[0] = 0; 586 648 voi[1] = dims[0]-1; 649 voi[2] = voi[3] = (int)((dims[1]-1) * ratio); 587 650 voi[4] = 0; 588 651 voi[5] = dims[2]-1; 589 652 break; 590 653 case Z_AXIS: 591 voi[4] = voi[5] = (int)((dims[2]-1) * ratio);592 654 voi[0] = 0; 593 655 voi[1] = dims[0]-1; 594 656 voi[2] = 0; 595 657 voi[3] = dims[1]-1; 658 voi[4] = voi[5] = (int)((dims[2]-1) * ratio); 596 659 break; 597 660 default: … … 666 729 * Will override any existing contours 667 730 */ 668 void HeightMap::set Contours(int numContours)731 void HeightMap::setNumContours(int numContours) 669 732 { 670 733 _contours.clear(); … … 724 787 725 788 /** 789 * \brief Turn on/off rendering of colormaped surface 790 */ 791 void HeightMap::setContourSurfaceVisibility(bool state) 792 { 793 if (_dsActor != NULL) { 794 _dsActor->SetVisibility((state ? 1 : 0)); 795 } 796 } 797 798 /** 726 799 * \brief Turn on/off rendering of contour isolines 727 800 */ 728 void HeightMap::setContour Visibility(bool state)801 void HeightMap::setContourLineVisibility(bool state) 729 802 { 730 803 if (_contourActor != NULL) { -
trunk/packages/vizservers/vtkvis/RpHeightMap.h
r2402 r2423 42 42 }; 43 43 44 HeightMap(int numContours );44 HeightMap(int numContours, double heightScale = 1.0); 45 45 46 HeightMap(const std::vector<double>& contours );46 HeightMap(const std::vector<double>& contours, double heightScale = 1.0); 47 47 48 48 virtual ~HeightMap(); … … 73 73 void setHeightScale(double scale); 74 74 75 void setContours(int numContours); 76 77 void setContours(int numContours, double range[2]); 75 void setNumContours(int numContours); 78 76 79 77 void setContourList(const std::vector<double>& contours); … … 100 98 double vectorComponentRange[3][2]); 101 99 102 void setContourVisibility(bool state); 100 void setContourLineVisibility(bool state); 101 102 void setContourSurfaceVisibility(bool state); 103 103 104 104 void setContourEdgeColor(float color[3]); -
trunk/packages/vizservers/vtkvis/RpPolyData.cpp
r2402 r2423 14 14 #include <vtkActor.h> 15 15 #include <vtkProperty.h> 16 #include <vtkTransform.h> 16 17 #include <vtkDelaunay2D.h> 17 18 #include <vtkDelaunay3D.h> … … 78 79 vtkPolyData *pd = vtkPolyData::SafeDownCast(ds); 79 80 if (pd) { 80 TRACE("Verts: %d Lines: %d Polys: %d Strips: %d", 81 pd->GetNumberOfVerts(), 82 pd->GetNumberOfLines(), 83 pd->GetNumberOfPolys(), 84 pd->GetNumberOfStrips()); 81 TRACE("Points: %d Verts: %d Lines: %d Polys: %d Strips: %d", 82 pd->GetNumberOfPoints(), 83 pd->GetNumberOfVerts(), 84 pd->GetNumberOfLines(), 85 pd->GetNumberOfPolys(), 86 pd->GetNumberOfStrips()); 85 87 // DataSet is a vtkPolyData 86 88 if (pd->GetNumberOfLines() == 0 && … … 88 90 pd->GetNumberOfStrips() == 0) { 89 91 // DataSet is a point cloud 90 if (_dataSet->is2D()) { 92 DataSet::PrincipalPlane plane; 93 double offset; 94 if (_dataSet->numDimensions() < 2 || pd->GetNumberOfPoints() < 3) { 95 // 0D or 1D or not enough points to mesh 96 _pdMapper->SetInput(pd); 97 } else if (_dataSet->is2D(&plane, &offset)) { 91 98 vtkSmartPointer<vtkDelaunay2D> mesher = vtkSmartPointer<vtkDelaunay2D>::New(); 99 if (plane == DataSet::PLANE_ZY) { 100 vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New(); 101 trans->RotateWXYZ(90, 0, 1, 0); 102 if (offset != 0.0) { 103 trans->Translate(-offset, 0, 0); 104 } 105 mesher->SetTransform(trans); 106 } else if (plane == DataSet::PLANE_XZ) { 107 vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New(); 108 trans->RotateWXYZ(-90, 1, 0, 0); 109 if (offset != 0.0) { 110 trans->Translate(0, -offset, 0); 111 } 112 mesher->SetTransform(trans); 113 } else if (offset != 0.0) { 114 // XY with Z offset 115 vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New(); 116 trans->Translate(0, 0, -offset); 117 mesher->SetTransform(trans); 118 } 92 119 mesher->SetInput(pd); 93 120 mesher->ReleaseDataFlagOn(); 94 _pdMapper->SetInputConnection(mesher->GetOutputPort());95 #if defined(DEBUG) && defined(WANT_TRACE)96 121 mesher->Update(); 97 122 vtkPolyData *outpd = mesher->GetOutput(); … … 101 126 outpd->GetNumberOfPolys(), 102 127 outpd->GetNumberOfStrips()); 103 #endif 128 if (outpd->GetNumberOfPolys() == 0) { 129 WARN("Delaunay2D mesher failed"); 130 _pdMapper->SetInput(pd); 131 } else { 132 _pdMapper->SetInputConnection(mesher->GetOutputPort()); 133 } 104 134 } else { 105 135 vtkSmartPointer<vtkDelaunay3D> mesher = vtkSmartPointer<vtkDelaunay3D>::New(); 106 136 mesher->SetInput(pd); 107 137 mesher->ReleaseDataFlagOn(); 108 // Delaunay3D returns an UnstructuredGrid, so feed it through a surface filter 109 // to get the grid boundary as a PolyData 110 vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New(); 111 gf->UseStripsOn(); 112 gf->SetInputConnection(mesher->GetOutputPort()); 113 gf->ReleaseDataFlagOn(); 114 _pdMapper->SetInputConnection(gf->GetOutputPort()); 115 } 138 mesher->Update(); 139 vtkUnstructuredGrid *grid = mesher->GetOutput(); 140 TRACE("Delaunay3D Cells: %d", 141 grid->GetNumberOfCells()); 142 if (grid->GetNumberOfCells() == 0) { 143 WARN("Delaunay3D mesher failed"); 144 _pdMapper->SetInput(pd); 145 } else { 146 // Delaunay3D returns an UnstructuredGrid, so feed it 147 // through a surface filter to get the grid boundary 148 // as a PolyData 149 vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New(); 150 gf->UseStripsOn(); 151 gf->SetInputConnection(mesher->GetOutputPort()); 152 gf->ReleaseDataFlagOn(); 153 _pdMapper->SetInputConnection(gf->GetOutputPort()); 154 } 155 } 116 156 } else { 117 157 // DataSet is a vtkPolyData with lines and/or polygons -
trunk/packages/vizservers/vtkvis/RpPolyData.h
r2328 r2423 22 22 * \brief VTK Mesh (Polygon data) 23 23 * 24 * Th e DataSet must be a PolyData object24 * This class creates a boundary mesh of a DataSet 25 25 */ 26 26 class PolyData : public VtkGraphicsObject { -
trunk/packages/vizservers/vtkvis/RpPseudoColor.cpp
r2402 r2423 15 15 #include <vtkImageData.h> 16 16 #include <vtkLookupTable.h> 17 #include <vtkTransform.h> 17 18 #include <vtkDelaunay2D.h> 18 19 #include <vtkDelaunay3D.h> … … 84 85 pd->GetNumberOfStrips() == 0) { 85 86 // DataSet is a point cloud 86 if (_dataSet->is2D()) { 87 DataSet::PrincipalPlane plane; 88 double offset; 89 if (_dataSet->is2D(&plane, &offset)) { 87 90 #ifdef MESH_POINT_CLOUDS 88 91 vtkSmartPointer<vtkDelaunay2D> mesher = vtkSmartPointer<vtkDelaunay2D>::New(); 92 if (plane == DataSet::PLANE_ZY) { 93 vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New(); 94 trans->RotateWXYZ(90, 0, 1, 0); 95 if (offset != 0.0) { 96 trans->Translate(-offset, 0, 0); 97 } 98 mesher->SetTransform(trans); 99 } else if (plane == DataSet::PLANE_XZ) { 100 vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New(); 101 trans->RotateWXYZ(-90, 1, 0, 0); 102 if (offset != 0.0) { 103 trans->Translate(0, -offset, 0); 104 } 105 mesher->SetTransform(trans); 106 } else if (offset != 0.0) { 107 // XY with Z offset 108 vtkSmartPointer<vtkTransform> trans = vtkSmartPointer<vtkTransform>::New(); 109 trans->Translate(0, 0, -offset); 110 mesher->SetTransform(trans); 111 } 89 112 mesher->SetInput(pd); 90 vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New(); 91 gf->SetInputConnection(mesher->GetOutputPort()); 92 _dsMapper->SetInputConnection(gf->GetOutputPort()); 113 _dsMapper->SetInputConnection(mesher->GetOutputPort()); 93 114 #else 94 115 vtkSmartPointer<vtkGaussianSplatter> splatter = vtkSmartPointer<vtkGaussianSplatter>::New(); 116 vtkSmartPointer<vtkExtractVOI> slicer = vtkSmartPointer<vtkExtractVOI>::New(); 95 117 splatter->SetInput(pd); 96 118 int dims[3]; 97 119 splatter->GetSampleDimensions(dims); 98 120 TRACE("Sample dims: %d %d %d", dims[0], dims[1], dims[2]); 99 dims[2] = 3; 121 if (plane == DataSet::PLANE_ZY) { 122 dims[0] = 3; 123 slicer->SetVOI(1, 1, 0, dims[1]-1, 0, dims[1]-1); 124 } else if (plane == DataSet::PLANE_XZ) { 125 dims[1] = 3; 126 slicer->SetVOI(0, dims[0]-1, 1, 1, 0, dims[2]-1); 127 } else { 128 dims[2] = 3; 129 slicer->SetVOI(0, dims[0]-1, 0, dims[1]-1, 1, 1); 130 } 100 131 splatter->SetSampleDimensions(dims); 101 132 double bounds[6]; … … 106 137 bounds[2], bounds[3], 107 138 bounds[4], bounds[5]); 108 vtkSmartPointer<vtkExtractVOI> slicer = vtkSmartPointer<vtkExtractVOI>::New();109 139 slicer->SetInputConnection(splatter->GetOutputPort()); 110 slicer->SetVOI(0, dims[0]-1, 0, dims[1]-1, 1, 1);111 140 slicer->SetSampleRate(1, 1, 1); 112 141 vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New(); -
trunk/packages/vizservers/vtkvis/RpPseudoColor.h
r2402 r2423 23 23 /** 24 24 * \brief Color-mapped plot of data set 25 *26 * Currently the DataSet must be image data (2D uniform grid)27 25 */ 28 26 class PseudoColor : public VtkGraphicsObject { -
trunk/packages/vizservers/vtkvis/RpVtkDataSet.cpp
r2404 r2423 6 6 */ 7 7 8 #include <cassert> 8 9 #include <cstring> 9 10 #include <cfloat> … … 162 163 } 163 164 165 void DataSet::setDefaultArrays() 166 { 167 if (_dataSet->GetPointData() != NULL && 168 _dataSet->GetPointData()->GetScalars() == NULL && 169 _dataSet->GetPointData()->GetNumberOfArrays() > 0) { 170 for (int i = 0; i < _dataSet->GetPointData()->GetNumberOfArrays(); i++) { 171 if (_dataSet->GetPointData()->GetArray(i)->GetNumberOfComponents() == 1) { 172 TRACE("Setting point scalars to '%s'", _dataSet->GetPointData()->GetArrayName(i)); 173 _dataSet->GetPointData()->SetActiveScalars(_dataSet->GetPointData()->GetArrayName(i)); 174 break; 175 } 176 } 177 } 178 if (_dataSet->GetPointData() != NULL && 179 _dataSet->GetPointData()->GetVectors() == NULL && 180 _dataSet->GetPointData()->GetNumberOfArrays() > 0) { 181 for (int i = 0; i < _dataSet->GetPointData()->GetNumberOfArrays(); i++) { 182 if (_dataSet->GetPointData()->GetArray(i)->GetNumberOfComponents() == 3) { 183 TRACE("Setting point vectors to '%s'", _dataSet->GetPointData()->GetArrayName(i)); 184 _dataSet->GetPointData()->SetActiveVectors(_dataSet->GetPointData()->GetArrayName(i)); 185 break; 186 } 187 } 188 } 189 if (_dataSet->GetCellData() != NULL && 190 _dataSet->GetCellData()->GetScalars() == NULL && 191 _dataSet->GetCellData()->GetNumberOfArrays() > 0) { 192 for (int i = 0; i < _dataSet->GetCellData()->GetNumberOfArrays(); i++) { 193 if (_dataSet->GetCellData()->GetArray(i)->GetNumberOfComponents() == 1) { 194 TRACE("Setting cell scalars to '%s'", _dataSet->GetCellData()->GetArrayName(i)); 195 _dataSet->GetCellData()->SetActiveScalars(_dataSet->GetCellData()->GetArrayName(i)); 196 break; 197 } 198 } 199 } 200 if (_dataSet->GetCellData() != NULL && 201 _dataSet->GetCellData()->GetVectors() == NULL && 202 _dataSet->GetCellData()->GetNumberOfArrays() > 0) { 203 for (int i = 0; i < _dataSet->GetCellData()->GetNumberOfArrays(); i++) { 204 if (_dataSet->GetCellData()->GetArray(i)->GetNumberOfComponents() == 3) { 205 TRACE("Setting cell vectors to '%s'", _dataSet->GetCellData()->GetArrayName(i)); 206 _dataSet->GetCellData()->SetActiveVectors(_dataSet->GetCellData()->GetArrayName(i)); 207 break; 208 } 209 } 210 } 211 } 212 164 213 /** 165 214 * \brief Read dataset using supplied reader … … 183 232 ERROR("No lookup table should be specified in DataSets"); 184 233 } 234 235 setDefaultArrays(); 185 236 186 237 #ifdef WANT_TRACE … … 205 256 ERROR("No lookup table should be specified in DataSets"); 206 257 } 258 259 setDefaultArrays(); 207 260 208 261 #ifdef WANT_TRACE … … 250 303 * \brief Does DataSet lie in the XY plane (z = 0) 251 304 */ 252 bool DataSet::is 2D() const305 bool DataSet::isXY() const 253 306 { 254 307 double bounds[6]; 255 308 getBounds(bounds); 256 309 return (bounds[4] == 0. && bounds[4] == bounds[5]); 310 } 311 312 /** 313 * \brief Returns the dimensionality of the AABB 314 */ 315 int DataSet::numDimensions() const 316 { 317 double bounds[6]; 318 getBounds(bounds); 319 int numDims = 0; 320 if (bounds[0] != bounds[1]) 321 numDims++; 322 if (bounds[2] != bounds[3]) 323 numDims++; 324 if (bounds[4] != bounds[5]) 325 numDims++; 326 327 return numDims; 328 } 329 330 /** 331 * \brief Determines if DataSet lies in a principal axis plane 332 * and if so, returns the plane normal and offset from origin 333 */ 334 bool DataSet::is2D(DataSet::PrincipalPlane *plane, double *offset) const 335 { 336 double bounds[6]; 337 getBounds(bounds); 338 if (bounds[4] == bounds[5]) { 339 // Z = 0, XY plane 340 if (plane != NULL) { 341 *plane = PLANE_XY; 342 } 343 if (offset != NULL) 344 *offset = bounds[4]; 345 return true; 346 } else if (bounds[0] == bounds[1]) { 347 // X = 0, ZY plane 348 if (plane != NULL) { 349 *plane = PLANE_ZY; 350 } 351 if (offset != NULL) 352 *offset = bounds[0]; 353 return true; 354 } else if (bounds[2] == bounds[3]) { 355 // Y = 0, XZ plane 356 if (plane != NULL) { 357 *plane = PLANE_XZ; 358 } 359 if (offset != NULL) 360 *offset = bounds[2]; 361 return true; 362 } 363 return false; 364 } 365 366 /** 367 * \brief Determines a principal plane with the 368 * largest two dimensions of the AABB 369 */ 370 DataSet::PrincipalPlane DataSet::principalPlane() const 371 { 372 double bounds[6]; 373 getBounds(bounds); 374 double xlen = bounds[1] - bounds[0]; 375 double ylen = bounds[3] - bounds[2]; 376 double zlen = bounds[5] - bounds[4]; 377 if (zlen <= xlen && zlen <= ylen) { 378 return PLANE_XY; 379 } else if (xlen <= ylen && xlen <= zlen) { 380 return PLANE_ZY; 381 } else { 382 return PLANE_XZ; 383 } 257 384 } 258 385 … … 324 451 void DataSet::getScalarRange(double minmax[2]) const 325 452 { 326 _dataSet->GetScalarRange(minmax); 453 if (_dataSet == NULL) 454 return; 455 if (_dataSet->GetPointData() != NULL && 456 _dataSet->GetPointData()->GetScalars() != NULL) { 457 _dataSet->GetPointData()->GetScalars()->GetRange(minmax, -1); 458 } else if (_dataSet->GetCellData() != NULL && 459 _dataSet->GetCellData()->GetScalars() != NULL) { 460 _dataSet->GetCellData()->GetScalars()->GetRange(minmax, -1); 461 } 327 462 } 328 463 … … 419 554 * \return the value of the nearest point or 0 if no scalar data available 420 555 */ 421 double DataSet::getDataValue(double x, double y, double z) const556 bool DataSet::getScalarValue(double x, double y, double z, double *value) const 422 557 { 423 558 if (_dataSet == NULL) 424 return 0;559 return false; 425 560 if (_dataSet->GetPointData() == NULL || 426 561 _dataSet->GetPointData()->GetScalars() == NULL) { 427 return 0.0;562 return false; 428 563 } 429 564 vtkIdType pt = _dataSet->FindPoint(x, y, z); 430 return _dataSet->GetPointData()->GetScalars()->GetComponent(pt, 0); 431 } 565 if (pt < 0) 566 return false; 567 *value = _dataSet->GetPointData()->GetScalars()->GetComponent(pt, 0); 568 return true; 569 } 570 571 /** 572 * \brief Get nearest vector data value given world coordinates x,y,z 573 * 574 * Note: no interpolation is performed on data 575 * 576 * \param[in] x World x coordinate to probe 577 * \param[in] y World y coordinate to probe 578 * \param[in] z World z coordinate to probe 579 * \param[out] vector On success, contains the data values 580 * \return boolean indicating success or failure 581 */ 582 bool DataSet::getVectorValue(double x, double y, double z, double vector[3]) const 583 { 584 if (_dataSet == NULL) 585 return false; 586 if (_dataSet->GetPointData() == NULL || 587 _dataSet->GetPointData()->GetVectors() == NULL) { 588 return false; 589 } 590 vtkIdType pt = _dataSet->FindPoint(x, y, z); 591 if (pt < 0) 592 return false; 593 assert(_dataSet->GetPointData()->GetVectors()->GetNumberOfComponents() == 3); 594 _dataSet->GetPointData()->GetVectors()->GetTuple(pt, vector); 595 return true; 596 } -
trunk/packages/vizservers/vtkvis/RpVtkDataSet.h
r2404 r2423 24 24 class DataSet { 25 25 public: 26 enum PrincipalPlane { 27 PLANE_XY, 28 PLANE_ZY, 29 PLANE_XZ 30 }; 26 31 DataSet(const std::string& name); 27 32 virtual ~DataSet(); … … 37 42 vtkDataSet *copyData(vtkDataSet *ds); 38 43 39 bool is2D() const; 44 bool isXY() const; 45 46 int numDimensions() const; 47 48 bool is2D(PrincipalPlane *plane = NULL, double *offset = NULL) const; 49 50 PrincipalPlane principalPlane() const; 40 51 41 52 const std::string& getName() const; … … 59 70 void getCellSizeRange(double minmax[6], double *average) const; 60 71 61 double getDataValue(double x, double y, double z) const; 72 bool getScalarValue(double x, double y, double z, double *value) const; 73 74 bool getVectorValue(double x, double y, double z, double vector[3]) const; 62 75 63 76 void setVisibility(bool state); … … 67 80 private: 68 81 DataSet(); 82 83 void setDefaultArrays(); 69 84 void print() const; 70 85 -
trunk/packages/vizservers/vtkvis/RpVtkGraphicsObject.h
r2404 r2423 46 46 _opacity(1.0), 47 47 _edgeWidth(1.0f), 48 _pointSize(1.0f), 48 49 _lighting(true), 49 50 _cullFace(CULL_BACK), … … 607 608 * \brief Set pixel width of edges 608 609 * 609 * NOTE: May be a no-op if OpenGL implementation doesn't support fatlines610 * NOTE: May be a no-op if OpenGL implementation doesn't support wide lines 610 611 */ 611 612 virtual void setEdgeWidth(float width) … … 621 622 if (vtkActor::SafeDownCast(prop) != NULL) { 622 623 vtkActor::SafeDownCast(prop)->GetProperty()->SetLineWidth(width); 624 } 625 } 626 } 627 } 628 629 /** 630 * \brief Set point size 631 * 632 * NOTE: May be a no-op if OpenGL implementation doesn't support wide points 633 */ 634 virtual void setPointSize(float size) 635 { 636 _pointSize = size; 637 if (getActor() != NULL) { 638 getActor()->GetProperty()->SetPointSize(size); 639 } else if (getAssembly() != NULL) { 640 vtkProp3DCollection *props = getAssembly()->GetParts(); 641 vtkProp3D *prop; 642 props->InitTraversal(); 643 while ((prop = props->GetNextProp3D()) != NULL) { 644 if (vtkActor::SafeDownCast(prop) != NULL) { 645 vtkActor::SafeDownCast(prop)->GetProperty()->SetPointSize(size); 623 646 } 624 647 } … … 748 771 float _edgeColor[3]; 749 772 float _edgeWidth; 773 float _pointSize; 750 774 bool _lighting; 751 775 CullFace _cullFace; -
trunk/packages/vizservers/vtkvis/RpVtkRenderServer.cpp
r2381 r2423 70 70 if (g_renderer->getCameraMode() == Renderer::IMAGE) { 71 71 double xywh[4]; 72 g_renderer->get ScreenWorldCoords(xywh);72 g_renderer->getCameraZoomRegion(xywh); 73 73 std::ostringstream oss; 74 74 oss.precision(12); … … 77 77 << std::scientific 78 78 << xywh[0] << " " 79 << (xywh[1] + xywh[3])<< " "80 << (xywh[0] + xywh[2])<< " "81 << xywh[ 1] << "} -bytes";79 << xywh[1] << " " 80 << xywh[2] << " " 81 << xywh[3] << "} -bytes"; 82 82 83 83 #ifdef RENDER_TARGA -
trunk/packages/vizservers/vtkvis/RpVtkRenderer.cpp
r2404 r2423 24 24 #include <vtkCharArray.h> 25 25 #include <vtkAxisActor2D.h> 26 #include <vtkCubeAxesActor.h> 26 27 #ifdef USE_CUSTOM_AXES 27 #include <vtkRpCubeAxesActor2D.h>28 #include "vtkRpCubeAxesActor2D.h" 28 29 #else 29 #include <vtkCubeAxesActor.h>30 30 #include <vtkCubeAxesActor2D.h> 31 31 #endif … … 53 53 Renderer::Renderer() : 54 54 _needsRedraw(true), 55 _windowWidth(320), 56 _windowHeight(320), 55 _windowWidth(500), 56 _windowHeight(500), 57 _imgCameraPlane(PLANE_XY), 58 _imgCameraOffset(0), 57 59 _cameraZoomRatio(1), 58 60 _useCumulativeRange(true), … … 657 659 } 658 660 661 void Renderer::getDataSetNames(std::vector<std::string>& names) 662 { 663 names.clear(); 664 for (DataSetHashmap::iterator itr = _dataSets.begin(); 665 itr != _dataSets.end(); ++itr) { 666 names.push_back(itr->second->getName()); 667 } 668 } 669 659 670 /** 660 671 * \brief Find the DataSet for the given DataSetId key … … 850 861 _cubeAxesActor2D->GetXAxisActor2D()->AdjustLabelsOn(); 851 862 _cubeAxesActor2D->GetYAxisActor2D()->AdjustLabelsOn(); 863 _cubeAxesActor2D->GetZAxisActor2D()->AdjustLabelsOn(); 852 864 853 865 #ifdef USE_CUSTOM_AXES … … 869 881 _cubeAxesActor2D->GetYAxisActor2D()->GetLabelTextProperty()->ItalicOff(); 870 882 _cubeAxesActor2D->GetYAxisActor2D()->GetLabelTextProperty()->ShadowOff(); 883 884 //_cubeAxesActor2D->GetZAxisActor2D()->SizeFontRelativeToAxisOn(); 885 _cubeAxesActor2D->GetZAxisActor2D()->GetTitleTextProperty()->BoldOn(); 886 _cubeAxesActor2D->GetZAxisActor2D()->GetTitleTextProperty()->ItalicOff(); 887 _cubeAxesActor2D->GetZAxisActor2D()->GetTitleTextProperty()->ShadowOn(); 888 _cubeAxesActor2D->GetZAxisActor2D()->GetLabelTextProperty()->BoldOff(); 889 _cubeAxesActor2D->GetZAxisActor2D()->GetLabelTextProperty()->ItalicOff(); 890 _cubeAxesActor2D->GetZAxisActor2D()->GetLabelTextProperty()->ShadowOff(); 871 891 #else 872 892 _cubeAxesActor2D->GetAxisTitleTextProperty()->BoldOn(); … … 1459 1479 * \brief Create a new Contour2D and associate it with the named DataSet 1460 1480 */ 1461 voidRenderer::addContour2D(const DataSetId& id, int numContours)1481 bool Renderer::addContour2D(const DataSetId& id, int numContours) 1462 1482 { 1463 1483 DataSetHashmap::iterator itr; … … 1472 1492 if (itr == _dataSets.end()) { 1473 1493 ERROR("Unknown dataset %s", id.c_str()); 1474 return ;1494 return false; 1475 1495 } 1476 1496 … … 1485 1505 1486 1506 Contour2D *contour = new Contour2D(numContours); 1487 _contour2Ds[dsID] = contour; 1488 1507 1489 1508 contour->setDataSet(ds, 1490 1509 _useCumulativeRange, … … 1493 1512 _cumulativeVectorComponentRange); 1494 1513 1495 _renderer->AddViewProp(contour->getProp()); 1514 if (contour->getProp() == NULL) { 1515 delete contour; 1516 return false; 1517 } else { 1518 _renderer->AddViewProp(contour->getProp()); 1519 } 1520 1521 _contour2Ds[dsID] = contour; 1496 1522 } while (doAll && ++itr != _dataSets.end()); 1497 1523 1498 1524 initCamera(); 1499 1525 _needsRedraw = true; 1526 return true; 1500 1527 } 1501 1528 … … 1503 1530 * \brief Create a new Contour2D and associate it with the named DataSet 1504 1531 */ 1505 voidRenderer::addContour2D(const DataSetId& id, const std::vector<double>& contours)1532 bool Renderer::addContour2D(const DataSetId& id, const std::vector<double>& contours) 1506 1533 { 1507 1534 DataSetHashmap::iterator itr; … … 1516 1543 if (itr == _dataSets.end()) { 1517 1544 ERROR("Unknown dataset %s", id.c_str()); 1518 return ;1545 return false; 1519 1546 } 1520 1547 … … 1529 1556 1530 1557 Contour2D *contour = new Contour2D(contours); 1531 _contour2Ds[dsID] = contour;1532 1558 1533 1559 contour->setDataSet(ds, … … 1537 1563 _cumulativeVectorComponentRange); 1538 1564 1539 _renderer->AddViewProp(contour->getProp()); 1565 if (contour->getProp() == NULL) { 1566 delete contour; 1567 return false; 1568 } else { 1569 _renderer->AddViewProp(contour->getProp()); 1570 } 1571 1572 _contour2Ds[dsID] = contour; 1540 1573 } while (doAll && ++itr != _dataSets.end()); 1541 1574 1542 1575 initCamera(); 1543 1576 _needsRedraw = true; 1577 return true; 1544 1578 } 1545 1579 … … 1894 1928 * \brief Create a new Contour3D and associate it with the named DataSet 1895 1929 */ 1896 voidRenderer::addContour3D(const DataSetId& id, int numContours)1930 bool Renderer::addContour3D(const DataSetId& id, int numContours) 1897 1931 { 1898 1932 DataSetHashmap::iterator itr; … … 1907 1941 if (itr == _dataSets.end()) { 1908 1942 ERROR("Unknown dataset %s", id.c_str()); 1909 return ;1943 return false; 1910 1944 } 1911 1945 … … 1920 1954 1921 1955 Contour3D *contour = new Contour3D(numContours); 1922 _contour3Ds[dsID] = contour;1923 1956 1924 1957 contour->setDataSet(ds, … … 1928 1961 _cumulativeVectorComponentRange); 1929 1962 1930 _renderer->AddViewProp(contour->getProp()); 1963 if (contour->getProp() == NULL) { 1964 delete contour; 1965 return false; 1966 } else { 1967 _renderer->AddViewProp(contour->getProp()); 1968 } 1969 1970 _contour3Ds[dsID] = contour; 1931 1971 } while (doAll && ++itr != _dataSets.end()); 1932 1972 … … 1935 1975 initCamera(); 1936 1976 _needsRedraw = true; 1977 return true; 1937 1978 } 1938 1979 … … 1940 1981 * \brief Create a new Contour3D and associate it with the named DataSet 1941 1982 */ 1942 voidRenderer::addContour3D(const DataSetId& id,const std::vector<double>& contours)1983 bool Renderer::addContour3D(const DataSetId& id,const std::vector<double>& contours) 1943 1984 { 1944 1985 DataSetHashmap::iterator itr; … … 1953 1994 if (itr == _dataSets.end()) { 1954 1995 ERROR("Unknown dataset %s", id.c_str()); 1955 return ;1996 return false; 1956 1997 } 1957 1998 … … 1966 2007 1967 2008 Contour3D *contour = new Contour3D(contours); 1968 _contour3Ds[dsID] = contour;1969 2009 1970 2010 contour->setDataSet(ds, … … 1974 2014 _cumulativeVectorComponentRange); 1975 2015 1976 _renderer->AddViewProp(contour->getProp()); 2016 if (contour->getProp() == NULL) { 2017 delete contour; 2018 return false; 2019 } else { 2020 _renderer->AddViewProp(contour->getProp()); 2021 } 2022 2023 _contour3Ds[dsID] = contour; 1977 2024 } while (doAll && ++itr != _dataSets.end()); 1978 2025 … … 1981 2028 initCamera(); 1982 2029 _needsRedraw = true; 2030 return true; 1983 2031 } 1984 2032 … … 2453 2501 * \brief Create a new Glyphs and associate it with the named DataSet 2454 2502 */ 2455 voidRenderer::addGlyphs(const DataSetId& id, Glyphs::GlyphShape shape)2503 bool Renderer::addGlyphs(const DataSetId& id, Glyphs::GlyphShape shape) 2456 2504 { 2457 2505 DataSetHashmap::iterator itr; … … 2466 2514 if (itr == _dataSets.end()) { 2467 2515 ERROR("Unknown dataset %s", id.c_str()); 2468 return ;2516 return false; 2469 2517 } 2470 2518 … … 2479 2527 2480 2528 Glyphs *glyphs = new Glyphs(shape); 2481 _glyphs[dsID] = glyphs;2482 2529 2483 2530 glyphs->setDataSet(ds, … … 2487 2534 _cumulativeVectorComponentRange); 2488 2535 2489 _renderer->AddViewProp(glyphs->getProp()); 2536 if (glyphs->getProp() == NULL) { 2537 delete glyphs; 2538 return false; 2539 } else { 2540 _renderer->AddViewProp(glyphs->getProp()); 2541 } 2542 2543 _glyphs[dsID] = glyphs; 2490 2544 } while (doAll && ++itr != _dataSets.end()); 2491 2545 … … 2495 2549 2496 2550 _needsRedraw = true; 2551 return true; 2497 2552 } 2498 2553 … … 3022 3077 * \brief Create a new HeightMap and associate it with the named DataSet 3023 3078 */ 3024 void Renderer::addHeightMap(const DataSetId& id, int numContours)3079 bool Renderer::addHeightMap(const DataSetId& id, int numContours, double heightScale) 3025 3080 { 3026 3081 DataSetHashmap::iterator itr; … … 3035 3090 if (itr == _dataSets.end()) { 3036 3091 ERROR("Unknown dataset %s", id.c_str()); 3037 return ;3092 return false; 3038 3093 } 3039 3094 … … 3047 3102 } 3048 3103 3049 HeightMap *hmap = new HeightMap(numContours); 3050 _heightMaps[dsID] = hmap; 3104 HeightMap *hmap = new HeightMap(numContours, heightScale); 3051 3105 3052 3106 hmap->setDataSet(ds, … … 3056 3110 _cumulativeVectorComponentRange); 3057 3111 3058 _renderer->AddViewProp(hmap->getProp()); 3112 if (hmap->getProp() == NULL) { 3113 delete hmap; 3114 return false; 3115 } else { 3116 _renderer->AddViewProp(hmap->getProp()); 3117 } 3118 3119 _heightMaps[dsID] = hmap; 3059 3120 } while (doAll && ++itr != _dataSets.end()); 3060 3121 … … 3064 3125 3065 3126 _needsRedraw = true; 3127 return true; 3066 3128 } 3067 3129 … … 3069 3131 * \brief Create a new HeightMap and associate it with the named DataSet 3070 3132 */ 3071 void Renderer::addHeightMap(const DataSetId& id, const std::vector<double>& contours)3133 bool Renderer::addHeightMap(const DataSetId& id, const std::vector<double>& contours, double heightScale) 3072 3134 { 3073 3135 DataSetHashmap::iterator itr; … … 3082 3144 if (itr == _dataSets.end()) { 3083 3145 ERROR("Unknown dataset %s", id.c_str()); 3084 return ;3146 return false; 3085 3147 } 3086 3148 … … 3094 3156 } 3095 3157 3096 HeightMap *hmap = new HeightMap(contours); 3097 _heightMaps[dsID] = hmap; 3158 HeightMap *hmap = new HeightMap(contours, heightScale); 3098 3159 3099 3160 hmap->setDataSet(ds, … … 3103 3164 _cumulativeVectorComponentRange); 3104 3165 3105 _renderer->AddViewProp(hmap->getProp()); 3166 if (hmap->getProp() == NULL) { 3167 delete hmap; 3168 return false; 3169 } else { 3170 _renderer->AddViewProp(hmap->getProp()); 3171 } 3172 3173 _heightMaps[dsID] = hmap; 3106 3174 } while (doAll && ++itr != _dataSets.end()); 3107 3175 … … 3111 3179 3112 3180 _needsRedraw = true; 3181 return true; 3113 3182 } 3114 3183 … … 3368 3437 * \brief Set the number of equally spaced contour isolines for the given DataSet 3369 3438 */ 3370 void Renderer::setHeightMap Contours(const DataSetId& id, int numContours)3439 void Renderer::setHeightMapNumContours(const DataSetId& id, int numContours) 3371 3440 { 3372 3441 HeightMapHashmap::iterator itr; … … 3386 3455 3387 3456 do { 3388 itr->second->set Contours(numContours);3457 itr->second->setNumContours(numContours); 3389 3458 } while (doAll && ++itr != _heightMaps.end()); 3390 3459 … … 3468 3537 do { 3469 3538 itr->second->setVisibility(state); 3539 } while (doAll && ++itr != _heightMaps.end()); 3540 3541 _needsRedraw = true; 3542 } 3543 3544 /** 3545 * \brief Set wireframe rendering for the specified DataSet 3546 */ 3547 void Renderer::setHeightMapWireframe(const DataSetId& id, bool state) 3548 { 3549 HeightMapHashmap::iterator itr; 3550 3551 bool doAll = false; 3552 3553 if (id.compare("all") == 0) { 3554 itr = _heightMaps.begin(); 3555 doAll = true; 3556 } else { 3557 itr = _heightMaps.find(id); 3558 } 3559 if (itr == _heightMaps.end()) { 3560 ERROR("HeightMap not found: %s", id.c_str()); 3561 return; 3562 } 3563 3564 do { 3565 itr->second->setWireframe(state); 3470 3566 } while (doAll && ++itr != _heightMaps.end()); 3471 3567 … … 3560 3656 * \brief Turn on/off rendering height map contour lines for the given DataSet 3561 3657 */ 3562 void Renderer::setHeightMapContour Visibility(const DataSetId& id, bool state)3658 void Renderer::setHeightMapContourLineVisibility(const DataSetId& id, bool state) 3563 3659 { 3564 3660 HeightMapHashmap::iterator itr; … … 3578 3674 3579 3675 do { 3580 itr->second->setContourVisibility(state); 3676 itr->second->setContourLineVisibility(state); 3677 } while (doAll && ++itr != _heightMaps.end()); 3678 3679 _needsRedraw = true; 3680 } 3681 3682 /** 3683 * \brief Turn on/off rendering height map colormap surface for the given DataSet 3684 */ 3685 void Renderer::setHeightMapContourSurfaceVisibility(const DataSetId& id, bool state) 3686 { 3687 HeightMapHashmap::iterator itr; 3688 3689 bool doAll = false; 3690 3691 if (id.compare("all") == 0) { 3692 itr = _heightMaps.begin(); 3693 doAll = true; 3694 } else { 3695 itr = _heightMaps.find(id); 3696 } 3697 if (itr == _heightMaps.end()) { 3698 ERROR("HeightMap not found: %s", id.c_str()); 3699 return; 3700 } 3701 3702 do { 3703 itr->second->setContourSurfaceVisibility(state); 3581 3704 } while (doAll && ++itr != _heightMaps.end()); 3582 3705 … … 3670 3793 * \brief Create a new LIC and associate it with the named DataSet 3671 3794 */ 3672 voidRenderer::addLIC(const DataSetId& id)3795 bool Renderer::addLIC(const DataSetId& id) 3673 3796 { 3674 3797 DataSetHashmap::iterator itr; … … 3683 3806 if (itr == _dataSets.end()) { 3684 3807 ERROR("Unknown dataset %s", id.c_str()); 3685 return ;3808 return false; 3686 3809 } 3687 3810 … … 3711 3834 initCamera(); 3712 3835 _needsRedraw = true; 3836 return true; 3713 3837 } 3714 3838 … … 4103 4227 * \brief Create a new Molecule and associate it with the named DataSet 4104 4228 */ 4105 voidRenderer::addMolecule(const DataSetId& id)4229 bool Renderer::addMolecule(const DataSetId& id) 4106 4230 { 4107 4231 DataSetHashmap::iterator itr; … … 4116 4240 if (itr == _dataSets.end()) { 4117 4241 ERROR("Unknown dataset %s", id.c_str()); 4118 return ;4242 return false; 4119 4243 } 4120 4244 … … 4140 4264 initCamera(); 4141 4265 _needsRedraw = true; 4266 return true; 4142 4267 } 4143 4268 … … 4611 4736 * \brief Create a new PolyData and associate it with the named DataSet 4612 4737 */ 4613 voidRenderer::addPolyData(const DataSetId& id)4738 bool Renderer::addPolyData(const DataSetId& id) 4614 4739 { 4615 4740 DataSetHashmap::iterator itr; … … 4624 4749 if (itr == _dataSets.end()) { 4625 4750 ERROR("Unknown dataset %s", id.c_str()); 4626 return ;4751 return false; 4627 4752 } 4628 4753 … … 4648 4773 initCamera(); 4649 4774 _needsRedraw = true; 4775 return true; 4650 4776 } 4651 4777 … … 4971 5097 4972 5098 /** 4973 * \brief Set wireframe rendering for the specified DataSet 4974 */ 4975 void Renderer::setPolyDataWireframe(const DataSetId& id, bool state) 5099 * \brief Set the point size for the specified DataSet (may be a no-op) 5100 * 5101 * If the OpenGL implementation/hardware does not support wide points, 5102 * this function may not have an effect. 5103 */ 5104 void Renderer::setPolyDataPointSize(const DataSetId& id, float size) 4976 5105 { 4977 5106 PolyDataHashmap::iterator itr; … … 4991 5120 4992 5121 do { 5122 itr->second->setPointSize(size); 5123 } while (doAll && ++itr != _polyDatas.end()); 5124 5125 _needsRedraw = true; 5126 } 5127 5128 /** 5129 * \brief Set wireframe rendering for the specified DataSet 5130 */ 5131 void Renderer::setPolyDataWireframe(const DataSetId& id, bool state) 5132 { 5133 PolyDataHashmap::iterator itr; 5134 5135 bool doAll = false; 5136 5137 if (id.compare("all") == 0) { 5138 itr = _polyDatas.begin(); 5139 doAll = true; 5140 } else { 5141 itr = _polyDatas.find(id); 5142 } 5143 if (itr == _polyDatas.end()) { 5144 ERROR("PolyData not found: %s", id.c_str()); 5145 return; 5146 } 5147 5148 do { 4993 5149 itr->second->setWireframe(state); 4994 5150 } while (doAll && ++itr != _polyDatas.end()); … … 5027 5183 * \brief Create a new PseudoColor rendering for the specified DataSet 5028 5184 */ 5029 voidRenderer::addPseudoColor(const DataSetId& id)5185 bool Renderer::addPseudoColor(const DataSetId& id) 5030 5186 { 5031 5187 DataSetHashmap::iterator itr; … … 5040 5196 if (itr == _dataSets.end()) { 5041 5197 ERROR("Unknown dataset %s", id.c_str()); 5042 return ;5198 return false; 5043 5199 } 5044 5200 … … 5065 5221 initCamera(); 5066 5222 _needsRedraw = true; 5223 return true; 5067 5224 } 5068 5225 … … 5461 5618 * \brief Create a new Streamlines and associate it with the named DataSet 5462 5619 */ 5463 voidRenderer::addStreamlines(const DataSetId& id)5620 bool Renderer::addStreamlines(const DataSetId& id) 5464 5621 { 5465 5622 DataSetHashmap::iterator itr; … … 5474 5631 if (itr == _dataSets.end()) { 5475 5632 ERROR("Unknown dataset %s", id.c_str()); 5476 return ;5633 return false; 5477 5634 } 5478 5635 … … 5500 5657 initCamera(); 5501 5658 _needsRedraw = true; 5659 return true; 5502 5660 } 5503 5661 … … 6230 6388 * \brief Create a new Volume and associate it with the named DataSet 6231 6389 */ 6232 voidRenderer::addVolume(const DataSetId& id)6390 bool Renderer::addVolume(const DataSetId& id) 6233 6391 { 6234 6392 DataSetHashmap::iterator itr; … … 6243 6401 if (itr == _dataSets.end()) { 6244 6402 ERROR("Unknown dataset %s", id.c_str()); 6245 return ;6403 return false; 6246 6404 } 6247 6405 … … 6271 6429 initCamera(); 6272 6430 _needsRedraw = true; 6431 return true; 6273 6432 } 6274 6433 … … 6652 6811 void Renderer::setWindowSize(int width, int height) 6653 6812 { 6654 setViewAngle(height); 6813 if (_windowWidth == width && 6814 _windowHeight == height) 6815 return; 6816 6817 //setViewAngle(height); 6655 6818 6656 6819 // FIXME: Fix up panning on aspect change … … 6691 6854 CameraMode origMode = _cameraMode; 6692 6855 _cameraMode = mode; 6856 resetAxes(); 6857 6693 6858 vtkSmartPointer<vtkCamera> camera = _renderer->GetActiveCamera(); 6694 6859 switch (mode) { … … 6719 6884 ERROR("Unkown camera mode: %d", mode); 6720 6885 } 6721 resetAxes();6722 6723 6886 _needsRedraw = true; 6724 6887 } … … 7173 7336 setCameraZoomRegion(_imgWorldOrigin[0], _imgWorldOrigin[1], 7174 7337 _imgWorldDims[0], _imgWorldDims[1]); 7175 } else if (_cameraMode == ORTHO) { 7176 camera->Zoom(z); // Change ortho parallel scale (Dolly has no effect in ortho) 7177 _renderer->ResetCameraClippingRange(); 7178 } else { 7179 camera->Dolly(z); // Move camera forward/back 7338 } else { 7339 // Keep ortho and perspective modes in sync 7340 // Move camera forward/back for perspective camera 7341 camera->Dolly(z); 7342 // Change ortho parallel scale 7343 camera->SetParallelScale(camera->GetParallelScale()/z); 7180 7344 _renderer->ResetCameraClippingRange(); 7181 7345 //computeScreenWorldCoords(); … … 7186 7350 7187 7351 _needsRedraw = true; 7352 } 7353 7354 /** 7355 * \brief Set the pan/zoom using a corner and dimensions in pixel coordinates 7356 * 7357 * \param[in] x left pixel coordinate 7358 * \param[in] y bottom pixel coordinate (with y=0 at top of window) 7359 * \param[in] width Width of zoom region in pixel coordinates 7360 * \param[in] height Height of zoom region in pixel coordinates 7361 */ 7362 void Renderer::setCameraZoomRegionPixels(int x, int y, int width, int height) 7363 { 7364 double wx, wy, ww, wh; 7365 7366 y = _windowHeight - y; 7367 double pxToWorldX = _screenWorldCoords[2] / (double)_windowWidth; 7368 double pxToWorldY = _screenWorldCoords[3] / (double)_windowHeight; 7369 7370 wx = _screenWorldCoords[0] + x * pxToWorldX; 7371 wy = _screenWorldCoords[1] + y * pxToWorldY; 7372 ww = abs(width) * pxToWorldX; 7373 wh = abs(height) * pxToWorldY; 7374 setCameraZoomRegion(wx, wy, ww, wh); 7375 7376 TRACE("\npx: %d %d %d %d\nworld: %g %g %g %g", 7377 x, y, width, height, 7378 wx, wy, ww, wh); 7188 7379 } 7189 7380 … … 7200 7391 double camPos[2]; 7201 7392 7202 int pxOffsetX = 85; 7203 int pxOffsetY = 75; 7204 int outerGutter = 15; 7393 int pxOffsetX = (int)(0.17 * (double)_windowWidth); 7394 pxOffsetX = (pxOffsetX > 100 ? 100 : pxOffsetX); 7395 int pxOffsetY = (int)(0.15 * (double)_windowHeight); 7396 pxOffsetY = (pxOffsetY > 75 ? 75 : pxOffsetY); 7397 int outerGutter = (int)(0.03 * (double)_windowWidth); 7398 outerGutter = (outerGutter > 15 ? 15 : outerGutter); 7205 7399 7206 7400 int imgHeightPx = _windowHeight - pxOffsetY - outerGutter; … … 7238 7432 vtkSmartPointer<vtkCamera> camera = _renderer->GetActiveCamera(); 7239 7433 camera->ParallelProjectionOn(); 7240 camera->SetPosition(camPos[0], camPos[1], 1);7241 camera->SetFocalPoint(camPos[0], camPos[1], 0);7242 camera->SetViewUp(0, 1, 0);7243 7434 camera->SetClippingRange(1, 2); 7244 7435 // Half of world coordinate height of viewport (Documentation is wrong) 7245 7436 camera->SetParallelScale(_windowHeight * pxToWorld / 2.0); 7246 7437 7247 // bottom 7248 _cameraClipPlanes[0]->SetOrigin(0, _imgWorldOrigin[1], 0); 7249 // left 7250 _cameraClipPlanes[1]->SetOrigin(_imgWorldOrigin[0], 0, 0); 7251 // top 7252 _cameraClipPlanes[2]->SetOrigin(0, _imgWorldOrigin[1] + _imgWorldDims[1], 0); 7253 // right 7254 _cameraClipPlanes[3]->SetOrigin(_imgWorldOrigin[0] + _imgWorldDims[0], 0, 0); 7255 7256 _cubeAxesActor2D->SetBounds(_imgWorldOrigin[0], _imgWorldOrigin[0] + _imgWorldDims[0], 7257 _imgWorldOrigin[1], _imgWorldOrigin[1] + _imgWorldDims[1], 0, 0); 7438 if (_imgCameraPlane == PLANE_XY) { 7439 // XY plane 7440 camera->SetPosition(camPos[0], camPos[1], _imgCameraOffset + 1.); 7441 camera->SetFocalPoint(camPos[0], camPos[1], _imgCameraOffset); 7442 camera->SetViewUp(0, 1, 0); 7443 // bottom 7444 _cameraClipPlanes[0]->SetOrigin(0, _imgWorldOrigin[1], 0); 7445 _cameraClipPlanes[0]->SetNormal(0, 1, 0); 7446 // left 7447 _cameraClipPlanes[1]->SetOrigin(_imgWorldOrigin[0], 0, 0); 7448 _cameraClipPlanes[1]->SetNormal(1, 0, 0); 7449 // top 7450 _cameraClipPlanes[2]->SetOrigin(0, _imgWorldOrigin[1] + _imgWorldDims[1], 0); 7451 _cameraClipPlanes[2]->SetNormal(0, -1, 0); 7452 // right 7453 _cameraClipPlanes[3]->SetOrigin(_imgWorldOrigin[0] + _imgWorldDims[0], 0, 0); 7454 _cameraClipPlanes[3]->SetNormal(-1, 0, 0); 7455 _cubeAxesActor2D->SetBounds(_imgWorldOrigin[0], _imgWorldOrigin[0] + _imgWorldDims[0], 7456 _imgWorldOrigin[1], _imgWorldOrigin[1] + _imgWorldDims[1], 7457 _imgCameraOffset, _imgCameraOffset); 7458 _cubeAxesActor2D->XAxisVisibilityOn(); 7459 _cubeAxesActor2D->YAxisVisibilityOn(); 7460 _cubeAxesActor2D->ZAxisVisibilityOff(); 7461 } else if (_imgCameraPlane == PLANE_ZY) { 7462 // ZY plane 7463 camera->SetPosition(_imgCameraOffset - 1., camPos[1], camPos[0]); 7464 camera->SetFocalPoint(_imgCameraOffset, camPos[1], camPos[0]); 7465 camera->SetViewUp(0, 1, 0); 7466 // bottom 7467 _cameraClipPlanes[0]->SetOrigin(0, _imgWorldOrigin[1], 0); 7468 _cameraClipPlanes[0]->SetNormal(0, 1, 0); 7469 // left 7470 _cameraClipPlanes[1]->SetOrigin(0, 0, _imgWorldOrigin[0]); 7471 _cameraClipPlanes[1]->SetNormal(0, 0, 1); 7472 // top 7473 _cameraClipPlanes[2]->SetOrigin(0, _imgWorldOrigin[1] + _imgWorldDims[1], 0); 7474 _cameraClipPlanes[2]->SetNormal(0, -1, 0); 7475 // right 7476 _cameraClipPlanes[3]->SetOrigin(0, 0, _imgWorldOrigin[0] + _imgWorldDims[0]); 7477 _cameraClipPlanes[3]->SetNormal(0, 0, -1); 7478 _cubeAxesActor2D->SetBounds(_imgCameraOffset, _imgCameraOffset, 7479 _imgWorldOrigin[1], _imgWorldOrigin[1] + _imgWorldDims[1], 7480 _imgWorldOrigin[0], _imgWorldOrigin[0] + _imgWorldDims[0]); 7481 _cubeAxesActor2D->XAxisVisibilityOff(); 7482 _cubeAxesActor2D->YAxisVisibilityOn(); 7483 _cubeAxesActor2D->ZAxisVisibilityOn(); 7484 } else { 7485 // XZ plane 7486 camera->SetPosition(camPos[0], _imgCameraOffset - 1., camPos[1]); 7487 camera->SetFocalPoint(camPos[0], _imgCameraOffset, camPos[1]); 7488 camera->SetViewUp(0, 0, 1); 7489 // bottom 7490 _cameraClipPlanes[0]->SetOrigin(0, 0, _imgWorldOrigin[1]); 7491 _cameraClipPlanes[0]->SetNormal(0, 0, 1); 7492 // left 7493 _cameraClipPlanes[1]->SetOrigin(_imgWorldOrigin[0], 0, 0); 7494 _cameraClipPlanes[1]->SetNormal(1, 0, 0); 7495 // top 7496 _cameraClipPlanes[2]->SetOrigin(0, 0, _imgWorldOrigin[1] + _imgWorldDims[1]); 7497 _cameraClipPlanes[2]->SetNormal(0, 0, -1); 7498 // right 7499 _cameraClipPlanes[3]->SetOrigin(_imgWorldOrigin[0] + _imgWorldDims[0], 0, 0); 7500 _cameraClipPlanes[3]->SetNormal(-1, 0, 0); 7501 _cubeAxesActor2D->SetBounds(_imgWorldOrigin[0], _imgWorldOrigin[0] + _imgWorldDims[0], 7502 _imgCameraOffset, _imgCameraOffset, 7503 _imgWorldOrigin[1], _imgWorldOrigin[1] + _imgWorldDims[1]); 7504 _cubeAxesActor2D->XAxisVisibilityOn(); 7505 _cubeAxesActor2D->YAxisVisibilityOff(); 7506 _cubeAxesActor2D->ZAxisVisibilityOn(); 7507 } 7258 7508 7259 7509 // Compute screen world coordinates … … 7347 7597 mat->Delete(); 7348 7598 7349 _screenWorldCoords[0] = x0; 7350 _screenWorldCoords[1] = y0; 7351 _screenWorldCoords[2] = x1 - x0; 7352 _screenWorldCoords[3] = y1 - y0; 7599 if (_imgCameraPlane == PLANE_XZ) { 7600 _screenWorldCoords[0] = x0; 7601 _screenWorldCoords[1] = z0; 7602 _screenWorldCoords[2] = x1 - x0; 7603 _screenWorldCoords[3] = z1 - z0; 7604 } else if (_imgCameraPlane == PLANE_ZY) { 7605 _screenWorldCoords[0] = z0; 7606 _screenWorldCoords[1] = y0; 7607 _screenWorldCoords[2] = z1 - z0; 7608 _screenWorldCoords[3] = y1 - y0; 7609 } else { 7610 // XY 7611 _screenWorldCoords[0] = x0; 7612 _screenWorldCoords[1] = y0; 7613 _screenWorldCoords[2] = x1 - x0; 7614 _screenWorldCoords[3] = y1 - y0; 7615 } 7353 7616 } 7354 7617 … … 7465 7728 mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds()); 7466 7729 } 7467 for (int i = 0; i < 6; i++) { 7468 if (i % 2 == 0) { 7469 if (bounds[i] == DBL_MAX) 7470 bounds[i] = 0; 7471 } else { 7472 if (bounds[i] == -DBL_MAX) 7473 bounds[i] = 1; 7730 7731 for (int i = 0; i < 6; i += 2) { 7732 if (bounds[i+1] < bounds[i]) { 7733 bounds[i] = -0.5; 7734 bounds[i+1] = 0.5; 7474 7735 } 7475 7736 } 7737 7738 int numDims = 0; 7739 if (bounds[0] != bounds[1]) 7740 numDims++; 7741 if (bounds[2] != bounds[3]) 7742 numDims++; 7743 if (bounds[4] != bounds[5]) 7744 numDims++; 7745 7746 if (numDims == 0) { 7747 bounds[0] -= .5; 7748 bounds[1] += .5; 7749 bounds[2] -= .5; 7750 bounds[3] += .5; 7751 } 7752 7476 7753 TRACE("Bounds: %g %g %g %g %g %g", 7477 7754 bounds[0], … … 7564 7841 collectVectorComponentRanges(_cumulativeVectorComponentRange[i], i, 7565 7842 _cumulativeRangeOnlyVisible); 7843 } 7844 7845 TRACE("Cumulative scalar range: %g, %g", 7846 _cumulativeScalarRange[0], 7847 _cumulativeScalarRange[1]); 7848 TRACE("Cumulative vmag range: %g, %g", 7849 _cumulativeVectorMagnitudeRange[0], 7850 _cumulativeVectorMagnitudeRange[1]); 7851 for (int i = 0; i < 3; i++) { 7852 TRACE("Cumulative v[%d] range: %g, %g", i, 7853 _cumulativeVectorComponentRange[i][0], 7854 _cumulativeVectorComponentRange[i][1]); 7566 7855 } 7567 7856 } … … 7644 7933 range[1] = 1; 7645 7934 } 7935 7936 /** 7937 * \brief Determines if AABB lies in a principal axis plane 7938 * and if so, returns the plane normal 7939 */ 7940 bool Renderer::is2D(const double bounds[6], 7941 Renderer::PrincipalPlane *plane, 7942 double *offset) const 7943 { 7944 if (bounds[4] == bounds[5]) { 7945 // Z = 0, XY plane 7946 if (plane) 7947 *plane = PLANE_XY; 7948 if (offset) 7949 *offset = bounds[4]; 7950 return true; 7951 } else if (bounds[0] == bounds[1]) { 7952 // X = 0, ZY plane 7953 if (plane) 7954 *plane = PLANE_ZY; 7955 if (offset) 7956 *offset = bounds[0]; 7957 return true; 7958 } else if (bounds[2] == bounds[3]) { 7959 // Y = 0, XZ plane 7960 if (plane) 7961 *plane = PLANE_XZ; 7962 if (offset) 7963 *offset = bounds[2]; 7964 return true; 7965 } 7966 *plane = PLANE_XY; 7967 *offset = 0; 7968 return false; 7969 } 7646 7970 7647 7971 /** … … 7667 7991 double bounds[6]; 7668 7992 collectBounds(bounds, false); 7669 _imgWorldOrigin[0] = bounds[0]; 7670 _imgWorldOrigin[1] = bounds[2]; 7671 _imgWorldDims[0] = bounds[1] - bounds[0]; 7672 _imgWorldDims[1] = bounds[3] - bounds[2]; 7993 bool twod = is2D(bounds, &_imgCameraPlane, &_imgCameraOffset); 7994 if (twod) { 7995 _cameraMode = IMAGE; 7996 if (_imgCameraPlane == PLANE_ZY) { 7997 _imgWorldOrigin[0] = bounds[4]; 7998 _imgWorldOrigin[1] = bounds[2]; 7999 _imgWorldDims[0] = bounds[5] - bounds[4]; 8000 _imgWorldDims[1] = bounds[3] - bounds[2]; 8001 } else if (_imgCameraPlane == PLANE_XZ) { 8002 _imgWorldOrigin[0] = bounds[0]; 8003 _imgWorldOrigin[1] = bounds[4]; 8004 _imgWorldDims[0] = bounds[1] - bounds[0]; 8005 _imgWorldDims[1] = bounds[5] - bounds[4]; 8006 } else { 8007 _imgWorldOrigin[0] = bounds[0]; 8008 _imgWorldOrigin[1] = bounds[2]; 8009 _imgWorldDims[0] = bounds[1] - bounds[0]; 8010 _imgWorldDims[1] = bounds[3] - bounds[2]; 8011 } 8012 } else { 8013 _imgWorldOrigin[0] = bounds[0]; 8014 _imgWorldOrigin[1] = bounds[2]; 8015 _imgWorldDims[0] = bounds[1] - bounds[0]; 8016 _imgWorldDims[1] = bounds[3] - bounds[2]; 8017 } 8018 7673 8019 _cameraPan[0] = 0; 7674 8020 _cameraPan[1] = 0; … … 7697 8043 ERROR("Unknown camera mode"); 7698 8044 } 8045 7699 8046 #ifdef WANT_TRACE 7700 8047 printCameraInfo(_renderer->GetActiveCamera()); … … 7707 8054 void Renderer::printCameraInfo(vtkCamera *camera) 7708 8055 { 7709 TRACE(" Parallel Scale: %g, View angle: %g, Cam pos: %g %g %g, focal pt: %g %g %g, view up: %g %g %g, Clipping range: %g %g",8056 TRACE("pscale: %g, angle: %g, d: %g pos: %g %g %g, fpt: %g %g %g, vup: %g %g %g, clip: %g %g", 7710 8057 camera->GetParallelScale(), 7711 8058 camera->GetViewAngle(), 8059 camera->GetDistance(), 7712 8060 camera->GetPosition()[0], 7713 8061 camera->GetPosition()[1], … … 8096 8444 * Note: no interpolation is performed on data 8097 8445 */ 8098 double Renderer::getDataValueAtPixel(const DataSetId& id, int x, int y)8446 bool Renderer::getScalarValueAtPixel(const DataSetId& id, int x, int y, double *value) 8099 8447 { 8100 8448 vtkSmartPointer<vtkCoordinate> coord = vtkSmartPointer<vtkCoordinate>::New(); 8101 8449 coord->SetCoordinateSystemToDisplay(); 8102 coord->SetValue(x, y, 0);8450 coord->SetValue(x, _windowHeight - y, 0); 8103 8451 double *worldCoords = coord->GetComputedWorldValue(_renderer); 8104 8452 8105 TRACE("Pixel coords: %d, %d\nWorld coords: % .12e, %.12e, %12e", x, y,8453 TRACE("Pixel coords: %d, %d\nWorld coords: %g, %g, %g", x, y, 8106 8454 worldCoords[0], 8107 8455 worldCoords[1], 8108 8456 worldCoords[2]); 8109 8457 8110 return get DataValue(id, worldCoords[0], worldCoords[1], worldCoords[2]);8458 return getScalarValue(id, worldCoords[0], worldCoords[1], worldCoords[2], value); 8111 8459 } 8112 8460 … … 8116 8464 * Note: no interpolation is performed on data 8117 8465 */ 8118 double Renderer::getDataValue(const DataSetId& id, double x, double y, double z)8466 bool Renderer::getScalarValue(const DataSetId& id, double x, double y, double z, double *value) 8119 8467 { 8120 8468 DataSet *ds = getDataSet(id); 8121 8469 if (ds == NULL) 8122 return 0; 8123 vtkDataSet *vtkds = ds->getVtkDataSet(); 8124 vtkIdType pt = vtkds->FindPoint(x, y, z); 8125 return vtkds->GetPointData()->GetScalars()->GetComponent(pt, 0); 8126 } 8470 return false; 8471 8472 return ds->getScalarValue(x, y, z, value); 8473 } 8474 8475 /** 8476 * \brief Get nearest data value given display coordinates x,y 8477 * 8478 * Note: no interpolation is performed on data 8479 */ 8480 bool Renderer::getVectorValueAtPixel(const DataSetId& id, int x, int y, double vector[3]) 8481 { 8482 vtkSmartPointer<vtkCoordinate> coord = vtkSmartPointer<vtkCoordinate>::New(); 8483 coord->SetCoordinateSystemToDisplay(); 8484 coord->SetValue(x, _windowHeight - y, 0); 8485 double *worldCoords = coord->GetComputedWorldValue(_renderer); 8486 8487 TRACE("Pixel coords: %d, %d\nWorld coords: %g, %g, %g", x, y, 8488 worldCoords[0], 8489 worldCoords[1], 8490 worldCoords[2]); 8491 8492 return getVectorValue(id, worldCoords[0], worldCoords[1], worldCoords[2], vector); 8493 } 8494 8495 /** 8496 * \brief Get nearest data value given world coordinates x,y,z 8497 * 8498 * Note: no interpolation is performed on data 8499 */ 8500 bool Renderer::getVectorValue(const DataSetId& id, double x, double y, double z, double vector[3]) 8501 { 8502 DataSet *ds = getDataSet(id); 8503 if (ds == NULL) 8504 return false; 8505 8506 return ds->getVectorValue(x, y, z, vector); 8507 } -
trunk/packages/vizservers/vtkvis/RpVtkRenderer.h
r2402 r2423 12 12 #include <vtkCubeAxesActor.h> 13 13 #ifdef USE_CUSTOM_AXES 14 #include <vtkRpCubeAxesActor2D.h>14 #include "vtkRpCubeAxesActor2D.h" 15 15 #else 16 16 #include <vtkCubeAxesActor2D.h> … … 59 59 Y_AXIS, 60 60 Z_AXIS 61 }; 62 63 enum PrincipalPlane { 64 PLANE_XY, 65 PLANE_ZY, 66 PLANE_XZ 61 67 }; 62 68 … … 104 110 DataSet *getDataSet(const DataSetId& id); 105 111 112 void getDataSetNames(std::vector<std::string>& names); 113 106 114 bool setData(const DataSetId& id, char *data, int nbytes); 107 115 … … 112 120 bool setDataSetActiveVectors(const DataSetId& id, const char *vectorName); 113 121 114 double getDataValueAtPixel(const DataSetId& id, int x, int y); 115 116 double getDataValue(const DataSetId& id, double x, double y, double z); 122 bool getScalarValueAtPixel(const DataSetId& id, int x, int y, double *value); 123 124 bool getScalarValue(const DataSetId& id, double x, double y, double z, double *value); 125 126 bool getVectorValueAtPixel(const DataSetId& id, int x, int y, double vector[3]); 127 128 bool getVectorValue(const DataSetId& id, double x, double y, double z, double vector[3]); 117 129 118 130 void setOpacity(const DataSetId& id, double opacity); … … 148 160 void resetCameraClippingRange(); 149 161 162 void setCameraZoomRegionPixels(int x, int y, int width, int height); 163 150 164 void setCameraZoomRegion(double x, double y, double width, double height); 151 165 … … 232 246 // 2D Contour plots 233 247 234 voidaddContour2D(const DataSetId& id, int numContours);235 236 voidaddContour2D(const DataSetId& id, const std::vector<double>& contours);248 bool addContour2D(const DataSetId& id, int numContours); 249 250 bool addContour2D(const DataSetId& id, const std::vector<double>& contours); 237 251 238 252 void deleteContour2D(const DataSetId& id); … … 266 280 // 3D Contour (isosurface) plots 267 281 268 voidaddContour3D(const DataSetId& id, int numContours);269 270 voidaddContour3D(const DataSetId& id, const std::vector<double>& contours);282 bool addContour3D(const DataSetId& id, int numContours); 283 284 bool addContour3D(const DataSetId& id, const std::vector<double>& contours); 271 285 272 286 void deleteContour3D(const DataSetId& id); … … 308 322 // Glyphs 309 323 310 voidaddGlyphs(const DataSetId& id, Glyphs::GlyphShape shape);324 bool addGlyphs(const DataSetId& id, Glyphs::GlyphShape shape); 311 325 312 326 void deleteGlyphs(const DataSetId& id); … … 352 366 // Height maps 353 367 354 void addHeightMap(const DataSetId& id, int numContours);355 356 void addHeightMap(const DataSetId& id, const std::vector<double>& contours);368 bool addHeightMap(const DataSetId& id, int numContours, double heightScale); 369 370 bool addHeightMap(const DataSetId& id, const std::vector<double>& contours, double heightScale); 357 371 358 372 void deleteHeightMap(const DataSetId& id); … … 382 396 void setHeightMapVisibility(const DataSetId& id, bool state); 383 397 398 void setHeightMapWireframe(const DataSetId& id, bool state); 399 384 400 void setHeightMapVolumeSlice(const DataSetId& id, HeightMap::Axis axis, double ratio); 385 401 … … 388 404 void setHeightMapColorMap(const DataSetId& id, const ColorMapId& colorMapId); 389 405 390 void setHeightMap Contours(const DataSetId& id, int numContours);406 void setHeightMapNumContours(const DataSetId& id, int numContours); 391 407 392 408 void setHeightMapContourList(const DataSetId& id, const std::vector<double>& contours); 393 409 394 void setHeightMapContourVisibility(const DataSetId& id, bool state); 410 void setHeightMapContourSurfaceVisibility(const DataSetId& id, bool state); 411 412 void setHeightMapContourLineVisibility(const DataSetId& id, bool state); 395 413 396 414 void setHeightMapContourEdgeColor(const DataSetId& id, float color[3]); … … 400 418 // LIC plots 401 419 402 voidaddLIC(const DataSetId& id);420 bool addLIC(const DataSetId& id); 403 421 404 422 void deleteLIC(const DataSetId& id); … … 434 452 // Molecules 435 453 436 voidaddMolecule(const DataSetId& id);454 bool addMolecule(const DataSetId& id); 437 455 438 456 void deleteMolecule(const DataSetId& id); … … 474 492 // PolyData Meshes 475 493 476 voidaddPolyData(const DataSetId& id);494 bool addPolyData(const DataSetId& id); 477 495 478 496 void deletePolyData(const DataSetId& id); … … 498 516 void setPolyDataEdgeWidth(const DataSetId& id, float edgeWidth); 499 517 518 void setPolyDataPointSize(const DataSetId& id, float size); 519 500 520 void setPolyDataLighting(const DataSetId& id, bool state); 501 521 … … 509 529 // Color-mapped surfaces 510 530 511 voidaddPseudoColor(const DataSetId& id);531 bool addPseudoColor(const DataSetId& id); 512 532 513 533 void deletePseudoColor(const DataSetId& id); … … 543 563 // Streamlines 544 564 545 voidaddStreamlines(const DataSetId& id);565 bool addStreamlines(const DataSetId& id); 546 566 547 567 void deleteStreamlines(const DataSetId& id); … … 612 632 // Volumes 613 633 614 voidaddVolume(const DataSetId& id);634 bool addVolume(const DataSetId& id); 615 635 616 636 void deleteVolume(const DataSetId& id); … … 678 698 void computeScreenWorldCoords(); 679 699 700 bool is2D(const double bounds[6], 701 PrincipalPlane *plane, 702 double *offset) const; 680 703 void initCamera(); 681 704 void initAxes(); … … 687 710 double _imgWorldOrigin[2]; 688 711 double _imgWorldDims[2]; 712 PrincipalPlane _imgCameraPlane; 713 double _imgCameraOffset; 689 714 double _screenWorldCoords[4]; 690 715 double _cameraOrientation[4]; -
trunk/packages/vizservers/vtkvis/RpVtkRendererCmd.cpp
r2402 r2423 10 10 #include <cstring> 11 11 #include <cerrno> 12 #include <string> 13 #include <sstream> 12 14 #include <unistd.h> 13 15 #include <sys/uio.h> … … 24 26 using namespace Rappture::VtkVis; 25 27 28 static ssize_t 29 SocketWrite(const void *bytes, size_t len) 30 { 31 size_t ofs = 0; 32 ssize_t bytesWritten; 33 while ((bytesWritten = write(g_fdOut, (const char *)bytes + ofs, len - ofs)) > 0) { 34 ofs += bytesWritten; 35 if (ofs == len) 36 break; 37 } 38 if (bytesWritten < 0) { 39 ERROR("write: %s", strerror(errno)); 40 } 41 return bytesWritten; 42 } 43 26 44 static int 27 45 ExecuteCommand(Tcl_Interp *interp, Tcl_DString *dsPtr) … … 35 53 } 36 54 37 static bool55 static int 38 56 GetBooleanFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, bool *boolPtr) 39 57 { … … 47 65 } 48 66 49 int67 static int 50 68 GetFloatFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, float *valuePtr) 51 69 { … … 324 342 325 343 char buf[256]; 326 snprintf(buf, sizeof(buf), "nv>camera set %.12e %.12e %.12e %.12e %.12e %.12e %.12e %.12e %.12e ",344 snprintf(buf, sizeof(buf), "nv>camera set %.12e %.12e %.12e %.12e %.12e %.12e %.12e %.12e %.12e\n", 327 345 pos[0], pos[1], pos[2], focalPt[0], focalPt[1], focalPt[2], viewUp[0], viewUp[1], viewUp[2]); 328 ssize_t bytesWritten; 329 size_t len = strlen(buf); 330 size_t ofs = 0; 331 while ((bytesWritten = write(g_fdOut, buf + ofs, len - ofs)) > 0) { 332 ofs += bytesWritten; 333 if (ofs == len) 334 break; 335 } 346 347 ssize_t bytesWritten = SocketWrite(buf, strlen(buf)); 348 336 349 if (bytesWritten < 0) { 337 350 return TCL_ERROR; … … 361 374 Tcl_Obj *const *objv) 362 375 { 363 double x, y, width, height; 364 365 if (Tcl_GetDoubleFromObj(interp, objv[2], &x) != TCL_OK || 366 Tcl_GetDoubleFromObj(interp, objv[3], &y) != TCL_OK || 367 Tcl_GetDoubleFromObj(interp, objv[4], &width) != TCL_OK || 368 Tcl_GetDoubleFromObj(interp, objv[5], &height) != TCL_OK) { 369 return TCL_ERROR; 370 } 371 372 g_renderer->setCameraZoomRegion(x, y, width, height); 376 const char *string = Tcl_GetString(objv[2]); 377 378 if (string[0] == 'p' && strcmp(string, "pixel") == 0) { 379 int x, y, width, height; 380 if (Tcl_GetIntFromObj(interp, objv[3], &x) != TCL_OK || 381 Tcl_GetIntFromObj(interp, objv[4], &y) != TCL_OK || 382 Tcl_GetIntFromObj(interp, objv[5], &width) != TCL_OK || 383 Tcl_GetIntFromObj(interp, objv[6], &height) != TCL_OK) { 384 return TCL_ERROR; 385 } 386 g_renderer->setCameraZoomRegionPixels(x, y, width, height); 387 } else if (string[0] == 'w' && strcmp(string, "world") == 0) { 388 double x, y, width, height; 389 if (Tcl_GetDoubleFromObj(interp, objv[3], &x) != TCL_OK || 390 Tcl_GetDoubleFromObj(interp, objv[4], &y) != TCL_OK || 391 Tcl_GetDoubleFromObj(interp, objv[5], &width) != TCL_OK || 392 Tcl_GetDoubleFromObj(interp, objv[6], &height) != TCL_OK) { 393 return TCL_ERROR; 394 } 395 g_renderer->setCameraZoomRegion(x, y, width, height); 396 } else { 397 Tcl_AppendResult(interp, "bad camera ortho option \"", string, 398 "\": should be pixel or world", (char*)NULL); 399 return TCL_ERROR; 400 } 401 373 402 return TCL_OK; 374 403 } … … 466 495 {"mode", 1, CameraModeOp, 3, 3, "mode"}, 467 496 {"orient", 3, CameraOrientOp, 6, 6, "qw qx qy qz"}, 468 {"ortho", 1, CameraOrthoOp, 6, 6, "x y width height"},497 {"ortho", 1, CameraOrthoOp, 7, 7, "coordMode x y width height"}, 469 498 {"pan", 1, CameraPanOp, 4, 4, "panX panY"}, 470 499 {"reset", 2, CameraResetOp, 2, 3, "?all?"}, … … 625 654 if (objc == 5) { 626 655 const char *name = Tcl_GetString(objv[4]); 627 g_renderer->addContour2D(name, contourList); 628 } else { 629 g_renderer->addContour2D("all", contourList); 656 if (!g_renderer->addContour2D(name, contourList)) { 657 Tcl_AppendResult(interp, "Failed to create contour2d", (char*)NULL); 658 return TCL_ERROR; 659 } 660 } else { 661 if (!g_renderer->addContour2D("all", contourList)) { 662 Tcl_AppendResult(interp, "Failed to create contour2d for one or more data sets", (char*)NULL); 663 return TCL_ERROR; 664 } 630 665 } 631 666 return TCL_OK; … … 642 677 if (objc == 5) { 643 678 const char *name = Tcl_GetString(objv[4]); 644 g_renderer->addContour2D(name, numContours); 645 } else { 646 g_renderer->addContour2D("all", numContours); 679 if (!g_renderer->addContour2D(name, numContours)) { 680 Tcl_AppendResult(interp, "Failed to create contour2d", (char*)NULL); 681 return TCL_ERROR; 682 } 683 } else { 684 if (!g_renderer->addContour2D("all", numContours)) { 685 Tcl_AppendResult(interp, "Failed to create contour2d for one or more data sets", (char*)NULL); 686 return TCL_ERROR; 687 } 647 688 } 648 689 return TCL_OK; … … 878 919 if (objc == 5) { 879 920 const char *name = Tcl_GetString(objv[4]); 880 g_renderer->addContour3D(name, contourList); 881 } else { 882 g_renderer->addContour3D("all", contourList); 921 if (!g_renderer->addContour3D(name, contourList)) { 922 Tcl_AppendResult(interp, "Failed to create contour3d", (char*)NULL); 923 return TCL_ERROR; 924 } 925 } else { 926 if (!g_renderer->addContour3D("all", contourList)) { 927 Tcl_AppendResult(interp, "Failed to create contour3d for one or more data sets", (char*)NULL); 928 return TCL_ERROR; 929 } 883 930 } 884 931 return TCL_OK; … … 895 942 if (objc == 5) { 896 943 const char *name = Tcl_GetString(objv[4]); 897 g_renderer->addContour3D(name, numContours); 898 } else { 899 g_renderer->addContour3D("all", numContours); 944 if (!g_renderer->addContour3D(name, numContours)) { 945 Tcl_AppendResult(interp, "Failed to create contour3d", (char*)NULL); 946 return TCL_ERROR; 947 } 948 } else { 949 if (!g_renderer->addContour3D("all", numContours)) { 950 Tcl_AppendResult(interp, "Failed to create contour3d for one or more data sets", (char*)NULL); 951 return TCL_ERROR; 952 } 900 953 } 901 954 return TCL_OK; … … 1290 1343 1291 1344 static int 1292 DataSetGet ValuePixelOp(ClientData clientData, Tcl_Interp *interp, int objc,1293 Tcl_Obj *const *objv)1345 DataSetGetScalarPixelOp(ClientData clientData, Tcl_Interp *interp, int objc, 1346 Tcl_Obj *const *objv) 1294 1347 { 1295 1348 const char *name = Tcl_GetString(objv[5]); … … 1299 1352 return TCL_ERROR; 1300 1353 } 1301 double value = g_renderer->getDataValueAtPixel(name, x, y);1302 char buf[128];1303 snprintf(buf, sizeof(buf), "nv>dataset value pixel %d %d %.12e", x, y, value);1304 ssize_t bytesWritten;1305 size_t len = strlen(buf);1306 size_t ofs = 0; 1307 while ((bytesWritten = write(g_fdOut, buf + ofs, len - ofs)) > 0) {1308 ofs += bytesWritten;1309 if (ofs == len) 1310 break;1311 } 1354 double value; 1355 if (!g_renderer->getScalarValueAtPixel(name, x, y, &value)) { 1356 Tcl_AppendResult(interp, "Pixel out of dataset bounds or no scalar data available", (char*)NULL); 1357 return TCL_ERROR; 1358 } 1359 1360 char buf[256]; 1361 snprintf(buf, sizeof(buf), "nv>dataset scalar pixel %d %d %g %s\n", x, y, value, name); 1362 1363 ssize_t bytesWritten = SocketWrite(buf, strlen(buf)); 1364 1312 1365 if (bytesWritten < 0) { 1313 1366 return TCL_ERROR; … … 1317 1370 1318 1371 static int 1319 DataSetGet ValueWorldOp(ClientData clientData, Tcl_Interp *interp, int objc,1320 Tcl_Obj *const *objv)1372 DataSetGetScalarWorldOp(ClientData clientData, Tcl_Interp *interp, int objc, 1373 Tcl_Obj *const *objv) 1321 1374 { 1322 1375 const char *name = Tcl_GetString(objv[6]); … … 1327 1380 return TCL_ERROR; 1328 1381 } 1329 double value = g_renderer->getDataValue(name, x, y, z);1330 char buf[128];1331 snprintf(buf, sizeof(buf), "nv>dataset value world %.12e %.12e %.12e %.12e", x, y, z, value);1332 ssize_t bytesWritten;1333 size_t len = strlen(buf);1334 size_t ofs = 0; 1335 while ((bytesWritten = write(g_fdOut, buf + ofs, len - ofs)) > 0) {1336 ofs += bytesWritten;1337 if (ofs == len) 1338 break;1339 } 1382 double value; 1383 if (!g_renderer->getScalarValue(name, x, y, z, &value)) { 1384 Tcl_AppendResult(interp, "Coordinate out of dataset bounds or no scalar data available", (char*)NULL); 1385 return TCL_ERROR; 1386 } 1387 1388 char buf[256]; 1389 snprintf(buf, sizeof(buf), "nv>dataset scalar world %g %g %g %g %s\n", x, y, z, value, name); 1390 1391 ssize_t bytesWritten = SocketWrite(buf, strlen(buf)); 1392 1340 1393 if (bytesWritten < 0) { 1341 1394 return TCL_ERROR; … … 1344 1397 } 1345 1398 1346 static Rappture::CmdSpec dataSetGet ValueOps[] = {1347 {"pixel", 1, DataSetGet ValuePixelOp, 6, 6, "x y dataSetName"},1348 {"world", 1, DataSetGet ValueWorldOp, 7, 7, "x y z dataSetName"}1399 static Rappture::CmdSpec dataSetGetScalarOps[] = { 1400 {"pixel", 1, DataSetGetScalarPixelOp, 6, 6, "x y dataSetName"}, 1401 {"world", 1, DataSetGetScalarWorldOp, 7, 7, "x y z dataSetName"} 1349 1402 }; 1350 static int nDataSetGet ValueOps = NumCmdSpecs(dataSetGetValueOps);1351 1352 static int 1353 DataSetGet ValueOp(ClientData clientData, Tcl_Interp *interp, int objc,1354 Tcl_Obj *const *objv)1403 static int nDataSetGetScalarOps = NumCmdSpecs(dataSetGetScalarOps); 1404 1405 static int 1406 DataSetGetScalarOp(ClientData clientData, Tcl_Interp *interp, int objc, 1407 Tcl_Obj *const *objv) 1355 1408 { 1356 1409 Tcl_ObjCmdProc *proc; 1357 1410 1358 proc = Rappture::GetOpFromObj(interp, nDataSetGetValueOps, dataSetGetValueOps, 1411 proc = Rappture::GetOpFromObj(interp, nDataSetGetScalarOps, dataSetGetScalarOps, 1412 Rappture::CMDSPEC_ARG2, objc, objv, 0); 1413 if (proc == NULL) { 1414 return TCL_ERROR; 1415 } 1416 return (*proc) (clientData, interp, objc, objv); 1417 } 1418 1419 static int 1420 DataSetGetVectorPixelOp(ClientData clientData, Tcl_Interp *interp, int objc, 1421 Tcl_Obj *const *objv) 1422 { 1423 const char *name = Tcl_GetString(objv[5]); 1424 int x, y; 1425 if (Tcl_GetIntFromObj(interp, objv[3], &x) != TCL_OK || 1426 Tcl_GetIntFromObj(interp, objv[4], &y) != TCL_OK) { 1427 return TCL_ERROR; 1428 } 1429 double value[3]; 1430 if (!g_renderer->getVectorValueAtPixel(name, x, y, value)) { 1431 Tcl_AppendResult(interp, "Pixel out of dataset bounds or no vector data available", (char*)NULL); 1432 return TCL_ERROR; 1433 } 1434 1435 char buf[256]; 1436 snprintf(buf, sizeof(buf), "nv>dataset vector pixel %d %d %g %g %g %s\n", x, y, 1437 value[0], value[1], value[2], name); 1438 1439 ssize_t bytesWritten = SocketWrite(buf, strlen(buf)); 1440 1441 if (bytesWritten < 0) { 1442 return TCL_ERROR; 1443 } 1444 return TCL_OK; 1445 } 1446 1447 static int 1448 DataSetGetVectorWorldOp(ClientData clientData, Tcl_Interp *interp, int objc, 1449 Tcl_Obj *const *objv) 1450 { 1451 const char *name = Tcl_GetString(objv[6]); 1452 double x, y, z; 1453 if (Tcl_GetDoubleFromObj(interp, objv[3], &x) != TCL_OK || 1454 Tcl_GetDoubleFromObj(interp, objv[4], &y) != TCL_OK || 1455 Tcl_GetDoubleFromObj(interp, objv[5], &z) != TCL_OK) { 1456 return TCL_ERROR; 1457 } 1458 double value[3]; 1459 if (!g_renderer->getVectorValue(name, x, y, z, value)) { 1460 Tcl_AppendResult(interp, "Coordinate out of dataset bounds or no vector data available", (char*)NULL); 1461 return TCL_ERROR; 1462 } 1463 1464 char buf[256]; 1465 snprintf(buf, sizeof(buf), "nv>dataset vector world %g %g %g %g %g %g %s\n", x, y, z, 1466 value[0], value[1], value[2], name); 1467 1468 ssize_t bytesWritten = SocketWrite(buf, strlen(buf)); 1469 1470 if (bytesWritten < 0) { 1471 return TCL_ERROR; 1472 } 1473 return TCL_OK; 1474 } 1475 1476 static Rappture::CmdSpec dataSetGetVectorOps[] = { 1477 {"pixel", 1, DataSetGetVectorPixelOp, 6, 6, "x y dataSetName"}, 1478 {"world", 1, DataSetGetVectorWorldOp, 7, 7, "x y z dataSetName"} 1479 }; 1480 static int nDataSetGetVectorOps = NumCmdSpecs(dataSetGetVectorOps); 1481 1482 static int 1483 DataSetGetVectorOp(ClientData clientData, Tcl_Interp *interp, int objc, 1484 Tcl_Obj *const *objv) 1485 { 1486 Tcl_ObjCmdProc *proc; 1487 1488 proc = Rappture::GetOpFromObj(interp, nDataSetGetVectorOps, dataSetGetVectorOps, 1359 1489 Rappture::CMDSPEC_ARG2, objc, objv, 0); 1360 1490 if (proc == NULL) { … … 1393 1523 g_renderer->setUseCumulativeDataRange(false); 1394 1524 } else { 1525 Tcl_AppendResult(interp, "bad maprange option \"", value, 1526 "\": should be all, visible, or separate", (char*)NULL); 1527 return TCL_ERROR; 1528 } 1529 return TCL_OK; 1530 } 1531 1532 static int 1533 DataSetNamesOp(ClientData clientData, Tcl_Interp *interp, int objc, 1534 Tcl_Obj *const *objv) 1535 { 1536 std::vector<std::string> dataSets; 1537 g_renderer->getDataSetNames(dataSets); 1538 std::ostringstream oss; 1539 size_t len = 0; 1540 oss << "nv>dataset names {"; 1541 len += 18; 1542 for (size_t i = 0; i < dataSets.size(); i++) { 1543 oss << "\"" << dataSets[i] << "\""; 1544 len += 2 + dataSets[i].length(); 1545 if (i < dataSets.size() - 1) { 1546 oss << " "; 1547 len++; 1548 } 1549 } 1550 oss << "}\n"; 1551 len += 2; 1552 1553 size_t bytesWritten = SocketWrite(oss.str().c_str(), len); 1554 1555 if (bytesWritten < 0) { 1395 1556 return TCL_ERROR; 1396 1557 } … … 1416 1577 1417 1578 static Rappture::CmdSpec dataSetOps[] = { 1418 {"add", 1, DataSetAddOp, 6, 6, "name data follows nBytes"}, 1419 {"delete", 1, DataSetDeleteOp, 2, 3, "?name?"}, 1420 {"getvalue", 1, DataSetGetValueOp, 6, 7, "oper x y ?z? name"}, 1421 {"maprange", 1, DataSetMapRangeOp, 3, 3, "value"}, 1422 {"opacity", 1, DataSetOpacityOp, 3, 4, "value ?name?"}, 1423 {"scalar", 1, DataSetActiveScalarsOp, 3, 4, "scalarName ?name?"}, 1424 {"vector", 2, DataSetActiveVectorsOp, 3, 4, "vectorName ?name?"}, 1425 {"visible", 2, DataSetVisibleOp, 3, 4, "bool ?name?"} 1579 {"add", 1, DataSetAddOp, 6, 6, "name data follows nBytes"}, 1580 {"delete", 1, DataSetDeleteOp, 2, 3, "?name?"}, 1581 {"getscalar", 4, DataSetGetScalarOp, 6, 7, "oper x y ?z? name"}, 1582 {"getvector", 4, DataSetGetVectorOp, 6, 7, "oper x y ?z? name"}, 1583 {"maprange", 1, DataSetMapRangeOp, 3, 3, "value"}, 1584 {"names", 1, DataSetNamesOp, 2, 2, ""}, 1585 {"opacity", 1, DataSetOpacityOp, 3, 4, "value ?name?"}, 1586 {"scalar", 1, DataSetActiveScalarsOp, 3, 4, "scalarName ?name?"}, 1587 {"vector", 2, DataSetActiveVectorsOp, 3, 4, "vectorName ?name?"}, 1588 {"visible", 2, DataSetVisibleOp, 3, 4, "bool ?name?"} 1426 1589 }; 1427 1590 static int nDataSetOps = NumCmdSpecs(dataSetOps); … … 1476 1639 if (objc == 4) { 1477 1640 const char *name = Tcl_GetString(objv[3]); 1478 g_renderer->addGlyphs(name, shape); 1479 } else { 1480 g_renderer->addGlyphs("all", shape); 1641 if (!g_renderer->addGlyphs(name, shape)) { 1642 Tcl_AppendResult(interp, "Failed to create glyphs", (char*)NULL); 1643 return TCL_ERROR; 1644 } 1645 } else { 1646 if (!g_renderer->addGlyphs("all", shape)) { 1647 Tcl_AppendResult(interp, "Failed to create glyphs for one or more data sets", (char*)NULL); 1648 return TCL_ERROR; 1649 } 1481 1650 } 1482 1651 return TCL_OK; … … 1864 2033 { 1865 2034 std::vector<double> contourList; 2035 double heightScale; 1866 2036 1867 2037 int clistc; … … 1880 2050 } 1881 2051 1882 if (objc == 5) { 1883 const char *name = Tcl_GetString(objv[4]); 1884 g_renderer->addHeightMap(name, contourList); 1885 } else { 1886 g_renderer->addHeightMap("all", contourList); 2052 if (Tcl_GetDoubleFromObj(interp, objv[4], &heightScale) != TCL_OK) { 2053 return TCL_ERROR; 2054 } 2055 2056 if (objc == 6) { 2057 const char *name = Tcl_GetString(objv[5]); 2058 if (!g_renderer->addHeightMap(name, contourList, heightScale)) { 2059 Tcl_AppendResult(interp, "Failed to create heightmap", (char*)NULL); 2060 return TCL_ERROR; 2061 } 2062 } else { 2063 if (!g_renderer->addHeightMap("all", contourList, heightScale)) { 2064 Tcl_AppendResult(interp, "Failed to create heightmap for one or more data sets", (char*)NULL); 2065 return TCL_ERROR; 2066 } 1887 2067 } 1888 2068 return TCL_OK; … … 1894 2074 { 1895 2075 int numContours; 2076 double heightScale; 1896 2077 if (Tcl_GetIntFromObj(interp, objv[3], &numContours) != TCL_OK) { 1897 2078 return TCL_ERROR; 1898 2079 } 1899 if (objc == 5) { 1900 const char *name = Tcl_GetString(objv[4]); 1901 g_renderer->addHeightMap(name, numContours); 1902 } else { 1903 g_renderer->addHeightMap("all", numContours); 2080 if (Tcl_GetDoubleFromObj(interp, objv[4], &heightScale) != TCL_OK) { 2081 return TCL_ERROR; 2082 } 2083 if (objc == 6) { 2084 const char *name = Tcl_GetString(objv[5]); 2085 if (!g_renderer->addHeightMap(name, numContours, heightScale)) { 2086 Tcl_AppendResult(interp, "Failed to create heightmap", (char*)NULL); 2087 return TCL_ERROR; 2088 } 2089 } else { 2090 if (!g_renderer->addHeightMap("all", numContours, heightScale)) { 2091 Tcl_AppendResult(interp, "Failed to create heightmap for one or more data sets", (char*)NULL); 2092 return TCL_ERROR; 2093 } 1904 2094 } 1905 2095 return TCL_OK; … … 1907 2097 1908 2098 static Rappture::CmdSpec heightmapAddOps[] = { 1909 {"contourlist", 1, HeightMapAddContourListOp, 4, 5, "contourList?dataSetName?"},1910 {"numcontours", 1, HeightMapAddNumContoursOp, 4, 5, "numContours?dataSetName?"}2099 {"contourlist", 1, HeightMapAddContourListOp, 5, 6, "contourList heightscale ?dataSetName?"}, 2100 {"numcontours", 1, HeightMapAddNumContoursOp, 5, 6, "numContours heightscale ?dataSetName?"} 1911 2101 }; 1912 2102 static int nHeightmapAddOps = NumCmdSpecs(heightmapAddOps); … … 1977 2167 1978 2168 static int 1979 HeightMapContourVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc, 1980 Tcl_Obj *const *objv) 2169 HeightMapContourListOp(ClientData clientData, Tcl_Interp *interp, int objc, 2170 Tcl_Obj *const *objv) 2171 { 2172 std::vector<double> contourList; 2173 2174 int clistc; 2175 Tcl_Obj **clistv; 2176 2177 if (Tcl_ListObjGetElements(interp, objv[2], &clistc, &clistv) != TCL_OK) { 2178 return TCL_ERROR; 2179 } 2180 2181 for (int i = 0; i < clistc; i++) { 2182 double val; 2183 if (Tcl_GetDoubleFromObj(interp, clistv[i], &val) != TCL_OK) { 2184 return TCL_ERROR; 2185 } 2186 contourList.push_back(val); 2187 } 2188 2189 if (objc == 4) { 2190 const char *name = Tcl_GetString(objv[3]); 2191 g_renderer->setHeightMapContourList(name, contourList); 2192 } else { 2193 g_renderer->setHeightMapContourList("all", contourList); 2194 } 2195 return TCL_OK; 2196 } 2197 2198 static int 2199 HeightMapContourLineVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc, 2200 Tcl_Obj *const *objv) 1981 2201 { 1982 2202 bool state; … … 1986 2206 if (objc == 4) { 1987 2207 const char *name = Tcl_GetString(objv[3]); 1988 g_renderer->setHeightMapContourVisibility(name, state); 1989 } else { 1990 g_renderer->setHeightMapContourVisibility("all", state); 2208 g_renderer->setHeightMapContourLineVisibility(name, state); 2209 } else { 2210 g_renderer->setHeightMapContourLineVisibility("all", state); 2211 } 2212 return TCL_OK; 2213 } 2214 2215 static int 2216 HeightMapContourSurfaceVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc, 2217 Tcl_Obj *const *objv) 2218 { 2219 bool state; 2220 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 2221 return TCL_ERROR; 2222 } 2223 if (objc == 4) { 2224 const char *name = Tcl_GetString(objv[3]); 2225 g_renderer->setHeightMapContourSurfaceVisibility(name, state); 2226 } else { 2227 g_renderer->setHeightMapContourSurfaceVisibility("all", state); 1991 2228 } 1992 2229 return TCL_OK; … … 2089 2326 } else { 2090 2327 g_renderer->setHeightMapEdgeWidth("all", width); 2328 } 2329 return TCL_OK; 2330 } 2331 2332 static int 2333 HeightMapNumContoursOp(ClientData clientData, Tcl_Interp *interp, int objc, 2334 Tcl_Obj *const *objv) 2335 { 2336 int numContours; 2337 2338 if (Tcl_GetIntFromObj(interp, objv[2], &numContours) != TCL_OK) { 2339 return TCL_ERROR; 2340 } 2341 if (objc == 4) { 2342 const char *name = Tcl_GetString(objv[3]); 2343 g_renderer->setHeightMapNumContours(name, numContours); 2344 } else { 2345 g_renderer->setHeightMapNumContours("all", numContours); 2091 2346 } 2092 2347 return TCL_OK; … … 2216 2471 } 2217 2472 2473 static int 2474 HeightMapWireframeOp(ClientData clientData, Tcl_Interp *interp, int objc, 2475 Tcl_Obj *const *objv) 2476 { 2477 bool state; 2478 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 2479 return TCL_ERROR; 2480 } 2481 if (objc == 4) { 2482 const char *name = Tcl_GetString(objv[3]); 2483 g_renderer->setHeightMapWireframe(name, state); 2484 } else { 2485 g_renderer->setHeightMapWireframe("all", state); 2486 } 2487 return TCL_OK; 2488 } 2489 2218 2490 static Rappture::CmdSpec heightmapOps[] = { 2219 {"add", 1, HeightMapAddOp, 4, 5, "oper value ?dataSetName?"}, 2220 {"colormap", 1, HeightMapColorMapOp, 3, 4, "colorMapName ?dataSetName?"}, 2491 {"add", 1, HeightMapAddOp, 5, 6, "oper value ?dataSetName?"}, 2492 {"colormap", 2, HeightMapColorMapOp, 3, 4, "colorMapName ?dataSetName?"}, 2493 {"contourlist", 2, HeightMapContourListOp, 3, 4, "contourList ?dataSetName?"}, 2221 2494 {"delete", 1, HeightMapDeleteOp, 2, 3, "?dataSetName?"}, 2222 2495 {"edges", 1, HeightMapEdgeVisibilityOp, 3, 4, "bool ?dataSetName?"}, 2223 2496 {"heightscale", 1, HeightMapHeightScaleOp, 3, 4, "value ?dataSetName?"}, 2224 2497 {"isolinecolor", 8, HeightMapContourLineColorOp, 5, 6, "r g b ?dataSetName?"}, 2225 {"isolines", 8, HeightMapContour VisibleOp, 3, 4, "bool ?dataSetName?"},2498 {"isolines", 8, HeightMapContourLineVisibleOp, 3, 4, "bool ?dataSetName?"}, 2226 2499 {"isolinewidth", 8, HeightMapContourLineWidthOp, 3, 4, "width ?dataSetName?"}, 2227 2500 {"lighting", 3, HeightMapLightingOp, 3, 4, "bool ?dataSetName?"}, 2228 2501 {"linecolor", 5, HeightMapLineColorOp, 5, 6, "r g b ?dataSetName?"}, 2229 2502 {"linewidth", 5, HeightMapLineWidthOp, 3, 4, "width ?dataSetName?"}, 2503 {"numcontours", 1, HeightMapNumContoursOp, 3, 4, "numContours ?dataSetName?"}, 2230 2504 {"opacity", 2, HeightMapOpacityOp, 3, 4, "value ?dataSetName?"}, 2231 2505 {"orient", 2, HeightMapOrientOp, 6, 7, "qw qx qy qz ?dataSetName?"}, 2232 2506 {"pos", 1, HeightMapPositionOp, 5, 6, "x y z ?dataSetName?"}, 2233 2507 {"scale", 1, HeightMapScaleOp, 5, 6, "sx sy sz ?dataSetName?"}, 2508 {"surface", 2, HeightMapContourSurfaceVisibleOp, 3, 4, "bool ?dataSetName?"}, 2234 2509 {"visible", 2, HeightMapVisibleOp, 3, 4, "bool ?dataSetName?"}, 2235 {"volumeslice", 2, HeightMapVolumeSliceOp, 4, 5, "axis ratio ?dataSetName?"} 2510 {"volumeslice", 2, HeightMapVolumeSliceOp, 4, 5, "axis ratio ?dataSetName?"}, 2511 {"wireframe", 1, HeightMapWireframeOp, 3, 4, "bool ?dataSetName?"} 2236 2512 }; 2237 2513 static int nHeightmapOps = NumCmdSpecs(heightmapOps); … … 2310 2586 if (objc == 3) { 2311 2587 const char *name = Tcl_GetString(objv[2]); 2312 g_renderer->addLIC(name); 2313 } else { 2314 g_renderer->addLIC("all"); 2588 if (!g_renderer->addLIC(name)) { 2589 Tcl_AppendResult(interp, "Failed to create lic", (char*)NULL); 2590 return TCL_ERROR; 2591 } 2592 } else { 2593 if (!g_renderer->addLIC("all")) { 2594 Tcl_AppendResult(interp, "Failed to create lic for one or more data sets", (char*)NULL); 2595 return TCL_ERROR; 2596 } 2315 2597 } 2316 2598 return TCL_OK; … … 2574 2856 if (objc == 3) { 2575 2857 const char *name = Tcl_GetString(objv[2]); 2576 g_renderer->addMolecule(name); 2577 } else { 2578 g_renderer->addMolecule("all"); 2858 if (!g_renderer->addMolecule(name)) { 2859 Tcl_AppendResult(interp, "Failed to create molecule", (char*)NULL); 2860 return TCL_ERROR; 2861 } 2862 } else { 2863 if (!g_renderer->addMolecule("all")) { 2864 Tcl_AppendResult(interp, "Failed to create molecule for one or more data sets", (char*)NULL); 2865 return TCL_ERROR; 2866 } 2579 2867 } 2580 2868 return TCL_OK; … … 2889 3177 if (objc == 3) { 2890 3178 const char *name = Tcl_GetString(objv[2]); 2891 g_renderer->addPolyData(name); 2892 } else { 2893 g_renderer->addPolyData("all"); 3179 if (!g_renderer->addPolyData(name)) { 3180 Tcl_AppendResult(interp, "Failed to create polydata", (char*)NULL); 3181 return TCL_ERROR; 3182 } 3183 } else { 3184 if (!g_renderer->addPolyData("all")) { 3185 Tcl_AppendResult(interp, "Failed to create polydata for one or more data sets", (char*)NULL); 3186 return TCL_ERROR; 3187 } 2894 3188 } 2895 3189 return TCL_OK; … … 3031 3325 } else { 3032 3326 g_renderer->setPolyDataOrientation("all", quat); 3327 } 3328 return TCL_OK; 3329 } 3330 3331 static int 3332 PolyDataPointSizeOp(ClientData clientData, Tcl_Interp *interp, int objc, 3333 Tcl_Obj *const *objv) 3334 { 3335 float size; 3336 if (GetFloatFromObj(interp, objv[2], &size) != TCL_OK) { 3337 return TCL_ERROR; 3338 } 3339 if (objc == 4) { 3340 const char *name = Tcl_GetString(objv[3]); 3341 g_renderer->setPolyDataPointSize(name, size); 3342 } else { 3343 g_renderer->setPolyDataPointSize("all", size); 3033 3344 } 3034 3345 return TCL_OK; … … 3117 3428 {"opacity", 2, PolyDataOpacityOp, 3, 4, "value ?dataSetName?"}, 3118 3429 {"orient", 2, PolyDataOrientOp, 6, 7, "qw qx qy qz ?dataSetName?"}, 3119 {"pos", 1, PolyDataPositionOp, 5, 6, "x y z ?dataSetName?"}, 3430 {"pos", 2, PolyDataPositionOp, 5, 6, "x y z ?dataSetName?"}, 3431 {"ptsize", 2, PolyDataPointSizeOp, 3, 4, "size ?dataSetName?"}, 3120 3432 {"scale", 1, PolyDataScaleOp, 5, 6, "sx sy sz ?dataSetName?"}, 3121 3433 {"visible", 1, PolyDataVisibleOp, 3, 4, "bool ?dataSetName?"}, … … 3144 3456 if (objc == 3) { 3145 3457 const char *name = Tcl_GetString(objv[2]); 3146 g_renderer->addPseudoColor(name); 3147 } else { 3148 g_renderer->addPseudoColor("all"); 3458 if (!g_renderer->addPseudoColor(name)) { 3459 Tcl_AppendResult(interp, "Failed to create pseudocolor", (char*)NULL); 3460 return TCL_ERROR; 3461 } 3462 } else { 3463 if (!g_renderer->addPseudoColor("all")) { 3464 Tcl_AppendResult(interp, "Failed to create pseudocolor for one or more data sets", (char*)NULL); 3465 return TCL_ERROR; 3466 } 3149 3467 } 3150 3468 return TCL_OK; … … 3529 3847 if (objc == 3) { 3530 3848 const char *name = Tcl_GetString(objv[2]); 3531 g_renderer->addStreamlines(name); 3532 } else { 3533 g_renderer->addStreamlines("all"); 3849 if (!g_renderer->addStreamlines(name)) { 3850 Tcl_AppendResult(interp, "Failed to create streamlines", (char*)NULL); 3851 return TCL_ERROR; 3852 } 3853 } else { 3854 if (!g_renderer->addStreamlines("all")) { 3855 Tcl_AppendResult(interp, "Failed to create streamlines for one or more data sets", (char*)NULL); 3856 return TCL_ERROR; 3857 } 3534 3858 } 3535 3859 return TCL_OK; … … 4103 4427 if (objc == 3) { 4104 4428 const char *name = Tcl_GetString(objv[2]); 4105 g_renderer->addVolume(name); 4106 } else { 4107 g_renderer->addVolume("all"); 4429 if (!g_renderer->addVolume(name)) { 4430 Tcl_AppendResult(interp, "Failed to create volume", (char*)NULL); 4431 return TCL_ERROR; 4432 } 4433 } else { 4434 if (!g_renderer->addVolume("all")) { 4435 Tcl_AppendResult(interp, "Failed to create volume for one or more data sets", (char*)NULL); 4436 return TCL_ERROR; 4437 } 4108 4438 } 4109 4439 return TCL_OK; -
trunk/packages/vizservers/vtkvis/protocol.txt
r2402 r2423 47 47 camera orient <quatW> <quatX> <quatY> <quatZ> 48 48 Set scene orientation using a quaternion 49 camera ortho < x> <y> <width> <height>50 Supply world coordinate bounds of plot area for image camera mode51 Data is assumed to lie in XY plane (z = 0)49 camera ortho <coordMode> <x> <y> <width> <height> 50 <coordMode> = pixel|world 51 Supply bounds of plot area for image camera mode 52 52 camera pan <x> <y> 53 53 <x,y> viewport coordinates (window center at 0,0). Positive x pan … … 75 75 dataset add <datasetName> data follows <nbytes> 76 76 dataset delete <?datasetName?> 77 dataset getvalue world <x> <y> <z> <datasetName> 78 dataset getvalue pixel <x> <y> <datasetName> 77 dataset getscalar world <x> <y> <z> <datasetName> 78 dataset getscalar pixel <x> <y> <datasetName> 79 dataset getvector world <x> <y> <z> <datasetName> 80 dataset getvector pixel <x> <y> <datasetName> 79 81 Use pixel for image camera mode 80 82 dataset maprange <val> … … 149 151 glyphs wireframe <bool> <?datasetName?> 150 152 151 heightmap add numcontours <n> < ?dataSetName?>153 heightmap add numcontours <n> <heightScale> <?dataSetName?> 152 154 Generate evenly spaced contours including range endpoints. See also 153 155 'dataset maprange' command. 154 heightmap add contourlist <list> < ?dataSetName?>156 heightmap add contourlist <list> <heightScale> <?dataSetName?> 155 157 list = {isoval1 isoval2 isoval3...} 156 158 heightmap colormap <colorMapName> <?dataSetName?> 159 heightmap contourlist <list> <?dataSetName?> 157 160 heightmap delete <?dataSetName?> 158 161 heightmap edges <bool> <?dataSetName?> … … 164 167 heightmap linecolor <r> <g> <b> <?dataSetName?> 165 168 heightmap linewidth <width> <?dataSetName?> 169 heightmap numcontours <n> <?dataSetName?> 166 170 heightmap opacity <value> <?dataSetName?> 167 171 heightmap orient <qw> <qx> <qy> <qz> <?dataSetName?> 168 172 heightmap pos <x> <y> <z> <?dataSetName?> 169 173 heightmap scale <sx> <sy> <sz> <?dataSetName?> 174 heightmap surface <bool> <?dataSetName?> 175 Toggle rendering of colormapped surface (mountain plot or cutplane) 170 176 heightmap visible <bool> <?dataSetName?> 171 177 heightmap volumeslice axis ratio <?dataSetName?> 172 178 For 3D data, select a slice along a principle axis of the volume. The 173 179 ratio is [0,1] 180 heightmap wireframe <bool> <?datasetName?> 174 181 175 182 lic add <?datasetName?> … … 218 225 polydata orient <qw> <qx> <qy> <qz> <?dataSetName?> 219 226 polydata pos <x> <y> <z> <?dataSetName?> 227 polydata ptsize <size> <?dataSetName?> 220 228 polydata scale <sx> <sy> <sz> <?dataSetName?> 221 229 polydata visible <bool> <?datasetName?> … … 301 309 nv>image -type image -bytes <nbytes> 302 310 <binary RGB data> 303 nv>image -type image -bbox {x 1 y1 x2 y2} -bytes <nbytes>311 nv>image -type image -bbox {x y w h} -bytes <nbytes> 304 312 <binary RGB data> 305 Note: in this form, the bbox is the upper left and lower right screen corners 306 in world coordinates. This form is currently used only if the camera mode is 307 set to 'image'. 313 The bounding box of the 2D image camera zoom region is supplied 314 Note: The bbox coordinates are in the form used by 'camera ortho world ...': 315 x,y - world coordinate of lower left corner, w,h - width height in world coords 316 This form is currently used only if the camera mode is set to 'image'. 308 317 nv>legend <colormapName> <nbytes> 309 318 <binary RGB data> 310 nv>dataset value world <x> <y> <z> <value> 311 nv>dataset value pixel <x> <y> <value> 319 nv>dataset scalar world <x> <y> <z> <value> <dataSetName> 320 nv>dataset scalar pixel <x> <y> <value> <dataSetName> 321 nv>dataset vector world <x> <y> <z> <valueX> <valueY> <valueZ> <dataSetName> 322 nv>dataset vector pixel <x> <y> <valueX> <valueY> <valueZ> <dataSetName> 312 323 313 324 ================================================================================ -
trunk/packages/vizservers/vtkvis/vtkRpCubeAxesActor2D.cpp
r2100 r2423 419 419 this->YAxis->SetFontFactor(AxisFontFactor); 420 420 this->YAxis->SetProperty(this->GetProperty()); 421 422 this->ZAxis->GetPositionCoordinate()->SetValue(zCoords[0], zCoords[1]); 423 this->ZAxis->GetPosition2Coordinate()->SetValue(zCoords[2], zCoords[3]); 424 this->ZAxis->SetRange(zRange[0], zRange[1]); 421 if ( this->YAxisVisibility ) { 422 this->ZAxis->GetPositionCoordinate()->SetValue(zCoords[0], zCoords[1]); 423 this->ZAxis->GetPosition2Coordinate()->SetValue(zCoords[2], zCoords[3]); 424 this->ZAxis->SetRange(zRange[0], zRange[1]); 425 } else { 426 this->ZAxis->GetPositionCoordinate()->SetValue(zCoords[2], zCoords[3]); 427 this->ZAxis->GetPosition2Coordinate()->SetValue(zCoords[0], zCoords[1]); 428 this->ZAxis->SetRange(zRange[1], zRange[0]); 429 } 425 430 this->ZAxis->SetTitle(this->Labels[zAxes]); 426 431 this->ZAxis->SetNumberOfLabels(this->NumberOfLabels);
Note: See TracChangeset
for help on using the changeset viewer.