Changeset 6245 for geovis


Ignore:
Timestamp:
Apr 4, 2016 4:57:46 PM (8 years ago)
Author:
ldelgass
Message:

Add define for new annotation API in osgEarth master

Location:
geovis/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • geovis/trunk/Makefile.in

    r6049 r6245  
    33TRACE                   = #yes
    44TRACE_FRAME             = #yes
     5NEW_ANNOTATION_API      = #yes
    56USE_OFFSCREEN_RENDERING = #yes
    67USE_THREADS             = yes
     
    9798ifdef TRACE_FRAME
    9899DEFINES         += -DWANT_FRAME
     100endif
     101ifdef NEW_ANNOTATION_API
     102DEFINES         += -DNEW_ANNOTATION_API
    99103endif
    100104ifdef USE_OFFSCREEN_RENDERING
  • geovis/trunk/Picker.cpp

    r6116 r6245  
    164164         itr != toUnHover.end(); ++itr) {
    165165        hovered.erase(*itr);
     166#ifndef NEW_ANNOTATION_API
    166167        (*itr)->clearDecoration();
     168#endif
    167169        _renderer->eventuallyRender();
    168170    }
     
    273275            osgEarth::Registry::objectIndex()->get<osgEarth::Annotation::AnnotationNode>(id);
    274276        std::set<osgEarth::Annotation::AnnotationNode*>& hovered = _renderer->getHovered();
     277#ifndef NEW_ANNOTATION_API
    275278        anno->clearDecoration();
     279#endif
    276280        _renderer->getPlaceNodes()->removeChild(anno);
    277281        if (hovered.find(anno) != hovered.end()) {
  • geovis/trunk/Placard.cpp

    r6084 r6245  
    1414#include <osgEarth/Registry>
    1515#include <osgEarth/ShaderGenerator>
     16#include <osgEarth/Decluttering>
    1617#include <osgEarthSymbology/PolygonSymbol>
    1718#include <osgEarthSymbology/TextSymbol>
     
    9697                         const Placard& placardConf,
    9798                         const osgEarth::Features::AttributeTable &attrs) :
     99#ifdef NEW_ANNOTATION_API
     100    osgEarth::Annotation::GeoPositionNode(mapNode, position),
     101#else
    98102    osgEarth::Annotation::OrthoNode(mapNode, position),
     103#endif
    99104    _placardConf(placardConf),
    100105    _attrs(attrs)
     
    144149PlacardNode::init( const osgEarth::Symbology::Style& style )
    145150{
     151#ifdef NEW_ANNOTATION_API
     152    osgEarth::Decluttering::setEnabled(this->getOrCreateStateSet(), false);
     153#endif
    146154    _backdropGeode = new osg::Geode();
    147155    _backdropGeode->setComputeBoundingSphereCallback(new osgEarth::Annotation::ControlPointCallback());
     156#ifdef NEW_ANNOTATION_API
     157    getPositionAttitudeTransform()->addChild( _backdropGeode.get() );
     158#else
    148159    getAttachPoint()->addChild(_backdropGeode.get());
    149 
     160#endif
    150161    osg::StateSet* stateSet = _backdropGeode->getOrCreateStateSet();
    151162    stateSet->setAttributeAndModes( new osg::Depth(osg::Depth::ALWAYS, 0, 1, false), 1 );
     
    157168    _geode->setComputeBoundingSphereCallback(new osgEarth::Annotation::ControlPointCallback());
    158169
     170#ifdef NEW_ANNOTATION_API
     171    getPositionAttitudeTransform()->addChild( _geode.get() );
     172#else
    159173    getAttachPoint()->addChild( _geode.get() );
    160 
     174#endif
    161175    stateSet = _geode->getOrCreateStateSet();
    162176    stateSet->setAttributeAndModes( new osg::Depth(osg::Depth::ALWAYS, 0, 1, false), 1 );
     
    210224        return;
    211225    }
    212 
     226#ifndef NEW_ANNOTATION_API
    213227    this->clearDecoration();
    214 
     228#endif
    215229    _backdropGeode->removeDrawables( 0, _backdropGeode->getNumDrawables() );
    216230
     
    227241    _geode->addDrawable(t);
    228242    _geode->setCullingActive(false);
    229 
    230     osg::BoundingBox bbox = t->getBoundingBox();
    231243
    232244    const osgEarth::Symbology::PolygonSymbol* gs = _style.get<osgEarth::Symbology::PolygonSymbol>();
     
    236248    }
    237249
     250    osg::BoundingBox bbox = t->getBoundingBox();
    238251    osg::Drawable *bd = osgEarth::Annotation::AnnotationUtils::create2DQuad(bbox, _placardConf.getPadding(), color);
    239252    _backdropGeode->addDrawable(bd);
     
    248261        "osgEarth.PlacardNode",
    249262        osgEarth::Registry::stateSetCache() );
    250 }
    251 
     263#ifdef NEW_ANNOTATION_API
     264    updateLayoutData();
     265#endif
     266}
     267
     268#ifdef NEW_ANNOTATION_API
     269void
     270PlacardNode::setPriority(float value)
     271{
     272    osgEarth::Annotation::GeoPositionNode::setPriority(value);
     273    updateLayoutData();
     274}
     275
     276void
     277PlacardNode::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
    252299void
    253300PlacardNode::setAnnotationData( osgEarth::Annotation::AnnotationData* data )
    254301{
    255302    osgEarth::Annotation::OrthoNode::setAnnotationData( data );
     303
     304    if (!_geode.valid())
     305        return;
    256306
    257307    // override this method so we can attach the anno data to the drawables.
     
    261311    }
    262312}
     313#endif
    263314
    264315void
    265316PlacardNode::setDynamic( bool dynamic )
    266317{
     318#ifdef NEW_ANNOTATION_API
     319    osgEarth::Annotation::GeoPositionNode::setDynamic( dynamic );
     320#else
    267321    osgEarth::Annotation::OrthoNode::setDynamic( dynamic );
    268 
     322#endif
    269323    osgText::Text* d = dynamic_cast<osgText::Text*>(_geode->getDrawable(0));
    270324    if ( d )
     
    281335PlacardNode::getConfig() const
    282336{
    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
    284344    conf.add   ( "text",   _text );
    285345    conf.addObj( "style",  _style );
    286346    conf.add   ( "padding", _placardConf.getPadding() );
    287     conf.addObj( "position", getPosition() );
    288347
    289348    return conf;
  • geovis/trunk/Placard.h

    r5974 r6245  
    1313#include <algorithm>
    1414
     15#ifdef NEW_ANNOTATION_API
     16#include <osgEarthAnnotation/GeoPositionNode>
     17#else
    1518#include <osgEarthAnnotation/Decoration>
    1619#include <osgEarthAnnotation/OrthoNode>
     20#endif
    1721#include <osgEarthAnnotation/LabelNode>
    1822#include <osgEarthFeatures/Feature>
     
    7983public:
    8084    META_Node(osgEarthAnnotation, PlacardLabelNode);
     85#ifndef NEW_ANNOTATION_API
    8186    virtual bool accept(osgEarth::Annotation::Decoration* ds, bool enable)
    8287    { return ds->apply(*this, enable); }
    83 
     88#endif
    8489    PlacardLabelNode() :
    8590        osgEarth::Annotation::LabelNode()
     
    105110};
    106111
    107 class PlacardNode : public osgEarth::Annotation::OrthoNode {
     112class PlacardNode :
     113#ifdef NEW_ANNOTATION_API
     114public osgEarth::Annotation::GeoPositionNode
     115#else
     116public osgEarth::Annotation::OrthoNode
     117#endif
     118{
    108119public:
    109120    META_Node(osgEarthAnnotation, PlacardNode);
     121#ifndef NEW_ANNOTATION_API
    110122    virtual bool accept(osgEarth::Annotation::Decoration* ds, bool enable)
    111123    { return ds->apply(*this, enable); }
    112 
     124#endif
    113125    PlacardNode() :
     126#ifdef NEW_ANNOTATION_API
     127        osgEarth::Annotation::GeoPositionNode()
     128#else
    114129        osgEarth::Annotation::OrthoNode()
     130#endif
    115131    {}
    116132    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
    117136        osgEarth::Annotation::OrthoNode(other, op),
     137#endif
    118138        _placardConf(other._placardConf)
    119139    {
     
    146166    void setStyle( const osgEarth::Symbology::Style& style );
    147167
    148 public: // OrthoNode override
    149 
     168public: // Ortho|GeoPositionNode override
     169#ifdef NEW_ANNOTATION_API
     170    virtual void setPriority(float value);
     171#else
    150172    virtual void setAnnotationData( osgEarth::Annotation::AnnotationData* data );
    151 
     173#endif
    152174    virtual void setDynamic( bool value );
    153175
     
    156178protected:
    157179    void init(const osgEarth::Symbology::Style& style);
     180#ifdef NEW_ANNOTATION_API
     181    void updateLayoutData();
     182#endif
    158183
    159184    std::string                _text;
  • geovis/trunk/Renderer.cpp

    r6219 r6245  
    7171#include <osgEarthAnnotation/FeatureNode>
    7272#include <osgEarthAnnotation/PlaceNode>
     73#ifndef NEW_ANNOTATION_API
    7374#include <osgEarthAnnotation/HighlightDecoration>
    7475#include <osgEarthAnnotation/ScaleDecoration>
     76#endif
    7577#include <osgEarthUtil/EarthManipulator>
    7678#include <osgEarthUtil/Sky>
     
    16941696        osg::Node *node = nodes->getChild(i);
    16951697        // 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
    16961701        if (dynamic_cast<osgEarth::Annotation::OrthoNode *>(node) != NULL) {
     1702#endif
    16971703            toRemove.push_back(node);
    16981704        }
     
    17551761    (*geom)[3] = osg::Vec3d(longMax, latMax, 0);
    17561762    node->init();
     1763#ifndef NEW_ANNOTATION_API
    17571764    for (std::set<osgEarth::Annotation::AnnotationNode *>::iterator itr = _selected.begin();
    17581765         itr != _selected.end(); ++itr) {
    17591766        (*itr)->clearDecoration();
    17601767    }
     1768#endif
    17611769    _selected.clear();
    17621770    SelectPlaceNodesVisitor spnv(this, latMin, latMax, longMin, longMax);
     
    17801788                     pt.x(), pt.y(), placeNode->getName().c_str(),
    17811789                     placeNode->getText().c_str());
     1790#ifndef NEW_ANNOTATION_API
    17821791                placeNode->setDecoration("select");
     1792#endif
    17831793            }
    17841794        }
     
    17931803        _selectionBox = NULL;
    17941804    }
     1805#ifndef NEW_ANNOTATION_API
    17951806    for (std::set<osgEarth::Annotation::AnnotationNode *>::iterator itr = _selected.begin();
    17961807         itr != _selected.end(); ++itr) {
    17971808        (*itr)->clearDecoration();
    17981809    }
     1810#endif
    17991811    _selected.clear();
    18001812    _needsRedraw = true;
Note: See TracChangeset for help on using the changeset viewer.