MeVisLab Toolbox Reference
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
27ML_START_NAMESPACE
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:
64
67 CSOList(bool shouldRegisterCSOList);
69 CSOList(const CSOList& csoList);
70
71protected:
77 ~CSOList() override;
78
80
81public:
82
83 /* DATA STRUCTURES */
84
99
100 /* METHODS */
101
103
105 void clone(const CSOList& csoList, bool useUndoRedo=false);
107 void merge(const CSOList& csoList, bool mergeGroupWithSameLabel, CSOIdToCSOIdMap& origToThisGroupIdMap, CSOIdToCSOIdMap& origToThisCSOIdMap, bool useUndoRedo=false);
109 void merge(const CSOList& csoList, const CSOGroupMergeHandling mergeMode, CSOIdToCSOIdMap& origToThisGroupIdMap, CSOIdToCSOIdMap& origToThisCSOIdMap, 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
147 inline CSOUndoRedoManager* getUndoRedoManager() { return _csoUndoRedoManager; }
149 inline CSOManager* getManager() { return _csoManager; }
150
152 inline void setUndoRedoManager(CSOUndoRedoManager* undoRedoManager) { _csoUndoRedoManager = undoRedoManager; }
154 void setManager(CSOManager* manager);
155
157
160 unsigned int getCurrentCSOId();
161
163 void updateCurrentCSOId(unsigned int newId);
164
167 unsigned int getCurrentGroupId();
169 inline void setCurrentCSOId(unsigned int id) { _currentLastCSOId = id; }
171 inline void setCurrentGroupId(unsigned int id) { _currentLastGroupId = id; }
172
174 void updateCurrentGroupId(const unsigned int newId);
175
177
180 bool isSelected(const CSO* cso) const;
182 bool isSelected(const CSOGroup* group) const;
183
185 void addSelected(CSO* cso);
187 void addSelected(CSOGroup* group);
188
193 bool setSelected(CSO* cso);
198 bool setSelected(CSOGroup* group);
199
206
210 void removeFromSelection(const std::vector<CSO*> &csos);
214 void removeFromSelection(const std::vector<CSOGroup*> &groups);
215
217 inline unsigned int numSelectedCSOs() const { return static_cast<unsigned int>(_selectedCSOs.size()); }
219 inline unsigned int numSelectedGroups() const { return static_cast<unsigned int>(_selectedGroups.size()); }
220
222 inline CSO* getSelectedCSOAt(unsigned int index) const
223 {
224 if (_selectedCSOs.size() > 0) {
225 return _selectedCSOs[index];
226 } else {
227 return nullptr;
228 }
229 }
230
231 inline CSOGroup* getSelectedGroupAt(unsigned int index) const
232 {
233 if (_selectedGroups.size() > 0) {
234 return _selectedGroups[index];
235 } else {
236 return nullptr;
237 }
238 }
239
241
244
247 Vector3 getCenterOfSelectedCSOs(bool& resultIsValid) const;
250 Vector3 getCenterOfSelectedGroups(bool& resultIsValid) const;
251
253 inline CSO* getCSOCurrentlyUnderMouse() const { return _currentlyUnderMouseCSO; }
256 void setCSOCurrentlyUnderMouse(CSO* csoUnderMouse);
257
261 {
262 CSO_DEBUG("Using the deprecated method 'CSOList::getCenterOfSelectedCSOs()'; use 'CSOList::getCenterOfSelectedCSOs(bool& resultIsValid)' instead!");
263 bool dummy;
264 return getCenterOfSelectedCSOs(dummy);
265 }
266
269 {
270 CSO_DEBUG("Using the deprecated method 'CSOList::getCenterOfSelectedGroups()'; use 'CSOList::getCenterOfSelectedGroups(bool& resultIsValid)' instead!");
271 bool dummy;
272 return getCenterOfSelectedGroups(dummy);
273 }
274
276
278 CSO* addCSO(bool useUndoRedo=true);
280 CSO* addCSONoEvent(bool useUndoRedo = true);
283 CSO* addCSO(const std::vector<Vector3>& seedPositions, bool closed, bool useUndoRedo);
286 CSO* addCSO(unsigned int numSeedPoints, bool closed, bool useUndoRedo);
288 CSO* addCSOCopy(CSO* cso, bool useUndoRedo=true, unsigned int csoId = INVALID_CSO_ID);
290 CSOGroup* addGroup(bool useUndoRedo=true);
292 CSOGroup* addGroup(const std::string& label, bool useUndoRedo=true);
295 CSOGroup* addGroupCopy(CSOGroup* group, bool useUndoRedo=true, unsigned int groupId=INVALID_CSO_ID);
296
298 CSO* addPoint(const Vector3& position, const std::string& subtype="point");
301 CSO* addCircle(const Vector3& midPoint, const Vector3& normal, double radius, double pointDistanceInMM = 1., const std::string& subtype="circle");
303 CSO* addArrow(const Vector3& pointAt, const Vector3& direction, double length, double pointDistanceInMM = 1., const std::string& subtype="arrow");
305 CSO* addPolygon(const std::vector<Vector3>& points, double pointDistanceInMM = 1., const std::string& subtype="polygon");
307 CSO* addPolyline(const std::vector<Vector3>& points, double pointDistanceInMM = 1., const std::string& subtype="polyline");
310 CSO* addClosedSpline(const std::vector<Vector3>& points, bool useInterpolation=true, double pointDistanceInMM = 1., const std::string& subtype="spline");
313 CSO* addOpenSpline(const std::vector<Vector3>& points, bool useInterpolation=true, double pointDistanceInMM = 1., const std::string& subtype="spline");
319 CSO* addRectangle(const Vector3& midPoint, const Vector3& uVector, const Vector3& vVector,
320 double angleInRadian = .0, double pointDistanceInMM = 1., const std::string& subtype = "rectangle");
327 CSO* addEllipse(const Vector3& midPoint, const Vector3& uVector, const Vector3& vVector,
328 double angleInRadian = .0, double pointDistanceInMM = 1., const std::string& subtype = "ellipse");
331 bool removeCSO(CSO* cso, bool useUndoRedo=true);
334 bool removeCSO(unsigned int id, bool useUndoRedo=true);
337 bool removeAllCSO(bool useUndoRedo=true);
340 bool removeGroup(CSOGroup* group, bool useUndoRedo=true);
343 bool removeGroup(unsigned int id, bool useUndoRedo=true);
346 bool removeAllGroups(bool useUndoRedo);
349 bool removeGroups(const std::vector<CSOGroup *> &groupsToRemove, bool useUndoRedo=true);
350
353 bool removeAll(bool useUndoRedo=true);
354
356
358 CSO* getCSOAt(unsigned int index) const;
361 CSO* getCSOById(unsigned int id) const;
364 CSO* getCSOByLabel(const std::string& label) const;
366 unsigned int getCSOIndex(CSO* cso) const;
368 unsigned int getCSOIndex(unsigned int id) const;
370 bool hasCSO(CSO* cso) const;
371
373
375 CSOGroup* getGroupById(unsigned int id) const;
377 CSOGroup* getGroupByLabel(const std::string& label) const;
379 CSOGroup* getGroupAt(unsigned int index) const;
381 unsigned int getGroupIndex(CSOGroup* group) const;
383 unsigned int getGroupIndex(unsigned int id) const;
385 bool hasGroup(CSOGroup* group) const;
386
388
392 std::string getUniqueCSOLabel(std::string label, std::string format, bool addIdAlways);
393
397 std::string getUniqueGroupLabel(std::string label, std::string format, bool addIdAlways);
398
403 inline void resetUniqueCSOLabelIdMap() { _csoLabelUniqueIdMap.clear(); }
404
409 inline void resetUniqueGroupLabelIdMap() { _groupLabelUniqueIdMap.clear(); }
410
412
414 bool combineCSOandGroup(CSO* cso, CSOGroup* group, bool useUndoRedo=true);
416 void breakCSOandGroup(CSO* cso, CSOGroup* group, bool useUndoRedo=true);
418 void breakCSOfromAllGroups(CSO* cso, bool useUndoRedo=true);
420 void breakAllCSOsFromGroup(CSOGroup* group, bool useUndoRedo=true);
423
425
427 unsigned int numCSOs() const;
429 unsigned int numGroups() const;
430
432
437
439
441 void undo();
443 void redo();
444
446
448 inline void enableUndoRedoManager() { _csoUndoRedoManagerEnabled = true; }
451
453
458
461
465 void sendPreEvent(CSOEvent::CSOEventType eventType, unsigned int csoId);
468 void sendPreEvent(CSOEvent::CSOEventType eventType, unsigned int csoId, const CSOIdVector& groupIds);
471 void sendPreEvent(CSOEvent::CSOEventType eventType, unsigned int csoId, unsigned int groupId);
473 void sendPreEvent(CSOEvent::CSOEventType eventType, const CSOIdVector& csoIds);
475 void sendPreEvent(CSOEvent::CSOEventType eventType, const CSOIdVector& csoIds, const CSOIdVector& groupIds);
476
477
481 void sendPostEvent(CSOEvent::CSOEventType eventType, unsigned int csoId);
484 void sendPostEvent(CSOEvent::CSOEventType eventType, unsigned int csoId, unsigned int groupId);
486 void sendPostEvent(CSOEvent::CSOEventType eventType, const CSOIdVector& csoIds);
489 void sendPostEvent(CSOEvent::CSOEventType eventType, unsigned int csoId, const CSOIdVector& groupIds);
491 void sendPostEvent(CSOEvent::CSOEventType eventType, const CSOIdVector& csoIds, const CSOIdVector& groupIds);
492
500
502
504 MLuint64 getListChangeId() const { return _listChangeId; }
506 MLuint64 getGeometryChangeId() const { return _geometryChangeId; }
511
513
515 inline void enableRepaintObserver() { _enableRepaintObserver = true; }
517 inline void disableRepaintObserver() { _enableRepaintObserver = false; }
518
520 inline void enableFinishedObserver() { _enableFinishedObserver = true; }
522 inline void disableFinishedObserver() { _enableFinishedObserver = false; }
523
525 inline void enableInteractionObserver() { _enableInteractionObserver = true; }
527 inline void disableInteractionObserver() { _enableInteractionObserver = false; }
528
530 inline void enableSelectionObserver() { _enableSelectionObserver = true; }
532 inline void disableSelectionObserver() { _enableSelectionObserver = false; }
533
535 inline void enableStartNewCSOObserver() { _enableStartNewCSOObserver = true; }
537 inline void disableStartNewCSOObserver() { _enableStartNewCSOObserver = false; }
538
540 inline void enableCSOMovedObserver() { _enableCSOMovedObserver = true; }
542 inline void disableCSOMovedObserver() { _enableCSOMovedObserver = false; }
543
545 inline void enableCSOCurrentlyUnderMouseObserver() { _enableCSOCurrentlyUnderMouseObserver = true; }
547 inline void disableCSOCurrentlyUnderMouseObserver() { _enableCSOCurrentlyUnderMouseObserver = false; }
548
550
552 inline bool isUndoRedoManagerEnabled() const { return _csoUndoRedoManagerEnabled; }
554 void openUndoRedoGroup(const std::string& description = "Contour Operation");
557
559
561 inline bool isRepaintNotificationEnabled() const { return _enableRepaintObserver; }
563 inline bool isFinishedNotificationEnabled() const { return _enableFinishedObserver; }
565 inline bool isInteractionInitNotificationEnabled() const { return _enableInteractionObserver; }
567 inline bool isSelectionNotificationEnabled() const { return _enableSelectionObserver; }
569 inline bool isStartNewCSONotificationEnabled() const { return _enableStartNewCSOObserver; }
571 inline bool isCSOMovedNotificationEnabled() const { return _enableCSOMovedObserver; }
573 inline bool isCSOCurrentlyUnderMouseNotificationEnabled() const { return _enableCSOCurrentlyUnderMouseObserver; }
574
576
578 static void alignSeedPathLinks(CSO* cso);
579
581
585
611
613
615 inline CSOListRules& getRules() { return _rules; }
616
618 void addStateToTree(TreeNode* /*parent*/) const override;
619
621 void readStateFromTree(TreeNode* /*parent*/) override;
622
623 // Sets current version number.
625
627 CSOList* deepCopy() const override { return new CSOList(*this); };
628
629 protected:
630
631 // nothing so far
632
633private:
634
635 /* DATA STRUCTURES */
636
638 struct IndexPair {
639 IndexPair() {
640 index0 = index1 = -1;
641 }
642 int index0, index1;
643 };
644
645
646 /* MEMBER VARIABLES */
647
649 CSOListRules _rules;
650
652 std::vector<CSO*>_csoList;
654 std::vector<CSOGroup*>_groupList;
655
657 std::vector<CSO*>_selectedCSOs;
659 std::vector<CSOGroup*>_selectedGroups;
660
662 CSO* _currentlyUnderMouseCSO;
663
665 bool _csoUndoRedoManagerEnabled;
667 CSOUndoRedoManager* _csoUndoRedoManager;
669 CSOManager* _csoManager;
670
671
674 unsigned int _currentLastCSOId;
677 unsigned int _currentLastGroupId;
678
679
681 static std::vector<CSOList*> _registeredCSOLists;
682
684 std::vector<CSONotificationCBData>_notificationObservers;
685
687 std::map<std::string, int>_csoLabelUniqueIdMap;
688
690 std::map<std::string, int>_groupLabelUniqueIdMap;
691
692 MLuint64 _listChangeId;
693 MLuint64 _geometryChangeId;
694 static MLuint64 _uniqueListChangeId;
695
697 bool _enableRepaintObserver;
699 bool _enableFinishedObserver;
701 bool _enableInteractionObserver;
703 bool _enableSelectionObserver;
705 bool _enableStartNewCSOObserver;
707 bool _enableCSOMovedObserver;
709 bool _enableCSOCurrentlyUnderMouseObserver;
710
712 int _numberOfEventMuteRequests;
713
714
715 /* METHODS */
716
718 inline bool _canUseUndoRedo(bool shouldUseUndoRedo) const { return shouldUseUndoRedo && _csoUndoRedoManagerEnabled && _csoUndoRedoManager; }
720 void _setDefaultValues(CSO* cso);
722 void _setDefaultValues(CSOGroup* group);
724 void _setDefaultRules(CSOGroup* group);
725
727 void _emptyInternalListOfCSOs();
729 void _emptyInternalListOfGroups();
730
732 CSOIdVector _filterContainedGroups(const std::vector<CSOGroup*> &groups, const std::vector<CSOGroup*>& container);
733 CSOIdVector _filterContainedCSOs(const std::vector<CSO*> &csos, const std::vector<CSO*>& container);
734
736 bool pathPointListIndexIsInRange(CSO* cso, int index) const;
738 bool seedPointIndexIsRange(CSO* cso, int index) const;
739
741 void killAll();
742
745 bool _fromStreamV1(std::istream& inStream, std::string& message);
748 bool _fromStreamV3(std::istream& inStream, std::string& message);
751 bool _fromStreamV4(std::istream& inStream, std::string& message);
754 bool _fromStreamV5(std::istream& inStream, bool asBinary, std::string& message);
756 bool loadFromVersionBefore5(std::istream& inStream, bool binary, short version, bool swapBytes, std::string& message);
759 bool _fromStreamV6(std::istream& inStream, bool asBinary, std::string& message, ModuleBackgroundTask* task=nullptr);
760
762 void reconstructPathPointListToSeedPointLinks( CSO* cso, std::vector<IndexPair>& pathIndexPairs, std::vector<IndexPair>& seedIndexPairs, const std::string& version, std::string& message);
763
766 bool _checkLine(const std::string& line, const std::string& name, std::string& errorMessage);
767
769 inline std::string spaces(unsigned int numSpaces) const
770 {
771 std::stringstream result;
772 for (unsigned int i = 0; i < numSpaces; ++i)
773 {
774 result << " ";
775 }
776 return result.str();
777 }
778
780 std::string buildLabel(std::string label, std::string format, int id)
781 {
782 //Example: buildLabel("cso", " (%i)", 9) returns "cso (0)"
783 size_t p = format.find("%i");
784 if (p == std::string::npos)
785 {
786 format.append("%i");
787 p = format.find("%i");
788 }
789 std::stringstream ss;
790 ss << id;
791 std::string tmp = format.replace(p, 2, ss.str());
792 return label.append(tmp);
793 }
794
796 static void registerCSOList(CSOList* csoList);
798 static void deregisterCSOList(CSOList* csoList);
799
800 friend class CSOLoad;
801
803};
804
806
807ML_END_NAMESPACE
#define CSO_DEBUG(msg)
Output macro for debug output.
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
CSOEventType
Enumeration for specifying the exact type of event.
Definition CSOEvent.h:49
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
CSO * addCSO(const std::vector< Vector3 > &seedPositions, bool closed, bool useUndoRedo)
void sendModuleEventGroup(CSOEvent *event)
Sends a module CSOGroup event.
void enableFinishedObserver()
Enables the finished observer mechanism.
Definition CSOList.h:520
Vector3 getCenterOfSelectedCSOs(bool &resultIsValid) const
MLuint64 getListChangeId() const
Returns the list change ID that changes whenever a CSO is added or removed (unique accross all CSOLis...
Definition CSOList.h:504
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)
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:569
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:542
bool saveTo(std::string &filename, bool binary, std::string &message, ModuleBackgroundTask *task=nullptr) const
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)
CSOList(const CSOList &csoList)
Copy constructor.
CSOList * deepCopy() const override
Creates a deep copy of the CSOList.
Definition CSOList.h:627
void sendPreEvent(CSOEvent::CSOEventType eventType, unsigned int csoId, unsigned int groupId)
void enableInteractionObserver()
Enables the interaction observer mechanism.
Definition CSOList.h:525
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()
Definition CSOList.h:409
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)
bool removeCSO(unsigned int id, bool useUndoRedo=true)
std::string getUniqueCSOLabel(std::string label, std::string format, bool addIdAlways)
unsigned int getCurrentGroupId()
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:522
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)
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:169
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
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:530
CSOList()
Standard constructor.
bool removeGroup(CSOGroup *group, bool useUndoRedo=true)
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:535
void enableUndoRedoManager()
Enables the undo/redo mechanism.
Definition CSOList.h:448
bool removeAll(bool useUndoRedo=true)
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:565
unsigned int numSelectedCSOs() const
Returns the number of selected CSOs.
Definition CSOList.h:217
CSO * addCircle(const Vector3 &midPoint, const Vector3 &normal, double radius, double pointDistanceInMM=1., const std::string &subtype="circle")
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:563
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)
bool isSelectionNotificationEnabled() const
Returns whether the selection notification is enabled.
Definition CSOList.h:567
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:506
CSOGroup * addGroupCopy(CSOGroup *group, bool useUndoRedo=true, unsigned int groupId=INVALID_CSO_ID)
friend class CSOLoad
Definition CSOList.h:800
bool saveTo(std::ostream &outStream, bool binary, ModuleBackgroundTask *task=nullptr) const
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:219
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:222
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:552
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")
CSO * getCSOByLabel(const std::string &label) const
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:571
bool removeAllCSO(bool useUndoRedo=true)
void resetUniqueCSOLabelIdMap()
Definition CSOList.h:403
CSO * getCSOCurrentlyUnderMouse() const
Returns the pointer to the CSO currently under the mouse cursor.
Definition CSOList.h:253
void disableSelectionObserver()
Disables the selection observer mechanism.
Definition CSOList.h:532
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)
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:171
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()
CSO * addClosedSpline(const std::vector< Vector3 > &points, bool useInterpolation=true, double pointDistanceInMM=1., const std::string &subtype="spline")
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:561
void setUndoRedoManager(CSOUndoRedoManager *undoRedoManager)
Sets the internal undo/redo manager.
Definition CSOList.h:152
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:573
static EnumValues< CSOVoxelWriteModes > getVoxelWriteModes()
Vector3 getCenterOfSelectedGroups(bool &resultIsValid) const
void enableCSOCurrentlyUnderMouseObserver()
Enables the 'CSO currently under mouse' observer mechanism.
Definition CSOList.h:545
void clearSelectedGroups()
Clears all selected CSOGroups.
Vector3 getCenterOfSelectedCSOs() const
Definition CSOList.h:260
void unmuteEvents()
void sendPreEvent(CSOEvent::CSOEventType eventType, unsigned int csoId, const CSOIdVector &groupIds)
bool isSelected(const CSO *cso) const
void disableCSOCurrentlyUnderMouseObserver()
Disables the 'CSO currently under mouse' observer mechanism.
Definition CSOList.h:547
void disableRepaintObserver()
Disables the repaint observer mechanism.
Definition CSOList.h:517
bool setSelected(CSOGroup *group)
bool loadFrom(std::string &filename, std::string &message, ModuleBackgroundTask *task=nullptr)
void disableStartNewCSOObserver()
Disables the 'start new CSO' observer mechanism.
Definition CSOList.h:537
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:231
void enableRepaintObserver()
Enables the repaint observer mechanism.
Definition CSOList.h:515
bool removeGroup(unsigned int id, bool useUndoRedo=true)
void setCSOCurrentlyUnderMouse(CSO *csoUnderMouse)
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:149
void readStateFromTree(TreeNode *) override
Reads the object state from the children of the specified parent node.
@ NOTIFICATION_INTERACTION_INIT
Flag for the observer mechanism, should be set if the interaction must be initialized.
Definition CSOList.h:601
@ NOTIFICATION_CSO_MOVED
Flag for the observer mechanism, should be set if a CSO was moved.
Definition CSOList.h:605
@ NOTIFICATION_NONE
Flag for the observer mechanism, signalizing no notification at all.
Definition CSOList.h:589
@ NOTIFICATION_GROUP_FINISHED
Flag for the observer mechanism, should be set if a CSOGroup action is finished.
Definition CSOList.h:597
@ NOTIFICATION_UNDO_REDO_STATE_CHANGED
Flag for the observer mechanism, should be set if the availability of undo/redo steps changes.
Definition CSOList.h:609
@ NOTIFICATION_REPAINT
Flag for the observer mechanism, should be set if a repaint should occur.
Definition CSOList.h:599
@ NOTIFICATION_START_NEW_CSO
Flag for the observer mechanism, signalizing that the generation of a new CSO has been started.
Definition CSOList.h:603
@ NOTIFICATION_GROUP_SELECTION
Flag for the observer mechanism, should be set if a CSOGroup selection changes.
Definition CSOList.h:593
@ NOTIFICATION_CSO_UNDER_MOUSE_CHANGED
Flag for the observer mechanism, should be set if the CSO under the mouse cursor changes.
Definition CSOList.h:607
@ NOTIFICATION_CSO_FINISHED
Flag for the observer mechanism, should be set if a CSO action is finished.
Definition CSOList.h:595
@ NOTIFICATION_CSO_SELECTION
Flag for the observer mechanism, should be set if a CSO selection changes.
Definition CSOList.h:591
CSO * addRectangle(const Vector3 &midPoint, const Vector3 &uVector, const Vector3 &vVector, double angleInRadian=.0, double pointDistanceInMM=1., const std::string &subtype="rectangle")
CSOIdVector getSelectedGroupIds()
Returns a vector with IDs of the selected CSOGroups.
void disableInteractionObserver()
Disables the interaction observer mechanism.
Definition CSOList.h:527
Vector3 getCenterOfSelectedGroups() const
Definition CSOList.h:268
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)
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")
void redo()
Performs a redo of the last undo modification.
void enableCSOMovedObserver()
Enables the 'CSO moved' observer mechanism.
Definition CSOList.h:540
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)
void sendPreEvent(CSOEvent::CSOEventType eventType)
Sends a pre-event with the specified event type.
bool removeAllGroups(bool useUndoRedo)
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:615
Definition CSO.h:44
RefCountedBase()
Constructor.
#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)
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
Tvec3< MLdouble > Vector3
A vector with three components of type double.
Definition mlVector3.h:286
int notificationFlag
The notification flag encodes which notifications are sent.
Definition CSOList.h:97
csoNotificationCB * notificationCB
The callback function that is triggered by the notification.
Definition CSOList.h:95
void * notificationCBData
The callback data that is a pointer to the observer object.
Definition CSOList.h:96