Slicer 5.4
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
vtkMRMLVolumePropertyNode.h
Go to the documentation of this file.
1
5
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
16class vtkColorTransferFunction;
17class vtkIntArray;
18class vtkPiecewiseFunction;
19class vtkVolumeProperty;
20
21// STD includes
22#include <string>
23#include <vector>
24
27class VTK_SLICER_VOLUMERENDERING_MODULE_MRML_EXPORT vtkMRMLVolumePropertyNode
28 : public vtkMRMLStorableNode
29{
30public:
31 enum
32 {
34 EffectiveRangeModified = 62300
35 };
36
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
137
138 //--------------------------------------------------------------------------
140 //--------------------------------------------------------------------------
142
144 void ReadXMLAttributes( const char** atts) override;
145
147 void WriteXML(ostream& of, int indent) override;
148
152
156
158 const char* GetNodeTagName() override {return "VolumeProperty";}
159
161 void ProcessMRMLEvents ( vtkObject *caller, unsigned long event, void *callData) override;
162
165
167 bool GetModifiedSinceRead() override;
168
169protected:
172
173 static int NodesFromString(const std::string& dataString, double* &data, int nodeSize);
174 static int DataFromString(const std::string& dataString, double* &data);
175 static std::string DataToString(double* data, int size);
176
177 // Getter and setter functions for the storable attributes
178 // (protected because only the XML read/write methods need to use these)
181 int GetShade();
182 void SetShade(int);
183 double GetDiffuse();
184 void SetDiffuse(double);
185 double GetAmbient();
186 void SetAmbient(double);
187 double GetSpecular();
188 void SetSpecular(double);
190 void SetSpecularPower(double);
192 void SetScalarOpacityAsString(std::string);
194 void SetGradientOpacityAsString(std::string);
197
198protected:
200 vtkIntArray* ObservedEvents;
201
203 vtkVolumeProperty* VolumeProperty{nullptr};
204
208 double EffectiveRange[2]{0.0,-1.0};
209
211 int DisabledModify{0};
212
213private:
216 void operator=(const vtkMRMLVolumePropertyNode&) = delete;
217
218};
219
220//---------------------------------------------------------------------------
221void vtkMRMLVolumePropertyNode
222::GetPiecewiseFunctionFromString(const char *str,
223 vtkPiecewiseFunction* result)
224{
226 std::string(str), result);
227}
228
229//---------------------------------------------------------------------------
230void vtkMRMLVolumePropertyNode
231::GetColorTransferFunctionFromString(const char *str,
232 vtkColorTransferFunction* result)
233{
235 std::string (str), result);
236}
237
238#endif
Abstract Superclass for all specific types of MRML nodes.
MRML node to represent a 3D surface model.
A superclass for other storage nodes.
vtkMRMLVolumePropertyNode contains the transfer functions (scalar opacity, color and gradient opacity...
bool GetModifiedSinceRead() override
~vtkMRMLVolumePropertyNode() override
void SetRGBTransferFunctionAsString(std::string)
void SetGradientOpacity(vtkPiecewiseFunction *newGradientOpacity, int component=0)
static double HigherAndUnique(double value, double &previousValue)
static double NextHigher(double value)
vtkMRMLCopyContentMacro(vtkMRMLVolumePropertyNode)
vtkIntArray * ObservedEvents
Events observed on the transfer functions.
vtkMRMLStorageNode * CreateDefaultStorageNode() override
Create default storage node or nullptr if does not have one.
vtkColorTransferFunction * GetColor(int component=0)
void SetScalarOpacityAsString(std::string)
void ProcessMRMLEvents(vtkObject *caller, unsigned long event, void *callData) override
Reimplemented for internal reasons.
static std::string GetPiecewiseFunctionString(vtkPiecewiseFunction *function)
void WriteXML(ostream &of, int indent) override
Write this node's information to a MRML file in XML format.
static void GetPiecewiseFunctionFromString(const std::string &str, vtkPiecewiseFunction *result)
static int DataFromString(const std::string &dataString, double *&data)
static std::string GetColorTransferFunctionString(vtkColorTransferFunction *function)
std::string GetRGBTransferFunctionAsString()
void SetGradientOpacityAsString(std::string)
void SetEffectiveRange(double range[2])
void SetEffectiveRange(double min, double max)
Set effective range.
static vtkMRMLVolumePropertyNode * New()
Create a new vtkMRMLVolumePropertyNode.
static int NodesFromString(const std::string &dataString, double *&data, int nodeSize)
void CopyParameterSet(vtkMRMLNode *node)
std::string GetScalarOpacityAsString()
void SetScalarOpacity(vtkPiecewiseFunction *newScalarOpacity, int component=0)
void SetColor(vtkColorTransferFunction *newColorFunction, int component=0)
std::string GetGradientOpacityAsString()
vtkPiecewiseFunction * GetGradientOpacity(int component=0)
void ReadXMLAttributes(const char **atts) override
Set node attributes.
vtkPiecewiseFunction * GetScalarOpacity(int component=0)
void SetSpecularPower(double)
void PrintSelf(ostream &os, vtkIndent indent) override
static std::string DataToString(double *data, int size)
vtkMRMLNode * CreateNodeInstance() override
MRMLNode methods.
const char * GetNodeTagName() override
Get node XML tag name (like Volume, Model)
static void GetColorTransferFunctionFromString(const std::string &str, vtkColorTransferFunction *result)