OpenWalnut  1.4.0
WUI.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 WUI_H
26 #define WUI_H
27 
28 #include <string>
29 
30 #include <boost/shared_ptr.hpp>
31 
32 #include "../common/WFlag.h"
33 #include "../graphicsEngine/WGECamera.h"
34 #include "WCustomWidget.h"
35 
36 class WDataSet;
37 
38 /**
39  * This library implements the user interface for OpenWalnut.
40  *
41  * \defgroup ui UI
42  */
43 
44 /**
45  * This class prescribes the interface to the UI. It basically is an abstract class defining the interface common to all possible
46  * UI implementations.
47  *
48  * \ingroup ui
49  */
50 class WUI : public boost::enable_shared_from_this< WUI >
51 {
52 public:
53  /**
54  * Constructor.
55  *
56  * \param argc number of arguments given on command line.
57  * \param argv arguments given on command line.
58  */
59  WUI( int argc, char** argv );
60 
61  /**
62  * Destructor.
63  */
64  virtual ~WUI();
65 
66  /**
67  * Returns the init flag.
68  *
69  * \return Reference to the flag.
70  */
71  virtual const WFlag< bool >& isInitialized() const;
72 
73  /**
74  * Runs the UI. All initialization should be done here.
75  *
76  * \return the return code.
77  */
78  virtual int run() = 0;
79 
80  /**
81  * Instruct to open a new custom widget. The specified condition should be the shutdown condition of the module, as the function returns only
82  * if the widget was created. To ensure that the creation is aborted properly if the module shuts down in the meantime, this condition is
83  * used.
84  *
85  * \note this function blocks until the widget was created. Check the resulting pointer for NULL.
86  *
87  * \param title the title of the widget
88  * \param projectionMode the kind of projection which should be used
89  * \param shutdownCondition a condition enforcing abort of widget creation.
90  *
91  * \return the created widget
92  */
94  std::string title,
95  WGECamera::ProjectionMode projectionMode,
96  boost::shared_ptr< WCondition > shutdownCondition ) = 0;
97 
98  /**
99  * Instruct to close a custom widget.
100  *
101  * \param title The title of the widget
102  */
103  virtual void closeCustomWidget( std::string title ) = 0;
104 
105  /**
106  * Instruct to close the custom widget.
107  *
108  * \param widget the widget to close again.
109  */
110  virtual void closeCustomWidget( WCustomWidget::SPtr widget ) = 0;
111 
112 protected:
113  /**
114  * Flag determining whether the UI is properly initialized.
115  */
117 
118  /**
119  * Number of command line arguments given.
120  */
121  int m_argc;
122 
123  /**
124  * Command line arguments given.
125  */
126  char** m_argv;
127 };
128 
129 #endif // WUI_H
130