OpenWalnut  1.5.0dev
WUIQtWidgetFactory.cpp
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #include <memory>
26 #include <string>
27 
28 #include <QApplication>
29 
30 #include "../WMainWindow.h"
31 #include "WUIQtGridWidget.h"
32 #include "WUIQtPropertyGroupWidget.h"
33 #include "WUIQtTabbedWidget.h"
34 #include "WUIQtViewWidget.h"
35 #include "WUIQtWidgetFactory.h"
36 
39  m_mainWindow( mainWindow )
40 {
41  // initialize members
42 }
43 
45 {
46  // cleanup
47 }
48 
50 {
51  return true;
52 }
53 
55 {
56  WUIQtWidgetBase::SPtr w = std::dynamic_pointer_cast< WUIQtWidgetBase >( widget );
57  return w;
58 }
59 
61 {
62  WUIQtGridWidget::SPtr widget( new WUIQtGridWidget( title, m_mainWindow, getAsQtWidgetBase( parent ) ) );
63  WUIWidgetFactory::setParent( widget, parent ); // NOTE: this is the parent on the WUI side
64  widget->realize();
65  return widget;
66 }
67 
69 {
71  WUIWidgetFactory::setParent( widget, parent ); // NOTE: this is the parent on the WUI side
72  widget->realize();
73  return widget;
74 }
75 
77  WUIWidgetBase::SPtr parent ) const
78 {
79  WUIQtPropertyGroupWidget::SPtr widget( new WUIQtPropertyGroupWidget( title, properties, m_mainWindow, getAsQtWidgetBase( parent ) ) );
80  WUIWidgetFactory::setParent( widget, parent ); // NOTE: this is the parent on the WUI side
81  widget->realize();
82  return widget;
83 }
84 
86  std::string title,
87  WGECamera::ProjectionMode projectionMode,
88  std::shared_ptr< WCondition > abortCondition,
89  WUIWidgetBase::SPtr parent ) const
90 {
91  WUIQtViewWidget::SPtr widget( new WUIQtViewWidget( title, projectionMode, m_mainWindow, getAsQtWidgetBase( parent ) ) );
92  WUIWidgetFactory::setParent( widget, parent ); // NOTE: this is the parent on the WUI side
93  widget->realize( abortCondition );
94  return widget;
95 }
ProjectionMode
List of possible camera modes.
Definition: WGECamera.h:44
This class contains the main window and the layout of the widgets within the window.
Definition: WMainWindow.h:66
std::shared_ptr< WUIGridWidget > SPtr
Convenience typedef for a std::shared_ptr< WUIGridWidget >.
Definition: WUIGridWidget.h:46
std::shared_ptr< WUIPropertyGroupWidget > SPtr
Convenience typedef for a std::shared_ptr< WUIPropertyGroupWidget >.
Implementation of WUIGridWidget.
std::shared_ptr< WUIQtGridWidget > SPtr
Convenience typedef for a std::shared_ptr< WUIQtGridWidget >.
Implementation of WUIPropertyGroupWidget.
std::shared_ptr< WUIQtPropertyGroupWidget > SPtr
Convenience typedef for a std::shared_ptr< WUIQtPropertyGroupWidget >.
Implementation of WUITabbedWidget.
std::shared_ptr< WUIQtTabbedWidget > SPtr
Convenience typedef for a std::shared_ptr< WUIQtTabbedWidget >.
Implementation of WUIViewWidget.
std::shared_ptr< WUIQtViewWidget > SPtr
Convenience typedef for a std::shared_ptr< WUIQtViewWidget >.
std::shared_ptr< WUIQtWidgetBase > SPtr
Convenience typedef for a std::shared_ptr< WUIQtWidgetBase >.
WUIQtWidgetFactory(WMainWindow *mainWindow)
Default constructor.
virtual WUITabbedWidget::SPtr createTabbedWidgetImpl(const std::string &title, WUIWidgetBase::SPtr parent=WUIWidgetBase::SPtr()) const
Implementation of createTabbedWidget.
virtual WUIGridWidget::SPtr createGridWidgetImpl(const std::string &title, WUIWidgetBase::SPtr parent=WUIWidgetBase::SPtr()) const
Create a grid widget.
virtual WUIPropertyGroupWidget::SPtr createPropertyGroupWidgetImpl(const std::string &title, WPropGroup properties, WUIWidgetBase::SPtr parent=WUIWidgetBase::SPtr()) const
Create a property widget.
static std::shared_ptr< WUIQtWidgetBase > getAsQtWidgetBase(WUIWidgetBase::SPtr widget)
Convert the given WUIWidgetBase to the corresponding WUIQtWidgetBase.
virtual ~WUIQtWidgetFactory()
Destructor.
virtual bool implementsUI() const
Query whether the WUI instance supports the WUI Widget interface properly as UIs can simply ignore th...
WMainWindow * m_mainWindow
The main window instance.
virtual WUIViewWidget::SPtr createViewWidgetImpl(std::string title, WGECamera::ProjectionMode projectionMode, std::shared_ptr< WCondition > abordCondition=WCondition::SPtr(), WUIWidgetBase::SPtr parent=WUIWidgetBase::SPtr()) const
Instruct to open a new view widget.
std::shared_ptr< WUITabbedWidget > SPtr
Convenience typedef for a std::shared_ptr< WUITabbedWidget >.
std::shared_ptr< WUIViewWidget > SPtr
Abbreviation for a shared pointer on a instance of this class.
Definition: WUIViewWidget.h:72
std::shared_ptr< WUIWidgetBase > SPtr
Convenience typedef for a std::shared_ptr< WUIWidgetBase >.
Definition: WUIWidgetBase.h:51
Create instances of WUI widgets.
void setParent(WUIWidgetBase::SPtr widget, WUIWidgetBase::SPtr parent) const
Set the parent of a widget and notify parent about new child widget.