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