Slicer 5.9
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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:
39
42 void PrintSelf(ostream& os, vtkIndent indent) override;
43
45
47 const char* GetNodeTagName() override { return "ColorLegendDisplay"; }
48
50 void ReadXMLAttributes(const char** atts) override;
51
53 void WriteXML(ostream& of, int indent) override;
54
58
60
62 vtkGetMacro(Orientation, OrientationType);
63 vtkSetMacro(Orientation, OrientationType);
65
67
69 vtkGetVector2Macro(Position, double);
70 vtkSetVector2Macro(Position, double);
72
74
80 vtkGetVector2Macro(Size, double);
81 vtkSetVector2Macro(Size, double);
83
85
86 vtkGetMacro(TitleText, std::string);
87 vtkSetMacro(TitleText, std::string);
89
91
99 vtkGetMacro(LabelFormat, std::string);
100 vtkSetMacro(LabelFormat, std::string);
102
106 virtual std::string GetDefaultNumericLabelFormat();
107
111 virtual std::string GetDefaultTextLabelFormat();
112
114
115 vtkGetMacro(MaxNumberOfColors, int);
116 vtkSetMacro(MaxNumberOfColors, int);
118
120
121 vtkGetMacro(NumberOfLabels, int);
122 vtkSetMacro(NumberOfLabels, int);
124
126
127 vtkGetMacro(UseColorNamesForLabels, bool);
128 vtkSetMacro(UseColorNamesForLabels, bool);
130
132
135 vtkGetObjectMacro(TitleTextProperty, vtkTextProperty);
137
139
142 vtkGetObjectMacro(LabelTextProperty, vtkTextProperty);
144
146
153
155 void ProcessMRMLEvents(vtkObject *caller, unsigned long eventID, void *callData) override;
156
157protected:
162
163 static const char* GetOrientationAsString(int id);
164 static int GetOrientationFromString(const char* name);
165 void SetOrientation(int id);
166
168
170 void SetTitleTextPropertyFromString(std::string textPropertyString);
171 void SetLabelTextPropertyFromString(std::string textPropertyString);
175
176private:
177 OrientationType Orientation{ vtkMRMLColorLegendDisplayNode::Vertical }; // Vertical or Horizontal
178 double Position[2]{ 0.95, 0.5 }; // color legend position within view
179 double Size[2]{ 0.15, 0.5 }; // color legend width within view
180 std::string TitleText; // color legend title
181 vtkTextProperty* TitleTextProperty{ nullptr };
182 vtkTextProperty* LabelTextProperty{ nullptr };
183 // 7 so that the number appears aligned to the right even if it is large (>1000)
184 // .1 to show one fractional digit
185 // f to make the behavior more predictable for users (behavior of g is somewhat complex)
186 std::string LabelFormat;
187 int MaxNumberOfColors{ 256 };
188 int NumberOfLabels{ 5 };
189 bool UseColorNamesForLabels{ false };
190 bool CenterLabels{ false };
191};
192
193#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.