VR-Forces 4.7 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 
68  virtual osgGA::GUIEventAdapter::KeySymbol osgKeyFromQtKeyEvent( QKeyEvent* event );
69 
72  virtual void processKeyPressEvent( QKeyEvent* keyEvent );
73 
76  virtual void processKeyReleaseEvent( QKeyEvent* keyEvent );
77 
78 
84  virtual bool processTouchEvent( QTouchEvent* touchEvent );
85 
86  virtual void mouseMoveEvent( QMouseEvent* event );
87 
88  virtual void focusInEvent( QFocusEvent * event );
89  virtual void focusOutEvent( QFocusEvent * event );
90  virtual bool event( QEvent* event );
91 
93  static QGLFormat createFormatFromTraits(
94  const osg::GraphicsContext::Traits* contextTraits);
95 
96  virtual QSize sizeHint() const;
97 
99  virtual void slot_onRightClickTerrainMenuRequest( double mouseX,
100  double mouseY, DtChannel* channel );
101 
103  virtual void slot_onRightClickSelectionMenuRequest( double mouseX,
104  double mouseY, DtChannel* channel );
105 
106  boost::signal<void (DtOsgAdapterQtWidget*)> signal_mouseEnter;
107  boost::signal<void (DtOsgAdapterQtWidget*)> signal_mouseExit;
108 
109  protected:
110  void init();
111 
114  virtual bool channelInThisWidget( const DtChannel& channel );
115 
116  virtual void resizeEvent( QResizeEvent* event);
117  virtual void keyPressEvent(QKeyEvent *);
118  virtual void keyReleaseEvent(QKeyEvent *);
119  virtual void mousePressEvent( QMouseEvent* event );
120  virtual void mouseReleaseEvent( QMouseEvent* event );
121  virtual void enterEvent( QEvent* event );
122  virtual void leaveEvent( QEvent* event );
123 
124  int qtButtonToOsgButton( QMouseEvent* event);
125  virtual void mouseDoubleClickEvent(QMouseEvent* event);
126  virtual void wheelEvent(QWheelEvent *);
127  virtual void closeEvent(QCloseEvent*);
128  virtual void slot_ctrlEnterPressed( const DtChannel& channel );
129 
134  virtual void getTouchPointPositions( const QTouchEvent& touchEvent,
135  osg::Vec2& p0, osg::Vec2& p1 );
136  //virtual void getTouchPointPosition( const QTouchEvent& touchEvent, int index,
137  // osg::Vec2& p );
138 
141  virtual void startOsgTouch( const osg::Vec2& p0, const osg::Vec2& p1 );
142 
145  virtual void continueOsgTouch( const osg::Vec2& p0, const osg::Vec2& p1 );
146 
149  virtual void endOsgTouch( const osg::Vec2& p0 );
150 
151  protected:
152 
153  osg::ref_ptr<osgViewer::GraphicsWindowEmbedded> myEmbeddedWindow;
154 
158 
159  // These are here to work around a bug in Qt 4.5 (and other versions??) where
160  // a doubleclick mouse event is followed by a stray release event.
164 
165  // This is used to suppress the stray left-mouse events that windows insists
166  // on generating when using multi-touch effects
168  };
169 
174  {
175 
176  public:
178  static DtOsgAdapterQtWidgetCreator& instance(DtDe& de);
179 
181  static void registerInstance(DtDe& de, DtOsgAdapterQtWidgetCreator* creator);
182 
184  virtual DtOsgAdapterQtWidget* create( DtDe& de,
185  osg::GraphicsContext::Traits* contextTraits, const QGLFormat& format,
186  QWidget * parent = 0, Qt::WindowFlags f = 0);
187  };
188 
189 }
190 

Document ID: Generated on Fri Apr 26 21:53:14 EDT 2019 from SVN revision 197883
Copyright © 2005-2019 VT MAK. All Rights Reserved (www.mak.com)