Slicer 5.9
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
vtkMRMLColorLegendDisplayNode.h
Go to the documentation of this file.
1/*==============================================================================
2
3 Program: 3D Slicer
4
5 See COPYRIGHT.txt
6 or http://www.slicer.org/copyright/copyright.txt for details.
7
8 Unless required by applicable law or agreed to in writing, software
9 distributed under the License is distributed on an "AS IS" BASIS,
10 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 See the License for the specific language governing permissions and
12 limitations under the License.
13
14==============================================================================*/
15
16#ifndef __vtkMRMLColorLegendDisplayNode_h
17#define __vtkMRMLColorLegendDisplayNode_h
18
19// MRML includes
20#include <vtkMRMLDisplayNode.h>
21#include "vtkSlicerColorsModuleMRMLExport.h"
22
24class vtkTextProperty;
25
34class VTK_SLICER_COLORS_MODULE_MRML_EXPORT vtkMRMLColorLegendDisplayNode : public vtkMRMLDisplayNode
35{
36public:
44
47 void PrintSelf(ostream& os, vtkIndent indent) override;
48
50
52 const char* GetNodeTagName() override { return "ColorLegendDisplay"; }
53
55 void ReadXMLAttributes(const char** atts) override;
56
58 void WriteXML(ostream& of, int indent) override;
59
63
65
67 vtkGetMacro(Orientation, OrientationType);
68 vtkSetMacro(Orientation, OrientationType);
70
72
74 vtkGetVector2Macro(Position, double);
75 vtkSetVector2Macro(Position, double);
77
79
85 vtkGetVector2Macro(Size, double);
86 vtkSetVector2Macro(Size, double);
88
90
91 vtkGetMacro(TitleText, std::string);
92 vtkSetMacro(TitleText, std::string);
94
96
104 vtkGetMacro(LabelFormat, std::string);
105 vtkSetMacro(LabelFormat, std::string);
107
111 virtual std::string GetDefaultNumericLabelFormat();
112
116 virtual std::string GetDefaultTextLabelFormat();
117
119
120 vtkGetMacro(MaxNumberOfColors, int);
121 vtkSetMacro(MaxNumberOfColors, int);
123
125
126 vtkGetMacro(NumberOfLabels, int);
127 vtkSetMacro(NumberOfLabels, int);
129
131
132 vtkGetMacro(UseColorNamesForLabels, bool);
133 vtkSetMacro(UseColorNamesForLabels, bool);
135
137
140 vtkGetObjectMacro(TitleTextProperty, vtkTextProperty);
142
144
147 vtkGetObjectMacro(LabelTextProperty, vtkTextProperty);
149
151
158
160 void ProcessMRMLEvents(vtkObject* caller, unsigned long eventID, void* callData) override;
161
162protected:
167
168 static const char* GetOrientationAsString(int id);
169 static int GetOrientationFromString(const char* name);
170 void SetOrientation(int id);
171
173
175 void SetTitleTextPropertyFromString(std::string textPropertyString);
176 void SetLabelTextPropertyFromString(std::string textPropertyString);
180
181private:
182 OrientationType Orientation{ vtkMRMLColorLegendDisplayNode::Vertical }; // Vertical or Horizontal
183
184 double Position[2]{ 0.95, 0.5 }; // color legend position within view
185 double Size[2]{ 0.15, 0.5 }; // color legend width within view
186 std::string TitleText; // color legend title
187 vtkTextProperty* TitleTextProperty{ nullptr };
188 vtkTextProperty* LabelTextProperty{ nullptr };
189 // 7 so that the number appears aligned to the right even if it is large (>1000)
190 // .1 to show one fractional digit
191 // f to make the behavior more predictable for users (behavior of g is somewhat complex)
192 std::string LabelFormat;
193 int MaxNumberOfColors{ 256 };
194 int NumberOfLabels{ 5 };
195 bool UseColorNamesForLabels{ false };
196 bool CenterLabels{ false };
197};
198
199#endif
void PrintSelf(ostream &os, vtkIndent indent) override
static vtkMRMLColorLegendDisplayNode * New()
void ProcessMRMLEvents(vtkObject *caller, unsigned long eventID, void *callData) override
Handles events registered in the observer manager.
~vtkMRMLColorLegendDisplayNode() override
static const char * GetOrientationAsString(int id)
std::string GetLabelTextPropertyAsString()
vtkMRMLColorLegendDisplayNode(const vtkMRMLColorLegendDisplayNode &)
void WriteXML(ostream &of, int indent) override
Write this node's information to a MRML file in XML format.
OrientationType
color legend orientation preset on a view node
vtkMRMLDisplayNode * GetPrimaryDisplayNode()
void operator=(const vtkMRMLColorLegendDisplayNode &)
void SetLabelTextPropertyFromString(std::string textPropertyString)
std::string GetTitleTextPropertyAsString()
void SetAndObservePrimaryDisplayNode(vtkMRMLDisplayNode *node)
static int GetOrientationFromString(const char *name)
vtkMRMLNode * CreateNodeInstance() override
Create instance of the default node. Like New only virtual.
void ReadXMLAttributes(const char **atts) override
Read node attributes from XML file.
virtual std::string GetDefaultNumericLabelFormat()
virtual std::string GetDefaultTextLabelFormat()
vtkMRMLCopyContentMacro(vtkMRMLColorLegendDisplayNode)
const char * GetNodeTagName() override
Get node XML tag name (like Volume, Model)
void SetTitleTextPropertyFromString(std::string textPropertyString)
Abstract MRML node to represent color information.