MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
CSOList.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
17
18#pragma once
19
20#include "MLCSOIncludes.h"
21
22#include "CSO.h"
23#include "CSOScopeEvents.h"
24#include "CSOEvent.h"
26
28
30
32typedef void csoNotificationCB(void* data, int notificationFlag);
33
35
38class CSOManager;
39class CSOGroup;
40
41class CSOLoad;
43
44// Define that can be used to detect if the CSOList is reference counted.
45#define ML_CSOLIST_REFCOUNTED 1
46
47// Declare CSOListPtr smart pointer.
48ML_REFCOUNTED_PTR(CSOList)
49
50
51
52
61{
62
63public:
68 CSOList(const CSOList& csoList);
69
70protected:
76 ~CSOList() override;
77
79
80public:
81 /* DATA STRUCTURES */
82
86 {
88 {
89 notificationCB = nullptr;
90 notificationCBData = nullptr;
91 notificationFlag = NOTIFICATION_NONE;
92 }
96 };
97
98 /* METHODS */
99
101
103 void clone(const CSOList& csoList, bool useUndoRedo = false);
110
112
115 bool saveTo(std::string& filename, bool binary, std::string& message, ModuleBackgroundTask* task = nullptr) const;
118 bool saveTo(std::ostream& outStream, bool binary, ModuleBackgroundTask* task = nullptr) const;
121 bool loadFrom(std::string& filename, std::string& message, ModuleBackgroundTask* task = nullptr);
124 bool loadFrom(std::istream& inStream, bool binary, std::string& message, ModuleBackgroundTask* task = nullptr);
125
127
129 void addNotificationObserver(csoNotificationCB* callback, void* userData);
131 void removeNotificationObserver(csoNotificationCB* callback, void* userData);
133 void notifyObservers(int notificationFlag);
135 static void removeNotificationObserverFromAllCSOLists(csoNotificationCB* callback, void* userData);
138
140
143
145
148 {
149 return _csoUndoRedoManager;
150 }
153 {
154 return _csoManager;
155 }
156
159 {
160 _csoUndoRedoManager = undoRedoManager;
161 }
164
166
169 unsigned int getCurrentCSOId();
170
172 void updateCurrentCSOId(unsigned int newId);
173
176 unsigned int getCurrentGroupId();
178 inline void setCurrentCSOId(unsigned int id)
179 {
180 _currentLastCSOId = id;
181 }
183 inline void setCurrentGroupId(unsigned int id)
184 {
185 _currentLastGroupId = id;
186 }
187
189 void updateCurrentGroupId(const unsigned int newId);
190
192
195 bool isSelected(const CSO* cso) const;
197 bool isSelected(const CSOGroup* group) const;
198
200 void addSelected(CSO* cso);
202 void addSelected(CSOGroup* group);
203
208 bool setSelected(CSO* cso);
213 bool setSelected(CSOGroup* group);
214
221
225 void removeFromSelection(const std::vector<CSO*>& csos);
229 void removeFromSelection(const std::vector<CSOGroup*>& groups);
230
232 inline unsigned int numSelectedCSOs() const
233 {
234 return static_cast<unsigned int>(_selectedCSOs.size());
235 }
237 inline unsigned int numSelectedGroups() const
238 {
239 return static_cast<unsigned int>(_selectedGroups.size());
240 }
241
243 inline CSO* getSelectedCSOAt(unsigned int index) const
244 {
245 if (_selectedCSOs.size() > 0) {
246 return _selectedCSOs[index];
247 }
248 else {
249 return nullptr;
250 }
251 }
253 inline CSOGroup* getSelectedGroupAt(unsigned int index) const
254 {
255 if (_selectedGroups.size() > 0) {
256 return _selectedGroups[index];
257 }
258 else {
259 return nullptr;
260 }
261 }
264
267
274
277 {
278 return _currentlyUnderMouseCSO;
279 }
283
286 [[deprecated("Use 'CSOList::getCenterOfSelectedCSOs(bool& resultIsValid)' instead.")]]
288 {
289 bool resultIsValid;
290 return getCenterOfSelectedCSOs(resultIsValid);
291 }
294 [[deprecated("Use 'CSOList::getCenterOfSelectedGroups(bool& resultIsValid)' instead.")]]
296 {
297 bool resultIsValid;
298 return getCenterOfSelectedGroups(resultIsValid);
299 }
300
302
304 CSO* addCSO(bool useUndoRedo = true);
309 CSO* addCSO(const std::vector<Vector3>& seedPositions, bool closed, bool useUndoRedo);
312 CSO* addCSO(unsigned int numSeedPoints, bool closed, bool useUndoRedo);
314 CSO* addCSOCopy(CSO* cso, bool useUndoRedo = true, unsigned int csoId = INVALID_CSO_ID);
318 CSOGroup* addGroup(const std::string& label, bool useUndoRedo = true);
321 CSOGroup* addGroupCopy(CSOGroup* group, bool useUndoRedo = true, unsigned int groupId = INVALID_CSO_ID);
322
324 CSO* addPoint(const Vector3& position, const std::string& subtype = "point");
327 CSO* addCircle(const Vector3& midPoint, const Vector3& normal, double radius, double pointDistanceInMM = 1.,
328 const std::string& subtype = "circle");
330 CSO* addArrow(const Vector3& pointAt, const Vector3& direction, double length, double pointDistanceInMM = 1.,
331 const std::string& subtype = "arrow");
333 CSO* addPolygon(const std::vector<Vector3>& points, double pointDistanceInMM = 1.,
334 const std::string& subtype = "polygon");
336 CSO* addPolyline(const std::vector<Vector3>& points, double pointDistanceInMM = 1.,
337 const std::string& subtype = "polyline");
340 CSO* addClosedSpline(const std::vector<Vector3>& points, bool useInterpolation = true, double pointDistanceInMM = 1.,
341 const std::string& subtype = "spline");
344 CSO* addOpenSpline(const std::vector<Vector3>& points, bool useInterpolation = true, double pointDistanceInMM = 1.,
345 const std::string& subtype = "spline");
353 double pointDistanceInMM = 1., const std::string& subtype = "rectangle");
362 double pointDistanceInMM = 1., const std::string& subtype = "ellipse");
365 bool removeCSO(CSO* cso, bool useUndoRedo = true);
368 bool removeCSO(unsigned int id, bool useUndoRedo = true);
371 bool removeAllCSO(bool useUndoRedo = true);
374 bool removeGroup(CSOGroup* group, bool useUndoRedo = true);
377 bool removeGroup(unsigned int id, bool useUndoRedo = true);
383 bool removeGroups(const std::vector<CSOGroup*>& groupsToRemove, bool useUndoRedo = true);
384
387 bool removeAll(bool useUndoRedo = true);
388
390
392 CSO* getCSOAt(unsigned int index) const;
395 CSO* getCSOById(unsigned int id) const;
398 CSO* getCSOByLabel(const std::string& label) const;
400 unsigned int getCSOIndex(CSO* cso) const;
402 unsigned int getCSOIndex(unsigned int id) const;
404 bool hasCSO(CSO* cso) const;
405
407
409 CSOGroup* getGroupById(unsigned int id) const;
411 CSOGroup* getGroupByLabel(const std::string& label) const;
413 CSOGroup* getGroupAt(unsigned int index) const;
415 unsigned int getGroupIndex(CSOGroup* group) const;
417 unsigned int getGroupIndex(unsigned int id) const;
419 bool hasGroup(CSOGroup* group) const;
420
422
426 std::string getUniqueCSOLabel(std::string label, std::string format, bool addIdAlways);
427
431 std::string getUniqueGroupLabel(std::string label, std::string format, bool addIdAlways);
432
438 {
439 _csoLabelUniqueIdMap.clear();
440 }
441
447 {
448 _groupLabelUniqueIdMap.clear();
449 }
450
452
454 bool combineCSOandGroup(CSO* cso, CSOGroup* group, bool useUndoRedo = true);
456 void breakCSOandGroup(CSO* cso, CSOGroup* group, bool useUndoRedo = true);
458 void breakCSOfromAllGroups(CSO* cso, bool useUndoRedo = true);
460 void breakAllCSOsFromGroup(CSOGroup* group, bool useUndoRedo = true);
463
465
467 unsigned int numCSOs() const;
469 unsigned int numGroups() const;
470
472
477
479
481 void undo();
483 void redo();
484
486
489 {
490 _csoUndoRedoManagerEnabled = true;
491 }
494
496
501
504
508 void sendPreEvent(CSOEvent::CSOEventType eventType, unsigned int csoId);
511 void sendPreEvent(CSOEvent::CSOEventType eventType, unsigned int csoId, const CSOIdVector& groupIds);
514 void sendPreEvent(CSOEvent::CSOEventType eventType, unsigned int csoId, unsigned int groupId);
516 void sendPreEvent(CSOEvent::CSOEventType eventType, const CSOIdVector& csoIds);
518 void sendPreEvent(CSOEvent::CSOEventType eventType, const CSOIdVector& csoIds, const CSOIdVector& groupIds);
519
520
524 void sendPostEvent(CSOEvent::CSOEventType eventType, unsigned int csoId);
527 void sendPostEvent(CSOEvent::CSOEventType eventType, unsigned int csoId, unsigned int groupId);
529 void sendPostEvent(CSOEvent::CSOEventType eventType, const CSOIdVector& csoIds);
532 void sendPostEvent(CSOEvent::CSOEventType eventType, unsigned int csoId, const CSOIdVector& groupIds);
534 void sendPostEvent(CSOEvent::CSOEventType eventType, const CSOIdVector& csoIds, const CSOIdVector& groupIds);
535
543
545
548 {
549 return _listChangeId;
550 }
554 {
555 return _geometryChangeId;
556 }
561
563
566 {
567 _enableRepaintObserver = true;
568 }
571 {
572 _enableRepaintObserver = false;
573 }
574
577 {
578 _enableFinishedObserver = true;
579 }
582 {
583 _enableFinishedObserver = false;
584 }
585
588 {
589 _enableInteractionObserver = true;
590 }
593 {
594 _enableInteractionObserver = false;
595 }
596
599 {
600 _enableSelectionObserver = true;
601 }
604 {
605 _enableSelectionObserver = false;
606 }
607
610 {
611 _enableStartNewCSOObserver = true;
612 }
615 {
616 _enableStartNewCSOObserver = false;
617 }
618
621 {
622 _enableCSOMovedObserver = true;
623 }
626 {
627 _enableCSOMovedObserver = false;
628 }
629
632 {
633 _enableCSOCurrentlyUnderMouseObserver = true;
634 }
637 {
638 _enableCSOCurrentlyUnderMouseObserver = false;
639 }
640
642
644 inline bool isUndoRedoManagerEnabled() const
645 {
646 return _csoUndoRedoManagerEnabled;
647 }
649 void openUndoRedoGroup(const std::string& description = "Contour Operation");
652
654
657 {
658 return _enableRepaintObserver;
659 }
662 {
663 return _enableFinishedObserver;
664 }
667 {
668 return _enableInteractionObserver;
669 }
672 {
673 return _enableSelectionObserver;
674 }
677 {
678 return _enableStartNewCSOObserver;
679 }
682 {
683 return _enableCSOMovedObserver;
684 }
687 {
688 return _enableCSOCurrentlyUnderMouseObserver;
689 }
690
692
694 static void alignSeedPathLinks(CSO* cso);
695
697
701
704 NOTIFICATION_NONE = 0,
706 NOTIFICATION_CSO_SELECTION = 1,
708 NOTIFICATION_GROUP_SELECTION = 2,
710 NOTIFICATION_CSO_FINISHED = 4,
712 NOTIFICATION_GROUP_FINISHED = 8,
714 NOTIFICATION_REPAINT = 16,
716 NOTIFICATION_INTERACTION_INIT = 32,
718 NOTIFICATION_START_NEW_CSO = 64,
720 NOTIFICATION_CSO_MOVED = 128,
722 NOTIFICATION_CSO_UNDER_MOUSE_CHANGED = 256,
724 NOTIFICATION_UNDO_REDO_STATE_CHANGED = 512
725 };
726
728
731 {
732 return _rules;
733 }
734
736 void addStateToTree(TreeNode* /*parent*/) const override;
737
739 void readStateFromTree(TreeNode* /*parent*/) override;
740
741 // Sets current version number.
743
745 CSOList* deepCopy() const override
746 {
747 return new CSOList(*this);
748 };
749
750protected:
751 // nothing so far
752
753private:
754 /* DATA STRUCTURES */
755
757 struct IndexPair
758 {
759 IndexPair()
760 {
761 index0 = index1 = -1;
762 }
763 int index0, index1;
764 };
765
766
767 /* MEMBER VARIABLES */
768
770 CSOListRules _rules;
771
773 std::vector<CSO*> _csoList;
775 std::vector<CSOGroup*> _groupList;
776
778 std::vector<CSO*> _selectedCSOs;
780 std::vector<CSOGroup*> _selectedGroups;
781
783 CSO* _currentlyUnderMouseCSO;
784
786 bool _csoUndoRedoManagerEnabled;
788 CSOUndoRedoManager* _csoUndoRedoManager;
790 CSOManager* _csoManager;
791
792
795 unsigned int _currentLastCSOId;
798 unsigned int _currentLastGroupId;
799
800
802 static std::vector<CSOList*> _registeredCSOLists;
803
805 std::vector<CSONotificationCBData> _notificationObservers;
806
808 std::map<std::string, int> _csoLabelUniqueIdMap;
809
811 std::map<std::string, int> _groupLabelUniqueIdMap;
812
813 MLuint64 _listChangeId;
814 MLuint64 _geometryChangeId;
815 static MLuint64 _uniqueListChangeId;
816
818 bool _enableRepaintObserver;
820 bool _enableFinishedObserver;
822 bool _enableInteractionObserver;
824 bool _enableSelectionObserver;
826 bool _enableStartNewCSOObserver;
828 bool _enableCSOMovedObserver;
830 bool _enableCSOCurrentlyUnderMouseObserver;
831
833 int _numberOfEventMuteRequests;
834
835
836 /* METHODS */
837
839 inline bool _canUseUndoRedo(bool shouldUseUndoRedo) const
840 {
841 return shouldUseUndoRedo && _csoUndoRedoManagerEnabled && _csoUndoRedoManager;
842 }
844 void _setDefaultValues(CSO* cso);
846 void _setDefaultValues(CSOGroup* group);
848 void _setDefaultRules(CSOGroup* group);
849
851 void _emptyInternalListOfCSOs();
853 void _emptyInternalListOfGroups();
854
856 CSOIdVector _filterContainedGroups(const std::vector<CSOGroup*>& groups, const std::vector<CSOGroup*>& container);
857 CSOIdVector _filterContainedCSOs(const std::vector<CSO*>& csos, const std::vector<CSO*>& container);
858
860 bool pathPointListIndexIsInRange(CSO* cso, int index) const;
862 bool seedPointIndexIsRange(CSO* cso, int index) const;
863
865 void killAll();
866
869 bool _fromStreamV1(std::istream& inStream, std::string& message);
872 bool _fromStreamV3(std::istream& inStream, std::string& message);
875 bool _fromStreamV4(std::istream& inStream, std::string& message);
878 bool _fromStreamV5(std::istream& inStream, bool asBinary, std::string& message);
880 bool loadFromVersionBefore5(std::istream& inStream, bool binary, short version, bool swapBytes, std::string& message);
883 bool _fromStreamV6(std::istream& inStream, bool asBinary, std::string& message, ModuleBackgroundTask* task = nullptr);
884
886 void reconstructPathPointListToSeedPointLinks(CSO* cso, std::vector<IndexPair>& pathIndexPairs,
887 std::vector<IndexPair>& seedIndexPairs, const std::string& version,
888 std::string& message);
889
892 bool _checkLine(const std::string& line, const std::string& name, std::string& errorMessage);
893
895 inline std::string spaces(unsigned int numSpaces) const
896 {
897 std::stringstream result;
898 for (unsigned int i = 0; i < numSpaces; ++i) {
899 result << " ";
900 }
901 return result.str();
902 }
903
906 std::string buildLabel(std::string label, std::string format, int id)
907 {
908 // Example: buildLabel("cso", " (%i)", 9) returns "cso (0)"
909 size_t p = format.find("%i");
910 if (p == std::string::npos) {
911 format.append("%i");
912 p = format.find("%i");
913 }
914 std::stringstream ss;
915 ss << id;
916 std::string tmp = format.replace(p, 2, ss.str());
917 return label.append(tmp);
918 }
919
921 static void registerCSOList(CSOList* csoList);
923 static void deregisterCSOList(CSOList* csoList);
924
925 friend class CSOLoad;
926
928};
929
931
std::map< unsigned int, unsigned int > CSOIdToCSOIdMap
Defines a map type to map old CSOIds to new CSOIds when merging CSOLists.
const unsigned int INVALID_CSO_ID
Defines a CSO/CSOGroup ID that is invalid.
std::vector< unsigned int > CSOIdVector
Defines a vector to hold CSO and CSOGroup IDs.
#define MLCSO_EXPORT
Defines export symbols for classes, so they can be used in other DLLs.
Definition MLCSOSystem.h:23
Class for all CSO events.
Definition CSOEvent.h:39
CSOEventType
Enumeration for specifying the exact type of event.
Definition CSOEvent.h:47
A CSOGroup comprises a number of CSOs, which themselves can be in a number of different CSOGroups.
Definition CSOGroup.h:38
The CSOListRules class controls how the CSOList should treat CSOGroups if their CSOs are removed.
A CSOList comprises a number of CSOs and CSOGroups and is the central object for contour segmentation...
Definition CSOList.h:61
void setupCSOList()
void updateCurrentGroupId(const unsigned int newId)
Updates the current CSOGroup ID if the new ID is larger than the current ID.
~CSOList() override
The CSOList destructor is protected since the CSOList ownership is managed by the CSOListPtr intrusiv...
CSO * addCSO(const std::vector< Vector3 > &seedPositions, bool closed, bool useUndoRedo)
Adds a new CSO to the list and returns its pointer.
void sendModuleEventGroup(CSOEvent *event)
Sends a module CSOGroup event.
void enableFinishedObserver()
Enables the finished observer mechanism.
Definition CSOList.h:576
Vector3 getCenterOfSelectedCSOs(bool &resultIsValid) const
Returns the center position of all bounding boxes of all selected CSOs.
MLuint64 getListChangeId() const
Returns the list change ID that changes whenever a CSO is added or removed (unique accross all CSOLis...
Definition CSOList.h:547
unsigned int getCSOIndex(CSO *cso) const
Returns the index of the specified CSO in its list.
CSO * addCSO(unsigned int numSeedPoints, bool closed, bool useUndoRedo)
Adds a new CSO to the list and returns its pointer.
CSOGroup * addGroup(const std::string &label, bool useUndoRedo=true)
Adds a new CSOGroup with specified label to the list and returns a pointer to it.
bool isStartNewCSONotificationEnabled() const
Returns whether the 'start new CSO' notification is enabled.
Definition CSOList.h:676
void breakCSOfromAllGroups(CSO *cso, bool useUndoRedo=true)
Breaks all combinations of the specified CSO and any CSOGroup.
CSOIdVector getSelectedCSOIds()
Returns a vector with IDs of the selected CSOs.
unsigned int getGroupIndex(unsigned int id) const
Returns the index of the CSOGroup with the specified ID in its list.
void disableCSOMovedObserver()
Disables the 'CSO moved' observer mechanism.
Definition CSOList.h:625
bool saveTo(std::string &filename, bool binary, std::string &message, ModuleBackgroundTask *task=nullptr) const
Pipes the internal structure of a this list (CSOs and CSOGroups) into the specified file.
CSO * addArrow(const Vector3 &pointAt, const Vector3 &direction, double length, double pointDistanceInMM=1., const std::string &subtype="arrow")
Adds an arrow pointing to pointAt from direction with a length.
CSO * addCSOCopy(CSO *cso, bool useUndoRedo=true, unsigned int csoId=INVALID_CSO_ID)
Adds a copy of the specified CSO to the list and returns a pointer to it.
bool setSelected(CSO *cso)
Sets the specified CSO as being selected and deselects all other CSOs.
CSOList(const CSOList &csoList)
Copy constructor.
CSOList * deepCopy() const override
Creates a deep copy of the CSOList.
Definition CSOList.h:745
void sendPreEvent(CSOEvent::CSOEventType eventType, unsigned int csoId, unsigned int groupId)
Sends a pre-event with the specified type, CSO ID, and CSOGroup ID.
void enableInteractionObserver()
Enables the interaction observer mechanism.
Definition CSOList.h:587
CSO * addPolyline(const std::vector< Vector3 > &points, double pointDistanceInMM=1., const std::string &subtype="polyline")
Adds a linearly interpolated open polyline with the specified points as seed points.
bool isSelected(const CSOGroup *group) const
Returns whether the specified CSOGroup is currently selected.
void resetUniqueGroupLabelIdMap()
Resets the data structure that is used to determine unique IDs for getUniqueCSOLabel Afterward,...
Definition CSOList.h:446
CSOGroup * getGroupById(unsigned int id) const
Returns a pointer to a CSOGroup with the specified ID.
CSOUndoRedoManager * getUndoRedoManager()
Returns a pointer to the undo/redo manager of this CSOList.
Definition CSOList.h:147
CSOList(bool shouldRegisterCSOList)
void sendPreEvent(CSOEvent::CSOEventType eventType, const CSOIdVector &csoIds)
Sends a pre-event with the specified event type and the CSO IDs.
bool hasCSO(CSO *cso) const
Returns whether there is the specified CSO in the list.
bool removeGroups(const std::vector< CSOGroup * > &groupsToRemove, bool useUndoRedo=true)
Removes all CSOGroups with specified IDs and removes them from CSOs Returns whether the operation was...
bool removeCSO(unsigned int id, bool useUndoRedo=true)
Removes a CSO by its ID and removes it from all CSOGroups.
std::string getUniqueCSOLabel(std::string label, std::string format, bool addIdAlways)
Returns a unique CSO label that includes the specified label and combines it with a unique ID using t...
unsigned int getCurrentGroupId()
Returns the current last ID (incremented each call) for CSOGroups.
CSOGroup * addGroup(bool useUndoRedo=true)
Adds a new CSOGroup to the list and returns a pointer to it.
unsigned int numCSOs() const
Returns the number of CSOs in the list.
void disableFinishedObserver()
Disables the finished observer mechanism.
Definition CSOList.h:581
void listChanged()
Called whenever the list has changed to generate a new ID. This also changes the geometry ID.
CSOIdVector getAllCSOIds() const
Returns a vector with the IDs of the CSOs contained in the list.
void removeFromSelection(CSO *cso)
Removes the specified CSO from the list of selected CSOs.
void addSelected(CSOGroup *group)
Adds the specified CSOGroup to the list of selected CSOGroups (no double entry).
void addSelected(CSO *cso)
Adds the specified CSO to the list of selected CSOs (no double entry).
CSOGroup * getGroupAt(unsigned int index) const
Returns the CSOGroup at the specified index position.
void breakAllCSOsFromGroup(CSOGroup *group, bool useUndoRedo=true)
Breaks all combinations of the specified CSOGroup and any CSO.
void sendPostEvent(CSOEvent::CSOEventType eventType, unsigned int csoId, const CSOIdVector &groupIds)
Sends a post-event with the specified type, CSO ID, and CSOGroup IDs.
void sendPostEvent(CSOEvent::CSOEventType eventType, const CSOIdVector &csoIds, const CSOIdVector &groupIds)
Sends a post-event with the specified type, CSO IDs, and CSOGroup IDs.
void registerCSOListForNotificationObservers()
Registers this CSOList in the static list of CSOLists for handling observers.
void sendPostEvent(CSOEvent::CSOEventType eventType, const CSOIdVector &csoIds)
Sends a post-event with the specified type and CSO IDs.
CSO * addCSO(bool useUndoRedo=true)
Adds a new CSO to the list and returns its pointer.
void setManager(CSOManager *manager)
Sets the pointer to the internal manager and sets the CSOGroup default rules.
void undo()
Performs an undo of the last modification.
void setCurrentCSOId(unsigned int id)
Sets the current last ID for CSOs. Do not tamper with it.
Definition CSOList.h:178
void removeNotificationObserver(csoNotificationCB *callback, void *userData)
Removes a notification observer from this CSOList.
bool isNotMutingEvents()
Returns whether CSOEvents are currently emitted.
CSO * getCSOById(unsigned int id) const
Returns a pointer to the CSO with the specified unique ID.
CSOGroup * getGroupByLabel(const std::string &label) const
Returns a pointer to a CSOGroup with the specified label.
void sendCloseEventGroup()
Sends a CSOLIST_EVENT_GROUP_CLOSE event to let listeners combine preceding events....
void clearSelectedCSOs()
Clears all selected CSOs.
void enableSelectionObserver()
Enables the selection observer mechanism.
Definition CSOList.h:598
CSOList()
Standard constructor.
bool removeGroup(CSOGroup *group, bool useUndoRedo=true)
Removes the specified CSOGroup and removes the CSOGroup from all CSOs.
CSOIdVector getAllGroupIds() const
Returns a vector with the IDs of the CSOGroups contained in the list.
void enableStartNewCSOObserver()
Enables the 'start new CSO' observer mechanism.
Definition CSOList.h:609
void enableUndoRedoManager()
Enables the undo/redo mechanism.
Definition CSOList.h:488
bool removeAll(bool useUndoRedo=true)
Removes all CSOs and CSOGroups and resets all else.
void clone(const CSOList &csoList, bool useUndoRedo=false)
Clones the internal CSOs and CSOGroups of the specified CSOList to this one.
void notifyObservers(int notificationFlag)
Notifies all observers.
bool isInteractionInitNotificationEnabled() const
Returns whether the interaction init notification is enabled.
Definition CSOList.h:666
unsigned int numSelectedCSOs() const
Returns the number of selected CSOs.
Definition CSOList.h:232
CSO * addCircle(const Vector3 &midPoint, const Vector3 &normal, double radius, double pointDistanceInMM=1., const std::string &subtype="circle")
Adds a circle CSO with its midPoint at the specified position and a specified radius.
void merge(const CSOList &csoList, const CSOGroupMergeHandling mergeMode, CSOIdToCSOIdMap &origToThisGroupIdMap, CSOIdToCSOIdMap &origToThisCSOIdMap, bool useUndoRedo=false)
Merges the internal CSOs and CSOGroups of the specified CSOList to this one with the specified merge ...
void updateCurrentCSOId(unsigned int newId)
Updates the current ID if the new ID is larger than the current ID.
bool isFinishedNotificationEnabled() const
Returns whether the finished notification is enabled.
Definition CSOList.h:661
void merge(const CSOList &csoList, bool mergeGroupWithSameLabel, CSOIdToCSOIdMap &origToThisGroupIdMap, CSOIdToCSOIdMap &origToThisCSOIdMap, bool useUndoRedo=false)
Merges the internal CSOs and CSOGroups of the specified CSOList to this one.
bool removeCSO(CSO *cso, bool useUndoRedo=true)
Removes a specified CSO from the list and from CSOGroups it is in.
bool isSelectionNotificationEnabled() const
Returns whether the selection notification is enabled.
Definition CSOList.h:671
void sendPreEvent(CSOEvent::CSOEventType eventType, const CSOIdVector &csoIds, const CSOIdVector &groupIds)
Sends a pre-event with the specified event type, CSO IDs, and CSOGroup IDs.
MLuint64 getGeometryChangeId() const
Returns the geometry change ID that changes on any CSO geometry change or list change (unique accross...
Definition CSOList.h:553
CSOGroup * addGroupCopy(CSOGroup *group, bool useUndoRedo=true, unsigned int groupId=INVALID_CSO_ID)
Adds a copy of the specified CSOGroup to this list and returns a pointer to it.
bool saveTo(std::ostream &outStream, bool binary, ModuleBackgroundTask *task=nullptr) const
Pipes the internal structure of a this list (CSOs and CSOGroups) into the specified stream.
static EnumValues< CSOPathPointsStyle > getLineStyleModes()
void sendOpenEventGroup()
Sends a CSOLIST_EVENT_GROUP_OPEN event to let listeners combine following events.
unsigned int numSelectedGroups() const
Returns the number of selected CSOGroups.
Definition CSOList.h:237
void removeFromSelection(const std::vector< CSO * > &csos)
Removes the specified CSOs from the list of selected CSOs.
CSO * getSelectedCSOAt(unsigned int index) const
Returns a pointer to the selected CSO at the specified index; no checking!
Definition CSOList.h:243
unsigned int getCSOIndex(unsigned int id) const
Returns the index of the CSO with the specified ID in its list.
bool isUndoRedoManagerEnabled() const
Returns 'true' if the undo/redo mechanism is enabled, 'false' otherwise.
Definition CSOList.h:644
void sendPreEvent(CSOEvent::CSOEventType eventType, unsigned int csoId)
Sends a pre-event with the specified event type and the CSO ID.
CSO * addEllipse(const Vector3 &midPoint, const Vector3 &uVector, const Vector3 &vVector, double angleInRadian=.0, double pointDistanceInMM=1., const std::string &subtype="ellipse")
Adds an ellipse with a specified midPoint, uVector, and vVector.
CSO * getCSOByLabel(const std::string &label) const
Returns a pointer to the first CSO with the specified label.
ML_SET_ADDSTATE_VERSION(1)
void addStateToTree(TreeNode *) const override
Attaches the object state as children of the specified parent node.
bool isCSOMovedNotificationEnabled() const
Returns whether the 'CSO moved' notification is enabled.
Definition CSOList.h:681
bool removeAllCSO(bool useUndoRedo=true)
Removes all CSOs from the list and from all CSOGroups they are in.
void resetUniqueCSOLabelIdMap()
Resets the data structure that is used to determine unique IDs for getUniqueCSOLabel.
Definition CSOList.h:437
CSO * getCSOCurrentlyUnderMouse() const
Returns the pointer to the CSO currently under the mouse cursor.
Definition CSOList.h:276
void disableSelectionObserver()
Disables the selection observer mechanism.
Definition CSOList.h:603
void removeFromSelection(const std::vector< CSOGroup * > &groups)
Removes the specified CSOGroups from the list of selected CSOGroups.
void sendPostEvent(CSOEvent::CSOEventType eventType, unsigned int csoId, unsigned int groupId)
Sends a post-event with the specified type, CSO ID, and CSOGroup ID.
CSO * addPoint(const Vector3 &position, const std::string &subtype="point")
Adds a point CSO at the specified position.
void setCurrentGroupId(unsigned int id)
Sets the current last ID for CSOGroups. Do not tamper with it.
Definition CSOList.h:183
CSO * addPolygon(const std::vector< Vector3 > &points, double pointDistanceInMM=1., const std::string &subtype="polygon")
Adds a linearly interpolated closed polygon with the specified points as seed points.
void muteEvents()
Prevents the CSOList from sending any CSOEvents until unmuteEvents is called.
unsigned int getCurrentCSOId()
Returns the current last ID (incremented each call) for CSOs.
CSO * addClosedSpline(const std::vector< Vector3 > &points, bool useInterpolation=true, double pointDistanceInMM=1., const std::string &subtype="spline")
Adds a spline interpolated closed polygon with the specified points as seed points.
CSO * addCSONoEvent(bool useUndoRedo=true)
Adds a new CSO to the list and returns its pointer. (Without sending any events).
void sendPostEvent(CSOEvent::CSOEventType eventType, unsigned int csoId)
Sends a post-event with the specified type and CSO ID.
void _addGroupRelationCommand(CSO *cso, CSOGroup *group)
Helper method to be used only inside MLCSO.
bool isRepaintNotificationEnabled() const
Returns whether the repaint notification is enabled.
Definition CSOList.h:656
void setUndoRedoManager(CSOUndoRedoManager *undoRedoManager)
Sets the internal undo/redo manager.
Definition CSOList.h:158
void addNotificationObserver(csoNotificationCB *callback, void *userData)
Adds a notification observer to this CSOList.
void closeUndoRedoGroup()
Closes a undo/redo group. All undoable commands before this are grouped together.
void disableUndoRedoManager()
Enables the undo/redo mechanism.
bool isCSOCurrentlyUnderMouseNotificationEnabled() const
Returns whether the 'CSO currently under mouse' notification is enabled.
Definition CSOList.h:686
static EnumValues< CSOVoxelWriteModes > getVoxelWriteModes()
Vector3 getCenterOfSelectedGroups(bool &resultIsValid) const
Returns the center position of all bounding boxes of all CSOs of all selected CSOGroups.
void enableCSOCurrentlyUnderMouseObserver()
Enables the 'CSO currently under mouse' observer mechanism.
Definition CSOList.h:631
void clearSelectedGroups()
Clears all selected CSOGroups.
Vector3 getCenterOfSelectedCSOs() const
/deprecated Returns the center position of all bounding boxes of all selected CSOs.
Definition CSOList.h:287
void unmuteEvents()
Revokes a mute request.
void sendPreEvent(CSOEvent::CSOEventType eventType, unsigned int csoId, const CSOIdVector &groupIds)
Sends a post-event with the specified type, CSO ID, and CSOGroup IDs.
bool isSelected(const CSO *cso) const
Returns whether the specified CSO is currently selected.
void disableCSOCurrentlyUnderMouseObserver()
Disables the 'CSO currently under mouse' observer mechanism.
Definition CSOList.h:636
void disableRepaintObserver()
Disables the repaint observer mechanism.
Definition CSOList.h:570
bool setSelected(CSOGroup *group)
Set the specified CSOGroup as being selected and deselects all other CSOGroups.
bool loadFrom(std::string &filename, std::string &message, ModuleBackgroundTask *task=nullptr)
Reads out the internal structure for this list (CSOs and CSOGroups) from the specified file.
void disableStartNewCSOObserver()
Disables the 'start new CSO' observer mechanism.
Definition CSOList.h:614
static void removeNotificationObserverFromAllCSOLists(csoNotificationCB *callback, void *userData)
Removes a certain notification observer from all CSOLists.
void removeFromSelection(CSOGroup *group)
Removes the specified CSOGroup from the list of selected CSOGroups.
CSOGroup * getSelectedGroupAt(unsigned int index) const
Returns a pointer to the selected CSOGroup at the specified index; no checking!
Definition CSOList.h:253
void enableRepaintObserver()
Enables the repaint observer mechanism.
Definition CSOList.h:565
bool removeGroup(unsigned int id, bool useUndoRedo=true)
Removes a CSOGroup by its ID and removes it from all CSOs.
void setCSOCurrentlyUnderMouse(CSO *csoUnderMouse)
Sets the pointer to the CSO currently under the mouse cursor.
void updateDisplays()
Updates all connected information/managing modules (not the renderers!).
void openUndoRedoGroup(const std::string &description="Contour Operation")
Opens a undo/redo group. All undoable commands after this are grouped together.
void geometryChanged()
Called whenever the geometry of a CSO has changed.
CSOManager * getManager()
Returns a pointer to the manager of this CSOList.
Definition CSOList.h:152
void readStateFromTree(TreeNode *) override
Reads the object state from the children of the specified parent node.
CSO * addRectangle(const Vector3 &midPoint, const Vector3 &uVector, const Vector3 &vVector, double angleInRadian=.0, double pointDistanceInMM=1., const std::string &subtype="rectangle")
Adds a rectangle with a specified midPoint, uVector, and vVector.
CSOIdVector getSelectedGroupIds()
Returns a vector with IDs of the selected CSOGroups.
void disableInteractionObserver()
Disables the interaction observer mechanism.
Definition CSOList.h:592
Vector3 getCenterOfSelectedGroups() const
/deprecated Returns the center position of all bounding boxes of all CSOs of all selected CSOGroups.
Definition CSOList.h:295
unsigned int getGroupIndex(CSOGroup *group) const
Returns the index of the specified CSOGroup in its list.
static EnumValues< CSOSeedPointStyle > getSeedPointStyles()
bool loadFrom(std::istream &inStream, bool binary, std::string &message, ModuleBackgroundTask *task=nullptr)
Reads out the internal structure for this list (CSOs and CSOGroups) from the specified stream.
bool hasGroup(CSOGroup *group) const
Returns whether there is the specified CSOGroup in the list.
static void alignSeedPathLinks(CSO *cso)
Aligns seed point positions with path point lists of a specified CSO by a squared distance-sum criter...
CSO * addOpenSpline(const std::vector< Vector3 > &points, bool useInterpolation=true, double pointDistanceInMM=1., const std::string &subtype="spline")
Adds a spline interpolated open polygon with the specified points as seed points.
void redo()
Performs a redo of the last undo modification.
void enableCSOMovedObserver()
Enables the 'CSO moved' observer mechanism.
Definition CSOList.h:620
bool combineCSOandGroup(CSO *cso, CSOGroup *group, bool useUndoRedo=true)
Combines the specified CSO with the specified CSOGroup.
std::string getUniqueGroupLabel(std::string label, std::string format, bool addIdAlways)
Returns a unique CSOGroup label that includes the specified label and combines it with a unique ID us...
void sendPreEvent(CSOEvent::CSOEventType eventType)
Sends a pre-event with the specified event type.
bool removeAllGroups(bool useUndoRedo)
Removes all CSOGroups and all CSOGroups from all CSOs.
void breakCSOandGroup(CSO *cso, CSOGroup *group, bool useUndoRedo=true)
Breaks the combination of the specified CSO and the specified CSOGroup.
CSO * getCSOAt(unsigned int index) const
Returns a pointer to the CSO at the specified position in the internal list.
void sendPostEvent(CSOEvent::CSOEventType eventType)
Sends a post-event with the specified event type.
void clearSelectedSeedPoints()
Clears all selected seed points in all CSOs.
unsigned int numGroups() const
Returns the number of CSOGroups.
CSOListRules & getRules()
Returns the rules for this CSOList.
Definition CSOList.h:730
The CSOManager allows for storing and iterating CSOs, and implements an undo/redo mechanism.
Definition CSOManager.h:33
Manager class for maintaining the undo and the redo stacks.
The CSO represents a contour segmentation object.
Definition CSO.h:44
Helper class that stores a list of typed enum values and their string names.
Definition mlFields.h:318
ModuleBackgroundTask extends the ImagingBackgroundTask with several useful methods that allow asynchr...
RefCountedBase class adds intrusive reference counting support to the Base class.
The class TreeNode is the abstract base class for the import/export of ML objects.
Definition mlTreeNode.h:160
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
#define ML_REFCOUNTED_PTR(CLASSNAME)
Macro that defines convenience Ptr/ConstPtr typedefs to be used instead of intrusive_ptr templates.
#define ML_CLASS_HEADER(className)
Same like ML_CLASS_HEADER_EXPORTED with a non-existing export symbol.
UINT64 MLuint64
Introduce platform-independent 64-bit unsigned integer type.
Definition mlTypeDefs.h:424
void csoNotificationCB(void *data, int notificationFlag)
Defines the function signature for the callback methods that is to be touched by a CSOList notificati...
Definition CSOList.h:32
This struct combines a function pointer, a user data pointer, and a flag for the notification observe...
Definition CSOList.h:86
int notificationFlag
The notification flag encodes which notifications are sent.
Definition CSOList.h:95
csoNotificationCB * notificationCB
The callback function that is triggered by the notification.
Definition CSOList.h:93
void * notificationCBData
The callback data that is a pointer to the observer object.
Definition CSOList.h:94