MeVisLab Toolbox Reference
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:
33
35 CSOCommand(const CSOListPtr& csoList);
37 ~CSOCommand() override;
38
42 virtual int execute() = 0;
43
45 void undo() override;
46
48 std::string commandName;
49
50protected:
53 bool checkRedoBehavior() const override { return false; }
54
57};
58
60
63{
64public:
65
67 CSOCmdAddCSO(const CSOListPtr& csoList, CSO* cso);
69 ~CSOCmdAddCSO() override;
70
72 int execute() override;
73
75 std::string description() const override { return "Remove Contour"; }
76
77private:
78
79 CSO* _addCSO;
80 unsigned int _lastCurrentCSOId;
81 unsigned int _csoId;
82 std::vector<unsigned int> _csoGroupIds;
83};
84
86
89{
90public:
91
93 CSOCmdRemoveCSO(const CSOListPtr& csoList, CSO* cso);
95 ~CSOCmdRemoveCSO() override;
96
98 int execute() override;
99
101 std::string description() const override { return "Add Contour"; }
102
103private:
104
105 unsigned int _removeCSOId;
106};
107
109
112{
113public:
114
116 CSOCmdAddCSOGroup(const CSOListPtr& csoList, CSOGroup* group);
119
121 int execute() override;
122
124 std::string description() const override { return "Remove Contour Group"; }
125
126private:
127
128 CSOGroup* _csoGroup;
129 unsigned int _lastCurrentGroupId;
130 unsigned int _groupId;
131 std::vector<unsigned int> _groupCSOIds;
132};
133
135
138{
139public:
141 CSOCmdRemoveCSOGroup(const CSOListPtr& csoList, CSOGroup* group);
144
146 int execute() override;
147
149 std::string description() const override { return "Add Contour Group"; }
150
151private:
152
153 unsigned int _csoGroupId;
154};
155
157
160{
161public:
162
164 CSOCmdAddCSOtoGroup(const CSOListPtr& csoList, CSO* cso, CSOGroup* group);
167
169 int execute() override;
170
172 std::string description() const override { return "Remove Contour From Group"; }
173
174private:
175
176 unsigned int _csoId;
177 unsigned int _groupId;
178};
179
180
182
185{
186public:
187
189 CSOCmdRemoveCSOfromGroup(const CSOListPtr& csoList, CSO* cso, CSOGroup* group);
192
194 int execute() override;
195
197 std::string description() const override { return "Add Contour To Group"; }
198
199private:
200
201 unsigned int _csoId;
202 unsigned int _groupId;
203};
204
206
209{
210public:
211
216
218 int execute() override;
219
221 std::string description() const override { return "Remove Contours"; }
222
223private:
224
225 CSOListPtr _addCSOList;
226};
227
229
232{
233public:
234
239
241 int execute() override;
242
244 std::string description() const override { return "Move Contour"; }
245
246private:
247
248 unsigned int _csoId;
249 Vector3 _fromPos;
250 Vector3 _toPos;
251 int _fromTimePointIndex;
252 int _toTimePointIndex;
253};
254
256
259{
260public:
261
263 CSOCmdMoveSeedPoint(const CSOListPtr& csoList, CSO* cso);
266
268 int execute() override;
269
271 std::string description() const override { return "Move Contour Point"; }
272
273private:
274
275 unsigned int _csoId;
276
277 unsigned int _numSeedPoints;
278 unsigned int _numPathPoints;
279
280 Vector3* _seedPositions;
281 std::vector<Vector4>* _pathPointPositionValues;
282};
283
285
288{
289public:
290
295
297 int execute() override;
298
300 std::string description() const override { return "Add Contour Point"; }
301
302private:
303
304 unsigned int _csoId;
305 std::string _type;
306 std::string _subType;
307
308 CSO _originalGeometry;
309};
310
312
314
317{
318public:
319
321 CSOCmdAddCSOSet(const CSOListPtr& csoList, const std::vector<CSO*>& csos);
324
326 int execute() override;
327
329 std::string description() const override { return "Remove Contours"; }
330
331private:
332
333 struct CSOUndoRedoData
334 {
335 CSOUndoRedoData() : cso(nullptr), csoId(0) {}
336 CSOUndoRedoData(CSO* _cso, unsigned int _csoId, const std::vector<unsigned int>& _csoGroupIds)
337 : cso(_cso), csoId(_csoId), csoGroupIds(_csoGroupIds) {}
338 CSO* cso;
339 unsigned int csoId;
340 std::vector<unsigned int> csoGroupIds;
341 };
342
343 unsigned int _lastCurrentCSOId;
344 std::vector<CSOUndoRedoData> _csoUndoRedoData;
345};
346
348
351{
352public:
353
355 CSOCmdRemoveCSOSet(const CSOListPtr& csoList, const std::vector<CSO*>& csos);
358
360 int execute() override;
361
363 std::string description() const override { return "Add Contours"; }
364
365private:
366
367 std::vector<unsigned int> _removeCSOIds;
368};
369
371
374{
375public:
376
378 CSOCmdModifySet(const CSOListPtr& csoList, const std::vector<CSO*>& csos);
381
383 int execute() override;
384
386 std::string description() const override { return "Change Contours"; }
387
388private:
389
390 struct CSOUndoRedoData
391 {
392 CSOUndoRedoData() : _seedPositions(nullptr), _pathPointPositionValues(nullptr) {}
393 CSOUndoRedoData(unsigned int csoId, const std::string& type, int markerMode, bool csoIsClosed, unsigned int numSeedPoints, unsigned int numPathPoints, Vector3* seedPositions, std::vector<Vector4>* pathPointPositionValues)
394 : _csoId(csoId), _type(type), _seedPointStyle(markerMode), _csoIsClosed(csoIsClosed), _numSeedPoints(numSeedPoints), _numPathPoints(numPathPoints), _seedPositions(seedPositions), _pathPointPositionValues(pathPointPositionValues) {}
395
396 unsigned int _csoId;
397 std::string _type;
398 int _seedPointStyle;
399 bool _csoIsClosed;
400 unsigned int _numSeedPoints;
401 unsigned int _numPathPoints;
402 Vector3* _seedPositions;
403 std::vector<Vector4>* _pathPointPositionValues;
404 };
405
406 std::vector<CSOUndoRedoData> _csoUndoRedoData;
407};
408
410
413{
414public:
415
420
422 int execute() override;
423
425 std::string description() const override { return "Modify Visual Attributes"; }
426
427private:
428
429 unsigned int _csoId;
430
431 Vector3 _pathPointColor;
432 float _pathPointAlpha;
433 int _pathPointStyle;
434 float _pathPointWidth;
435
436 Vector3 _seedPointColor;
437 float _seedPointAlpha;
438 int _seedPointStyle;
439 float _seedPointSize;
440};
441
443
#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 Group.
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 Group.
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
Not every undo step generates a redo step (a previous step might generate two instead),...
~CSOCommand() override
Destructor.
virtual int execute()=0
Execute method, 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 3 components of type double.
Definition mlVector3.h:287