VR-Forces 4.3 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 
20 #include <set>
21 #include <vector>
22 
23 // Forward declarations
24 namespace osg {
25  class Node;
26 }
27 namespace osgEarth {
28  class MapNode;
29  class ModelLayer;
30 }
31 
32 namespace makVrv
33 {
43  class DT_DLL_VRVOSG DtOsgEarthFeatureDataBroker : public osg::Referenced
44  {
45  public:
46  // Callback to invoke when new data merges into the scene graph.
47  struct DT_DLL_VRVOSG Callback : public osg::Referenced
48  {
49  virtual void onLayerLoaded(osgEarth::MapNode* mapNode,
50  osgEarth::ModelLayer* layer) =0;
51 
52  virtual void onDataLoaded(osgEarth::Map* map,
53  osgEarth::ModelLayer* layer,
54  osg::Node* newData) =0;
55  };
56 
57  public:
58  // Constructs a broker for the specified map node.
59  DtOsgEarthFeatureDataBroker(osgEarth::MapNode* mapNode, DtDe& de);
60 
61  // Install a callback.
62  void addCallback(Callback* cb);
63 
64  // Whether to run state sharing optimization after invoking
65  // all the callbacks. Default = true.
66  void setOptimizeStateSharing(bool value);
67  bool getOptimizeStateSharing() const;
68 
69  public: // internal functions
70 
71  // Adds a model layer to the broker. You normally do not need to
72  // call this directly; the object will discover model layers in the
73  // Map model automatically.
74  void addModelLayer(osgEarth::ModelLayer* layer);
75 
76  // Internal function that's called after a new map layer is
77  // loaded in the MapNode.
78  void notifyNewLayer(osgEarth::ModelLayer* layer);
79 
80  // Internal function that's called after new data for the model
81  // layer merges into the scene graph. This is called internally;
82  // there is no need to call it yourself.
83  void notifyNewData(osgEarth::ModelLayer* layer, osg::Node* data);
84 
85  protected:
86  virtual ~DtOsgEarthFeatureDataBroker();
87 
88  protected:
89  std::vector<osg::ref_ptr<Callback> > myCallbacks;
90  osg::observer_ptr<osgEarth::MapNode> myMapNode;
91  osg::ref_ptr<osgEarth::MapCallback> myMapCallback;
92  std::set<osg::ref_ptr<osgEarth::NodeOperation> > myOperations;
95  };
96 }
97 

Document ID: Generated on Wed Mar 11 21:20:57 EDT 2015 from SVN revision 150940
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)