Slicer 5.13
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
vtkMRMLSegmentationDisplayNode.h
Go to the documentation of this file.
1/*==============================================================================
2
3 Program: 3D Slicer
4
5 Copyright (c) Laboratory for Percutaneous Surgery (PerkLab)
6 Queen's University, Kingston, ON, Canada. All Rights Reserved.
7
8 See COPYRIGHT.txt
9 or http://www.slicer.org/copyright/copyright.txt for details.
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16
17 This file was originally developed by Csaba Pinter, PerkLab, Queen's University
18 and was supported through the Applied Cancer Research Unit program of Cancer Care
19 Ontario with funds provided by the Ontario Ministry of Health and Long-Term Care
20
21==============================================================================*/
22
23#ifndef __vtkMRMLSegmentationDisplayNode_h
24#define __vtkMRMLSegmentationDisplayNode_h
25
26#include "vtkMRMLDisplayNode.h"
27
28#include <set>
29
31class vtkSegmentation;
32class vtkStringArray;
33class vtkVector3d;
34
39{
40public:
41 // Define constants
42 static const double SEGMENT_COLOR_NO_OVERRIDE;
43
46 {
49 double OverrideColor[3];
51 bool Visible{ true }; // Turns visibility on/off in general. Useful for allowing the user to show/hide a segment without changing any detailed visibility options.
52 bool Visible3D{ true };
53 bool Visible2DFill{ true }; // This one is used for labelmap volume related operations (color table, merged labelmap)
54 bool Visible2DOutline{ true };
56 double Opacity3D{ 1.0 };
57 double Opacity2DFill{ 1.0 }; // This one is used for labelmap volume related operations (color table, merged labelmap)
58 double Opacity2DOutline{ 1.0 };
60 bool Pickable{ true };
61
62 // Initialize with default values
69
70 // Automatically generated operator= and copy constructor work
71 // correctly for these members, so there is no need to define them.
72
73 bool operator==(const SegmentDisplayProperties& rhs) const
74 {
75 // color comparison
76 for (int i = 0; i < 3; ++i)
77 {
78 if (fabs(OverrideColor[i] - rhs.OverrideColor[i]) > VTK_DBL_EPSILON)
79 {
80 return false;
81 }
82 }
83 return //
84 Visible == rhs.Visible //
85 && Visible3D == rhs.Visible3D //
86 && Visible2DFill == rhs.Visible2DFill //
88 && Opacity3D == rhs.Opacity3D //
89 && Opacity2DFill == rhs.Opacity2DFill //
91 && Pickable == rhs.Pickable;
92 }
93 };
94
95 typedef std::map<std::string, SegmentDisplayProperties> SegmentDisplayPropertiesMap;
96
97public:
100 void PrintSelf(ostream& os, vtkIndent indent) override;
101
103
105 void ReadXMLAttributes(const char** atts) override;
106
108 void WriteXML(ostream& of, int indent) override;
109
113
115 const char* GetNodeTagName() override { return "SegmentationDisplay"; }
116
117public:
127
129 vtkGetMacro(Visibility2DFill, bool);
130 vtkSetMacro(Visibility2DFill, bool);
131 vtkBooleanMacro(Visibility2DFill, bool);
133 vtkGetMacro(Visibility2DOutline, bool);
134 vtkSetMacro(Visibility2DOutline, bool);
135 vtkBooleanMacro(Visibility2DOutline, bool);
136
138 vtkGetMacro(Opacity3D, double);
139 vtkSetMacro(Opacity3D, double);
141 vtkGetMacro(Opacity2DFill, double);
142 vtkSetMacro(Opacity2DFill, double);
144 vtkGetMacro(Opacity2DOutline, double);
145 vtkSetMacro(Opacity2DOutline, double);
146
147public:
153 bool GetSegmentDisplayProperties(std::string segmentID, SegmentDisplayProperties& properties);
154
156 void SetSegmentDisplayProperties(std::string segmentID, SegmentDisplayProperties& properties);
157
159 void SetSegmentDisplayPropertiesToDefault(const std::string& segmentId);
160
162 void RemoveSegmentDisplayProperties(std::string segmentID);
163
166
168
176 void UpdateSegmentList(bool removeUnusedDisplayProperties);
178
186
188
202
209 void GenerateSegmentColor(double color[3], int colorNumber = 0);
212 void GenerateSegmentColor(double& r, double& g, double& b);
213
215
217 void SetSegmentColorGeneratorSourceColorNodeID(const char* colorNodeID);
220
222 void GetPolyDataRepresentationNames(std::set<std::string>& representationNames);
223
232
236
241
242 // Convenience and python compatibility functions
243public:
246 vtkVector3d GetSegmentColor(std::string segmentID);
248 bool GetSegmentColor(std::string segmentID, double* color);
250 bool GetSegmentColor(std::string segmentID, double& r, double& g, double& b);
251
254 vtkVector3d GetSegmentOverrideColor(std::string segmentID);
260 void SetSegmentOverrideColor(std::string segmentID, double r, double g, double b);
262 void SetSegmentOverrideColor(std::string segmentID, vtkVector3d overrideColor);
264 void UnsetSegmentOverrideColor(std::string segmentID);
265
268 bool GetSegmentVisibility(std::string segmentID);
270 void SetSegmentVisibility(std::string segmentID, bool visible);
271 void SetAllSegmentsVisibility(bool visible);
272
275 bool GetSegmentVisibility3D(std::string segmentID);
277 void SetSegmentVisibility3D(std::string segmentID, bool visible);
278 void SetAllSegmentsVisibility3D(bool visible, bool changeVisibleSegmentsOnly = false);
279
282 bool GetSegmentVisibility2DFill(std::string segmentID);
284 void SetSegmentVisibility2DFill(std::string segmentID, bool visible);
285 void SetAllSegmentsVisibility2DFill(bool visible, bool changeVisibleSegmentsOnly = false);
286
289 bool GetSegmentVisibility2DOutline(std::string segmentID);
291 void SetSegmentVisibility2DOutline(std::string segmentID, bool visible);
292 void SetAllSegmentsVisibility2DOutline(bool visible, bool changeVisibleSegmentsOnly = false);
293
296 double GetSegmentOpacity3D(std::string segmentID);
298 void SetSegmentOpacity3D(std::string segmentID, double opacity);
299 void SetAllSegmentsOpacity3D(double opacity, bool changeVisibleSegmentsOnly = false);
300
303 double GetSegmentOpacity2DFill(std::string segmentID);
305 void SetSegmentOpacity2DFill(std::string segmentID, double opacity);
306 void SetAllSegmentsOpacity2DFill(double opacity, bool changeVisibleSegmentsOnly = false);
307
310 double GetSegmentOpacity2DOutline(std::string segmentID);
312 void SetSegmentOpacity2DOutline(std::string segmentID, double opacity);
313 void SetAllSegmentsOpacity2DOutline(double opacity, bool changeVisibleSegmentsOnly = false);
314
316 void SetSegmentOpacity(std::string segmentID, double opacity);
317 void SetAllSegmentsOpacity(double opacity, bool changeVisibleSegmentsOnly = false);
318
321 bool GetSegmentPickable(std::string segmentID);
323 void SetSegmentPickable(std::string segmentID, bool pickable);
324 void SetAllSegmentsPickable(bool pickable, bool changeVisibleSegmentsOnly = false);
325
327 void GetVisibleSegmentIDs(vtkStringArray* segmentIDs);
328
330 void GetVisibleSegmentIDs(std::vector<std::string>& segmentIDs);
331
333 std::vector<std::string> GetVisibleSegmentIDs();
334
336
343 vtkBooleanMacro(RemoveUnusedDisplayProperties, bool);
345
347
349 vtkGetMacro(ClippingCapSurface, bool);
350 vtkSetMacro(ClippingCapSurface, bool);
351 vtkBooleanMacro(ClippingCapSurface, bool);
353
355
356 vtkGetMacro(ClippingCapOpacity, double);
357 vtkSetMacro(ClippingCapOpacity, double);
359
361
363 vtkGetMacro(ClippingOutline, bool);
364 vtkSetMacro(ClippingOutline, bool);
365 vtkBooleanMacro(ClippingOutline, bool);
366
367protected:
369 void GetSegmentIDs(std::vector<std::string>& segmentIDs, bool visibleSegmentsOnly);
370
371protected:
376
377protected:
381
386
390
393 unsigned int NumberOfGeneratedColors{ 0 };
394
396 vtkMTimeType SegmentListUpdateTime{ 0 };
398
402 bool Visibility2DFill{ true };
407
409 double Opacity3D{ 1.0 };
414 double Opacity2DFill{ 0.5 };
416 double Opacity2DOutline{ 1.0 };
417
419
420 bool ClippingCapSurface{ false };
421 double ClippingCapOpacity{ 1.0 };
422 bool ClippingOutline{ false };
423};
424
425#endif
MRML node to represent discrete color information.
bool GetSegmentVisibility3D(std::string segmentID)
bool GetSegmentVisibility2DOutline(std::string segmentID)
void RemoveSegmentDisplayProperties(std::string segmentID)
Remove segment display properties.
void SetSegmentOpacity(std::string segmentID, double opacity)
Set all three types of segment opacity by segment ID.
void SetSegmentVisibility3D(std::string segmentID, bool visible)
Set segment 3D visibility by segment ID. Convenience function for python compatibility.
void WriteXML(ostream &of, int indent) override
Write this node's information to a MRML file in XML format.
void SetSegmentOverrideColor(std::string segmentID, vtkVector3d overrideColor)
Set segment override color by segment ID.
void SetSegmentOpacity2DOutline(std::string segmentID, double opacity)
Set segment 2D outline opacity by segment ID. Convenience function for python compatibility.
double GetLabelmapSurfaceTranslucentOpacity(int level)
double GetSegmentOpacity3D(std::string segmentID)
bool GetSegmentColor(std::string segmentID, double *color)
Get segment color by segment ID. If overridden then the override color is returned.
vtkMTimeType SegmentListUpdateTime
For checking if cached segment list in SegmentationDisplayProperties has to be updated.
SegmentDisplayPropertiesMap SegmentationDisplayProperties
void SetSegmentDisplayProperties(std::string segmentID, SegmentDisplayProperties &properties)
Set segment display properties.
void ClearSegmentDisplayProperties()
Clear segment display properties.
void SetSegmentOpacity2DFill(std::string segmentID, double opacity)
Set segment 2D fill opacity by segment ID. Convenience function for python compatibility.
double GetSegmentOpacity2DFill(std::string segmentID)
std::vector< std::string > GetVisibleSegmentIDs()
Get all visible segment IDs.
const char * GetNodeTagName() override
Get node XML tag name (like Volume, Model)
vtkVector3d GetSegmentOverrideColor(std::string segmentID)
void operator=(const vtkMRMLSegmentationDisplayNode &)
vtkVector3d GetSegmentColor(std::string segmentID)
bool GetSegmentPickable(std::string segmentID)
static vtkMRMLSegmentationDisplayNode * New()
void SetAllSegmentsOpacity2DFill(double opacity, bool changeVisibleSegmentsOnly=false)
void GenerateSegmentColor(double &r, double &g, double &b)
int GetLabelmapSurfaceTranslucentOpacityLevel(double opacity)
void SetAllSegmentsPickable(bool pickable, bool changeVisibleSegmentsOnly=false)
void GenerateSegmentColor(double color[3], int colorNumber=0)
double GetSegmentOpacity2DOutline(std::string segmentID)
void SetAllSegmentsOpacity2DOutline(double opacity, bool changeVisibleSegmentsOnly=false)
bool GetSegmentDisplayProperties(std::string segmentID, SegmentDisplayProperties &properties)
void GetVisibleSegmentIDs(std::vector< std::string > &segmentIDs)
Get all visible segment IDs.
void SetSegmentColorGeneratorSourceColorNodeID(const char *colorNodeID)
vtkMRMLSegmentationDisplayNode(const vtkMRMLSegmentationDisplayNode &)
void PrintSelf(ostream &os, vtkIndent indent) override
std::string GetDisplayRepresentationName2D()
bool GetSegmentVisibility(std::string segmentID)
void SetAllSegmentsVisibility3D(bool visible, bool changeVisibleSegmentsOnly=false)
bool IsBinaryLabelmapPreferredDisplayRepresentation3D()
void GetVisibleSegmentIDs(vtkStringArray *segmentIDs)
Get all visible segment IDs.
void SetNumberOfLabelmapSurfaceOpacityLevels(int numberOfLevels)
bool GetSegmentVisibility2DFill(std::string segmentID)
void SetAllSegmentsVisibility2DFill(bool visible, bool changeVisibleSegmentsOnly=false)
void GetPolyDataRepresentationNames(std::set< std::string > &representationNames)
Collect representation names that are stored as poly data.
void UnsetSegmentOverrideColor(std::string segmentID)
Unset segment override color (default segment color will be used for display instead).
void SetSegmentVisibility2DFill(std::string segmentID, bool visible)
Set segment 2D fill visibility by segment ID. Convenience function for python compatibility.
vtkMRMLNode * CreateNodeInstance() override
Create instance of the default node. Like New only virtual.
void SetSegmentPickable(std::string segmentID, bool pickable)
Set segment 2D pickability by segment ID. Convenience function for python compatibility.
void SetSegmentOpacity3D(std::string segmentID, double opacity)
Set segment 3D opacity by segment ID. Convenience function for python compatibility.
vtkMRMLCopyContentMacro(vtkMRMLSegmentationDisplayNode)
void SetAllSegmentsVisibility(bool visible)
std::map< std::string, SegmentDisplayProperties > SegmentDisplayPropertiesMap
void ReadXMLAttributes(const char **atts) override
Set node attributes from name/value pairs.
void SetSegmentDisplayPropertiesToDefault(const std::string &segmentId)
Set segment display properties to default.
double Opacity2DFill
2D fill opacity for the whole segmentation
double Opacity3D
3D opacity for the whole segmentation
const char * GetSegmentColorGeneratorSourceColorNodeID()
double Opacity2DOutline
2D outline opacity for the whole segmentation
void GetSegmentIDs(std::vector< std::string > &segmentIDs, bool visibleSegmentsOnly)
Convenience function for getting all segment IDs.
void UpdateSegmentList(bool removeUnusedDisplayProperties)
void SetAllSegmentsOpacity(double opacity, bool changeVisibleSegmentsOnly=false)
bool GetSegmentColor(std::string segmentID, double &r, double &g, double &b)
Get segment color by segment ID. If overridden then the override color is returned.
void SetSegmentVisibility(std::string segmentID, bool visible)
Set overall segment visibility by segment ID. Convenience function for python compatibility.
std::string GetDisplayRepresentationName3D()
void SetAllSegmentsOpacity3D(double opacity, bool changeVisibleSegmentsOnly=false)
void SetSegmentOverrideColor(std::string segmentID, double r, double g, double b)
void SetAllSegmentsVisibility2DOutline(bool visible, bool changeVisibleSegmentsOnly=false)
void SetSegmentVisibility2DOutline(std::string segmentID, bool visible)
Set segment 2D outline visibility by segment ID. Convenience function for python compatibility.
~vtkMRMLSegmentationDisplayNode() override
This class encapsulates a segmentation that can contain multiple segments and multiple representation...
bool Pickable
Pickable by interactions flag. If true, then the point under the mouse on the segment surfaces in the...
bool operator==(const SegmentDisplayProperties &rhs) const