MorphoGraphX
GlobalProcess.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 GLOBALPROCESS_HPP
12 #define GLOBALPROCESS_HPP
13 
14 #include <Process.hpp>
15 
16 namespace mgx {
17 namespace process {
18 
21 
26 class mgxBase_EXPORT SetCurrentStack : public GlobalProcess {
27 public:
29  : Process(process)
30  , GlobalProcess(process)
31  {
32  }
33 
34  bool operator()(const QStringList& parms)
35  {
36  bool is_main = stringToMainStore(parms[0]);
37  int id = parms[1].toInt();
38  if(!checkState().store((is_main ? STORE_MAIN : STORE_WORK), id))
39  return false;
40  return (*this)(is_main, id);
41  }
42 
43  bool operator()(bool is_main, int id);
44 
45  QString name() const {
46  return "SetCurrentStack";
47  }
48  QString folder() const {
49  return "System";
50  }
51  QString description() const {
52  return "Change the current stack and mesh. Needed for scripts.";
53  }
55  {
56  return QStringList() << "Store"
57  << "Stack id";
58  }
60  {
61  return QStringList() << "Store"
62  << "Stack id";
63  }
65  {
66  ParmChoiceMap map;
67  map[0] = storeChoice();
68  return map;
69  }
71  {
72  return QStringList() << "Main"
73  << "0";
74  }
75  QIcon icon() const {
76  return QIcon(":/images/Relabel.png");
77  }
78 };
79 
94 class mgxBase_EXPORT SaveGlobalTransform : public QObject, public GlobalProcess {
95  Q_OBJECT
96 
97 public:
99  : Process(process)
100  , QObject()
101  , GlobalProcess(process)
102  {
103  }
104 
105  bool initialize(QStringList& parms, QWidget* parent);
106 
107  bool operator()(const QStringList& parms) {
108  return (*this)(parms[0]);
109  }
110 
111  bool operator()(const QString& filename);
112 
113  QString folder() const {
114  return "Transform";
115  }
116  QString name() const {
117  return "Save Global Transform";
118  }
120  {
121  return "Save the global alignment (transform) matrix from one stack to the other into a file";
122  }
124  return QStringList() << "Filename";
125  }
127  return QStringList() << "Filename";
128  }
130  return QStringList() << "";
131  }
132  QIcon icon() const {
133  return QIcon(":/images/save.png");
134  }
135 };
136 
147 class mgxBase_EXPORT JoinRegionsSegment : public GlobalProcess {
148 public:
150  : Process(process)
151  , GlobalProcess(process)
152  {
153  }
154 
155  bool operator()(const QStringList& parms)
156  {
157  if(!checkState().store(STORE_WORK | STORE_LABEL).mesh(MESH_NON_EMPTY))
158  return false;
159  Store* work = currentStack()->work();
160  Mesh* mesh = currentMesh();
161 
162  bool ok;
163  float cubeSize = parms[0].toFloat(&ok);
164  if(not ok)
165  return setErrorMessage("Error, the parameter 'Cube Size' must be a number.");
166 
167  bool res = (*this)(work, mesh, cubeSize);
168  if(res)
169  work->show();
170  return res;
171  }
172 
173  bool operator()(Store* work, Mesh* mesh, float cubeSize);
174 
175  QString name() const {
176  return "JoinRegions Segmentation";
177  }
179  {
180  return "Join Regions after 3D segmentation.\n"
181  "Cells selected in the 3D cell mesh extracted from the stack will be merged and re-extracted.";
182  }
183  QString folder() const {
184  return "Segmentation";
185  }
187  return QStringList() << "Cube Size";
188  }
190  return QStringList() << "Cube Size for the Marching Cube process.";
191  }
193  return QStringList() << "0";
194  }
195  QIcon icon() const {
196  return QIcon(":/images/JoinRegions.png");
197  }
198 };
200 } // namespace process
201 } // namespace mgx
202 
203 #endif
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: GlobalProcess.hpp:132
QStringList parmNames() const
List of named parameters.
Definition: GlobalProcess.hpp:186
ParmChoiceMap parmChoice() const
Purely for GUI purposes, provides for some of the parms parameter a choice.
Definition: GlobalProcess.hpp:64
QStringList parmDefaults() const
List of default parms.
Definition: GlobalProcess.hpp:192
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: GlobalProcess.hpp:155
QStringList parmNames() const
List of named parameters.
Definition: GlobalProcess.hpp:123
QString description() const
Returns a description of the process for the GUI.
Definition: GlobalProcess.hpp:119
QString description() const
Returns a description of the process for the GUI.
Definition: GlobalProcess.hpp:178
QString folder() const
Folder in which to place the process.
Definition: GlobalProcess.hpp:48
QString folder() const
Folder in which to place the process.
Definition: GlobalProcess.hpp:183
QString name() const
Returns the name of the process.
Definition: GlobalProcess.hpp:116
QStringList parmNames() const
List of named parameters.
Definition: GlobalProcess.hpp:54
QStringList parmDescs() const
List of parameters descriptions.
Definition: GlobalProcess.hpp:189
The Store class holds the actual 3D data and properties specific to it.
Definition: Store.hpp:35
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: GlobalProcess.hpp:107
This class holds the actual mesh as a VV Graph and all sort of properties for it, including visualiza...
Definition: Mesh.hpp:177
QString folder() const
Folder in which to place the process.
Definition: GlobalProcess.hpp:113
QStringList parmDefaults() const
List of default parms.
Definition: GlobalProcess.hpp:129
This namespace contains all the API of MorphoGraphX.
Definition: Assert.hpp:26
QStringList parmDescs() const
List of parameters descriptions.
Definition: GlobalProcess.hpp:59
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: GlobalProcess.hpp:34
File containing the definition of a Process.
This is the main process class, the one all process inherit from.
Definition: Process.hpp:258
Global processes have full mutable access to all properties of the process.
Definition: Process.hpp:904
This namespace contains all the classes needed to define processes.
QString description() const
Returns a description of the process for the GUI.
Definition: GlobalProcess.hpp:51
QString name() const
Returns the name of the process.
Definition: GlobalProcess.hpp:175
QStringList parmDescs() const
List of parameters descriptions.
Definition: GlobalProcess.hpp:126
Save the transformation from stack 1 to stack 2 in a file.
Definition: GlobalProcess.hpp:94
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: GlobalProcess.hpp:195
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: GlobalProcess.hpp:75
QString name() const
Returns the name of the process.
Definition: GlobalProcess.hpp:45
Join regions, using both the segmented stack and the extracted 3D cell mesh.
Definition: GlobalProcess.hpp:147
mgx_EXPORT bool stringToMainStore(const QString &string)
Returns true if string correspond to the main store, false otherwise.
Set the current stack and store.
Definition: GlobalProcess.hpp:26
QStringList parmDefaults() const
List of default parms.
Definition: GlobalProcess.hpp:70