Changeset 6570 for geovis/branches/rex/Placard.cpp
- Timestamp:
- Nov 6, 2016 12:00:27 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.