Commit 4fe1bb72 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[ADD] - extended custom widget API. Added some really basic methods which should have been there.

parent ecc40edf
......@@ -24,6 +24,17 @@
#include "WCustomWidget.h"
WCustomWidget::WCustomWidget( std::string title ):
m_title( title )
{
}
WCustomWidget::~WCustomWidget()
{
}
std::string WCustomWidget::getTitle() const
{
return m_title;
}
......@@ -25,11 +25,14 @@
#ifndef WCUSTOMWIDGET_H
#define WCUSTOMWIDGET_H
#include <string>
#include <boost/shared_ptr.hpp>
#include <osg/ref_ptr>
#include "../graphicsEngine/WGEViewer.h"
class WGEGroupNode;
/**
......@@ -38,6 +41,23 @@ class WGEGroupNode;
class WCustomWidget
{
public:
/**
* Abbreviation for a shared pointer on a instance of this class.
*/
typedef boost::shared_ptr< WCustomWidget > SPtr;
/**
* Abbreviation for a const shared pointer on a instance of this class.
*/
typedef boost::shared_ptr< const WCustomWidget > ConstSPtr;
/**
* Constructor. Create a custom widget instance.
*
* \param title the title of the widget
*/
explicit WCustomWidget( std::string title );
/**
* Destructor
*/
......@@ -57,8 +77,20 @@ public:
*/
virtual boost::shared_ptr< WGEViewer > getViewer() const = 0;
/**
* Get the title of the widget.
*
* \return title as string
*/
virtual std::string getTitle() const;
protected:
private:
/**
* The widget's title string.
*/
std::string m_title;
};
#endif // WCUSTOMWIDGET_H
......@@ -82,23 +82,37 @@ public:
virtual int run() = 0;
/**
* Instruct the MainWindow to open a new custom widget.
* Instruct to open a new custom widget. The specified condition should be the shutdown condition of the module, as the function returns only
* if the widget was created. To ensure that the creation is aborted properly if the module shuts down in the meantime, this condition is
* used.
*
* \note this function blocks until the widget was created. Check the resulting pointer for NULL.
*
* \param title the title of the widget
* \param projectionMode the kind of projection which should be used
* \param shutdownCondition condition to wait for the shutdown of a module
* \param shutdownCondition a condition enforcing abort of widget creation.
*
* \return the created widget
*/
virtual boost::shared_ptr< WCustomWidget > openCustomWidget( std::string title, WGECamera::ProjectionMode projectionMode,
boost::shared_ptr< WCondition > shutdownCondition ) = 0;
virtual WCustomWidget::SPtr openCustomWidget(
std::string title,
WGECamera::ProjectionMode projectionMode,
boost::shared_ptr< WCondition > shutdownCondition ) = 0;
/**
* Instruct the MainWindow to close a custom widget.
* Instruct to close a custom widget.
*
* \param title The title of the widget
*/
virtual void closeCustomWidget( std::string title ) = 0;
/**
* Instruct to close the custom widget.
*
* \param widget the widget to close again.
*/
virtual void closeCustomWidget( WCustomWidget::SPtr widget ) = 0;
protected:
/**
* Flag determining whether the GUI is properly initialized.
......
......@@ -354,6 +354,11 @@ void WQt4Gui::closeCustomWidget( std::string title )
m_mainWindow->closeCustomDockWidget( title );
}
void WQt4Gui::closeCustomWidget( WCustomWidget::SPtr widget )
{
m_mainWindow->closeCustomDockWidget( widget->getTitle() );
}
QSettings& WQt4Gui::getSettings()
{
return *m_settings;
......
......@@ -141,15 +141,20 @@ public:
*/
boost::signals2::signal1< void, std::vector< std::string > >* getLoadButtonSignal();
/**
* Instruct the WMainWindow to open a new custom widget.
/**
* Instruct to open a new custom widget. The specified condition should be the shutdown condition of the module, as the function returns only
* if the widget was created. To ensure that the creation is aborted properly if the module shuts down in the meantime, this condition is
* used.
*
* \note this function blocks until the widget was created. Check the resulting pointer for NULL.
*
* \param title the title of the widget
* \param projectionMode the kind of projection which should be used
* \param shutdownCondition condition to wait for the shutdown of a module
* \param shutdownCondition a condition enforcing abort of widget creation.
*
* \return the created widget
*/
virtual boost::shared_ptr< WCustomWidget > openCustomWidget( std::string title, WGECamera::ProjectionMode projectionMode,
virtual WCustomWidget::SPtr openCustomWidget( std::string title, WGECamera::ProjectionMode projectionMode,
boost::shared_ptr< WCondition > shutdownCondition );
/**
......@@ -159,6 +164,13 @@ public:
*/
virtual void closeCustomWidget( std::string title );
/**
* Instruct the WMainWindow to close a custom widget.
*
* \param widget the widget to close
*/
virtual void closeCustomWidget( WCustomWidget::SPtr widget );
/**
* Returns the current main window instance or NULL if not existent.
*
......
......@@ -31,6 +31,7 @@
WQtCustomDockWidget::WQtCustomDockWidget( std::string title, QWidget* parent, WGECamera::ProjectionMode projectionMode )
: WQtGLDockWidget( QString::fromStdString( title ), QString::fromStdString( title ), parent, projectionMode ),
WCustomWidget( title ),
m_useCount( 1 )
{
setObjectName( QString( "Custom Dock Window " ) + QString::fromStdString( title ) );
......
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