OpendTect  6.3
ui3dviewerbody.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*+
4 ________________________________________________________________________
5 
6  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
7  Author: K. Tingdahl
8  Date: Dec 2011
9 ________________________________________________________________________
10 
11 -*/
12 
13 #include "uiobjbody.h"
14 
15 #include "mousecursor.h"
16 #include "refcount.h"
17 #include "visosg.h"
18 #include "uieventfilter.h"
19 
20 class QGestureEvent;
21 
22 namespace visBase
23 {
24  class Axes;
25  class Camera;
26  class PolygonSelection;
27  class Scene;
28  class SceneColTab;
29  class Transformation;
30  class ThumbWheel;
31  class DataObjectGroup;
32 }
33 
34 
35 namespace osgViewer { class CompositeViewer; class View; class GraphicsWindow; }
36 namespace osgGeo { class TrackballManipulator; }
37 
38 class ui3DViewer;
39 class TrackBallManipulatorMessenger;
40 class KeyBindMan;
42 class SwapCallback;
43 
44 namespace osg
45 {
46  class Group;
47  class GraphicsContext;
48  class Camera;
49  class MatrixTransform;
50  class Projection;
51  class Vec3f;
52  class Viewport;
53 }
54 
55 namespace osgViewer { class View; }
56 
58 
59 mClass(uiOSG) ui3DViewerBody : public uiObjectBody
61  friend class TrackBallManipulatorMessenger;
62 
63 public:
65  virtual ~ui3DViewerBody();
66 
67  void viewAll(bool animate);
68 
69  void setSceneID(int);
70  visBase::Scene* getScene() { return scene_; }
71  const visBase::Scene* getScene() const { return scene_; }
72 
73  bool serializeScene(const char*) const;
74 
75  void setBackgroundColor(const Color&);
76  Color getBackgroundColor() const;
77  Geom::Size2D<int> getViewportSizePixels() const;
78 
79  float getMouseWheelZoomFactor() const;
82  void setMouseWheelZoomFactor(float);
83 
84  void setReversedMouseWheelDirection(bool);
85  bool getReversedMouseWheelDirection() const;
86 
87  void setHomePos(const IOPar&);
88  void resetToHomePosition();
89 
90  void toggleCameraType();
91  bool isCameraPerspective() const;
92  bool isCameraOrthographic() const;
93 
94  void align();
95  void viewPlaneX();
96  void viewPlaneY();
97  void viewPlaneZ();
98  void viewPlaneInl();
99  void viewPlaneCrl();
100  void viewPlaneN();
101  void viewPlaneYZ();
102 
103  void uiRotate(float angle,bool horizontal);
104  void uiZoom(float rel,const osg::Vec3f* dir=0);
105  void setCameraZoom(float val);
106  float getCameraZoom() const;
107 
108  //Not sure were to put these
109  bool isViewMode() const;
110  virtual void setViewMode(bool viewmode,bool trigger);
111 
112  Coord3 getCameraPosition() const;
113  visBase::Camera* getVisCamera() { return camera_; }
114 
115  virtual void reSizeEvent(CallBacker*);
116  void toggleViewMode(CallBacker*);
117 
118  enum WheelMode { Never, Always, OnHover };
119  void setWheelDisplayMode(WheelMode);
120  WheelMode getWheelDisplayMode() const;
121 
122  void setAnimationEnabled(bool);
123  bool isAnimationEnabled() const;
124  void showRotAxis(bool);
125  bool isAxisShown() const;
126  void setAnnotColor(const Color&);
127  void setAnnotationFont(const FontData&);
128  visBase::PolygonSelection* getPolygonSelector();
129  visBase::SceneColTab* getSceneColTab();
130 
131  void toHomePos();
132  void saveHomePos();
133  bool isHomePosEmpty() { return homepos_.isEmpty(); }
134  void fillCameraPos(IOPar&) const;
135  bool useCameraPos(const IOPar&);
136  const osgViewer::View* getOsgViewerMainView() const { return view_; }
137  const osgViewer::View* getOsgViewerHudView() const { return hudview_; }
138  void setScenesPixelDensity(float dpi);
139 
140  enum StereoType { None, RedCyan, QuadBuffer };
141 
142  bool setStereoType(StereoType);
143  StereoType getStereoType() const;
144  void setStereoOffset(float);
145  float getStereoOffset() const;
146 
147  void updateZDomainInfo();
148 
149  void setMapView(bool yn);
150  bool isMapView() const { return mapview_; }
151 
152  KeyBindMan& keyBindMan() { return keybindman_; }
153 
154  void removeSwapCallback(CallBacker*);
155 
156 protected:
157  void enableDragging( bool yn );
158 
159  enum ViewModeCursor { RotateCursor, PanCursor, ZoomCursor,
160  HoverCursor };
161  virtual void setViewModeCursor( ViewModeCursor );
162 
163  virtual void updateActModeCursor();
164  void mouseCursorChg(CallBacker*);
166 
167  void notifyManipulatorMovement(
168  float dh,float dv,float df);
169  void setupTouch();
170  void setupHUD();
171  void setupView();
172  void qtEventCB(CallBacker*);
173  void setFocusCB(CallBacker*);
174  void handleGestureEvent(QGestureEvent*);
175  static osgViewer::CompositeViewer* getCompositeViewer();
176 
177  void glInfoCB(CallBacker*);
178 
179  virtual osgViewer::GraphicsWindow& getGraphicsWindow() = 0;
180  virtual osg::GraphicsContext* getGraphicsContext() = 0;
181 
183 
184  void requestRedraw();
185 
186  osg::Camera* getOsgCamera();
187  const osg::Camera* getOsgCamera() const;
188  void setCameraPos(const osg::Vec3f&,
189  const osg::Vec3f&,bool);
190 
191  void thumbWheelRotationCB(CallBacker*);
192  void enableThumbWheelHandling(bool yn,
193  const visBase::ThumbWheel* tw=0);
194 
197 
204 
206  osgViewer::CompositeViewer* compositeviewer_;
207  osgViewer::View* view_;
208  osg::Viewport* viewport_;
211 
212  osgViewer::View* hudview_;
215 
220  TrackBallManipulatorMessenger* manipmessenger_;
221 
223 
226 
228 
229  bool mapview_;
230  static bool isbadglwarned_;
231 };
Inherit from this class to be able to send and/or receive CallBacks.
Definition: callback.h:182
bool isHomePosEmpty()
Definition: ui3dviewerbody.h:133
keep osg camera status and render info
Definition: viscamera.h:27
osg::Switch * offscreenrenderswitch_
Definition: ui3dviewerbody.h:205
Definition of a mouse cursor, can be either a predefined shape (from the enum, or a file...
Definition: mousecursor.h:24
ui3DViewer & handle_
Definition: ui3dviewerbody.h:195
RefMan< visBase::DataObjectGroup > hudscene_
Definition: ui3dviewerbody.h:214
virtual uiObject & uiObjHandle()
Definition: i_uiobjqtbody.h:51
RefMan< visBase::Scene > scene_
Definition: ui3dviewerbody.h:199
bool isMapView() const
Definition: ui3dviewerbody.h:150
IOPar & printpar_
Definition: ui3dviewerbody.h:196
osgViewer::View * hudview_
Definition: ui3dviewerbody.h:212
uiEventFilter eventfilter_
Definition: ui3dviewerbody.h:216
uiMouseEventBlockerByGestures & mouseeventblocker_
Definition: ui3dviewerbody.h:217
#define mODTextTranslationClass(clss)
Definition: uistring.h:37
Definition: visdata.h:22
const osgViewer::View * getOsgViewerHudView() const
Definition: ui3dviewerbody.h:137
A collection of geoscientific extensions to OpenSceneGraph.
Definition: visannot.h:35
Baseclass for different body implementation (direct & indirect) of OSG.
Definition: ui3dviewerbody.h:59
bool mapview_
Definition: ui3dviewerbody.h:229
The base class for most UI elements.
Definition: uiobj.h:35
Class for a swap callback. This class triggers on the second render that the context is up an running...
Definition: swapbuffercallback.h:25
Definition: uiparent.h:24
Definition: visthumbwheel.h:26
Data needed to make an actual font.
Definition: fontdata.h:18
osgViewer::CompositeViewer * compositeviewer_
Definition: ui3dviewerbody.h:206
RefMan< visBase::PolygonSelection > polygonselection_
Definition: ui3dviewerbody.h:219
FixedString None()
Definition: keystrs.h:90
const osgViewer::View * getOsgViewerMainView() const
Definition: ui3dviewerbody.h:136
is a class that is able to recieve events from Qt and trigger an OD-style notification/callback.
Definition: uieventfilter.h:26
RefMan< visBase::ThumbWheel > horthumbwheel_
Definition: ui3dviewerbody.h:200
WheelMode
Definition: ui3dviewerbody.h:118
3D point or vector
Definition: commontypes.h:57
RefMan< visBase::SceneColTab > visscenecoltab_
Definition: ui3dviewerbody.h:225
RefMan< visBase::Axes > axes_
Definition: ui3dviewerbody.h:218
Definition: vispolygonselection.h:37
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:53
ViewModeCursor
Definition: ui3dviewerbody.h:159
IOPar homepos_
Definition: ui3dviewerbody.h:224
Definition: ui3dviewerbody.h:159
StereoType
Definition: ui3dviewerbody.h:140
Definition: ui3dviewer.h:27
RefMan< visBase::ThumbWheel > verthumbwheel_
Definition: ui3dviewerbody.h:201
RefMan< visBase::ThumbWheel > distancethumbwheel_
Definition: ui3dviewerbody.h:202
static bool isbadglwarned_
Definition: ui3dviewerbody.h:230
SwapCallback * swapcallback_
Definition: ui3dviewerbody.h:222
KeyBindMan & keyBindMan()
Definition: ui3dviewerbody.h:152
RefMan< visBase::Camera > camera_
Definition: ui3dviewerbody.h:198
visBase::Camera * getVisCamera()
Definition: ui3dviewerbody.h:113
const visBase::Scene * getScene() const
Definition: ui3dviewerbody.h:71
int wheeldisplaymode_
Definition: ui3dviewerbody.h:203
visBase::Scene * getScene()
Definition: ui3dviewerbody.h:70
KeyBindMan & keybindman_
Definition: ui3dviewerbody.h:227
float stereooffset_
Definition: ui3dviewerbody.h:210
Definition: visannot.h:40
Definition: visscenecoltab.h:25
Scene manages all DataObjects and has some managing functions such as the selection management and va...
Definition: visscene.h:38
TrackBallManipulatorMessenger * manipmessenger_
Definition: ui3dviewerbody.h:220
Open Scene Graph.
Definition: visannot.h:26
Color is an RGB color object, with a transparancy. The storage is in a 4-byte integer, similar to Qt.
Definition: color.h:24
Definition: uimouseeventblockerbygesture.h:25
Manages keybindings.
Definition: keybindings.h:73
osg::Switch * offscreenrenderhudswitch_
Definition: ui3dviewerbody.h:213
osgViewer::View * view_
Definition: ui3dviewerbody.h:207
#define mClass(module)
Definition: commondefs.h:161
MouseCursor actmodecursor_
Definition: ui3dviewerbody.h:165
osg::Viewport * viewport_
Definition: ui3dviewerbody.h:208
StereoType stereotype_
Definition: ui3dviewerbody.h:209

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2017