schnapps.h 6.52 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1 2 3
#ifndef _SCHNAPPS_H_
#define _SCHNAPPS_H_

Thery Sylvain's avatar
Thery Sylvain committed
4
#include "dll.h"
Sylvain Thery's avatar
Sylvain Thery committed
5

Pierre Kraemer's avatar
Pierre Kraemer committed
6 7 8
#include "ui_schnapps.h"

#include "types.h"
9

10 11 12
#include "PythonQt.h"
#include "gui/PythonQtScriptingConsole.h"
#include "slot_debug.h"
Sylvain Thery's avatar
Sylvain Thery committed
13
#include <QTextStream>
Pierre Kraemer's avatar
Pierre Kraemer committed
14 15 16

class QVBoxLayout;
class QSplitter;
Sylvain Thery's avatar
Sylvain Thery committed
17 18
class QFile;

Pierre Kraemer's avatar
Pierre Kraemer committed
19 20 21 22 23 24 25 26 27 28 29

namespace CGoGN
{

namespace SCHNApps
{

class ControlDock_CameraTab;
class ControlDock_MapTab;
class ControlDock_PluginTab;

Sylvain Thery's avatar
Sylvain Thery committed
30
class SCHNAPPS_API SCHNApps : public QMainWindow, Ui::SCHNApps
Pierre Kraemer's avatar
Pierre Kraemer committed
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
{
	Q_OBJECT

public:
	SCHNApps(const QString& appPath, PythonQtObjectPtr& pythonContext, PythonQtScriptingConsole& pythonConsole);
	~SCHNApps();

public slots:
	const QString& getAppPath() { return m_appPath; }

	/*********************************************************
	 * MANAGE CAMERAS
	 *********************************************************/

public slots:
	Camera* addCamera(const QString& name);
	Camera* addCamera();
	void removeCamera(const QString& name);

	Camera* getCamera(const QString& name) const;
	const CameraSet& getCameraSet() const { return m_cameras; }

	/*********************************************************
	 * MANAGE VIEWS
	 *********************************************************/
Sylvain Thery's avatar
Sylvain Thery committed
56 57
public:
	void redrawAllViews();
Pierre Kraemer's avatar
Pierre Kraemer committed
58

59

Pierre Kraemer's avatar
Pierre Kraemer committed
60 61 62 63 64 65 66 67 68 69 70 71 72
public slots:
	View* addView(const QString& name);
	View* addView();
	void removeView(const QString& name);

	View* getView(const QString& name) const;
	const ViewSet& getViewSet() const { return m_views; }

	View* getSelectedView() const { return m_selectedView; }
	void setSelectedView(View* view);

	void splitView(const QString& name, Qt::Orientation orientation);

73 74 75 76
	QString saveSplitViewPositions();
	void restoreSplitViewPositions(QString stringStates);


Pierre Kraemer's avatar
Pierre Kraemer committed
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
	/*********************************************************
	 * MANAGE PLUGINS
	 *********************************************************/

public slots:
	void registerPluginsDirectory(const QString& path);

	Plugin* enablePlugin(const QString& pluginName);
	void disablePlugin(const QString& pluginName);

	Plugin* getPlugin(const QString& name) const;
	const PluginSet& getPluginSet() const { return m_plugins; }

	const QMap<QString, QString>& getAvailablePlugins() const { return m_availablePlugins; }

public:
	void addPluginDockTab(Plugin* plugin, QWidget* tabWidget, const QString& tabText);
	void removePluginDockTab(Plugin* plugin, QWidget* tabWidget);

96 97 98
private slots:
	void enablePluginTabWidgets(PluginInteraction* plugin);
	void disablePluginTabWidgets(PluginInteraction* plugin);
Pierre Kraemer's avatar
Pierre Kraemer committed
99 100 101 102 103 104 105 106

	/*********************************************************
	 * MANAGE MAPS
	 *********************************************************/

public slots:
	MapHandlerGen* addMap(const QString& name, unsigned int dim);
	void removeMap(const QString& name);
107 108 109
	MapHandlerGen* duplicateMap(const QString& name, bool properties);


110
	void setSelectedMap(const QString& mapName);
Pierre Kraemer's avatar
Pierre Kraemer committed
111 112 113 114

	MapHandlerGen* getMap(const QString& name) const;
	const MapSet& getMapSet() const { return m_maps; }

115
	void notifySelectedMapChanged(MapHandlerGen* old, MapHandlerGen* cur) { DEBUG_EMIT("selectedMapChanged"); emit(selectedMapChanged(old, cur)); }
Pierre Kraemer's avatar
Pierre Kraemer committed
116 117
	MapHandlerGen* getSelectedMap() const;

118
	unsigned int getCurrentOrbit() const;
119
	void notifySelectedCellSelectorChanged(CellSelectorGen* cs) { DEBUG_EMIT("selectedCellSelectorChanged"); emit(selectedCellSelectorChanged(cs)); }
120 121
	CellSelectorGen* getSelectedSelector(unsigned int orbit) const;

122
	const StaticPointers& getStaticPointers() const { return m_sp; }
123

Pierre Kraemer's avatar
Pierre Kraemer committed
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
	/*********************************************************
	 * MANAGE TEXTURES
	 *********************************************************/

public:
	Texture* getTexture(const QString& image);
	void releaseTexture(const QString& image);

	/*********************************************************
	 * MANAGE MENU ACTIONS
	 *********************************************************/

public:
	void addMenuAction(Plugin* plugin, const QString& menuPath, QAction* action);
	void removeMenuAction(Plugin* plugin, QAction* action);

public slots:
	void aboutSCHNApps();
	void aboutCGoGN();

	void showHideControlDock();
	void showHidePluginDock();
	void showHidePythonDock();

	void loadPythonScriptFromFile(const QString& fileName);

Sylvain Thery's avatar
Sylvain Thery committed
150 151
	void execPythonCmd(const QString& fileName);

Sylvain Thery's avatar
Sylvain Thery committed
152 153 154 155 156 157
	void statusBarMessage(const QString& msg, int msec);

	QString openFileDialog(const QString& title, const QString& dir = QString(), const QString& filter = QString());

	QString saveFileDialog(const QString& title, const QString& dir = QString(), const QString& filter = QString());

158
	void setWindowSize(int w, int h) { this->resize(w, h); }
Sylvain Thery's avatar
Sylvain Thery committed
159

Pierre Kraemer's avatar
Pierre Kraemer committed
160 161 162
private slots:
	void loadPythonScriptFromFileDialog();

Sylvain Thery's avatar
Sylvain Thery committed
163 164 165 166 167 168 169

	/*********************************************************
	* MANAGE PYTHON RECORDING
	*********************************************************/
protected:
	QTextStream* m_pyRecording;
	QFile* m_pyRecFile;
Sylvain Thery's avatar
Sylvain Thery committed
170 171
	QList<QString> m_pyVarNames;
	QString m_pyBuffer;
Sylvain Thery's avatar
Sylvain Thery committed
172 173

private slots:
174
	void pyRecording();
Sylvain Thery's avatar
Sylvain Thery committed
175
	void appendPyRecording();
Sylvain Thery's avatar
Sylvain Thery committed
176
//	void endPyRecording();
Sylvain Thery's avatar
Sylvain Thery committed
177 178 179

public:
	inline QTextStream* pythonStreamRecorder()  { return m_pyRecording; }
Sylvain Thery's avatar
Sylvain Thery committed
180 181
	inline void pythonVarDeclare(const QString& var) { m_pyVarNames.push_back(var); }
	inline void pythonVarsClear() { m_pyVarNames.clear(); }
Sylvain Thery's avatar
Sylvain Thery committed
182

Pierre Kraemer's avatar
Pierre Kraemer committed
183 184 185 186 187 188 189 190 191 192 193
signals:
	void cameraAdded(Camera* camera);
	void cameraRemoved(Camera* camera);

	void viewAdded(View* view);
	void viewRemoved(View* view);
	void selectedViewChanged(View* old, View* cur);

	void mapAdded(MapHandlerGen* map);
	void mapRemoved(MapHandlerGen* map);
	void selectedMapChanged(MapHandlerGen* old, MapHandlerGen* cur);
Pierre Kraemer's avatar
Pierre Kraemer committed
194
	void selectedCellSelectorChanged(CellSelectorGen* cs);
Pierre Kraemer's avatar
Pierre Kraemer committed
195 196 197 198 199

	void pluginAvailableAdded(QString name);
	void pluginEnabled(Plugin* plugin);
	void pluginDisabled(Plugin* plugin);

200
	void schnappsClosing();
Sylvain Thery's avatar
Sylvain Thery committed
201

Pierre Kraemer's avatar
Pierre Kraemer committed
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
protected:
	QString m_appPath;
	PythonQtObjectPtr& m_pythonContext;
	PythonQtScriptingConsole& m_pythonConsole;

	QDockWidget* m_controlDock;
	QTabWidget* m_controlDockTabWidget;
	ControlDock_CameraTab* m_controlCameraTab;
	ControlDock_MapTab* m_controlMapTab;
	ControlDock_PluginTab* m_controlPluginTab;

	QDockWidget* m_pluginDock;
	QTabWidget* m_pluginDockTabWidget;

	QDockWidget* m_pythonDock;

	QVBoxLayout* m_centralLayout;
	QSplitter* m_rootSplitter;
	bool b_rootSplitterInitialized;

	View* m_firstView;
	View* m_selectedView;

	QMap<QString, QString> m_availablePlugins;
	QMap<Plugin*, QList<QWidget*> > m_pluginTabs;
	QMap<Plugin*, QList<QAction*> > m_pluginMenuActions;

Sylvain Thery's avatar
Sylvain Thery committed
229 230 231
	QMap<int, QString > m_pythonShortCuts;


Pierre Kraemer's avatar
Pierre Kraemer committed
232 233 234 235 236 237
	CameraSet m_cameras;
	ViewSet m_views;
	PluginSet m_plugins;
	MapSet m_maps;

	TextureSet m_textures;
238 239

	StaticPointers m_sp;
Sylvain Thery's avatar
Sylvain Thery committed
240 241

	void closeEvent(QCloseEvent *event);
Sylvain Thery's avatar
Sylvain Thery committed
242 243


Pierre Kraemer's avatar
Pierre Kraemer committed
244 245 246 247 248 249 250
};

} // namespace SCHNApps

} // namespace CGoGN

#endif