Changeset 6273 for geovis


Ignore:
Timestamp:
Apr 19, 2016 9:05:15 AM (8 years ago)
Author:
ldelgass
Message:

Fix placard to work with osgearth trunk refactor (Decluttering -> ScreenSpaceLayout?)

Location:
geovis/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • geovis/trunk/Placard.cpp

    r6254 r6273  
    1414#include <osgEarth/Registry>
    1515#include <osgEarth/ShaderGenerator>
     16#ifdef NEW_ANNOTATION_API
     17#include <osgEarth/ScreenSpaceLayout>
     18#else
    1619#include <osgEarth/Decluttering>
     20#endif
    1721#include <osgEarthSymbology/PolygonSymbol>
    1822#include <osgEarthSymbology/TextSymbol>
     
    151155{
    152156#ifdef NEW_ANNOTATION_API
    153     osgEarth::Decluttering::setEnabled(this->getOrCreateStateSet(), false);
     157    osgEarth::ScreenSpaceLayout::activate(this->getOrCreateStateSet());
    154158#endif
    155159    _backdropGeode = new osg::Geode();
     
    263267        osgEarth::Registry::stateSetCache() );
    264268#ifdef NEW_ANNOTATION_API
    265     updateLayoutData();
     269    // Set to max priority to draw on top in decluttering sort
     270    setPriority(FLT_MAX);
     271    // setPriority calls updateLayoutData
     272    //updateLayoutData();
    266273#endif
    267274}
     
    281288        return;
    282289
    283     osg::ref_ptr<osgEarth::LayoutData> data = new osgEarth::LayoutData();
    284     data->_priority = getPriority();
     290    if (!_dataLayout.valid())
     291    {
     292        _dataLayout = new osgEarth::ScreenSpaceLayoutData();
     293    }
     294
     295    // re-apply annotation drawable-level stuff as neccesary.
     296    for (unsigned i = 0; i < _backdropGeode->getNumDrawables(); ++i)
     297    {
     298        _backdropGeode->getDrawable(i)->setUserData(_dataLayout.get());
     299    }
     300    // re-apply annotation drawable-level stuff as neccesary.
     301    for (unsigned i = 0; i < _geode->getNumDrawables(); ++i)
     302    {
     303        _geode->getDrawable(i)->setUserData(_dataLayout.get());
     304    }
     305
     306    _dataLayout->setPriority(getPriority());
    285307    const osgEarth::Symbology::TextSymbol *ts = getStyle().get<osgEarth::Symbology::TextSymbol>();
    286     if (ts) data->_pixelOffset = ts->pixelOffset().get();
    287 
    288     // re-apply annotation drawable-level stuff as neccesary.
    289     for (unsigned i = 0; i<_backdropGeode->getNumDrawables(); ++i)
    290     {
    291         _backdropGeode->getDrawable(i)->setUserData(data.get());
    292     }
    293     // re-apply annotation drawable-level stuff as neccesary.
    294     for (unsigned i = 0; i<_geode->getNumDrawables(); ++i)
    295     {
    296         _geode->getDrawable(i)->setUserData(data.get());
     308    if (ts)
     309    {
     310        _dataLayout->setPixelOffset(ts->pixelOffset().get());
    297311    }
    298312}
  • geovis/trunk/Placard.h

    r6254 r6273  
    195195    osg::ref_ptr<osg::Geode>   _geode;
    196196    osg::ref_ptr<osg::Geode>   _backdropGeode;
     197#ifdef NEW_ANNOTATION_API
     198    osg::ref_ptr<osgEarth::ScreenSpaceLayoutData> _dataLayout;
     199#endif
    197200
    198201    Placard _placardConf;
  • geovis/trunk/Renderer.cpp

    r6254 r6273  
    17321732    PlacardNode *label =
    17331733        new PlacardNode(_mapNode.get(), location, placard, attrs);
     1734#ifndef NEW_ANNOTATION_API
    17341735    label->getOrCreateStateSet()->setRenderBinDetails(INT_MAX, "RenderBin");
     1736#endif
    17351737    getAnnotations()->addChild(label);
    17361738}
Note: See TracChangeset for help on using the changeset viewer.