![]() |
VR-Forces 4.0.4 Class Documentation
|
00001 /****************************************************************************** 00002 ** Copyright (c) 2011 MAK Technologies, Inc. 00003 ** All rights reserved. 00004 ******************************************************************************/ 00005 /****************************************************************************** 00006 ** $RCSfile: DtOsgAdapterQtWidget.h,v $ $Revision: 1.29 $ $State: Exp $ 00007 ******************************************************************************/ 00008 00012 00013 #ifndef DtOsgAdapterQtWidget_H_ 00014 #define DtOsgAdapterQtWidget_H_ 00015 00016 #include <vrvOsgQt/vrvOsgQt.h> 00017 00018 //We use winsock2, but QGLWidget includes windows.h so we have to get ws2 in first 00019 #ifdef _WIN32 00020 #include <WinSock2.h> 00021 #endif 00022 00023 #include <QtOpenGL/QGLWidget> 00024 #include <osgViewer/Viewer> 00025 #include <QtCore/QTimer> 00026 00027 namespace osg 00028 { 00029 class GraphicsContext; 00030 } 00031 00032 namespace makVrv 00033 { 00034 class DtWindow; 00035 00036 class DtChannel; 00037 class DtOsgAdapterQtWidgetLogic; 00038 00039 00043 class DT_DLL_VRVOSGQT DtOsgAdapterQtWidget : public QGLWidget 00044 { 00045 Q_OBJECT; 00046 public: 00047 00049 DtOsgAdapterQtWidget( DtDe& de, osg::GraphicsContext::Traits* contextTraits, 00050 const QGLFormat& format, 00051 QWidget * parent = 0, 00052 Qt::WindowFlags f = 0 ); 00053 00055 virtual ~DtOsgAdapterQtWidget(); 00056 00058 osgViewer::GraphicsWindow* graphicsWindow(); 00059 00061 void setView(DtWindow* window); 00062 DtWindow* view() const; 00063 00065 osgGA::GUIEventAdapter::KeySymbol osgKeyFromQtKeyEvent( QKeyEvent* event ); 00066 00069 void processKeyPressEvent( QKeyEvent* keyEvent ); 00070 00073 void processKeyReleaseEvent( QKeyEvent* keyEvent ); 00074 00075 virtual void mouseMoveEvent( QMouseEvent* event ); 00076 00077 virtual void focusInEvent( QFocusEvent * event ); 00078 virtual void focusOutEvent( QFocusEvent * event ); 00079 00081 static QGLFormat createFormatFromTraits( 00082 const osg::GraphicsContext::Traits* contextTraits); 00083 00084 virtual QSize sizeHint(); 00085 00087 virtual void slot_onRightClickTerrainMenuRequest( double mouseX, 00088 double mouseY, DtChannel* channel ); 00089 00091 virtual void slot_onRightClickSelectionMenuRequest( double mouseX, 00092 double mouseY, DtChannel* channel ); 00093 00094 protected: 00095 void init(); 00096 00099 virtual bool channelInThisWidget( const DtChannel& channel ); 00100 00101 virtual void resizeEvent( QResizeEvent* event); 00102 virtual void keyPressEvent(QKeyEvent *); 00103 virtual void keyReleaseEvent(QKeyEvent *); 00104 virtual void mousePressEvent( QMouseEvent* event ); 00105 virtual void mouseReleaseEvent( QMouseEvent* event ); 00106 00107 int qtButtonToOsgButton( QMouseEvent* event); 00108 virtual void mouseDoubleClickEvent(QMouseEvent* event); 00109 virtual void wheelEvent(QWheelEvent *); 00110 virtual void closeEvent(QCloseEvent*); 00111 virtual void slot_ctrlEnterPressed( const DtChannel& channel ); 00112 00113 protected: 00114 00115 osg::ref_ptr<osgViewer::GraphicsWindowEmbedded> myEmbeddedWindow; 00116 00117 DtDe& myDe; 00118 DtWindow* myWindow; 00119 DtOsgAdapterQtWidgetLogic* myLogic; 00120 00121 // These are here to work around a bug in Qt 4.5 (and other versions??) where 00122 // a doubleclick mouse event is followed by a stray release event. 00123 bool myLeftPressed; 00124 bool myMiddlePressed; 00125 bool myRightPressed; 00126 }; 00127 00128 } 00129 00130 #endif