OpenWalnut  1.5.0dev
WUIQtWidgetFactory.h
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 #ifndef WUIQTWIDGETFACTORY_H
26 #define WUIQTWIDGETFACTORY_H
27 
28 #include <memory>
29 #include <string>
30 
31 
32 #include "core/common/WCondition.h"
33 #include "core/ui/WUIWidgetFactory.h"
34 
35 class WMainWindow;
36 class WUIQtWidgetBase;
37 
38 /**
39  * Implementation of \ref WUIWidgetFactory.
40  */
42 {
43 public:
44  /**
45  * Convenience typedef for a std::shared_ptr< WUIQtWidgetFactory >.
46  */
47  typedef std::shared_ptr< WUIQtWidgetFactory > SPtr;
48 
49  /**
50  * Convenience typedef for a std::shared_ptr< const WUIQtWidgetFactory >.
51  */
52  typedef std::shared_ptr< const WUIQtWidgetFactory > ConstSPtr;
53 
54  /**
55  * Default constructor.
56  *
57  * \param mainWindow the main window instance
58  */
59  explicit WUIQtWidgetFactory( WMainWindow* mainWindow );
60 
61  /**
62  * Destructor.
63  */
64  virtual ~WUIQtWidgetFactory();
65 
66  /**
67  * Query whether the WUI instance supports the WUI Widget interface properly as UIs can simply ignore the WUIWidgetFactory calls done in
68  * modules. This is used mainly by \ref WUIRequirement.
69  *
70  * \return always true. QtGui supports the WUI widget interface
71  */
72  virtual bool implementsUI() const;
73 
74  /**
75  * Convert the given WUIWidgetBase to the corresponding WUIQtWidgetBase.
76  *
77  * \param widget the widget to convert
78  *
79  * \return the converted widget.
80  */
81  static std::shared_ptr< WUIQtWidgetBase > getAsQtWidgetBase( WUIWidgetBase::SPtr widget );
82 protected:
83  /**
84  * Create a grid widget. This kind of widget is basically empty. Add others to it. The widgets are initially invisible. Use
85  * WUIWidgetBase::show() to make them visible.
86  * If a widget with this name already exists, it will be returned.
87  *
88  * \note this function blocks until the widget was created. Check the resulting pointer for NULL.
89  *
90  * \param title the title
91  * \param parent the parent widget which will contain this widget. Can be NULL.
92  *
93  * \return the widget. Might be NULL if something goes wrong.
94  */
95  virtual WUIGridWidget::SPtr createGridWidgetImpl( const std::string& title, WUIWidgetBase::SPtr parent = WUIWidgetBase::SPtr() ) const;
96  /**
97  * Implementation of \ref createTabbedWidget.
98  *
99  * \param title the title
100  * \param parent the parent widget which will contain this widget. Can be NULL.
101  *
102  * \return the widget. Might be NULL if something goes wrong.
103  */
104  virtual WUITabbedWidget::SPtr createTabbedWidgetImpl( const std::string& title, WUIWidgetBase::SPtr parent = WUIWidgetBase::SPtr() ) const;
105 
106  /**
107  * Create a property widget. Parentless widgets are initially invisible. Use
108  * WUIWidgetBase::show() to make them visible.
109  *
110  * \note this function blocks until the widget was created. Check the resulting pointer for NULL.
111  *
112  * \param title the title
113  * \param properties the property group
114  * \param parent the parent widget which will contain this widget. Can be NULL.
115  *
116  * \return the widget. Might be NULL if something goes wrong.
117  */
118  virtual WUIPropertyGroupWidget::SPtr createPropertyGroupWidgetImpl( const std::string& title, WPropGroup properties,
119  WUIWidgetBase::SPtr parent = WUIWidgetBase::SPtr() ) const;
120 
121  /**
122  * Instruct to open a new view widget. The specified condition should be the shutdown condition of the module, as the function returns only
123  * if the widget was created. To ensure that the creation is aborted properly if the module shuts down in the meantime, this condition is
124  * used. The widgets are initially invisible. Use WUIWidgetBase::show() to make them visible.
125  * If a widget with this name already exists, it will be returned.
126  *
127  * \note this function blocks until the widget was created. Check the resulting pointer for NULL.
128  *
129  * \param title the title of the widget
130  * \param projectionMode the kind of projection which should be used
131  * \param abordCondition a condition enforcing abort of widget creation. Can be NULL
132  * \param parent the parent widget which will contain this widget. Can be NULL.
133  *
134  * \return the created widget
135  */
137  std::string title,
138  WGECamera::ProjectionMode projectionMode,
139  std::shared_ptr< WCondition > abordCondition = WCondition::SPtr(),
140  WUIWidgetBase::SPtr parent = WUIWidgetBase::SPtr() ) const;
141 private:
142  /**
143  * The main window instance.
144  */
146 };
147 
148 #endif // WUIQTWIDGETFACTORY_H
149 
std::shared_ptr< WCondition > SPtr
Shared pointer type for WCondition.
Definition: WCondition.h:48
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 WUIWidgetBase.
Implementation of WUIWidgetFactory.
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.
std::shared_ptr< const WUIQtWidgetFactory > ConstSPtr
Convenience typedef for a std::shared_ptr< const WUIQtWidgetFactory >.
static std::shared_ptr< WUIQtWidgetBase > getAsQtWidgetBase(WUIWidgetBase::SPtr widget)
Convert the given WUIWidgetBase to the corresponding WUIQtWidgetBase.
virtual ~WUIQtWidgetFactory()
Destructor.
std::shared_ptr< WUIQtWidgetFactory > SPtr
Convenience typedef for a std::shared_ptr< WUIQtWidgetFactory >.
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.