Slicer 5.4
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
35
41{
42public:
43 // Define constants
44 static const double SEGMENT_COLOR_NO_OVERRIDE;
45
48 {
51 double OverrideColor[3];
53 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.
54 bool Visible3D{true};
55 bool Visible2DFill{true}; // This one is used for labelmap volume related operations (color table, merged labelmap)
56 bool Visible2DOutline{true};
58 double Opacity3D{1.0};
59 double Opacity2DFill{1.0}; // This one is used for labelmap volume related operations (color table, merged labelmap)
60 double Opacity2DOutline{1.0};
62 bool Pickable{true};
63
64 // Initialize with default values
66 {
67 OverrideColor[0] = SEGMENT_COLOR_NO_OVERRIDE;
68 OverrideColor[1] = SEGMENT_COLOR_NO_OVERRIDE;
69 OverrideColor[2] = SEGMENT_COLOR_NO_OVERRIDE;
70 }
71
72 // Automatically generated operator= and copy constructor work
73 // correctly for these members, so there is no need to define them.
74 };
75
76 typedef std::map<std::string, SegmentDisplayProperties> SegmentDisplayPropertiesMap;
77
78public:
81 void PrintSelf(ostream& os, vtkIndent indent) override;
82
84
86 void ReadXMLAttributes( const char** atts) override;
87
89 void WriteXML(ostream& of, int indent) override;
90
94
96 const char* GetNodeTagName() override { return "SegmentationDisplay"; }
97
98public:
101 vtkGetStringMacro(PreferredDisplayRepresentationName2D);
103 vtkSetStringMacro(PreferredDisplayRepresentationName2D);
105 vtkGetStringMacro(PreferredDisplayRepresentationName3D);
107 vtkSetStringMacro(PreferredDisplayRepresentationName3D);
108
110 vtkGetMacro(Visibility2DFill, bool);
111 vtkSetMacro(Visibility2DFill, bool);
112 vtkBooleanMacro(Visibility2DFill, bool);
114 vtkGetMacro(Visibility2DOutline, bool);
115 vtkSetMacro(Visibility2DOutline, bool);
116 vtkBooleanMacro(Visibility2DOutline, bool);
117
119 vtkGetMacro(Opacity3D, double);
120 vtkSetMacro(Opacity3D, double);
122 vtkGetMacro(Opacity2DFill, double);
123 vtkSetMacro(Opacity2DFill, double);
125 vtkGetMacro(Opacity2DOutline, double);
126 vtkSetMacro(Opacity2DOutline, double);
127
128public:
134 bool GetSegmentDisplayProperties(std::string segmentID, SegmentDisplayProperties &properties);
135
137 void SetSegmentDisplayProperties(std::string segmentID, SegmentDisplayProperties &properties);
138
140 void SetSegmentDisplayPropertiesToDefault(const std::string& segmentId);
141
143 void RemoveSegmentDisplayProperties(std::string segmentID);
144
147
152
159 void GenerateSegmentColor(double color[3], int colorNumber=0);
162 void GenerateSegmentColor(double &r, double &g, double &b);
163
165
167 void SetSegmentColorGeneratorSourceColorNodeID(const char* colorNodeID);
170
172 void GetPolyDataRepresentationNames(std::set<std::string> &representationNames);
173
180
185
186// Convenience and python compatibility functions
187public:
190 vtkVector3d GetSegmentColor(std::string segmentID);
192 bool GetSegmentColor(std::string segmentID, double* color);
194 bool GetSegmentColor(std::string segmentID, double &r, double &g, double &b);
195
198 vtkVector3d GetSegmentOverrideColor(std::string segmentID);
204 void SetSegmentOverrideColor(std::string segmentID, double r, double g, double b);
206 void SetSegmentOverrideColor(std::string segmentID, vtkVector3d overrideColor);
208 void UnsetSegmentOverrideColor(std::string segmentID);
209
212 bool GetSegmentVisibility(std::string segmentID);
214 void SetSegmentVisibility(std::string segmentID, bool visible);
215 void SetAllSegmentsVisibility(bool visible);
216
219 bool GetSegmentVisibility3D(std::string segmentID);
221 void SetSegmentVisibility3D(std::string segmentID, bool visible);
222 void SetAllSegmentsVisibility3D(bool visible, bool changeVisibleSegmentsOnly = false);
223
226 bool GetSegmentVisibility2DFill(std::string segmentID);
228 void SetSegmentVisibility2DFill(std::string segmentID, bool visible);
229 void SetAllSegmentsVisibility2DFill(bool visible, bool changeVisibleSegmentsOnly = false);
230
233 bool GetSegmentVisibility2DOutline(std::string segmentID);
235 void SetSegmentVisibility2DOutline(std::string segmentID, bool visible);
236 void SetAllSegmentsVisibility2DOutline(bool visible, bool changeVisibleSegmentsOnly = false);
237
240 double GetSegmentOpacity3D(std::string segmentID);
242 void SetSegmentOpacity3D(std::string segmentID, double opacity);
243 void SetAllSegmentsOpacity3D(double opacity, bool changeVisibleSegmentsOnly = false);
244
247 double GetSegmentOpacity2DFill(std::string segmentID);
249 void SetSegmentOpacity2DFill(std::string segmentID, double opacity);
250 void SetAllSegmentsOpacity2DFill(double opacity, bool changeVisibleSegmentsOnly = false);
251
254 double GetSegmentOpacity2DOutline(std::string segmentID);
256 void SetSegmentOpacity2DOutline(std::string segmentID, double opacity);
257 void SetAllSegmentsOpacity2DOutline(double opacity, bool changeVisibleSegmentsOnly = false);
258
260 void SetSegmentOpacity(std::string segmentID, double opacity);
261 void SetAllSegmentsOpacity(double opacity, bool changeVisibleSegmentsOnly = false);
262
265 bool GetSegmentPickable(std::string segmentID);
267 void SetSegmentPickable(std::string segmentID, bool pickable);
268 void SetAllSegmentsPickable(bool pickable, bool changeVisibleSegmentsOnly = false);
269
271 void GetVisibleSegmentIDs(vtkStringArray* segmentIDs);
272
274 void GetVisibleSegmentIDs(std::vector<std::string>& segmentIDs);
275
277 std::vector<std::string> GetVisibleSegmentIDs();
278
279protected:
281 void GetSegmentIDs(std::vector<std::string>& segmentIDs, bool visibleSegmentsOnly);
282
286 void UpdateSegmentList(bool removeUnusedDisplayProperties = true);
287
288protected:
293
294 friend class vtkMRMLSegmentationNode; // Access to UpdateSegmentList();
295
296protected:
299 char* PreferredDisplayRepresentationName2D{nullptr};
300
304 char* PreferredDisplayRepresentationName3D{nullptr};
305
309
312 unsigned int NumberOfGeneratedColors{0};
313
315 vtkMTimeType SegmentListUpdateTime{0};
316 vtkSegmentation* SegmentListUpdateSource{nullptr};
317
321 bool Visibility2DFill{true};
325 bool Visibility2DOutline{true};
326
328 double Opacity3D{1.0};
330 double Opacity2DFill{0.5};
332 double Opacity2DOutline{1.0};
333};
334
335#endif
MRML node to represent discrete color information.
Abstract class that contains graphical display properties for displayable nodes.
Abstract Superclass for all specific types of MRML nodes.
MRML node for representing segmentation display attributes.
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 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.
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)
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)
void GetVisibleSegmentIDs(vtkStringArray *segmentIDs)
Get all visible segment IDs.
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 UpdateSegmentList(bool removeUnusedDisplayProperties=true)
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.
const char * GetSegmentColorGeneratorSourceColorNodeID()
void GetSegmentIDs(std::vector< std::string > &segmentIDs, bool visibleSegmentsOnly)
Convenience function for getting all segment IDs.
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
MRML node containing segmentations.
This class encapsulates a segmentation that can contain multiple segments and multiple representation...