/*************************************************************************** * Copyright by (C) 2004 by Garrett Potts * * Copyright by (C) 2009 by Jack R * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * ***************************************************************************/ #ifndef OSSIMPLANETWIDGET_H #define OSSIMPLANETWIDGET_H #include #include #include class ossimOsgMainFormController; class OssimPlanetQgisGlWidget : public QGLWidget { Q_OBJECT public: OssimPlanetQgisGlWidget( QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WindowFlags f = 0 ); OssimPlanetQgisGlWidget( const QGLFormat & format, QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WindowFlags f = 0 ); virtual ~OssimPlanetQgisGlWidget(); osgViewer::GraphicsWindow* getGraphicsWindow() { return theGraphicsWindow.get(); } const osgViewer::GraphicsWindow* getGraphicsWindow() const { return theGraphicsWindow.get(); } void setMouseNavigationFlag(bool flag); bool getMouseNavigationFlag()const; virtual void dropEvent ( QDropEvent * event ); virtual void dragEnterEvent(QDragEnterEvent *event); protected slots: void doIdleAnimationFrame(); signals: void signalMouseMoveEvent(QMouseEvent* event); void signalMousePressEvent(QMouseEvent* event); void signalMouseReleaseEvent(QMouseEvent* event); void signalMouseDoubleClickEvent(QMouseEvent* event); void signalViewPositionChangedLatLonHgtHPR(double lat, double lon, double height, double heading, double pitch, double roll); void signalDropEvent(QDropEvent * event); void signalDragEnterEvent(QDragEnterEvent *event); protected: void init(); virtual void frameIfNeeded()=0; virtual void resizeGL( int width, int height ); virtual void keyPressEvent( QKeyEvent* event ); virtual void keyReleaseEvent( QKeyEvent* event ); virtual void mousePressEvent( QMouseEvent* event ); virtual void mouseReleaseEvent( QMouseEvent* event ); virtual void mouseMoveEvent( QMouseEvent* event ); osgGA::GUIEventAdapter::KeySymbol qtKeyToOsg(QKeyEvent * e)const; void addModifiers(osg::ref_ptr eventQueue, Qt::KeyboardModifiers modifier); osg::ref_ptr theGraphicsWindow; bool theMouseNavigationFlag; bool thePassAllUnhandledEventsFlag; }; class OssimPlanetQgisViewer : public ossimPlanetViewer, public OssimPlanetQgisGlWidget { public: OssimPlanetQgisViewer(QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WindowFlags f = 0); OssimPlanetQgisViewer( const QGLFormat & format, QWidget * parent = 0, const QGLWidget * shareWidget = 0, Qt::WindowFlags f = 0 ); virtual void paintGL(); virtual void requestRedraw(); virtual void requestContinuousUpdate(bool needed=true); virtual void frameIfNeeded(); virtual void mouseMoveEvent( QMouseEvent* event ); virtual void updateTraversal(); protected: QTimer *timer(); // Ensures that qtimer_ exists OpenThreads::ReentrantMutex theDrawMutex; bool theRequestRedrawFlag; bool theRequestContinuousUpdateFlag; int theTimerInterval; osg::Matrixd theCurrentViewMatrix; osg::Matrixd theCurrentViewMatrixInverse; osg::Vec3d theCurrentViewLlh; osg::Vec3d theCurrentViewHpr; private: QTimer *theQTimer; // This should always be accessed via the timer() method }; #endif // OSSIMPLANETWIDGET_H