MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
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"
24
26
27// forward declarations
28class CSO;
29class 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
43public:
47 CSOGroup(CSOList* csoList);
49 CSOGroup(const CSOGroup& group, int groupId = -1, CSOList* csoList = nullptr);
52
55 {
56 return _rules;
57 }
58
65 bool addCSO(CSO& cso, bool useUndoRedo = true);
67 void removeCSO(CSO& cso, bool useUndoRedo = true);
71 bool contains(const CSO* cso) const;
73 inline unsigned int numCSOs() const
74 {
75 return static_cast<unsigned int>(_memberCSOIds.size());
76 }
78 CSO* getCSOAt(unsigned int index) const;
80 inline unsigned int getCSOIdAt(unsigned int index) const
81 {
82 return _memberCSOIds[index];
83 }
85
91 void _addReferenceToCSO(const CSO& cso);
93 void _removeReferenceToCSO(const CSO& cso);
95
101 inline unsigned int getId() const
102 {
103 return _uniqueId;
104 }
106 inline void setId(unsigned int id)
107 {
108 _uniqueId = id;
109 }
113 void setCSOList(CSOList* csoList);
115 inline CSOList* getCSOList() const
116 {
117 return _csoList;
118 }
120
123 bool isSelected() const;
124
130 void setLabel(const std::string& label);
132 inline const std::string& getLabel() const
133 {
134 return _attributes.label;
135 }
137 void setDescription(const std::string& description);
139 inline const std::string& getDescription() const
140 {
141 return _attributes.description;
142 }
143
145 inline int getTimePointIndex() const
146 {
147 return _attributes.timePointIndex;
148 }
150 void setTimePointIndex(MLint timePointIndex);
152 void setShowState(bool state);
154 inline bool getShowState() const
155 {
156 return _attributes.showState;
157 }
159 void setVoxelizeState(bool state);
161 inline bool getVoxelizeState() const
162 {
163 return _attributes.voxelizeState;
164 }
166 void setEditableState(bool state);
168 inline bool getEditableState() const
169 {
170 return _attributes.editableState;
171 }
174 {
175 return static_cast<CSOPathPointsStyle>(_attributes.pathPointStyle);
176 }
180 inline void setPathPointStyle(int style)
181 {
182 setPathPointStyle(static_cast<CSOPathPointsStyle>(style));
183 }
185 inline float getPathPointWidth() const
186 {
187 return _attributes.pathPointWidth;
188 }
190 void setPathPointWidth(float width);
192 inline const Vector3& getPathPointColor() const
193 {
194 return _attributes.pathPointColor;
195 }
197 void setPathPointColor(const Vector3& color);
199 inline float getPathPointAlpha() const
200 {
201 return _attributes.pathPointAlpha;
202 }
204 void setPathPointAlpha(float alpha);
206 inline int getSeedPointStyle() const
207 {
208 return _attributes.seedPointStyle;
209 }
211 void setSeedPointStyle(int seedPointStyle);
213 inline float getSeedPointSize() const
214 {
215 return _attributes.seedPointSize;
216 }
218 void setSeedPointSize(float size);
220 inline const Vector3& getSeedPointColor() const
221 {
222 return _attributes.seedPointColor;
223 }
225 void setSeedPointColor(const Vector3& color);
227 inline float getSeedPointAlpha() const
228 {
229 return _attributes.seedPointAlpha;
230 }
232 void setSeedPointAlpha(float alpha);
234 inline int getVoxelWriteMode() const
235 {
236 return _attributes.voxelWriteMode;
237 }
239 void setVoxelWriteMode(int mode);
241 inline float getVoxelWriteValue() const
242 {
243 return _attributes.voxelWriteValue;
244 }
246 void setVoxelWriteValue(float value);
248
254 void setUserData(const std::string& name, Variant value)
255 {
256 _attributes.setUserData(name, value);
257 }
259 Variant getUserData(const std::string& name) const
260 {
261 return _attributes.getUserData(name);
262 }
264 void getUserDataNames(std::vector<std::string>& names) const
265 {
266 _attributes.getUserDataNames(names);
267 }
269 void removeUserData(const std::string& name)
270 {
271 _attributes.removeUserData(name);
272 }
274
280 inline bool getUseTimePointIndex() const
281 {
282 return _useTimePointIndex;
283 }
285 inline void setUseTimePointIndex(bool state)
286 {
287 _useTimePointIndex = state;
288 }
290 inline bool getUseShowState() const
291 {
292 return _useShowState;
293 }
295 inline void setUseShowState(bool state)
296 {
297 _useShowState = state;
298 }
300 inline bool getUseVoxelizeState() const
301 {
302 return _useVoxelizeState;
303 }
305 inline void setUseVoxelizeState(bool state)
306 {
307 _useVoxelizeState = state;
308 }
310 inline bool getUseEditableState() const
311 {
312 return _useEditableState;
313 }
315 inline void setUseEditableState(bool state)
316 {
317 _useEditableState = state;
318 }
320 inline bool getUseSeedPointStyle() const
321 {
322 return _useSeedPointStyle;
323 }
325 inline void setUseSeedPointStyle(bool state)
326 {
327 _useSeedPointStyle = state;
328 }
330 inline bool getUseSeedPointSize() const
331 {
332 return _useSeedPointSize;
333 }
335 inline void setUseSeedPointSize(bool state)
336 {
337 _useSeedPointSize = state;
338 }
340 inline bool getUseSeedPointColor() const
341 {
342 return _useSeedPointColor;
343 }
345 inline void setUseSeedPointColor(bool state)
346 {
347 _useSeedPointColor = state;
348 }
350 inline bool getUseSeedPointAlpha() const
351 {
352 return _useSeedPointAlpha;
353 }
355 inline void setUseSeedPointAlpha(bool state)
356 {
357 _useSeedPointAlpha = state;
358 }
360 inline bool getUsePathPointStyle() const
361 {
362 return _usePathPointStyle;
363 }
365 inline void setUsePathPointStyle(bool state)
366 {
367 _usePathPointStyle = state;
368 }
370 inline bool getUsePathPointWidth() const
371 {
372 return _usePathPointWidth;
373 }
375 inline void setUsePathPointWidth(bool state)
376 {
377 _usePathPointWidth = state;
378 }
380 inline bool getUsePathPointColor() const
381 {
382 return _usePathPointColor;
383 }
385 inline void setUsePathPointColor(bool state)
386 {
387 _usePathPointColor = state;
388 }
390 inline bool getUsePathPointAlpha() const
391 {
392 return _usePathPointAlpha;
393 }
395 inline void setUsePathPointAlpha(bool state)
396 {
397 _usePathPointAlpha = state;
398 }
400 inline bool getUseVoxelWriteMode() const
401 {
402 return _useVoxelWriteMode;
403 }
405 inline void setUseVoxelWriteMode(bool state)
406 {
407 _useVoxelWriteMode = state;
408 }
410 inline bool getUseVoxelWriteValue() const
411 {
412 return _useVoxelWriteValue;
413 }
415 inline void setUseVoxelWriteValue(bool state)
416 {
417 _useVoxelWriteValue = state;
418 }
420
428 CSOBoundingBox getVoxelBoundingBox(const Matrix4& worldToVoxelMatrix, size_t hashKey);
430
433
435 bool saveAttributes(std::ostream& outStream, bool useAscii = false);
437 void loadAttributes(std::istream& inStream, short version, bool swapBytes, bool useAscii = false);
438
440private:
442 unsigned int _uniqueId;
443
445 std::vector<unsigned int> _memberCSOIds;
446
448 CSOList* _csoList;
449
451 CSOAttributes _attributes;
452
454 CSOGroupRules _rules;
455
457 bool _useTimePointIndex;
459 bool _useShowState;
461 bool _useVoxelizeState;
463 bool _useEditableState;
464
465 bool _useSeedPointStyle;
466 bool _useSeedPointSize;
467 bool _useSeedPointColor;
468 bool _useSeedPointAlpha;
469
470 bool _usePathPointStyle;
471 bool _usePathPointWidth;
472 bool _usePathPointColor;
473 bool _usePathPointAlpha;
474
475 bool _useVoxelWriteMode;
476 bool _useVoxelWriteValue;
477
479 bool _hasValidWorldBoundingBox;
481 CSOBoundingBox _worldBoundingBox;
483 boost::unordered_map<size_t, CSOBoundingBox> _voxelBoundingBoxCache;
484};
485
#define MLCSO_EXPORT
Defines export symbols for classes, so they can be used in other DLLs.
Definition MLCSOSystem.h:23
This class comprises some attributes that are common for a CSO and a CSOGroup.
The CSOBoundingBox defines an axis-parallel bounding box with double precision.
This handles rules like the maximum number of CSOs in a CSOGroup and applies them.
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 CSOGroup overrides the seed point style of its CSOs.
Definition CSOGroup.h:325
bool getUseSeedPointColor() const
Returns whether this CSOGroup overrides the seed point color of its CSOs.
Definition CSOGroup.h:340
void setSeedPointAlpha(float alpha)
Sets the alpha value of the seed points.
bool getUseVoxelWriteMode() const
Returns whether this CSOGroup overrides the voxel write mode of its CSOs.
Definition CSOGroup.h:400
float getSeedPointAlpha() const
Returns the alpha value of the seed points.
Definition CSOGroup.h:227
void setUsePathPointStyle(bool state)
Sets whether this CSOGroup overrides the path point style of its CSOs.
Definition CSOGroup.h:365
void setId(unsigned int id)
Sets the ID of this CSOGroup.
Definition CSOGroup.h:106
void setUseVoxelizeState(bool state)
Sets whether this CSOGroup overrides the voxelize state of its CSOs.
Definition CSOGroup.h:305
void setShowState(bool state)
Sets the 'show' status of this CSOGroup.
void setTimePointIndex(MLint timePointIndex)
Sets the time point index of this CSOGroup.
void setVoxelWriteMode(int mode)
Sets the voxel write mode of this CSOGroup.
bool getEditableState() const
Returns the 'editable' status of this CSOGroup.
Definition CSOGroup.h:168
void setPathPointAlpha(float alpha)
Sets the alpha value of the path points.
void loadAttributes(std::istream &inStream, short version, bool swapBytes, bool useAscii=false)
Loads attributes from stream.
bool getUseSeedPointStyle() const
Returns whether this CSOGroup overrides the seed point style of its CSOs.
Definition CSOGroup.h:320
bool getUseEditableState() const
Returns whether this CSOGroup overrides the editable state of its CSOs.
Definition CSOGroup.h:310
void setUseSeedPointColor(bool state)
Sets whether this CSOGroup overrides the seed point color of its CSOs.
Definition CSOGroup.h:345
void _removeReferenceToCSO(const CSO &cso)
Removes a reference to a CSO from this CSOGroup.
float getSeedPointSize() const
Returns the size of the seed points.
Definition CSOGroup.h:213
int getSeedPointStyle() const
Returns the style of the seed points.
Definition CSOGroup.h:206
CSO * getCSOAt(unsigned int index) const
Returns a pointer to the CSO at the specified index. Beware: no index check.
bool isSelected() const
Returns whether this CSOGroup 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 CSOGroup.
Definition CSOGroup.h:73
bool contains(const CSO *cso) const
Returns whether this CSOGroup contains the specified CSO.
float getPathPointAlpha() const
Returns the alpha value of the path points.
Definition CSOGroup.h:199
bool getUseShowState() const
Returns whether this CSOGroup overrides the show state of its CSOs.
Definition CSOGroup.h:290
void setUserData(const std::string &name, Variant value)
Definition CSOGroup.h:254
void setUsePathPointAlpha(bool state)
Sets whether this CSOGroup overrides the path point alpha of its CSOs.
Definition CSOGroup.h:395
unsigned int getId() const
Definition CSOGroup.h:101
void setUseVoxelWriteMode(bool state)
Sets whether this CSOGroup overrides the voxel write mode of its CSOs.
Definition CSOGroup.h:405
unsigned int getCSOIdAt(unsigned int index) const
Returns the ID of an associated CSO at the specified index. Beware: no index check.
Definition CSOGroup.h:80
void setUseSeedPointSize(bool state)
Sets whether this CSOGroup overrides the seed point size of its CSOs.
Definition CSOGroup.h:335
void setPathPointStyle(int style)
Sets the path point style as an int.
Definition CSOGroup.h:180
const std::string & getDescription() const
Returns the CSOGroup description.
Definition CSOGroup.h:139
bool getUsePathPointStyle() const
Returns whether this CSOGroup overrides the path point style of its CSOs.
Definition CSOGroup.h:360
bool addCSO(CSO &cso, bool useUndoRedo=true)
bool getUseTimePointIndex() const
Definition CSOGroup.h:280
void setUseShowState(bool state)
Sets whether this CSOGroup overrides the show state of its CSOs.
Definition CSOGroup.h:295
void removeCSO(CSO &cso, bool useUndoRedo=true)
Removes specified CSO from this CSOGroup.
void setUseSeedPointAlpha(bool state)
Sets whether this CSOGroup overrides the seed point alpha of its CSOs.
Definition CSOGroup.h:355
Variant getUserData(const std::string &name) const
Returns the user data under the specified name or an invalid value if the entry does not exist.
Definition CSOGroup.h:259
void setDescription(const std::string &description)
Sets the CSOGroup description.
bool getShowState() const
Returns the 'show' status of this CSOGroup.
Definition CSOGroup.h:154
bool getUsePathPointAlpha() const
Returns whether this CSOGroup overrides the path point alpha of its CSOs.
Definition CSOGroup.h:390
void setUsePathPointColor(bool state)
Sets whether this CSOGroup overrides the path point color of its CSOs.
Definition CSOGroup.h:385
bool getVoxelizeState() const
Returns the 'voxelize' status of this CSOGroup.
Definition CSOGroup.h:161
void setUseEditableState(bool state)
Sets whether this CSOGroup overrides the editable state of its CSOs.
Definition CSOGroup.h:315
void getUserDataNames(std::vector< std::string > &names) const
Fills the specified vector with the keys/name under which user data are stored for this CSO.
Definition CSOGroup.h:264
const CSOBoundingBox & getBoundingBox()
bool saveAttributes(std::ostream &outStream, bool useAscii=false)
Saves attributes to stream and returns whether the saving was successful.
bool getUsePathPointColor() const
Returns whether this CSOGroup overrides the path point color of its CSOs.
Definition CSOGroup.h:380
float getVoxelWriteValue() const
Returns the voxel write value of this CSOGroup.
Definition CSOGroup.h:241
void setEditableState(bool state)
Sets the 'editable' status of this CSOGroup.
int getVoxelWriteMode() const
Returns the voxel write mode of this CSOGroup.
Definition CSOGroup.h:234
const Vector3 & getPathPointColor() const
Returns the color of the path points.
Definition CSOGroup.h:192
void removeAllCSO(bool useUndoRedo=true, bool shouldApplyRemoveFromGroupRule=true)
Removes all CSOs from this CSOGroup.
int getTimePointIndex() const
Returns the time point index of this CSOGroup.
Definition CSOGroup.h:145
void setSeedPointStyle(int seedPointStyle)
Sets the style of the seed points.
bool getUsePathPointWidth() const
Returns whether this CSOGroup overrides the path point width of its CSOs.
Definition CSOGroup.h:370
void setVoxelizeState(bool state)
Sets the 'voxelize' status of this CSOGroup.
CSOGroupRules & getRules()
Returns the rules for this CSOGroup.
Definition CSOGroup.h:54
void setUsePathPointWidth(bool state)
Sets whether this CSOGroup overrides the path point width of its CSOs.
Definition CSOGroup.h:375
bool getUseVoxelWriteValue() const
Returns whether this CSOGroup overrides the voxel write value of its CSOs.
Definition CSOGroup.h:410
const Vector3 & getSeedPointColor() const
Returns the color of the seed points.
Definition CSOGroup.h:220
CSOList * getCSOList() const
Returns a pointer to the embracing CSOList of this CSOGroup.
Definition CSOGroup.h:115
CSOPathPointsStyle getPathPointStyle() const
Returns the path point style.
Definition CSOGroup.h:173
const std::string & getLabel() const
Returns the CSOGroup label.
Definition CSOGroup.h:132
bool getUseSeedPointAlpha() const
Returns whether this CSOGroup overrides the seed point alpha of its CSOs.
Definition CSOGroup.h:350
float getPathPointWidth() const
Returns the width of the path points.
Definition CSOGroup.h:185
void setCSOList(CSOList *csoList)
Sets the embracing CSOList for this CSOGroup.
void setUseVoxelWriteValue(bool state)
Sets whether this CSOGroup overrides the voxel write value of its CSOs.
Definition CSOGroup.h:415
void setLabel(const std::string &label)
bool getUseVoxelizeState() const
Returns whether this CSOGroup overrides the voxelize state of its CSOs.
Definition CSOGroup.h:300
bool getUseSeedPointSize() const
Returns whether this CSOGroup overrides the seed point size of its CSOs.
Definition CSOGroup.h:330
void removeUserData(const std::string &name)
Removes a user data entry.
Definition CSOGroup.h:269
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 CSOGroup should be used.
Definition CSOGroup.h:285
void groupChanged()
Marks this CSOGroup as changed (e.g., if a CSO has been added, removed, or changed).
void setVoxelWriteValue(float value)
Sets the voxel write value of this CSOGroup.
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
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition mlTypeDefs.h:489
CSOPathPointsStyle
Enumeration of line styles (order as StylePalette::LineStyle).
Definition CSODefines.h:45