- Timestamp:
- Apr 4, 2016 4:57:46 PM (8 years ago)
- Location:
- geovis/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
geovis/trunk/Makefile.in
r6049 r6245 3 3 TRACE = #yes 4 4 TRACE_FRAME = #yes 5 NEW_ANNOTATION_API = #yes 5 6 USE_OFFSCREEN_RENDERING = #yes 6 7 USE_THREADS = yes … … 97 98 ifdef TRACE_FRAME 98 99 DEFINES += -DWANT_FRAME 100 endif 101 ifdef NEW_ANNOTATION_API 102 DEFINES += -DNEW_ANNOTATION_API 99 103 endif 100 104 ifdef USE_OFFSCREEN_RENDERING -
geovis/trunk/Picker.cpp
r6116 r6245 164 164 itr != toUnHover.end(); ++itr) { 165 165 hovered.erase(*itr); 166 #ifndef NEW_ANNOTATION_API 166 167 (*itr)->clearDecoration(); 168 #endif 167 169 _renderer->eventuallyRender(); 168 170 } … … 273 275 osgEarth::Registry::objectIndex()->get<osgEarth::Annotation::AnnotationNode>(id); 274 276 std::set<osgEarth::Annotation::AnnotationNode*>& hovered = _renderer->getHovered(); 277 #ifndef NEW_ANNOTATION_API 275 278 anno->clearDecoration(); 279 #endif 276 280 _renderer->getPlaceNodes()->removeChild(anno); 277 281 if (hovered.find(anno) != hovered.end()) { -
geovis/trunk/Placard.cpp
r6084 r6245 14 14 #include <osgEarth/Registry> 15 15 #include <osgEarth/ShaderGenerator> 16 #include <osgEarth/Decluttering> 16 17 #include <osgEarthSymbology/PolygonSymbol> 17 18 #include <osgEarthSymbology/TextSymbol> … … 96 97 const Placard& placardConf, 97 98 const osgEarth::Features::AttributeTable &attrs) : 99 #ifdef NEW_ANNOTATION_API 100 osgEarth::Annotation::GeoPositionNode(mapNode, position), 101 #else 98 102 osgEarth::Annotation::OrthoNode(mapNode, position), 103 #endif 99 104 _placardConf(placardConf), 100 105 _attrs(attrs) … … 144 149 PlacardNode::init( const osgEarth::Symbology::Style& style ) 145 150 { 151 #ifdef NEW_ANNOTATION_API 152 osgEarth::Decluttering::setEnabled(this->getOrCreateStateSet(), false); 153 #endif 146 154 _backdropGeode = new osg::Geode(); 147 155 _backdropGeode->setComputeBoundingSphereCallback(new osgEarth::Annotation::ControlPointCallback()); 156 #ifdef NEW_ANNOTATION_API 157 getPositionAttitudeTransform()->addChild( _backdropGeode.get() ); 158 #else 148 159 getAttachPoint()->addChild(_backdropGeode.get()); 149 160 #endif 150 161 osg::StateSet* stateSet = _backdropGeode->getOrCreateStateSet(); 151 162 stateSet->setAttributeAndModes( new osg::Depth(osg::Depth::ALWAYS, 0, 1, false), 1 ); … … 157 168 _geode->setComputeBoundingSphereCallback(new osgEarth::Annotation::ControlPointCallback()); 158 169 170 #ifdef NEW_ANNOTATION_API 171 getPositionAttitudeTransform()->addChild( _geode.get() ); 172 #else 159 173 getAttachPoint()->addChild( _geode.get() ); 160 174 #endif 161 175 stateSet = _geode->getOrCreateStateSet(); 162 176 stateSet->setAttributeAndModes( new osg::Depth(osg::Depth::ALWAYS, 0, 1, false), 1 ); … … 210 224 return; 211 225 } 212 226 #ifndef NEW_ANNOTATION_API 213 227 this->clearDecoration(); 214 228 #endif 215 229 _backdropGeode->removeDrawables( 0, _backdropGeode->getNumDrawables() ); 216 230 … … 227 241 _geode->addDrawable(t); 228 242 _geode->setCullingActive(false); 229 230 osg::BoundingBox bbox = t->getBoundingBox();231 243 232 244 const osgEarth::Symbology::PolygonSymbol* gs = _style.get<osgEarth::Symbology::PolygonSymbol>(); … … 236 248 } 237 249 250 osg::BoundingBox bbox = t->getBoundingBox(); 238 251 osg::Drawable *bd = osgEarth::Annotation::AnnotationUtils::create2DQuad(bbox, _placardConf.getPadding(), color); 239 252 _backdropGeode->addDrawable(bd); … … 248 261 "osgEarth.PlacardNode", 249 262 osgEarth::Registry::stateSetCache() ); 250 } 251 263 #ifdef NEW_ANNOTATION_API 264 updateLayoutData(); 265 #endif 266 } 267 268 #ifdef NEW_ANNOTATION_API 269 void 270 PlacardNode::setPriority(float value) 271 { 272 osgEarth::Annotation::GeoPositionNode::setPriority(value); 273 updateLayoutData(); 274 } 275 276 void 277 PlacardNode::updateLayoutData() 278 { 279 if (!_geode.valid()) 280 return; 281 282 osg::ref_ptr<osgEarth::LayoutData> data = new osgEarth::LayoutData(); 283 data->_priority = getPriority(); 284 const osgEarth::Symbology::TextSymbol *ts = getStyle().get<osgEarth::Symbology::TextSymbol>(); 285 if (ts) data->_pixelOffset = ts->pixelOffset().get(); 286 287 // re-apply annotation drawable-level stuff as neccesary. 288 for (unsigned i = 0; i<_backdropGeode->getNumDrawables(); ++i) 289 { 290 _backdropGeode->getDrawable(i)->setUserData(data.get()); 291 } 292 // re-apply annotation drawable-level stuff as neccesary. 293 for (unsigned i = 0; i<_geode->getNumDrawables(); ++i) 294 { 295 _geode->getDrawable(i)->setUserData(data.get()); 296 } 297 } 298 #else 252 299 void 253 300 PlacardNode::setAnnotationData( osgEarth::Annotation::AnnotationData* data ) 254 301 { 255 302 osgEarth::Annotation::OrthoNode::setAnnotationData( data ); 303 304 if (!_geode.valid()) 305 return; 256 306 257 307 // override this method so we can attach the anno data to the drawables. … … 261 311 } 262 312 } 313 #endif 263 314 264 315 void 265 316 PlacardNode::setDynamic( bool dynamic ) 266 317 { 318 #ifdef NEW_ANNOTATION_API 319 osgEarth::Annotation::GeoPositionNode::setDynamic( dynamic ); 320 #else 267 321 osgEarth::Annotation::OrthoNode::setDynamic( dynamic ); 268 322 #endif 269 323 osgText::Text* d = dynamic_cast<osgText::Text*>(_geode->getDrawable(0)); 270 324 if ( d ) … … 281 335 PlacardNode::getConfig() const 282 336 { 283 osgEarth::Config conf( "placard" ); 337 #ifdef NEW_ANNOTATION_API 338 osgEarth::Config conf = osgEarth::Annotation::GeoPositionNode::getConfig(); 339 #else 340 osgEarth::Config conf = osgEarth::Annotation::OrthoNode::getConfig(); 341 #endif 342 conf.key() = "placard"; 343 284 344 conf.add ( "text", _text ); 285 345 conf.addObj( "style", _style ); 286 346 conf.add ( "padding", _placardConf.getPadding() ); 287 conf.addObj( "position", getPosition() );288 347 289 348 return conf; -
geovis/trunk/Placard.h
r5974 r6245 13 13 #include <algorithm> 14 14 15 #ifdef NEW_ANNOTATION_API 16 #include <osgEarthAnnotation/GeoPositionNode> 17 #else 15 18 #include <osgEarthAnnotation/Decoration> 16 19 #include <osgEarthAnnotation/OrthoNode> 20 #endif 17 21 #include <osgEarthAnnotation/LabelNode> 18 22 #include <osgEarthFeatures/Feature> … … 79 83 public: 80 84 META_Node(osgEarthAnnotation, PlacardLabelNode); 85 #ifndef NEW_ANNOTATION_API 81 86 virtual bool accept(osgEarth::Annotation::Decoration* ds, bool enable) 82 87 { return ds->apply(*this, enable); } 83 88 #endif 84 89 PlacardLabelNode() : 85 90 osgEarth::Annotation::LabelNode() … … 105 110 }; 106 111 107 class PlacardNode : public osgEarth::Annotation::OrthoNode { 112 class PlacardNode : 113 #ifdef NEW_ANNOTATION_API 114 public osgEarth::Annotation::GeoPositionNode 115 #else 116 public osgEarth::Annotation::OrthoNode 117 #endif 118 { 108 119 public: 109 120 META_Node(osgEarthAnnotation, PlacardNode); 121 #ifndef NEW_ANNOTATION_API 110 122 virtual bool accept(osgEarth::Annotation::Decoration* ds, bool enable) 111 123 { return ds->apply(*this, enable); } 112 124 #endif 113 125 PlacardNode() : 126 #ifdef NEW_ANNOTATION_API 127 osgEarth::Annotation::GeoPositionNode() 128 #else 114 129 osgEarth::Annotation::OrthoNode() 130 #endif 115 131 {} 116 132 PlacardNode(const PlacardNode& other, const osg::CopyOp& op = osg::CopyOp::DEEP_COPY_ALL) : 133 #ifdef NEW_ANNOTATION_API 134 osgEarth::Annotation::GeoPositionNode(other, op), 135 #else 117 136 osgEarth::Annotation::OrthoNode(other, op), 137 #endif 118 138 _placardConf(other._placardConf) 119 139 { … … 146 166 void setStyle( const osgEarth::Symbology::Style& style ); 147 167 148 public: // OrthoNode override 149 168 public: // Ortho|GeoPositionNode override 169 #ifdef NEW_ANNOTATION_API 170 virtual void setPriority(float value); 171 #else 150 172 virtual void setAnnotationData( osgEarth::Annotation::AnnotationData* data ); 151 173 #endif 152 174 virtual void setDynamic( bool value ); 153 175 … … 156 178 protected: 157 179 void init(const osgEarth::Symbology::Style& style); 180 #ifdef NEW_ANNOTATION_API 181 void updateLayoutData(); 182 #endif 158 183 159 184 std::string _text; -
geovis/trunk/Renderer.cpp
r6219 r6245 71 71 #include <osgEarthAnnotation/FeatureNode> 72 72 #include <osgEarthAnnotation/PlaceNode> 73 #ifndef NEW_ANNOTATION_API 73 74 #include <osgEarthAnnotation/HighlightDecoration> 74 75 #include <osgEarthAnnotation/ScaleDecoration> 76 #endif 75 77 #include <osgEarthUtil/EarthManipulator> 76 78 #include <osgEarthUtil/Sky> … … 1694 1696 osg::Node *node = nodes->getChild(i); 1695 1697 // This can be Placard, PlacardLabel, Label, Place or Track Node 1698 #ifdef NEW_ANNOTATION_API 1699 if (dynamic_cast<osgEarth::Annotation::GeoPositionNode *>(node) != NULL) { 1700 #else 1696 1701 if (dynamic_cast<osgEarth::Annotation::OrthoNode *>(node) != NULL) { 1702 #endif 1697 1703 toRemove.push_back(node); 1698 1704 } … … 1755 1761 (*geom)[3] = osg::Vec3d(longMax, latMax, 0); 1756 1762 node->init(); 1763 #ifndef NEW_ANNOTATION_API 1757 1764 for (std::set<osgEarth::Annotation::AnnotationNode *>::iterator itr = _selected.begin(); 1758 1765 itr != _selected.end(); ++itr) { 1759 1766 (*itr)->clearDecoration(); 1760 1767 } 1768 #endif 1761 1769 _selected.clear(); 1762 1770 SelectPlaceNodesVisitor spnv(this, latMin, latMax, longMin, longMax); … … 1780 1788 pt.x(), pt.y(), placeNode->getName().c_str(), 1781 1789 placeNode->getText().c_str()); 1790 #ifndef NEW_ANNOTATION_API 1782 1791 placeNode->setDecoration("select"); 1792 #endif 1783 1793 } 1784 1794 } … … 1793 1803 _selectionBox = NULL; 1794 1804 } 1805 #ifndef NEW_ANNOTATION_API 1795 1806 for (std::set<osgEarth::Annotation::AnnotationNode *>::iterator itr = _selected.begin(); 1796 1807 itr != _selected.end(); ++itr) { 1797 1808 (*itr)->clearDecoration(); 1798 1809 } 1810 #endif 1799 1811 _selected.clear(); 1800 1812 _needsRedraw = true;
Note: See TracChangeset
for help on using the changeset viewer.