Changeset 6005 for geovis


Ignore:
Timestamp:
Feb 11, 2016 11:57:17 PM (8 years ago)
Author:
ldelgass
Message:

Add ability to post placard on select feature command (currently disabled).

Location:
geovis/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • geovis/trunk/Picker.cpp

    r6003 r6005  
    202202
    203203        _renderer->clearSelection();
    204 
    205         const osgEarth::Features::AttributeTable &attrs = feature->getAttrs();
    206         Placard placard = _renderer->getPlacardConfig(layerName);
    207         if (placard.getNumEntries() == 0) {
    208             placard.addAllAttributes(attrs);
    209         }
    210         PlacardNode *label =
    211             new PlacardNode(_renderer->getMapNode(), _pickPoint, placard, attrs);
    212         label->getOrCreateStateSet()->setRenderBinDetails(INT_MAX, "RenderBin");
    213         _renderer->getAnnotations()->addChild(label);
     204        _renderer->addPlacard(_pickPoint, feature, layerName.c_str());
    214205
    215206        char mesg[256];
  • geovis/trunk/Renderer.cpp

    r6004 r6005  
    15661566#if OSGEARTH_MIN_VERSION_REQUIRED(3, 0, 0)
    15671567            osgEarth::ObjectID id = index->getObjectID(fid);
     1568#if 0
     1569            osgEarth::Features::Feature *feature = index->getFeature(id);
     1570            if (feature) {
     1571                // Find feature centroid
     1572                osgEarth::GeoPoint location;
     1573                if (feature->getGeometry()) {
     1574                    osg::BoundingSphered bound;
     1575                    feature->getWorldBound(getMapSRS(), bound);
     1576                    location.set(getMapSRS(), bound.center(),
     1577                                 osgEarth::ALTMODE_ABSOLUTE);
     1578                }
     1579                addPlacard(location, feature, layerName);
     1580            }
     1581#endif
    15681582            setHighlightByObjectID(id);
    15691583            TRACE("FID %lu = OID %d", fid, id);
     
    15721586        _needsRedraw = true;
    15731587    }
     1588}
     1589
     1590void Renderer::addPlacard(const osgEarth::GeoPoint& location,
     1591                          osgEarth::Features::Feature *feature,
     1592                          const char *layerName)
     1593{
     1594    if (feature == NULL) return;
     1595
     1596    const osgEarth::Features::AttributeTable &attrs = feature->getAttrs();
     1597    Placard placard = getPlacardConfig(layerName);
     1598    if (placard.getNumEntries() == 0) {
     1599        placard.addAllAttributes(attrs);
     1600    }
     1601    PlacardNode *label =
     1602        new PlacardNode(_mapNode.get(), location, placard, attrs);
     1603    label->getOrCreateStateSet()->setRenderBinDetails(INT_MAX, "RenderBin");
     1604    getAnnotations()->addChild(label);
    15741605}
    15751606
  • geovis/trunk/Renderer.h

    r6002 r6005  
    519519    void selectFeatures(std::vector<unsigned long>& featureIDs, const char *layerName);
    520520
     521    void addPlacard(const osgEarth::GeoPoint& location,
     522                    osgEarth::Features::Feature *feature,
     523                    const char *layerName);
     524
    521525    void clearSelection();
    522526
     
    555559        return _placeNodes.get();
    556560    }
    557     Placard getPlacardConfig(const std::string& layerName)
     561    Placard getPlacardConfig(const char *layerName)
    558562    {
    559563        Placard ret;
Note: See TracChangeset for help on using the changeset viewer.