svn propset svn:eol-style native include/*/*
 svn propset svn:keywords "Author Date Id Revision" include/*/*
This commit is contained in:
Robert Osfield 2011-01-31 11:40:35 +00:00
parent ef673dec45
commit 45c933daf2

View File

@ -1,99 +1,99 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 2009 Wang Rui /* -*-c++-*- OpenSceneGraph - Copyright (C) 2009 Wang Rui
* *
* This library is open source and may be redistributed and/or modified under * This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file * (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website. * included with this distribution, and on the openscenegraph.org website.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details. * OpenSceneGraph Public License for more details.
*/ */
#ifndef OSGVIEWER_GRAPHICSWINDOWQT #ifndef OSGVIEWER_GRAPHICSWINDOWQT
#define OSGVIEWER_GRAPHICSWINDOWQT #define OSGVIEWER_GRAPHICSWINDOWQT
#include <osgViewer/GraphicsWindow> #include <osgViewer/GraphicsWindow>
#include <QtGui/QWidget> #include <QtGui/QWidget>
#include <QtGui/QInputEvent> #include <QtGui/QInputEvent>
#include <QtOpenGL/QGLWidget> #include <QtOpenGL/QGLWidget>
#include <osgQt/Export> #include <osgQt/Export>
namespace osgQt namespace osgQt
{ {
class OSGQT_EXPORT GraphWidget : public QGLWidget class OSGQT_EXPORT GraphWidget : public QGLWidget
{ {
public: public:
GraphWidget( const QGLFormat& format, QWidget* parent=0, const QGLWidget* shareWidget=0, Qt::WindowFlags f=0 ); GraphWidget( const QGLFormat& format, QWidget* parent=0, const QGLWidget* shareWidget=0, Qt::WindowFlags f=0 );
inline void setGraphicsWindow( osgViewer::GraphicsWindow* gw ) { _gw = gw; } inline void setGraphicsWindow( osgViewer::GraphicsWindow* gw ) { _gw = gw; }
void setKeyboardModifiers( QInputEvent* event ); void setKeyboardModifiers( QInputEvent* event );
virtual void resizeEvent( QResizeEvent* event ); virtual void resizeEvent( QResizeEvent* event );
virtual void keyPressEvent( QKeyEvent* event ); virtual void keyPressEvent( QKeyEvent* event );
virtual void keyReleaseEvent( QKeyEvent* event ); virtual void keyReleaseEvent( QKeyEvent* event );
virtual void mousePressEvent( QMouseEvent* event ); virtual void mousePressEvent( QMouseEvent* event );
virtual void mouseReleaseEvent( QMouseEvent* event ); virtual void mouseReleaseEvent( QMouseEvent* event );
virtual void mouseDoubleClickEvent( QMouseEvent* event ); virtual void mouseDoubleClickEvent( QMouseEvent* event );
virtual void mouseMoveEvent( QMouseEvent* event ); virtual void mouseMoveEvent( QMouseEvent* event );
virtual void wheelEvent( QWheelEvent* event ); virtual void wheelEvent( QWheelEvent* event );
protected: protected:
osgViewer::GraphicsWindow* _gw; osgViewer::GraphicsWindow* _gw;
}; };
class OSGQT_EXPORT GraphicsWindowQt : public osgViewer::GraphicsWindow class OSGQT_EXPORT GraphicsWindowQt : public osgViewer::GraphicsWindow
{ {
public: public:
GraphicsWindowQt( osg::GraphicsContext::Traits* traits ); GraphicsWindowQt( osg::GraphicsContext::Traits* traits );
virtual ~GraphicsWindowQt(); virtual ~GraphicsWindowQt();
inline GraphWidget* getGraphWidget() { return _widget; } inline GraphWidget* getGraphWidget() { return _widget; }
inline const GraphWidget* getGraphWidget() const { return _widget; } inline const GraphWidget* getGraphWidget() const { return _widget; }
struct WindowData : public osg::Referenced struct WindowData : public osg::Referenced
{ {
WindowData( GraphWidget* widget ): _widget(widget) {} WindowData( GraphWidget* widget ): _widget(widget) {}
GraphWidget* _widget; GraphWidget* _widget;
}; };
bool init(); bool init();
virtual bool setWindowRectangleImplementation( int x, int y, int width, int height ); virtual bool setWindowRectangleImplementation( int x, int y, int width, int height );
virtual void getWindowRectangle( int& x, int& y, int& width, int& height ); virtual void getWindowRectangle( int& x, int& y, int& width, int& height );
virtual bool setWindowDecorationImplementation( bool windowDecoration ); virtual bool setWindowDecorationImplementation( bool windowDecoration );
virtual bool getWindowDecoration() const; virtual bool getWindowDecoration() const;
virtual void grabFocus(); virtual void grabFocus();
virtual void grabFocusIfPointerInWindow(); virtual void grabFocusIfPointerInWindow();
virtual void raiseWindow(); virtual void raiseWindow();
virtual void setWindowName( const std::string& name ); virtual void setWindowName( const std::string& name );
virtual std::string getWindowName(); virtual std::string getWindowName();
virtual void useCursor( bool cursorOn ); virtual void useCursor( bool cursorOn );
virtual void setCursor( MouseCursor cursor ); virtual void setCursor( MouseCursor cursor );
virtual bool valid() const; virtual bool valid() const;
virtual bool realizeImplementation(); virtual bool realizeImplementation();
virtual bool isRealizedImplementation() const; virtual bool isRealizedImplementation() const;
virtual void closeImplementation(); virtual void closeImplementation();
virtual bool makeCurrentImplementation(); virtual bool makeCurrentImplementation();
virtual bool releaseContextImplementation(); virtual bool releaseContextImplementation();
virtual void swapBuffersImplementation(); virtual void swapBuffersImplementation();
virtual void requestWarpPointer( float x, float y ); virtual void requestWarpPointer( float x, float y );
protected: protected:
GraphWidget* _widget; GraphWidget* _widget;
QCursor _currentCursor; QCursor _currentCursor;
bool _initialized; bool _initialized;
bool _realized; bool _realized;
}; };
} }
#endif #endif