VR-Forces 4.3.1 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DtOsgAdapterQtWidget.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2015 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
6 
10 
11 #include <vrvOsgQt/vrvOsgQt.h>
12 
14 
15 //We use winsock2, but QGLWidget includes windows.h so we have to get ws2 in first
16 #ifdef _WIN32
17 #include <WinSock2.h>
18 #endif
19 
20 #include <QtOpenGL/QGLWidget>
21 #include <osgViewer/Viewer>
22 #include <QtCore/QTimer>
23 
24 #include <boost/signal.hpp>
25 
26 namespace osg
27 {
28  class GraphicsContext;
29 }
30 
31 namespace makVrv
32 {
33  class DtWindow;
34 
35  class DtChannel;
36  class DtOsgAdapterQtWidgetLogic;
37 
38 
43  {
44  Q_OBJECT;
45  public:
46 
48  DtOsgAdapterQtWidget( DtDe& de, osg::GraphicsContext::Traits* contextTraits,
49  const QGLFormat& format,
50  QWidget * parent = 0,
51  Qt::WindowFlags f = 0 );
52 
54  virtual ~DtOsgAdapterQtWidget();
55 
57  osgViewer::GraphicsWindow* graphicsWindow();
58 
60  void setView(DtWindow* window);
61  DtWindow* view() const;
62 
64  osgGA::GUIEventAdapter::KeySymbol osgKeyFromQtKeyEvent( QKeyEvent* event );
65 
68  void processKeyPressEvent( QKeyEvent* keyEvent );
69 
72  void processKeyReleaseEvent( QKeyEvent* keyEvent );
73 
74  virtual void mouseMoveEvent( QMouseEvent* event );
75 
76  virtual void focusInEvent( QFocusEvent * event );
77  virtual void focusOutEvent( QFocusEvent * event );
78 
80  static QGLFormat createFormatFromTraits(
81  const osg::GraphicsContext::Traits* contextTraits);
82 
83  virtual QSize sizeHint();
84 
86  virtual void slot_onRightClickTerrainMenuRequest( double mouseX,
87  double mouseY, DtChannel* channel );
88 
90  virtual void slot_onRightClickSelectionMenuRequest( double mouseX,
91  double mouseY, DtChannel* channel );
92 
93  boost::signal<void (DtOsgAdapterQtWidget*)> signal_mouseEnter;
94  boost::signal<void (DtOsgAdapterQtWidget*)> signal_mouseExit;
95 
96  protected:
97  void init();
98 
101  virtual bool channelInThisWidget( const DtChannel& channel );
102 
103  virtual void resizeEvent( QResizeEvent* event);
104  virtual void keyPressEvent(QKeyEvent *);
105  virtual void keyReleaseEvent(QKeyEvent *);
106  virtual void mousePressEvent( QMouseEvent* event );
107  virtual void mouseReleaseEvent( QMouseEvent* event );
108  virtual void enterEvent( QEvent* event );
109  virtual void leaveEvent( QEvent* event );
110 
111  int qtButtonToOsgButton( QMouseEvent* event);
112  virtual void mouseDoubleClickEvent(QMouseEvent* event);
113  virtual void wheelEvent(QWheelEvent *);
114  virtual void closeEvent(QCloseEvent*);
115  virtual void slot_ctrlEnterPressed( const DtChannel& channel );
116 
117  protected:
118 
119  osg::ref_ptr<osgViewer::GraphicsWindowEmbedded> myEmbeddedWindow;
120 
124 
125  // These are here to work around a bug in Qt 4.5 (and other versions??) where
126  // a doubleclick mouse event is followed by a stray release event.
130  };
131 
136  {
137 
138  public:
140  static DtOsgAdapterQtWidgetCreator& instance(DtDe& de);
141 
143  static void registerInstance(DtDe& de, DtOsgAdapterQtWidgetCreator* creator);
144 
146  virtual DtOsgAdapterQtWidget* create( DtDe& de,
147  osg::GraphicsContext::Traits* contextTraits, const QGLFormat& format,
148  QWidget * parent = 0, Qt::WindowFlags f = 0);
149  };
150 
151 }
152 

Document ID: Generated on Wed Jul 29 00:55:00 EDT 2015 from SVN revision 155257
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)