Slicer 5.9
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
vtkMRMLColorTableNode.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: vtkMRMLColorTableNode.h,v $
10 Date: $Date: 2006/03/19 17:12:28 $
11 Version: $Revision: 1.0 $
12
13=========================================================================auto=*/
14
15#ifndef __vtkMRMLColorTableNode_h
16#define __vtkMRMLColorTableNode_h
17
18#include "vtkMRMLColorNode.h"
19
26class VTK_MRML_EXPORT vtkMRMLColorTableNode : public vtkMRMLColorNode
27{
28public:
31 void PrintSelf(ostream& os, vtkIndent indent) override;
32
33 //--------------------------------------------------------------------------
35 //--------------------------------------------------------------------------
36
38
41 void ReadXMLAttributes(const char** atts) override;
42
45 void WriteXML(ostream& of, int indent) override;
46
49 void Copy(vtkMRMLNode* node) override;
50
53 const char* GetNodeTagName() override { return "ColorTable"; }
54
57 vtkLookupTable* GetLookupTable() override;
58
63 virtual void SetAndObserveLookupTable(vtkLookupTable* newLookupTable, bool markAllColorsAsDefined = true);
64
68 virtual void SetLookupTable(vtkLookupTable* newLookupTable) { this->SetAndObserveLookupTable(newLookupTable, /*markAllColorsAsDefined=*/true); }
69
72 void SetType(int type) override;
73 // GetType is defined in ColorTableNode class via macro.
110
111 void ProcessMRMLEvents(vtkObject* caller, unsigned long event, void* callData) override;
112
115
143 enum
144 {
146 Grey = 1,
147 Iron = 2,
149 Ocean = 4,
153 FMRI = 8,
155 Labels = 10,
157 Random = 12,
158 Red = 15,
159 Green = 16,
160 Blue = 17,
161 Yellow = 18,
162 Cyan = 19,
164 Warm1 = 21,
165 Warm2 = 22,
166 Warm3 = 23,
167 Cool1 = 24,
168 Cool2 = 25,
169 Cool3 = 26,
182 };
183
186 int GetFirstType() override { return this->FullRainbow; };
187 int GetLastType() override { return this->CoolTint3; };
188
191 const char* GetTypeAsString() override;
192
195 void SetNumberOfColors(int n);
196
199 int GetNumberOfColors() override;
200
203 void AddColor(const char* name, double r, double g, double b, double a = 1.0);
204
207 int SetColor(int entry, const char* name, double r, double g, double b, double a = 1.0);
208
211 bool RemoveColor(int entry);
212
217 int SetColors(int firstEntry, int lastEntry, const char* name, double r, double g, double b, double a = 1.0);
218
221 bool RemoveColors(int firstEntry, int lastEntry);
222
226 int SetColor(int entry, double r, double g, double b, double a);
227 int SetColor(int entry, double r, double g, double b);
228 int SetOpacity(int entry, double opacity);
229
232 bool GetColor(int entry, double color[4]) override;
233
237
240 void Reset(vtkMRMLNode* defaultNode) override;
241
245
246protected:
251
253 bool IsValidColorIndex(int entry, const std::string& callerMethod, bool isCallerMethodSet = false);
254
257 vtkLookupTable* LookupTable;
258
261 int LastAddedColor{ -1 };
262};
263
264#endif
int LastAddedColor
keep track of where we last added a color.
~vtkMRMLColorTableNode() override
int SetColor(int entry, double r, double g, double b, double a)
vtkMRMLNode * CreateNodeInstance() override
MRMLNode methods.
virtual void SetAndObserveLookupTable(vtkLookupTable *newLookupTable, bool markAllColorsAsDefined=true)
int GetFirstType() override
Return the lowest and highest integers, for use in looping.
void ProcessMRMLEvents(vtkObject *caller, unsigned long event, void *callData) override
Propagate events generated in mrml.
bool RemoveColors(int firstEntry, int lastEntry)
void Copy(vtkMRMLNode *node) override
Copy the node's attributes to this object.
void SetNumberOfColors(int n)
Set the size of the color table if it's a User table.
bool RemoveColor(int entry)
vtkLookupTable * GetLookupTable() override
bool IsValidColorIndex(int entry, const std::string &callerMethod, bool isCallerMethodSet=false)
Log error message and return false if not a valid color index.
virtual void SetLookupTable(vtkLookupTable *newLookupTable)
vtkMRMLColorTableNode(const vtkMRMLColorTableNode &)
vtkLookupTable * LookupTable
The look up table, constructed according to the Type.
int SetOpacity(int entry, double opacity)
int SetColors(int firstEntry, int lastEntry, const char *name, double r, double g, double b, double a=1.0)
void PrintSelf(ostream &os, vtkIndent indent) override
void ClearNames()
Clear out the names list.
bool GetColor(int entry, double color[4]) override
const char * GetNodeTagName() override
Get node XML tag name (like Volume, Model)
int SetColor(int entry, const char *name, double r, double g, double b, double a=1.0)
Set a color into the User color table. Return 1 on success, 0 on failure.
vtkMRMLStorageNode * CreateDefaultStorageNode() override
Create default storage node or nullptr if does not have one.
void AddColor(const char *name, double r, double g, double b, double a=1.0)
Add a color to the User color table, at the end.
int GetNumberOfColors() override
Set the size of the color table if it's a User table.
void WriteXML(ostream &of, int indent) override
Write this node's information to a MRML file in XML format.
void Reset(vtkMRMLNode *defaultNode) override
Reset when close the scene.
int SetColor(int entry, double r, double g, double b)
static vtkMRMLColorTableNode * New()
void ReadXMLAttributes(const char **atts) override
Set node attributes.
void SetType(int type) override
Get/Set for Type.
void operator=(const vtkMRMLColorTableNode &)
const char * GetTypeAsString() override
return a text string describing the color look up table type
A superclass for other storage nodes.