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