MeVisLab Toolbox Reference
CSOGroupRules.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#include "MLCSOIncludes.h"
19
20
22
23class CSO;
24class CSOGroup;
25
27
37
46
49{
53};
55
58{
59
60public:
61
63 CSOGroupRules(unsigned int numMaxCSOs = 0);
66
68 void reset();
69
71 void setNumMaximumCSOs(unsigned int numMaxCSOs) { _numMaxCSOs = numMaxCSOs; }
73 unsigned int getNumMaximumCSOs() const { return _numMaxCSOs; }
75 void setOverflowHandling(CSOGroupOverflowHandling handling) { _overflowHandling = handling; }
77 CSOGroupOverflowHandling getOverflowHandling() const { return _overflowHandling; }
79 void setRemoveFromGroupHandling(CSORemoveHandling handling) { _removeFromGroupHandling = handling; }
81 CSORemoveHandling getRemoveFromGroupHandling() const { return _removeFromGroupHandling; }
83 void setDeleteGroupCSOHandling(CSORemoveHandling handling) { _deleteGroupCSOHandling = handling; }
85 CSORemoveHandling getDeleteGroupCSOHandling() const { return _deleteGroupCSOHandling; }
88
95 bool addCSO(CSO& cso, CSOGroup& csoGroup, bool useUndoRedo=true);
97 void removeCSO(CSO& cso, CSOGroup& csoGroup, bool useUndoRedo=true);
102
104 static unsigned int getDefaultNumMaximumCSOs() { return 0; }
111
112protected:
113
116
121private:
122
123
126 unsigned int _numMaxCSOs;
127
129 CSOGroupOverflowHandling _overflowHandling;
130
132 CSORemoveHandling _removeFromGroupHandling;
133
135 CSORemoveHandling _deleteGroupCSOHandling;
136
137};
138
140
MERGE_MODE_NONE
MERGE_MODE_BY_ID
#define MLCSO_EXPORT
Defines export symbols for classes, so they can be used in other DLLs.
Definition MLCSOSystem.h:23
This handles rules like the maximum number of CSOs in a group and applies them.
static CSOGroupOverflowHandling getDefaultOverflowHandling()
Returns the default overflow handling for a group.
CSOGroupRules(unsigned int numMaxCSOs=0)
Constructor.
void applyRemoveFromGroupRule(CSO &cso, bool useUndoRedo)
Applies the remove from group rule to the cso (Is is executed anytime a cso is removed from the group...
static CSORemoveHandling getDefaultDeleteGroupCSOHandling()
Returns the default handling for removal from groups.
CSORemoveHandling getDeleteGroupCSOHandling() const
Returns the _deleteGroupCSOHandling mode.
void applyDeletionRule(CSOGroup &csoGroup)
Applies the delete group rules to the csoGroup.
unsigned int getNumMaximumCSOs() const
Returns the maximum number of CSOs.
void applyTo(CSOGroup &csoGroup)
Applies the rules to the csoGroup.
CSO * addNewCSO(CSOGroup &csoGroup, bool useUndoRedo=true)
Adds a new CSO to the csoGroup according to the rules.
CSORemoveHandling getRemoveFromGroupHandling() const
Returns the _removeFromGroupHandling mode.
static CSORemoveHandling getDefaultRemoveFromGroupHandling()
Returns the default handling for removal from groups.
void reset()
Sets default values to all members.
void setNumMaximumCSOs(unsigned int numMaxCSOs)
Sets the maximum number of CSOs allowed in the group where the rules are applied to.
void setDeleteGroupCSOHandling(CSORemoveHandling handling)
Sets the handling mode for CSOs when this group is deleted, i.e. should they also be removed from the...
void _combineCSOAndGroup(CSO &cso, CSOGroup &csoGroup)
establishes bidirectional link between given cso and group
void removeCSO(CSO &cso, CSOGroup &csoGroup, bool useUndoRedo=true)
Removes a CSO from the csoGroup according to the rules.
bool mayAddCSO(CSOGroup &csoGroup) const
Checks if one could add a CSO to the group csoGroup.
void _breakCSOandGroup(CSO &cso, CSOGroup &csoGroup)
removes bidirectional link between given cso and group
void _removeAllCSO(CSOGroup &csoGroup, bool useUndoRedo=true)
Removes all CSOs from the csoGroup according to the rules.
CSOGroupOverflowHandling getOverflowHandling() const
Returns the _overflowHandling mode.
bool addCSO(CSO &cso, CSOGroup &csoGroup, bool useUndoRedo=true)
Adds the given cso to the given csoGroup if the rules allow that.
static unsigned int getDefaultNumMaximumCSOs()
Returns the default value for the maximum amount of CSOs in a group.
~CSOGroupRules()
Destructor.
void setOverflowHandling(CSOGroupOverflowHandling handling)
Sets the overflow handling, i.e. what has to done when one wants to add CSO and _numMaxCSOs is reache...
void setRemoveFromGroupHandling(CSORemoveHandling handling)
Sets the handling mode for CSOs that are removed from the group, i.e. should they also be removed fro...
A CSOGroup comprises a number of CSOs, which themselves can be in a number of different CSOGroups.
Definition CSOGroup.h:38
The CSO represents a contour segmentation object.
Definition CSO.h:44
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
CSORemoveHandling
Enumeration for the removal handling of CSOs from group and if group is deleted.
@ REMOVE_NEVER
If a CSO is removed from a group, it is not deleted from the list.
@ REMOVE_ALWAYS
If a CSO is removed from a group, it is also deleted from the list.
@ REMOVE_IF_IN_NO_GROUP
If a CSO is removed from a group, it is only deleted from the list if it is in no group anymore.
@ NUM_REMOVE_MODES
Number of modes.
CSOGroupOverflowHandling
Enumeration for the group overflow handling modes.
@ OVERFLOW_DELETE_LAST
If a CSOGroup is full, the last CSO in the group is replaced by the newly generated CSO.
@ OVERFLOW_DELETE_ALL
If a CSOGroup is full, all CSOs in the group are deleted.
@ NUM_OVERFLOW_MODES
Number of modes.
@ OVERFLOW_IGNORE_NEW
If a CSOGroup is full, one can not generate a new one.
@ OVERFLOW_DELETE_FIRST
If a CSOGroup is full, the first CSO in the group is replaced by the newly generated CSO.