VR-Forces 4.10 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) 2020 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 <vrvUtil/signalslib.h>
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 DtWindowConfiguration;
41  class DtOsgAdapterQtWidgetLogic;
42 
43 
48  {
49  Q_OBJECT;
50  public:
51 
53  DtOsgAdapterQtWidget( DtDe& de, osg::GraphicsContext::Traits* contextTraits,
54  const QGLFormat& format,
55  QWidget * parent = 0,
56  Qt::WindowFlags f = 0 );
57 
59  virtual ~DtOsgAdapterQtWidget();
60 
62  osgViewer::GraphicsWindow* graphicsWindow();
63 
65  void setView(DtWindow* window);
66  DtWindow* view() const;
67 
72  int widgetToNativeCoordinate(int widgetValue);
73 
78  int nativeToWidgetCoordinate(int nativeValue);
79 
81  virtual osgGA::GUIEventAdapter::KeySymbol osgKeyFromQtKeyEvent( QKeyEvent* event );
82 
85  virtual void processKeyPressEvent( QKeyEvent* keyEvent );
86 
89  virtual void processKeyReleaseEvent( QKeyEvent* keyEvent );
90 
91 
97  virtual bool processTouchEvent( QTouchEvent* touchEvent );
98 
99  virtual void mouseMoveEvent( QMouseEvent* event );
100 
101  virtual void focusInEvent( QFocusEvent * event );
102  virtual void focusOutEvent( QFocusEvent * event );
103  virtual bool event( QEvent* event );
104 
106  static QGLFormat createFormatFromTraits(
107  const osg::GraphicsContext::Traits* contextTraits);
108 
109  virtual QSize sizeHint() const;
110 
112  virtual void slot_onRightClickTerrainMenuRequest( double mouseX,
113  double mouseY, DtChannel* channel );
114 
116  virtual void slot_onRightClickSelectionMenuRequest( double mouseX,
117  double mouseY, DtChannel* channel );
118 
120  virtual void slot_onWindowConfigurationModified( const DtWindowConfiguration& newWindowConfig );
121 
122  boost::signalslib::signal<void (DtOsgAdapterQtWidget*)> signal_mouseEnter;
123  boost::signalslib::signal<void (DtOsgAdapterQtWidget*)> signal_mouseExit;
124 
125  signals:
127  void devicePixelRatioChanged();
128 
129  protected:
130  void init();
131 
134  virtual bool channelInThisWidget( const DtChannel& channel );
135 
136  // height, width are going to be in 4K coordinates for example, and not
137  // scaled Qt coordinates
138  virtual void resizeGL(int width, int height);
139 
140  virtual void keyPressEvent(QKeyEvent *);
141  virtual void keyReleaseEvent(QKeyEvent *);
142  virtual void mousePressEvent( QMouseEvent* event );
143  virtual void mouseReleaseEvent( QMouseEvent* event );
144  virtual void enterEvent( QEvent* event );
145  virtual void leaveEvent( QEvent* event );
146 
147  int qtButtonToOsgButton( QMouseEvent* event);
148  virtual void mouseDoubleClickEvent(QMouseEvent* event);
149  virtual void wheelEvent(QWheelEvent *);
150  virtual void closeEvent(QCloseEvent*);
151  virtual void slot_ctrlEnterPressed( const DtChannel& channel );
152 
157  virtual void getTouchPointPositions( const QTouchEvent& touchEvent,
158  osg::Vec2& p0, osg::Vec2& p1 );
159  //virtual void getTouchPointPosition( const QTouchEvent& touchEvent, int index,
160  // osg::Vec2& p );
161 
164  virtual void startOsgTouch( const osg::Vec2& p0, const osg::Vec2& p1 );
165 
168  virtual void continueOsgTouch( const osg::Vec2& p0, const osg::Vec2& p1 );
169 
172  virtual void endOsgTouch( const osg::Vec2& p0 );
173 
174  protected slots:
176  void emit_signal_pixelRatioChanged();
177 
178  protected:
179 
181 
185 
186  // These are here to work around a bug in Qt 4.5 (and other versions??) where
187  // a doubleclick mouse event is followed by a stray release event.
191 
192  // This is used to suppress the stray left-mouse events that windows insists
193  // on generating when using multi-touch effects
195 
196  // int because we get ints from Qt (unless we are using qml for everything)
198  };
199 
204  {
205 
206  public:
208  static DtOsgAdapterQtWidgetCreator& instance(DtDe& de);
209 
211  static void registerInstance(DtDe& de, DtOsgAdapterQtWidgetCreator* creator);
212 
214  virtual DtOsgAdapterQtWidget* create( DtDe& de,
215  osg::GraphicsContext::Traits* contextTraits, const QGLFormat& format,
216  QWidget * parent = 0, Qt::WindowFlags f = 0);
217  };
218 
219 }
220 
DT_DLL_EXAMPLESCENEROOTPLUGIN void init(DtDe &anIG)
Abstract Base class.
Definition: DtWindow.h:25
DtOsgAdapterQtWidgetCreator provides the mechanism for creating an extended DtOsgAdapterQtWidget.
Definition: DtOsgAdapterQtWidget.h:203
Virtual base class.
Definition: DtVirtualBaseClass.h:19
DtOsgAdapterQtWidget provides the mechanism for embedding an OSG context into a Qt widget...
Definition: DtOsgAdapterQtWidget.h:47
bool myRightPressed
Definition: DtOsgAdapterQtWidget.h:190
DtDe & myDe
Definition: DtOsgAdapterQtWidget.h:182
osg::ref_ptr< osgViewer::GraphicsWindowEmbedded > myEmbeddedWindow
Definition: DtOsgAdapterQtWidget.h:180
boost::signalslib::signal< void(DtOsgAdapterQtWidget *)> signal_mouseEnter
Definition: DtOsgAdapterQtWidget.h:122
This owns a list of channel configurations.
Definition: DtWindowConfiguration.h:28
#define DT_DLL_VRVOSGQT
Definition: vrvOsgQt.h:22
int myOldDevicePixelRatio
Definition: DtOsgAdapterQtWidget.h:197
DtOsgAdapterQtWidgetLogic * myLogic
Definition: DtOsgAdapterQtWidget.h:184
Contains DLL export macros.
The abstract Channel Class.
Definition: DtChannel.h:30
Contains makVrv::DtVirtualBaseClass class.
bool myIsPinching
Definition: DtOsgAdapterQtWidget.h:194
brief The Qt main window.
Definition: DtOsgAdapterQtWidgetLogic.h:29
DtWindow * myWindow
Definition: DtOsgAdapterQtWidget.h:183
boost::signalslib::signal< void(DtOsgAdapterQtWidget *)> signal_mouseExit
Definition: DtOsgAdapterQtWidget.h:123
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
bool myMiddlePressed
Definition: DtOsgAdapterQtWidget.h:189
bool myLeftPressed
Definition: DtOsgAdapterQtWidget.h:188

Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)