forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtkResliceCursorRepresentation.h
339 lines (293 loc) · 9.41 KB
/
vtkResliceCursorRepresentation.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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
/*=========================================================================
Program: Visualization Toolkit
Module: vtkResliceCursorRepresentation.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/**
* @class vtkResliceCursorRepresentation
* @brief represent the vtkResliceCursorWidget
*
* This class is the base class for the reslice cursor representation
* subclasses. It represents a cursor that may be interactively translated,
* rotated through an image and perform thick / thick reformats.
* @sa
* vtkResliceCursorLineRepresentation vtkResliceCursorThickLineRepresentation
* vtkResliceCursorWidget vtkResliceCursor
*/
#ifndef vtkResliceCursorRepresentation_h
#define vtkResliceCursorRepresentation_h
#include "vtkInteractionWidgetsModule.h" // For export macro
#include "vtkWidgetRepresentation.h"
class vtkTextProperty;
class vtkActor2D;
class vtkTextMapper;
class vtkImageData;
class vtkImageReslice;
class vtkPlane;
class vtkPlaneSource;
class vtkResliceCursorPolyDataAlgorithm;
class vtkResliceCursor;
class vtkMatrix4x4;
class vtkScalarsToColors;
class vtkImageMapToColors;
class vtkActor;
class vtkImageActor;
class vtkTexture;
class vtkTextActor;
class vtkImageAlgorithm;
class VTKINTERACTIONWIDGETS_EXPORT vtkResliceCursorRepresentation : public vtkWidgetRepresentation
{
public:
//@{
/**
* Standard VTK methods.
*/
vtkTypeMacro(vtkResliceCursorRepresentation,vtkWidgetRepresentation);
void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
//@}
//@{
/**
* The tolerance representing the distance to the representation (in
* pixels) in which the cursor is considered near enough to the
* representation to be active.
*/
vtkSetClampMacro(Tolerance,int,1,100);
vtkGetMacro(Tolerance,int);
//@}
//@{
/**
* Show the resliced image ?
*/
vtkSetMacro( ShowReslicedImage, int );
vtkGetMacro( ShowReslicedImage, int );
vtkBooleanMacro( ShowReslicedImage, int );
//@}
//@{
/**
* Make sure that the resliced image remains within the volume.
* Default is On.
*/
vtkSetMacro(RestrictPlaneToVolume,int);
vtkGetMacro(RestrictPlaneToVolume,int);
vtkBooleanMacro(RestrictPlaneToVolume,int);
//@}
//@{
/**
* Specify the format to use for labelling the distance. Note that an empty
* string results in no label, or a format string without a "%" character
* will not print the thickness value.
*/
vtkSetStringMacro(ThicknessLabelFormat);
vtkGetStringMacro(ThicknessLabelFormat);
//@}
// Used to communicate about the state of the representation
enum { Outside=0, NearCenter, NearAxis1, NearAxis2,
OnCenter, OnAxis1, OnAxis2};
enum { None=0, PanAndRotate, RotateBothAxes,
ResizeThickness, WindowLevelling };
/**
* Get the text shown in the widget's label.
*/
virtual char* GetThicknessLabelText();
//@{
/**
* Get the position of the widget's label in display coordinates.
*/
virtual double* GetThicknessLabelPosition();
virtual void GetThicknessLabelPosition(double pos[3]);
virtual void GetWorldThicknessLabelPosition(double pos[3]);
//@}
/**
* These are methods that satisfy vtkWidgetRepresentation's API.
*/
void BuildRepresentation() VTK_OVERRIDE;
//@{
/**
* Get the current reslice class and reslice axes
*/
vtkGetObjectMacro( ResliceAxes, vtkMatrix4x4 );
vtkGetObjectMacro( Reslice, vtkImageAlgorithm );
//@}
//@{
/**
* Get the displayed image actor
*/
vtkGetObjectMacro( ImageActor, vtkImageActor );
//@}
//@{
/**
* Set/Get the internal lookuptable (lut) to one defined by the user, or,
* alternatively, to the lut of another Reslice cusror widget. In this way,
* a set of three orthogonal planes can share the same lut so that
* window-levelling is performed uniformly among planes. The default
* internal lut can be re- set/allocated by setting to 0 (NULL).
*/
virtual void SetLookupTable(vtkScalarsToColors*);
vtkGetObjectMacro(LookupTable,vtkScalarsToColors);
//@}
//@{
/**
* Convenience method to get the vtkImageMapToColors filter used by this
* widget. The user can properly render other transparent actors in a
* scene by calling the filter's SetOutputFormatToRGB and
* PassAlphaToOutputOff.
*/
vtkGetObjectMacro(ColorMap, vtkImageMapToColors);
virtual void SetColorMap(vtkImageMapToColors *);
//@}
//@{
/**
* Set/Get the current window and level values. SetWindowLevel should
* only be called after SetInput. If a shared lookup table is being used,
* a callback is required to update the window level values without having
* to update the lookup table again.
*/
void SetWindowLevel(double window, double level, int copy = 0);
void GetWindowLevel(double wl[2]);
double GetWindow(){return this->CurrentWindow;}
double GetLevel(){return this->CurrentLevel;}
//@}
virtual vtkResliceCursor * GetResliceCursor() = 0;
//@{
/**
* Enable/disable text display of window-level, image coordinates and
* scalar values in a render window.
*/
vtkSetMacro(DisplayText,int);
vtkGetMacro(DisplayText,int);
vtkBooleanMacro(DisplayText,int);
//@}
//@{
/**
* Set/Get the text property for the image data and window-level annotation.
*/
void SetTextProperty(vtkTextProperty* tprop);
vtkTextProperty* GetTextProperty();
//@}
//@{
/**
* Render as a 2D image, or render as a plane with a texture in physical
* space.
*/
vtkSetMacro( UseImageActor, int );
vtkGetMacro( UseImageActor, int );
vtkBooleanMacro( UseImageActor, int );
//@}
//@{
/**
* INTERNAL - Do not use
* Set the manipulation mode. This is done by the widget
*/
void SetManipulationMode( int m );
vtkGetMacro(ManipulationMode, int);
//@}
//@{
/**
* INTERNAL - Do not use.
* Internal methods used by the widget to manage text displays
* for annotations.
*/
void ActivateText(int);
void ManageTextDisplay();
//@}
//@{
/**
* Initialize the reslice planes and the camera center. This is done
* automatically, the first time we render.
*/
virtual void InitializeReslicePlane();
virtual void ResetCamera();
//@}
/**
* Get the underlying cursor source.
*/
virtual vtkResliceCursorPolyDataAlgorithm * GetCursorAlgorithm() = 0;
//@{
/**
* Get the plane source on which the texture (the thin/thick resliced
* image is displayed)
*/
vtkGetObjectMacro( PlaneSource, vtkPlaneSource );
//@}
protected:
vtkResliceCursorRepresentation();
~vtkResliceCursorRepresentation() VTK_OVERRIDE;
//@{
/**
* Create New Reslice plane. Allows subclasses to override and crate
* their own reslice filters to respond to the widget.
*/
virtual void CreateDefaultResliceAlgorithm();
virtual void SetResliceParameters(
double outputSpacingX, double outputSpacingY,
int extentX, int extentY );
//@}
/**
* Process window level
*/
virtual void WindowLevel( double x, double y );
/**
* Update the reslice plane
*/
virtual void UpdateReslicePlane();
/**
* Compute the origin of the planes so as to capture the entire image.
*/
virtual void ComputeReslicePlaneOrigin();
// for negative window values.
void InvertTable();
// recompute origin to make the location of the reslice cursor consistent
// with its physical location
virtual void ComputeOrigin( vtkMatrix4x4 * );
//@{
void GetVector1( double d[3] );
void GetVector2( double d[3] );
//@}
/**
* The widget sets the manipulation mode. This can be one of :
* None, PanAndRotate, RotateBothAxes, ResizeThickness
*/
int ManipulationMode;
// Keep track if modifier is set
int Modifier;
// Selection tolerance for the handles
int Tolerance;
// Format for printing the distance
char *ThicknessLabelFormat;
vtkImageAlgorithm * Reslice;
vtkPlaneSource * PlaneSource;
int RestrictPlaneToVolume;
int ShowReslicedImage;
vtkTextProperty * ThicknessTextProperty;
vtkTextMapper * ThicknessTextMapper;
vtkActor2D * ThicknessTextActor;
vtkMatrix4x4 * ResliceAxes;
vtkMatrix4x4 * NewResliceAxes;
vtkImageMapToColors * ColorMap;
vtkActor * TexturePlaneActor;
vtkTexture * Texture;
vtkScalarsToColors * LookupTable;
vtkImageActor * ImageActor;
vtkTextActor * TextActor;
double OriginalWindow;
double OriginalLevel;
double CurrentWindow;
double CurrentLevel;
double InitialWindow;
double InitialLevel;
double LastEventPosition[2];
int UseImageActor;
char TextBuff[128];
int DisplayText;
vtkScalarsToColors * CreateDefaultLookupTable();
void GenerateText();
private:
vtkResliceCursorRepresentation(const vtkResliceCursorRepresentation&) VTK_DELETE_FUNCTION;
void operator=(const vtkResliceCursorRepresentation&) VTK_DELETE_FUNCTION;
};
#endif