VR-Forces 4.3.1 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  static std::string getFeatureNameFromModelLayer(
98  const osgEarth::ModelLayer& layer );
99 
100  protected:
102 
103  protected:
104 
105  typedef osg::ref_ptr<osgEarth::NodeOperation> NodeOperationRefPtr;
106  osg::observer_ptr<osgEarth::MapNode> myMapNode;
107  osg::ref_ptr<osgEarth::MapCallback> myMapCallback;
108  std::set<NodeOperationRefPtr> myOperations;
111 
112  typedef osg::ref_ptr<Callback> CallbackRefPtr;
113  typedef boost::unordered_multimap<std::string, CallbackRefPtr>
115  typedef std::pair<FeatureDataCallbackMap::iterator,
116  FeatureDataCallbackMap::iterator> RangeIterFeatureDataCallbacks;
117  typedef std::pair<FeatureDataCallbackMap::const_iterator,
118  FeatureDataCallbackMap::const_iterator>
120 
122 
123  typedef boost::unordered_map<std::string, std::vector<std::string> >
125 
126  typedef boost::unordered_map<std::string,
127  std::vector<std::string> >::iterator RegistrantToFeaturesMapIter;
128 
130 
131 
132  };
133 }
134 

Document ID: Generated on Wed Jul 29 00:55:00 EDT 2015 from SVN revision 155257
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)