Changeset 6253 for geovis/trunk


Ignore:
Timestamp:
Apr 7, 2016, 6:35:03 AM (8 years ago)
Author:
ldelgass
Message:

selection debug display

Location:
geovis/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • geovis/trunk/MouseCoordsTool.h

    r4349 r6253  
    5656        // Out of range of map extents
    5757        if (_label.valid()) {
    58             _label->setText("");
     58            _label->setText(osgEarth::Stringify()
     59                            << _prefix
     60                            << "N/A");
    5961        }
    6062        _havePoint = false;
  • geovis/trunk/Picker.cpp

    r6245 r6253  
    204204        TRACE("Hit feature ID: %lu (of %d) layer: %s", feature->getFID(), index->size(), layerName.c_str());
    205205
    206         _renderer->clearSelection();
     206        std::vector<unsigned long> fids;
     207        fids.push_back(feature->getFID());
     208        _renderer->selectFeatures(fids, layerName.c_str(), true);
    207209        _renderer->addPlacard(_pickPoint, feature, layerName.c_str());
    208210
  • geovis/trunk/Renderer.cpp

    r6250 r6253  
    495495void Renderer::initControls()
    496496{
     497    if (!_debugBox.valid()) {
     498        _debugBox =
     499            new osgEarth::Util::Controls::HBox(osgEarth::Util::Controls::Control::ALIGN_RIGHT,
     500                                               osgEarth::Util::Controls::Control::ALIGN_TOP,
     501                                               osgEarth::Util::Controls::Gutter(0, 2, 2, 0), 2.0f);
     502        _debugLabel =
     503            new osgEarth::Util::Controls::LabelControl("Selection: None", 12.0f);
     504        _debugLabel->setForeColor(osg::Vec4f(0, 0, 0, 1));
     505        //_debugLabel->setHaloColor(osg::Vec4f(1, 1, 1, 1));
     506        _debugBox->addControl(_debugLabel.get());
     507        _debugBox->setVertFill(true);
     508        _debugBox->setForeColor(osg::Vec4f(0, 0, 0, 1));
     509        _debugBox->setBackColor(osg::Vec4f(1, 1, 1, 0.6));
     510        osgEarth::Util::Controls::ControlCanvas::getOrCreate(_viewer.get())->addControl(_debugBox.get());
     511    }
    497512    if (_copyrightScaleBox.valid())
    498513        return;
     
    606621            _mouseCoordsTool = NULL;
    607622        }
    608         if (_coordsCallback.valid() && _viewer.valid()) {
    609             osgEarth::Util::Controls::LabelControl *readout =
    610                 _coordsCallback->getLabel();
    611             osgEarth::Util::Controls::ControlCanvas::getOrCreate(_viewer.get())->removeControl(readout);
     623        if (_coordsCallback.valid()) {
    612624            _coordsCallback = NULL;
    613625        }
     626        if (_coordsBox.valid() && _viewer.valid()) {
     627            _coordsBox->clearControls();
     628            osgEarth::Util::Controls::ControlCanvas::getOrCreate(_viewer.get())->removeControl(_coordsBox.get());
     629        }
     630        _coordsBox = NULL;
    614631    } else {
    615632        initMouseCoordsTool(type, precision);
     
    653670        _coordsCallback = NULL;
    654671    } else {
    655         readout = new osgEarth::Util::Controls::LabelControl("", 12.0f);
    656         osgEarth::Util::Controls::ControlCanvas::getOrCreate(_viewer.get())->addControl(readout);
    657         readout->setForeColor(osg::Vec4f(1, 1, 1, 1));
    658         readout->setHaloColor(osg::Vec4f(0, 0, 0, 1));
     672        readout = new osgEarth::Util::Controls::LabelControl("Lat/Long: N/A", 12.0f);
     673        readout->setForeColor(osg::Vec4f(0, 0, 0, 1));
     674        _coordsBox =
     675            new osgEarth::Util::Controls::HBox(osgEarth::Util::Controls::Control::ALIGN_LEFT,
     676                                               osgEarth::Util::Controls::Control::ALIGN_TOP,
     677                                               osgEarth::Util::Controls::Gutter(0, 2, 2, 0), 2.0f);
     678        _coordsBox->setVertFill(true);
     679        _coordsBox->setForeColor(osg::Vec4f(0, 0, 0, 1));
     680        _coordsBox->setBackColor(osg::Vec4f(1, 1, 1, 0.6));
     681        _coordsBox->addControl(readout);
     682        osgEarth::Util::Controls::ControlCanvas::getOrCreate(_viewer.get())->addControl(_coordsBox.get());
    659683    }
    660684
     
    15791603void Renderer::deselectFeatures(std::vector<unsigned long>& featureIDs, const char *layerName)
    15801604{
     1605    // TODO: Take down placard?
    15811606    TRACE("Deselect features layer '%s', num features: %u", layerName, featureIDs.size());
    15821607    for (unsigned int i = 0; i < featureIDs.size(); i++) {
     
    15921617        TRACE("No selection");
    15931618    }
     1619    updateDebugLabel();
    15941620}
    15951621
     
    16571683        _needsRedraw = true;
    16581684    }
     1685    updateDebugLabel();
     1686}
     1687
     1688void Renderer::updateDebugLabel()
     1689{
     1690    if (!_debugLabel.valid()) return;
     1691    std::ostringstream oss;
     1692    oss << "Selection:";
     1693    for (FeatureSelectionHashmap::iterator itr = _selectedFeatures.begin();
     1694         itr != _selectedFeatures.end(); ++itr) {
     1695        bool found = false;
     1696        oss << std::endl << itr->first << ":";
     1697        for (FeatureSelectionHashmap::mapped_type::iterator fitr = itr->second.begin();
     1698             fitr != itr->second.end(); ++fitr) {
     1699            oss << " " << *fitr;
     1700            found = true;
     1701        }
     1702        if (!found) {
     1703            oss << " None";
     1704        }
     1705    }
     1706    _debugLabel->setText(oss.str());
    16591707}
    16601708
     
    16821730    clearSelectionAnnotationNodes();
    16831731    clearBoxSelection();
     1732    updateDebugLabel();
    16841733    _needsRedraw = true;
    16851734}
  • geovis/trunk/Renderer.h

    r6246 r6253  
    603603    void initControls();
    604604
     605    void updateDebugLabel();
     606
    605607    void initEarthManipulator();
    606608
     
    661663    osg::ref_ptr<ScreenCaptureCallback> _captureCallback;
    662664    osg::ref_ptr<osgEarth::Util::AutoClipPlaneCullCallback> _clipPlaneCullCallback;
     665    osg::ref_ptr<osgEarth::Util::Controls::HBox> _coordsBox;
    663666    osg::ref_ptr<MouseCoordsTool> _mouseCoordsTool;
    664667    osg::ref_ptr<MouseCoordsCallback> _coordsCallback;
     668    osg::ref_ptr<osgEarth::Util::Controls::HBox> _debugBox;
     669    osg::ref_ptr<osgEarth::Util::Controls::LabelControl> _debugLabel;
    665670    osg::ref_ptr<osgEarth::Util::Controls::HBox> _copyrightScaleBox;
    666671    osg::ref_ptr<osgEarth::Util::Controls::LabelControl> _copyrightLabel;
Note: See TracChangeset for help on using the changeset viewer.