forked from Slicer/SlicerGitSVNArchive
-
Notifications
You must be signed in to change notification settings - Fork 2
/
vtkMRMLScalarVolumeDisplayNode.h
248 lines (197 loc) · 7.57 KB
/
vtkMRMLScalarVolumeDisplayNode.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
/*=auto=========================================================================
Portions (c) Copyright 2005 Brigham and Women's Hospital (BWH) All Rights Reserved.
See COPYRIGHT.txt
or http://www.slicer.org/copyright/copyright.txt for details.
Program: 3D Slicer
Module: $RCSfile: vtkMRMLScalarVolumeDisplayNode.h,v $
Date: $Date: 2006/03/19 17:12:29 $
Version: $Revision: 1.3 $
=========================================================================auto=*/
#ifndef __vtkMRMLScalarVolumeDisplayNode_h
#define __vtkMRMLScalarVolumeDisplayNode_h
// MRML includes
#include "vtkMRMLVolumeDisplayNode.h"
// VTK includes
class vtkImageAlgorithm;
class vtkImageAppendComponents;
class vtkImageHistogramStatistics;
class vtkImageCast;
class vtkImageLogic;
class vtkImageMapToColors;
class vtkImageMapToWindowLevelColors;
class vtkImageStencil;
class vtkImageThreshold;
class vtkImageExtractComponents;
class vtkImageMathematics;
// STD includes
#include <vector>
/// \brief MRML node for representing a volume display attributes.
///
/// vtkMRMLScalarVolumeDisplayNode nodes describe how volume is displayed.
class VTK_MRML_EXPORT vtkMRMLScalarVolumeDisplayNode : public vtkMRMLVolumeDisplayNode
{
public:
static vtkMRMLScalarVolumeDisplayNode *New();
vtkTypeMacro(vtkMRMLScalarVolumeDisplayNode,vtkMRMLVolumeDisplayNode);
void PrintSelf(ostream& os, vtkIndent indent) override;
vtkMRMLNode* CreateNodeInstance() override;
///
/// Read node attributes from XML file
void ReadXMLAttributes( const char** atts) override;
///
/// Write this node's information to a MRML file in XML format.
void WriteXML(ostream& of, int indent) override;
///
/// Copy the node's attributes to this object
void Copy(vtkMRMLNode *node) override;
///
/// Get node XML tag name (like Volume, Model)
const char* GetNodeTagName() override {return "VolumeDisplay";}
//--------------------------------------------------------------------------
/// Display Information
//--------------------------------------------------------------------------
///
/// Window/Level cannot be edited through the user interface
vtkGetMacro(WindowLevelLocked, bool);
vtkSetMacro(WindowLevelLocked, bool);
///
/// Specifies whether windowing and leveling are to be performed automatically
vtkBooleanMacro(AutoWindowLevel, int);
vtkGetMacro(AutoWindowLevel, int);
vtkSetMacro(AutoWindowLevel, int);
///
/// The window value to use when autoWindowLevel is 'no'
double GetWindow();
virtual void SetWindow(double);
///
/// The level value to use when autoWindowLevel is 'no'
double GetLevel();
virtual void SetLevel(double);
/// Sets the window and level at once, generates only 1 modified event if
/// needed.
virtual void SetWindowLevel(double window, double level);
/// Utility function that sets the window/level by passing the min and max
/// of the window.
void SetWindowLevelMinMax(double min, double max);
/// Utility function that returns the minimum value of the window level
double GetWindowLevelMin();
/// Utility function that returns the maximum value of the window level
double GetWindowLevelMax();
///
/// Specifies whether to apply the threshold
vtkBooleanMacro(ApplyThreshold, int);
vtkGetMacro(ApplyThreshold, int);
virtual void SetApplyThreshold(int);
///
/// Specifies whether the threshold should be set automatically
vtkBooleanMacro(AutoThreshold, int);
vtkGetMacro(AutoThreshold, int);
vtkSetMacro(AutoThreshold, int);
///
/// The lower threshold value to use when autoThreshold is 'no'
/// Defaults to VTK_SHORT_MIN
virtual double GetLowerThreshold();
virtual void SetLowerThreshold(double lower);
///
/// The upper threshold value to use when autoThreshold is 'no'
/// Defaults to VTK_SHORT_MAX
virtual double GetUpperThreshold();
virtual void SetUpperThreshold(double upper);
virtual void SetThreshold(double lower, double upper);
///
/// Set/Get interpolate reformated slices
vtkGetMacro(Interpolate, int);
vtkSetMacro(Interpolate, int);
vtkBooleanMacro(Interpolate, int);
void SetDefaultColorMap() override;
///
/// alternative method to propagate events generated in Display nodes
void ProcessMRMLEvents ( vtkObject * /*caller*/,
unsigned long /*event*/,
void * /*callData*/ ) override;
/// Set the pipeline input
void SetInputImageDataConnection(vtkAlgorithmOutput *imageDataConnection) override;
/// Gets the pipeline input
vtkAlgorithmOutput* GetInputImageDataConnection() override;
/// Gets the pipeline output
vtkAlgorithmOutput* GetOutputImageDataConnection() override;
///
/// Get/set background mask stencil
void SetBackgroundImageStencilDataConnection(vtkAlgorithmOutput *imageDataConnection) override;
vtkAlgorithmOutput* GetBackgroundImageStencilDataConnection() override;
///
/// Parse a string with window and level as double|double, and add a preset
void AddWindowLevelPresetFromString(const char *preset);
///
/// Add a window level preset
void AddWindowLevelPreset(double window, double level);
///
/// Remove all presets
void ResetWindowLevelPresets();
///
/// Set Window and Level from preset p
void SetWindowLevelFromPreset(int p);
///
/// Get the number of window/level presets
int GetNumberOfWindowLevelPresets();
///
/// Return a specific preset, returns 0 if p out of range
double GetWindowPreset(int p);
double GetLevelPreset(int p);
///
/// Defines the expected range of the output data after
/// having been mapped through the current display options
/// If no input is set, then it searches the scene to find the associated
/// Volume node and returns its image data scalar range.
virtual void GetDisplayScalarRange(double range[2]);
protected:
vtkMRMLScalarVolumeDisplayNode();
~vtkMRMLScalarVolumeDisplayNode() override;
vtkMRMLScalarVolumeDisplayNode(const vtkMRMLScalarVolumeDisplayNode&);
void operator=(const vtkMRMLScalarVolumeDisplayNode&);
void SetColorNodeInternal(vtkMRMLColorNode* newColorNode) override;
void UpdateLookupTable(vtkMRMLColorNode* newColorNode);
void CalculateAutoLevels();
/// Return the image data with scalar type, it can be in the middle of the
/// pipeline, it's typically the input of the threshold/windowlevel filters
vtkImageData* GetScalarImageData();
virtual vtkAlgorithmOutput* GetScalarImageDataConnection();
void SetInputToImageDataPipeline(vtkAlgorithmOutput *imageDataConnection) override;
///
/// To hold preset values for window and level, so can restore this display
/// node's window and level to ones read from DICOM files, or defined by
/// users
class WindowLevelPreset
{
public:
double Window;
double Level;
WindowLevelPreset() { this->Window = 0.0; this->Level = 0.0; };
};
//double Window;
//double Level;
//double UpperThreshold;
//double LowerThreshold;
/// Booleans
int Interpolate;
bool WindowLevelLocked;
int AutoWindowLevel;
int ApplyThreshold;
int AutoThreshold;
vtkImageLogic *AlphaLogic;
vtkImageMapToColors *MapToColors;
vtkImageThreshold *Threshold;
vtkImageAppendComponents *AppendComponents;
vtkImageMapToWindowLevelColors *MapToWindowLevelColors;
vtkImageExtractComponents *ExtractRGB;
vtkImageExtractComponents *ExtractAlpha;
vtkImageStencil *MultiplyAlpha;
///
/// window level presets
std::vector<WindowLevelPreset> WindowLevelPresets;
///
/// Used internally in CalculateScalarAutoLevels and CalculateStatisticsAutoLevels
vtkImageHistogramStatistics *HistogramStatistics;
bool IsInCalculateAutoLevels;
};
#endif