VR-Forces 4.3 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) 2011 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 /******************************************************************************
6 ** $RCSfile: DtOsgAdapterQtWidget.h,v $ $Revision: 1.29 $ $State: Exp $
7 ******************************************************************************/
8 
12 
13 #ifndef DtOsgAdapterQtWidget_H_
14 #define DtOsgAdapterQtWidget_H_
15 
16 #include <vrvOsgQt/vrvOsgQt.h>
17 
18 //We use winsock2, but QGLWidget includes windows.h so we have to get ws2 in first
19 #ifdef _WIN32
20 #include <WinSock2.h>
21 #endif
22 
23 #include <QtOpenGL/QGLWidget>
24 #include <osgViewer/Viewer>
25 #include <QtCore/QTimer>
26 
27 #include <boost/signal.hpp>
28 
29 namespace osg
30 {
31  class GraphicsContext;
32 }
33 
34 namespace makVrv
35 {
36  class DtWindow;
37 
38  class DtChannel;
39  class DtOsgAdapterQtWidgetLogic;
40 
41 
46  {
47  Q_OBJECT;
48  public:
49 
51  DtOsgAdapterQtWidget( DtDe& de, osg::GraphicsContext::Traits* contextTraits,
52  const QGLFormat& format,
53  QWidget * parent = 0,
54  Qt::WindowFlags f = 0 );
55 
57  virtual ~DtOsgAdapterQtWidget();
58 
60  osgViewer::GraphicsWindow* graphicsWindow();
61 
63  void setView(DtWindow* window);
64  DtWindow* view() const;
65 
67  osgGA::GUIEventAdapter::KeySymbol osgKeyFromQtKeyEvent( QKeyEvent* event );
68 
71  void processKeyPressEvent( QKeyEvent* keyEvent );
72 
75  void processKeyReleaseEvent( QKeyEvent* keyEvent );
76 
77  virtual void mouseMoveEvent( QMouseEvent* event );
78 
79  virtual void focusInEvent( QFocusEvent * event );
80  virtual void focusOutEvent( QFocusEvent * event );
81 
83  static QGLFormat createFormatFromTraits(
84  const osg::GraphicsContext::Traits* contextTraits);
85 
86  virtual QSize sizeHint();
87 
89  virtual void slot_onRightClickTerrainMenuRequest( double mouseX,
90  double mouseY, DtChannel* channel );
91 
93  virtual void slot_onRightClickSelectionMenuRequest( double mouseX,
94  double mouseY, DtChannel* channel );
95 
96  boost::signal<void (DtOsgAdapterQtWidget*)> signal_mouseEnter;
97  boost::signal<void (DtOsgAdapterQtWidget*)> signal_mouseExit;
98 
99  protected:
100  void init();
101 
104  virtual bool channelInThisWidget( const DtChannel& channel );
105 
106  virtual void resizeEvent( QResizeEvent* event);
107  virtual void keyPressEvent(QKeyEvent *);
108  virtual void keyReleaseEvent(QKeyEvent *);
109  virtual void mousePressEvent( QMouseEvent* event );
110  virtual void mouseReleaseEvent( QMouseEvent* event );
111  virtual void enterEvent( QEvent* event );
112  virtual void leaveEvent( QEvent* event );
113 
114  int qtButtonToOsgButton( QMouseEvent* event);
115  virtual void mouseDoubleClickEvent(QMouseEvent* event);
116  virtual void wheelEvent(QWheelEvent *);
117  virtual void closeEvent(QCloseEvent*);
118  virtual void slot_ctrlEnterPressed( const DtChannel& channel );
119 
120  protected:
121 
122  osg::ref_ptr<osgViewer::GraphicsWindowEmbedded> myEmbeddedWindow;
123 
127 
128  // These are here to work around a bug in Qt 4.5 (and other versions??) where
129  // a doubleclick mouse event is followed by a stray release event.
133  };
134 
135 }
136 
137 #endif

Document ID: Generated on Wed Mar 11 21:20:57 EDT 2015 from SVN revision 150940
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)