VTK  9.5.2
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
117
118#ifndef vtkImagePlaneWidget_h
119#define vtkImagePlaneWidget_h
120
121#include "vtkInteractionWidgetsModule.h" // For export macro
123
124VTK_ABI_NAMESPACE_BEGIN
125class vtkActor;
127class vtkDataSetMapper;
128class vtkImageData;
130class vtkImageReslice;
131class vtkLookupTable;
132class vtkMatrix4x4;
133class vtkPlaneSource;
134class vtkPoints;
135class vtkPolyData;
136class vtkProperty;
137class vtkTextActor;
138class vtkTextProperty;
139class vtkTexture;
140class vtkTransform;
141
142#define VTK_NEAREST_RESLICE 0
143#define VTK_LINEAR_RESLICE 1
144#define VTK_CUBIC_RESLICE 2
145
146// Private.
147#define VTK_IMAGE_PLANE_WIDGET_MAX_TEXTBUFF 128
148
149class VTKINTERACTIONWIDGETS_EXPORT vtkImagePlaneWidget : public vtkPolyDataSourceWidget
150{
151public:
156
158 void PrintSelf(ostream& os, vtkIndent indent) override;
159
161
164 void SetEnabled(int) override;
165 void PlaceWidget(double bounds[6]) override;
166 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
168 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
169 {
170 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
171 }
172
173
178
180
183 void SetOrigin(double x, double y, double z);
184 void SetOrigin(double xyz[3]);
186 void GetOrigin(double xyz[3]);
188
190
193 void SetPoint1(double x, double y, double z);
194 void SetPoint1(double xyz[3]);
196 void GetPoint1(double xyz[3]);
198
200
203 void SetPoint2(double x, double y, double z);
204 void SetPoint2(double xyz[3]);
206 void GetPoint2(double xyz[3]);
208
210
214 void GetCenter(double xyz[3]);
216
218
222 void GetNormal(double xyz[3]);
224
228 void GetVector1(double v1[3]);
229
233 void GetVector2(double v2[3]);
234
239
243 void SetSliceIndex(int index);
244
249
253 void SetSlicePosition(double position);
254
256
260 vtkGetMacro(ResliceInterpolate, int);
268
273
275
283
285
294
296
306
308
316
326
334
339 void UpdatePlacement() override;
340
346
348
354 vtkGetObjectMacro(ColorMap, vtkImageMapToColors);
357
359
364 vtkGetObjectMacro(PlaneProperty, vtkProperty);
368
370
375 vtkGetMacro(PlaneOrientation, int);
380
388
390
398 vtkGetObjectMacro(LookupTable, vtkLookupTable);
400
402
408 vtkBooleanMacro(DisplayText, vtkTypeBool);
410
412
416 vtkGetObjectMacro(CursorProperty, vtkProperty);
418
420
424 vtkGetObjectMacro(MarginProperty, vtkProperty);
426
428
432 vtkSetClampMacro(MarginSizeX, double, 0.0, 0.5);
433 vtkGetMacro(MarginSizeX, double);
434 vtkSetClampMacro(MarginSizeY, double, 0.0, 0.5);
435 vtkGetMacro(MarginSizeY, double);
437
439
445
447
453
455
461 void SetWindowLevel(double window, double level, int copy = 0);
462 void GetWindowLevel(double wl[2]);
463 double GetWindow() { return this->CurrentWindow; }
464 double GetLevel() { return this->CurrentLevel; }
466
471 int GetCursorData(double xyzv[4]);
472
479
481
485 vtkGetVectorMacro(CurrentCursorPosition, double, 3);
487
489
494 vtkGetMacro(CurrentImageValue, double);
496
498
501 vtkGetObjectMacro(ResliceAxes, vtkMatrix4x4);
502 vtkGetObjectMacro(Reslice, vtkImageReslice);
504
506
517
519
524 vtkBooleanMacro(Interaction, vtkTypeBool);
526
528
531 enum
532 {
536 };
538 vtkGetMacro(LeftButtonAction, int);
540 vtkGetMacro(MiddleButtonAction, int);
542 vtkGetMacro(RightButtonAction, int);
544
546
554 enum
555 {
559 };
561 vtkGetMacro(LeftButtonAutoModifier, int);
563 vtkGetMacro(MiddleButtonAutoModifier, int);
565 vtkGetMacro(RightButtonAutoModifier, int);
567
568protected:
571
573
577
581
582 enum
583 {
588 };
590
591 // Manage the state of the widget
592 int State;
605
606 // Handles the events
607 static void ProcessEvents(
608 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
609
610 // internal utility method that adds observers to the RenderWindowInteractor
611 // so that our ProcessEvents is eventually called. this method is called
612 // by SetEnabled as well as SetInteraction
614
615 // ProcessEvents() dispatches to these methods.
616 virtual void OnMouseMove();
617 virtual void OnLeftButtonDown();
618 virtual void OnLeftButtonUp();
619 virtual void OnMiddleButtonDown();
620 virtual void OnMiddleButtonUp();
621 virtual void OnRightButtonDown();
622 virtual void OnRightButtonUp();
623 void OnChar() override;
624
625 virtual void StartCursor();
626 virtual void StopCursor();
627 virtual void StartSliceMotion();
628 virtual void StopSliceMotion();
629 virtual void StartWindowLevel();
630 virtual void StopWindowLevel();
631
632 // controlling ivars
633 vtkTypeBool Interaction; // Is the widget responsive to mouse events
648
649 // The geometric representation of the plane and it's outline
653 void HighlightPlane(int highlight);
655
656 // Re-builds the plane outline based on the plane source
658
659 // Do the picking
661
662 // Register internal Pickers within PickingManager
663 void RegisterPickers() override;
664
665 // for negative window values.
667
668 // Methods to manipulate the plane
669 void WindowLevel(int X, int Y);
670 void Push(double* p1, double* p2);
671 void Spin(double* p1, double* p2);
672 void Rotate(double* p1, double* p2, double* vpn);
673 void Scale(double* p1, double* p2, int X, int Y);
674 void Translate(double* p1, double* p2);
675
685
686 // Properties used to control the appearance of selected objects and
687 // the manipulator in general. The plane property is actually that for
688 // the outline. The TexturePlaneProperty can be used to control the
689 // lighting etc. of the resliced image data.
696
697 // Reslice and texture management
700
701 // The cross-hair cursor
705 double CurrentImageValue; // Set to VTK_DOUBLE_MAX when invalid
707 void UpdateCursor(int, int);
708 void ActivateCursor(int);
710 int UpdateDiscreteCursor(double* q);
712
713 // The text to display W/L, image data
718 void ActivateText(int);
719
720 // Oblique reslice control
721 double RotateAxis[3];
722 double RadiusVector[3];
724
725 // Visible margins to assist user interaction
734
735private:
737 void operator=(const vtkImagePlaneWidget&) = delete;
738};
739
740VTK_ABI_NAMESPACE_END
741#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:151
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:108
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:159
create an array of quadrilaterals located in a plane
represent and manipulate 3D points
Definition vtkPoints.h:139
vtkPolyDataSourceWidget()
Empty constructor that calls the parent constructor.
concrete dataset represents vertices, lines, polygons, and triangle strips
represent surface properties of a geometric object
An actor that displays text.
represent text properties.
handles properties associated with a texture map
Definition vtkTexture.h:168
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 vtkPolyDataAlgorithm
#define VTK_SIZEHINT(...)