VR-Forces 4.1.1 Class Documentation
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 namespace osg
28 {
29  class GraphicsContext;
30 }
31 
32 namespace makVrv
33 {
34  class DtWindow;
35 
36  class DtChannel;
37  class DtOsgAdapterQtWidgetLogic;
38 
39 
44  {
45  Q_OBJECT;
46  public:
47 
49  DtOsgAdapterQtWidget( DtDe& de, osg::GraphicsContext::Traits* contextTraits,
50  const QGLFormat& format,
51  QWidget * parent = 0,
52  Qt::WindowFlags f = 0 );
53 
55  virtual ~DtOsgAdapterQtWidget();
56 
58  osgViewer::GraphicsWindow* graphicsWindow();
59 
61  void setView(DtWindow* window);
62  DtWindow* view() const;
63 
65  osgGA::GUIEventAdapter::KeySymbol osgKeyFromQtKeyEvent( QKeyEvent* event );
66 
69  void processKeyPressEvent( QKeyEvent* keyEvent );
70 
73  void processKeyReleaseEvent( QKeyEvent* keyEvent );
74 
75  virtual void mouseMoveEvent( QMouseEvent* event );
76 
77  virtual void focusInEvent( QFocusEvent * event );
78  virtual void focusOutEvent( QFocusEvent * event );
79 
81  static QGLFormat createFormatFromTraits(
82  const osg::GraphicsContext::Traits* contextTraits);
83 
84  virtual QSize sizeHint();
85 
87  virtual void slot_onRightClickTerrainMenuRequest( double mouseX,
88  double mouseY, DtChannel* channel );
89 
91  virtual void slot_onRightClickSelectionMenuRequest( double mouseX,
92  double mouseY, DtChannel* channel );
93 
94  protected:
95  void init();
96 
99  virtual bool channelInThisWidget( const DtChannel& channel );
100 
101  virtual void resizeEvent( QResizeEvent* event);
102  virtual void keyPressEvent(QKeyEvent *);
103  virtual void keyReleaseEvent(QKeyEvent *);
104  virtual void mousePressEvent( QMouseEvent* event );
105  virtual void mouseReleaseEvent( QMouseEvent* event );
106 
107  int qtButtonToOsgButton( QMouseEvent* event);
108  virtual void mouseDoubleClickEvent(QMouseEvent* event);
109  virtual void wheelEvent(QWheelEvent *);
110  virtual void closeEvent(QCloseEvent*);
111  virtual void slot_ctrlEnterPressed( const DtChannel& channel );
112 
113  protected:
114 
115  osg::ref_ptr<osgViewer::GraphicsWindowEmbedded> myEmbeddedWindow;
116 
120 
121  // These are here to work around a bug in Qt 4.5 (and other versions??) where
122  // a doubleclick mouse event is followed by a stray release event.
126  };
127 
128 }
129 
130 #endif

Document ID: Generated on Mon Apr 8 19:24:01 EDT 2013 from SVN revision 125877
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)