window.h 10.6 KB
Newer Older
1
2
3
4
5
#ifndef _WINDOW_H_
#define _WINDOW_H_

#include "ui_window.h"

Pierre Kraemer's avatar
Pierre Kraemer committed
6
#include "system.h"
7
#include <QVBoxLayout>
8

9
class SplitArea;
Pierre Kraemer's avatar
Pierre Kraemer committed
10
11
class PluginDialog;
class CameraDialog;
12
class Texture;
13
14
15
16
17
18
19

class Window : public QMainWindow, Ui::Window
{
	Q_OBJECT

public:
	/**
20
	 * \fn Window(QWidget* parent = NULL)
21
22
23
24
	 * \brief Default (and unique) constructor
	 *
	 * \param parent the parent of the window
	 */
25
26
	Window(QWidget* parent = NULL);

27
28
29
30
31
32
	/**
	 * \fn ~Window()
	 * \brief the class destructor
	 */
	~Window();

Pierre Kraemer's avatar
Pierre Kraemer committed
33
34
35
	/*********************************************************
	 * MANAGE DOCK
	 *********************************************************/
36
37
38
39
40
41
42

	/**
	 * \fn QTabWidget* getDockTabWidget()
	 * \brief Accessor to the QTabWidget of this interface
	 *
	 * \return a pointer to the TabWidget, NULL if not allocated yet
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
43
	QTabWidget* getDockTabWidget();
44
45

	/**
Pierre Kraemer's avatar
Pierre Kraemer committed
46
	 * \fn void addTabInDock(QWidget* tabWidget, const QString& tabText)
47
48
	 * \brief Adds the widget as a new tab in the interface's dock
	 *
Pierre Kraemer's avatar
Pierre Kraemer committed
49
	 * \param tabWidget the created and allocated pointer to the QWidget to add in the dock
50
51
52
53
	 * \param tabText The text that will appears in the tab label
	 *
	 * \see removeTabInDock()
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
54
	void addTabInDock(QWidget* tabWidget, const QString& tabText);
55
56
57
58
59
60
61
62
63
64
65

	/**
	 * \fn void removeTabInDock(QWidget* tabWidget)
	 * \brief removes a given widget from the tab
	 *
	 * \param tabWidget the reference to the widget you want to remove
	 *
	 * If the widget does belong to the tab, it will be destroyed.
	 *
	 * \see addWidgetInDockTab()
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
66
67
68
69
70
	void removeTabInDock(QWidget* tabWidget);

	/*********************************************************
	 * MANAGE MENU ACTIONS
	 *********************************************************/
71
72

	/**
Pierre Kraemer's avatar
Pierre Kraemer committed
73
	 * \fn bool addMenuAction(const QString& menuPath, QAction* action)
74
75
76
	 * \brief adds an action in the program menu bar
	 *
	 * \param menuPath the menu path (see details below) to specify a location for the action in the menu.
Pierre Kraemer's avatar
Pierre Kraemer committed
77
	 * \param action a pointer to the allocated action to add in the menu. All the details on that action (such as
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
	 *          QObject::connect() calls) are not dealt in this function.
	 *
	 *  The menu path is a string used to specify the location of the new action in the menu bar.
	 *  In such path every menu step of the path should be separate by ';'. The action is the last substring after
	 *  the last ';', and will be added in the menu with that name. All non-existing menu specified in the path
	 *  shall be created.
	 *
	 *  <b>Example 1:</b> if you want to add an entry <em>"action"</em> to the existing menu <em>"Plugins"</em> the
	 *                  menu path shall be: <em>Plugins;action</em>
	 *
	 *  <b>Example 2:</b> if you want to add an entry <em>"action"</em> in a new menu <em>"config"</em> that is also a
	 *                  submenu of a new menu <em>"Settings"</em>, the menu path
	 *                  shall be: <em>Settings;config;action</em>
	 *
	 *  A new action should at least belong to one menu (already existing or not). Otherwise the method will fail.
	 *
Pierre Kraemer's avatar
Pierre Kraemer committed
94
	 *  This method is called by Plugin methods
95
96
97
98
	 *
	 *  \return a boolean whether the method succeeded or not.
	 *
	 * If the function failed, the error code ( Error::code ) is affected with a value
Pierre Kraemer's avatar
Pierre Kraemer committed
99
	 *    depending on the error. This error can be shown with Error::showError
100
101
	 *
	 * \see deleteMenuAction()
Pierre Kraemer's avatar
Pierre Kraemer committed
102
	 * \see Plugin::addMenuAction()
103
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
104
	bool addMenuAction(const QString& menuPath, QAction* action);
105
106

	/**
Pierre Kraemer's avatar
Pierre Kraemer committed
107
	 * \fn void deleteMenuAction(QAction* action)
108
109
	 * \brief delete an action from the menu bar
	 *
Pierre Kraemer's avatar
Pierre Kraemer committed
110
	 * \param action pointer to the allocated action to delete.
111
112
113
114
115
	 *
	 *  If this action was the only action remaining in a menu, this menu will also be deleted.
	 *
	 *  \warning DO NOT use this method with an action that hasn't been added with addMenuAction()
	 *
Pierre Kraemer's avatar
Pierre Kraemer committed
116
	 *  This method is called by Plugin methods
117
118
	 *
	 *  \see addMenuAction()
Pierre Kraemer's avatar
Pierre Kraemer committed
119
	 *  \see Plugin::removeMenuAction()
120
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
121
122
123
124
125
126
127
	void removeMenuAction(QAction* action);

	/*********************************************************
	 * MANAGE TOOLBAR ACTIONS
	 *********************************************************/

	bool addToolbarAction(QAction* action);
128

Pierre Kraemer's avatar
Pierre Kraemer committed
129
130
	void removeToolbarAction(QAction* action);

131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
	/*********************************************************
	 * MANAGE CAMERAS
	 *********************************************************/

	Camera* addCamera(const QString& name);
	Camera* addCamera();
	void removeCamera(const QString& name);
	Camera* getCamera(const QString& name);
	QList<Camera*> getCamerasList() { return h_cameras.values(); }
	const CameraHash& getCamerasHash() { return h_cameras; }

	/*********************************************************
	 * MANAGE VIEWS
	 *********************************************************/

	View* addView(const QString& name);
	View* addView();
	void removeView(const QString& name);
	View* getView(const QString& name);
	QList<View*> getViewsList() { return h_views.values(); }
	const ViewHash& getViewsHash() { return h_views; }

Pierre Kraemer's avatar
Pierre Kraemer committed
153
154
155
	/*********************************************************
	 * MANAGE PLUGINS
	 *********************************************************/
156
157
158
159
160
161
162
163

	/**
	 * \fn bool loadPlugin(QString pluginPath)
	 * \brief Loads and references a Plugin
	 *
	 * \param pluginPath the absolute path of the Plugin location
	 *
	 * The Plugin is loaded and referenced under a name that is the Plugin file name
Pierre Kraemer's avatar
Pierre Kraemer committed
164
	 * where the extension ('.so', '.dylib') and the prefix 'lib' were removed.
165
166
167
168
169
170
	 *
	 *  <b>Example:</b> <em>/path/libExample.so</em> will be referenced as <em>Example</em>
	 *
	 * You have to make sure that a Plugin file with a similar name hasn't been loaded yet, otherwise
	 * the loading will fail.
	 *
Pierre Kraemer's avatar
Pierre Kraemer committed
171
172
	 * This method calls the Plugin::enable() method of the concerned Plugin. That is why
	 * when Plugin are written, this method is overriden and used as an initialization method.
173
	 *
Pierre Kraemer's avatar
Pierre Kraemer committed
174
	 * \warning In the program this method is called under specific and controlled circumstances, you should probably not call it.
175
	 *
Pierre Kraemer's avatar
Pierre Kraemer committed
176
	 * \return a boolean whether the loading succeeded or not.
177
178
	 *
	 * If the function failed, the error code ( Error::code ) is affected with a value
Pierre Kraemer's avatar
Pierre Kraemer committed
179
	 * depending on the error. This error can be shown with Error::showError
180
181
	 *
	 * \see unloadPlugin()
Pierre Kraemer's avatar
Pierre Kraemer committed
182
183
184
	 * \see getPlugins()
	 * \see Plugin::enable()
	 */
185
	Plugin* loadPlugin(QString pluginFilePath);
186
187
188
189
190
191
192

