Slicer  4.13
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
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
22 class vtkLookupTable;
23 class vtkScalarsToColors;
24 
25 // Std includes
26 #include <string>
27 #include <vector>
28 
47 class VTK_MRML_EXPORT vtkMRMLColorNode : public vtkMRMLStorableNode
48 {
49 public:
50  static vtkMRMLColorNode *New();
52  void PrintSelf(ostream& os, vtkIndent indent) override;
53 
54  //--------------------------------------------------------------------------
56  //--------------------------------------------------------------------------
57 
58  vtkMRMLNode* CreateNodeInstance() override;
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 
94  void SetTypeToUser();
95  void SetTypeToFile();
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);
186  void SetNamesFromColors();
187 
189  bool GetModifiedSinceRead() override;
190 
197  enum
198  {
199  User = 13,
200  File = 14,
201  };
202 
206  virtual vtkLookupTable* CreateLookupTableCopy();
207 
208 protected:
210  ~vtkMRMLColorNode() override;
212  void operator=(const vtkMRMLColorNode&);
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
virtual void Reset(vtkMRMLNode *defaultNode)
Reset node attributes to the initial state as defined in the constructor or the passed default node...
void ReadXMLAttributes(const char **atts) override
Read node attributes from XML file
virtual bool GetModifiedSinceRead()
virtual int GetFirstType()
vtkMRMLNode * CreateNodeInstance() override=0
MRMLNode methods.
const char * GetNodeTagName() override
Get node XML tag name (like Volume, Model)
virtual void Copy(vtkMRMLNode *node)
Copy node contents from another node of the same type. Does not copy node ID and Scene. Performs deep copy - an independent copy is created from all data, including bulk data.
MRML node to represent a 3D surface model.
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:61
char * NoName
the string used for an unnamed colour
int NamesInitialised
Have the colour names been set? Used to do lazy copy of the Names array.
char * FileName
A file name to read text attributes from
Abstract MRML node to represent color information.
void ProcessMRMLEvents(vtkObject *, unsigned long, void *) override
alternative method to propagate events generated in Storage nodes
virtual int GetLastType()
void UpdateScene(vtkMRMLScene *scene) override
Finds the storage node and read the data
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:167
std::vector< std::string > Names
A vector of names for the color table elements
void operator=(const vtkMRMLStorableNode &)
void WriteXML(ostream &of, int indent) override
Write this node&#39;s information to a MRML file in XML format.
void PrintSelf(ostream &os, vtkIndent indent) override