MorphoGraphX  2.0-1-227
MorphoGraphX.hpp
Go to the documentation of this file.
1 //
2 // This file is part of MorphoGraphX - http://www.MorphoGraphX.org
3 // Copyright (C) 2012-2016 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 <string.h>
25 #include <QMutex>
26 #include <QTime>
27 #include <QPointer>
28 
29 #include <ui_GUI.h>
30 #include <ui_EditParms.h>
31 #include <ui_ProcessDocs.h>
32 
33 class QDragEnterEvent;
34 class QDropEvent;
35 class QCloseEvent;
36 class ProcessParmsModel;
37 class Library;
38 class QFileSystemWatcher;
39 class QAction;
40 class PathEditorDlg;
41 class LabelEditorDlg;
42 
43 namespace mgx
44 {
45  class ProcessThread;
46 
47  class SetupProcess;
48  class Process;
49 }
50 
51 class MorphoGraphX : public QMainWindow
52 {
53  Q_OBJECT
54 
55 public:
56  MorphoGraphX(QString appdir,QStringList addLibraries = QStringList());
57  ~MorphoGraphX();
58 
59  // Must be the same in Process.hpp
62 
63  static QString AppDir;
64  static QLabel* ActiveStack;
65 
68 
69 private:
70  QDialog* editParmsDlog;
71  Ui_EditParmsDialog* editParmsDialog;
72  Ui::MainWindow ui;
73 
74  // Confocal stack objects
75  mgx::ImgData stack1, stack2;
76 
77  // Cutting surface
78  mgx::CutSurf cutSurf;
79 
80  size_t CudaHoldMem;
81  bool initalView;
82  bool needSaving;
83 
84  ProcessParmsModel* parmsModel;
85  QString currentProcessName;
86  bool currentProcessInTasks;
87  mgx::Process* currentProcess;
88  mgx::SetupProcess* currentSetup;
89  mgx::ProcessThread* processThread;
90  QList<QFileInfo> addedLibFiles;
91  QList<Library*> loadedLibs;
92 #ifdef WATCH_PROCESS_FOLDERS
93  QFileSystemWatcher* processWatcher;
94  QTimer* processReloadTimer;
95 #endif
96  QAction* resetParametersAct;
97  QAction* editTasksAct;
98 
99  QMap<QString, mgx::ProcessDefinition> savedProc;
100 
101  TaskEditDlg::tasks_t tasks;
102 
103  QPointer<PathEditorDlg> editPathsDlg;
104  QPointer<LabelEditorDlg> labelEditorDlg;
105 
106  const QString& projectFile() const;
107  QHash<QString, QTreeWidgetItem*> stackFolders, meshFolders, ccFolders, miscFolders, dynamXFolders;
108 
109 public:
110  void setDebug(bool debug);
111 
112  // Launch a process
113  bool LaunchProcess(const QString& processName, QStringList& parms,
114  mgx::Process::ProcessAction processAction, bool useGUI = true, bool saveDefaults = true);
115 
116  int activeStack() const;
117  int activeMesh() const;
118  QString getStackName(bool main, int num);
119  QString getMeshName(int num);
120  void setLoadFile(const QString& f)
121  {
122  _loadFilename = f;
123  }
124  bool runningProcess() const
125  {
126  return currentProcess != 0;
127  }
128  const mgx::Process* globalProcess() const;
130  static void writeProcessParms(const mgx::ProcessDefinition& def, QTextStream& pout);
131 
132 signals:
133  void processFinished();
134  void processFailed();
135 
136 private:
137  void loadControls();
138  void connectControlsIn();
139  void connectControlsOut();
140  void readParms();
141  void writeParms();
142  void clearMeshSelect();
143  void updateVBOs();
144  void readProcessParms();
145  void createSetupProcess();
146  void updateCurrentTasks(const TaskEditDlg::tasks_t& saved_tasks);
147  QTreeWidgetItem* getFolder(QString name,
148  QHash<QString, QTreeWidgetItem*>& folders, QTreeWidget* tree);
149  void createItem(const mgx::ProcessDefinition& def);
150  void updateDefinitions(QMap<QString, mgx::ProcessDefinition>& procDefs,
151  mgx::ProcessFactoryPtr factory, const
152  QMap<QString, mgx::ProcessDefinition>& oldProcDefs);
153  void setProjectFile(const QString &f);
154 
155  void updateViewer();
156  void loadView(mgx::Process *proc, QString fileName);
157  void saveView(mgx::Process *proc, QString fileName);
158  void setCurrentStack(mgx::Process *proc, const QString &store, int id);
159  void takeSnapshot(mgx::Process *proc, QString fileName,
160  float overSampling, int width, int height, int quality, bool expandFrustum);
161  void updateStateFromProcess(mgx::Process* proc);
162  void setStatus(QString fileName, bool alsoPrint = true);
163 
164 public slots:
165  // Process communication
166  void systemCommand(mgx::Process *proc, int command, QStringList parms);
167 
168  void modified(bool state = true);
169  void storeParameters();
170  void ImportMesh(int stack);
171  void ExportMesh(int stack);
172  void ResetMesh(int mesh);
173  void LoadMesh(int mesh);
174  void SaveMesh(int mesh);
175  void ImportStack(int stack, bool main);
176  void ImportStackSeries(int stack, bool main);
177  void OpenStack(int stack, bool main);
178  void SaveStack(int stack, bool main);
179  void ExportStack(int stack, bool main);
180  void updateCurrentStack();
181 
182  // Shortcuts
183  void toggleControlsTab();
184  void toggleStackTabs();
186  void toggleMeshViewDropdown();
187  void toggleMeshSurfaceView();
188  void toggleMainCheckBox();
189  void toggleWorkCheckBox();
190 
191  //Attributes
192  void ManageAttributesMesh(int mesh);
193 
194  // Open session file
195  void FileOpen(const QString& filename);
196  void setModelPath(const QString& path);
197  // Open any file, using extension to figure out which file type
198  void AutoOpen(const QString& filename = QString(), int stack = 0, bool main = true);
199  void AutoRunSlot();
200  void resetDefaultParameters();
201  void editTasks();
202  void ReloadTasks();
203  void DebugDialogSlot();
204  void ResetCutSurf();
205  void SetCutSurfControl();
206  void ResetClipControl(float sceneRadius);
207  void changeSelectLabel(int lab);
208  void UpdateSliderScaleSlot();
209 
210 private slots:
211  void stack1UnloadedSlot();
212  void stack2UnloadedSlot();
213  void changeStack1SizeSlot(const Point3u& size, const Point3f& step, const Point3f& origin);
214  void changeStack2SizeSlot(const Point3u& size, const Point3f& step, const Point3f& origin);
215 
216  void RotateSlot(bool checked);
217 
218  void ProcessCommandSlot(QTreeWidgetItem* current, QTreeWidgetItem* prev);
219  void ProcessTasksCommandSlot(QTreeWidgetItem* current, QTreeWidgetItem* prev);
220  void SeedStackSlot(bool val);
221  void VoxelEditRadiusSlot(int val) {
223  }
224  void FillWorkDataSlot(bool val) {
226  }
227 
228  void LoadView(const QString& filename);
229  void SaveView(const QString& filename);
230 
231  void FileEditPathsSlot();
232  void FileOpenSlot();
233  void FileSaveSlot();
234  void FileSaveAsSlot();
235  void FileQuickSaveSlot();
236  void ExitSlot();
237 
238  void GlobalContrastSlot();
239  void GlobalBrightnessSlot();
240 
241  void Stack1ImportSlot();
242  void Stack1ImportSeriesSlot();
243  void Stack1SaveSlot();
244  void Stack1OpenSlot();
245  void Stack1ExportSlot();
246  void Stack1ResetSlot();
247  void Stack2ImportSlot();
248  void Stack2ImportSeriesSlot();
249  void Stack2SaveSlot();
250  void Stack2OpenSlot();
251  void Stack2ExportSlot();
252  void Stack2ResetSlot();
253 
254  void Stack1WorkImportSlot();
255  void Stack1WorkImportSeriesSlot();
256  void Stack1WorkSaveSlot();
257  void Stack1WorkOpenSlot();
258  void Stack1WorkExportSlot();
259  void Stack2WorkImportSlot();
260  void Stack2WorkImportSeriesSlot();
261  void Stack2WorkSaveSlot();
262  void Stack2WorkOpenSlot();
263  void Stack2WorkExportSlot();
264 
265  void Mesh1ImportSlot();
266  void Mesh1ExportSlot();
267  void Mesh1LoadSlot();
268  void Mesh1SaveSlot();
269  void Mesh1ResetSlot();
270  void Mesh2ImportSlot();
271  void Mesh2ExportSlot();
272  void Mesh2LoadSlot();
273  void Mesh2SaveSlot();
274  void Mesh2ResetSlot();
275 
276  void MeshSelectAll();
277  void MeshUnselect();
278  void MeshInvertSelection();
279  void MeshAddCurrentLabel();
280  void MeshAddUnlabeled();
281  void MeshRemoveCurrentLabel();
282  void ChangeCurrentSeed();
283 
284  void Mesh1ManageAttributes();
285  void Mesh2ManageAttributes();
286 
287  void UserManualSlot();
288  void DoxygenSlot();
289  void QGLViewerHelpSlot();
290  void AboutSlot();
291 
292  void LabelColorSlot();
293  void LabelColorSlot(QIcon& icon);
294 
295  void on_actionAddNewSeed_triggered(bool on);
296  void on_actionAddCurrentSeed_triggered(bool on);
297  void on_actionPickLabel_triggered(bool on);
298  void on_actionGrabSeed_triggered(bool on);
299  void on_actionFillLabel_triggered(bool on);
300  void on_actionPickFillLabel_triggered(bool on);
301  void on_actionPickFillParent_triggered(bool on);
302  void on_actionMeshSelect_toggled(bool on);
303  void on_actionLassoSelect_toggled(bool on);
304  void on_actionTriangleSelect_toggled(bool on);
305  void on_actionLabelSelect_triggered(bool on);
306  void on_actionConnectedSelect_triggered(bool on);
307 
308  void on_actionPickVolLabel_triggered(bool on);
309  void on_actionPickFillVolumeLabel_triggered(bool on);
310  void on_actionFillVolumeLabel_triggered(bool on);
311  void on_actionVoxelEdit_triggered(bool on);
312  void on_actionDeleteVolumeLabel_triggered(bool on);
313 
314  void on_actionRewind_triggered(bool on);
315  void on_actionStop_triggered(bool on);
316  void on_actionStep_triggered(bool on);
317  void on_actionRun_triggered(bool on);
318 
319  void EraseSelectSlot();
320  void FillSelectSlot();
321  void DeleteSelectionSlot();
322  void EditParmsSlot();
323  void ProcessDocsSlot();
324  void ColorPaletteSlot();
325  void LabelsEditSlot(bool on);
326  void EditParmsSaveAsSlot();
327  void SwapSurfacesSlot();
328  void ProgressStopSlot();
329 
330  void ProcessCommandTabSlot(int tab);
331 
332  void SaveProcessesParameters();
333  void RecallProcessesParameters();
334  void ReloadProcesses();
335  void ProcessCommandFinished();
336 
337 protected:
338  void dragEnterEvent(QDragEnterEvent* event);
339  void dropEvent(QDropEvent* event);
340  void closeEvent(QCloseEvent* e);
341  void saveSettings();
342 
344  QString _loadFilename;
345 };
346 
347 #endif
LabelEditorDlg
Definition: LabelEditorDlg.hpp:61
MorphoGraphX::setLoadFile
void setLoadFile(const QString &f)
Definition: MorphoGraphX.hpp:120
ushort
unsigned short ushort
Definition: MorphoGraphX.hpp:13
MorphoGraphX::ManageAttributesMesh
void ManageAttributesMesh(int mesh)
Process.hpp
mgx::ImgData::FillWorkData
static bool FillWorkData
Definition: ImageData.hpp:194
CutSurf.hpp
MorphoGraphX::Point3u
mgx::Point3u Point3u
Definition: MorphoGraphX.hpp:66
MorphoGraphX::writeProcessParms
static void writeProcessParms(const mgx::ProcessDefinition &def, QTextStream &pout)
MorphoGraphX::AutoRunSlot
void AutoRunSlot()
mgx::ProcessThread
Definition: ProcessThread.hpp:22
MorphoGraphX::SET_CURRENT_STACK
@ SET_CURRENT_STACK
Definition: MorphoGraphX.hpp:60
MorphoGraphX::ResetClipControl
void ResetClipControl(float sceneRadius)
MorphoGraphX::processFailed
void processFailed()
mgx::Process::ProcessAction
ProcessAction
Enumeration for process flow control.
Definition: Process.hpp:540
MorphoGraphX::dropEvent
void dropEvent(QDropEvent *event)
MorphoGraphX::TAKE_SNAPSHOT
@ TAKE_SNAPSHOT
Definition: MorphoGraphX.hpp:61
MorphoGraphX::currentProcessTime
QTime currentProcessTime
Definition: MorphoGraphX.hpp:343
MorphoGraphX::SetCutSurfControl
void SetCutSurfControl()
uint
unsigned int uint
Definition: MorphoGraphX.hpp:14
MorphoGraphX::LoadMesh
void LoadMesh(int mesh)
MorphoGraphX::ImportStackSeries
void ImportStackSeries(int stack, bool main)
MorphoGraphX::ReloadTasks
void ReloadTasks()
MorphoGraphX::updateCurrentStack
void updateCurrentStack()
mgx::ImgData::VoxelEditRadius
static int VoxelEditRadius
Definition: ImageData.hpp:196
MorphoGraphX::changeSelectLabel
void changeSelectLabel(int lab)
MorphoGraphX::closeEvent
void closeEvent(QCloseEvent *e)
MorphoGraphX::toggleControlsTab
void toggleControlsTab()
MorphoGraphX::OpenStack
void OpenStack(int stack, bool main)
MorphoGraphX::LaunchProcess
bool LaunchProcess(const QString &processName, QStringList &parms, mgx::Process::ProcessAction processAction, bool useGUI=true, bool saveDefaults=true)
Library
Definition: Library.hpp:18
MorphoGraphX::SAVE_VIEW
@ SAVE_VIEW
Definition: MorphoGraphX.hpp:60
MorphoGraphX::ResetMesh
void ResetMesh(int mesh)
Geometry.hpp
MorphoGraphX::resetDefaultParameters
void resetDefaultParameters()
mgx
Distributed matrix library.
Definition: Assert.hpp:26
MorphoGraphX::getStackName
QString getStackName(bool main, int num)
MorphoGraphX::AppDir
static QString AppDir
Definition: MorphoGraphX.hpp:63
MorphoGraphX::toggleWorkCheckBox
void toggleWorkCheckBox()
MorphoGraphX::UPDATE_VIEWER
@ UPDATE_VIEWER
Definition: MorphoGraphX.hpp:60
MorphoGraphX::saveSettings
void saveSettings()
MorphoGraphX::editTasks
void editTasks()
MorphoGraphX::toggleMeshViewDropdown
void toggleMeshViewDropdown()
MorphoGraphX::toggleMainCheckBox
void toggleMainCheckBox()
TaskEditDlg.hpp
MorphoGraphX::UpdateSliderScaleSlot
void UpdateSliderScaleSlot()
mgx::Process
Definition: Process.hpp:219
MorphoGraphX::AutoOpen
void AutoOpen(const QString &filename=QString(), int stack=0, bool main=true)
MorphoGraphX::systemCommand
void systemCommand(mgx::Process *proc, int command, QStringList parms)
MorphoGraphX::Point3f
mgx::Point3f Point3f
Definition: MorphoGraphX.hpp:67
MorphoGraphX::setDebug
void setDebug(bool debug)
MorphoGraphX::FileOpen
void FileOpen(const QString &filename)
MorphoGraphX::processFinished
void processFinished()
MorphoGraphX::_loadFilename
QString _loadFilename
Definition: MorphoGraphX.hpp:344
MorphoGraphX::SystemCommand
SystemCommand
Definition: MorphoGraphX.hpp:60
MorphoGraphX::activeStack
int activeStack() const
MorphoGraphX::SaveMesh
void SaveMesh(int mesh)
MorphoGraphX::~MorphoGraphX
~MorphoGraphX()
MorphoGraphX::storeParameters
void storeParameters()
MorphoGraphX::ActiveStack
static QLabel * ActiveStack
Definition: MorphoGraphX.hpp:64
MorphoGraphX::toggleStackTabs
void toggleStackTabs()
MorphoGraphX::ExportStack
void ExportStack(int stack, bool main)
ProcessParmsModel
Definition: ProcessParmsModel.hpp:30
MorphoGraphX
Definition: MorphoGraphX.hpp:51
MorphoGraphX::ResetCutSurf
void ResetCutSurf()
Misc.hpp
PathEditorDlg
Definition: PathEditorDlg.hpp:62
mgx::ImgData
Definition: ImageData.hpp:45
MorphoGraphX::dragEnterEvent
void dragEnterEvent(QDragEnterEvent *event)
mgx::Vector< 3, uint >
MorphoGraphX::MorphoGraphX
MorphoGraphX(QString appdir, QStringList addLibraries=QStringList())
MorphoGraphX::getMeshName
QString getMeshName(int num)
MorphoGraphX::DebugDialogSlot
void DebugDialogSlot()
MorphoGraphX::runningProcess
bool runningProcess() const
Definition: MorphoGraphX.hpp:124
MorphoGraphX::UPDATE_STATE
@ UPDATE_STATE
Definition: MorphoGraphX.hpp:61
MorphoGraphX::activeMesh
int activeMesh() const
mgx::CutSurf
Definition: CutSurf.hpp:34
MorphoGraphX::LOAD_VIEW
@ LOAD_VIEW
Definition: MorphoGraphX.hpp:60
MorphoGraphX::SET_STATUS
@ SET_STATUS
Definition: MorphoGraphX.hpp:61
MorphoGraphX::modified
void modified(bool state=true)
mgx::ProcessDefinition
Definition: Process.hpp:873
TaskEditDlg::tasks_t
TasksModel::tasks_t tasks_t
Definition: TaskEditDlg.hpp:88
MorphoGraphX::ImportStack
void ImportStack(int stack, bool main)
MorphoGraphX::toggleControlKeyInteraction
void toggleControlKeyInteraction()
MorphoGraphX::ExportMesh
void ExportMesh(int stack)
MorphoGraphX::toggleMeshSurfaceView
void toggleMeshSurfaceView()
MorphoGraphX::SaveStack
void SaveStack(int stack, bool main)
MorphoGraphX::globalProcess
const mgx::Process * globalProcess() const
MorphoGraphX::setModelPath
void setModelPath(const QString &path)
MorphoGraphX::ImportMesh
void ImportMesh(int stack)