Commit 3b2fa836 authored by schurade's avatar schurade
Browse files

Merge with 2fd5acc31e69e18ad45fd821668d16adff4788e9

parents 19f55de8 82b6f9c8
......@@ -8,4 +8,6 @@ syntax: regexp
^doc/developer/html
^doc/developer/man
^build
\ No newline at end of file
^build
syntax: glob
.project
\ No newline at end of file
......@@ -27,7 +27,7 @@
#include "exceptions/WGEInitFailed.h"
WGEGraphicsWindow::WGEGraphicsWindow( boost::shared_ptr<WindowData> wdata,
WGEGraphicsWindow::WGEGraphicsWindow( osg::ref_ptr<WindowData> wdata,
int x,
int y,
int width,
......@@ -52,7 +52,7 @@ WGEGraphicsWindow::~WGEGraphicsWindow()
// cleanup
}
boost::shared_ptr<osgViewer::GraphicsWindow> WGEGraphicsWindow::getGraphicsWindow()
osg::ref_ptr<osgViewer::GraphicsWindow> WGEGraphicsWindow::getGraphicsWindow()
{
return m_GraphicsWindow;
}
......@@ -60,7 +60,7 @@ boost::shared_ptr<osgViewer::GraphicsWindow> WGEGraphicsWindow::getGraphicsWindo
void WGEGraphicsWindow::createContext( int x, int y, int width, int height )
{
// Create traits for graphics contest request
osg::DisplaySettings* ds = osg::DisplaySettings::instance();
osg::ref_ptr<osg::DisplaySettings> ds = osg::DisplaySettings::instance();
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
// ensure correct $DISPLAY variable
......@@ -108,11 +108,10 @@ void WGEGraphicsWindow::createContext( int x, int y, int width, int height )
// finally create graphics context and window
m_GraphicsContext = osg::GraphicsContext::createGraphicsContext( traits.get() );
m_GraphicsWindow = boost::shared_ptr<osgViewer::GraphicsWindow>(
static_cast<osgViewer::GraphicsWindow*>( m_GraphicsContext ) );
m_GraphicsWindow = osg::ref_ptr<osgViewer::GraphicsWindow>(
static_cast<osgViewer::GraphicsWindow*>( m_GraphicsContext.get() ) );
// get around dearanged traits on X11 (MTCompositeViewer only)
// get around dearranged traits on X11 (MTCompositeViewer only)
traits->x = x;
traits->y = x;
traits->width = width;
......
......@@ -58,7 +58,7 @@ public:
* \param height Height of the Widget.
* \exception WGEInitFailed thrown if initialization of graphics context or graphics window has failed.
*/
WGEGraphicsWindow( boost::shared_ptr<WindowData> wdata, int x, int y, int width, int height );
WGEGraphicsWindow( osg::ref_ptr<WindowData> wdata, int x, int y, int width, int height );
/**
* Destructor.
......@@ -70,9 +70,9 @@ public:
*
* \return the OSG GraphicsWindow instance.
*/
boost::shared_ptr<osgViewer::GraphicsWindow> getGraphicsWindow();
osg::ref_ptr<osgViewer::GraphicsWindow> getGraphicsWindow();
/**
/**
* Event types for the keyEvent() handler.
*/
enum KeyEvents
......@@ -80,7 +80,7 @@ public:
KEYPRESS, KEYRELEASE
};
/**
/**
* Mouse event types for the mouseEvent() handler.
*/
enum MouseEvents
......@@ -96,23 +96,23 @@ public:
*/
virtual void resize( int width, int height );
/**
/**
* Initiates a close event for this viewer. It destroys the graphics context and invalidates the viewer.
* This should be called whenever a QT Widget closes to also free its OSG Viewer resources.
*/
virtual void close();
/**
/**
* Handles key events (if forwarded to this Viewer instance).
*
*
* \param key the key code.
* \param eventType the type of event.
*/
virtual void keyEvent( KeyEvents eventType, int key );
/**
/**
* Handles mouse events forwarded from widget.
*
*
* \param eventType the event type.
* \param x x coordinate of event.
* \param y y coordinate of event.
......@@ -135,18 +135,17 @@ protected:
/**
* OpenSceneGraph render window.
*/
boost::shared_ptr<osgViewer::GraphicsWindow> m_GraphicsWindow;
osg::ref_ptr<osgViewer::GraphicsWindow> m_GraphicsWindow;
/**
* OpenSceneGraph render context. This is required to be a "normal" pointer since using shared_ptr causes
* the code not to work (unknown reason for now). But since we do not offer a getter for it -> no prob.
* OpenSceneGraph render context.
*/
osg::GraphicsContext* m_GraphicsContext;
osg::ref_ptr<osg::GraphicsContext> m_GraphicsContext;
/**
* Widget window data.
*/
boost::shared_ptr<WindowData> m_WindowData;
osg::ref_ptr<WindowData> m_WindowData;
private:
};
......
......@@ -40,6 +40,7 @@ WGEScene::WGEScene():
WGEScene::~WGEScene()
{
std::cout << "Shutting down OpenSceneGraph Root Node" << std::endl;
// cleanup
}
......
......@@ -39,12 +39,12 @@ public:
*/
WGEScene();
protected:
/**
* Destructor.
*/
virtual ~WGEScene();
protected:
virtual ~WGEScene();
private:
};
......
......@@ -41,17 +41,17 @@
#include "exceptions/WGEInitFailed.h"
#include "WGEViewer.h"
WGEViewer::WGEViewer( boost::shared_ptr<WindowData> wdata, int x, int y, int width, int height ):
WGEViewer::WGEViewer( osg::ref_ptr<WindowData> wdata, int x, int y, int width, int height ):
WGEGraphicsWindow( wdata, x, y, width, height )
{
try
{
// initialize OSG render window
m_Viewer = boost::shared_ptr<osgViewer::CompositeViewer>( new osgViewer::CompositeViewer() );
m_Viewer = osg::ref_ptr<osgViewer::CompositeViewer>( new osgViewer::CompositeViewer() );
m_Viewer->setThreadingModel( osgViewer::Viewer::DrawThreadPerContext );
// m_Viewer->setThreadingModel( osgViewer::Viewer::SingleThreaded );
m_View = boost::shared_ptr<osgViewer::Viewer>( new osgViewer::Viewer() );
m_View = osg::ref_ptr<osgViewer::Viewer>( new osgViewer::Viewer() );
m_View->getCamera()->setGraphicsContext( m_GraphicsContext );
m_View->getCamera()->setProjectionMatrixAsPerspective( 30.0f, 1.333, 1.0, 1000.0 );
m_View->getCamera()->setViewport( new osg::Viewport( 0, 0, 10, 10 ) );
......@@ -78,39 +78,39 @@ WGEViewer::~WGEViewer()
// cleanup
}
boost::shared_ptr<osgViewer::CompositeViewer> WGEViewer::getViewer()
osg::ref_ptr<osgViewer::CompositeViewer> WGEViewer::getViewer()
{
return m_Viewer;
}
void WGEViewer::setCameraManipulator( osgGA::MatrixManipulator* manipulator )
void WGEViewer::setCameraManipulator( osg::ref_ptr<osgGA::MatrixManipulator> manipulator )
{
m_View->setCameraManipulator( manipulator );
// redraw request?? no since it redraws permanently and uses the new settings
}
osgGA::MatrixManipulator* WGEViewer::getCameraManipulator()
osg::ref_ptr<osgGA::MatrixManipulator> WGEViewer::getCameraManipulator()
{
return m_View->getCameraManipulator();
}
void WGEViewer::setCamera( osg::Camera* camera )
void WGEViewer::setCamera( osg::ref_ptr<osg::Camera> camera )
{
m_View->setCamera( camera );
// redraw request?? no since it redraws permanently and uses the new settings
}
osg::Camera* WGEViewer::getCamera()
osg::ref_ptr<osg::Camera> WGEViewer::getCamera()
{
return m_View->getCamera();
}
void WGEViewer::setScene( osg::Node* node )
void WGEViewer::setScene( osg::ref_ptr<osg::Node> node )
{
m_View->setSceneData( node );
}
osg::Node* WGEViewer::getNode()
osg::ref_ptr<osg::Node> WGEViewer::getNode()
{
return m_View->getSceneData();
}
......
......@@ -60,7 +60,7 @@ public:
* \param height Height of the Widget.
* \exception WGEInitFailed thrown if initialization of graphics context or graphics window has failed.
*/
WGEViewer( boost::shared_ptr<WindowData> wdata, int x, int y, int width, int height );
WGEViewer( osg::ref_ptr<WindowData> wdata, int x, int y, int width, int height );
/**
* Destructor.
......@@ -85,61 +85,61 @@ public:
*
* \return the OSG Viewer instance.
*/
boost::shared_ptr<osgViewer::CompositeViewer> getViewer();
osg::ref_ptr<osgViewer::CompositeViewer> getViewer();
/**
* Sets the camera manipulator to use.
*
* \param manipulator the manipulator to use.
*/
void setCameraManipulator( osgGA::MatrixManipulator* manipulator );
void setCameraManipulator( osg::ref_ptr<osgGA::MatrixManipulator> manipulator );
/**
* Returns current active camera manipulator
*
* \return the active camera manipulator.
*/
osgGA::MatrixManipulator* getCameraManipulator();
osg::ref_ptr<osgGA::MatrixManipulator> getCameraManipulator();
/**
/**
* Sets the current camera.
*
*
* \param camera the OSG camera instance.
*/
void setCamera( osg::Camera* camera );
void setCamera( osg::ref_ptr<osg::Camera> camera );
/**
/**
* Returns the camera currently in use.
*
*
* \return the camera currently in use.
*/
osg::Camera* getCamera();
osg::ref_ptr<osg::Camera> getCamera();
/**
/**
* Sets the scene graph node to be used for rendering.
*
*
* \param node part of the scene graph
*/
void setScene( osg::Node* node );
void setScene( osg::ref_ptr<osg::Node> node );
/**
/**
* Returns the currently set OSG node.
*
*
* \return the node.
*/
osg::Node* getNode();
osg::ref_ptr<osg::Node> getNode();
protected:
/**
* OpenSceneGraph viewer.
*/
boost::shared_ptr<osgViewer::CompositeViewer> m_Viewer;
osg::ref_ptr<osgViewer::CompositeViewer> m_Viewer;
/**
* The OpenSceneGraph view used in this (Composite)Viewer.
*/
boost::shared_ptr<osgViewer::View> m_View;
osg::ref_ptr<osgViewer::View> m_View;
private:
};
......
......@@ -40,7 +40,6 @@ WGraphicsEngine::~WGraphicsEngine()
{
// cleanup
std::cout << "Shutting down Graphics Engine" << std::endl;
delete m_RootNode;
}
WGraphicsEngine::WGraphicsEngine( const WGraphicsEngine& other )
......@@ -48,7 +47,7 @@ WGraphicsEngine::WGraphicsEngine( const WGraphicsEngine& other )
*this = other;
}
WGEScene* WGraphicsEngine::getScene()
osg::ref_ptr<WGEScene> WGraphicsEngine::getScene()
{
return m_RootNode;
}
......
......@@ -64,14 +64,14 @@ public:
*
* \return the root node.
*/
WGEScene* getScene();
osg::ref_ptr<WGEScene> getScene();
protected:
/**
* OpenSceneGraph root node.
*/
WGEScene* m_RootNode;
osg::ref_ptr<WGEScene> m_RootNode;
/**
* Handler for repainting and event handling. Gets executed in separate thread.
......
......@@ -35,14 +35,20 @@
#include "../icons/WIcons.h"
WMainWindow::~WMainWindow()
{
// clean up list with views
m_glWidgets.clear();
}
void WMainWindow::addDockableGLWidget( QMainWindow *MainWindow )
{
QDockWidget *dockWidget = new QDockWidget( "Graphics Display" );
dockWidget->setAllowedAreas( Qt::LeftDockWidgetArea
| Qt::RightDockWidgetArea );
m_glWidget = new WQtGLWidget( dockWidget );
dockWidget->setWidget( m_glWidget );
boost::shared_ptr<WQtGLWidget> widget = boost::shared_ptr<WQtGLWidget>( new WQtGLWidget( dockWidget ) );
m_glWidgets.push_back( widget );
dockWidget->setWidget( widget.get() );
MainWindow->addDockWidget( Qt::LeftDockWidgetArea, dockWidget );
}
......@@ -152,8 +158,9 @@ void WMainWindow::setupGUI( QMainWindow *MainWindow )
m_menuHelp->setTitle( QApplication::translate( "MainWindow", "&Help", 0,
QApplication::UnicodeUTF8 ) );
m_glWidget = new WQtGLWidget( MainWindow );
MainWindow->setCentralWidget( m_glWidget );
boost::shared_ptr<WQtGLWidget> widget = boost::shared_ptr<WQtGLWidget>( new WQtGLWidget( MainWindow ) );
m_glWidgets.push_back( widget );
MainWindow->setCentralWidget( widget.get() );
// initially 3 views
addDockableGLWidget( MainWindow );
......
......@@ -24,6 +24,10 @@
#ifndef WMAINWINDOW_H
#define WMAINWINDOW_H
#include <list>
#include <boost/shared_ptr.hpp>
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
......@@ -66,6 +70,11 @@ public:
*/
void setEnabled( bool enable );
/**
* Destructor.
*/
virtual ~WMainWindow();
private:
/**
* Helper routine for adding new docks with GL content
......@@ -89,7 +98,7 @@ private:
QStatusBar* m_statusBar;
QToolBar* m_toolBar;
WQtGLWidget* m_glWidget;
std::list<boost::shared_ptr<WQtGLWidget> > m_glWidgets;
WQtPipelineBrowser* m_pipelineBrowser;
......
......@@ -43,11 +43,11 @@ WQtGLWidget::WQtGLWidget( QWidget* parent )
// Extract a WindowPtr from the HIViewRef that QWidget::winId() returns.
// Without this change, the peer tries to call GetWindowPort on the HIViewRef
// which returns 0 and we only render white.
wdata = boost::shared_ptr<WindowData>(
wdata = osg::ref_ptr<WindowData>(
new WindowData( HIViewGetWindow( static_cast<HIViewRef>winId() ) )
);
#else // all others
wdata = boost::shared_ptr<WindowData>( new WindowData( winId() ) );
wdata = osg::ref_ptr<WindowData>( new WindowData( winId() ) );
#endif
// create viewer
......
......@@ -64,7 +64,7 @@ public:
QSize sizeHint() const;
/**
/**
* List of currently possible camera manipulators.
*/
enum CameraManipulators
......@@ -72,16 +72,16 @@ public:
TRACKBALL, TERRAIN, UFO, DRIVE, FLIGHT
};
/**
/**
* Sets the camera manipulator to use.
*
*
* \param manipulator the manipulator.
*/
void setCameraManipulator( CameraManipulators manipulator );
/**
/**
* Returns the actually set camera manipulator.
*
*
* \return the manipulator.
*/
CameraManipulators getCameraManipulators();
......@@ -96,85 +96,85 @@ protected:
// We don't want to relay these on Windows, it will just cause duplicate messages
// with further problems downstream (i.e. not being able to throw the trackball
#ifndef WIN32
/**
/**
* Event handler for double clicks.
*
*
* \param event the event description.
*/
virtual void mouseDoubleClickEvent( QMouseEvent* event );
/**
/**
* Event handler for close events.
*
*
* \param event the event description.
*/
virtual void closeEvent( QCloseEvent* event );
/**
/**
* Event handler for destroy events (called after close).
*/
virtual void destroyEvent( bool destroyWindow = true, bool destroySubWindows = true );
/**
/**
* Event handler for resize events.
*
*
* \param event the event description.
*/
virtual void resizeEvent( QResizeEvent* event );
/**
/**
* Event handler for key press.
*
*
* \param event the event description.
*/
virtual void keyPressEvent( QKeyEvent* event );
/**
/**
* Event handler for key release.
*
*
* \param event the event description.
*/
virtual void keyReleaseEvent( QKeyEvent* event );
/**
/**
* Event handler for mouse button press.
*
*
* \param event the event description.
*/
virtual void mousePressEvent( QMouseEvent* event );
/**
/**
* Event handler for mouse button release.
*
*
* \param event the event description.
*/
virtual void mouseReleaseEvent( QMouseEvent* event );
/**
/**
* Event handler for mouse moves.
*
*
* \param event the event description.
*/
virtual void mouseMoveEvent( QMouseEvent* event );
#endif
/**
/**
* QT Callback for handling repaints.
*
*
* \param event event descriptor.
*/
virtual void paintEvent( QPaintEvent* event );
/**
/**
* Simply translate the mouse button from an event to an int.
*
*
* \param event the QT Event.
*
*
* \return the translated button number.
*/
int translateButton( QMouseEvent* event );
/**
/**
* Stores the current manipulator.
*/
CameraManipulators m_CurrentManipulator;
......@@ -184,12 +184,12 @@ private:
*/
QSize m_recommendedSize;
/**
/**
* Window Data for this widget needed by OpenSceneGraph.
*/
boost::shared_ptr<WindowData> wdata;
osg::ref_ptr<WindowData> wdata;
/**
/**
* Timer used for permanent redraw of all views. This is just a hack and will be improved
* so that redraws are done by separate threads.
*/
......
......@@ -134,7 +134,6 @@ int WKernel::run()
// finally GE
m_GraphicsEngine->wait( true );
// how to get QT return code from its thread?
return 0;
}
......
......@@ -61,7 +61,7 @@ const std::string WTestModule::getDescription() const
void WTestModule::threadMain()
{
// load the sample scene.
osg::Geode* sceneDataGeode = new osg::Geode();
osg::ref_ptr<osg::Geode> sceneDataGeode = new osg::Geode();
// 20 units into the screen
sceneDataGeode->addDrawable(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment