window.h 10.3 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 13 14 15 16 17 18

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

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

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

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

	/**
	 * \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
42
	QTabWidget* getDockTabWidget();
43 44

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

	/**
	 * \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
65 66 67 68 69
	void removeTabInDock(QWidget* tabWidget);

	/*********************************************************
	 * MANAGE MENU ACTIONS
	 *********************************************************/
70 71

	/**
Pierre Kraemer's avatar
Pierre Kraemer committed
72
	 * \fn bool addMenuAction(const QString& menuPath, QAction* action)
73 74 75
	 * \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
76
	 * \param action a pointer to the allocated action to add in the menu. All the details on that action (such as
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
	 *          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
93
	 *  This method is called by Plugin methods
94 95 96 97
	 *
	 *  \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
98
	 *    depending on the error. This error can be shown with Error::showError
99 100
	 *
	 * \see deleteMenuAction()
Pierre Kraemer's avatar
Pierre Kraemer committed
101
	 * \see Plugin::addMenuAction()
102
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
103
	bool addMenuAction(const QString& menuPath, QAction* action);
104 105

	/**
Pierre Kraemer's avatar
Pierre Kraemer committed
106
	 * \fn void deleteMenuAction(QAction* action)
107 108
	 * \brief delete an action from the menu bar
	 *
Pierre Kraemer's avatar
Pierre Kraemer committed
109
	 * \param action pointer to the allocated action to delete.
110 111 112 113 114
	 *
	 *  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
115
	 *  This method is called by Plugin methods
116 117
	 *
	 *  \see addMenuAction()
Pierre Kraemer's avatar
Pierre Kraemer committed
118
	 *  \see Plugin::removeMenuAction()
119
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
120 121 122 123 124 125 126
	void removeMenuAction(QAction* action);

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

	bool addToolbarAction(QAction* action);
127

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

	/*********************************************************
	 * MANAGE PLUGINS
	 *********************************************************/
133 134 135 136 137 138 139 140

	/**
	 * \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
141
	 * where the extension ('.so', '.dylib') and the prefix 'lib' were removed.
142 143 144 145 146 147
	 *
	 *  <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
148 149
	 * 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.
150
	 *
Pierre Kraemer's avatar
Pierre Kraemer committed
151
	 * \warning In the program this method is called under specific and controlled circumstances, you should probably not call it.
152
	 *
Pierre Kraemer's avatar
Pierre Kraemer committed
153
	 * \return a boolean whether the loading succeeded or not.
154 155
	 *
	 * If the function failed, the error code ( Error::code ) is affected with a value
Pierre Kraemer's avatar
Pierre Kraemer committed
156
	 * depending on the error. This error can be shown with Error::showError
157 158
	 *
	 * \see unloadPlugin()
Pierre Kraemer's avatar
Pierre Kraemer committed
159 160 161
	 * \see getPlugins()
	 * \see Plugin::enable()
	 */
162
	Plugin* loadPlugin(QString pluginFilePath);
163 164 165 166 167 168 169

	/**
	 * \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
170
	 * The Plugin of the given name is dereferenced and deleted, if it exists and was previously
171 172
	 * referenced, if not, the method does nothing.
	 *
Pierre Kraemer's avatar
Pierre Kraemer committed
173 174
	 * 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.
175 176 177 178
	 *
	 * \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
179
	 * \see getPlugins()
180 181
	 * \see Plugin::disable()
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
182
	void unloadPlugin(const QString& pluginName);
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201

	/**
	 * \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
202 203 204
	 */
//	Plugin *checkPluginDependencie(QString name, Plugin *dependantPlugin);

205
	Plugin* getPlugin(const QString& name);
206 207
	QList<Plugin*> getPluginsList() { return h_plugins.values(); }
	const PluginHash& getPluginsHash() { return h_plugins; }
208

Pierre Kraemer's avatar
Pierre Kraemer committed
209
	/*********************************************************
210
	 * MANAGE VIEWS
Pierre Kraemer's avatar
Pierre Kraemer committed
211 212
	 *********************************************************/

213
	View* addView(const QString& name);
214
	View* addView();
215 216
	void removeView(const QString& name);
	View* getView(const QString& name);
217 218
	QList<View*> getViewsList() { return h_views.values(); }
	const ViewHash& getViewsHash() { return h_views; }
219

Pierre Kraemer's avatar
Pierre Kraemer committed
220 221 222 223
	/*********************************************************
	 * MANAGE CAMERAS
	 *********************************************************/

224
	Camera* addCamera(const QString& name);
225
	Camera* addCamera();
226 227
	void removeCamera(const QString& name);
	Camera* getCamera(const QString& name);
228 229
	QList<Camera*> getCamerasList() { return h_cameras.values(); }
	const CameraHash& getCamerasHash() { return h_cameras; }
Pierre Kraemer's avatar
Pierre Kraemer committed
230

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

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

241 242 243 244 245 246 247 248 249 250 251 252 253
//	template<typename T>
//	T* getReferencedMap(QString map_name){
//		MapHash::iterator it;
//		if((it=h_map.find(map_name))!=h_map.end()){
//			return ((T*)(*it));
//		}
//		else{
//			System::Error::code= System::Error::MAP_UNREFERENCED_f(map_name);
//			return NULL;
//		}
//	}

protected:
Pierre Kraemer's avatar
Pierre Kraemer committed
254
	bool m_initialization;
255

Pierre Kraemer's avatar
Pierre Kraemer committed
256 257
	QVBoxLayout* m_verticalLayout;
	SplitArea* m_splitArea;
258

259 260
	View* m_firstView;

Pierre Kraemer's avatar
Pierre Kraemer committed
261 262
	QDockWidget* m_dock;
	QTabWidget* m_dockTabWidget;
263

Pierre Kraemer's avatar
Pierre Kraemer committed
264
	PluginHash h_plugins;
265
	ViewHash h_views;
Pierre Kraemer's avatar
Pierre Kraemer committed
266
	CameraHash h_cameras;
267
	MapHash h_maps;
268

Pierre Kraemer's avatar
Pierre Kraemer committed
269
	PluginDialog* m_pluginDialog;
Pierre Kraemer's avatar
Pierre Kraemer committed
270
	CameraDialog* m_cameraDialog;
Pierre Kraemer's avatar
Pierre Kraemer committed
271

272 273 274 275 276 277 278 279 280 281 282 283
	/**
	 * \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
	 *
284
	 * Make a call with the right parameters to the dialog class
285 286 287 288 289 290 291 292
	 * GLVSelector and show this dialog.
	 *
	 * This method is meant to be called when the user press
	 * CTRL+Shift+M.
	 */
	void moveView();

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

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

305
	/**
306 307 308
	 * \fn void cb_managePlugins()
	 * \brief method called when the "Plugins" action is triggered.
	 * Show the plugins management dialog
309
	 */
310
	void cb_managePlugins();
311 312

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

319 320 321 322 323 324
	/**
	 * \fn void cb_manageCameras()
	 * \brief method called when the "Cameras" action is triggered.
	 * Show the cameras management dialog:
	 */
	void cb_manageCameras();
325 326 327
};

#endif