MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
CSOUndoRedoCommands.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13
15
16#pragma once
17
18
19#include "MLCSOIncludes.h"
20#include "CSOBase/CSOList.h"
21
22#include <mlUndoStep.h>
23
24
26
28
30class MLCSO_EXPORT CSOCommand : public ml::UndoOnlyStep
31{
32public:
34 CSOCommand(const CSOListPtr& csoList);
36 ~CSOCommand() override;
37
41 virtual int execute() = 0;
42
44 void undo() override;
45
47 std::string commandName;
48
49protected:
53 bool checkRedoBehavior() const override
54 {
55 return false;
56 }
57
60};
61
63
66{
67public:
69 CSOCmdAddCSO(const CSOListPtr& csoList, CSO* cso);
71 ~CSOCmdAddCSO() override;
72
74 int execute() override;
75
77 std::string description() const override
78 {
79 return "Remove Contour";
80 }
81
82private:
83 CSO* _addCSO;
84 unsigned int _lastCurrentCSOId;
85 unsigned int _csoId;
86 std::vector<unsigned int> _csoGroupIds;
87};
88
90
93{
94public:
96 CSOCmdRemoveCSO(const CSOListPtr& csoList, CSO* cso);
98 ~CSOCmdRemoveCSO() override;
99
101 int execute() override;
102
104 std::string description() const override
105 {
106 return "Add Contour";
107 }
108
109private:
110 unsigned int _removeCSOId;
111};
112
114
117{
118public:
120 CSOCmdAddCSOGroup(const CSOListPtr& csoList, CSOGroup* group);
123
125 int execute() override;
126
128 std::string description() const override
129 {
130 return "Remove Contour Group";
131 }
132
133private:
134 CSOGroup* _csoGroup;
135 unsigned int _lastCurrentGroupId;
136 unsigned int _groupId;
137 std::vector<unsigned int> _groupCSOIds;
138};
139
141
144{
145public:
147 CSOCmdRemoveCSOGroup(const CSOListPtr& csoList, CSOGroup* group);
150
152 int execute() override;
153
155 std::string description() const override
156 {
157 return "Add Contour Group";
158 }
159
160private:
161 unsigned int _csoGroupId;
162};
163
165
168{
169public:
171 CSOCmdAddCSOtoGroup(const CSOListPtr& csoList, CSO* cso, CSOGroup* group);
174
176 int execute() override;
177
179 std::string description() const override
180 {
181 return "Remove Contour From Group";
182 }
183
184private:
185 unsigned int _csoId;
186 unsigned int _groupId;
187};
188
189
191
194{
195public:
197 CSOCmdRemoveCSOfromGroup(const CSOListPtr& csoList, CSO* cso, CSOGroup* group);
200
202 int execute() override;
203
205 std::string description() const override
206 {
207 return "Add Contour To Group";
208 }
209
210private:
211 unsigned int _csoId;
212 unsigned int _groupId;
213};
214
216
219{
220public:
225
227 int execute() override;
228
230 std::string description() const override
231 {
232 return "Remove Contours";
233 }
234
235private:
236 CSOListPtr _addCSOList;
237};
238
240
243{
244public:
249
251 int execute() override;
252
254 std::string description() const override
255 {
256 return "Move Contour";
257 }
258
259private:
260 unsigned int _csoId;
261 Vector3 _fromPos;
262 Vector3 _toPos;
263 int _fromTimePointIndex;
264 int _toTimePointIndex;
265};
266
268
271{
272public:
274 CSOCmdMoveSeedPoint(const CSOListPtr& csoList, CSO* cso);
277
279 int execute() override;
280
282 std::string description() const override
283 {
284 return "Move Contour Point";
285 }
286
287private:
288 unsigned int _csoId;
289
290 unsigned int _numSeedPoints;
291 unsigned int _numPathPoints;
292
293 Vector3* _seedPositions;
294 std::vector<Vector4>* _pathPointPositionValues;
295};
296
298
301{
302public:
307
309 int execute() override;
310
312 std::string description() const override
313 {
314 return "Add Contour Point";
315 }
316
317private:
318 unsigned int _csoId;
319 std::string _type;
320 std::string _subType;
321
322 CSO _originalGeometry;
323};
324
326
328
331{
332public:
334 CSOCmdAddCSOSet(const CSOListPtr& csoList, const std::vector<CSO*>& csos);
337
339 int execute() override;
340
342 std::string description() const override
343 {
344 return "Remove Contours";
345 }
346
347private:
348 struct CSOUndoRedoData
349 {
350 CSOUndoRedoData()
351 : cso(nullptr)
352 , csoId(0)
353 {}
354 CSOUndoRedoData(CSO* _cso, unsigned int _csoId, const std::vector<unsigned int>& _csoGroupIds)
355 : cso(_cso)
356 , csoId(_csoId)
357 , csoGroupIds(_csoGroupIds)
358 {}
359 CSO* cso;
360 unsigned int csoId;
361 std::vector<unsigned int> csoGroupIds;
362 };
363
364 unsigned int _lastCurrentCSOId;
365 std::vector<CSOUndoRedoData> _csoUndoRedoData;
366};
367
369
372{
373public:
375 CSOCmdRemoveCSOSet(const CSOListPtr& csoList, const std::vector<CSO*>& csos);
378
380 int execute() override;
381
383 std::string description() const override
384 {
385 return "Add Contours";
386 }
387
388private:
389 std::vector<unsigned int> _removeCSOIds;
390};
391
393
396{
397public:
399 CSOCmdModifySet(const CSOListPtr& csoList, const std::vector<CSO*>& csos);
402
404 int execute() override;
405
407 std::string description() const override
408 {
409 return "Change Contours";
410 }
411
412private:
413 struct CSOUndoRedoData
414 {
415 CSOUndoRedoData()
416 : _seedPositions(nullptr)
417 , _pathPointPositionValues(nullptr)
418 {}
419 CSOUndoRedoData(unsigned int csoId, const std::string& type, int markerMode, bool csoIsClosed,
420 unsigned int numSeedPoints, unsigned int numPathPoints, Vector3* seedPositions,
421 std::vector<Vector4>* pathPointPositionValues)
422 : _csoId(csoId)
423 , _type(type)
424 , _seedPointStyle(markerMode)
425 , _csoIsClosed(csoIsClosed)
426 , _numSeedPoints(numSeedPoints)
427 , _numPathPoints(numPathPoints)
428 , _seedPositions(seedPositions)
429 , _pathPointPositionValues(pathPointPositionValues)
430 {}
431
432 unsigned int _csoId;
433 std::string _type;
434 int _seedPointStyle;
435 bool _csoIsClosed;
436 unsigned int _numSeedPoints;
437 unsigned int _numPathPoints;
438 Vector3* _seedPositions;
439 std::vector<Vector4>* _pathPointPositionValues;
440 };
441
442 std::vector<CSOUndoRedoData> _csoUndoRedoData;
443};
444
446
449{
450public:
455
457 int execute() override;
458
460 std::string description() const override
461 {
462 return "Modify Visual Attributes";
463 }
464
465private:
466 unsigned int _csoId;
467
468 Vector3 _pathPointColor;
469 float _pathPointAlpha;
470 int _pathPointStyle;
471 float _pathPointWidth;
472
473 Vector3 _seedPointColor;
474 float _seedPointAlpha;
475 int _seedPointStyle;
476 float _seedPointSize;
477};
478
480
#define MLCSO_EXPORT
Defines export symbols for classes, so they can be used in other DLLs.
Definition MLCSOSystem.h:23
Class for undo/redo of adding a CSOGroup to the CSOList.
CSOCmdAddCSOGroup(const CSOListPtr &csoList, CSOGroup *group)
Constructor.
int execute() override
Method is executed on undo/redo.
std::string description() const override
Undo descriptions are the inverse of the performed operation.
~CSOCmdAddCSOGroup() override
Destructor.
Class for undo/redo of adding multiple CSOs to the CSOList.
int execute() override
Method is executed on undo/redo.
std::string description() const override
Undo descriptions are the inverse of the performed operation.
~CSOCmdAddCSOList() override
Destructor.
CSOCmdAddCSOList(const CSOListPtr &csoList)
Constructor.
Class for undo/redo of of adding a set of CSOs to the CSOList.
int execute() override
Method is executed on undo/redo.
std::string description() const override
Undo descriptions are the inverse of the performed operation.
CSOCmdAddCSOSet(const CSOListPtr &csoList, const std::vector< CSO * > &csos)
Constructor.
~CSOCmdAddCSOSet() override
Destructor.
Class for undo/redo of adding a new CSO to the CSOList.
int execute() override
Method is executed on undo/redo.
std::string description() const override
Undo descriptions are the inverse of the performed operation.
CSOCmdAddCSO(const CSOListPtr &csoList, CSO *cso)
Constructor.
~CSOCmdAddCSO() override
Destructor.
Class for undo/redo of adding a CSO to a CSOGroup.
CSOCmdAddCSOtoGroup(const CSOListPtr &csoList, CSO *cso, CSOGroup *group)
Constructor.
~CSOCmdAddCSOtoGroup() override
Destructor.
std::string description() const override
Undo descriptions are the inverse of the performed operation.
int execute() override
Method is executed on undo/redo.
Class for undo/redo of modifying attributes of a CSO.
int execute() override
Method is executed on undo/redo.
~CSOCmdCSOModifyVisualAttributes() override
Destructor.
std::string description() const override
Undo descriptions are the inverse of the performed operation.
CSOCmdCSOModifyVisualAttributes(const CSOListPtr &csoList, CSO *cso)
Constructor.
Class for undo/redo of the insertion/removal of a single seed point.
std::string description() const override
Undo descriptions are the inverse of the performed operation.
int execute() override
Method is executed on undo/redo.
CSOCmdInsertRemoveSeedPoint(const CSOListPtr &csoList, CSO *cso)
Constructor.
~CSOCmdInsertRemoveSeedPoint() override
Destructor.
Class for undo/redo of modifying a set of CSOs.
~CSOCmdModifySet() override
Destructor.
int execute() override
Method is executed on undo/redo.
std::string description() const override
Undo descriptions are the inverse of the performed operation.
CSOCmdModifySet(const CSOListPtr &csoList, const std::vector< CSO * > &csos)
Constructor.
Class for undo/redo of the moving of a contour.
~CSOCmdMoveContour() override
Destructor.
CSOCmdMoveContour(const CSOListPtr &csoList, CSO *cso, Vector3 fromPos, Vector3 toPos, int fromTPI, int toTPI)
Constructor.
std::string description() const override
Undo descriptions are the inverse of the performed operation.
int execute() override
Method is executed on undo/redo.
Class for undo/redo of the moving of a single seed point.
CSOCmdMoveSeedPoint(const CSOListPtr &csoList, CSO *cso)
Constructor.
std::string description() const override
Undo descriptions are the inverse of the performed operation.
int execute() override
Method is executed on undo/redo.
~CSOCmdMoveSeedPoint() override
Destructor.
Class for undo/redo of removing a CSOGroup from the CSOList.
CSOCmdRemoveCSOGroup(const CSOListPtr &csoList, CSOGroup *group)
Constructor.
std::string description() const override
Undo descriptions are the inverse of the performed operation.
int execute() override
Method is executed on undo/redo.
~CSOCmdRemoveCSOGroup() override
Destructor.
Class for undo/redo of removing a set of CSOs from the CSOList.
int execute() override
Method is executed on undo/redo.
CSOCmdRemoveCSOSet(const CSOListPtr &csoList, const std::vector< CSO * > &csos)
Constructor.
std::string description() const override
Undo descriptions are the inverse of the performed operation.
~CSOCmdRemoveCSOSet() override
Destructor.
Class for undo/redo of removing a CSO from the CSOList.
int execute() override
Method is executed on undo/redo.
~CSOCmdRemoveCSO() override
Destructor.
CSOCmdRemoveCSO(const CSOListPtr &csoList, CSO *cso)
Constructor.
std::string description() const override
Undo descriptions are the inverse of the performed operation.
Class for undo/redo of removing a CSO from a CSOGroup.
CSOCmdRemoveCSOfromGroup(const CSOListPtr &csoList, CSO *cso, CSOGroup *group)
Constructor.
~CSOCmdRemoveCSOfromGroup() override
Destructor.
std::string description() const override
Undo descriptions are the inverse of the performed operation.
int execute() override
Method is executed on undo/redo.
Base class for a CSOCommand for the undo/redo mechanism.
bool checkRedoBehavior() const override
Returns whether the undo/redo behavior should be checked; returns 'false' to disable the check.
~CSOCommand() override
Destructor.
virtual int execute()=0
Execute method that must be overridden by each derived class.
CSOList * _csoList
Pointer to the csoList.
CSOCommand(const CSOListPtr &csoList)
Constructor.
void undo() override
Calls execute.
std::string commandName
The command as a string (for debugging purposes).
A CSOGroup comprises a number of CSOs, which themselves can be in a number of different CSOGroups.
Definition CSOGroup.h:38
A CSOList comprises a number of CSOs and CSOGroups and is the central object for contour segmentation...
Definition CSOList.h:61
The CSO represents a contour segmentation object.
Definition CSO.h:44
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
Tvec3< MLdouble > Vector3
A vector with three components of type double.
Definition mlVector3.h:274