VR-Forces 4.1.1 Class Documentation
DtOsgChannel.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2012 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
13 
14 #include <vrvCore/DtChannel.h>
15 #include <vrvOsg/DtOsgRenderer.h>
16 #include <vrvOsg/DtCameraNode.h>
17 
18 #include <osg/ref_ptr>
19 #include <osgViewer/View>
20 
21 #include <boost/signals.hpp>
22 
23 namespace osg
24 {
25  class Matrixd;
26 }
27 
28 namespace makVrv
29 {
30  class DtChannelSpecificGroup;
31  class DtOsgWindow;
32  class DtOsgChannelCreator;
33  class DtChannelManager;
34  class DtWindowConfiguration;
35  class DtSensorModule;
36  class DtSensor;
37 
45  {
46  protected:
47  friend class DtOsgChannelCreator;
48 
52  DtOsgChannel(DtDe& de, DtOsgWindow* window, DtChannelConfiguration& config);
53 
55 
56 
61  virtual bool initialize();
62 
64 
65  virtual void initializeNormalized2DCamera();
66  virtual void initialize2DCamera( int w, int h );
67  virtual void initializeSceneCamera( );
68 
69  void initializeViewCamera();
70 
72 
74  virtual void addOverlayDrawablesToCameras();
75 
77  virtual void initializeStatsHandler();
78 
84  virtual void initializeSignalConnections();
86 
87  public:
89  virtual ~DtOsgChannel();
90 
95  void setSensorName( const std::string& sensorName );
96 
98  virtual void setClearColor(float r,float g,float b, float a);
99 
103  virtual void setWindow(DtWindow* view);
104 
106  virtual const DtWindow* window() const;
107 
109  virtual void setViewport(int x,int y,int width, int height);
110 
112  virtual void getViewport(int& x,int& y, int& width,int& height) const;
113 
115  virtual void setCameraPosition(double x, double y, double z);
116 
118  virtual void setCameraOrientation( double psi, double theta, double phi );
119 
124  virtual void setCameraPositionAndOrientation( double x, double y,
125  double z, double psi, double theta, double phi );
126  virtual void setCameraPositionAndOrientation( osg::Vec3d& pos,
127  osg::Quat& orient );
128 
130  virtual void getCameraPositionAndOrientation( osg::Vec3d& position,
131  osg::Quat& rotation ) const;
132 
133  virtual void update();
134 
136  virtual void connectToObserver();
137 
139  virtual void setDynamicNearFar(bool enable);
140 
143  virtual void setNearFarRatio(double ratio);
144 
147  virtual void setProjectionMatrixAsPerspective(double fovy,
148  double aspectRatio, double zNear, double zFar);
149 
151  virtual void setProjectionMatrixAsFrustum (double left, double right,
152  double bottom, double top, double zNear, double zFar);
153 
155  virtual osgViewer::View& view();
156 
158  virtual DtCameraNode* sceneCamera();
159  virtual const DtCameraNode* sceneCamera() const;
160 
162  virtual DtCameraNode* postProcessingCamera();
164  virtual const DtCameraNode* postProcessingCamera() const;
165 
167  virtual DtCameraNode* overlayCamera();
168 
170  virtual void setPostProcessingEnabled(bool enabled);
171 
173  virtual void setPostProcessCamera(DtCameraNode* camera);
174 
178  virtual void setPostProcessTexture(osg::Texture* texture);
179 
182  virtual void setProjectionResizePolicy(
184 
187  virtual void updateProjection();
188 
189  void projectionUnitsToFrustum( DtChannelConfiguration::ProjectionUnits units,
190  double &left, double zNear, double &right, double &top, double &bottom );
191 
193  virtual void connectChannelToScene();
194 
196  virtual bool processMouseEvent( const DtMouseEvent& ev);
197 
199  virtual bool processKeyboardEvent(const DtKeyEvent & ev);
200 
202  //virtual DtDynamicOverlay* overlay();
203 
205  void getWorldToWindowMatrix( osg::Matrix& worldToWindowMatrix ) const;
206 
208  virtual void moveMouseToScreenLocation(float screenX, float screenY);
209 
213  virtual void projectToScreen( double dbX, double dbY, double dbZ,
214  double& screenX, double& screenY, double& screenZ );
215 
217  virtual void projectToWorld( double screenX, double screenY,
218  double& dbX, double& dbY, double& dbZ );
219 
221  virtual const std::string& name();
222 
223  /*osg::Texture* sceneTexture();
224 
225  DtCameraNode* viewCamera();*/
226 
231  boost::signal<void (int, int, int, int)> signal_viewportChanged;
232 
233  protected:
234  void makeObserverToCameraMatrix( osg::Vec3d& orient,
235  osg::Matrixd& offsetObserverToCamera );
236  void makeObserverToCameraMatrix( osg::Quat& qObserverToWorld,
237  osg::Matrixd& offsetObserverToCamera );
238 
240  virtual void calculateNearFar(double& zNear, double& zFar);
241 
243  virtual void projectFor3D();
244 
246  virtual void projectFor2D();
247 
251  virtual void stopUsingModelSet( int modelSet );
252 
256  virtual void startUsingModelSet( int modelSet );
257 
259  virtual void stopUsingSensor( DtSensor* sensor );
260 
262  virtual void startUsingSensor( DtSensor* sensor );
263 
265  virtual void slot_sensorRemoved( DtSensor* sensor );
266 
268  virtual void slot_visualizerRootAdded( int modelSet, int visualType );
269 
271  virtual void slot_observerModelSetChanged( DtObserverObject* observer,
272  int modelSet );
273 
275  virtual void slot_observerSettingChanged( DtObserverObject* observer,
276  int setting, bool value );
277 
279  virtual void slot_observerSettingRemoved( DtObserverObject* observer,
280  int setting );
281 
283  virtual void slot_channelAdded(DtChannelManager* mgr, DtChannel* channel);
284 
286  virtual void slot_channelDestroyed(DtChannelManager* mgr, DtChannel* channel);
287 
289  virtual void slot_windowConfigurationModified( const std::string& deName,
290  const std::string& oldWindowName, const DtWindowConfiguration& config);
291 
293  virtual void slot_onCoordinateSystemChanged();
294 
298  virtual void throttleDatabasePager(DtChannelManager* mgr, DtChannel* channel);
299 
300  protected:
302  void stopUsingModelSetWork( int modelSet );
303 
305  void startUsingModelSetWork( int modelSet );
306 
307  protected:
308  typedef std::map< int, DtChannelSpecificGroup*> VisualTypeMap;
309 
310  osg::ref_ptr<osgViewer::View> myView;
312 
314 
315  osg::ref_ptr<osg::Group> myRoot;
316 
317  osg::ref_ptr<DtCameraNode> myPostProcessCamera;
318  osg::ref_ptr<osg::Texture> myPostProcessBuffer;
319 
320  //The 2D camera in screen space(0,0 - w,h)
321  osg::ref_ptr<DtCameraNode> my2DCamera;
322 
323  //The 2D camera in normalize screen space (0,0 - 1,1)
324  osg::ref_ptr<DtCameraNode> myNormalized2DCamera;
325 
327  osg::ref_ptr<DtCameraNode> mySceneCamera;
328 
330  osg::ref_ptr<DtCameraNode> myViewCamera;
331 
333  osg::ref_ptr<osg::Texture2D> mySceneTexture;
334 
337  };
338 
342  {
343  public:
345  virtual DtChannel* create(DtDe& de, DtWindow* window, DtChannelConfiguration& config);
346  };
347 }

Document ID: Generated on Mon Apr 8 19:24:01 EDT 2013 from SVN revision 125877
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)