Changeset 5938 for geovis/trunk
- Timestamp:
- Dec 3, 2015, 12:30:50 PM (9 years ago)
- Location:
- geovis/trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
geovis/trunk/Makefile.in
r5873 r5938 206 206 PPMWriter.o: PPMWriter.h ResponseQueue.h Trace.h 207 207 ReadBuffer.o: ReadBuffer.h Trace.h 208 Renderer.o: Renderer.h Trace.h Picker.h MouseCoordsTool.h ScaleBar.h FileUtil.h 208 Renderer.o: Renderer.h Trace.h Picker.h MouseCoordsTool.h ScaleBar.h FileUtil.h Util.h 209 209 RendererCmd.o: Renderer.h ReadBuffer.h ResponseQueue.h Trace.h CmdProc.h PPMWriter.h TGAWriter.h 210 210 RenderServer.o: RenderServer.h RendererCmd.h Renderer.h ReadBuffer.h ResponseQueue.h Trace.h PPMWriter.h TGAWriter.h Stats.h -
geovis/trunk/Picker.cpp
r5890 r5938 29 29 30 30 static const char *highlightVert = 31 "#version 130\n"31 "#version " GLSL_VERSION_STR "\n" 32 32 "uniform uint objectid_to_highlight; \n" 33 33 "uint oe_index_objectid; // Stage global containing object id \n" … … 39 39 40 40 static const char *highlightFrag = 41 "#version 130\n"41 "#version " GLSL_VERSION_STR "\n" 42 42 "flat in int selected; \n" 43 43 "void highlightFragment(inout vec4 color) \n" … … 51 51 static void installHighlighter(osg::StateSet *stateSet, int attrLocation) 52 52 { 53 TRACE("GLSL Version: %s", GLSL_VERSION_STR); 53 54 // This shader program will highlight the selected object. 54 55 osgEarth::VirtualProgram *vp = osgEarth::VirtualProgram::getOrCreate(stateSet); … … 62 63 s_highlightUniform = new osg::Uniform("objectid_to_highlight", 0u); 63 64 stateSet->addUniform(s_highlightUniform); 65 } 66 67 void GeoVis::setHighlightByObjectID(osgEarth::ObjectID id) 68 { 69 if (s_highlightUniform != NULL) { 70 s_highlightUniform->set(id); 71 } 72 } 73 74 void GeoVis::clearHighlight() 75 { 76 if (s_highlightUniform != NULL) { 77 s_highlightUniform->set(0U); 78 } 64 79 } 65 80 -
geovis/trunk/Picker.h
r5873 r5938 9 9 10 10 #include <osgEarth/Picker> 11 #include <osgEarth/ObjectIndex> 11 12 12 13 namespace GeoVis { … … 53 54 }; 54 55 56 extern void setHighlightByObjectID(osgEarth::ObjectID id); 57 extern void clearHighlight(); 58 55 59 } 56 60 -
geovis/trunk/Renderer.cpp
r5930 r5938 41 41 #include <osgEarthDrivers/cache_filesystem/FileSystemCache> 42 42 #include <osgEarth/MapNode> 43 #include <osgEarth/TerrainEngineNode> 43 44 #include <osgEarth/Bounds> 44 45 #include <osgEarth/Profile> … … 62 63 #include <osgEarth/Pickers> 63 64 #endif 65 #include <osgEarthFeatures/FeatureModelSource> 64 66 #include <osgEarthFeatures/Feature> 65 67 #include <osgEarthSymbology/Color> … … 101 103 #include "ScaleBar.h" 102 104 #include "FileUtil.h" 105 #include "Util.h" 103 106 #include "Trace.h" 104 107 … … 1533 1536 { 1534 1537 TRACE("Select layer '%s', num features: %u", layerName, featureIDs.size()); 1538 if (featureIDs.size() == 0) { 1539 // clear selection 1540 return; 1541 } 1535 1542 osgEarth::ModelLayer *layer = _map->getModelLayerByName(layerName); 1536 1543 if (layer == NULL) { … … 1538 1545 return; 1539 1546 } 1547 #ifdef WANT_TRACE 1540 1548 for (unsigned int i = 0; i < featureIDs.size(); i++) { 1541 1549 TRACE("feature ID: %u", featureIDs.at(i)); 1550 } 1551 #endif 1552 unsigned long fid = featureIDs.at(0); 1553 1554 osgEarth::ModelSource *modelSource = layer->getModelSource(); 1555 osgEarth::Features::FeatureModelSource *fms = dynamic_cast<osgEarth::Features::FeatureModelSource *>(modelSource); 1556 if (fms != NULL) { 1557 osgEarth::Features::FeatureSource *fs = fms->getFeatureSource(); 1558 FindFeatureSourceIndexNodeVisitor visitor; 1559 visitor.source = fs; 1560 _sceneRoot->accept(visitor); 1561 TRACE("Num FeatureSourceIndexNodes found: %lu", visitor.nodes.size()); 1562 for (size_t i = 0; i < visitor.nodes.size(); i++) { 1563 osgEarth::Features::FeatureIndex *index = visitor.nodes[i]->getIndex(); 1564 #if OSGEARTH_MIN_VERSION_REQUIRED(3, 0, 0) 1565 osgEarth::ObjectID id = index->getObjectID(fid); 1566 setHighlightByObjectID(id); 1567 TRACE("FID %lu = OID %d", fid, id); 1568 #endif 1569 } 1542 1570 } 1543 1571 } -
geovis/trunk/Util.h
r5873 r5938 8 8 #define GEOVIS_UTIL_H 9 9 10 #include <cstring> 10 11 #include <string> 11 12 13 #include <osg/NodeVisitor> 14 #include <osgEarthFeatures/FeatureIndex> 15 #include <osgEarthFeatures/FeatureSourceIndexNode> 16 12 17 namespace GeoVis { 18 19 class FindFeatureSourceIndexNodeVisitor : public osg::NodeVisitor { 20 public: 21 FindFeatureSourceIndexNodeVisitor() : 22 osg::NodeVisitor(TRAVERSE_ALL_CHILDREN), 23 source(NULL) 24 { 25 } 26 27 virtual ~FindFeatureSourceIndexNodeVisitor() {} 28 29 virtual void apply(osg::Node& node) 30 { 31 if (strcmp(node.className(), "FeatureSourceIndexNode") == 0) { 32 osgEarth::Features::FeatureSourceIndexNode *fsin = dynamic_cast<osgEarth::Features::FeatureSourceIndexNode *>(&node); 33 osgEarth::Features::FeatureSourceIndex *index = fsin->getIndex(); 34 if (source == NULL || index->getFeatureSource() == source) { 35 nodes.push_back(fsin); 36 } 37 } 38 traverse(node); 39 } 40 41 osgEarth::Features::FeatureSource *source; 42 std::vector<osgEarth::Features::FeatureSourceIndexNode *> nodes; 43 }; 13 44 14 45 extern std::string loadCSVLayer(const char *filename, const char *longitudeColName = "longitude", const char *latitudeColName = "latitude"); -
geovis/trunk/geovis_protocol.txt
r5924 r5938 215 215 <clamptechnique> = drape|gpu|scene|map 216 216 217 map layer add <layerName> feature <driver> <format> <typeName> <url> <cache> <style> <?scripts?> <?selectors?> <?visibilityRangeMin?> <?visibilityRangeMax?> 218 <style> = CSS styles 219 <scripts> = JavaScript 220 <selectors> = List of name/value pairs 217 221 map layer add <layerName> icon <driver> <format> <typeName> <url> <cache> <icon> <scale> <heading> <declutter> <placement> <alignment> <?visibilityRangeMin?> <?visibilityRangeMax?> 218 222 Add an icon feature layer from a file or URL
Note: See TracChangeset
for help on using the changeset viewer.