MorphoGraphX
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MergeStacks.hpp
1 #ifndef MergeStacks_HPP
2 #define MergeStacks_HPP
3 
4 #include <Process.hpp>
5 
6 namespace mgx {
7 namespace process {
8 
11 
21 class AlignCanvas : public StackProcess {
22 public:
23  AlignCanvas(const StackProcess& process)
24  : Process(process)
25  , StackProcess(process)
26  {
27  }
28 
29  bool operator()(const QStringList& parms)
30  {
31  if(not checkState().store(STORE_NON_EMPTY | STORE_VISIBLE, 0).store(STORE_NON_EMPTY | STORE_VISIBLE, 1))
32  return false;
33  Stack* current = currentStack();
34  Stack* other = stack(1 - current->id());
35  if(current->currentStore()->labels() != other->currentStore()->labels())
36  return setErrorMessage("Error, one stack is labeled and the other is not.");
37  bool change_both = stringToBool(parms[0]);
38  bool result = operator()(current, other, change_both);
39  if(not change_both and result)
40  current->work()->show();
41  return result;
42  }
43 
44  bool operator()(Stack* target, Stack* other, bool change_both);
45 
46  QString folder() const {
47  return "Multi-stack";
48  }
49  QString name() const {
50  return "Align Canvas";
51  }
53  {
54  return "Align two stacks' canvas. Expand the canvas of the first stack so the\n"
55  "second one can be drawn onto it. If the 'change both stack' option is \n"
56  "selected, then all the stacks are extended and made aligned with the \n"
57  "axis of the reference system. Otherwise, the work store of the current\n"
58  "stack is replaced with the projection of the other stack onto the\n"
59  "extended canvas, keeping the resolution of the current stack.\n";
60  }
62  return QStringList() << "Change both stacks";
63  }
65  return QStringList() << "Extend the non-active stacks canvas as well";
66  }
68  return QStringList() << "True";
69  }
71  {
72  ParmChoiceMap map;
73  map[0] = booleanChoice();
74  return map;
75  }
76  QIcon icon() const {
77  return QIcon(":/images/AlignCanvas.png");
78  }
79 
80  bool projectGlobal(Stack* s1, Stack* s2);
81  bool projectOnStack(Stack* target, const Stack* to_project);
82 };
83 
89 class CombineStacks : public StackProcess {
90 public:
91  CombineStacks(const StackProcess& process)
92  : Process(process)
93  , StackProcess(process)
94  {
95  }
96 
97  bool operator()(const QStringList& parms)
98  {
100  | STORE_WORK))
101  return false;
102  Stack* current = currentStack();
103  if(current->main()->labels() != current->work()->labels())
104  return setErrorMessage("Error, one store is labeled and the other is not.");
105  return operator()(current, parms[0]);
106  }
107 
108  bool operator()(Stack* target, QString method);
109 
110  QString folder() const {
111  return "Multi-stack";
112  }
113  QString name() const {
114  return "Combine Stacks";
115  }
117  return "Combine the values of the main and work store onto the work store.";
118  }
120  return QStringList() << "Method";
121  }
123  return QStringList() << "Method";
124  }
126  return QStringList() << "Max";
127  }
129  {
130  ParmChoiceMap map;
131  map[0] = QStringList() << "Max"
132  << "Min"
133  << "Average"
134  << "Product"
135  << "Add"
136  << "Subtract";
137  return map;
138  }
139  QIcon icon() const {
140  return QIcon(":/images/CombineStacks.png");
141  }
142 };
143 
151 class MergeStacks : public StackProcess {
152 public:
153  MergeStacks(const StackProcess& process)
154  : Process(process)
155  , StackProcess(process)
156  {
157  }
158 
159  bool operator()(const QStringList& parms)
160  {
161  if(not checkState().store(STORE_NON_EMPTY | STORE_VISIBLE, 0).store(STORE_NON_EMPTY | STORE_VISIBLE, 1))
162  return false;
163  Stack* current = currentStack();
164  Stack* other = stack(1 - current->id());
165  if(current->currentStore() != current->main())
166  return setErrorMessage("Error, the current stack must have its main store active.");
167  if(current->currentStore()->labels() != other->currentStore()->labels())
168  return setErrorMessage("Error, one stack is labeled and the other is not.");
169  bool result = operator()(current, other, parms[0]);
170  if(result)
171  current->work()->show();
172  return result;
173  }
174 
175  bool operator()(Stack* target, const Stack* other, QString method);
176 
177  QString folder() const {
178  return "Multi-stack";
179  }
180  QString name() const {
181  return "Merge Stacks";
182  }
184  {
185  return "Merge the main store of the current stack with the current store of the other one.\n"
186  "The current stack will be aligned with the other before the stores being combines.\n"
187  "The method argument is simply passed to the Combine_Stacks process.";
188  }
190  return QStringList() << "Method";
191  }
193  return QStringList() << "Method";
194  }
196  return QStringList() << "max";
197  }
199  {
200  ParmChoiceMap map;
201  map[0] = QStringList() << "max"
202  << "min"
203  << "average"
204  << "product";
205  return map;
206  }
207  QIcon icon() const {
208  return QIcon(":/images/MergeStacks.png");
209  }
210 };
212 } // namespace process
213 } // namespace mgx
214 #endif
void show()
Ask the user interface to show this store.
Definition: Store.hpp:167
QStringList parmNames() const
List of named parameters.
Definition: MergeStacks.hpp:189
ParmChoiceMap parmChoice() const
Purely for GUI purposes, provides for some of the parms parameter a choice.
Definition: MergeStacks.hpp:70
QString description() const
Returns a description of the process for the GUI.
Definition: MergeStacks.hpp:116
Stack * currentStack()
Returns the current stack (i.e.
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: MergeStacks.hpp:29
QString folder() const
Folder in which to place the process.
Definition: MergeStacks.hpp:110
int id() const
Id of a stack.
Definition: Stack.hpp:49
QStringList parmDefaults() const
List of default parms.
Definition: MergeStacks.hpp:195
QString name() const
Returns the name of the process.
Definition: MergeStacks.hpp:49
const Store * currentStore() const
Returns the current store.
Definition: Stack.hpp:112
QStringList parmNames() const
List of named parameters.
Definition: MergeStacks.hpp:119
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: MergeStacks.hpp:159
QString description() const
Returns a description of the process for the GUI.
Definition: MergeStacks.hpp:52
QStringList parmDefaults() const
List of default parms.
Definition: MergeStacks.hpp:125
Process()
Default constructor.
QStringList parmDescs() const
List of parameters descriptions.
Definition: MergeStacks.hpp:64
QStringList parmDefaults() const
List of default parms.
Definition: MergeStacks.hpp:67
Align two stacks' canvas.
Definition: MergeStacks.hpp:21
QStringList parmNames() const
List of named parameters.
Definition: MergeStacks.hpp:61
CheckState checkState()
Call this function and convert the result to a boolean.
ParmChoiceMap parmChoice() const
Purely for GUI purposes, provides for some of the parms parameter a choice.
Definition: MergeStacks.hpp:128
Visible store.
Definition: Process.hpp:644
Merge the main store of the current stack with the current store of the other one.
Definition: MergeStacks.hpp:151
Stack * stack(int i)
Returns the ith stack, or 0 if there is no such stack.
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: MergeStacks.hpp:139
QString folder() const
Folder in which to place the process.
Definition: MergeStacks.hpp:177
bool setErrorMessage(const QString &str)
Set an error message that will be displayed if the process returns false.
Non-Empty store.
Definition: Process.hpp:643
QString name() const
Returns the name of the process.
Definition: MergeStacks.hpp:180
bool labels() const
Returns true if the data is to be interpreted as labels rather than intensities.
Definition: Store.hpp:63
File containing the definition of a Process.
ParmChoiceMap parmChoice() const
Purely for GUI purposes, provides for some of the parms parameter a choice.
Definition: MergeStacks.hpp:198
The Stack class represent the dimensions of the 3D data, and the frames transformations.
Definition: Stack.hpp:25
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: MergeStacks.hpp:97
QStringList parmDescs() const
List of parameters descriptions.
Definition: MergeStacks.hpp:122
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: MergeStacks.hpp:76
mgx_EXPORT bool stringToBool(const QString &string)
Helper function converting a string into a boolean.
Main store.
Definition: Process.hpp:656
const Store * work() const
Access the work store.
Definition: Stack.hpp:93
QString name() const
Returns the name of the process.
Definition: MergeStacks.hpp:113
Combine the values of the main and work store onto the work store.
Definition: MergeStacks.hpp:89
const Store * main() const
Access the main store.
Definition: Stack.hpp:74
QString description() const
Returns a description of the process for the GUI.
Definition: MergeStacks.hpp:183
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: MergeStacks.hpp:207
Stack processes have non-mutable access to meshes and mutable access to stacks.
Definition: Process.hpp:819
QStringList booleanChoice() const
Helper function that provides a list of choices for a boolean argument.
Definition: Process.hpp:599
QString folder() const
Folder in which to place the process.
Definition: MergeStacks.hpp:46
QStringList parmDescs() const
List of parameters descriptions.
Definition: MergeStacks.hpp:192
Work store.
Definition: Process.hpp:655