Moved GraphicsWindowQt from osgviewerQtContext into osgQt.

This commit is contained in:
Robert Osfield 2010-12-13 16:25:50 +00:00
parent c4fded0629
commit eb9510eb72
5 changed files with 30 additions and 9 deletions

View File

@ -1,7 +1,5 @@
SET( TARGET_SRC SET( TARGET_SRC
GraphicsWindowQt osgviewerQtContext.cpp
GraphicsWindowQt.cpp
osgviewerQtContext.cpp
) )
IF( QT4_FOUND ) IF( QT4_FOUND )
@ -12,4 +10,7 @@ ELSE( QT4_FOUND )
ENDIF( QT4_FOUND ) ENDIF( QT4_FOUND )
INCLUDE_DIRECTORIES( ${QT_INCLUDE_DIR} ) INCLUDE_DIRECTORIES( ${QT_INCLUDE_DIR} )
SET(TARGET_ADDED_LIBRARIES osgWidget osgQt)
SETUP_EXAMPLE( osgviewerQtContext ) SETUP_EXAMPLE( osgviewerQtContext )

View File

@ -1,12 +1,17 @@
#include <QtCore/QTimer> #include <QtCore/QTimer>
#include <QtGui/QApplication> #include <QtGui/QApplication>
#include <QtGui/QGridLayout> #include <QtGui/QGridLayout>
#include <osgViewer/CompositeViewer> #include <osgViewer/CompositeViewer>
#include <osgViewer/ViewerEventHandlers> #include <osgViewer/ViewerEventHandlers>
#include <osgGA/TrackballManipulator> #include <osgGA/TrackballManipulator>
#include <osgDB/ReadFile> #include <osgDB/ReadFile>
#include <osgQt/GraphicsWindowQt>
#include <iostream> #include <iostream>
#include "GraphicsWindowQt"
class ViewerWidget : public QWidget, public osgViewer::CompositeViewer class ViewerWidget : public QWidget, public osgViewer::CompositeViewer
{ {
@ -44,7 +49,7 @@ public:
view->addEventHandler( new osgViewer::StatsHandler ); view->addEventHandler( new osgViewer::StatsHandler );
view->setCameraManipulator( new osgGA::TrackballManipulator ); view->setCameraManipulator( new osgGA::TrackballManipulator );
GraphicsWindowQt* gw = dynamic_cast<GraphicsWindowQt*>( camera->getGraphicsContext() ); osgQt::GraphicsWindowQt* gw = dynamic_cast<osgQt::GraphicsWindowQt*>( camera->getGraphicsContext() );
return gw ? gw->getGraphWidget() : NULL; return gw ? gw->getGraphWidget() : NULL;
} }
@ -65,7 +70,7 @@ public:
traits->samples = ds->getNumMultiSamples(); traits->samples = ds->getNumMultiSamples();
osg::ref_ptr<osg::Camera> camera = new osg::Camera; osg::ref_ptr<osg::Camera> camera = new osg::Camera;
camera->setGraphicsContext( new GraphicsWindowQt(traits.get()) ); camera->setGraphicsContext( new osgQt::GraphicsWindowQt(traits.get()) );
camera->setClearColor( osg::Vec4(0.2, 0.2, 0.6, 1.0) ); camera->setClearColor( osg::Vec4(0.2, 0.2, 0.6, 1.0) );
camera->setViewport( new osg::Viewport(0, 0, traits->width, traits->height) ); camera->setViewport( new osg::Viewport(0, 0, traits->width, traits->height) );

View File

@ -20,7 +20,12 @@
#include <QtGui/QInputEvent> #include <QtGui/QInputEvent>
#include <QtOpenGL/QGLWidget> #include <QtOpenGL/QGLWidget>
class GraphWidget : public QGLWidget #include <osgQt/Export>
namespace osgQt
{
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 );
@ -42,7 +47,7 @@ protected:
osgViewer::GraphicsWindow* _gw; osgViewer::GraphicsWindow* _gw;
}; };
class GraphicsWindowQt : public osgViewer::GraphicsWindow class OSGQT_EXPORT GraphicsWindowQt : public osgViewer::GraphicsWindow
{ {
public: public:
GraphicsWindowQt( osg::GraphicsContext::Traits* traits ); GraphicsWindowQt( osg::GraphicsContext::Traits* traits );
@ -88,4 +93,7 @@ protected:
bool _realized; bool _realized;
}; };
}
#endif #endif

View File

@ -17,6 +17,7 @@ QT4_WRAP_CPP( SOURCES_H_MOC ${SOURCES_H} OPTIONS "-f" )
SET(LIB_PUBLIC_HEADERS SET(LIB_PUBLIC_HEADERS
${HEADER_PATH}/Export ${HEADER_PATH}/Export
${HEADER_PATH}/GraphicsWindowQt
${HEADER_PATH}/QFontImplementation ${HEADER_PATH}/QFontImplementation
${HEADER_PATH}/QGraphicsViewAdapter ${HEADER_PATH}/QGraphicsViewAdapter
${HEADER_PATH}/QWidgetImage ${HEADER_PATH}/QWidgetImage
@ -28,6 +29,7 @@ SET(LIB_PUBLIC_HEADERS
ADD_LIBRARY(${LIB_NAME} ADD_LIBRARY(${LIB_NAME}
${OPENSCENEGRAPH_USER_DEFINED_DYNAMIC_OR_STATIC} ${OPENSCENEGRAPH_USER_DEFINED_DYNAMIC_OR_STATIC}
${LIB_PUBLIC_HEADERS} ${LIB_PUBLIC_HEADERS}
GraphicsWindowQt.cpp
QFontImplementation.cpp QFontImplementation.cpp
QGraphicsViewAdapter.cpp QGraphicsViewAdapter.cpp
QWidgetImage.cpp QWidgetImage.cpp

View File

@ -11,7 +11,10 @@
* OpenSceneGraph Public License for more details. * OpenSceneGraph Public License for more details.
*/ */
#include "GraphicsWindowQt" #include <osgQt/GraphicsWindowQt>
namespace osgQt
{
GraphWidget::GraphWidget( const QGLFormat& format, QWidget* parent, const QGLWidget* shareWidget, Qt::WindowFlags f ) GraphWidget::GraphWidget( const QGLFormat& format, QWidget* parent, const QGLWidget* shareWidget, Qt::WindowFlags f )
: QGLWidget(format, parent, shareWidget, f) : QGLWidget(format, parent, shareWidget, f)
@ -340,3 +343,5 @@ void GraphicsWindowQt::requestWarpPointer( float x, float y )
if ( _widget ) if ( _widget )
QCursor::setPos( _widget->mapToGlobal(QPoint((int)x,(int)y)) ); QCursor::setPos( _widget->mapToGlobal(QPoint((int)x,(int)y)) );
} }
}