VR-Forces 4.8 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtOsgAdapterQtWidget.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2016 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
6 
10 
11 #pragma once
12 
13 #include <vrvOsgQt/vrvOsgQt.h>
14 
16 
17 //We use winsock2, but QGLWidget includes windows.h so we have to get ws2 in first
18 #ifdef _WIN32
19 #include <WinSock2.h>
20 #endif
21 
22 #include <QtOpenGL/QGLWidget>
23 #include <osgViewer/Viewer>
24 #include <QtCore/QTimer>
25 
26 #include <boost/signal.hpp>
27 
28 class QTouchEvent;
29 
30 namespace osg
31 {
32  class GraphicsContext;
33 }
34 
35 namespace makVrv
36 {
37  class DtWindow;
38 
39  class DtChannel;
40  class DtOsgAdapterQtWidgetLogic;
41 
42 
47  {
48  Q_OBJECT;
49  public:
50 
52  DtOsgAdapterQtWidget( DtDe& de, osg::GraphicsContext::Traits* contextTraits,
53  const QGLFormat& format,
54  QWidget * parent = 0,
55  Qt::WindowFlags f = 0 );
56 
58  virtual ~DtOsgAdapterQtWidget();
59 
61  osgViewer::GraphicsWindow* graphicsWindow();
62 
64  void setView(DtWindow* window);
65  DtWindow* view() const;
66 
71  int widgetToNativeCoordinate(int widgetValue);
72 
77  int nativeToWidgetCoordinate(int nativeValue);
78 
80  virtual osgGA::GUIEventAdapter::KeySymbol osgKeyFromQtKeyEvent( QKeyEvent* event );
81 
84  virtual void processKeyPressEvent( QKeyEvent* keyEvent );
85 
88  virtual void processKeyReleaseEvent( QKeyEvent* keyEvent );
89 
90 
96  virtual bool processTouchEvent( QTouchEvent* touchEvent );
97 
98  virtual void mouseMoveEvent( QMouseEvent* event );
99 
100  virtual void focusInEvent( QFocusEvent * event );
101  virtual void focusOutEvent( QFocusEvent * event );
102  virtual bool event( QEvent* event );
103 
105  static QGLFormat createFormatFromTraits(
106  const osg::GraphicsContext::Traits* contextTraits);
107 
108  virtual QSize sizeHint() const;
109 
111  virtual void slot_onRightClickTerrainMenuRequest( double mouseX,
112  double mouseY, DtChannel* channel );
113 
115  virtual void slot_onRightClickSelectionMenuRequest( double mouseX,
116  double mouseY, DtChannel* channel );
117 
118  boost::signal<void (DtOsgAdapterQtWidget*)> signal_mouseEnter;
119  boost::signal<void (DtOsgAdapterQtWidget*)> signal_mouseExit;
120 
121  signals:
123  void devicePixelRatioChanged();
124 
125  protected:
126  void init();
127 
130  virtual bool channelInThisWidget( const DtChannel& channel );
131 
132  // height, width are going to be in 4K coordinates for example, and not
133  // scaled Qt coordinates
134  virtual void resizeGL(int width, int height);
135 
136  virtual void keyPressEvent(QKeyEvent *);
137  virtual void keyReleaseEvent(QKeyEvent *);
138  virtual void mousePressEvent( QMouseEvent* event );
139  virtual void mouseReleaseEvent( QMouseEvent* event );
140  virtual void enterEvent( QEvent* event );
141  virtual void leaveEvent( QEvent* event );
142 
143  int qtButtonToOsgButton( QMouseEvent* event);
144  virtual void mouseDoubleClickEvent(QMouseEvent* event);
145  virtual void wheelEvent(QWheelEvent *);
146  virtual void closeEvent(QCloseEvent*);
147  virtual void slot_ctrlEnterPressed( const DtChannel& channel );
148 
153  virtual void getTouchPointPositions( const QTouchEvent& touchEvent,
154  osg::Vec2& p0, osg::Vec2& p1 );
155  //virtual void getTouchPointPosition( const QTouchEvent& touchEvent, int index,
156  // osg::Vec2& p );
157 
160  virtual void startOsgTouch( const osg::Vec2& p0, const osg::Vec2& p1 );
161 
164  virtual void continueOsgTouch( const osg::Vec2& p0, const osg::Vec2& p1 );
165 
168  virtual void endOsgTouch( const osg::Vec2& p0 );
169 
170  protected slots:
172  void emit_signal_pixelRatioChanged();
173 
174  protected:
175 
177 
181 
182  // These are here to work around a bug in Qt 4.5 (and other versions??) where
183  // a doubleclick mouse event is followed by a stray release event.
187 
188  // This is used to suppress the stray left-mouse events that windows insists
189  // on generating when using multi-touch effects
191 
192  // int because we get ints from Qt (unless we are using qml for everything)
194  };
195 
200  {
201 
202  public:
204  static DtOsgAdapterQtWidgetCreator& instance(DtDe& de);
205 
207  static void registerInstance(DtDe& de, DtOsgAdapterQtWidgetCreator* creator);
208 
210  virtual DtOsgAdapterQtWidget* create( DtDe& de,
211  osg::GraphicsContext::Traits* contextTraits, const QGLFormat& format,
212  QWidget * parent = 0, Qt::WindowFlags f = 0);
213  };
214 
215 }
216 
Abstract Base class.
Definition: DtWindow.h:25
DtOsgAdapterQtWidgetCreator provides the mechanism for creating an extended DtOsgAdapterQtWidget.
Definition: DtOsgAdapterQtWidget.h:199
Virtual base class.
Definition: DtVirtualBaseClass.h:22
DtOsgAdapterQtWidget provides the mechanism for embedding an OSG context into a Qt widget...
Definition: DtOsgAdapterQtWidget.h:46
boost::signal< void(DtOsgAdapterQtWidget *)> signal_mouseExit
Definition: DtOsgAdapterQtWidget.h:119
bool myRightPressed
Definition: DtOsgAdapterQtWidget.h:186
DtDe & myDe
Definition: DtOsgAdapterQtWidget.h:178
boost::signal< void(DtOsgAdapterQtWidget *)> signal_mouseEnter
Definition: DtOsgAdapterQtWidget.h:118
osg::ref_ptr< osgViewer::GraphicsWindowEmbedded > myEmbeddedWindow
Definition: DtOsgAdapterQtWidget.h:176
#define DT_DLL_VRVOSGQT
Definition: vrvOsgQt.h:22
int myOldDevicePixelRatio
Definition: DtOsgAdapterQtWidget.h:193
DtOsgAdapterQtWidgetLogic * myLogic
Definition: DtOsgAdapterQtWidget.h:180
Contains DLL export macros.
The abstract Channel Class.
Definition: DtChannel.h:29
Contains makVrv::DtVirtualBaseClass class.
bool myIsPinching
Definition: DtOsgAdapterQtWidget.h:190
brief The Qt main window.
Definition: DtOsgAdapterQtWidgetLogic.h:32
DtWindow * myWindow
Definition: DtOsgAdapterQtWidget.h:179
DT_DLL_DEBUGDRAWRENDERER void init(makVrv::DtDe &de)
Work function for the plugin initialization.
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
bool myMiddlePressed
Definition: DtOsgAdapterQtWidget.h:185
bool myLeftPressed
Definition: DtOsgAdapterQtWidget.h:184

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)