Slicer  4.11
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkMRMLVolumePropertyNode.h
Go to the documentation of this file.
1 
6 #ifndef __vtkMRMLVolumePropertyNode_h
7 #define __vtkMRMLVolumePropertyNode_h
8 
9 // VolumeRendering includes
10 #include "vtkSlicerVolumeRenderingModuleMRMLExport.h"
11 
12 // MRML includes
13 #include "vtkMRMLStorableNode.h"
14 
15 // VTK includes
16 class vtkColorTransferFunction;
17 class vtkIntArray;
18 class vtkPiecewiseFunction;
19 class vtkVolumeProperty;
20 
21 // STD includes
22 #include <string>
23 #include <vector>
24 
27 class VTK_SLICER_VOLUMERENDERING_MODULE_MRML_EXPORT vtkMRMLVolumePropertyNode
28  : public vtkMRMLStorableNode
29 {
30 public:
31  enum
32  {
34  EffectiveRangeModified = 62300
35  };
36 
38  static vtkMRMLVolumePropertyNode *New();
40  void PrintSelf(ostream& os, vtkIndent indent) override;
41 
44  vtkGetObjectMacro(VolumeProperty, vtkVolumeProperty);
45 
49  void SetScalarOpacity(vtkPiecewiseFunction* newScalarOpacity, int component = 0);
53  vtkPiecewiseFunction* GetScalarOpacity(int component = 0);
54 
58  void SetGradientOpacity(vtkPiecewiseFunction* newGradientOpacity, int component = 0);
62  vtkPiecewiseFunction* GetGradientOpacity(int component = 0);
63 
67  void SetColor(vtkColorTransferFunction* newColorFunction, int component = 0);
71  vtkColorTransferFunction* GetColor(int component = 0);
72 
79  static std::string GetPiecewiseFunctionString(vtkPiecewiseFunction* function);
80 
87  static std::string GetColorTransferFunctionString(vtkColorTransferFunction* function);
88 
93  static void GetPiecewiseFunctionFromString(const std::string& str,
94  vtkPiecewiseFunction* result);
95 
100  static void GetColorTransferFunctionFromString(const std::string& str,
101  vtkColorTransferFunction* result);
102 
107  static inline void GetPiecewiseFunctionFromString(const char *str,
108  vtkPiecewiseFunction* result);
109 
115  static inline void GetColorTransferFunctionFromString(const char *str,
116  vtkColorTransferFunction* result);
117 
121  static double NextHigher(double value);
126  static double HigherAndUnique(double value, double & previousValue);
127 
129  void SetEffectiveRange(double min, double max);
130  void SetEffectiveRange(double range[2]);
132  vtkGetVector2Macro(EffectiveRange, double);
133 
136  bool CalculateEffectiveRange();
137 
138  //--------------------------------------------------------------------------
140  //--------------------------------------------------------------------------
141  vtkMRMLNode* CreateNodeInstance() override;
142 
144  void ReadXMLAttributes( const char** atts) override;
145 
147  void WriteXML(ostream& of, int indent) override;
148 
150  void Copy(vtkMRMLNode *node) override;
151 
154  void CopyParameterSet(vtkMRMLNode *node);
155 
157  const char* GetNodeTagName() override {return "VolumeProperty";}
158 
160  void ProcessMRMLEvents ( vtkObject *caller, unsigned long event, void *callData) override;
161 
164 
166  bool GetModifiedSinceRead() override;
167 
168 protected:
170  ~vtkMRMLVolumePropertyNode(void) override;
171 
172  static int NodesFromString(const std::string& dataString, double* &data, int nodeSize);
173  static int DataFromString(const std::string& dataString, double* &data);
174  static std::string DataToString(double* data, int size);
175 
176  // Getter and setter functions for the storable attributes
177  // (protected because only the XML read/write methods need to use these)
178  int GetInterpolationType();
179  void SetInterpolationType(int);
180  int GetShade();
181  void SetShade(int);
182  double GetDiffuse();
183  void SetDiffuse(double);
184  double GetAmbient();
185  void SetAmbient(double);
186  double GetSpecular();
187  void SetSpecular(double);
188  double GetSpecularPower();
189  void SetSpecularPower(double);
190  std::string GetScalarOpacityAsString();
191  void SetScalarOpacityAsString(std::string);
192  std::string GetGradientOpacityAsString();
193  void SetGradientOpacityAsString(std::string);
194  std::string GetRGBTransferFunctionAsString();
195  void SetRGBTransferFunctionAsString(std::string);
196 
197 protected:
199  vtkIntArray* ObservedEvents;
200 
202  vtkVolumeProperty* VolumeProperty;
203 
207  double EffectiveRange[2];
208 
211 
212 private:
215  void operator=(const vtkMRMLVolumePropertyNode&) = delete;
216 
217 };
218 
219 //---------------------------------------------------------------------------
222  vtkPiecewiseFunction* result)
223 {
225  std::string(str), result);
226 }
227 
228 //---------------------------------------------------------------------------
231  vtkColorTransferFunction* result)
232 {
234  std::string (str), result);
235 }
236 
237 #endif
virtual vtkMRMLStorageNode * CreateDefaultStorageNode()
const char * GetNodeTagName() override
Get node XML tag name (like Volume, Model)
void ReadXMLAttributes(const char **atts) override
Read node attributes from XML file
virtual bool GetModifiedSinceRead()
vtkVolumeProperty * VolumeProperty
Main parameters for visualization.
vtkMRMLNode * CreateNodeInstance() override=0
MRMLNode methods.
void Copy(vtkMRMLNode *node) override
Copy the node&#39;s attributes to this object
MRML node to represent a 3D surface model.
vtkIntArray * ObservedEvents
Events observed on the transfer functions.
A superclass for other storage nodes.
void ProcessMRMLEvents(vtkObject *, unsigned long, void *) override
alternative method to propagate events generated in Storage nodes
static void GetPiecewiseFunctionFromString(const std::string &str, vtkPiecewiseFunction *result)
static void GetColorTransferFunctionFromString(const std::string &str, vtkColorTransferFunction *result)
Abstract Superclass for all specific types of MRML nodes.
Definition: vtkMRMLNode.h:139
void operator=(const vtkMRMLStorableNode &)
vtkMRMLVolumePropertyNode contains the transfer functions (scalar opacity, color and gradient opacity...
int DisabledModify
Keep track of state of disable modified events.
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