VTK  9.1.0
vtkImagePlaneWidget.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkImagePlaneWidget.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
114#ifndef vtkImagePlaneWidget_h
115#define vtkImagePlaneWidget_h
116
117#include "vtkInteractionWidgetsModule.h" // For export macro
119
120class vtkActor;
122class vtkDataSetMapper;
123class vtkImageData;
125class vtkImageReslice;
126class vtkLookupTable;
127class vtkMatrix4x4;
128class vtkPlaneSource;
129class vtkPoints;
130class vtkPolyData;
131class vtkProperty;
132class vtkTextActor;
133class vtkTextProperty;
134class vtkTexture;
135class vtkTransform;
136
137#define VTK_NEAREST_RESLICE 0
138#define VTK_LINEAR_RESLICE 1
139#define VTK_CUBIC_RESLICE 2
140
141// Private.
142#define VTK_IMAGE_PLANE_WIDGET_MAX_TEXTBUFF 128
143
144class VTKINTERACTIONWIDGETS_EXPORT vtkImagePlaneWidget : public vtkPolyDataSourceWidget
145{
146public:
151
153 void PrintSelf(ostream& os, vtkIndent indent) override;
154
156
159 void SetEnabled(int) override;
160 void PlaceWidget(double bounds[6]) override;
161 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
163 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
164 {
165 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
166 }
168
173
175
178 void SetOrigin(double x, double y, double z);
179 void SetOrigin(double xyz[3]);
181 void GetOrigin(double xyz[3]);
183
185
188 void SetPoint1(double x, double y, double z);
189 void SetPoint1(double xyz[3]);
190 double* GetPoint1() VTK_SIZEHINT(3);
191 void GetPoint1(double xyz[3]);
193
195
198 void SetPoint2(double x, double y, double z);
199 void SetPoint2(double xyz[3]);
200 double* GetPoint2() VTK_SIZEHINT(3);
201 void GetPoint2(double xyz[3]);
203
205
208 double* GetCenter() VTK_SIZEHINT(3);
209 void GetCenter(double xyz[3]);
211
213
216 double* GetNormal() VTK_SIZEHINT(3);
217 void GetNormal(double xyz[3]);
219
223 void GetVector1(double v1[3]);
224
228 void GetVector2(double v2[3]);
229
233 int GetSliceIndex();
234
238 void SetSliceIndex(int index);
239
243 double GetSlicePosition();
244
248 void SetSlicePosition(double position);
249
251
254 void SetResliceInterpolate(int);
255 vtkGetMacro(ResliceInterpolate, int);
256 void SetResliceInterpolateToNearestNeighbour()
257 {
258 this->SetResliceInterpolate(VTK_NEAREST_RESLICE);
259 }
260 void SetResliceInterpolateToLinear() { this->SetResliceInterpolate(VTK_LINEAR_RESLICE); }
261 void SetResliceInterpolateToCubic() { this->SetResliceInterpolate(VTK_CUBIC_RESLICE); }
263
268
270
274 vtkSetMacro(RestrictPlaneToVolume, vtkTypeBool);
275 vtkGetMacro(RestrictPlaneToVolume, vtkTypeBool);
276 vtkBooleanMacro(RestrictPlaneToVolume, vtkTypeBool);
278
280
285 vtkSetMacro(UserControlledLookupTable, vtkTypeBool);
286 vtkGetMacro(UserControlledLookupTable, vtkTypeBool);
287 vtkBooleanMacro(UserControlledLookupTable, vtkTypeBool);
289
291
297 vtkSetMacro(TextureInterpolate, vtkTypeBool);
298 vtkGetMacro(TextureInterpolate, vtkTypeBool);
299 vtkBooleanMacro(TextureInterpolate, vtkTypeBool);
301
303
308 vtkGetMacro(TextureVisibility, vtkTypeBool);
309 vtkBooleanMacro(TextureVisibility, vtkTypeBool);
311
321
329
334 void UpdatePlacement(void) override;
335
341
343
349 vtkGetObjectMacro(ColorMap, vtkImageMapToColors);
352
354
359 vtkGetObjectMacro(PlaneProperty, vtkProperty);
361 vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
363
365
370 vtkGetMacro(PlaneOrientation, int);
371 void SetPlaneOrientationToXAxes() { this->SetPlaneOrientation(0); }
372 void SetPlaneOrientationToYAxes() { this->SetPlaneOrientation(1); }
373 void SetPlaneOrientationToZAxes() { this->SetPlaneOrientation(2); }
375
383
385
393 vtkGetObjectMacro(LookupTable, vtkLookupTable);
395
397
401 vtkSetMacro(DisplayText, vtkTypeBool);
402 vtkGetMacro(DisplayText, vtkTypeBool);
403 vtkBooleanMacro(DisplayText, vtkTypeBool);
405
407
411 vtkGetObjectMacro(CursorProperty, vtkProperty);
413
415
419 vtkGetObjectMacro(MarginProperty, vtkProperty);
421
423
427 vtkSetClampMacro(MarginSizeX, double, 0.0, 0.5);
428 vtkGetMacro(MarginSizeX, double);
429 vtkSetClampMacro(MarginSizeY, double, 0.0, 0.5);
430 vtkGetMacro(MarginSizeY, double);
432
434
440
442
446 vtkGetObjectMacro(TexturePlaneProperty, vtkProperty);
448
450
456 void SetWindowLevel(double window, double level, int copy = 0);
457 void GetWindowLevel(double wl[2]);
458 double GetWindow() { return this->CurrentWindow; }
459 double GetLevel() { return this->CurrentLevel; }
461
466 int GetCursorData(double xyzv[4]);
467
474
476
480 vtkGetVectorMacro(CurrentCursorPosition, double, 3);
482
484
489 vtkGetMacro(CurrentImageValue, double);
491
493
496 vtkGetObjectMacro(ResliceAxes, vtkMatrix4x4);
497 vtkGetObjectMacro(Reslice, vtkImageReslice);
499
501
508 vtkSetMacro(UseContinuousCursor, vtkTypeBool);
509 vtkGetMacro(UseContinuousCursor, vtkTypeBool);
510 vtkBooleanMacro(UseContinuousCursor, vtkTypeBool);
512
514
518 vtkGetMacro(Interaction, vtkTypeBool);
519 vtkBooleanMacro(Interaction, vtkTypeBool);
521
523
526 enum
527 {
528 VTK_CURSOR_ACTION = 0,
529 VTK_SLICE_MOTION_ACTION = 1,
530 VTK_WINDOW_LEVEL_ACTION = 2
531 };
532 vtkSetClampMacro(LeftButtonAction, int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
533 vtkGetMacro(LeftButtonAction, int);
534 vtkSetClampMacro(MiddleButtonAction, int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
535 vtkGetMacro(MiddleButtonAction, int);
536 vtkSetClampMacro(RightButtonAction, int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
537 vtkGetMacro(RightButtonAction, int);
539
541
549 enum
550 {
551 VTK_NO_MODIFIER = 0,
552 VTK_SHIFT_MODIFIER = 1,
553 VTK_CONTROL_MODIFIER = 2
554 };
555 vtkSetClampMacro(LeftButtonAutoModifier, int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
556 vtkGetMacro(LeftButtonAutoModifier, int);
557 vtkSetClampMacro(MiddleButtonAutoModifier, int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
558 vtkGetMacro(MiddleButtonAutoModifier, int);
559 vtkSetClampMacro(RightButtonAutoModifier, int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
560 vtkGetMacro(RightButtonAutoModifier, int);
562
563protected:
566
568
572
576
577 enum
578 {
579 VTK_NO_BUTTON = 0,
580 VTK_LEFT_BUTTON = 1,
581 VTK_MIDDLE_BUTTON = 2,
582 VTK_RIGHT_BUTTON = 3
583 };
585
586 // Manage the state of the widget
587 int State;
589 {
590 Start = 0,
598 Outside
599 };
600
601 // Handles the events
602 static void ProcessEvents(
603 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
604
605 // internal utility method that adds observers to the RenderWindowInteractor
606 // so that our ProcessEvents is eventually called. this method is called
607 // by SetEnabled as well as SetInteraction
609
610 // ProcessEvents() dispatches to these methods.
611 virtual void OnMouseMove();
612 virtual void OnLeftButtonDown();
613 virtual void OnLeftButtonUp();
614 virtual void OnMiddleButtonDown();
615 virtual void OnMiddleButtonUp();
616 virtual void OnRightButtonDown();
617 virtual void OnRightButtonUp();
618 void OnChar() override;
619
620 virtual void StartCursor();
621 virtual void StopCursor();
622 virtual void StartSliceMotion();
623 virtual void StopSliceMotion();
624 virtual void StartWindowLevel();
625 virtual void StopWindowLevel();
626
627 // controlling ivars
628 vtkTypeBool Interaction; // Is the widget responsive to mouse events
643
644 // The geometric representation of the plane and it's outline
648 void HighlightPlane(int highlight);
650
651 // Re-builds the plane outline based on the plane source
653
654 // Do the picking
656
657 // Register internal Pickers within PickingManager
658 void RegisterPickers() override;
659
660 // for negative window values.
662
663 // Methods to manipulate the plane
664 void WindowLevel(int X, int Y);
665 void Push(double* p1, double* p2);
666 void Spin(double* p1, double* p2);
667 void Rotate(double* p1, double* p2, double* vpn);
668 void Scale(double* p1, double* p2, int X, int Y);
669 void Translate(double* p1, double* p2);
670
680
681 // Properties used to control the appearance of selected objects and
682 // the manipulator in general. The plane property is actually that for
683 // the outline. The TexturePlaneProperty can be used to control the
684 // lighting etc. of the resliced image data.
691
692 // Reslice and texture management
695
696 // The cross-hair cursor
699 double CurrentCursorPosition[3];
700 double CurrentImageValue; // Set to VTK_DOUBLE_MAX when invalid
702 void UpdateCursor(int, int);
703 void ActivateCursor(int);
705 int UpdateDiscreteCursor(double* q);
707
708 // The text to display W/L, image data
713 void ActivateText(int);
714
715 // Oblique reslice control
716 double RotateAxis[3];
717 double RadiusVector[3];
719
720 // Visible margins to assist user interaction
729
730private:
732 void operator=(const vtkImagePlaneWidget&) = delete;
733};
734
735#endif
virtual void PlaceWidget()
This method is used to initially place the widget.
abstract API for pickers that can pick an instance of vtkProp
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:46
Proxy object to connect input/output ports.
map vtkDataSet and derived classes to graphics primitives
topologically and geometrically regular array of data
Definition: vtkImageData.h:48
map the input image through a lookup table
3D widget for reslicing image data
void SetPicker(vtkAbstractPropPicker *)
Set the internal picker to one defined by the user.
virtual void StartSliceMotion()
vtkPolyData * MarginPolyData
virtual void StartWindowLevel()
void GetPolyData(vtkPolyData *pd)
Grab the polydata (including points) that defines the plane.
vtkProperty * SelectedPlaneProperty
void SetPlaneOrientationToZAxes()
Convenience method sets the plane orientation normal to the x, y, or z axes.
double * GetOrigin()
Set/Get the origin of the plane.
void PlaceWidget() override
Methods that satisfy the superclass' API.
void WindowLevel(int X, int Y)
vtkAbstractPropPicker * PlanePicker
vtkProperty * TexturePlaneProperty
void SetPlaneOrientation(int)
Convenience method sets the plane orientation normal to the x, y, or z axes.
vtkPlaneSource * PlaneSource
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkTypeBool RestrictPlaneToVolume
void Rotate(double *p1, double *p2, double *vpn)
void Push(double *p1, double *p2)
virtual void SetSelectedPlaneProperty(vtkProperty *)
Set/Get the plane's outline properties.
vtkLookupTable * LookupTable
double GetWindow()
Set/Get the current window and level values.
void ActivateCursor(int)
virtual void SetCursorProperty(vtkProperty *)
Set the properties of the cross-hair cursor.
virtual void StopWindowLevel()
virtual void StartCursor()
virtual void OnMiddleButtonUp()
virtual void SetMarginProperty(vtkProperty *)
Set the properties of the margins.
~vtkImagePlaneWidget() override
void SetOrigin(double x, double y, double z)
Set/Get the origin of the plane.
static vtkImagePlaneWidget * New()
Instantiate the object.
virtual void StopSliceMotion()
double GetLevel()
Set/Get the current window and level values.
void SetPlaneOrientationToYAxes()
Convenience method sets the plane orientation normal to the x, y, or z axes.
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
Methods that satisfy the superclass' API.
vtkProperty * MarginProperty
virtual void SetTextureVisibility(vtkTypeBool)
Control the visibility of the actual texture mapped reformatted plane.
virtual void SetTexturePlaneProperty(vtkProperty *)
Set/Get the property for the resliced image.
void Translate(double *p1, double *p2)
void SetResliceInterpolateToCubic()
Set the interpolation to use when texturing the plane.
virtual void OnMouseMove()
vtkTexture * GetTexture()
Convenience method to get the texture used by this widget.
void CreateDefaultProperties()
void HighlightPlane(int highlight)
void SetResliceInterpolateToLinear()
Set the interpolation to use when texturing the plane.
vtkPolyDataAlgorithm * GetPolyDataAlgorithm() override
Satisfies superclass API.
void SetInputConnection(vtkAlgorithmOutput *aout) override
Set the vtkImageData* input for the vtkImageReslice.
int UpdateContinuousCursor(double *q)
void SetWindowLevel(double window, double level, int copy=0)
Set/Get the current window and level values.
int GetCursorData(double xyzv[4])
Get the image coordinate position and voxel value.
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
virtual void SetLookupTable(vtkLookupTable *)
Set/Get the internal lookuptable (lut) to one defined by the user, or, alternatively,...
void SetEnabled(int) override
Methods that satisfy the superclass' API.
vtkTypeBool UserControlledLookupTable
void SetOrigin(double xyz[3])
Set/Get the origin of the plane.
vtkMatrix4x4 * ResliceAxes
void Spin(double *p1, double *p2)
vtkImageData * GetResliceOutput()
Convenience method to get the vtkImageReslice output.
void ActivateMargins(int)
vtkTextProperty * GetTextProperty()
Set/Get the text property for the image data and window-level annotation.
vtkProperty * CursorProperty
int UpdateDiscreteCursor(double *q)
virtual void OnMiddleButtonDown()
void GetWindowLevel(double wl[2])
Set/Get the current window and level values.
void SetTextProperty(vtkTextProperty *tprop)
Set/Get the text property for the image data and window-level annotation.
virtual void OnRightButtonUp()
virtual void SetPlaneProperty(vtkProperty *)
Set/Get the plane's outline properties.
int GetCursorDataStatus()
Get the status of the cursor data.
void PlaceWidget(double bounds[6]) override
Methods that satisfy the superclass' API.
virtual void StopCursor()
virtual void OnLeftButtonUp()
vtkImageMapToColors * ColorMap
vtkImageReslice * Reslice
vtkLookupTable * CreateDefaultLookupTable()
vtkPolyData * CursorPolyData
void UpdateCursor(int, int)
void SetInteraction(vtkTypeBool interact)
Enable/disable mouse interaction so the widget remains on display.
virtual void SetColorMap(vtkImageMapToColors *)
Convenience method to get the vtkImageMapToColors filter used by this widget.
virtual void OnLeftButtonDown()
void UpdatePlacement(void) override
Satisfies superclass API.
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
virtual void OnRightButtonDown()
vtkPolyData * PlaneOutlinePolyData
void SetPlaneOrientationToXAxes()
Convenience method sets the plane orientation normal to the x, y, or z axes.
void OnChar() override
Sets up the keypress-i event.
void ActivateText(int)
void Scale(double *p1, double *p2, int X, int Y)
Reslices a volume along a new set of axes.
a simple class to control print indentation
Definition: vtkIndent.h:34
map scalar values into colors via a lookup table
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:36
abstract base class for most VTK objects
Definition: vtkObject.h:63
create an array of quadrilaterals located in a plane
represent and manipulate 3D points
Definition: vtkPoints.h:34
Superclass for algorithms that produce only polydata as output.
abstract PolyDataSource-based 3D widget
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:86
represent surface properties of a geometric object
Definition: vtkProperty.h:62
An actor that displays text.
Definition: vtkTextActor.h:51
represent text properties.
handles properties associated with a texture map
Definition: vtkTexture.h:66
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:55
@ level
Definition: vtkX3D.h:401
@ position
Definition: vtkX3D.h:267
@ index
Definition: vtkX3D.h:252
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_LINEAR_RESLICE
#define VTK_CUBIC_RESLICE
#define VTK_IMAGE_PLANE_WIDGET_MAX_TEXTBUFF
#define VTK_NEAREST_RESLICE
#define VTK_SIZEHINT(...)