Slicer  4.11
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 
203 protected:
205  ~vtkMRMLColorNode() override;
207  void operator=(const vtkMRMLColorNode&);
208 
211  virtual bool SetNameFromColor(int index);
212 
217  virtual bool HasNameFromColor(int index);
218 
221  int Type;
222 
225  std::vector<std::string> Names;
226 
229  char *FileName;
230 
233  char *NoName;
234 
238 };
239 
240 #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.
void Copy(vtkMRMLNode *node) override
Copy the node&#39;s attributes to this object
const char * GetNodeTagName() override
Get node XML tag name (like Volume, Model)
MRML node to represent a 3D surface model.
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:56
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:139
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