Changeset 2402 for trunk/packages/vizservers/vtkvis/RpVtkRenderer.cpp
- Timestamp:
- Aug 22, 2011, 2:15:12 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/vtkvis/RpVtkRenderer.cpp
r2393 r2402 69 69 _cameraOrientation[2] = 0.0; 70 70 _cameraOrientation[3] = 0.0; 71 _cumulativeDataRange[0] = 0.0; 72 _cumulativeDataRange[1] = 1.0; 71 _cumulativeScalarRange[0] = 0.0; 72 _cumulativeScalarRange[1] = 1.0; 73 _cumulativeVectorMagnitudeRange[0] = 0.0; 74 _cumulativeVectorMagnitudeRange[1] = 1.0; 75 for (int i = 0; i < 3; i++) { 76 _cumulativeVectorComponentRange[i][0] = 0.0; 77 _cumulativeVectorComponentRange[i][1] = 1.0; 78 } 73 79 // clipping planes to prevent overdrawing axes 74 80 _activeClipPlanes = vtkSmartPointer<vtkPlaneCollection>::New(); … … 263 269 } while (doAll && itr != _contour2Ds.end()); 264 270 271 initCamera(); 265 272 _needsRedraw = true; 266 273 } … … 299 306 } while (doAll && itr != _contour3Ds.end()); 300 307 308 initCamera(); 301 309 _needsRedraw = true; 302 310 } … … 335 343 } while (doAll && itr != _glyphs.end()); 336 344 345 initCamera(); 337 346 _needsRedraw = true; 338 347 } … … 371 380 } while (doAll && itr != _heightMaps.end()); 372 381 382 initCamera(); 373 383 _needsRedraw = true; 374 384 } … … 407 417 } while (doAll && itr != _lics.end()); 408 418 419 initCamera(); 409 420 _needsRedraw = true; 410 421 } … … 443 454 } while (doAll && itr != _molecules.end()); 444 455 456 initCamera(); 445 457 _needsRedraw = true; 446 458 } … … 479 491 } while (doAll && itr != _polyDatas.end()); 480 492 493 initCamera(); 481 494 _needsRedraw = true; 482 495 } … … 515 528 } while (doAll && itr != _pseudoColors.end()); 516 529 530 initCamera(); 517 531 _needsRedraw = true; 518 532 } … … 551 565 } while (doAll && itr != _streamlines.end()); 552 566 567 initCamera(); 553 568 _needsRedraw = true; 554 569 } … … 587 602 } while (doAll && itr != _volumes.end()); 588 603 604 initCamera(); 589 605 _needsRedraw = true; 590 606 } … … 634 650 635 651 // Update cumulative data range 636 collectDataRanges(_cumulativeDataRange, _cumulativeRangeOnlyVisible);637 updateRanges(_useCumulativeRange); 638 652 updateRanges(); 653 654 initCamera(); 639 655 _needsRedraw = true; 640 656 } … … 649 665 DataSetHashmap::iterator itr = _dataSets.find(id); 650 666 if (itr == _dataSets.end()) { 667 #ifdef DEBUG 651 668 TRACE("DataSet not found: %s", id.c_str()); 669 #endif 652 670 return NULL; 653 671 } else … … 663 681 if (ds) { 664 682 bool ret = ds->setDataFile(filename); 665 collectDataRanges(_cumulativeDataRange, _cumulativeRangeOnlyVisible); 666 updateRanges(_useCumulativeRange); 683 updateRanges(); 667 684 _needsRedraw = true; 668 685 return ret; … … 679 696 if (ds) { 680 697 bool ret = ds->setData(data, nbytes); 681 collectDataRanges(_cumulativeDataRange, _cumulativeRangeOnlyVisible); 682 updateRanges(_useCumulativeRange); 698 updateRanges(); 683 699 _needsRedraw = true; 684 700 return ret; … … 712 728 713 729 if (ret) { 714 collectDataRanges(_cumulativeDataRange, _cumulativeRangeOnlyVisible); 715 updateRanges(_useCumulativeRange); 730 updateRanges(); 716 731 _needsRedraw = true; 717 732 } … … 745 760 746 761 if (ret) { 747 collectDataRanges(_cumulativeDataRange, _cumulativeRangeOnlyVisible); 748 updateRanges(_useCumulativeRange); 762 updateRanges(); 749 763 _needsRedraw = true; 750 764 } … … 762 776 _useCumulativeRange = state; 763 777 _cumulativeRangeOnlyVisible = onlyVisible; 764 collectDataRanges(_cumulativeDataRange, _cumulativeRangeOnlyVisible); 765 updateRanges(_useCumulativeRange); 778 updateRanges(); 766 779 _needsRedraw = true; 767 780 } 768 781 } 769 782 770 void Renderer::resetAxes( )783 void Renderer::resetAxes(double bounds[6]) 771 784 { 772 785 TRACE("Resetting axes"); … … 793 806 _renderer->AddViewProp(_cubeAxesActor); 794 807 } 795 double bounds[6]; 796 collectBounds(bounds, false); 797 _cubeAxesActor->SetBounds(bounds); 808 if (bounds == NULL) { 809 double newBounds[6]; 810 collectBounds(newBounds, false); 811 _cubeAxesActor->SetBounds(newBounds); 812 } else { 813 _cubeAxesActor->SetBounds(bounds); 814 } 798 815 } 799 816 } … … 1137 1154 1138 1155 /** 1139 * \brief Add a color map for use in the Renderer 1156 * \brief Notify graphics objects that color map has changed 1157 */ 1158 void Renderer::updateColorMap(ColorMap *cmap) 1159 { 1160 for (Contour3DHashmap::iterator itr = _contour3Ds.begin(); 1161 itr != _contour3Ds.end(); ++itr) { 1162 if (itr->second->getColorMap() == cmap) { 1163 itr->second->updateColorMap(); 1164 _needsRedraw = true; 1165 } 1166 } 1167 for (GlyphsHashmap::iterator itr = _glyphs.begin(); 1168 itr != _glyphs.end(); ++itr) { 1169 if (itr->second->getColorMap() == cmap) { 1170 itr->second->updateColorMap(); 1171 _needsRedraw = true; 1172 } 1173 } 1174 for (HeightMapHashmap::iterator itr = _heightMaps.begin(); 1175 itr != _heightMaps.end(); ++itr) { 1176 if (itr->second->getColorMap() == cmap) { 1177 itr->second->updateColorMap(); 1178 _needsRedraw = true; 1179 } 1180 } 1181 for (LICHashmap::iterator itr = _lics.begin(); 1182 itr != _lics.end(); ++itr) { 1183 if (itr->second->getColorMap() == cmap) { 1184 itr->second->updateColorMap(); 1185 _needsRedraw = true; 1186 } 1187 } 1188 for (MoleculeHashmap::iterator itr = _molecules.begin(); 1189 itr != _molecules.end(); ++itr) { 1190 if (itr->second->getColorMap() == cmap) { 1191 itr->second->updateColorMap(); 1192 _needsRedraw = true; 1193 } 1194 } 1195 for (PseudoColorHashmap::iterator itr = _pseudoColors.begin(); 1196 itr != _pseudoColors.end(); ++itr) { 1197 if (itr->second->getColorMap() == cmap) { 1198 itr->second->updateColorMap(); 1199 _needsRedraw = true; 1200 } 1201 } 1202 for (StreamlinesHashmap::iterator itr = _streamlines.begin(); 1203 itr != _streamlines.end(); ++itr) { 1204 if (itr->second->getColorMap() == cmap) { 1205 itr->second->updateColorMap(); 1206 _needsRedraw = true; 1207 } 1208 } 1209 for (VolumeHashmap::iterator itr = _volumes.begin(); 1210 itr != _volumes.end(); ++itr) { 1211 if (itr->second->getColorMap() == cmap) { 1212 itr->second->updateColorMap(); 1213 _needsRedraw = true; 1214 } 1215 } 1216 } 1217 1218 /** 1219 * \brief Check if a ColorMap is in use by graphics objects 1220 */ 1221 bool Renderer::colorMapUsed(ColorMap *cmap) 1222 { 1223 for (Contour3DHashmap::iterator itr = _contour3Ds.begin(); 1224 itr != _contour3Ds.end(); ++itr) { 1225 if (itr->second->getColorMap() == cmap) 1226 return true; 1227 } 1228 for (GlyphsHashmap::iterator itr = _glyphs.begin(); 1229 itr != _glyphs.end(); ++itr) { 1230 if (itr->second->getColorMap() == cmap) 1231 return true; 1232 } 1233 for (HeightMapHashmap::iterator itr = _heightMaps.begin(); 1234 itr != _heightMaps.end(); ++itr) { 1235 if (itr->second->getColorMap() == cmap) 1236 return true; 1237 } 1238 for (LICHashmap::iterator itr = _lics.begin(); 1239 itr != _lics.end(); ++itr) { 1240 if (itr->second->getColorMap() == cmap) 1241 return true; 1242 } 1243 for (MoleculeHashmap::iterator itr = _molecules.begin(); 1244 itr != _molecules.end(); ++itr) { 1245 if (itr->second->getColorMap() == cmap) 1246 return true; 1247 } 1248 for (PseudoColorHashmap::iterator itr = _pseudoColors.begin(); 1249 itr != _pseudoColors.end(); ++itr) { 1250 if (itr->second->getColorMap() == cmap) 1251 return true; 1252 } 1253 for (StreamlinesHashmap::iterator itr = _streamlines.begin(); 1254 itr != _streamlines.end(); ++itr) { 1255 if (itr->second->getColorMap() == cmap) 1256 return true; 1257 } 1258 for (VolumeHashmap::iterator itr = _volumes.begin(); 1259 itr != _volumes.end(); ++itr) { 1260 if (itr->second->getColorMap() == cmap) 1261 return true; 1262 } 1263 return false; 1264 } 1265 1266 /** 1267 * \brief Add/replace a ColorMap for use in the Renderer 1140 1268 */ 1141 1269 void Renderer::addColorMap(const ColorMapId& id, ColorMap *colorMap) … … 1144 1272 colorMap->build(); 1145 1273 if (getColorMap(id) != NULL) { 1146 WARN("Replacing existing ColorMap %s", id.c_str()); 1147 deleteColorMap(id); 1148 } 1149 _colorMaps[id] = colorMap; 1274 TRACE("Replacing existing ColorMap %s", id.c_str()); 1275 // Copy to current colormap to avoid invalidating 1276 // pointers in graphics objects using the color map 1277 *_colorMaps[id] = *colorMap; 1278 delete colorMap; 1279 // Notify graphics objects of change 1280 updateColorMap(_colorMaps[id]); 1281 } else 1282 _colorMaps[id] = colorMap; 1150 1283 } else { 1151 1284 ERROR("NULL ColorMap"); … … 1191 1324 1192 1325 do { 1326 if (itr->second->getName().compare("default") == 0 || 1327 itr->second->getName().compare("volumeDefault") == 0 || 1328 itr->second->getName().compare("elementDefault") == 0) { 1329 if (id.compare("all") != 0) { 1330 WARN("Cannot delete a default color map"); 1331 } 1332 continue; 1333 } else if (colorMapUsed(itr->second)) { 1334 WARN("Cannot delete color map '%s', it is in use", itr->second->getName().c_str()); 1335 continue; 1336 } 1337 1193 1338 TRACE("Deleting ColorMap %s", itr->second->getName().c_str()); 1194 1339 1195 // TODO: Check if color map is used in PseudoColors?1196 1340 delete itr->second; 1197 1341 itr = _colorMaps.erase(itr); … … 1220 1364 _legendRenderWindow->DoubleBufferOff(); 1221 1365 _legendRenderWindow->OffScreenRenderingOn(); 1366 #else 1367 _legendRenderWindow->DoubleBufferOn(); 1368 _legendRenderWindow->SwapBuffersOff(); 1222 1369 #endif 1223 1370 } … … 1239 1386 vtkSmartPointer<vtkLookupTable> lut = colorMap->getLookupTable(); 1240 1387 if (dataSetID.compare("all") == 0) { 1241 lut->SetRange(_cumulative DataRange);1388 lut->SetRange(_cumulativeScalarRange); 1242 1389 } else { 1243 1390 DataSet *dataSet = getDataSet(dataSetID); 1244 1391 if (dataSet == NULL) { 1245 lut->SetRange(_cumulative DataRange);1392 lut->SetRange(_cumulativeScalarRange); 1246 1393 } else { 1247 1394 double range[2]; 1248 dataSet->get DataRange(range);1395 dataSet->getScalarRange(range); 1249 1396 lut->SetRange(range); 1250 1397 } … … 1310 1457 * \brief Create a new Contour2D and associate it with the named DataSet 1311 1458 */ 1312 void Renderer::addContour2D(const DataSetId& id )1459 void Renderer::addContour2D(const DataSetId& id, int numContours) 1313 1460 { 1314 1461 DataSetHashmap::iterator itr; … … 1335 1482 } 1336 1483 1337 Contour2D *contour = new Contour2D( );1484 Contour2D *contour = new Contour2D(numContours); 1338 1485 _contour2Ds[dsID] = contour; 1339 1486 1340 contour->setDataSet(ds); 1487 contour->setDataSet(ds, 1488 _useCumulativeRange, 1489 _cumulativeScalarRange, 1490 _cumulativeVectorMagnitudeRange, 1491 _cumulativeVectorComponentRange); 1341 1492 1342 1493 _renderer->AddViewProp(contour->getProp()); … … 1348 1499 1349 1500 /** 1501 * \brief Create a new Contour2D and associate it with the named DataSet 1502 */ 1503 void Renderer::addContour2D(const DataSetId& id, const std::vector<double>& contours) 1504 { 1505 DataSetHashmap::iterator itr; 1506 1507 bool doAll = false; 1508 1509 if (id.compare("all") == 0) { 1510 itr = _dataSets.begin(); 1511 } else { 1512 itr = _dataSets.find(id); 1513 } 1514 if (itr == _dataSets.end()) { 1515 ERROR("Unknown dataset %s", id.c_str()); 1516 return; 1517 } 1518 1519 do { 1520 DataSet *ds = itr->second; 1521 const DataSetId& dsID = ds->getName(); 1522 1523 if (getContour2D(dsID)) { 1524 WARN("Replacing existing Contour2D %s", dsID.c_str()); 1525 deleteContour2D(dsID); 1526 } 1527 1528 Contour2D *contour = new Contour2D(contours); 1529 _contour2Ds[dsID] = contour; 1530 1531 contour->setDataSet(ds, 1532 _useCumulativeRange, 1533 _cumulativeScalarRange, 1534 _cumulativeVectorMagnitudeRange, 1535 _cumulativeVectorComponentRange); 1536 1537 _renderer->AddViewProp(contour->getProp()); 1538 } while (doAll && ++itr != _dataSets.end()); 1539 1540 initCamera(); 1541 _needsRedraw = true; 1542 } 1543 1544 /** 1350 1545 * \brief Get the Contour2D associated with a named DataSet 1351 1546 */ … … 1355 1550 1356 1551 if (itr == _contour2Ds.end()) { 1552 #ifdef DEBUG 1357 1553 TRACE("Contour2D not found: %s", id.c_str()); 1554 #endif 1358 1555 return NULL; 1359 1556 } else … … 1522 1719 1523 1720 do { 1524 if (_useCumulativeRange) { 1525 itr->second->setContours(numContours, _cumulativeDataRange); 1526 } else { 1527 itr->second->setContours(numContours); 1528 } 1721 itr->second->setContours(numContours); 1529 1722 } while (doAll && ++itr != _contour2Ds.end()); 1530 1723 … … 1699 1892 * \brief Create a new Contour3D and associate it with the named DataSet 1700 1893 */ 1701 void Renderer::addContour3D(const DataSetId& id )1894 void Renderer::addContour3D(const DataSetId& id, int numContours) 1702 1895 { 1703 1896 DataSetHashmap::iterator itr; … … 1724 1917 } 1725 1918 1726 Contour3D *contour = new Contour3D( );1919 Contour3D *contour = new Contour3D(numContours); 1727 1920 _contour3Ds[dsID] = contour; 1728 1921 1729 contour->setDataSet(ds); 1730 1731 // Use the default color map 1732 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New(); 1733 ColorMap *cmap = getColorMap("default"); 1734 lut->DeepCopy(cmap->getLookupTable()); 1735 if (_useCumulativeRange) { 1736 lut->SetRange(_cumulativeDataRange); 1737 } else { 1738 double range[2]; 1739 ds->getDataRange(range); 1740 lut->SetRange(range); 1741 } 1742 1743 contour->setLookupTable(lut); 1922 contour->setDataSet(ds, 1923 _useCumulativeRange, 1924 _cumulativeScalarRange, 1925 _cumulativeVectorMagnitudeRange, 1926 _cumulativeVectorComponentRange); 1744 1927 1745 1928 _renderer->AddViewProp(contour->getProp()); … … 1753 1936 1754 1937 /** 1938 * \brief Create a new Contour3D and associate it with the named DataSet 1939 */ 1940 void Renderer::addContour3D(const DataSetId& id,const std::vector<double>& contours) 1941 { 1942 DataSetHashmap::iterator itr; 1943 1944 bool doAll = false; 1945 1946 if (id.compare("all") == 0) { 1947 itr = _dataSets.begin(); 1948 } else { 1949 itr = _dataSets.find(id); 1950 } 1951 if (itr == _dataSets.end()) { 1952 ERROR("Unknown dataset %s", id.c_str()); 1953 return; 1954 } 1955 1956 do { 1957 DataSet *ds = itr->second; 1958 const DataSetId& dsID = ds->getName(); 1959 1960 if (getContour3D(dsID)) { 1961 WARN("Replacing existing Contour3D %s", dsID.c_str()); 1962 deleteContour3D(dsID); 1963 } 1964 1965 Contour3D *contour = new Contour3D(contours); 1966 _contour3Ds[dsID] = contour; 1967 1968 contour->setDataSet(ds, 1969 _useCumulativeRange, 1970 _cumulativeScalarRange, 1971 _cumulativeVectorMagnitudeRange, 1972 _cumulativeVectorComponentRange); 1973 1974 _renderer->AddViewProp(contour->getProp()); 1975 } while (doAll && ++itr != _dataSets.end()); 1976 1977 if (_cameraMode == IMAGE) 1978 setCameraMode(PERSPECTIVE); 1979 initCamera(); 1980 _needsRedraw = true; 1981 } 1982 1983 /** 1755 1984 * \brief Get the Contour3D associated with a named DataSet 1756 1985 */ … … 1760 1989 1761 1990 if (itr == _contour3Ds.end()) { 1991 #ifdef DEBUG 1762 1992 TRACE("Contour3D not found: %s", id.c_str()); 1993 #endif 1763 1994 return NULL; 1764 1995 } else … … 1927 2158 1928 2159 do { 1929 if (_useCumulativeRange) { 1930 itr->second->setContours(numContours, _cumulativeDataRange); 1931 } else { 1932 itr->second->setContours(numContours); 1933 } 1934 } while (doAll && ++itr != _contour3Ds.end()); 2160 itr->second->setContours(numContours); 2161 } while (doAll && ++itr != _contour3Ds.end()); 1935 2162 1936 2163 initCamera(); … … 2052 2279 itr->second->getDataSet()->getName().c_str()); 2053 2280 2054 // Make a copy of the generic colormap lookup table, so 2055 // data range can be set in the copy table to match the 2056 // dataset being plotted 2057 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New(); 2058 lut->DeepCopy(cmap->getLookupTable()); 2059 2060 if (_useCumulativeRange) { 2061 lut->SetRange(_cumulativeDataRange); 2062 } else { 2063 if (itr->second->getDataSet() != NULL) { 2064 double range[2]; 2065 itr->second->getDataSet()->getDataRange(range); 2066 lut->SetRange(range); 2067 } 2068 } 2069 2070 itr->second->setLookupTable(lut); 2281 itr->second->setColorMap(cmap); 2071 2282 } while (doAll && ++itr != _contour3Ds.end()); 2072 2283 … … 2240 2451 * \brief Create a new Glyphs and associate it with the named DataSet 2241 2452 */ 2242 void Renderer::addGlyphs(const DataSetId& id )2453 void Renderer::addGlyphs(const DataSetId& id, Glyphs::GlyphShape shape) 2243 2454 { 2244 2455 DataSetHashmap::iterator itr; … … 2265 2476 } 2266 2477 2267 Glyphs *glyphs = new Glyphs( );2478 Glyphs *glyphs = new Glyphs(shape); 2268 2479 _glyphs[dsID] = glyphs; 2269 2480 2270 glyphs->setDataSet(ds); 2271 2272 // Use the default color map 2273 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New(); 2274 ColorMap *cmap = getColorMap("default"); 2275 lut->DeepCopy(cmap->getLookupTable()); 2276 if (_useCumulativeRange) { 2277 lut->SetRange(_cumulativeDataRange); 2278 } else { 2279 double range[2]; 2280 ds->getDataRange(range); 2281 lut->SetRange(range); 2282 } 2283 2284 glyphs->setLookupTable(lut); 2481 glyphs->setDataSet(ds, 2482 _useCumulativeRange, 2483 _cumulativeScalarRange, 2484 _cumulativeVectorMagnitudeRange, 2485 _cumulativeVectorComponentRange); 2285 2486 2286 2487 _renderer->AddViewProp(glyphs->getProp()); … … 2302 2503 2303 2504 if (itr == _glyphs.end()) { 2505 #ifdef DEBUG 2304 2506 TRACE("Glyphs not found: %s", id.c_str()); 2507 #endif 2305 2508 return NULL; 2306 2509 } else … … 2506 2709 itr->second->getDataSet()->getName().c_str()); 2507 2710 2508 // Make a copy of the generic colormap lookup table, so 2509 // data range can be set in the copy table to match the 2510 // dataset being plotted 2511 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New(); 2512 lut->DeepCopy(cmap->getLookupTable()); 2513 2514 if (_useCumulativeRange) { 2515 lut->SetRange(_cumulativeDataRange); 2516 } else { 2517 if (itr->second->getDataSet() != NULL) { 2518 double range[2]; 2519 itr->second->getDataSet()->getDataRange(range); 2520 lut->SetRange(range); 2521 } 2522 } 2523 2524 itr->second->setLookupTable(lut); 2711 itr->second->setColorMap(cmap); 2525 2712 } while (doAll && ++itr != _glyphs.end()); 2526 2713 … … 2833 3020 * \brief Create a new HeightMap and associate it with the named DataSet 2834 3021 */ 2835 void Renderer::addHeightMap(const DataSetId& id )3022 void Renderer::addHeightMap(const DataSetId& id, int numContours) 2836 3023 { 2837 3024 DataSetHashmap::iterator itr; … … 2858 3045 } 2859 3046 2860 HeightMap *hmap = new HeightMap( );3047 HeightMap *hmap = new HeightMap(numContours); 2861 3048 _heightMaps[dsID] = hmap; 2862 3049 2863 hmap->setDataSet(ds); 2864 2865 // Use the default color map 2866 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New(); 2867 ColorMap *cmap = getColorMap("default"); 2868 lut->DeepCopy(cmap->getLookupTable()); 2869 if (_useCumulativeRange) { 2870 lut->SetRange(_cumulativeDataRange); 2871 } else { 2872 double range[2]; 2873 ds->getDataRange(range); 2874 lut->SetRange(range); 2875 } 2876 2877 hmap->setLookupTable(lut); 3050 hmap->setDataSet(ds, 3051 _useCumulativeRange, 3052 _cumulativeScalarRange, 3053 _cumulativeVectorMagnitudeRange, 3054 _cumulativeVectorComponentRange); 2878 3055 2879 3056 _renderer->AddViewProp(hmap->getProp()); … … 2888 3065 2889 3066 /** 3067 * \brief Create a new HeightMap and associate it with the named DataSet 3068 */ 3069 void Renderer::addHeightMap(const DataSetId& id, const std::vector<double>& contours) 3070 { 3071 DataSetHashmap::iterator itr; 3072 3073 bool doAll = false; 3074 3075 if (id.compare("all") == 0) { 3076 itr = _dataSets.begin(); 3077 } else { 3078 itr = _dataSets.find(id); 3079 } 3080 if (itr == _dataSets.end()) { 3081 ERROR("Unknown dataset %s", id.c_str()); 3082 return; 3083 } 3084 3085 do { 3086 DataSet *ds = itr->second; 3087 const DataSetId& dsID = ds->getName(); 3088 3089 if (getHeightMap(dsID)) { 3090 WARN("Replacing existing HeightMap %s", dsID.c_str()); 3091 deleteHeightMap(dsID); 3092 } 3093 3094 HeightMap *hmap = new HeightMap(contours); 3095 _heightMaps[dsID] = hmap; 3096 3097 hmap->setDataSet(ds, 3098 _useCumulativeRange, 3099 _cumulativeScalarRange, 3100 _cumulativeVectorMagnitudeRange, 3101 _cumulativeVectorComponentRange); 3102 3103 _renderer->AddViewProp(hmap->getProp()); 3104 } while (doAll && ++itr != _dataSets.end()); 3105 3106 if (_cameraMode == IMAGE) 3107 setCameraMode(PERSPECTIVE); 3108 initCamera(); 3109 3110 _needsRedraw = true; 3111 } 3112 3113 /** 2890 3114 * \brief Get the HeightMap associated with a named DataSet 2891 3115 */ … … 2895 3119 2896 3120 if (itr == _heightMaps.end()) { 3121 #ifdef DEBUG 2897 3122 TRACE("HeightMap not found: %s", id.c_str()); 3123 #endif 2898 3124 return NULL; 2899 3125 } else … … 3131 3357 itr->second->getDataSet()->getName().c_str()); 3132 3358 3133 // Make a copy of the generic colormap lookup table, so 3134 // data range can be set in the copy table to match the 3135 // dataset being plotted 3136 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New(); 3137 lut->DeepCopy(cmap->getLookupTable()); 3138 3139 if (_useCumulativeRange) { 3140 lut->SetRange(_cumulativeDataRange); 3141 } else { 3142 if (itr->second->getDataSet() != NULL) { 3143 double range[2]; 3144 itr->second->getDataSet()->getDataRange(range); 3145 lut->SetRange(range); 3146 } 3147 } 3148 3149 itr->second->setLookupTable(lut); 3359 itr->second->setColorMap(cmap); 3150 3360 } while (doAll && ++itr != _heightMaps.end()); 3151 3361 … … 3174 3384 3175 3385 do { 3176 if (_useCumulativeRange) { 3177 itr->second->setContours(numContours, _cumulativeDataRange); 3178 } else { 3179 itr->second->setContours(numContours); 3180 } 3386 itr->second->setContours(numContours); 3181 3387 } while (doAll && ++itr != _heightMaps.end()); 3182 3388 … … 3490 3696 _lics[dsID] = lic; 3491 3697 3492 lic->setDataSet(ds); 3698 lic->setDataSet(ds, 3699 _useCumulativeRange, 3700 _cumulativeScalarRange, 3701 _cumulativeVectorMagnitudeRange, 3702 _cumulativeVectorComponentRange); 3493 3703 3494 3704 _renderer->AddViewProp(lic->getProp()); … … 3509 3719 3510 3720 if (itr == _lics.end()) { 3721 #ifdef DEBUG 3511 3722 TRACE("LIC not found: %s", id.c_str()); 3723 #endif 3512 3724 return NULL; 3513 3725 } else … … 3715 3927 itr->second->getDataSet()->getName().c_str()); 3716 3928 3717 // Make a copy of the generic colormap lookup table, so 3718 // data range can be set in the copy table to match the 3719 // dataset being plotted 3720 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New(); 3721 lut->DeepCopy(cmap->getLookupTable()); 3722 3723 if (_useCumulativeRange) { 3724 lut->SetRange(_cumulativeDataRange); 3725 } else { 3726 if (itr->second->getDataSet() != NULL) { 3727 double range[2]; 3728 itr->second->getDataSet()->getDataRange(range); 3729 lut->SetRange(range); 3730 } 3731 } 3732 3733 itr->second->setLookupTable(lut); 3929 itr->second->setColorMap(cmap); 3734 3930 } while (doAll && ++itr != _lics.end()); 3735 3931 … … 3952 4148 3953 4149 if (itr == _molecules.end()) { 4150 #ifdef DEBUG 3954 4151 TRACE("Molecule not found: %s", id.c_str()); 4152 #endif 3955 4153 return NULL; 3956 4154 } else … … 4129 4327 itr->second->getDataSet()->getName().c_str()); 4130 4328 4131 // Make a copy of the generic colormap lookup table, so 4132 // data range can be set in the copy table to match the 4133 // dataset being plotted 4134 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New(); 4135 lut->DeepCopy(cmap->getLookupTable()); 4136 4137 if (_useCumulativeRange) { 4138 lut->SetRange(_cumulativeDataRange); 4139 } else { 4140 if (itr->second->getDataSet() != NULL) { 4141 double range[2]; 4142 itr->second->getDataSet()->getDataRange(range); 4143 lut->SetRange(range); 4144 } 4145 } 4146 4147 itr->second->setLookupTable(lut); 4329 itr->second->setColorMap(cmap); 4148 4330 } while (doAll && ++itr != _molecules.end()); 4149 4331 … … 4474 4656 4475 4657 if (itr == _polyDatas.end()) { 4658 #ifdef DEBUG 4476 4659 TRACE("PolyData not found: %s", id.c_str()); 4660 #endif 4477 4661 return NULL; 4478 4662 } else … … 4868 5052 _pseudoColors[dsID] = pc; 4869 5053 4870 pc->setDataSet(ds); 4871 4872 // Use the default color map 4873 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New(); 4874 ColorMap *cmap = getColorMap("default"); 4875 lut->DeepCopy(cmap->getLookupTable()); 4876 if (_useCumulativeRange) { 4877 lut->SetRange(_cumulativeDataRange); 4878 } else { 4879 double range[2]; 4880 ds->getDataRange(range); 4881 lut->SetRange(range); 4882 } 4883 4884 pc->setLookupTable(lut); 5054 pc->setDataSet(ds, 5055 _useCumulativeRange, 5056 _cumulativeScalarRange, 5057 _cumulativeVectorMagnitudeRange, 5058 _cumulativeVectorComponentRange); 4885 5059 4886 5060 _renderer->AddViewProp(pc->getProp()); … … 4899 5073 4900 5074 if (itr == _pseudoColors.end()) { 5075 #ifdef DEBUG 4901 5076 TRACE("PseudoColor not found: %s", id.c_str()); 5077 #endif 4902 5078 return NULL; 4903 5079 } else … … 5076 5252 itr->second->getDataSet()->getName().c_str()); 5077 5253 5078 // Make a copy of the generic colormap lookup table, so 5079 // data range can be set in the copy table to match the 5080 // dataset being plotted 5081 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New(); 5082 lut->DeepCopy(cmap->getLookupTable()); 5083 5084 if (_useCumulativeRange) { 5085 lut->SetRange(_cumulativeDataRange); 5086 } else { 5087 if (itr->second->getDataSet() != NULL) { 5088 double range[2]; 5089 itr->second->getDataSet()->getDataRange(range); 5090 lut->SetRange(range); 5091 } 5092 } 5093 5094 itr->second->setLookupTable(lut); 5254 itr->second->setColorMap(cmap); 5095 5255 } while (doAll && ++itr != _pseudoColors.end()); 5096 5256 … … 5327 5487 _streamlines[dsID] = streamlines; 5328 5488 5329 streamlines->setDataSet(ds); 5330 5331 // Use the default color map 5332 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New(); 5333 ColorMap *cmap = getColorMap("default"); 5334 lut->DeepCopy(cmap->getLookupTable()); 5335 5336 if (_useCumulativeRange) { 5337 lut->SetRange(_cumulativeDataRange); 5338 } else { 5339 double range[2]; 5340 ds->getDataRange(range); 5341 lut->SetRange(range); 5342 } 5343 streamlines->setLookupTable(lut); 5489 streamlines->setDataSet(ds, 5490 _useCumulativeRange, 5491 _cumulativeScalarRange, 5492 _cumulativeVectorMagnitudeRange, 5493 _cumulativeVectorComponentRange); 5344 5494 5345 5495 _renderer->AddViewProp(streamlines->getProp()); … … 5358 5508 5359 5509 if (itr == _streamlines.end()) { 5510 #ifdef DEBUG 5360 5511 TRACE("Streamlines not found: %s", id.c_str()); 5512 #endif 5361 5513 return NULL; 5362 5514 } else … … 5901 6053 itr->second->getDataSet()->getName().c_str()); 5902 6054 5903 // Make a copy of the generic colormap lookup table, so 5904 // data range can be set in the copy table to match the 5905 // dataset being plotted 5906 vtkSmartPointer<vtkLookupTable> lut = vtkSmartPointer<vtkLookupTable>::New(); 5907 lut->DeepCopy(cmap->getLookupTable()); 5908 5909 if (_useCumulativeRange) { 5910 lut->SetRange(_cumulativeDataRange); 5911 } else { 5912 if (itr->second->getDataSet() != NULL) { 5913 double range[2]; 5914 itr->second->getDataSet()->getDataRange(range); 5915 lut->SetRange(range); 5916 } 5917 } 5918 5919 itr->second->setLookupTable(lut); 6055 itr->second->setColorMap(cmap); 5920 6056 } while (doAll && ++itr != _streamlines.end()); 5921 6057 … … 6120 6256 _volumes[dsID] = volume; 6121 6257 6122 volume->setDataSet(ds); 6123 6124 if (_useCumulativeRange) { 6125 ColorMap *cmap = volume->getColorMap(); 6126 volume->setColorMap(cmap, _cumulativeDataRange); 6127 } 6258 volume->setDataSet(ds, 6259 _useCumulativeRange, 6260 _cumulativeScalarRange, 6261 _cumulativeVectorMagnitudeRange, 6262 _cumulativeVectorComponentRange ); 6128 6263 6129 6264 _renderer->AddViewProp(volume->getProp()); … … 6144 6279 6145 6280 if (itr == _volumes.end()) { 6281 #ifdef DEBUG 6146 6282 TRACE("Volume not found: %s", id.c_str()); 6283 #endif 6147 6284 return NULL; 6148 6285 } else … … 6321 6458 itr->second->getDataSet()->getName().c_str()); 6322 6459 6323 if (_useCumulativeRange) { 6324 itr->second->setColorMap(cmap, _cumulativeDataRange); 6325 } else { 6326 itr->second->setColorMap(cmap); 6327 } 6460 itr->second->setColorMap(cmap); 6328 6461 } while (doAll && ++itr != _volumes.end()); 6329 6462 … … 7350 7483 /** 7351 7484 * \brief Update data ranges for color-mapping and contours 7352 * 7353 * \param[in] useCumulative Use cumulative range of all DataSets 7354 */ 7355 void Renderer::updateRanges(bool useCumulative) 7356 { 7485 */ 7486 void Renderer::updateRanges() 7487 { 7488 collectDataRanges(); 7489 7357 7490 for (Contour2DHashmap::iterator itr = _contour2Ds.begin(); 7358 7491 itr != _contour2Ds.end(); ++itr) { 7359 // Only need to update range if using evenly spaced contours 7360 if (itr->second->getContourList().empty()) { 7361 if (useCumulative) { 7362 itr->second->setContours(itr->second->getNumContours(), _cumulativeDataRange); 7363 } else { 7364 itr->second->setContours(itr->second->getNumContours()); 7365 } 7366 } 7492 itr->second->updateRanges(_useCumulativeRange, 7493 _cumulativeScalarRange, 7494 _cumulativeVectorMagnitudeRange, 7495 _cumulativeVectorComponentRange); 7367 7496 } 7368 7497 for (Contour3DHashmap::iterator itr = _contour3Ds.begin(); 7369 7498 itr != _contour3Ds.end(); ++itr) { 7370 // Only need to update range if using evenly spaced contours 7371 if (itr->second->getContourList().empty()) { 7372 if (useCumulative) { 7373 itr->second->setContours(itr->second->getNumContours(), _cumulativeDataRange); 7374 } else { 7375 itr->second->setContours(itr->second->getNumContours()); 7376 } 7377 } 7499 itr->second->updateRanges(_useCumulativeRange, 7500 _cumulativeScalarRange, 7501 _cumulativeVectorMagnitudeRange, 7502 _cumulativeVectorComponentRange); 7378 7503 } 7379 7504 for (GlyphsHashmap::iterator itr = _glyphs.begin(); 7380 7505 itr != _glyphs.end(); ++itr) { 7381 vtkLookupTable *lut = itr->second->getLookupTable(); 7382 if (lut) { 7383 if (useCumulative) { 7384 lut->SetRange(_cumulativeDataRange); 7385 } else { 7386 double range[2]; 7387 if (itr->second->getDataSet()) { 7388 itr->second->getDataSet()->getDataRange(range); 7389 lut->SetRange(range); 7390 } 7391 } 7392 } 7506 itr->second->updateRanges(_useCumulativeRange, 7507 _cumulativeScalarRange, 7508 _cumulativeVectorMagnitudeRange, 7509 _cumulativeVectorComponentRange); 7393 7510 } 7394 7511 for (HeightMapHashmap::iterator itr = _heightMaps.begin(); 7395 7512 itr != _heightMaps.end(); ++itr) { 7396 vtkLookupTable *lut = itr->second->getLookupTable(); 7397 if (lut) { 7398 if (useCumulative) { 7399 lut->SetRange(_cumulativeDataRange); 7400 } else { 7401 double range[2]; 7402 if (itr->second->getDataSet()) { 7403 itr->second->getDataSet()->getDataRange(range); 7404 lut->SetRange(range); 7405 } 7406 } 7407 } 7408 // Only need to update contour range if using evenly spaced contours 7409 if (itr->second->getContourList().empty()) { 7410 if (useCumulative) { 7411 itr->second->setContours(itr->second->getNumContours(), _cumulativeDataRange); 7412 } else { 7413 itr->second->setContours(itr->second->getNumContours()); 7414 } 7415 } 7513 itr->second->updateRanges(_useCumulativeRange, 7514 _cumulativeScalarRange, 7515 _cumulativeVectorMagnitudeRange, 7516 _cumulativeVectorComponentRange); 7416 7517 } 7417 7518 for (LICHashmap::iterator itr = _lics.begin(); 7418 7519 itr != _lics.end(); ++itr) { 7419 vtkLookupTable *lut = itr->second->getLookupTable(); 7420 if (lut) { 7421 if (useCumulative) { 7422 lut->SetRange(_cumulativeDataRange); 7423 } else { 7424 double range[2]; 7425 if (itr->second->getDataSet()) { 7426 itr->second->getDataSet()->getDataRange(range); 7427 lut->SetRange(range); 7428 } 7429 } 7430 } 7520 itr->second->updateRanges(_useCumulativeRange, 7521 _cumulativeScalarRange, 7522 _cumulativeVectorMagnitudeRange, 7523 _cumulativeVectorComponentRange); 7524 } 7525 for (MoleculeHashmap::iterator itr = _molecules.begin(); 7526 itr != _molecules.end(); ++itr) { 7527 itr->second->updateRanges(_useCumulativeRange, 7528 _cumulativeScalarRange, 7529 _cumulativeVectorMagnitudeRange, 7530 _cumulativeVectorComponentRange); 7431 7531 } 7432 7532 for (PseudoColorHashmap::iterator itr = _pseudoColors.begin(); 7433 7533 itr != _pseudoColors.end(); ++itr) { 7434 vtkLookupTable *lut = itr->second->getLookupTable(); 7435 if (lut) { 7436 if (useCumulative) { 7437 lut->SetRange(_cumulativeDataRange); 7438 } else { 7439 double range[2]; 7440 if (itr->second->getDataSet()) { 7441 itr->second->getDataSet()->getDataRange(range); 7442 lut->SetRange(range); 7443 } 7444 } 7445 } 7534 itr->second->updateRanges(_useCumulativeRange, 7535 _cumulativeScalarRange, 7536 _cumulativeVectorMagnitudeRange, 7537 _cumulativeVectorComponentRange); 7446 7538 } 7447 7539 for (StreamlinesHashmap::iterator itr = _streamlines.begin(); 7448 7540 itr != _streamlines.end(); ++itr) { 7449 vtkLookupTable *lut = itr->second->getLookupTable(); 7450 if (lut) { 7451 if (useCumulative) { 7452 lut->SetRange(_cumulativeDataRange); 7453 } else { 7454 double range[2]; 7455 if (itr->second->getDataSet()) { 7456 itr->second->getDataSet()->getDataRange(range); 7457 lut->SetRange(range); 7458 } 7459 } 7460 } 7541 itr->second->updateRanges(_useCumulativeRange, 7542 _cumulativeScalarRange, 7543 _cumulativeVectorMagnitudeRange, 7544 _cumulativeVectorComponentRange); 7461 7545 } 7462 7546 for (VolumeHashmap::iterator itr = _volumes.begin(); 7463 7547 itr != _volumes.end(); ++itr) { 7464 ColorMap *cmap = itr->second->getColorMap(); 7465 if (cmap) { 7466 if (useCumulative) { 7467 itr->second->setColorMap(cmap, _cumulativeDataRange); 7468 } else { 7469 itr->second->setColorMap(cmap); 7470 } 7471 } 7548 itr->second->updateRanges(_useCumulativeRange, 7549 _cumulativeScalarRange, 7550 _cumulativeVectorMagnitudeRange, 7551 _cumulativeVectorComponentRange); 7552 } 7553 } 7554 7555 void Renderer::collectDataRanges() 7556 { 7557 collectScalarRanges(_cumulativeScalarRange, 7558 _cumulativeRangeOnlyVisible); 7559 collectVectorMagnitudeRanges(_cumulativeVectorMagnitudeRange, 7560 _cumulativeRangeOnlyVisible); 7561 for (int i = 0; i < 3; i++) { 7562 collectVectorComponentRanges(_cumulativeVectorComponentRange[i], i, 7563 _cumulativeRangeOnlyVisible); 7472 7564 } 7473 7565 } … … 7479 7571 * \param[in] onlyVisible Only collect range of visible DataSets 7480 7572 */ 7481 void Renderer::collect DataRanges(double *range, bool onlyVisible)7573 void Renderer::collectScalarRanges(double *range, bool onlyVisible) 7482 7574 { 7483 7575 range[0] = DBL_MAX; … … 7488 7580 if (!onlyVisible || itr->second->getVisibility()) { 7489 7581 double r[2]; 7490 itr->second->get DataRange(r);7582 itr->second->getScalarRange(r); 7491 7583 range[0] = min2(range[0], r[0]); 7492 7584 range[1] = max2(range[1], r[1]); … … 7498 7590 range[1] = 1; 7499 7591 } 7592 7593 /** 7594 * \brief Collect cumulative data range of all DataSets 7595 * 7596 * \param[inout] range Data range of all DataSets 7597 * \param[in] onlyVisible Only collect range of visible DataSets 7598 */ 7599 void Renderer::collectVectorMagnitudeRanges(double *range, bool onlyVisible) 7600 { 7601 range[0] = DBL_MAX; 7602 range[1] = -DBL_MAX; 7603 7604 for (DataSetHashmap::iterator itr = _dataSets.begin(); 7605 itr != _dataSets.end(); ++itr) { 7606 if (!onlyVisible || itr->second->getVisibility()) { 7607 double r[2]; 7608 itr->second->getVectorRange(r); 7609 range[0] = min2(range[0], r[0]); 7610 range[1] = max2(range[1], r[1]); 7611 } 7612 } 7613 if (range[0] == DBL_MAX) 7614 range[0] = 0; 7615 if (range[1] == -DBL_MAX) 7616 range[1] = 1; 7617 } 7618 7619 /** 7620 * \brief Collect cumulative data range of all DataSets 7621 * 7622 * \param[inout] range Data range of all DataSets 7623 * \param[in] onlyVisible Only collect range of visible DataSets 7624 */ 7625 void Renderer::collectVectorComponentRanges(double *range, int component, bool onlyVisible) 7626 { 7627 range[0] = DBL_MAX; 7628 range[1] = -DBL_MAX; 7629 7630 for (DataSetHashmap::iterator itr = _dataSets.begin(); 7631 itr != _dataSets.end(); ++itr) { 7632 if (!onlyVisible || itr->second->getVisibility()) { 7633 double r[2]; 7634 itr->second->getVectorRange(r, component); 7635 range[0] = min2(range[0], r[0]); 7636 range[1] = max2(range[1], r[1]); 7637 } 7638 } 7639 if (range[0] == DBL_MAX) 7640 range[0] = 0; 7641 if (range[1] == -DBL_MAX) 7642 range[1] = 1; 7643 } 7500 7644 7501 7645 /** … … 7538 7682 case ORTHO: 7539 7683 _renderer->GetActiveCamera()->ParallelProjectionOn(); 7540 resetAxes( );7684 resetAxes(bounds); 7541 7685 _renderer->ResetCamera(bounds); 7542 7686 //computeScreenWorldCoords(); … … 7544 7688 case PERSPECTIVE: 7545 7689 _renderer->GetActiveCamera()->ParallelProjectionOff(); 7546 resetAxes( );7690 resetAxes(bounds); 7547 7691 _renderer->ResetCamera(bounds); 7548 7692 //computeScreenWorldCoords();
Note: See TracChangeset
for help on using the changeset viewer.