- Timestamp:
- Nov 6, 2016, 12:00:27 AM (8 years ago)
- Location:
- geovis/branches/rex
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
geovis/branches/rex/Makefile.in
r6248 r6570 3 3 TRACE = #yes 4 4 TRACE_FRAME = #yes 5 NEW_ANNOTATION_API = #yes6 5 USE_OFFSCREEN_RENDERING = #yes 7 6 USE_THREADS = yes … … 11 10 SLEEP_AFTER_QUEUE_FRAME = yes 12 11 QUEUE_ONLY_ONE_FRAME = yes 13 USE_REX = #yes12 USE_REX = yes 14 13 15 14 bindir = @bindir@ … … 99 98 ifdef TRACE_FRAME 100 99 DEFINES += -DWANT_FRAME 101 endif102 ifdef NEW_ANNOTATION_API103 DEFINES += -DNEW_ANNOTATION_API104 100 endif 105 101 ifdef USE_OFFSCREEN_RENDERING -
geovis/branches/rex/MouseCoordsTool.h
r6487 r6570 42 42 TRACE("%g %g %g", mapCoords.x(), mapCoords.y(), mapCoords.z()); 43 43 if (_label.valid()) { 44 if (mapNode->getMap()->getNumElevationLayers() > 0) { 45 _label->setText(osgEarth::Stringify() 46 << _prefix 47 << _formatter->format(mapCoords) 48 << "\nElev: " << mapCoords.z() << " m"); 49 } else { 50 _label->setText(osgEarth::Stringify() 51 << _prefix 52 << _formatter->format(mapCoords)); 53 } 44 _label->setText(osgEarth::Stringify() 45 << _prefix 46 << _formatter->format(mapCoords) 47 << "\nElev: " << mapCoords.z() << " m"); 54 48 } 55 49 _pt = mapCoords; -
geovis/branches/rex/Picker.cpp
r6281 r6570 164 164 itr != toUnHover.end(); ++itr) { 165 165 hovered.erase(*itr); 166 #ifndef NEW_ANNOTATION_API167 (*itr)->clearDecoration();168 #endif169 166 _renderer->eventuallyRender(); 170 167 } … … 285 282 osgEarth::Registry::objectIndex()->get<osgEarth::Annotation::AnnotationNode>(id); 286 283 std::set<osgEarth::Annotation::AnnotationNode*>& hovered = _renderer->getHovered(); 287 #ifndef NEW_ANNOTATION_API288 anno->clearDecoration();289 #endif290 284 _renderer->getPlaceNodes()->removeChild(anno); 291 285 if (hovered.find(anno) != hovered.end()) { -
geovis/branches/rex/Placard.cpp
r6507 r6570 14 14 #include <osgEarth/Registry> 15 15 #include <osgEarth/ShaderGenerator> 16 #ifdef NEW_ANNOTATION_API17 16 #include <osgEarth/ScreenSpaceLayout> 18 17 #include <osgEarthSymbology/BBoxSymbol> 19 #else20 #include <osgEarth/Decluttering>21 #endif22 18 #include <osgEarthSymbology/PolygonSymbol> 23 19 #include <osgEarthSymbology/TextSymbol> … … 45 41 _padding = (float)(charSize / 2.0); 46 42 47 #ifdef NEW_ANNOTATION_API48 43 osgEarth::Symbology::BBoxSymbol *bbs = _textStyle.getOrCreateSymbol<osgEarth::Symbology::BBoxSymbol>(); 49 44 bbs->fill() = osgEarth::Symbology::Color(0.75, 0.75, 0.75, 0.75); 50 45 bbs->margin() = _padding; 51 #else52 // Set backdrop quad color as PolygonSymbol fill53 osgEarth::Symbology::PolygonSymbol *ps = _textStyle.getOrCreateSymbol<osgEarth::Symbology::PolygonSymbol>();54 ps->fill() = osgEarth::Symbology::Color(0.75, 0.75, 0.75, 0.75);55 #endif56 46 } 57 47 … … 108 98 const Placard& placardConf, 109 99 const osgEarth::Features::AttributeTable &attrs) : 110 #ifdef NEW_ANNOTATION_API111 100 osgEarth::Annotation::GeoPositionNode(mapNode, position), 112 #else113 osgEarth::Annotation::OrthoNode(mapNode, position),114 #endif115 101 _placardConf(placardConf), 116 102 _attrs(attrs) … … 160 146 PlacardNode::init( const osgEarth::Symbology::Style& style ) 161 147 { 162 #ifdef NEW_ANNOTATION_API163 148 osgEarth::ScreenSpaceLayout::activate(this->getOrCreateStateSet()); 164 #endif165 149 _backdropGeode = new osg::Geode(); 166 150 _backdropGeode->setComputeBoundingSphereCallback(new osgEarth::Annotation::ControlPointCallback()); 167 #ifdef NEW_ANNOTATION_API168 151 getPositionAttitudeTransform()->addChild( _backdropGeode.get() ); 169 #else 170 getAttachPoint()->addChild(_backdropGeode.get()); 171 #endif 152 172 153 osg::StateSet* stateSet = _backdropGeode->getOrCreateStateSet(); 173 154 stateSet->setAttributeAndModes( new osg::Depth(osg::Depth::ALWAYS, 0, 1, false), 1 ); … … 179 160 _geode->setComputeBoundingSphereCallback(new osgEarth::Annotation::ControlPointCallback()); 180 161 181 #ifdef NEW_ANNOTATION_API182 162 getPositionAttitudeTransform()->addChild( _geode.get() ); 183 #else184 getAttachPoint()->addChild( _geode.get() );185 #endif186 163 stateSet = _geode->getOrCreateStateSet(); 187 164 stateSet->setAttributeAndModes( new osg::Depth(osg::Depth::ALWAYS, 0, 1, false), 1 ); … … 235 212 return; 236 213 } 237 #ifndef NEW_ANNOTATION_API238 this->clearDecoration();239 #endif240 214 _backdropGeode->removeDrawables( 0, _backdropGeode->getNumDrawables() ); 241 215 … … 272 246 "osgEarth.PlacardNode", 273 247 osgEarth::Registry::stateSetCache() ); 274 #ifdef NEW_ANNOTATION_API 248 275 249 // Set to max priority to draw on top in decluttering sort 276 250 setPriority(FLT_MAX); 277 251 // setPriority calls updateLayoutData 278 252 //updateLayoutData(); 279 #endif 280 } 281 282 #ifdef NEW_ANNOTATION_API 253 } 254 283 255 void 284 256 PlacardNode::setPriority(float value) … … 317 289 } 318 290 } 319 #else320 void321 PlacardNode::setAnnotationData( osgEarth::Annotation::AnnotationData* data )322 {323 osgEarth::Annotation::OrthoNode::setAnnotationData( data );324 325 if (!_geode.valid())326 return;327 328 // override this method so we can attach the anno data to the drawables.329 for(unsigned i=0; i<_geode->getNumDrawables(); ++i)330 {331 _geode->getDrawable(i)->setUserData( data );332 }333 }334 #endif335 291 336 292 void 337 293 PlacardNode::setDynamic( bool dynamic ) 338 294 { 339 #ifdef NEW_ANNOTATION_API340 295 osgEarth::Annotation::GeoPositionNode::setDynamic( dynamic ); 341 #else 342 osgEarth::Annotation::OrthoNode::setDynamic( dynamic ); 343 #endif 296 344 297 osgText::Text* d = dynamic_cast<osgText::Text*>(_geode->getDrawable(0)); 345 298 if ( d ) … … 356 309 PlacardNode::getConfig() const 357 310 { 358 #ifdef NEW_ANNOTATION_API359 311 osgEarth::Config conf = osgEarth::Annotation::GeoPositionNode::getConfig(); 360 #else 361 osgEarth::Config conf = osgEarth::Annotation::OrthoNode::getConfig(); 362 #endif 312 363 313 conf.key() = "placard"; 364 314 -
geovis/branches/rex/Placard.h
r6274 r6570 13 13 #include <algorithm> 14 14 15 #ifdef NEW_ANNOTATION_API16 15 #include <osgEarth/ScreenSpaceLayout> 17 16 #include <osgEarthAnnotation/GeoPositionNode> 18 #else19 #include <osgEarthAnnotation/Decoration>20 #include <osgEarthAnnotation/OrthoNode>21 #endif22 17 #include <osgEarthAnnotation/LabelNode> 23 18 #include <osgEarthFeatures/Feature> … … 93 88 public: 94 89 META_Node(osgEarthAnnotation, PlacardLabelNode); 95 #ifndef NEW_ANNOTATION_API 96 virtual bool accept(osgEarth::Annotation::Decoration* ds, bool enable) 97 { return ds->apply(*this, enable); } 98 #endif 90 99 91 PlacardLabelNode() : 100 92 osgEarth::Annotation::LabelNode() … … 121 113 122 114 class PlacardNode : 123 #ifdef NEW_ANNOTATION_API124 115 public osgEarth::Annotation::GeoPositionNode 125 #else126 public osgEarth::Annotation::OrthoNode127 #endif128 116 { 129 117 public: 130 118 META_Node(osgEarthAnnotation, PlacardNode); 131 #ifndef NEW_ANNOTATION_API 132 virtual bool accept(osgEarth::Annotation::Decoration* ds, bool enable) 133 { return ds->apply(*this, enable); } 134 #endif 119 135 120 PlacardNode() : 136 #ifdef NEW_ANNOTATION_API137 121 osgEarth::Annotation::GeoPositionNode() 138 #else139 osgEarth::Annotation::OrthoNode()140 #endif141 122 {} 142 123 PlacardNode(const PlacardNode& other, const osg::CopyOp& op = osg::CopyOp::DEEP_COPY_ALL) : 143 #ifdef NEW_ANNOTATION_API144 124 osgEarth::Annotation::GeoPositionNode(other, op), 145 #else146 osgEarth::Annotation::OrthoNode(other, op),147 #endif148 125 _placardConf(other._placardConf) 149 126 { … … 177 154 178 155 public: // Ortho|GeoPositionNode override 179 #ifdef NEW_ANNOTATION_API180 156 virtual void setPriority(float value); 181 #else 182 virtual void setAnnotationData( osgEarth::Annotation::AnnotationData* data ); 183 #endif 157 184 158 virtual void setDynamic( bool value ); 185 159 … … 188 162 protected: 189 163 void init(const osgEarth::Symbology::Style& style); 190 #ifdef NEW_ANNOTATION_API 164 191 165 void updateLayoutData(); 192 #endif193 166 194 167 std::string _text; … … 196 169 osg::ref_ptr<osg::Geode> _geode; 197 170 osg::ref_ptr<osg::Geode> _backdropGeode; 198 #ifdef NEW_ANNOTATION_API199 171 osg::ref_ptr<osgEarth::ScreenSpaceLayoutData> _dataLayout; 200 #endif201 172 202 173 Placard _placardConf; -
geovis/branches/rex/Renderer.cpp
r6549 r6570 67 67 #include <osgEarthSymbology/IconSymbol> 68 68 #include <osgEarthSymbology/LineSymbol> 69 70 69 #include <osgEarthAnnotation/AnnotationNode> 71 70 #include <osgEarthAnnotation/FeatureNode> 72 71 #include <osgEarthAnnotation/PlaceNode> 73 #ifdef NEW_ANNOTATION_API74 72 #include <osgEarth/ScreenSpaceLayout> 75 #else76 #include <osgEarth/Decluttering>77 #include <osgEarthAnnotation/HighlightDecoration>78 #include <osgEarthAnnotation/ScaleDecoration>79 #endif80 73 #include <osgEarthUtil/EarthManipulator> 81 74 #include <osgEarthUtil/Sky> … … 1321 1314 } 1322 1315 1316 void Renderer::setLayerOpacity(const char *name, double opacity) 1317 { 1318 if (!_map.valid()) { 1319 ERROR("No map"); 1320 return; 1321 } 1322 osgEarth::Layer *layer = _map->getLayerByName(name); 1323 osgEarth::ImageLayer *ilayer = dynamic_cast<osgEarth::ImageLayer *>(layer); 1324 if (ilayer != NULL) { 1325 ilayer->setOpacity(opacity); 1326 _needsRedraw = true; 1327 return; 1328 } 1329 osgEarth::ModelLayer *mlayer = dynamic_cast<osgEarth::ModelLayer *>(layer); 1330 if (mlayer != NULL) { 1331 mlayer->setOpacity(opacity); 1332 _needsRedraw = true; 1333 return; 1334 } 1335 TRACE("Image layer not found: %s", name); 1336 } 1337 1338 void Renderer::setLayerVisibility(const char *name, bool state) 1339 { 1340 if (!_map.valid()) { 1341 ERROR("No map"); 1342 return; 1343 } 1344 osgEarth::Layer *layer = _map->getLayerByName(name); 1345 osgEarth::TerrainLayer *tlayer = dynamic_cast<osgEarth::TerrainLayer *>(layer); 1346 if (tlayer != NULL) { 1347 tlayer->setVisible(state); 1348 _needsRedraw = true; 1349 return; 1350 } 1351 osgEarth::ModelLayer *mlayer = dynamic_cast<osgEarth::ModelLayer *>(layer); 1352 if (mlayer != NULL) { 1353 mlayer->setVisible(state); 1354 _needsRedraw = true; 1355 return; 1356 } 1357 TRACE("Layer not found: %s", name); 1358 } 1359 1360 void Renderer::moveLayer(const char *name, unsigned int pos) 1361 { 1362 if (!_map.valid()) { 1363 ERROR("No map"); 1364 return; 1365 } 1366 osgEarth::Layer *layer = _map->getLayerByName(name); 1367 if (layer != NULL) { 1368 _map->moveLayer(layer, pos); 1369 _needsRedraw = true; 1370 } else { 1371 TRACE("Layer not found: %s", name); 1372 } 1373 } 1374 1375 void Renderer::removeLayer(const char *name) 1376 { 1377 if (!_map.valid()) { 1378 ERROR("No map"); 1379 return; 1380 } 1381 osgEarth::Layer *layer = _map->getLayerByName(name); 1382 if (layer != NULL) { 1383 _map->removeLayer(layer); 1384 _needsRedraw = true; 1385 } else { 1386 TRACE("Layer not found: %s", name); 1387 } 1388 } 1389 1323 1390 bool Renderer::addImageLayer(const char *name, 1324 1391 osgEarth::TileSourceOptions& opts, … … 1356 1423 layerOpts.maxLevel() = maxLOD; 1357 1424 osg::ref_ptr<osgEarth::ImageLayer> layer = new osgEarth::ImageLayer(layerOpts); 1358 if (pos < (unsigned int) _map->getNumImageLayers()) {1425 if (pos < (unsigned int)getNumImageLayers()) { 1359 1426 _map->insertImageLayer(layer.get(), pos); 1360 1427 } else { … … 1377 1444 return; 1378 1445 } 1379 osgEarth::ImageLayer *layer = _map->getImageLayerByName(name);1446 osgEarth::ImageLayer *layer = getImageLayerByName(name); 1380 1447 if (layer == NULL) { 1381 1448 TRACE("Image layer not found: %s", name); … … 1395 1462 return; 1396 1463 } 1397 osgEarth::ImageLayer *layer = _map->getImageLayerByName(name);1464 osgEarth::ImageLayer *layer = getImageLayerByName(name); 1398 1465 if (layer == NULL) { 1399 1466 TRACE("Image layer not found: %s", name); … … 1416 1483 return; 1417 1484 } 1418 osgEarth::ImageLayer *layer = _map->getImageLayerByName(name);1485 osgEarth::ImageLayer *layer = getImageLayerByName(name); 1419 1486 if (layer != NULL) { 1420 _map->remove ImageLayer(layer);1487 _map->removeLayer(layer); 1421 1488 _needsRedraw = true; 1422 1489 } else { … … 1431 1498 return; 1432 1499 } 1433 osgEarth::ImageLayer *layer = _map->getImageLayerByName(name);1500 osgEarth::ImageLayer *layer = getImageLayerByName(name); 1434 1501 if (layer != NULL) { 1435 1502 _map->moveImageLayer(layer, pos); … … 1446 1513 return; 1447 1514 } 1448 osgEarth::ImageLayer *layer = _map->getImageLayerByName(name);1515 osgEarth::ImageLayer *layer = getImageLayerByName(name); 1449 1516 if (layer != NULL) { 1450 1517 layer->setOpacity(opacity); … … 1461 1528 return; 1462 1529 } 1463 osgEarth::ImageLayer *layer = _map->getImageLayerByName(name);1530 osgEarth::ImageLayer *layer = getImageLayerByName(name); 1464 1531 if (layer != NULL) { 1465 1532 layer->setMinVisibleRange(min); … … 1477 1544 return; 1478 1545 } 1479 osgEarth::ImageLayer *layer = _map->get ImageLayerByName(name);1546 osgEarth::ImageLayer *layer = _map->getLayerByName<osgEarth::ImageLayer>(name); 1480 1547 if (layer != NULL) { 1481 1548 layer->setVisible(state); … … 1492 1559 return false; 1493 1560 } 1494 osgEarth::ImageLayer *layer = _map->getImageLayerByName(name);1561 osgEarth::ImageLayer *layer = getImageLayerByName(name); 1495 1562 if (layer != NULL) { 1496 1563 osgEarth::SequenceControl *seq = layer->getSequenceControl(); … … 1511 1578 return false; 1512 1579 } 1513 osgEarth::ImageLayer *layer = _map->getImageLayerByName(name);1580 osgEarth::ImageLayer *layer = getImageLayerByName(name); 1514 1581 if (layer != NULL) { 1515 1582 osgEarth::SequenceControl *seq = layer->getSequenceControl(); … … 1532 1599 return false; 1533 1600 } 1534 osgEarth::ImageLayer *layer = _map->getImageLayerByName(name);1601 osgEarth::ImageLayer *layer = getImageLayerByName(name); 1535 1602 if (layer != NULL) { 1536 1603 osgEarth::SequenceControl *seq = layer->getSequenceControl(); … … 1553 1620 return false; 1554 1621 } 1555 osgEarth::ImageLayer *layer = _map->getImageLayerByName(name);1622 osgEarth::ImageLayer *layer = getImageLayerByName(name); 1556 1623 if (layer != NULL) { 1557 1624 osgEarth::SequenceControl *seq = layer->getSequenceControl(); … … 1601 1668 _map->addElevationLayer(layer); 1602 1669 // Map API lacks an insertElevationLayer method, so need to move it 1603 if (pos < (unsigned int) _map->getNumElevationLayers()) {1670 if (pos < (unsigned int)getNumElevationLayers()) { 1604 1671 _map->moveElevationLayer(layer, pos); 1605 1672 } … … 1613 1680 return; 1614 1681 } 1615 osgEarth::ElevationLayer *layer = _map->getElevationLayerByName(name);1682 osgEarth::ElevationLayer *layer = getElevationLayerByName(name); 1616 1683 if (layer != NULL) { 1617 _map->remove ElevationLayer(layer);1684 _map->removeLayer(layer); 1618 1685 _needsRedraw = true; 1619 1686 } else { … … 1628 1695 return; 1629 1696 } 1630 osgEarth::ElevationLayer *layer = _map->getElevationLayerByName(name);1697 osgEarth::ElevationLayer *layer = getElevationLayerByName(name); 1631 1698 if (layer != NULL) { 1632 1699 _map->moveElevationLayer(layer, pos); … … 1643 1710 return; 1644 1711 } 1645 osgEarth::ElevationLayer *layer = _map->getElevationLayerByName(name);1712 osgEarth::ElevationLayer *layer = getElevationLayerByName(name); 1646 1713 if (layer != NULL) { 1647 1714 layer->setVisible(state); … … 1676 1743 osgEarth::MaskLayer *layer = getTerrainMaskLayerByName(name); 1677 1744 if (layer != NULL) { 1678 _map->remove TerrainMaskLayer(layer);1745 _map->removeLayer(layer); 1679 1746 _needsRedraw = true; 1680 1747 } else { … … 1691 1758 _placeNodes = new osg::Group(); 1692 1759 _placeNodes->setName("Place Nodes"); 1693 #ifdef NEW_ANNOTATION_API1694 1760 osgEarth::ScreenSpaceLayout::activate(_placeNodes->getOrCreateStateSet()); 1695 #else1696 osgEarth::Decluttering::setEnabled(_placeNodes->getOrCreateStateSet(), true);1697 #endif1698 1761 _annotations->addChild(_placeNodes.get()); 1699 1762 if (_picker.valid()) { … … 1735 1798 void Renderer::enablePlacard(const char *layerName, bool state) 1736 1799 { 1737 osgEarth::ModelLayer *layer = _map->getModelLayerByName(layerName);1800 osgEarth::ModelLayer *layer = getModelLayerByName(layerName); 1738 1801 if (layer == NULL) { 1739 1802 ERROR("Unknown layer '%s'", layerName); … … 1745 1808 void Renderer::setPlacardConfig(const Placard& placardConf, const char *layerName) 1746 1809 { 1747 osgEarth::ModelLayer *layer = _map->getModelLayerByName(layerName);1810 osgEarth::ModelLayer *layer = getModelLayerByName(layerName); 1748 1811 if (layer == NULL) { 1749 1812 ERROR("Unknown layer '%s'", layerName); … … 1785 1848 return; 1786 1849 } 1787 osgEarth::ModelLayer *layer = _map->getModelLayerByName(layerName);1850 osgEarth::ModelLayer *layer = getModelLayerByName(layerName); 1788 1851 if (layer == NULL) { 1789 1852 ERROR("Unknown layer '%s'", layerName); … … 1815 1878 for (size_t i = 0; i < visitor.nodes.size(); i++) { 1816 1879 osgEarth::Features::FeatureIndex *index = visitor.nodes[i]->getIndex(); 1817 #if OSGEARTH_MIN_VERSION_REQUIRED(3, 0, 0)1818 1880 osgEarth::ObjectID id = index->getObjectID(fid); 1819 1881 if (doPlacard) { … … 1833 1895 setHighlightByObjectID(id); 1834 1896 TRACE("FID %lu = OID %d", fid, id); 1835 #endif1836 1897 } 1837 1898 _needsRedraw = true; … … 1876 1937 PlacardNode *label = 1877 1938 new PlacardNode(_mapNode.get(), location, placard, attrs); 1878 #ifndef NEW_ANNOTATION_API1879 label->getOrCreateStateSet()->setRenderBinDetails(INT_MAX, "RenderBin");1880 #endif1881 1939 getAnnotations()->addChild(label); 1882 1940 } … … 1904 1962 osg::Node *node = nodes->getChild(i); 1905 1963 // This can be Placard, PlacardLabel, Label, Place or Track Node 1906 #ifdef NEW_ANNOTATION_API1907 1964 if (dynamic_cast<osgEarth::Annotation::GeoPositionNode *>(node) != NULL) { 1908 #else1909 if (dynamic_cast<osgEarth::Annotation::OrthoNode *>(node) != NULL) {1910 #endif1911 1965 toRemove.push_back(node); 1912 1966 } … … 1978 2032 (*geom)[3] = osg::Vec3d(longMin, latMax, 0); 1979 2033 node->init(); 1980 #ifndef NEW_ANNOTATION_API1981 for (std::set<osgEarth::Annotation::AnnotationNode *>::iterator itr = _selected.begin();1982 itr != _selected.end(); ++itr) {1983 (*itr)->clearDecoration();1984 }1985 #endif1986 2034 _selected.clear(); 1987 2035 SelectPlaceNodesVisitor spnv(this, latMin, latMax, longMin, longMax); … … 2033 2081 pt.x(), pt.y(), placeNode->getName().c_str(), 2034 2082 placeNode->getText().c_str()); 2035 #ifndef NEW_ANNOTATION_API2036 placeNode->setDecoration("select");2037 #endif2038 2083 } 2039 2084 } … … 2048 2093 _selectionBox = NULL; 2049 2094 } 2050 #ifndef NEW_ANNOTATION_API2051 for (std::set<osgEarth::Annotation::AnnotationNode *>::iterator itr = _selected.begin();2052 itr != _selected.end(); ++itr) {2053 (*itr)->clearDecoration();2054 }2055 #endif2056 2095 _selected.clear(); 2057 2096 _needsRedraw = true; … … 2357 2396 } 2358 2397 osgEarth::ModelLayer *layer = new osgEarth::ModelLayer(layerOpts); 2359 if (pos < (unsigned int) _map->getNumModelLayers()) {2398 if (pos < (unsigned int)getNumModelLayers()) { 2360 2399 _map->insertModelLayer(layer, pos); 2361 2400 } else { … … 2371 2410 return; 2372 2411 } 2373 osgEarth::ModelLayer *layer = _map->getModelLayerByName(name);2412 osgEarth::ModelLayer *layer = getModelLayerByName(name); 2374 2413 if (layer != NULL) { 2375 _map->remove ModelLayer(layer);2414 _map->removeLayer(layer); 2376 2415 _needsRedraw = true; 2377 2416 } else { … … 2386 2425 return; 2387 2426 } 2388 osgEarth::ModelLayer *layer = _map->getModelLayerByName(name);2427 osgEarth::ModelLayer *layer = getModelLayerByName(name); 2389 2428 if (layer != NULL) { 2390 2429 _map->moveModelLayer(layer, pos); … … 2401 2440 return; 2402 2441 } 2403 osgEarth::ModelLayer *layer = _map->getModelLayerByName(name);2442 osgEarth::ModelLayer *layer = getModelLayerByName(name); 2404 2443 if (layer != NULL) { 2405 2444 layer->setOpacity(opacity); … … 2416 2455 return; 2417 2456 } 2418 osgEarth::ModelLayer *layer = _map->getModelLayerByName(name);2457 osgEarth::ModelLayer *layer = getModelLayerByName(name); 2419 2458 if (layer != NULL) { 2420 2459 layer->minVisibleRange(min); … … 2432 2471 return; 2433 2472 } 2434 osgEarth::ModelLayer *layer = _map->getModelLayerByName(name);2473 osgEarth::ModelLayer *layer = getModelLayerByName(name); 2435 2474 if (layer != NULL) { 2436 2475 layer->setVisible(state); … … 2633 2672 return false; 2634 2673 } 2635 osgEarth::ImageLayer *layer = _map->getImageLayerByName(name);2674 osgEarth::ImageLayer *layer = getImageLayerByName(name); 2636 2675 if (layer != NULL) { 2637 2676 osgEarth::TileSource *ts = layer->getTileSource(); … … 2658 2697 return false; 2659 2698 } 2660 osgEarth::ElevationLayer *layer = _map->getElevationLayerByName(name);2699 osgEarth::ElevationLayer *layer = getElevationLayerByName(name); 2661 2700 if (layer != NULL) { 2662 2701 osgEarth::TileSource *ts = layer->getTileSource(); … … 2715 2754 return false; 2716 2755 } 2717 osgEarth::ModelLayer *layer = _map->getModelLayerByName(name);2756 osgEarth::ModelLayer *layer = getModelLayerByName(name); 2718 2757 if (layer != NULL) { 2719 2758 osgEarth::ModelSource *ms = layer->getModelSource(); -
geovis/branches/rex/Renderer.h
r6549 r6570 244 244 void setSkyAmbient(float ambientLevel); 245 245 246 // Generic layer API 247 248 void setLayerVisibility(const char *name, bool state); 249 250 void setLayerOpacity(const char *name, double opacity); 251 252 void removeLayer(const char *name); 253 254 void moveLayer(const char *name, unsigned int pos); 255 246 256 // Image raster layers 247 248 257 int getNumImageLayers() const 249 258 { 250 return (_map.valid() ? _map->getNumImageLayers() : 0); 259 if (!_map.valid()) return 0; 260 261 osgEarth::LayerVector layers; 262 _map->getLayers(layers); 263 int count = 0; 264 osgEarth::LayerVector::const_iterator itr; 265 for (itr = layers.begin(); itr != layers.end(); ++itr) { 266 if (dynamic_cast<const osgEarth::ImageLayer *>((*itr).get())) { 267 count++; 268 } 269 } 270 return count; 251 271 } 252 272 … … 254 274 { 255 275 if (_map.valid()) { 256 osgEarth:: ImageLayerVector layerVector;257 _map->get ImageLayers(layerVector);258 osgEarth:: ImageLayerVector::const_iterator itr;276 osgEarth::LayerVector layerVector; 277 _map->getLayers(layerVector); 278 osgEarth::LayerVector::const_iterator itr; 259 279 for (itr = layerVector.begin(); itr != layerVector.end(); ++itr) { 260 //osgEarth::UID uid = (*itr)->getUID(); 261 names.push_back((*itr)->getName()); 280 if (dynamic_cast<const osgEarth::ImageLayer *>((*itr).get())) { 281 //osgEarth::UID uid = (*itr)->getUID(); 282 names.push_back((*itr)->getName()); 283 } 262 284 } 263 285 } 286 } 287 288 osgEarth::ImageLayer *getImageLayerByName(const std::string& name) 289 { 290 if (!_map.valid()) 291 return NULL; 292 293 return _map->getLayerByName<osgEarth::ImageLayer>(name); 264 294 } 265 295 … … 306 336 int getNumElevationLayers() const 307 337 { 308 return (_map.valid() ? _map->getNumElevationLayers() : 0); 338 if (!_map.valid()) return 0; 339 340 osgEarth::LayerVector layers; 341 _map->getLayers(layers); 342 int count = 0; 343 osgEarth::LayerVector::const_iterator itr; 344 for (itr = layers.begin(); itr != layers.end(); ++itr) { 345 if (dynamic_cast<const osgEarth::ElevationLayer *>((*itr).get())) { 346 count++; 347 } 348 } 349 return count; 309 350 } 310 351 … … 312 353 { 313 354 if (_map.valid()) { 314 osgEarth:: ElevationLayerVector layerVector;315 _map->get ElevationLayers(layerVector);316 osgEarth:: ElevationLayerVector::const_iterator itr;355 osgEarth::LayerVector layerVector; 356 _map->getLayers(layerVector); 357 osgEarth::LayerVector::const_iterator itr; 317 358 for (itr = layerVector.begin(); itr != layerVector.end(); ++itr) { 318 //osgEarth::UID uid = (*itr)->getUID(); 319 names.push_back((*itr)->getName()); 359 if (dynamic_cast<osgEarth::ElevationLayer *>((*itr).get())) { 360 //osgEarth::UID uid = (*itr)->getUID(); 361 names.push_back((*itr)->getName()); 362 } 320 363 } 321 364 } 365 } 366 367 osgEarth::ElevationLayer *getElevationLayerByName(const std::string& name) 368 { 369 if (!_map.valid()) 370 return NULL; 371 372 return _map->getLayerByName<osgEarth::ElevationLayer>(name); 322 373 } 323 374 … … 347 398 if (!_map.valid()) return 0; 348 399 349 osgEarth::MaskLayerVector layers; 350 _map->getTerrainMaskLayers(layers); 351 return (int)layers.size(); 400 osgEarth::LayerVector layers; 401 _map->getLayers(layers); 402 int count = 0; 403 osgEarth::LayerVector::const_iterator itr; 404 for (itr = layers.begin(); itr != layers.end(); ++itr) { 405 if (dynamic_cast<const osgEarth::MaskLayer *>((*itr).get())) { 406 count++; 407 } 408 } 409 return count; 352 410 } 353 411 … … 355 413 { 356 414 if (_map.valid()) { 357 osgEarth:: MaskLayerVector layerVector;358 _map->get TerrainMaskLayers(layerVector);359 osgEarth:: MaskLayerVector::const_iterator itr;415 osgEarth::LayerVector layerVector; 416 _map->getLayers(layerVector); 417 osgEarth::LayerVector::const_iterator itr; 360 418 for (itr = layerVector.begin(); itr != layerVector.end(); ++itr) { 361 //osgEarth::UID uid = (*itr)->getUID(); 362 names.push_back((*itr)->getName()); 419 if (dynamic_cast<const osgEarth::MaskLayer *>((*itr).get())) { 420 //osgEarth::UID uid = (*itr)->getUID(); 421 names.push_back((*itr)->getName()); 422 } 363 423 } 364 424 } … … 370 430 return NULL; 371 431 372 osgEarth::MaskLayerVector layerVector; 373 _map->getTerrainMaskLayers(layerVector); 374 osgEarth::MaskLayerVector::iterator itr; 375 for (itr = layerVector.begin(); itr != layerVector.end(); ++itr) { 376 if ((*itr)->getName() == name) { 377 return (*itr).get(); 378 } 379 } 380 return NULL; 432 return _map->getLayerByName<osgEarth::MaskLayer>(name); 381 433 } 382 434 … … 390 442 391 443 // Model layers 392 393 444 int getNumModelLayers() const 394 445 { 395 return (_map.valid() ? _map->getNumModelLayers() : 0); 446 if (!_map.valid()) return 0; 447 448 osgEarth::LayerVector layers; 449 _map->getLayers(layers); 450 int count = 0; 451 osgEarth::LayerVector::const_iterator itr; 452 for (itr = layers.begin(); itr != layers.end(); ++itr) { 453 if (dynamic_cast<const osgEarth::ModelLayer *>((*itr).get())) { 454 count++; 455 } 456 } 457 return count; 396 458 } 397 459 … … 399 461 { 400 462 if (_map.valid()) { 401 osgEarth:: ModelLayerVector layerVector;402 _map->get ModelLayers(layerVector);403 osgEarth:: ModelLayerVector::const_iterator itr;463 osgEarth::LayerVector layerVector; 464 _map->getLayers(layerVector); 465 osgEarth::LayerVector::const_iterator itr; 404 466 for (itr = layerVector.begin(); itr != layerVector.end(); ++itr) { 405 //osgEarth::UID uid = (*itr)->getUID(); 406 names.push_back((*itr)->getName()); 467 if (dynamic_cast<const osgEarth::ModelLayer *>((*itr).get())) { 468 //osgEarth::UID uid = (*itr)->getUID(); 469 names.push_back((*itr)->getName()); 470 } 407 471 } 408 472 } 473 } 474 475 osgEarth::ModelLayer *getModelLayerByName(const std::string& name) 476 { 477 if (!_map.valid()) 478 return NULL; 479 480 return _map->getLayerByName<osgEarth::ModelLayer>(name); 409 481 } 410 482 -
geovis/branches/rex/RendererCmd.cpp
r6562 r6570 2740 2740 if (objc > 3) { 2741 2741 char *name = Tcl_GetString(objv[3]); 2742 g_renderer->removeImageLayer(name); 2743 g_renderer->removeElevationLayer(name); 2744 g_renderer->removeTerrainMaskLayer(name); 2745 g_renderer->removeModelLayer(name); 2742 g_renderer->removeLayer(name); 2746 2743 } else { 2747 2744 g_renderer->clearMap(); … … 2765 2762 return TCL_ERROR; 2766 2763 } 2767 g_renderer->moveImageLayer(name, (unsigned int)pos); 2768 g_renderer->moveElevationLayer(name, (unsigned int)pos); 2769 g_renderer->moveModelLayer(name, (unsigned int)pos); 2764 g_renderer->moveLayer(name, (unsigned int)pos); 2770 2765 2771 2766 return TCL_OK; … … 2786 2781 return TCL_ERROR; 2787 2782 } 2788 g_renderer->setImageLayerOpacity(name, opacity); 2789 g_renderer->setModelLayerOpacity(name, opacity); 2783 g_renderer->setLayerOpacity(name, opacity); 2790 2784 2791 2785 return TCL_OK; … … 2856 2850 if (objc > 4) { 2857 2851 char *name = Tcl_GetString(objv[4]); 2858 g_renderer->setImageLayerVisibility(name, visible); 2859 g_renderer->setElevationLayerVisibility(name, visible); 2860 g_renderer->setModelLayerVisibility(name, visible); 2852 g_renderer->setLayerVisibility(name, visible); 2861 2853 } else { 2862 2854 std::vector<std::string> layers; … … 2866 2858 for (std::vector<std::string>::iterator itr = layers.begin(); 2867 2859 itr != layers.end(); ++itr) { 2868 g_renderer->setImageLayerVisibility(itr->c_str(), visible); 2869 g_renderer->setElevationLayerVisibility(itr->c_str(), visible); 2870 g_renderer->setModelLayerVisibility(itr->c_str(), visible); 2860 g_renderer->setLayerVisibility(itr->c_str(), visible); 2871 2861 } 2872 2862 }
Note: See TracChangeset
for help on using the changeset viewer.