Commit 2ea2c875 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[ADD] - graphics widgets are now dockable.

parent 8ff86086
......@@ -15,6 +15,7 @@ SET(GUI_QT4_MOC_HDRS
WMainWindow.h
WQtNavGLWidget.h
WQtGLWidget.h
WQtGLDockWidget.h
WQtCombinerToolbar.h
guiElements/WQtPushButton.h
guiElements/WQtModuleOneToOneCombinerAction.h
......
......@@ -76,6 +76,7 @@
#include "WQtCombinerToolbar.h"
#include "WQtCustomDockWidget.h"
#include "WQtNavGLWidget.h"
#include "WQtGLDockWidget.h"
#include "WMainWindow.h"
......@@ -140,8 +141,14 @@ void WMainWindow::setupGUI()
addDockWidget( Qt::RightDockWidgetArea, m_controlPanel );
m_mainGLWidget = boost::shared_ptr< WQtGLWidget >( new WQtGLWidget( "main", this, WGECamera::ORTHOGRAPHIC ) );
setCentralWidget( m_mainGLWidget.get() );
m_glDock = new QMainWindow();
m_glDock->setDockOptions( QMainWindow::AnimatedDocks | QMainWindow::AllowNestedDocks | QMainWindow::AllowTabbedDocks );
m_glDock->setDocumentMode( true );
setCentralWidget( m_glDock );
WQtGLDockWidget* mainGLDock = new WQtGLDockWidget( "main", "3D View", m_glDock );
mainGLDock->getGLWidget()->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
m_mainGLWidget = mainGLDock->getGLWidget();
m_glDock->addDockWidget( Qt::RightDockWidgetArea, mainGLDock );
m_permanentToolBar = new WQtToolBar( "Permanent Toolbar", this );
......@@ -269,34 +276,37 @@ void WMainWindow::setupGUI()
if( !( WPreferences::getPreference( "qt4gui.hideAxial", &hideWidget ) && hideWidget) )
{
#ifndef _MSC_VER
m_navAxial = boost::shared_ptr< WQtNavGLWidget >( new WQtNavGLWidget( "Axial View", this, "Axial Slice", m_mainGLWidget.get() ) );
m_navAxial = boost::shared_ptr< WQtNavGLWidget >( new WQtNavGLWidget( "Axial View", "Axial View", this, "Axial Slice",
m_mainGLWidget.get() ) );
#else
m_navAxial = boost::shared_ptr< WQtNavGLWidget >( new WQtNavGLWidget( "Axial View", this, "Axial Slice" ) );
m_navAxial = boost::shared_ptr< WQtNavGLWidget >( new WQtNavGLWidget( "Axial View", "Axial View", this, "Axial Slice" ) );
#endif
m_navAxial->setFeatures( QDockWidget::AllDockWidgetFeatures );
addDockWidget( Qt::LeftDockWidgetArea, m_navAxial.get() );
m_glDock->addDockWidget( Qt::LeftDockWidgetArea, m_navAxial.get() );
}
if( !( WPreferences::getPreference( "qt4gui.hideCoronal", &hideWidget ) && hideWidget) )
{
#ifndef _MSC_VER
m_navCoronal = boost::shared_ptr< WQtNavGLWidget >( new WQtNavGLWidget( "Coronal View", this, "Coronal Slice", m_mainGLWidget.get() ) );
m_navCoronal = boost::shared_ptr< WQtNavGLWidget >( new WQtNavGLWidget( "Coronal View", "Coronal View", this, "Coronal Slice",
m_mainGLWidget.get() ) );
#else
m_navCoronal = boost::shared_ptr< WQtNavGLWidget >( new WQtNavGLWidget( "Coronal View", this, "Coronal Slice" ) );
m_navCoronal = boost::shared_ptr< WQtNavGLWidget >( new WQtNavGLWidget( "Coronal View", "Coronal View", this, "Coronal Slice" ) );
#endif
m_navCoronal->setFeatures( QDockWidget::AllDockWidgetFeatures );
addDockWidget( Qt::LeftDockWidgetArea, m_navCoronal.get() );
m_glDock->addDockWidget( Qt::LeftDockWidgetArea, m_navCoronal.get() );
}
if( !( WPreferences::getPreference( "qt4gui.hideSagittal", &hideWidget ) && hideWidget) )
{
#ifndef _MSC_VER
m_navSagittal =
boost::shared_ptr< WQtNavGLWidget >( new WQtNavGLWidget( "Sagittal View", this, "Sagittal Slice", m_mainGLWidget.get() ) );
boost::shared_ptr< WQtNavGLWidget >( new WQtNavGLWidget( "Sagittal View", "Sagittal View", this, "Sagittal Slice",
m_mainGLWidget.get() ) );
#else
m_navSagittal =
boost::shared_ptr< WQtNavGLWidget >( new WQtNavGLWidget( "Sagittal View", this, "Sagittal Slice" ) );
boost::shared_ptr< WQtNavGLWidget >( new WQtNavGLWidget( "Sagittal View", "Sagittal View", this, "Sagittal Slice" ) );
#endif
m_navSagittal->setFeatures( QDockWidget::AllDockWidgetFeatures );
addDockWidget( Qt::LeftDockWidgetArea, m_navSagittal.get() );
m_glDock->addDockWidget( Qt::LeftDockWidgetArea, m_navSagittal.get() );
}
}
......@@ -1045,9 +1055,11 @@ void WMainWindow::restoreSavedState()
wlog::info( "MainWindow" ) << "Restoring window state from \"" << stateName << "\"";
QSettings setting( "OpenWalnut.org", QString::fromStdString( stateName ) );
QByteArray state = setting.value( "MainWindowState", "" ).toByteArray();
restoreGeometry( setting.value( "MainWindowGeometry", "" ).toByteArray() );
restoreState( state );
restoreState( setting.value( "MainWindowState", "" ).toByteArray() );
m_glDock->restoreGeometry( setting.value( "GLDockWindowGeometry", "" ).toByteArray() );
m_glDock->restoreState( setting.value( "GLDockWindowState", "" ).toByteArray() );
}
void WMainWindow::saveWindowState()
......@@ -1069,10 +1081,12 @@ void WMainWindow::saveWindowState()
wlog::info( "MainWindow" ) << "Saving window state for \"" << stateName << "\"";
// this saves the window state to some common location on the target OS in user scope.
QByteArray state = saveState();
QSettings setting( "OpenWalnut.org", QString::fromStdString( stateName ) );
setting.setValue( "MainWindowState", state );
setting.setValue( "MainWindowState", saveState() );
setting.setValue( "GLDockWindowState", m_glDock->saveState() );
// NOTE: Qt Doc says that saveState also saves geometry. But this somehow is wrong (at least for 4.6.3)
setting.setValue( "MainWindowGeometry", saveGeometry() );
setting.setValue( "GLDockWindowGeometry", m_glDock->saveGeometry() );
}
......@@ -50,6 +50,7 @@ class WQtCombinerToolbar;
class WQtControlPanel;
class WQtCustomDockWidget;
class WQtNavGLWidget;
class WQtGLDockWidget;
class WQtPropertyBoolAction;
class WPropertyBase;
class WQtControlPanel;
......@@ -300,6 +301,7 @@ private:
boost::shared_ptr< WQtNavGLWidget > m_navAxial; //!< the axial view widget GL widget of the GUI
boost::shared_ptr< WQtNavGLWidget > m_navCoronal; //!< the coronal view widget GL widget of the GUI
boost::shared_ptr< WQtNavGLWidget > m_navSagittal; //!< the sgittal view widget GL widget of the GUI
QMainWindow* m_glDock; //!< the dock that is used for gl widgets
QDockWidget* m_dummyWidget; //!< The dummywidget serves as spacer in the dockwidget area;
/**
......
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#include <QtGui/QDockWidget>
#include <QtGui/QVBoxLayout>
#include "WQtGLDockWidget.h"
WQtGLDockWidget::WQtGLDockWidget( QString viewTitle, QString dockTitle, QWidget* parent, const QGLWidget* shareWidget )
: QDockWidget( dockTitle, parent )
{
setObjectName( QString( "GL - " ) + dockTitle );
setAllowedAreas( Qt::AllDockWidgetAreas );
setFeatures( QDockWidget::AllDockWidgetFeatures );
// the panel contains all other widgets, including the gl widget
// This allows adding other widgets to certain docks
m_panel = new QWidget( this );
m_layout = new QVBoxLayout();
#ifndef _MSC_VER
m_glWidget = boost::shared_ptr<WQtGLWidget>( new WQtGLWidget( viewTitle.toStdString(), m_panel, WGECamera::ORTHOGRAPHIC, shareWidget ) );
#else
m_glWidget = boost::shared_ptr<WQtGLWidget>( new WQtGLWidget( viewTitle.toStdString(), m_panel, WGECamera::ORTHOGRAPHIC ) );
#endif
setMinimumSize( 240, 240 );
//setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum );
// add panel to layout.
m_layout->addWidget( m_glWidget.get() );
m_panel->setLayout( m_layout );
setWidget( m_panel );
// we need to know whether the dock is visible or not
connect( this, SIGNAL( visibilityChanged( bool ) ), this, SLOT( handleVisibilityChange( bool ) ) );
}
WQtGLDockWidget::~WQtGLDockWidget()
{
// cleanup
}
boost::shared_ptr<WQtGLWidget>WQtGLDockWidget::getGLWidget() const
{
return m_glWidget;
}
void WQtGLDockWidget::handleVisibilityChange( bool visible )
{
// this can help to reduce CPU load. Especially if multithreading viewers are used with cull thread per context.
m_glWidget->getViewer()->getView()->getScene()->getSceneData()->setNodeMask( visible * 0xFFFFFFFF );
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WQTGLDOCKWIDGET_H
#define WQTGLDOCKWIDGET_H
#include <QtGui/QDockWidget>
#include <QtGui/QVBoxLayout>
#include "WQtGLWidget.h"
/**
* Dock widget containing only a GLWidget.
*/
class WQtGLDockWidget : public QDockWidget
{
Q_OBJECT
public:
/**
* default constructor
*
* \param viewTitle Title will be used as view title
* \param dockTitle The title of the dock widget.
* \param parent The widget that manages this widget
* \param shareWidget this widget will share OpenGL display lists and texture objects with shareWidget
*/
WQtGLDockWidget( QString viewTitle, QString dockTitle, QWidget* parent , const QGLWidget* shareWidget = 0 );
/**
* destructor.
*/
virtual ~WQtGLDockWidget();
/**
* Gets the contained GL widget instance.
*
* \return pointer to GL widget
*/
boost::shared_ptr< WQtGLWidget > getGLWidget() const;
protected:
/**
* Layout of this widget. Use this to extend the dock width other widgets (i.e. PropWidgets).
*/
QVBoxLayout* m_layout;
/**
* The panel widget using m_layout.
*/
QWidget* m_panel;
private slots:
/**
* If the dock widget changes its visibility.
*
* \param visible if true, the dock is visible
*/
void handleVisibilityChange( bool visible );
private:
/**
* My GL widget.
*/
boost::shared_ptr<WQtGLWidget> m_glWidget;
};
#endif // WQTGLDOCKWIDGET_H
......@@ -37,42 +37,16 @@
#include "WQtNavGLWidget.h"
WQtNavGLWidget::WQtNavGLWidget( QString title, QWidget* parent, std::string sliderTitle, const QGLWidget * shareWidget )
: QDockWidget( title, parent )
WQtNavGLWidget::WQtNavGLWidget( QString viewTitle, QString dockTitle, QWidget* parent, std::string sliderTitle, const QGLWidget * shareWidget )
: WQtGLDockWidget( viewTitle, dockTitle, parent, shareWidget )
{
setObjectName( QString( "Navigation Window " ) + title );
propertyWidgetMap.clear();
m_sliderTitle = QString( sliderTitle.c_str() );
setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
setFeatures( QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable );
QWidget* panel = new QWidget( this );
m_layout = new QVBoxLayout();
#ifndef _MSC_VER
m_glWidget = boost::shared_ptr<WQtGLWidget>( new WQtGLWidget( title.toStdString(), panel, WGECamera::ORTHOGRAPHIC, shareWidget ) );
#else
m_glWidget = boost::shared_ptr<WQtGLWidget>( new WQtGLWidget( title.toStdString(), panel, WGECamera::ORTHOGRAPHIC ) );
#endif
setMinimumSize( 160, 240 );
//setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum );
m_scene = new WGEScene();
m_scene->setDataVariance( osg::Object::DYNAMIC );
m_glWidget->getViewer()->getView()->requestContinuousUpdate( false );
m_glWidget->getViewer()->setScene( m_scene );
m_layout->addWidget( m_glWidget.get() );
panel->setLayout( m_layout );
setWidget( panel );
// we need to know whether the dock is visible or not
connect( this, SIGNAL( visibilityChanged( bool ) ), this, SLOT( handleVisibilityChange( bool ) ) );
getGLWidget()->getViewer()->getView()->requestContinuousUpdate( false );
getGLWidget()->getViewer()->setScene( m_scene );
}
WQtNavGLWidget::~WQtNavGLWidget()
......@@ -93,18 +67,13 @@ void WQtNavGLWidget::setSliderTitle( std::string title )
m_sliderTitle = QString( title.c_str() );
}
boost::shared_ptr<WQtGLWidget>WQtNavGLWidget::getGLWidget()
{
return m_glWidget;
}
void WQtNavGLWidget::setSliderProperty( boost::shared_ptr< WPropertyBase > prop )
{
WPropertyIntWidget* propWidget;
propWidget = new WPropertyIntWidget( prop->toPropInt(), NULL, parentWidget() );
propertyWidgetMap[prop] = propWidget;
m_layout->addWidget( propWidget );
m_layout->setStretchFactor( m_glWidget.get(), 1 );
m_layout->setStretchFactor( getGLWidget().get(), 1 );
m_layout->setStretchFactor( propWidget, 0 );
}
......@@ -116,9 +85,3 @@ void WQtNavGLWidget::removeSliderProperty( boost::shared_ptr< WPropertyBase > pr
propertyWidgetMap.erase( prop );
}
void WQtNavGLWidget::handleVisibilityChange( bool visible )
{
// this canhelp to reduce CPU load. Especially if multithreading viewers are used with cull thread per context.
m_glWidget->getViewer()->getView()->getScene()->getSceneData()->setNodeMask( visible * 0xFFFFFFFF );
}
......@@ -35,12 +35,12 @@
#include "../../graphicsEngine/WGEGroupNode.h"
#include "controlPanel/WPropertyIntWidget.h"
#include "WQtGLWidget.h"
#include "WQtGLDockWidget.h"
/**
* container widget to hold as GL widget and a slider
*/
class WQtNavGLWidget : public QDockWidget
class WQtNavGLWidget : public WQtGLDockWidget
{
Q_OBJECT
......@@ -48,25 +48,19 @@ public:
/**
* default constructor
*
* \param title Title will be displayed above the widget
* \param viewTitle Title will be used as view title
* \param dockTitle The title of the dock widget.
* \param parent The widget that manages this widget
* \param sliderTitle Name of the slider corresponding to the property it manipulates
* \param shareWidget this widget will share OpenGL display lists and texture objects with shareWidget
*/
explicit WQtNavGLWidget( QString title, QWidget* parent, std::string sliderTitle="pos", const QGLWidget * shareWidget = 0 );
WQtNavGLWidget( QString viewTitle, QString dockTitle, QWidget* parent, std::string sliderTitle="pos", const QGLWidget * shareWidget = 0 );
/**
* destructor.
*/
virtual ~WQtNavGLWidget();
/**
* Gets the contained GL widget instance.
*
* \return pointer to GL widget
*/
boost::shared_ptr< WQtGLWidget > getGLWidget();
/**
* Set the title of the slider used in this nav widget
*
......@@ -90,14 +84,6 @@ public:
protected:
private slots:
/**
* If the dock widget changes its visibility.
*
* \param visible if true, the dock is visible
*/
void handleVisibilityChange( bool visible );
private:
/**
......@@ -105,11 +91,6 @@ private:
*/
QString m_sliderTitle;
/**
* My GL widget.
*/
boost::shared_ptr<WQtGLWidget> m_glWidget;
/**
* the scene which is displayed by the GL widget
*/
......@@ -120,11 +101,6 @@ private:
*/
void handleChangedPropertyValue();
/**
* Layout of this widget.
*/
QVBoxLayout* m_layout;
/**
* Map holding the widgets for module properties added automatically. So they can be removed again automatically
* if the module is removed.
......
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