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
25ML_START_NAMESPACE
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:
54 bool checkRedoBehavior() const override { return false; }
55
58};
59
61
64{
65public:
66
68 CSOCmdAddCSO(const CSOListPtr& csoList, CSO* cso);
70 ~CSOCmdAddCSO() override;
71
73 int execute() override;
74
76 std::string description() const override { return "Remove Contour"; }
77
78private:
79
80 CSO* _addCSO;
81 unsigned int _lastCurrentCSOId;
82 unsigned int _csoId;
83 std::vector<unsigned int> _csoGroupIds;
84};
85
87
90{
91public:
92
94 CSOCmdRemoveCSO(const CSOListPtr& csoList, CSO* cso);
96 ~CSOCmdRemoveCSO() override;
97
99 int execute() override;
100
102 std::string description() const override { return "Add Contour"; }
103
104private:
105
106 unsigned int _removeCSOId;
107};
108
110
113{
114public:
115
117 CSOCmdAddCSOGroup(const CSOListPtr& csoList, CSOGroup* group);
120
122 int execute() override;
123
125 std::string description() const override { return "Remove Contour Group"; }
126
127private:
128
129 CSOGroup* _csoGroup;
130 unsigned int _lastCurrentGroupId;
131 unsigned int _groupId;
132 std::vector<unsigned int> _groupCSOIds;
133};
134
136
139{
140public:
142 CSOCmdRemoveCSOGroup(const CSOListPtr& csoList, CSOGroup* group);
145
147 int execute() override;
148
150 std::string description() const override { return "Add Contour Group"; }
151
152private:
153
154 unsigned int _csoGroupId;
155};
156
158
161{
162public:
163
165 CSOCmdAddCSOtoGroup(const CSOListPtr& csoList, CSO* cso, CSOGroup* group);
168
170 int execute() override;
171
173 std::string description() const override { return "Remove Contour From Group"; }
174
175private:
176
177 unsigned int _csoId;
178 unsigned int _groupId;
179};
180
181
183
186{
187public:
188
190 CSOCmdRemoveCSOfromGroup(const CSOListPtr& csoList, CSO* cso, CSOGroup* group);
193
195 int execute() override;
196
198 std::string description() const override { return "Add Contour To Group"; }
199
200private:
201
202 unsigned int _csoId;
203 unsigned int _groupId;
204};
205
207
210{
211public:
212
214 CSOCmdAddCSOList(const CSOListPtr& csoList);
217
219 int execute() override;
220
222 std::string description() const override { return "Remove Contours"; }
223
224private:
225
226 CSOListPtr _addCSOList;
227};
228
230
233{
234public:
235
237 CSOCmdMoveContour(const CSOListPtr& csoList, CSO* cso, Vector3 fromPos, Vector3 toPos, int fromTPI, int toTPI);
240
242 int execute() override;
243
245 std::string description() const override { return "Move Contour"; }
246
247private:
248
249 unsigned int _csoId;
250 Vector3 _fromPos;
251 Vector3 _toPos;
252 int _fromTimePointIndex;
253 int _toTimePointIndex;
254};
255
257
260{
261public:
262
264 CSOCmdMoveSeedPoint(const CSOListPtr& csoList, CSO* cso);
267
269 int execute() override;
270
272 std::string description() const override { return "Move Contour Point"; }
273
274private:
275
276 unsigned int _csoId;
277
278 unsigned int _numSeedPoints;
279 unsigned int _numPathPoints;
280
281 Vector3* _seedPositions;
282 std::vector<Vector4>* _pathPointPositionValues;
283};
284
286
289{
290public:
291
293 CSOCmdInsertRemoveSeedPoint(const CSOListPtr& csoList, CSO* cso);
296
298 int execute() override;
299
301 std::string description() const override { return "Add Contour Point"; }
302
303private:
304
305 unsigned int _csoId;
306 std::string _type;
307 std::string _subType;
308
309 CSO _originalGeometry;
310};
311
313
315
318{
319public:
320
322 CSOCmdAddCSOSet(const CSOListPtr& csoList, const std::vector<CSO*>& csos);
325
327 int execute() override;
328
330 std::string description() const override { return "Remove Contours"; }
331
332private:
333
334 struct CSOUndoRedoData
335 {
336 CSOUndoRedoData() : cso(nullptr), csoId(0) {}
337 CSOUndoRedoData(CSO* _cso, unsigned int _csoId, const std::vector<unsigned int>& _csoGroupIds)
338 : cso(_cso), csoId(_csoId), csoGroupIds(_csoGroupIds) {}
339 CSO* cso;
340 unsigned int csoId;
341 std::vector<unsigned int> csoGroupIds;
342 };
343
344 unsigned int _lastCurrentCSOId;
345 std::vector<CSOUndoRedoData> _csoUndoRedoData;
346};
347
349
352{
353public:
354
356 CSOCmdRemoveCSOSet(const CSOListPtr& csoList, const std::vector<CSO*>& csos);
359
361 int execute() override;
362
364 std::string description() const override { return "Add Contours"; }
365
366private:
367
368 std::vector<unsigned int> _removeCSOIds;
369};
370
372
375{
376public:
377
379 CSOCmdModifySet(const CSOListPtr& csoList, const std::vector<CSO*>& csos);
382
384 int execute() override;
385
387 std::string description() const override { return "Change Contours"; }
388
389private:
390
391 struct CSOUndoRedoData
392 {
393 CSOUndoRedoData() : _seedPositions(nullptr), _pathPointPositionValues(nullptr) {}
394 CSOUndoRedoData(unsigned int csoId, const std::string& type, int markerMode, bool csoIsClosed, unsigned int numSeedPoints, unsigned int numPathPoints, Vector3* seedPositions, std::vector<Vector4>* pathPointPositionValues)
395 : _csoId(csoId), _type(type), _seedPointStyle(markerMode), _csoIsClosed(csoIsClosed), _numSeedPoints(numSeedPoints), _numPathPoints(numPathPoints), _seedPositions(seedPositions), _pathPointPositionValues(pathPointPositionValues) {}
396
397 unsigned int _csoId;
398 std::string _type;
399 int _seedPointStyle;
400 bool _csoIsClosed;
401 unsigned int _numSeedPoints;
402 unsigned int _numPathPoints;
403 Vector3* _seedPositions;
404 std::vector<Vector4>* _pathPointPositionValues;
405 };
406
407 std::vector<CSOUndoRedoData> _csoUndoRedoData;
408};
409
411
414{
415public:
416
418 CSOCmdCSOModifyVisualAttributes(const CSOListPtr& csoList, CSO* cso);
421
423 int execute() override;
424
426 std::string description() const override { return "Modify Visual Attributes"; }
427
428private:
429
430 unsigned int _csoId;
431
432 Vector3 _pathPointColor;
433 float _pathPointAlpha;
434 int _pathPointStyle;
435 float _pathPointWidth;
436
437 Vector3 _seedPointColor;
438 float _seedPointAlpha;
439 int _seedPointStyle;
440 float _seedPointSize;
441};
442
444
445ML_END_NAMESPACE
#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
Tvec3< MLdouble > Vector3
A vector with three components of type double.
Definition mlVector3.h:286