VR-Forces 4.5 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DtOsgEarthFeatureDataBroker.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2011 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 /******************************************************************************
6 ** $RCSfile: $ $Revision: $ $State: $
7 ******************************************************************************/
8 
12 
13 #pragma once
14 #include <vrvOsg/vrvOsg.h>
15 #include <osg/observer_ptr>
16 #include <osg/ref_ptr>
17 
18 #include <osgEarth/Map>
19 #include <boost/unordered_map.hpp>
20 
21 #include <set>
22 #include <string>
23 
24 // Forward declarations
25 namespace osg {
26  class Node;
27 }
28 namespace osgEarth {
29  class MapNode;
30  class ModelLayer;
31 }
32 
33 namespace makVrv
34 {
44  class DT_DLL_VRVOSG DtOsgEarthFeatureDataBroker : public osg::Referenced
45  {
46  public:
47  // Callback to invoke when new data merges into the scene graph.
48  struct DT_DLL_VRVOSG Callback : public osg::Referenced
49  {
50  virtual void onLayerLoaded(osgEarth::MapNode* mapNode,
51  osgEarth::ModelLayer* layer) =0;
52 
53  virtual void onDataLoaded(osgEarth::Map* map,
54  osgEarth::ModelLayer* layer,
55  osg::Node* newData) =0;
56  };
57 
58  public:
59  // Constructs a broker for the specified map node.
60  DtOsgEarthFeatureDataBroker(osgEarth::MapNode* mapNode, DtDe& de);
61 
62  // Install a callback.
63  void addCallback(const std::string& registrant, Callback* cb);
64 
65  // Whether to run state sharing optimization after invoking
66  // all the callbacks. Default = true.
67  void setOptimizeStateSharing(bool value);
68  bool getOptimizeStateSharing() const;
69 
70  public: // internal functions
71 
72  // Adds a model layer to the broker. You normally do not need to
73  // call this directly; the object will discover model layers in the
74  // Map model automatically.
75  void addModelLayer(osgEarth::ModelLayer* layer);
76 
77  // Internal function that's called after a new map layer is
78  // loaded in the MapNode.
79  void notifyNewLayer(osgEarth::ModelLayer* layer);
80 
81  // Internal function that's called after new data for the model
82  // layer merges into the scene graph. This is called internally;
83  // there is no need to call it yourself.
84  void notifyNewData(osgEarth::ModelLayer* layer, osg::Node* data);
85 
86  protected:
87  virtual ~DtOsgEarthFeatureDataBroker();
88 
93  bool readFeatureNameRegistrationFile( const std::string& path,
94  const std::string& filename );
95 
96  protected:
97  std::string getFeatureNameFromModelLayer( const osgEarth::ModelLayer& layer );
98 
99  protected:
101 
102  protected:
103 
104  typedef osg::ref_ptr<osgEarth::NodeOperation> NodeOperationRefPtr;
105  osg::observer_ptr<osgEarth::MapNode> myMapNode;
106  osg::ref_ptr<osgEarth::MapCallback> myMapCallback;
107  std::set<NodeOperationRefPtr> myOperations;
110 
111  typedef osg::ref_ptr<Callback> CallbackRefPtr;
112  typedef boost::unordered_multimap<std::string, CallbackRefPtr>
114  typedef std::pair<FeatureDataCallbackMap::iterator,
115  FeatureDataCallbackMap::iterator> RangeIterFeatureDataCallbacks;
116  typedef std::pair<FeatureDataCallbackMap::const_iterator,
117  FeatureDataCallbackMap::const_iterator>
119 
121 
122  typedef boost::unordered_map<std::string, std::vector<std::string> >
124 
125  typedef boost::unordered_map<std::string,
126  std::vector<std::string> >::iterator RegistrantToFeaturesMapIter;
127 
129 
130  //added to speed up lookup since building the config structure is slow currently
131  boost::unordered_map<const osgEarth::ModelLayer*, std::string> myFeatureNameLookup;
132  };
133 }
134 

Document ID: Generated on Thu Mar 23 18:54:12 EDT 2017 from SVN revision 174804
Copyright © 2005-2017 VT MÄK. All Rights Reserved (www.mak.com)