Slicer 5.8
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 vtkVolume;
20class vtkVolumeProperty;
21
22// STD includes
23#include <string>
24#include <vector>
25
28class VTK_SLICER_VOLUMERENDERING_MODULE_MRML_EXPORT vtkMRMLVolumePropertyNode
29 : public vtkMRMLStorableNode
30{
31public:
32 enum
33 {
35 EffectiveRangeModified = 62300
36 };
37
41 void PrintSelf(ostream& os, vtkIndent indent) override;
42
45 vtkGetObjectMacro(VolumeProperty, vtkVolumeProperty);
46
50 void SetScalarOpacity(vtkPiecewiseFunction* newScalarOpacity, int component = 0);
54 vtkPiecewiseFunction* GetScalarOpacity(int component = 0);
55
59 void SetGradientOpacity(vtkPiecewiseFunction* newGradientOpacity, int component = 0);
63 vtkPiecewiseFunction* GetGradientOpacity(int component = 0);
64
68 void SetColor(vtkColorTransferFunction* newColorFunction, int component = 0);
72 vtkColorTransferFunction* GetColor(int component = 0);
73
80 static std::string GetPiecewiseFunctionString(vtkPiecewiseFunction* function);
81
88 static std::string GetColorTransferFunctionString(vtkColorTransferFunction* function);
89
94 static void GetPiecewiseFunctionFromString(const std::string& str,
95 vtkPiecewiseFunction* result);
96
101 static void GetColorTransferFunctionFromString(const std::string& str,
102 vtkColorTransferFunction* result);
103
108 static inline void GetPiecewiseFunctionFromString(const char *str,
109 vtkPiecewiseFunction* result);
110
116 static inline void GetColorTransferFunctionFromString(const char *str,
117 vtkColorTransferFunction* result);
118
122 static double NextHigher(double value);
127 static double HigherAndUnique(double value, double & previousValue);
128
130 void SetEffectiveRange(double min, double max);
131 void SetEffectiveRange(double range[2]);
133 vtkGetVector2Macro(EffectiveRange, double);
134
138
139 //--------------------------------------------------------------------------
141 //--------------------------------------------------------------------------
143
145 void ReadXMLAttributes( const char** atts) override;
146
148 void WriteXML(ostream& of, int indent) override;
149
153
157
159 const char* GetNodeTagName() override {return "VolumeProperty";}
160
162 void ProcessMRMLEvents ( vtkObject *caller, unsigned long event, void *callData) override;
163
166
172 void SetPropertyInVolumeNode(vtkVolume* volume);
173
174protected:
177
178 static int NodesFromString(const std::string& dataString, double* &data, int nodeSize);
179 static int DataFromString(const std::string& dataString, double* &data);
180 static std::string DataToString(double* data, int size);
181
182 // Getter and setter functions for the storable attributes
183 // (protected because only the XML read/write methods need to use these)
186 int GetShade();
187 void SetShade(int);
188 double GetDiffuse();
189 void SetDiffuse(double);
190 double GetAmbient();
191 void SetAmbient(double);
192 double GetSpecular();
193 void SetSpecular(double);
195 void SetSpecularPower(double);
197 void SetScalarOpacityAsString(std::string);
199 void SetGradientOpacityAsString(std::string);
202
203protected:
205 vtkSmartPointer<vtkIntArray> ObservedEvents;
206
210 bool IgnoreVolumePropertyChanges{false};
211
213 vtkVolumeProperty* VolumeProperty{nullptr};
214
218 double EffectiveRange[2]{0.0,-1.0};
219
220private:
223 void operator=(const vtkMRMLVolumePropertyNode&) = delete;
224
225};
226
227//---------------------------------------------------------------------------
228void vtkMRMLVolumePropertyNode
229::GetPiecewiseFunctionFromString(const char *str,
230 vtkPiecewiseFunction* result)
231{
233 std::string(str), result);
234}
235
236//---------------------------------------------------------------------------
237void vtkMRMLVolumePropertyNode
238::GetColorTransferFunctionFromString(const char *str,
239 vtkColorTransferFunction* result)
240{
242 std::string (str), result);
243}
244
245#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...
~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)
vtkSmartPointer< vtkIntArray > ObservedEvents
Events observed on the transfer functions.
void SetPropertyInVolumeNode(vtkVolume *volume)
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)