	/**
	 * \fn void unloadPlugin(QString pluginName)
	 * \brief Unload the Plugin of a given name
	 *
	 * \param pluginName the name under which the Plugin is referenced
	 *
Pierre Kraemer's avatar
Pierre Kraemer committed
193
	 * The Plugin of the given name is dereferenced and deleted, if it exists and was previously
194
195
	 * referenced, if not, the method does nothing.
	 *
Pierre Kraemer's avatar
Pierre Kraemer committed
196
197
	 * This method calls the Plugin::disable() method of the concerned Plugin. That is why,
	 * when Plugin are written, this method is overriden and used as a destruction method.
198
199
200
201
	 *
	 * \warning In the program this method is called under specific and controlled circumstances, you should probably not call it.
	 *
	 * \see loadPlugin()
Pierre Kraemer's avatar
Pierre Kraemer committed
202
	 * \see getPlugins()
203
204
	 * \see Plugin::disable()
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
205
	void unloadPlugin(const QString& pluginName);
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224

	/**
	 * \fn Plugin* checkPluginDependencie(QString name, Plugin* dependantPlugin)
	 * \brief checks for a dependencie Plugin, and set the dependencie link for the found Plugin
	 *
	 * \param name the name of the Plugin you have to check the existence in order to make a dependencie
	 * \param dependantPlugin a reference to the Plugin that asks for the dependencie that will be set as a
	 *          dependant Plugin for the found Plugin
	 *
	 * \warning In the program this method is called under specific and controlled circumstances
	 *          by the Plugins you should probably not call it.
	 *
	 * \return a pointer to the found dependencie Plugin, NULL if this Plugin wasn't referenced
	 *
	 * If the function failed, the error code ( Error::code ) is affected with a value
	     depending on the error. This error can be shown with Error::showError
	 *
	 * \see loadPlugin()
	 * \see VisualPlugin::addDependencie()
Pierre Kraemer's avatar
Pierre Kraemer committed
225
226
227
	 */
//	Plugin *checkPluginDependencie(QString name, Plugin *dependantPlugin);

228
	Plugin* getPlugin(const QString& name);
229
230
	QList<Plugin*> getPluginsList() { return h_plugins.values(); }
	const PluginHash& getPluginsHash() { return h_plugins; }
231

232
233
234
	/*********************************************************
	 * MANAGE MAPS
	 *********************************************************/
Pierre Kraemer's avatar
Pierre Kraemer committed
235

236
237
238
	bool addMap(const QString& name, MapHandler* map);
	void removeMap(const QString& name);
	MapHandler* getMap(const QString& name);
239
240
	QList<MapHandler*> getMapsList() { return h_maps.values(); }
	const MapHash& getMapsHash() { return h_maps; }
Pierre Kraemer's avatar
Pierre Kraemer committed
241

242
243
244
245
246
247
	/*********************************************************
	 * MANAGE TEXTURES
	 *********************************************************/

	Texture* getTexture(const QString& image);
	void releaseTexture(const QString& image);
248
249

protected:
Pierre Kraemer's avatar
Pierre Kraemer committed
250
	bool m_initialization;
251

Pierre Kraemer's avatar
Pierre Kraemer committed
252
253
	QVBoxLayout* m_verticalLayout;
	SplitArea* m_splitArea;
254

255
256
	View* m_firstView;

Pierre Kraemer's avatar
Pierre Kraemer committed
257
258
	QDockWidget* m_dock;
	QTabWidget* m_dockTabWidget;
259

Pierre Kraemer's avatar
Pierre Kraemer committed
260
	PluginHash h_plugins;
261
	ViewHash h_views;
Pierre Kraemer's avatar
Pierre Kraemer committed
262
	CameraHash h_cameras;
263
	MapHash h_maps;
264

265
266
	TextureHash h_textures;

Pierre Kraemer's avatar
Pierre Kraemer committed
267
	PluginDialog* m_pluginDialog;
Pierre Kraemer's avatar
Pierre Kraemer committed
268
	CameraDialog* m_cameraDialog;
Pierre Kraemer's avatar
Pierre Kraemer committed
269

270
271
272
273
274
275
276
277
278
279
280
281
	/**
	 * \var bool keys[3]
	 * \brief a static tab to store state of some keys (here: M, Shift and CTRL)
	 */
	bool keys[3];
	void keyPressEvent(QKeyEvent *event);
	void keyReleaseEvent(QKeyEvent *event);

	/**
	 * \fn void moveView()
	 * \brief shows a reordering dialog for the Views
	 *
282
	 * Make a call with the right parameters to the dialog class
283
284
285
286
287
288
289
290
	 * GLVSelector and show this dialog.
	 *
	 * This method is meant to be called when the user press
	 * CTRL+Shift+M.
	 */
	void moveView();

public slots:
291
292
293
294
295
296
	/**
	 * \fn void cb_about_SCHNApps();
	 * \brief function that is called when the "about SCHNApps" menu action is triggered
	 */
	void cb_aboutSCHNApps();

297
298
299
300
	/**
	 * \fn void cb_about_CGoGN();
	 * \brief function that is called when the "about CGOGN" menu action is triggered
	 */
301
302
	void cb_aboutCGoGN();

303
	/**
304
305
306
	 * \fn void cb_manageCameras()
	 * \brief method called when the "Cameras" action is triggered.
	 * Show the cameras management dialog:
307
	 */
308
	void cb_manageCameras();
309
310

	/**
311
312
	 * \fn void cb_manageViews()
	 * \brief method called when the "Views" action is triggered.
313
	 * Show the scenes management dialog:
314
	 */
315
	void cb_manageViews();
316

317
	/**
318
319
320
	 * \fn void cb_managePlugins()
	 * \brief method called when the "Plugins" action is triggered.
	 * Show the plugins management dialog
321
	 */
322
323
324
325
326
327
328
329
330
	void cb_managePlugins();

signals:
	void cameraAdded(Camera* camera);
	void cameraRemoved(Camera* camera);

	void viewAdded(View* view);
	void viewRemoved(View* view);

331
	void mapAdded(MapHandler* map);
332
333
334
335
	void mapRemoved(MapHandler* map);

	void pluginAdded(Plugin* plugin);
	void pluginRemoved(Plugin* plugin);
336
337
338
};

#endif