Slicer  4.8
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) VTK_OVERRIDE;
53 
54  //--------------------------------------------------------------------------
56  //--------------------------------------------------------------------------
57 
58  virtual vtkMRMLNode* CreateNodeInstance() VTK_OVERRIDE;
59 
62  virtual void ReadXMLAttributes( const char** atts) VTK_OVERRIDE;
63 
66  virtual void WriteXML(ostream& of, int indent) VTK_OVERRIDE;
67 
70  virtual void Copy(vtkMRMLNode *node) VTK_OVERRIDE;
71 
74  virtual const char* GetNodeTagName() VTK_OVERRIDE {return "Color";};
75 
79  virtual void Reset(vtkMRMLNode* defaultNode) VTK_OVERRIDE;
80 
83  virtual void UpdateScene(vtkMRMLScene *scene) VTK_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 ) VTK_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  virtual bool GetModifiedSinceRead() VTK_OVERRIDE;
190 
197  enum
198  {
199  User = 13,
200  File = 14,
201  };
202 
203 protected:
205  virtual ~vtkMRMLColorNode();
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...
virtual bool GetModifiedSinceRead()
virtual int GetFirstType()
virtual void ProcessMRMLEvents(vtkObject *, unsigned long, void *) VTK_OVERRIDE
alternative method to propagate events generated in Storage nodes
virtual vtkMRMLNode * CreateNodeInstance() VTK_OVERRIDE=0
MRMLNode methods.
MRML node to represent a 3D surface model.
A set of MRML Nodes that supports serialization and undo/redo.
Definition: vtkMRMLScene.h:54
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 PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
virtual int GetLastType()
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:135
std::vector< std::string > Names
A vector of names for the color table elements.
virtual void UpdateScene(vtkMRMLScene *scene) VTK_OVERRIDE
Finds the storage node and read the data.
void operator=(const vtkMRMLStorableNode &)