VTK  9.6.1
vtkImagePlaneWidget.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
101
102#ifndef vtkImagePlaneWidget_h
103#define vtkImagePlaneWidget_h
104
105#include "vtkInteractionWidgetsModule.h" // For export macro
107
108VTK_ABI_NAMESPACE_BEGIN
109class vtkActor;
111class vtkDataSetMapper;
112class vtkImageData;
114class vtkImageReslice;
115class vtkLookupTable;
116class vtkMatrix4x4;
117class vtkPlaneSource;
118class vtkPoints;
119class vtkPolyData;
120class vtkProperty;
121class vtkTextActor;
122class vtkTextProperty;
123class vtkTexture;
124class vtkTransform;
125
126#define VTK_NEAREST_RESLICE 0
127#define VTK_LINEAR_RESLICE 1
128#define VTK_CUBIC_RESLICE 2
129
130// Private.
131#define VTK_IMAGE_PLANE_WIDGET_MAX_TEXTBUFF 128
132
133class VTKINTERACTIONWIDGETS_EXPORT vtkImagePlaneWidget : public vtkPolyDataSourceWidget
134{
135public:
140
142 void PrintSelf(ostream& os, vtkIndent indent) override;
143
145
148 void SetEnabled(int) override;
149 void PlaceWidget(double bounds[6]) override;
150 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
152 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
153 {
154 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
155 }
156
157
162
164
167 void SetOrigin(double x, double y, double z);
168 void SetOrigin(double xyz[3]);
170 void GetOrigin(double xyz[3]);
172
174
177 void SetPoint1(double x, double y, double z);
178 void SetPoint1(double xyz[3]);
180 void GetPoint1(double xyz[3]);
182
184
187 void SetPoint2(double x, double y, double z);
188 void SetPoint2(double xyz[3]);
190 void GetPoint2(double xyz[3]);
192
194
198 void GetCenter(double xyz[3]);
200
202
206 void GetNormal(double xyz[3]);
208
212 void GetVector1(double v1[3]);
213
217 void GetVector2(double v2[3]);
218
223
227 void SetSliceIndex(int index);
228
233
237 void SetSlicePosition(double position);
238
240
244 vtkGetMacro(ResliceInterpolate, int);
252
257
259
267
269
278
280
290
292
300
310
318
323 void UpdatePlacement() override;
324
330
332
338 vtkGetObjectMacro(ColorMap, vtkImageMapToColors);
341
343
348 vtkGetObjectMacro(PlaneProperty, vtkProperty);
352
354
359 vtkGetMacro(PlaneOrientation, int);
364
372
374
382 vtkGetObjectMacro(LookupTable, vtkLookupTable);
384
386
392 vtkBooleanMacro(DisplayText, vtkTypeBool);
394
396
400 vtkGetObjectMacro(CursorProperty, vtkProperty);
402
404
408 vtkGetObjectMacro(MarginProperty, vtkProperty);
410
412
416 vtkSetClampMacro(MarginSizeX, double, 0.0, 0.5);
417 vtkGetMacro(MarginSizeX, double);
418 vtkSetClampMacro(MarginSizeY, double, 0.0, 0.5);
419 vtkGetMacro(MarginSizeY, double);
421
423
429
431
437
439
445 void SetWindowLevel(double window, double level, int copy = 0);
446 void GetWindowLevel(double wl[2]);
447 double GetWindow() { return this->CurrentWindow; }
448 double GetLevel() { return this->CurrentLevel; }
450
455 int GetCursorData(double xyzv[4]);
456
463
465
469 vtkGetVectorMacro(CurrentCursorPosition, double, 3);
471
473
478 vtkGetMacro(CurrentImageValue, double);
480
482
485 vtkGetObjectMacro(ResliceAxes, vtkMatrix4x4);
486 vtkGetObjectMacro(Reslice, vtkImageReslice);
488
490
501
503
508 vtkBooleanMacro(Interaction, vtkTypeBool);
510
512
515 enum
516 {
520 };
522 vtkGetMacro(LeftButtonAction, int);
524 vtkGetMacro(MiddleButtonAction, int);
526 vtkGetMacro(RightButtonAction, int);
528
530
538 enum
539 {
543 };
545 vtkGetMacro(LeftButtonAutoModifier, int);
547 vtkGetMacro(MiddleButtonAutoModifier, int);
549 vtkGetMacro(RightButtonAutoModifier, int);
551
552protected:
555
557
561
565
566 enum
567 {
572 };
574
575 // Manage the state of the widget
576 int State;
589
590 // Handles the events
591 static void ProcessEvents(
592 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
593
594 // internal utility method that adds observers to the RenderWindowInteractor
595 // so that our ProcessEvents is eventually called. this method is called
596 // by SetEnabled as well as SetInteraction
598
599 // ProcessEvents() dispatches to these methods.
600 virtual void OnMouseMove();
601 virtual void OnLeftButtonDown();
602 virtual void OnLeftButtonUp();
603 virtual void OnMiddleButtonDown();
604 virtual void OnMiddleButtonUp();
605 virtual void OnRightButtonDown();
606 virtual void OnRightButtonUp();
607 void OnChar() override;
608
609 virtual void StartCursor();
610 virtual void StopCursor();
611 virtual void StartSliceMotion();
612 virtual void StopSliceMotion();
613 virtual void StartWindowLevel();
614 virtual void StopWindowLevel();
615
616 // controlling ivars
617 vtkTypeBool Interaction; // Is the widget responsive to mouse events
632
633 // The geometric representation of the plane and it's outline
637 void HighlightPlane(int highlight);
639
640 // Re-builds the plane outline based on the plane source
642
643 // Do the picking
645
646 // Register internal Pickers within PickingManager
647 void RegisterPickers() override;
648
649 // for negative window values.
651
652 // Methods to manipulate the plane
653 void WindowLevel(int X, int Y);
654 void Push(double* p1, double* p2);
655 void Spin(double* p1, double* p2);
656 void Rotate(double* p1, double* p2, double* vpn);
657 void Scale(double* p1, double* p2, int X, int Y);
658 void Translate(double* p1, double* p2);
659
669
670 // Properties used to control the appearance of selected objects and
671 // the manipulator in general. The plane property is actually that for
672 // the outline. The TexturePlaneProperty can be used to control the
673 // lighting etc. of the resliced image data.
680
681 // Reslice and texture management
684
685 // The cross-hair cursor
689 double CurrentImageValue; // Set to VTK_DOUBLE_MAX when invalid
691 void UpdateCursor(int, int);
692 void ActivateCursor(int);
694 int UpdateDiscreteCursor(double* q);
696
697 // The text to display W/L, image data
702 void ActivateText(int);
703
704 // Oblique reslice control
705 double RotateAxis[3];
706 double RadiusVector[3];
708
709 // Visible margins to assist user interaction
718
719private:
721 void operator=(const vtkImagePlaneWidget&) = delete;
722};
723
724VTK_ABI_NAMESPACE_END
725#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:42
Proxy object to connect input/output ports.
map vtkDataSet and derived classes to graphics primitives
topologically and geometrically regular array of data
map the input image through a lookup table
void SetPicker(vtkAbstractPropPicker *)
Set the internal picker to one defined by the user.
virtual void StartSliceMotion()
virtual void StartWindowLevel()
void GetPolyData(vtkPolyData *pd)
Grab the polydata (including points) that defines the plane.
double * GetPoint1()
Set/Get the position of the point defining the first axis of the plane.
void GetVector1(double v1[3])
Get the vector from the plane origin to point1.
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)
void SetSlicePosition(double position)
Set the position of the slice along its normal.
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.
void SetResliceInterpolate(int)
Set the interpolation to use when texturing the plane.
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.
double * GetPoint2()
Set/Get the position of the point defining the second axis of the plane.
~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.
void SetPoint1(double x, double y, double z)
Set/Get the position of the point defining the first axis of the plane.
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()
int GetSliceIndex()
Get the slice position in terms of the data extent.
vtkTexture * GetTexture()
Convenience method to get the texture used by this widget.
double * GetNormal()
Get the normal to the plane.
void CreateDefaultProperties()
void HighlightPlane(int highlight)
void SetResliceInterpolateToNearestNeighbour()
Set the interpolation to use when texturing the plane.
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)
void UpdatePlacement() override
Satisfies superclass API.
virtual void SetLookupTable(vtkLookupTable *)
Set/Get the internal lookuptable (lut) to one defined by the user, or, alternatively,...
void SetPoint2(double x, double y, double z)
Set/Get the position of the point defining the second axis of the plane.
void SetEnabled(int) override
Methods that satisfy the superclass' API.
vtkTypeBool UserControlledLookupTable
double GetSlicePosition()
Get the position of the slice along its normal.
void SetOrigin(double xyz[3])
Set/Get the origin of the plane.
void Spin(double *p1, double *p2)
vtkImageData * GetResliceOutput()
Convenience method to get the vtkImageReslice output.
void ActivateMargins(int)
void GetVector2(double v2[3])
Get the vector from the plane origin to point2.
vtkTextProperty * GetTextProperty()
Set/Get the text property for the image data and window-level annotation.
char TextBuff[VTK_IMAGE_PLANE_WIDGET_MAX_TEXTBUFF]
void SetSliceIndex(int index)
Set the slice position in terms of the data extent.
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()
void UpdateCursor(int, int)
void SetInteraction(vtkTypeBool interact)
Enable/disable mouse interaction so the widget remains on display.
double * GetCenter()
Get the center of the plane.
virtual void SetColorMap(vtkImageMapToColors *)
Convenience method to get the vtkImageMapToColors filter used by this widget.
virtual void OnLeftButtonDown()
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:29
map scalar values into colors via a lookup table
represent and manipulate 4x4 transformation matrices
abstract base class for most VTK objects
Definition vtkObject.h:53
create an array of quadrilaterals located in a plane
represent and manipulate 3D points
Definition vtkPoints.h:30
vtkPolyDataSourceWidget()
Empty constructor that calls the parent constructor.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:72
represent surface properties of a geometric object
Definition vtkProperty.h:60
An actor that displays text.
represent text properties.
handles properties associated with a texture map
Definition vtkTexture.h:59
describes linear transformations via a 4x4 matrix
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_LINEAR_RESLICE
#define VTK_CUBIC_RESLICE
#define VTK_IMAGE_PLANE_WIDGET_MAX_TEXTBUFF
#define VTK_NEAREST_RESLICE
#define VTK_SIZEHINT(...)
#define vtkPolyDataAlgorithm