Ignore:
Timestamp:
Nov 6, 2016 12:00:27 AM (7 years ago)
Author:
ldelgass
Message:

First pass at porting to new Map layer API

File:
1 edited

Legend:

Unmodified
Added
Removed
  • geovis/branches/rex/Placard.cpp

    r6507 r6570  
    1414#include <osgEarth/Registry>
    1515#include <osgEarth/ShaderGenerator>
    16 #ifdef NEW_ANNOTATION_API
    1716#include <osgEarth/ScreenSpaceLayout>
    1817#include <osgEarthSymbology/BBoxSymbol>
    19 #else
    20 #include <osgEarth/Decluttering>
    21 #endif
    2218#include <osgEarthSymbology/PolygonSymbol>
    2319#include <osgEarthSymbology/TextSymbol>
     
    4541    _padding = (float)(charSize / 2.0);
    4642
    47 #ifdef NEW_ANNOTATION_API
    4843    osgEarth::Symbology::BBoxSymbol *bbs = _textStyle.getOrCreateSymbol<osgEarth::Symbology::BBoxSymbol>();
    4944    bbs->fill() = osgEarth::Symbology::Color(0.75, 0.75, 0.75, 0.75);
    5045    bbs->margin() = _padding;
    51 #else
    52     // Set backdrop quad color as PolygonSymbol fill
    53     osgEarth::Symbology::PolygonSymbol *ps = _textStyle.getOrCreateSymbol<osgEarth::Symbology::PolygonSymbol>();
    54     ps->fill() = osgEarth::Symbology::Color(0.75, 0.75, 0.75, 0.75);
    55 #endif
    5646}
    5747
     
    10898                         const Placard& placardConf,
    10999                         const osgEarth::Features::AttributeTable &attrs) :
    110 #ifdef NEW_ANNOTATION_API
    111100    osgEarth::Annotation::GeoPositionNode(mapNode, position),
    112 #else
    113     osgEarth::Annotation::OrthoNode(mapNode, position),
    114 #endif
    115101    _placardConf(placardConf),
    116102    _attrs(attrs)
     
    160146PlacardNode::init( const osgEarth::Symbology::Style& style )
    161147{
    162 #ifdef NEW_ANNOTATION_API
    163148    osgEarth::ScreenSpaceLayout::activate(this->getOrCreateStateSet());
    164 #endif
    165149    _backdropGeode = new osg::Geode();
    166150    _backdropGeode->setComputeBoundingSphereCallback(new osgEarth::Annotation::ControlPointCallback());
    167 #ifdef NEW_ANNOTATION_API
    168151    getPositionAttitudeTransform()->addChild( _backdropGeode.get() );
    169 #else
    170     getAttachPoint()->addChild(_backdropGeode.get());
    171 #endif
     152
    172153    osg::StateSet* stateSet = _backdropGeode->getOrCreateStateSet();
    173154    stateSet->setAttributeAndModes( new osg::Depth(osg::Depth::ALWAYS, 0, 1, false), 1 );
     
    179160    _geode->setComputeBoundingSphereCallback(new osgEarth::Annotation::ControlPointCallback());
    180161
    181 #ifdef NEW_ANNOTATION_API
    182162    getPositionAttitudeTransform()->addChild( _geode.get() );
    183 #else
    184     getAttachPoint()->addChild( _geode.get() );
    185 #endif
    186163    stateSet = _geode->getOrCreateStateSet();
    187164    stateSet->setAttributeAndModes( new osg::Depth(osg::Depth::ALWAYS, 0, 1, false), 1 );
     
    235212        return;
    236213    }
    237 #ifndef NEW_ANNOTATION_API
    238     this->clearDecoration();
    239 #endif
    240214    _backdropGeode->removeDrawables( 0, _backdropGeode->getNumDrawables() );
    241215
     
    272246        "osgEarth.PlacardNode",
    273247        osgEarth::Registry::stateSetCache() );
    274 #ifdef NEW_ANNOTATION_API
     248
    275249    // Set to max priority to draw on top in decluttering sort
    276250    setPriority(FLT_MAX);
    277251    // setPriority calls updateLayoutData
    278252    //updateLayoutData();
    279 #endif
    280 }
    281 
    282 #ifdef NEW_ANNOTATION_API
     253}
     254
    283255void
    284256PlacardNode::setPriority(float value)
     
    317289    }
    318290}
    319 #else
    320 void
    321 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 #endif
    335291
    336292void
    337293PlacardNode::setDynamic( bool dynamic )
    338294{
    339 #ifdef NEW_ANNOTATION_API
    340295    osgEarth::Annotation::GeoPositionNode::setDynamic( dynamic );
    341 #else
    342     osgEarth::Annotation::OrthoNode::setDynamic( dynamic );
    343 #endif
     296
    344297    osgText::Text* d = dynamic_cast<osgText::Text*>(_geode->getDrawable(0));
    345298    if ( d )
     
    356309PlacardNode::getConfig() const
    357310{
    358 #ifdef NEW_ANNOTATION_API
    359311    osgEarth::Config conf = osgEarth::Annotation::GeoPositionNode::getConfig();
    360 #else
    361     osgEarth::Config conf = osgEarth::Annotation::OrthoNode::getConfig();
    362 #endif
     312
    363313    conf.key() = "placard";
    364314
Note: See TracChangeset for help on using the changeset viewer.