Slicer 5.9
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 : public vtkMRMLStorableNode
29{
30public:
31 enum
32 {
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, vtkPiecewiseFunction* result);
94
99 static void GetColorTransferFunctionFromString(const std::string& str, vtkColorTransferFunction* result);
100
105 static inline void GetPiecewiseFunctionFromString(const char* str, vtkPiecewiseFunction* result);
106
112 static inline void GetColorTransferFunctionFromString(const char* str, vtkColorTransferFunction* result);
113
117 static double NextHigher(double value);
122 static double HigherAndUnique(double value, double& previousValue);
123
125 void SetEffectiveRange(double min, double max);
126 void SetEffectiveRange(double range[2]);
128 vtkGetVector2Macro(EffectiveRange, double);
129
133
134 //--------------------------------------------------------------------------
136 //--------------------------------------------------------------------------
138
140 void ReadXMLAttributes(const char** atts) override;
141
143 void WriteXML(ostream& of, int indent) override;
144
148
152
154 const char* GetNodeTagName() override { return "VolumeProperty"; }
155
157 void ProcessMRMLEvents(vtkObject* caller, unsigned long event, void* callData) override;
158
161
167 void SetPropertyInVolumeNode(vtkVolume* volume);
168
171 vtkSetClampMacro(NumberOfIndependentComponents, int, 1, VTK_MAX_VRCOMP);
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 // Setter functions for the storable attributes
183 // (protected because only the XML read method needs to use these)
185 void SetShade(int);
186 void SetDiffuse(double);
187 void SetAmbient(double);
188 void SetSpecular(double);
189 void SetSpecularPower(double);
190 void SetScalarOpacityAsString(std::string);
191 void SetGradientOpacityAsString(std::string);
193
194protected:
196 vtkSmartPointer<vtkIntArray> ObservedEvents;
197
202
204 vtkVolumeProperty* VolumeProperty{ nullptr };
205
209 double EffectiveRange[2]{ 0.0, -1.0 };
210
213
214private:
217 void operator=(const vtkMRMLVolumePropertyNode&) = delete;
218};
219
220//---------------------------------------------------------------------------
221void vtkMRMLVolumePropertyNode::GetPiecewiseFunctionFromString(const char* str, vtkPiecewiseFunction* result)
222{
224}
225
226//---------------------------------------------------------------------------
227void vtkMRMLVolumePropertyNode::GetColorTransferFunctionFromString(const char* str, vtkColorTransferFunction* result)
228{
230}
231
232#endif
void operator=(const vtkMRMLStorableNode &)
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)
void SetGradientOpacityAsString(std::string)
vtkVolumeProperty * VolumeProperty
Main parameters for visualization.
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)
void SetScalarOpacity(vtkPiecewiseFunction *newScalarOpacity, int component=0)
void SetColor(vtkColorTransferFunction *newColorFunction, int component=0)
vtkPiecewiseFunction * GetGradientOpacity(int component=0)
void ReadXMLAttributes(const char **atts) override
Set node attributes.
int NumberOfIndependentComponents
The number of independent components that will be displayed on the GUI or written to json.
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)