Changeset 5944 for geovis/trunk/Picker.cpp
- Timestamp:
- Dec 11, 2015, 12:21:12 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
geovis/trunk/Picker.cpp
r5942 r5944 22 22 23 23 #include "Picker.h" 24 #include "Placard.h" 24 25 #include "Renderer.h" 25 26 #include "RendererCmd.h" … … 188 189 osgEarth::Features::FeatureIndex *index = osgEarth::Registry::objectIndex()->get<osgEarth::Features::FeatureIndex>(id); 189 190 osgEarth::Features::Feature *feature = index ? index->getFeature(id) : 0L; 190 INFO("Select hit oid: %lu ", id);191 INFO("Select hit oid: %lu at %g,%g", id, _pickPoint.x(), _pickPoint.y()); 191 192 if (feature) { 192 INFO("Hit feature ID: %lu (of %d)", feature->getFID(), index->size()); 193 const osgEarth::Features::AttributeTable &attrs = feature->getAttrs(); 194 std::ostringstream oss; 195 for (osgEarth::Features::AttributeTable::const_iterator itr = attrs.begin(); itr != attrs.end(); ++itr) { 196 INFO(" attr: %s", itr->first.c_str()); 197 oss << itr->first.c_str() << ": "; 198 switch (itr->second.first) { 199 case osgEarth::Features::ATTRTYPE_STRING: 200 INFO(" value: %s", itr->second.getString().c_str()); 201 oss << itr->second.getString() << std::endl; 202 break; 203 case osgEarth::Features::ATTRTYPE_INT: 204 INFO(" value: %d", itr->second.getInt()); 205 oss << itr->second.getInt() << std::endl; 206 break; 207 case osgEarth::Features::ATTRTYPE_DOUBLE: 208 INFO(" value: %g", itr->second.getDouble()); 209 oss << itr->second.getDouble() << std::endl; 210 break; 211 case osgEarth::Features::ATTRTYPE_BOOL: 212 INFO(" value: %s", itr->second.getBool() ? "true" : "false"); 213 oss << (itr->second.getBool() ? "true" : "false") << std::endl; 214 break; 215 default: 216 INFO(" value: unknown type"); 193 osgEarth::Features::FeatureSourceIndex *fsi = dynamic_cast<osgEarth::Features::FeatureSourceIndex *>(index); 194 std::string layerName; 195 if (fsi) { 196 osgEarth::Features::FeatureSource *source = fsi->getFeatureSource(); 197 if (source) { 198 layerName = source->getFeatureSourceOptions().name().get(); 217 199 } 218 200 } 219 INFO(" Point: %g %g", _pickPoint.x(), _pickPoint.y());220 //INFO("Label: %s", oss.str().c_str()); 201 INFO("Hit feature ID: %lu (of %d) layer: %s", feature->getFID(), index->size(), layerName.c_str()); 202 221 203 osgEarth::Symbology::Style style; 222 204 osgEarth::Symbology::TextSymbol *ts = style.getOrCreateSymbol<osgEarth::Symbology::TextSymbol>(); … … 229 211 //ts->encoding() = osgEarth::Symbology::TextSymbol::ENCODING_UTF8; 230 212 clearSelection(); 231 osgEarth::Annotation::LabelNode *label = 232 new osgEarth::Annotation::LabelNode(_renderer->getMapNode(), _pickPoint, oss.str(), style); 213 214 const osgEarth::Features::AttributeTable &attrs = feature->getAttrs(); 215 Placard placard = _renderer->getPlacardConfig(layerName); 216 if (placard.getNumEntries() == 0) { 217 placard.addAllAttributes(attrs); 218 } 219 PlacardNode *label = 220 new PlacardNode(_renderer->getMapNode(), _pickPoint, placard, attrs, style); 233 221 label->getOrCreateStateSet()->setRenderBinDetails(INT_MAX, "RenderBin"); 234 222 _renderer->getAnnotations()->addChild(label); 223 235 224 char mesg[256]; 236 std::string layerName;237 osgEarth::Features::FeatureSourceIndex *fsi = dynamic_cast<osgEarth::Features::FeatureSourceIndex *>(index);238 if (fsi) {239 osgEarth::Features::FeatureSource *source = fsi->getFeatureSource();240 if (source) {241 layerName = source->getFeatureSourceOptions().name().get();242 }243 }244 225 snprintf(mesg, sizeof(mesg), "nv>select feature %u %lu %d {%s}\n", id, feature->getFID(), index->size(), layerName.c_str()); 245 226 size_t length = strlen(mesg);
Note: See TracChangeset
for help on using the changeset viewer.