From eb9510eb7219a31c201592da0dee35389cfa14cb Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 13 Dec 2010 16:25:50 +0000 Subject: [PATCH] Moved GraphicsWindowQt from osgviewerQtContext into osgQt. --- examples/osgviewerQtContext/CMakeLists.txt | 7 ++++--- examples/osgviewerQtContext/osgviewerQtContext.cpp | 11 ++++++++--- .../osgQt}/GraphicsWindowQt | 12 ++++++++++-- src/osgQt/CMakeLists.txt | 2 ++ .../osgQt}/GraphicsWindowQt.cpp | 7 ++++++- 5 files changed, 30 insertions(+), 9 deletions(-) rename {examples/osgviewerQtContext => include/osgQt}/GraphicsWindowQt (92%) rename {examples/osgviewerQtContext => src/osgQt}/GraphicsWindowQt.cpp (99%) diff --git a/examples/osgviewerQtContext/CMakeLists.txt b/examples/osgviewerQtContext/CMakeLists.txt index 80aba84e4..25665d6d6 100644 --- a/examples/osgviewerQtContext/CMakeLists.txt +++ b/examples/osgviewerQtContext/CMakeLists.txt @@ -1,7 +1,5 @@ SET( TARGET_SRC - GraphicsWindowQt - GraphicsWindowQt.cpp - osgviewerQtContext.cpp + osgviewerQtContext.cpp ) IF( QT4_FOUND ) @@ -12,4 +10,7 @@ ELSE( QT4_FOUND ) ENDIF( QT4_FOUND ) INCLUDE_DIRECTORIES( ${QT_INCLUDE_DIR} ) + +SET(TARGET_ADDED_LIBRARIES osgWidget osgQt) + SETUP_EXAMPLE( osgviewerQtContext ) diff --git a/examples/osgviewerQtContext/osgviewerQtContext.cpp b/examples/osgviewerQtContext/osgviewerQtContext.cpp index 73ad48db4..340a88ed9 100644 --- a/examples/osgviewerQtContext/osgviewerQtContext.cpp +++ b/examples/osgviewerQtContext/osgviewerQtContext.cpp @@ -1,12 +1,17 @@ #include #include #include + #include #include + #include + #include + +#include + #include -#include "GraphicsWindowQt" class ViewerWidget : public QWidget, public osgViewer::CompositeViewer { @@ -44,7 +49,7 @@ public: view->addEventHandler( new osgViewer::StatsHandler ); view->setCameraManipulator( new osgGA::TrackballManipulator ); - GraphicsWindowQt* gw = dynamic_cast( camera->getGraphicsContext() ); + osgQt::GraphicsWindowQt* gw = dynamic_cast( camera->getGraphicsContext() ); return gw ? gw->getGraphWidget() : NULL; } @@ -65,7 +70,7 @@ public: traits->samples = ds->getNumMultiSamples(); osg::ref_ptr 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->setViewport( new osg::Viewport(0, 0, traits->width, traits->height) ); diff --git a/examples/osgviewerQtContext/GraphicsWindowQt b/include/osgQt/GraphicsWindowQt similarity index 92% rename from examples/osgviewerQtContext/GraphicsWindowQt rename to include/osgQt/GraphicsWindowQt index aee3eec5d..1271a5178 100644 --- a/examples/osgviewerQtContext/GraphicsWindowQt +++ b/include/osgQt/GraphicsWindowQt @@ -20,7 +20,12 @@ #include #include -class GraphWidget : public QGLWidget +#include + +namespace osgQt +{ + +class OSGQT_EXPORT GraphWidget : public QGLWidget { public: GraphWidget( const QGLFormat& format, QWidget* parent=0, const QGLWidget* shareWidget=0, Qt::WindowFlags f=0 ); @@ -42,7 +47,7 @@ protected: osgViewer::GraphicsWindow* _gw; }; -class GraphicsWindowQt : public osgViewer::GraphicsWindow +class OSGQT_EXPORT GraphicsWindowQt : public osgViewer::GraphicsWindow { public: GraphicsWindowQt( osg::GraphicsContext::Traits* traits ); @@ -88,4 +93,7 @@ protected: bool _realized; }; +} + #endif + diff --git a/src/osgQt/CMakeLists.txt b/src/osgQt/CMakeLists.txt index 6794d57cf..40bb9eede 100644 --- a/src/osgQt/CMakeLists.txt +++ b/src/osgQt/CMakeLists.txt @@ -17,6 +17,7 @@ QT4_WRAP_CPP( SOURCES_H_MOC ${SOURCES_H} OPTIONS "-f" ) SET(LIB_PUBLIC_HEADERS ${HEADER_PATH}/Export + ${HEADER_PATH}/GraphicsWindowQt ${HEADER_PATH}/QFontImplementation ${HEADER_PATH}/QGraphicsViewAdapter ${HEADER_PATH}/QWidgetImage @@ -28,6 +29,7 @@ SET(LIB_PUBLIC_HEADERS ADD_LIBRARY(${LIB_NAME} ${OPENSCENEGRAPH_USER_DEFINED_DYNAMIC_OR_STATIC} ${LIB_PUBLIC_HEADERS} + GraphicsWindowQt.cpp QFontImplementation.cpp QGraphicsViewAdapter.cpp QWidgetImage.cpp diff --git a/examples/osgviewerQtContext/GraphicsWindowQt.cpp b/src/osgQt/GraphicsWindowQt.cpp similarity index 99% rename from examples/osgviewerQtContext/GraphicsWindowQt.cpp rename to src/osgQt/GraphicsWindowQt.cpp index 1aa96d3c3..8d365a730 100644 --- a/examples/osgviewerQtContext/GraphicsWindowQt.cpp +++ b/src/osgQt/GraphicsWindowQt.cpp @@ -11,7 +11,10 @@ * OpenSceneGraph Public License for more details. */ -#include "GraphicsWindowQt" +#include + +namespace osgQt +{ GraphWidget::GraphWidget( const QGLFormat& format, QWidget* parent, const QGLWidget* shareWidget, Qt::WindowFlags f ) : QGLWidget(format, parent, shareWidget, f) @@ -340,3 +343,5 @@ void GraphicsWindowQt::requestWarpPointer( float x, float y ) if ( _widget ) QCursor::setPos( _widget->mapToGlobal(QPoint((int)x,(int)y)) ); } + +} \ No newline at end of file