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 
21 ML_START_NAMESPACE
22 
23 class CSO;
24 class CSOGroup;
25 
27 
30 {
36 };
37 
40 {
44  NUM_REMOVE_MODES = 3
45 };
46 
48 enum MLCSO_EXPORT CSOGroupMergeHandling
49 {
52  MERGE_MODE_BY_LABEL = 2
53 };
55 
58 {
59 
60 public:
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; }
87  bool mayAddCSO(CSOGroup& csoGroup) const;
88 
90  void applyTo(CSOGroup& csoGroup);
92  CSO* addNewCSO(CSOGroup& csoGroup, bool useUndoRedo=true);
95  bool addCSO(CSO& cso, CSOGroup& csoGroup, bool useUndoRedo=true);
97  void removeCSO(CSO& cso, CSOGroup& csoGroup, bool useUndoRedo=true);
99  void applyDeletionRule(CSOGroup& csoGroup);
101  void applyRemoveFromGroupRule(CSO& cso, bool useUndoRedo);
102 
104  static unsigned int getDefaultNumMaximumCSOs() { return 0; }
111 
112 protected:
113 
115  void _removeAllCSO(CSOGroup& csoGroup, bool useUndoRedo=true);
116 
118  void _combineCSOAndGroup(CSO& cso, CSOGroup& csoGroup);
120  void _breakCSOandGroup(CSO& cso, CSOGroup& csoGroup);
121 private:
122 
123 
126  unsigned int _numMaxCSOs;
127 
129  CSOGroupOverflowHandling _overflowHandling;
130 
132  CSORemoveHandling _removeFromGroupHandling;
133 
135  CSORemoveHandling _deleteGroupCSOHandling;
136 
137 };
138 
140 
141 ML_END_NAMESPACE
MERGE_MODE_NONE
Definition: CSOGroupRules.h:50
MERGE_MODE_BY_ID
Definition: CSOGroupRules.h:51
#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.
Definition: CSOGroupRules.h:58
static CSOGroupOverflowHandling getDefaultOverflowHandling()
Returns the default overflow handling for a group.
CSO * addNewCSO(CSOGroup &csoGroup, bool useUndoRedo=true)
Adds a new CSO to the csoGroup according to the rules.
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.
Definition: CSOGroupRules.h:85
void applyDeletionRule(CSOGroup &csoGroup)
Applies the delete group rules to the csoGroup.
unsigned int getNumMaximumCSOs() const
Returns the maximum number of CSOs.
Definition: CSOGroupRules.h:73
void applyTo(CSOGroup &csoGroup)
Applies the rules to the csoGroup.
CSORemoveHandling getRemoveFromGroupHandling() const
Returns the _removeFromGroupHandling mode.
Definition: CSOGroupRules.h:81
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.
Definition: CSOGroupRules.h:71
void setDeleteGroupCSOHandling(CSORemoveHandling handling)
Sets the handling mode for CSOs when this group is deleted, i.e. should they also be removed from the...
Definition: CSOGroupRules.h:83
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.
Definition: CSOGroupRules.h:77
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...
Definition: CSOGroupRules.h:75
void setRemoveFromGroupHandling(CSORemoveHandling handling)
Sets the handling mode for CSOs that are removed from the group, i.e. should they also be removed fro...
Definition: CSOGroupRules.h:79
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
CSORemoveHandling
Enumeration for the removal handling of CSOs from group and if group is deleted.
Definition: CSOGroupRules.h:40
@ REMOVE_NEVER
If a CSO is removed from a group, it is not deleted from the list.
Definition: CSOGroupRules.h:42
@ REMOVE_ALWAYS
If a CSO is removed from a group, it is also deleted from the list.
Definition: CSOGroupRules.h:41
@ 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.
Definition: CSOGroupRules.h:43
@ NUM_REMOVE_MODES
Number of modes.
Definition: CSOGroupRules.h:44
CSOGroupOverflowHandling
Enumeration for the group overflow handling modes.
Definition: CSOGroupRules.h:30
@ OVERFLOW_DELETE_LAST
If a CSOGroup is full, the last CSO in the group is replaced by the newly generated CSO.
Definition: CSOGroupRules.h:32
@ OVERFLOW_DELETE_ALL
If a CSOGroup is full, all CSOs in the group are deleted.
Definition: CSOGroupRules.h:33
@ NUM_OVERFLOW_MODES
Number of modes.
Definition: CSOGroupRules.h:35
@ OVERFLOW_IGNORE_NEW
If a CSOGroup is full, one can not generate a new one.
Definition: CSOGroupRules.h:34
@ OVERFLOW_DELETE_FIRST
If a CSOGroup is full, the first CSO in the group is replaced by the newly generated CSO.
Definition: CSOGroupRules.h:31