Changeset 2146
- Timestamp:
- Mar 24, 2011, 9:41:10 AM (14 years ago)
- Location:
- trunk/packages/vizservers/vtkvis
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/vtkvis/RpPseudoColor.cpp
r2137 r2146 95 95 _lut->SetRange(dataRange); 96 96 97 _dsMapper->UseLookupTableScalarRangeOn(); 97 98 _dsMapper->SetLookupTable(_lut); 98 _dsMapper->SetScalarRange(dataRange);99 //_dsMapper->GetLookupTable()->SetRange(dataRange);100 99 //_dsMapper->InterpolateScalarsBeforeMappingOn(); 101 100 102 101 initActor(); 103 102 _dsActor->SetMapper(_dsMapper); 104 //_dsActor->GetProperty()->SetRepresentationToWireframe();105 103 } 106 104 -
trunk/packages/vizservers/vtkvis/RpVtkRenderer.cpp
r2137 r2146 38 38 _needsRedraw(true), 39 39 _windowWidth(320), 40 _windowHeight(320) 40 _windowHeight(320), 41 _useCumulativeRanges(true) 41 42 { 42 43 _bgColor[0] = 0; … … 48 49 _clippingPlanes = vtkSmartPointer<vtkPlaneCollection>::New(); 49 50 // bottom 50 vtk Plane *plane0 = vtkPlane::New();51 vtkSmartPointer<vtkPlane> plane0 = vtkSmartPointer<vtkPlane>::New(); 51 52 plane0->SetNormal(0, 1, 0); 52 53 plane0->SetOrigin(0, 0, 0); 53 54 _clippingPlanes->AddItem(plane0); 54 55 // left 55 vtk Plane *plane1 = vtkPlane::New();56 vtkSmartPointer<vtkPlane> plane1 = vtkSmartPointer<vtkPlane>::New(); 56 57 plane1->SetNormal(1, 0, 0); 57 58 plane1->SetOrigin(0, 0, 0); 58 59 _clippingPlanes->AddItem(plane1); 59 60 // top 60 vtk Plane *plane2 = vtkPlane::New();61 vtkSmartPointer<vtkPlane> plane2 = vtkSmartPointer<vtkPlane>::New(); 61 62 plane2->SetNormal(0, -1, 0); 62 63 plane2->SetOrigin(0, 1, 0); 63 64 _clippingPlanes->AddItem(plane2); 64 65 // right 65 vtk Plane *plane3 = vtkPlane::New();66 vtkSmartPointer<vtkPlane> plane3 = vtkSmartPointer<vtkPlane>::New(); 66 67 plane3->SetNormal(-1, 0, 0); 67 68 plane3->SetOrigin(1, 0, 0); … … 300 301 if (ds) { 301 302 bool ret = ds->setDataFile(filename); 302 PseudoColor *ps = getPseudoColor(id); 303 if (ps) { 304 ps->setDataSet(ds); 305 } 303 collectDataRanges(_cumulativeDataRange); 304 updateRanges(_useCumulativeRanges); 306 305 _needsRedraw = true; 307 306 return ret; … … 317 316 DataSet *ds = getDataSet(id); 318 317 if (ds) { 318 bool ret = ds->setData(data, nbytes); 319 collectDataRanges(_cumulativeDataRange); 320 updateRanges(_useCumulativeRanges); 319 321 _needsRedraw = true; 320 return ds->setData(data, nbytes); 321 collectDataRanges(_cumulativeDataRange); 322 return ret; 322 323 } else 323 324 return false; … … 628 629 629 630 do { 631 TRACE("Deleting ColorMap %s", itr->second->getName().c_str()); 632 630 633 // TODO: Check if color map is used in PseudoColors? 631 634 delete itr->second; … … 640 643 * returned if the color map is not found 641 644 */ 642 bool Renderer::renderColorMap(const ColorMapId& id, const char *title, 645 bool Renderer::renderColorMap(const ColorMapId& id, 646 const DataSetId& dataSetID, 647 const char *title, 643 648 int width, int height, 644 649 vtkUnsignedCharArray *imgData) … … 667 672 _legendRenderer->AddActor(_scalarBarActor); 668 673 } 669 _scalarBarActor->SetLookupTable(colorMap->getLookupTable()); 674 675 vtkSmartPointer<vtkLookupTable> lut = colorMap->getLookupTable(); 676 if (dataSetID.compare("all") == 0) { 677 lut->SetRange(_cumulativeDataRange); 678 } else { 679 DataSet *dataSet = getDataSet(dataSetID); 680 if (dataSet == NULL) { 681 lut->SetRange(_cumulativeDataRange); 682 } else { 683 double range[2]; 684 dataSet->getDataRange(range); 685 lut->SetRange(range); 686 } 687 } 688 _scalarBarActor->SetLookupTable(lut); 689 670 690 // Set viewport-relative width/height/pos 671 691 if (width > height) { … … 776 796 itr->second->getDataSet()->getName().c_str()); 777 797 778 itr->second->setLookupTable(cmap->getLookupTable()); 798 // Make a copy of the generic colormap lookup table, so 799 // data range can be set in the copy table to match the 800 // dataset being plotted 801 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New(); 802 lut->DeepCopy(cmap->getLookupTable()); 803 804 itr->second->setLookupTable(lut); 779 805 } while (doAll && ++itr != _pseudoColors.end()); 780 806 … … 1778 1804 if (bounds[i] == -DBL_MAX) 1779 1805 bounds[i] = 1; 1806 } 1807 } 1808 } 1809 1810 /** 1811 * \brief Update data ranges for color-mapping 1812 * 1813 * \param[in] useCumulative Use cumulative range of all DataSets 1814 */ 1815 void Renderer::updateRanges(bool useCumulative) 1816 { 1817 for (PseudoColorHashmap::iterator itr = _pseudoColors.begin(); 1818 itr != _pseudoColors.end(); ++itr) { 1819 vtkLookupTable *lut = itr->second->getLookupTable(); 1820 if (lut) { 1821 if (useCumulative) { 1822 lut->SetRange(_cumulativeDataRange); 1823 } else { 1824 double range[2]; 1825 if (itr->second->getDataSet()) { 1826 itr->second->getDataSet()->getDataRange(range); 1827 lut->SetRange(range); 1828 } 1829 } 1780 1830 } 1781 1831 } -
trunk/packages/vizservers/vtkvis/RpVtkRenderer.h
r2137 r2146 138 138 ColorMap *getColorMap(const ColorMapId& id); 139 139 140 bool renderColorMap(const ColorMapId& id, const char *title, 140 bool renderColorMap(const ColorMapId& id, 141 const DataSetId& dataSetID, 142 const char *title, 141 143 int width, int height, 142 144 vtkUnsignedCharArray *imgData); … … 228 230 void collectDataRanges(double *range); 229 231 232 void updateRanges(bool useCumulative); 233 230 234 void storeCameraOrientation(); 231 235 void restoreCameraOrientation(); … … 242 246 double _cameraUp[3]; 243 247 float _bgColor[3]; 248 bool _useCumulativeRanges; 244 249 double _cumulativeDataRange[2]; 245 250 -
trunk/packages/vizservers/vtkvis/RpVtkRendererCmd.cpp
r2137 r2146 827 827 if (objc < 4) { 828 828 Tcl_AppendResult(interp, "wrong # args: should be \"", 829 Tcl_GetString(objv[0]), " colormapName title width height \"", (char*)NULL);829 Tcl_GetString(objv[0]), " colormapName title width height ?dataSetName?\"", (char*)NULL); 830 830 return TCL_ERROR; 831 831 } … … 842 842 vtkSmartPointer<vtkUnsignedCharArray>::New(); 843 843 844 if (!g_renderer->renderColorMap(name, title, width, height, imgData)) { 845 Tcl_AppendResult(interp, "Color map \"", 846 name, "\" was not found", (char*)NULL); 847 return TCL_ERROR; 844 if (objc == 6) { 845 const char *dataSetName = Tcl_GetString(objv[5]); 846 if (!g_renderer->renderColorMap(name, dataSetName, title, width, height, imgData)) { 847 Tcl_AppendResult(interp, "Color map \"", 848 name, "\" was not found", (char*)NULL); 849 return TCL_ERROR; 850 } 851 } else { 852 if (!g_renderer->renderColorMap(name, "all", title, width, height, imgData)) { 853 Tcl_AppendResult(interp, "Color map \"", 854 name, "\" was not found", (char*)NULL); 855 return TCL_ERROR; 856 } 848 857 } 849 858 -
trunk/packages/vizservers/vtkvis/protocol.txt
r2137 r2146 36 36 colormap delete <?colorMapName?> 37 37 38 legend <colormapName> <legendTitle> <width> <height> 38 legend <colormapName> <legendTitle> <width> <height> <?datasetName?> 39 39 Causes legend to be rendered and written back with labels and title 40 40
Note: See TracChangeset
for help on using the changeset viewer.