MorphoGraphX
MeshProcessSelection.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 MESH_PROCESS_SELECTION_HPP
12 #define MESH_PROCESS_SELECTION_HPP
13 
14 #include <Process.hpp>
15 
16 namespace mgx {
17 namespace process {
20 
25 class mgxBase_EXPORT MeshSelectAll : public MeshProcess {
26 public:
28  : Process(process)
29  , MeshProcess(process)
30  {
31  }
32 
33  bool operator()(const QStringList& )
34  {
35  if(!checkState().mesh(MESH_NON_EMPTY | MESH_SHOW_MESH))
36  return false;
37  return (*this)(currentMesh());
38  }
39 
40  bool operator()(Mesh* m);
41 
42  QString folder() const {
43  return "Selection";
44  }
45  QString name() const {
46  return "Select All";
47  }
48  QString description() const {
49  return "Select all vertices of the current mesh";
50  }
52  return QStringList();
53  }
55  return QStringList();
56  }
57  QIcon icon() const {
58  return QIcon();
59  }
60 };
61 
67 class mgxBase_EXPORT MeshSelectBadNormals : public MeshProcess {
68 public:
70  : Process(process)
71  , MeshProcess(process)
72  {
73  }
74 
75  bool operator()(const QStringList& )
76  {
77  if(!checkState().mesh(MESH_NON_EMPTY | MESH_SHOW_MESH))
78  return false;
79  return (*this)(currentMesh());
80  }
81 
82  bool operator()(Mesh* m);
83 
84  QString folder() const {
85  return "Selection";
86  }
87  QString name() const {
88  return "Select Bad Normals";
89  }
91  {
92  return "Select all vertices of the current mesh with bad normals (i.e. normals is not opf size 1)";
93  }
95  return QStringList();
96  }
98  return QStringList();
99  }
100  QIcon icon() const {
101  return QIcon();
102  }
103 };
104 
110 class mgxBase_EXPORT MeshUnselect : public MeshProcess {
111 public:
113  : Process(process)
114  , MeshProcess(process)
115  {
116  }
117 
118  bool operator()(const QStringList& )
119  {
120  if(!checkState().mesh(MESH_NON_EMPTY | MESH_SHOW_MESH))
121  return false;
122  return (*this)(currentMesh());
123  }
124 
125  bool operator()(Mesh* m);
126 
127  QString folder() const {
128  return "Selection";
129  }
130  QString name() const {
131  return "Unselect";
132  }
134  return "Unselect the vertices of the current mesh";
135  }
137  return QStringList();
138  }
140  return QStringList();
141  }
142  QIcon icon() const {
143  return QIcon();
144  }
145 };
146 
152 class mgxBase_EXPORT MeshInvertSelection : public MeshProcess {
153 public:
155  : Process(process)
156  , MeshProcess(process)
157  {
158  }
159 
160  bool operator()(const QStringList& )
161  {
162  if(!checkState().mesh(MESH_NON_EMPTY | MESH_SHOW_MESH))
163  return false;
164  return (*this)(currentMesh());
165  }
166 
167  bool operator()(Mesh* m);
168 
169  QString folder() const {
170  return "Selection";
171  }
172  QString name() const {
173  return "Invert Selection";
174  }
176  return "Invert the selection of the current mesh.";
177  }
179  return QStringList();
180  }
182  return QStringList();
183  }
184  QIcon icon() const {
185  return QIcon();
186  }
187 };
188 
195 class mgxBase_EXPORT MeshSelectUnlabeled : public MeshProcess {
196 public:
198  : Process(process)
199  , MeshProcess(process)
200  {
201  }
202 
203  bool operator()(const QStringList& parms)
204  {
205  if(!checkState().mesh(MESH_NON_EMPTY | MESH_SHOW_MESH))
206  return false;
207  bool replace = stringToBool(parms[0]);
208  return (*this)(currentMesh(), replace);
209  }
210 
211  bool operator()(Mesh* m, bool replace);
212 
213  QString folder() const {
214  return "Selection";
215  }
216  QString name() const {
217  return "Select Unlabeled";
218  }
220  return "Add to or replace the selection with the unlabeled vertices.";
221  }
223  return QStringList() << "Replace selection";
224  }
226  return QStringList() << "Replace selection";
227  }
229  return QStringList() << "No";
230  }
232  {
233  ParmChoiceMap map;
234  map[0] = booleanChoice();
235  return map;
236  }
237  QIcon icon() const {
238  return QIcon();
239  }
240 };
241 
247 class mgxBase_EXPORT MeshSelectLabeled : public MeshProcess {
248 public:
250  : Process(process)
251  , MeshProcess(process)
252  {
253  }
254 
255  bool operator()(const QStringList& parms)
256  {
257  if(!checkState().mesh(MESH_NON_EMPTY | MESH_SHOW_MESH))
258  return false;
259  bool replace = stringToBool(parms[0]);
260  return (*this)(currentMesh(), replace);
261  }
262 
263  bool operator()(Mesh* m, bool replace);
264 
265  QString folder() const {
266  return "Selection";
267  }
268  QString name() const {
269  return "Select Labeled";
270  }
272  return "Add to or replace the selection with the labeled vertices.";
273  }
275  return QStringList() << "Replace selection";
276  }
278  return QStringList() << "Replace selection";
279  }
281  return QStringList() << "No";
282  }
284  {
285  ParmChoiceMap map;
286  map[0] = booleanChoice();
287  return map;
288  }
289  QIcon icon() const {
290  return QIcon();
291  }
292 };
293 
297 class mgxBase_EXPORT MeshSelectLabel : public MeshProcess {
298 public:
300  : Process(process)
301  , MeshProcess(process)
302  {
303  }
304 
305  bool operator()(const QStringList& parms)
306  {
307  if(!checkState().mesh(MESH_NON_EMPTY | MESH_SHOW_MESH))
308  return false;
309  bool replace = stringToBool(parms[0]);
310  return (*this)(currentMesh(), replace, parms[1].toInt());
311  }
312 
313  bool operator()(Mesh* m, bool replace, int label);
314 
315  QString folder() const {
316  return "Selection";
317  }
318  QString name() const {
319  return "Select Label";
320  }
322  {
323  return "Add to or replace the selection with the vertices of a given label (0 for current label).";
324  }
326  {
327  return QStringList() << "Replace selection"
328  << "Label (0 for current)";
329  }
331  {
332  return QStringList() << "No"
333  << "0";
334  }
336  {
337  ParmChoiceMap map;
338  map[0] = booleanChoice();
339  return map;
340  }
341  QIcon icon() const {
342  return QIcon();
343  }
344 };
345 
351 class mgxBase_EXPORT MeshUnselectLabel : public MeshProcess {
352 public:
354  : Process(process)
355  , MeshProcess(process)
356  {
357  }
358 
359  bool operator()(const QStringList& parms)
360  {
361  if(!checkState().mesh(MESH_NON_EMPTY | MESH_SHOW_MESH))
362  return false;
363  return (*this)(currentMesh(), parms[0].toInt());
364  }
365 
366  bool operator()(Mesh* m, int label);
367 
368  QString folder() const {
369  return "Selection";
370  }
371  QString name() const {
372  return "Unselect Label";
373  }
375  {
376  return "Remove the vertices of a given label (0 for current label) from the selection.";
377  }
379  return QStringList() << "Label (0 for current)";
380  }
382  return QStringList() << "Label (0 for current)";
383  }
385  return QStringList() << "0";
386  }
387  QIcon icon() const {
388  return QIcon();
389  }
390 };
391 
397 class mgxBase_EXPORT MeshSelectClip : public MeshProcess {
398 public:
400  : Process(process)
401  , MeshProcess(process)
402  {
403  }
404 
405  bool operator()(const QStringList& )
406  {
407  if(!checkState().mesh(MESH_NON_EMPTY | MESH_SHOW_MESH))
408  return false;
409  return (*this)(currentMesh());
410  }
411 
412  bool operator()(Mesh* m);
413 
414  QString folder() const {
415  return "Selection";
416  }
417  QString name() const {
418  return "Select Clip Region";
419  }
421  return "Add vertices in clip region to selection.";
422  }
424  return QStringList();
425  }
427  return QStringList();
428  }
429  QIcon icon() const {
430  return QIcon();
431  }
432 };
433 
440 class mgxBase_EXPORT MeshSelectWholeLabelExtend : public MeshProcess {
441 public:
443  : Process(process)
444  , MeshProcess(process)
445  {
446  }
447 
448  bool operator()(const QStringList& )
449  {
450  if(!checkState().mesh(MESH_NON_EMPTY | MESH_SHOW_MESH))
451  return false;
452  return (*this)(currentMesh());
453  }
454 
455  bool operator()(Mesh* m);
456 
457  QString folder() const {
458  return "Selection";
459  }
460  QString name() const {
461  return "Extend to Whole Cells";
462  }
464  return "Extend Selection to Whole Cells";
465  }
467  return QStringList();
468  }
470  return QStringList();
471  }
472  QIcon icon() const {
473  return QIcon();
474  }
475 };
476 
482 class mgxBase_EXPORT MeshSelectDuplicateCells : public MeshProcess {
483 public:
485  : Process(process)
486  , MeshProcess(process)
487  {
488  }
489 
490  bool operator()(const QStringList& )
491  {
492  if(!checkState().mesh(MESH_NON_EMPTY | MESH_SHOW_MESH))
493  return false;
494  return (*this)(currentMesh());
495  }
496 
497  bool operator()(Mesh* m);
498 
499  QString folder() const {
500  return "Selection";
501  }
502  QString name() const {
503  return "Select Duplicate Cells";
504  }
506  return "Select cells with duplicate labels.";
507  }
509  return QStringList();
510  }
512  return QStringList();
513  }
514  QIcon icon() const {
515  return QIcon();
516  }
517 };
518 
526 public:
528  : Process(process)
529  , MeshProcess(process)
530  {
531  }
532 
533  bool operator()(const QStringList& )
534  {
535  if(!checkState().mesh(MESH_NON_EMPTY))
536  return false;
537  return operator()(currentMesh());
538  }
539 
540  bool operator()(Mesh* m);
541 
542  QString folder() const {
543  return "Selection";
544  }
545  QString name() const {
546  return "Extend by Connectivity";
547  }
549  return "Extend the selection to connected regions";
550  }
552  return QStringList();
553  }
555  return QStringList();
556  }
557  QIcon icon() const {
558  return QIcon(":/images/SelectConnected.png");
559  }
560 };
562 } // namespace process
563 } // namespace mgx
564 
565 #endif
bool operator()(const QStringList &)
Implementation of the process with generic arguments.
Definition: MeshProcessSelection.hpp:118
QString description() const
Returns a description of the process for the GUI.
Definition: MeshProcessSelection.hpp:463
QStringList parmNames() const
List of named parameters.
Definition: MeshProcessSelection.hpp:466
QStringList parmNames() const
List of named parameters.
Definition: MeshProcessSelection.hpp:94
QStringList parmNames() const
List of named parameters.
Definition: MeshProcessSelection.hpp:274
QStringList parmNames() const
List of named parameters.
Definition: MeshProcessSelection.hpp:378
bool operator()(const QStringList &)
Implementation of the process with generic arguments.
Definition: MeshProcessSelection.hpp:448
bool operator()(const QStringList &)
Implementation of the process with generic arguments.
Definition: MeshProcessSelection.hpp:33
QStringList parmDefaults() const
List of default parms.
Definition: MeshProcessSelection.hpp:384
Select all vertices within the clipped region.
Definition: MeshProcessSelection.hpp:397
QString name() const
Returns the name of the process.
Definition: MeshProcessSelection.hpp:417
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: MeshProcessSelection.hpp:100
bool operator()(const QStringList &)
Implementation of the process with generic arguments.
Definition: MeshProcessSelection.hpp:490
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: MeshProcessSelection.hpp:203
ParmChoiceMap parmChoice() const
Purely for GUI purposes, provides for some of the parms parameter a choice.
Definition: MeshProcessSelection.hpp:283
QString name() const
Returns the name of the process.
Definition: MeshProcessSelection.hpp:268
QString folder() const
Folder in which to place the process.
Definition: MeshProcessSelection.hpp:368
QString name() const
Returns the name of the process.
Definition: MeshProcessSelection.hpp:172
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: MeshProcessSelection.hpp:184
QString folder() const
Folder in which to place the process.
Definition: MeshProcessSelection.hpp:315
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: MeshProcessSelection.hpp:305
QStringList parmNames() const
List of named parameters.
Definition: MeshProcessSelection.hpp:325
Select all the vertices with invalid normals in the current mesh.
Definition: MeshProcessSelection.hpp:67
QString folder() const
Folder in which to place the process.
Definition: MeshProcessSelection.hpp:42
bool operator()(const QStringList &)
Implementation of the process with generic arguments.
Definition: MeshProcessSelection.hpp:75
Ensure no vertex is selected in the current mesh.
Definition: MeshProcessSelection.hpp:110
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: MeshProcessSelection.hpp:255
ParmChoiceMap parmChoice() const
Purely for GUI purposes, provides for some of the parms parameter a choice.
Definition: MeshProcessSelection.hpp:231
QStringList parmNames() const
List of named parameters.
Definition: MeshProcessSelection.hpp:178
QString description() const
Returns a description of the process for the GUI.
Definition: MeshProcessSelection.hpp:374
QString name() const
Returns the name of the process.
Definition: MeshProcessSelection.hpp:460
QStringList parmDescs() const
List of parameters descriptions.
Definition: MeshProcessSelection.hpp:554
QString folder() const
Folder in which to place the process.
Definition: MeshProcessSelection.hpp:265
bool operator()(const QStringList &)
Implementation of the process with generic arguments.
Definition: MeshProcessSelection.hpp:160
Invert the selection status of all the vertices in the current mesh.
Definition: MeshProcessSelection.hpp:152
QStringList parmNames() const
List of named parameters.
Definition: MeshProcessSelection.hpp:423
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: MeshProcessSelection.hpp:237
QStringList parmNames() const
List of named parameters.
Definition: MeshProcessSelection.hpp:51
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: MeshProcessSelection.hpp:429
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: MeshProcessSelection.hpp:472
QString description() const
Returns a description of the process for the GUI.
Definition: MeshProcessSelection.hpp:90
QString description() const
Returns a description of the process for the GUI.
Definition: MeshProcessSelection.hpp:271
QStringList parmDefaults() const
List of default parms.
Definition: MeshProcessSelection.hpp:330
QString name() const
Returns the name of the process.
Definition: MeshProcessSelection.hpp:502
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: MeshProcessSelection.hpp:542
QString description() const
Returns a description of the process for the GUI.
Definition: MeshProcessSelection.hpp:420
QString folder() const
Folder in which to place the process.
Definition: MeshProcessSelection.hpp:499
QStringList parmNames() const
List of named parameters.
Definition: MeshProcessSelection.hpp:222
QStringList parmDescs() const
List of parameters descriptions.
Definition: MeshProcessSelection.hpp:469
QString name() const
Returns the name of the process.
Definition: MeshProcessSelection.hpp:371
QStringList parmDefaults() const
List of default parms.
Definition: MeshProcessSelection.hpp:280
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: MeshProcessSelection.hpp:341
This namespace contains all the API of MorphoGraphX.
Definition: Assert.hpp:26
Unselect all the vertices having a given label.
Definition: MeshProcessSelection.hpp:351
QString folder() const
Folder in which to place the process.
Definition: MeshProcessSelection.hpp:127
QString name() const
Returns the name of the process.
Definition: MeshProcessSelection.hpp:318
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: MeshProcessSelection.hpp:289
QString description() const
Returns a description of the process for the GUI.
Definition: MeshProcessSelection.hpp:48
QStringList parmDescs() const
List of parameters descriptions.
Definition: MeshProcessSelection.hpp:225
QStringList parmNames() const
List of named parameters.
Definition: MeshProcessSelection.hpp:551
QString description() const
Returns a description of the process for the GUI.
Definition: MeshProcessSelection.hpp:175
File containing the definition of a Process.
QStringList parmDescs() const
List of parameters descriptions.
Definition: MeshProcessSelection.hpp:426
QString name() const
Returns the name of the process.
Definition: MeshProcessSelection.hpp:87
QString folder() const
Folder in which to place the process.
Definition: MeshProcessSelection.hpp:457
QStringList parmDescs() const
List of parameters descriptions.
Definition: MeshProcessSelection.hpp:277
This is the main process class, the one all process inherit from.
Definition: Process.hpp:258
QString name() const
Returns the name of the process.
Definition: MeshProcessSelection.hpp:545
QString description() const
Returns a description of the process for the GUI.
Definition: MeshProcessSelection.hpp:133
QStringList parmDescs() const
List of parameters descriptions.
Definition: MeshProcessSelection.hpp:381
QString description() const
Returns a description of the process for the GUI.
Definition: MeshProcessSelection.hpp:321
QString name() const
Returns the name of the process.
Definition: MeshProcessSelection.hpp:216
QString folder() const
Folder in which to place the process.
Definition: MeshProcessSelection.hpp:84
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: MeshProcessSelection.hpp:142
Select all labeled vertices in the current mesh.
Definition: MeshProcessSelection.hpp:247
mgx_EXPORT bool stringToBool(const QString &string)
Helper function converting a string into a boolean.
Select all the unlabel vertices of the current mesh.
Definition: MeshProcessSelection.hpp:195
This namespace contains all the classes needed to define processes.
QStringList parmDescs() const
List of parameters descriptions.
Definition: MeshProcessSelection.hpp:511
QStringList parmDescs() const
List of parameters descriptions.
Definition: MeshProcessSelection.hpp:181
Select vertices if the region with their label is not contiguous (e.g.
Definition: MeshProcessSelection.hpp:482
QString name() const
Returns the name of the process.
Definition: MeshProcessSelection.hpp:45
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: MeshProcessSelection.hpp:57
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: MeshProcessSelection.hpp:514
QStringList parmNames() const
List of named parameters.
Definition: MeshProcessSelection.hpp:508
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: MeshProcessSelection.hpp:557
QString description() const
Returns a description of the process for the GUI.
Definition: MeshProcessSelection.hpp:219
QStringList parmDescs() const
List of parameters descriptions.
Definition: MeshProcessSelection.hpp:54
QStringList parmDescs() const
List of parameters descriptions.
Definition: MeshProcessSelection.hpp:97
QString description() const
Returns a description of the process for the GUI.
Definition: MeshProcessSelection.hpp:505
bool operator()(const QStringList &parms)
Implementation of the process with generic arguments.
Definition: MeshProcessSelection.hpp:359
ParmChoiceMap parmChoice() const
Purely for GUI purposes, provides for some of the parms parameter a choice.
Definition: MeshProcessSelection.hpp:335
Select all the vertices in the current mesh.
Definition: MeshProcessSelection.hpp:25
QString folder() const
Folder in which to place the process.
Definition: MeshProcessSelection.hpp:213
QString folder() const
Folder in which to place the process.
Definition: MeshProcessSelection.hpp:414
Definition: MeshProcessSelection.hpp:297
Extend the current selection to all vertices that are connected to a currently selected vertex...
Definition: MeshProcessSelection.hpp:525
QStringList parmNames() const
List of named parameters.
Definition: MeshProcessSelection.hpp:136
QIcon icon() const
Icon to use to represent the process in the GUI.
Definition: MeshProcessSelection.hpp:387
bool operator()(const QStringList &)
Implementation of the process with generic arguments.
Definition: MeshProcessSelection.hpp:533
QStringList parmDescs() const
List of parameters descriptions.
Definition: MeshProcessSelection.hpp:139
QString folder() const
Folder in which to place the process.
Definition: MeshProcessSelection.hpp:169
QStringList parmDefaults() const
List of default parms.
Definition: MeshProcessSelection.hpp:228
Mesh processes have mutable access to meshes and non-mutable access to stacks.
Definition: Process.hpp:865
bool operator()(const QStringList &)
Implementation of the process with generic arguments.
Definition: MeshProcessSelection.hpp:405
QString description() const
Returns a description of the process for the GUI.
Definition: MeshProcessSelection.hpp:548
QString name() const
Returns the name of the process.
Definition: MeshProcessSelection.hpp:130
Extent the current selection so each label having at least one vertex selected will be fully selected...
Definition: MeshProcessSelection.hpp:440