MorphoGraphX
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MorphoGraphX.hpp
1 #ifndef MORPHOGRAPHX_H
2 #define MORPHOGRAPHX_H
3 typedef unsigned short ushort;
4 typedef unsigned int uint;
5 
6 #include <Config.hpp>
7 
8 #include <Misc.hpp>
9 #include <Geometry.hpp>
10 #include <CutSurf.hpp>
11 #include <Process.hpp>
12 #include <TaskEditDlg.hpp>
13 
14 #include <QtGui>
15 #include <string.h>
16 #include <QMutex>
17 #include <QTime>
18 #include <QPointer>
19 
20 #include <ui_GUI.h>
21 #include <ui_EditParms.h>
22 #include <ui_ProcessDocs.h>
23 
24 class QDragEnterEvent;
25 class QDropEvent;
26 class QCloseEvent;
27 class ProcessParmsModel;
28 class Library;
29 class QFileSystemWatcher;
30 class QAction;
31 class PathEditorDlg;
32 class LabelEditorDlg;
33 
34 namespace mgx {
35 class ProcessThread;
36 
37 namespace process {
38 class SetupProcess;
39 class Process;
40 } // namespace process
41 } // namespace mgx
42 
43 class MorphoGraphX : public QMainWindow {
44  Q_OBJECT
45 
46 public:
47  MorphoGraphX(QString appdir);
48  ~MorphoGraphX();
49 
50  static QString AppDir;
51  static QLabel* ActiveStack;
52 
53  typedef mgx::Point3u Point3u;
54  typedef mgx::Point3f Point3f;
55 
56 private:
57  QDialog* editParmsDlog;
58  Ui_EditParmsDialog* editParmsDialog;
59  Ui::MainWindow ui;
60 
61  // Confocal stack objects
62  mgx::ImgData stack1, stack2;
63 
64  // Cutting surface
65  mgx::CutSurf cutSurf;
66 
67  size_t CudaHoldMem;
68  bool readOnce;
69  bool needSaving;
70 
71  ProcessParmsModel* parmsModel;
72  QString currentProcessName;
73  QString currentProcessType;
74  bool currentProcessInTasks;
75  mgx::process::Process* currentProcess;
76  mgx::process::SetupProcess* currentSetup;
77  mgx::ProcessThread* processThread;
78  QList<Library*> loadedLibs;
79 #ifdef WATCH_PROCESS_FOLDERS
80  QFileSystemWatcher* processWatcher;
81  QTimer* processReloadTimer;
82 #endif
83  QAction* resetParametersAct;
84  QAction* editTasksAct;
85 
89 
91 
92  QPointer<PathEditorDlg> editPathsDlg;
93  QPointer<LabelEditorDlg> labelEditorDlg;
94 
95  const QString& projectFile() const;
96  void setProjectFile(const QString& f);
97 
98 public:
99  void setDebug(bool debug);
100 
101  // Launch a process
102  bool LaunchProcess(const QString& processType, const QString& processName, QStringList& parms,
103  bool useGUI = true, bool saveDefaults = true);
104 
105  int activeStack() const;
106  int activeMesh() const;
107  QString getStackName(bool main, int num);
108  QString getMeshName(int num);
109  void setLoadFile(const QString& f)
110  {
111  _loadFilename = f;
112  }
113  bool runningProcess() const
114  {
115  return currentProcess != 0;
116  }
117  const mgx::process::Process* globalProcess() const;
118  mgx::process::Process* globalProcess();
119  static void writeProcessParams(const mgx::process::BaseProcessDefinition& def, QTextStream& pout);
120 
121 signals:
122  void processFinished();
123  void processFailed();
124 
125 private:
126  void loadControls();
127  void connectControlsIn();
128  void connectControlsOut();
129  void readParms();
130  void writeParms();
131  void clearMeshSelect();
132  void updateVBOs();
133  void processCommandGetParmValues(const QString& name, int type);
134  void processCommandSetParmValues(const QString& name, int type);
135  void readProcessParms();
136  void createSetupProcess();
137  void updateCurrentTasks(const TaskEditDlg::tasks_t& saved_tasks);
138 
139 public slots:
140  void forceStack1SurfHeat();
141  void forceStack2SurfHeat();
142  void modified(bool state = true);
143  void storeParameters();
144  void updateStateFromProcess(mgx::process::Process* proc);
145  void ImportMesh(int stack);
146  void ExportMesh(int stack);
147  void ResetMesh(int mesh);
148  void LoadMesh(int mesh);
149  void SaveMesh(int mesh);
150  void ImportStack(int stack, bool main);
151  void ImportStackSeries(int stack, bool main);
152  void OpenStack(int stack, bool main);
153  void SaveStack(int stack, bool main);
154  void ExportStack(int stack, bool main);
155  void updateCurrentStack();
156  void processSystemCommand(mgx::process::Process* proc, mgx::process::SystemCommand command, const QStringList& parms);
157  // Open session file
158  void FileOpen(const QString& filename);
159  // Open any file, using extension to figure out which file type
160  void AutoOpen(const QString& filename = QString(), int stack = 0, bool main = true);
161  void resetDefaultParameters();
162  void editTasks();
163  void ReloadTasks();
164  void DebugDialogSlot();
165  void ResetCutSurf();
166  void SetCutSurfControl();
167  void ResetClipControl(float sceneRadius);
168  void changeSelectLabel(int lab);
169  void UpdateSliderScaleSlot();
170 
171 private slots:
172  void stack1UnloadedSlot();
173  void stack2UnloadedSlot();
174  void changeStack1SizeSlot(const Point3u& size, const Point3f& step, const Point3f& origin);
175  void changeStack2SizeSlot(const Point3u& size, const Point3f& step, const Point3f& origin);
176 
177  void RotateSlot(bool checked);
178 
179  void ProcessStackCommandSlot(QTreeWidgetItem* current, QTreeWidgetItem* prev);
180  void ProcessMeshCommandSlot(QTreeWidgetItem* current, QTreeWidgetItem* prev);
181  void ProcessGlobalCommandSlot(QTreeWidgetItem* current, QTreeWidgetItem* prev);
182  void ProcessTasksCommandSlot(QTreeWidgetItem* current, QTreeWidgetItem* prev);
183  void SeedStackSlot(bool val);
184  void PixelEditRadiusSlot(int val) {
185  mgx::ImgData::PixelEditRadius = val;
186  }
187  void FillWorkDataSlot(bool val) {
188  mgx::ImgData::FillWorkData = val;
189  }
190 
191  void LoadView(const QString& filename);
192  void SaveView(const QString& filename);
193 
194  void FileEditPathsSlot();
195  void FileOpenSlot();
196  void FileSaveSlot();
197  void FileSaveAsSlot();
198  void ExitSlot();
199 
200  void GlobalContrastSlot();
201  void GlobalBrightnessSlot();
202 
203  void Stack1ImportSlot();
204  void Stack1ImportSeriesSlot();
205  void Stack1SaveSlot();
206  void Stack1OpenSlot();
207  void Stack1ExportSlot();
208  void Stack1ResetSlot();
209  void Stack2ImportSlot();
210  void Stack2ImportSeriesSlot();
211  void Stack2SaveSlot();
212  void Stack2OpenSlot();
213  void Stack2ExportSlot();
214  void Stack2ResetSlot();
215 
216  void Stack1WorkImportSlot();
217  void Stack1WorkImportSeriesSlot();
218  void Stack1WorkSaveSlot();
219  void Stack1WorkOpenSlot();
220  void Stack1WorkExportSlot();
221  void Stack2WorkImportSlot();
222  void Stack2WorkImportSeriesSlot();
223  void Stack2WorkSaveSlot();
224  void Stack2WorkOpenSlot();
225  void Stack2WorkExportSlot();
226 
227  void Mesh1ImportSlot();
228  void Mesh1ExportSlot();
229  void Mesh1LoadSlot();
230  void Mesh1SaveSlot();
231  void Mesh1ResetSlot();
232  void Mesh2ImportSlot();
233  void Mesh2ExportSlot();
234  void Mesh2LoadSlot();
235  void Mesh2SaveSlot();
236  void Mesh2ResetSlot();
237 
238  void MeshSelectAll();
239  void MeshUnselect();
240  void MeshInvertSelection();
241  void MeshAddCurrentLabel();
242  void MeshAddUnlabeled();
243  void MeshRemoveCurrentLabel();
244  void ChangeCurrentSeed();
245 
246  void UserManualSlot();
247  void DoxygenSlot();
248  void QGLViewerHelpSlot();
249  void AboutSlot();
250 
251  void LabelColorSlot();
252  void LabelColorSlot(QIcon& icon);
253  void AddNewSeedSlot(bool on);
254  void AddCurrSeedSlot(bool on);
255  void PickLabelSlot(bool on);
256  void GrabSeedSlot(bool on);
257  void FillLabelSlot(bool on);
258  void MeshSelectSlot(bool on);
259  void LabelSelectSlot(bool on);
260  void ConnectedSelectSlot(bool on);
261  void PixelEditSlot(bool on);
262  void PickVolLabelSlot(bool on);
263  void DeleteVolumeLabelSlot(bool on);
264  void DeletePickedLabelSlot(bool on);
265  void FillVolumeLabelSlot(bool on);
266 
267  void EraseSelectSlot();
268  void FillSelectSlot();
269  void DeleteSelectionSlot();
270  void EditParmsSlot();
271  void ProcessDocsSlot();
272  void ColorPaletteSlot();
273  void LabelsEditSlot(bool on);
274  void EditParmsSaveAsSlot();
275  void SwapSurfacesSlot();
276 
277  void ProcessCommandGoSlot();
278  void ProcessCommandTabSlot(int tab);
279 
280  void SaveProcessesParameters();
281  void RecallProcessesParameters();
282  void ReloadProcesses();
283  void ProcessCommandFinished();
284 
285  // void StartSession();
286 
287 protected:
288  bool event(QEvent* e);
289  void dragEnterEvent(QDragEnterEvent* event);
290  void dropEvent(QDropEvent* event);
291  void closeEvent(QCloseEvent* e);
292  void cleanProcess();
293  void saveSettings();
294 
295  QTime currentProcessTime;
296  QString _loadFilename;
297 };
298 
299 #endif
AttribBase(const QString &name) const QString & name()
Default constructor of named attribute.
Definition: Attributes.hpp:54
Definition of a process, without the process factory.
Definition: Process.hpp:1229
Misc.
Definition: ProcessParms.hpp:19
Definition: MorphoGraphX.hpp:43
Definition: PathEditorDlg.hpp:50
Common definitions and utilities for all geometry algorithms This file is shared by cuda...
Definition: ProcessThread.hpp:25
File containing the definition of a Process.
Definition: CutSurf.hpp:21
This is the main process class, the one all process inherit from.
Definition: Process.hpp:248
Definition: ImageData.hpp:37
Definition: LabelEditorDlg.hpp:50
Definition: Library.hpp:8