Slicer 5.8
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
vtkMRMLColorNode.h
Go to the documentation of this file.
1/*=auto=========================================================================
2
3 Portions (c) Copyright 2006 Brigham and Women's Hospital (BWH) All Rights Reserved.
4
5 See COPYRIGHT.txt
6 or http://www.slicer.org/copyright/copyright.txt for details.
7
8 Program: 3D Slicer
9 Module: $RCSfile: vtkMRMLColorNode.h,v $
10 Date: $Date: 2006/03/19 17:12:28 $
11 Version: $Revision: 1.0 $
12
13=========================================================================auto=*/
14
15#ifndef __vtkMRMLColorNode_h
16#define __vtkMRMLColorNode_h
17
18// MRML includes
19#include "vtkMRMLStorableNode.h"
20
21// VTK includes
22class vtkLookupTable;
23class vtkScalarsToColors;
24
25// Std includes
26#include <string>
27#include <vector>
28
47class VTK_MRML_EXPORT vtkMRMLColorNode : public vtkMRMLStorableNode
48{
49public:
52 void PrintSelf(ostream& os, vtkIndent indent) override;
53
54 //--------------------------------------------------------------------------
56 //--------------------------------------------------------------------------
57
59
62 void ReadXMLAttributes( const char** atts) override;
63
66 void WriteXML(ostream& of, int indent) override;
67
70 void Copy(vtkMRMLNode *node) override;
71
74 const char* GetNodeTagName() override {return "Color";};
75
79 void Reset(vtkMRMLNode* defaultNode) override;
80
83 void UpdateScene(vtkMRMLScene *scene) override;
84
87 virtual void SetType(int type);
90 vtkGetMacro(Type,int);
91
96
97 void ProcessMRMLEvents ( vtkObject *caller, unsigned long event, void *callData ) override;
98
101 virtual int GetFirstType () { return this->User; }
102 virtual int GetLastType () { return this->File; }
103
105 virtual const char * GetTypeAsString();
106
108 enum
109 {
110 TypeModifiedEvent = 20002
111 };
112
115 const char *GetColorName(int ind);
116
120 int GetColorIndexByName(const char *name);
121
132 std::string GetColorNameAsFileName(int colorIndex, const char *subst = "_");
133
138 std::string GetColorNameWithoutSpaces(int ind, const char *subst);
139
142 int SetColorName(int ind, const char *name);
143
147 int SetColorNameWithSpaces(int ind, const char *name, const char *subst);
150 virtual int GetNumberOfColors();
151
155 virtual bool GetColor(int ind, double color[4]);
156
159 vtkSetStringMacro(FileName);
160 vtkGetStringMacro(FileName);
161
165 virtual vtkLookupTable * GetLookupTable();
166
171 virtual vtkScalarsToColors* GetScalarsToColors();
172
176 vtkGetStringMacro(NoName);
177 vtkSetStringMacro(NoName);
178
181 vtkGetMacro(NamesInitialised, int);
182 vtkSetMacro(NamesInitialised, int);
183 vtkBooleanMacro(NamesInitialised, int);
187
189 bool GetModifiedSinceRead() override;
190
197 enum
198 {
199 User = 13,
200 File = 14,
201 };
202
206 virtual vtkLookupTable* CreateLookupTableCopy();
207
208protected:
213
216 virtual bool SetNameFromColor(int index);
217
222 virtual bool HasNameFromColor(int index);
223
226 int Type;
227
230 std::vector<std::string> Names;
231
234 char *FileName;
235
238 char *NoName;
239
243};
244
245#endif
Abstract MRML node to represent color information.
char * FileName
A file name to read text attributes from.
virtual vtkLookupTable * GetLookupTable()
void ProcessMRMLEvents(vtkObject *caller, unsigned long event, void *callData) override
Propagate events generated in mrml.
void ReadXMLAttributes(const char **atts) override
Set node attributes.
virtual void SetType(int type)
Set Type to type, then build colors and set names.
virtual bool GetColor(int ind, double color[4])
void WriteXML(ostream &of, int indent) override
Write this node's information to a MRML file in XML format.
int NamesInitialised
Have the color names been set? Used to do lazy copy of the Names array.
void operator=(const vtkMRMLColorNode &)
virtual vtkLookupTable * CreateLookupTableCopy()
char * NoName
the string used for an unnamed color
vtkMRMLColorNode(const vtkMRMLColorNode &)
vtkMRMLNode * CreateNodeInstance() override
MRMLNode methods.
const char * GetColorName(int ind)
std::string GetColorNameWithoutSpaces(int ind, const char *subst)
void PrintSelf(ostream &os, vtkIndent indent) override
virtual int GetNumberOfColors()
Get the number of colors in the table.
void Reset(vtkMRMLNode *defaultNode) override
virtual const char * GetTypeAsString()
return a text string describing the color look up table type
int GetColorIndexByName(const char *name)
void UpdateScene(vtkMRMLScene *scene) override
int SetColorName(int ind, const char *name)
virtual bool HasNameFromColor(int index)
virtual bool SetNameFromColor(int index)
Set values in the names vector from the colors in the node.
void Copy(vtkMRMLNode *node) override
Copy the node's attributes to this object.
std::string GetColorNameAsFileName(int colorIndex, const char *subst="_")
bool GetModifiedSinceRead() override
static vtkMRMLColorNode * New()
virtual int GetFirstType()
virtual vtkScalarsToColors * GetScalarsToColors()
~vtkMRMLColorNode() override
const char * GetNodeTagName() override
Get node XML tag name (like Volume, Model)
int SetColorNameWithSpaces(int ind, const char *name, const char *subst)
void SetNamesFromColors()
Set values in the names vector from the colors in the node.
std::vector< std::string > Names
A vector of names for the color table elements.
virtual int GetLastType()
Abstract Superclass for all specific types of MRML nodes.
A set of MRML Nodes that supports serialization and undo/redo.
MRML node to represent a 3D surface model.