MeVisLab Toolbox Reference
CSOGroup.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 
16 
17 #pragma once
18 
19 
20 #include "MLCSOIncludes.h"
21 #include "CSOAttributes.h"
22 #include "CSOBoundingBox.h"
23 #include "CSORules/CSOGroupRules.h"
24 
25 ML_START_NAMESPACE
26 
27 // forward declarations
28 class CSO;
29 class CSOList;
30 
32 
38 {
39  // The friend is needed to let the reader and writer have access to
40  // the deprecated and private functions
41  friend class CSOList;
42 
43 public:
44 
48  CSOGroup(CSOList* csoList);
50  CSOGroup(const CSOGroup &group, int groupId=-1, CSOList* csoList=nullptr);
53 
55  inline CSOGroupRules& getRules() { return _rules; }
56 
63  bool addCSO(CSO& cso, bool useUndoRedo=true);
65  void removeCSO(CSO& cso, bool useUndoRedo=true);
67  void removeAllCSO(bool useUndoRedo=true, bool shouldApplyRemoveFromGroupRule=true);
69  bool contains(const CSO *cso) const;
71  inline unsigned int numCSOs() const { return static_cast<unsigned int>(_memberCSOIds.size()); }
73  CSO* getCSOAt(unsigned int index) const;
75  inline unsigned int getCSOIdAt(unsigned int index) const { return _memberCSOIds[index]; }
77 
83  void _addReferenceToCSO(const CSO& cso);
85  void _removeReferenceToCSO(const CSO& cso);
87 
93  inline unsigned int getId() const { return _uniqueId; }
95  inline void setId(unsigned int id) { _uniqueId = id; }
99  void setCSOList(CSOList* csoList);
101  inline CSOList* getCSOList() const { return _csoList; }
103 
106  bool isSelected() const;
107 
113  void setLabel(const std::string& label);
115  inline const std::string& getLabel() const { return _attributes.label; }
117  void setDescription(const std::string& description);
119  inline const std::string& getDescription() const { return _attributes.description; }
120 
122  inline int getTimePointIndex() const { return _attributes.timePointIndex; }
124  void setTimePointIndex(MLint timePointIndex);
126  void setShowState(bool state);
128  inline bool getShowState() const { return _attributes.showState; }
130  void setVoxelizeState(bool state);
132  inline bool getVoxelizeState() const { return _attributes.voxelizeState; }
134  void setEditableState(bool state);
136  inline bool getEditableState() const { return _attributes.editableState; }
138  inline CSOPathPointsStyle getPathPointStyle() const { return static_cast<CSOPathPointsStyle>(_attributes.pathPointStyle); }
142  inline void setPathPointStyle(int style) { setPathPointStyle(static_cast<CSOPathPointsStyle>(style)); }
144  inline float getPathPointWidth() const { return _attributes.pathPointWidth; }
146  void setPathPointWidth(float width);
148  inline const Vector3& getPathPointColor() const { return _attributes.pathPointColor; }
150  void setPathPointColor(const Vector3& color);
152  inline float getPathPointAlpha() const { return _attributes.pathPointAlpha; }
154  void setPathPointAlpha(float alpha);
156  inline int getSeedPointStyle() const { return _attributes.seedPointStyle; }
158  void setSeedPointStyle(int seedPointStyle);
160  inline float getSeedPointSize() const { return _attributes.seedPointSize; }
162  void setSeedPointSize(float size);
164  inline const Vector3& getSeedPointColor() const { return _attributes.seedPointColor; }
166  void setSeedPointColor(const Vector3& color);
168  inline float getSeedPointAlpha() const { return _attributes.seedPointAlpha; }
170  void setSeedPointAlpha(float alpha);
172  inline int getVoxelWriteMode() const { return _attributes.voxelWriteMode; }
174  void setVoxelWriteMode(int mode);
176  inline float getVoxelWriteValue() const { return _attributes.voxelWriteValue; }
178  void setVoxelWriteValue(float value);
180 
186  void setUserData(const std::string& name, Variant value) { _attributes.setUserData(name, value); }
188  Variant getUserData(const std::string& name) const { return _attributes.getUserData(name); }
190  void getUserDataNames(std::vector< std::string >& names) const { _attributes.getUserDataNames(names); }
192  void removeUserData(const std::string& name) { _attributes.removeUserData(name); }
194 
200  inline bool getUseTimePointIndex() const { return _useTimePointIndex; }
202  inline void setUseTimePointIndex(bool state) { _useTimePointIndex = state; }
204  inline bool getUseShowState() const { return _useShowState; }
206  inline void setUseShowState(bool state) { _useShowState = state; }
208  inline bool getUseVoxelizeState() const { return _useVoxelizeState; }
210  inline void setUseVoxelizeState(bool state) { _useVoxelizeState = state; }
212  inline bool getUseEditableState() const { return _useEditableState; }
214  inline void setUseEditableState(bool state) { _useEditableState = state; }
216  inline bool getUseSeedPointStyle() const { return _useSeedPointStyle; }
218  inline void setUseSeedPointStyle(bool state) { _useSeedPointStyle = state; }
220  inline bool getUseSeedPointSize() const { return _useSeedPointSize; }
222  inline void setUseSeedPointSize(bool state) { _useSeedPointSize = state; }
224  inline bool getUseSeedPointColor() const { return _useSeedPointColor; }
226  inline void setUseSeedPointColor(bool state) { _useSeedPointColor = state; }
228  inline bool getUseSeedPointAlpha() const { return _useSeedPointAlpha; }
230  inline void setUseSeedPointAlpha(bool state) { _useSeedPointAlpha = state; }
232  inline bool getUsePathPointStyle() const { return _usePathPointStyle; }
234  inline void setUsePathPointStyle(bool state) { _usePathPointStyle = state; }
236  inline bool getUsePathPointWidth() const { return _usePathPointWidth; }
238  inline void setUsePathPointWidth(bool state) { _usePathPointWidth = state; }
240  inline bool getUsePathPointColor() const { return _usePathPointColor; }
242  inline void setUsePathPointColor(bool state) { _usePathPointColor = state; }
244  inline bool getUsePathPointAlpha() const { return _usePathPointAlpha; }
246  inline void setUsePathPointAlpha(bool state) { _usePathPointAlpha = state; }
248  inline bool getUseVoxelWriteMode() const { return _useVoxelWriteMode; }
250  inline void setUseVoxelWriteMode(bool state) { _useVoxelWriteMode = state; }
252  inline bool getUseVoxelWriteValue() const { return _useVoxelWriteValue; }
254  inline void setUseVoxelWriteValue(bool state) { _useVoxelWriteValue = state; }
256 
264  CSOBoundingBox getVoxelBoundingBox(const Matrix4& worldToVoxelMatrix, size_t hashKey);
266 
268  void groupChanged();
269 
271  bool saveAttributes(std::ostream& outStream, bool useAscii=false);
273  void loadAttributes(std::istream& inStream, short version, bool swapBytes, bool useAscii=false);
274 
275 
276 #if !ML_DEPRECATED_SINCE(3,5,0)
277 private:
278 
279 #ifdef ML_DEPRECATED
280 #define ML_DEPRECATED_TMP ML_DEPRECATED
281 #undef ML_DEPRECATED
282 #endif
283 
284 #define ML_DEPRECATED
285 #endif
286 
290  inline ML_DEPRECATED unsigned int numCSO() const { return numCSOs(); }
293  inline ML_DEPRECATED CSOPathPointsStyle getLineStyle() const { return getPathPointStyle(); }
296  inline ML_DEPRECATED void setLineStyle(CSOPathPointsStyle lineStyle) { setPathPointStyle(lineStyle); }
299  inline ML_DEPRECATED const Vector3& getColor() const { return getPathPointColor(); }
302  inline ML_DEPRECATED void setColor(const Vector3& color) { setPathPointColor(color); }
305  inline ML_DEPRECATED float getAlpha() const { return getPathPointAlpha(); }
308  inline ML_DEPRECATED void setAlpha(float alpha) { setPathPointAlpha(alpha); }
311  inline ML_DEPRECATED float getLineWidth() const { return getPathPointWidth(); }
314  inline ML_DEPRECATED void setLineWidth(float lineWidth) { setPathPointWidth(lineWidth); }
317  inline ML_DEPRECATED int getMarkerMode() const { return getSeedPointStyle(); }
320  inline ML_DEPRECATED void setMarkerMode(int markerMode) { setSeedPointStyle(markerMode); }
323  inline ML_DEPRECATED const Vector3& getMarkerColor() const { return getSeedPointColor(); }
326  inline ML_DEPRECATED void setMarkerColor(const Vector3& markerColor) { setSeedPointColor(markerColor); }
329  inline ML_DEPRECATED float getMarkerAlpha() const { return getSeedPointAlpha(); }
332  inline ML_DEPRECATED void setMarkerAlpha(float markerAlpha) { setSeedPointAlpha(markerAlpha); }
335  inline ML_DEPRECATED float getMarkerSize() const { return getSeedPointSize(); }
338  inline ML_DEPRECATED void setMarkerSize(float markerSize) { setSeedPointSize(markerSize);}
341  inline ML_DEPRECATED bool getUseVisuals() const {
342  return _usePathPointStyle || _usePathPointWidth || _usePathPointColor || _usePathPointAlpha;
343  }
346  inline ML_DEPRECATED void setUseVisuals(bool state) {
347  _usePathPointAlpha = _usePathPointColor = _usePathPointStyle = _usePathPointWidth = state;
348  }
351  inline ML_DEPRECATED bool getUseVoxelWrite() const {
352  return _useVoxelWriteValue || _useVoxelWriteMode;
353  }
356  inline ML_DEPRECATED void setUseVoxelWrite(bool state) {
357  _useVoxelWriteMode = _useVoxelWriteValue = state;
358  }
361  inline ML_DEPRECATED bool getUseMarkerSettings() const {
362  return _useSeedPointAlpha || _useSeedPointColor || _useSeedPointSize || _useSeedPointStyle;
363  }
366  inline ML_DEPRECATED void setUseMarkerSettings(bool state) {
367  _useSeedPointAlpha = _useSeedPointColor = _useSeedPointSize = _useSeedPointStyle = state;
368  }
370 #ifdef ML_DEPRECATED_TMP
371 #define ML_DEPRECATED ML_DEPRECATED_TMP
372 #undef ML_DEPRECATED_TMP
373 #endif
374 private:
375 
377  unsigned int _uniqueId;
378 
380  std::vector<unsigned int>_memberCSOIds;
381 
383  CSOList* _csoList;
384 
386  CSOAttributes _attributes;
387 
389  CSOGroupRules _rules;
390 
392  bool _useTimePointIndex;
394  bool _useShowState;
396  bool _useVoxelizeState;
398  bool _useEditableState;
399 
400  bool _useSeedPointStyle;
401  bool _useSeedPointSize;
402  bool _useSeedPointColor;
403  bool _useSeedPointAlpha;
404 
405  bool _usePathPointStyle;
406  bool _usePathPointWidth;
407  bool _usePathPointColor;
408  bool _usePathPointAlpha;
409 
410  bool _useVoxelWriteMode;
411  bool _useVoxelWriteValue;
412 
414  bool _hasValidWorldBoundingBox;
416  CSOBoundingBox _worldBoundingBox;
418  boost::unordered_map < size_t, CSOBoundingBox > _voxelBoundingBoxCache;
419 };
420 
421 ML_END_NAMESPACE
#define ML_DEPRECATED
Definition: CSOGroup.h:371
#define MLCSO_EXPORT
Defines export symbols for classes, so they can be used in other DLLs.
Definition: MLCSOSystem.h:23
The CSOBoundingBox defines an axis parallel bounding box with double precision.
This handles rules like the maximum number of CSOs in a group and applies them.
Definition: CSOGroupRules.h:58
A CSOGroup comprises a number of CSOs, which themselves can be in a number of different CSOGroups.
Definition: CSOGroup.h:38
CSOGroup(const CSOGroup &group, int groupId=-1, CSOList *csoList=nullptr)
Copy constructor.
CSOGroup(CSOList *csoList)
Constructor, takes a pointer to the embracing CSOList as an argument.
void setPathPointWidth(float width)
Sets the width of the path points.
void _addReferenceToCSO(const CSO &cso)
void setSeedPointColor(const Vector3 &color)
Sets the color of the seed points.
void setSeedPointSize(float size)
Sets the size of the seed points.
void setUseSeedPointStyle(bool state)
Sets whether this Group overrides the seed point style of its CSOs.
Definition: CSOGroup.h:218
bool getUseSeedPointColor() const
Returns whether this Group overrides the seed point color of its CSOs.
Definition: CSOGroup.h:224
void setSeedPointAlpha(float alpha)
Sets the alpha value of the seed points.
bool getUseVoxelWriteMode() const
Returns whether this Group overrides the voxel write mode of its CSOs.
Definition: CSOGroup.h:248
float getSeedPointAlpha() const
Returns the alpha value of the seed points.
Definition: CSOGroup.h:168
void setUsePathPointStyle(bool state)
Sets whether this Group overrides the path point style of its CSOs.
Definition: CSOGroup.h:234
void setId(unsigned int id)
Sets the Id of this group.
Definition: CSOGroup.h:95
void setUseVoxelizeState(bool state)
Sets whether this Group overrides the voxelize state of its CSOs.
Definition: CSOGroup.h:210
void setShowState(bool state)
Sets the 'show' status of this Group.
void setTimePointIndex(MLint timePointIndex)
Sets the time point index of this group.
void setVoxelWriteMode(int mode)
Sets the voxel write mode of this Group.
bool getEditableState() const
Returns the 'editable' status of this Group.
Definition: CSOGroup.h:136
void setPathPointAlpha(float alpha)
Sets the alpha value of the path points.
void loadAttributes(std::istream &inStream, short version, bool swapBytes, bool useAscii=false)
Load attributes from stream.
bool getUseSeedPointStyle() const
Returns whether this Group overrides the seed point style of its CSOs.
Definition: CSOGroup.h:216
bool getUseEditableState() const
Returns whether this Group overrides the editable state of its CSOs.
Definition: CSOGroup.h:212
void setUseSeedPointColor(bool state)
Sets whether this Group overrides the seed point color of its CSOs.
Definition: CSOGroup.h:226
void _removeReferenceToCSO(const CSO &cso)
Removes a reference to a CSO from this group.
CSO * getCSOAt(unsigned int index) const
Returns a pointer to the CSO at the given index. Beware: no index check.
const CSOBoundingBox & getBoundingBox()
CSOGroupRules & getRules()
Return the rules for this CSOGroup.
Definition: CSOGroup.h:55
float getSeedPointSize() const
Returns the size of the seed points.
Definition: CSOGroup.h:160
int getSeedPointStyle() const
Returns the style of the seed points.
Definition: CSOGroup.h:156
const Vector3 & getPathPointColor() const
Returns the color of the path points.
Definition: CSOGroup.h:148
bool isSelected() const
Returns whether this group is selected in its enclosing CSOList.
void setPathPointColor(const Vector3 &color)
Sets the color of the path points.
~CSOGroup()
Destructor.
unsigned int numCSOs() const
Returns the number of CSOs in this group.
Definition: CSOGroup.h:71
bool contains(const CSO *cso) const
Returns if this group contains the given CSO.
float getPathPointAlpha() const
Returns the alpha value of the path points.
Definition: CSOGroup.h:152
bool getUseShowState() const
Returns if this Group overrides the show state of its CSOs.
Definition: CSOGroup.h:204
void setUserData(const std::string &name, Variant value)
Definition: CSOGroup.h:186
void setUsePathPointAlpha(bool state)
Sets whether this Group overrides the path point alpha of its CSOs.
Definition: CSOGroup.h:246
unsigned int getId() const
Definition: CSOGroup.h:93
void setUseVoxelWriteMode(bool state)
Sets whether this Group overrides the voxel write mode of its CSOs.
Definition: CSOGroup.h:250
unsigned int getCSOIdAt(unsigned int index) const
Returns the id of an associated CSO at the given index. Beware: no index check.
Definition: CSOGroup.h:75
void setUseSeedPointSize(bool state)
Sets whether this Group overrides the seed point size of its CSOs.
Definition: CSOGroup.h:222
void setPathPointStyle(int style)
Sets the path point style as an int.
Definition: CSOGroup.h:142
CSOList * getCSOList() const
Returns a pointer to the embracing CSOList of this Group.
Definition: CSOGroup.h:101
bool getUsePathPointStyle() const
Returns whether this Group overrides the path point style of its CSOs.
Definition: CSOGroup.h:232
bool addCSO(CSO &cso, bool useUndoRedo=true)
bool getUseTimePointIndex() const
Definition: CSOGroup.h:200
void setUseShowState(bool state)
Sets whether this Group overrides the show state of its CSOs.
Definition: CSOGroup.h:206
void removeCSO(CSO &cso, bool useUndoRedo=true)
removes given CSO from this group
void setUseSeedPointAlpha(bool state)
Sets whether this Group overrides the seed point alpha of its CSOs.
Definition: CSOGroup.h:230
Variant getUserData(const std::string &name) const
Returns the user data under the given name or an invalid value if the entry does not exist.
Definition: CSOGroup.h:188
void setDescription(const std::string &description)
Sets the group description.
bool getShowState() const
Returns the 'show' status of this Group.
Definition: CSOGroup.h:128
bool getUsePathPointAlpha() const
Returns whether this Group overrides the path point alpha of its CSOs.
Definition: CSOGroup.h:244
void setUsePathPointColor(bool state)
Sets whether this Group overrides the path point color of its CSOs.
Definition: CSOGroup.h:242
bool getVoxelizeState() const
Returns the 'voxelize' status of this Group.
Definition: CSOGroup.h:132
const std::string & getDescription() const
Returns the group description.
Definition: CSOGroup.h:119
void setUseEditableState(bool state)
Sets whether this Group overrides the editable state of its CSOs.
Definition: CSOGroup.h:214
void getUserDataNames(std::vector< std::string > &names) const
Fills the given vector with the keys/name under which user data are stored for this CSO.
Definition: CSOGroup.h:190
bool saveAttributes(std::ostream &outStream, bool useAscii=false)
Save attributes to stream and returns whether the saving was successful.
bool getUsePathPointColor() const
Returns whether this Group overrides the path point color of its CSOs.
Definition: CSOGroup.h:240
float getVoxelWriteValue() const
Returns the voxel write value of this Group.
Definition: CSOGroup.h:176
void setEditableState(bool state)
Sets the 'editable' status of this Group.
int getVoxelWriteMode() const
Returns the voxel write mode of this Group.
Definition: CSOGroup.h:172
const Vector3 & getSeedPointColor() const
Returns the color of the seed points.
Definition: CSOGroup.h:164
void removeAllCSO(bool useUndoRedo=true, bool shouldApplyRemoveFromGroupRule=true)
Removes all CSOs from this group.
int getTimePointIndex() const
Returns the time point index of this group.
Definition: CSOGroup.h:122
void setSeedPointStyle(int seedPointStyle)
Sets the style of the seed points.
bool getUsePathPointWidth() const
Returns whether this Group overrides the path point width of its CSOs.
Definition: CSOGroup.h:236
void setVoxelizeState(bool state)
Sets the 'voxelize' status of this Group.
void setUsePathPointWidth(bool state)
Sets whether this Group overrides the path point width of its CSOs.
Definition: CSOGroup.h:238
const std::string & getLabel() const
Returns the group label.
Definition: CSOGroup.h:115
bool getUseVoxelWriteValue() const
Returns whether this Group overrides the voxel write value of its CSOs.
Definition: CSOGroup.h:252
CSOPathPointsStyle getPathPointStyle() const
Returns the path point style.
Definition: CSOGroup.h:138
bool getUseSeedPointAlpha() const
Returns whether this Group overrides the seed point alpha of its CSOs.
Definition: CSOGroup.h:228
float getPathPointWidth() const
Returns the width of the path points.
Definition: CSOGroup.h:144
void setCSOList(CSOList *csoList)
Sets the embracing CSOList for this Group.
void setUseVoxelWriteValue(bool state)
Sets whether this Group overrides the voxel write value of its CSOs.
Definition: CSOGroup.h:254
void setLabel(const std::string &label)
bool getUseVoxelizeState() const
Returns whether this Group overrides the voxelize state of its CSOs.
Definition: CSOGroup.h:208
bool getUseSeedPointSize() const
Returns whether this Group overrides the seed point size of its CSOs.
Definition: CSOGroup.h:220
void removeUserData(const std::string &name)
Removes a user data entry.
Definition: CSOGroup.h:192
CSOGroup()
Constructor.
void setPathPointStyle(CSOPathPointsStyle style)
Sets the path point style.
CSOBoundingBox getVoxelBoundingBox(const Matrix4 &worldToVoxelMatrix, size_t hashKey)
Returns the unified voxel bounding box of all contained CSOs.
void setUseTimePointIndex(bool state)
Sets whether the time point index of this Group should be used.
Definition: CSOGroup.h:202
void groupChanged()
Marks this Group as changed (e.g. if a CSO has been added, removed or changed).
void setVoxelWriteValue(float value)
Sets the voxel write value of this Group.
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
The Variant class stores different data types.
Definition: mlVariant.h:36
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition: mlTypeDefs.h:578
CSOPathPointsStyle
Enumeration of line styles (order as StylePalette::LineStyle).
Definition: CSODefines.h:42
Tvec3< MLdouble > Vector3
A vector with 3 components of type double.
Definition: mlVector3.h:300