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
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 }
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]);
179 double* GetPoint1() VTK_SIZEHINT(3);
180 void GetPoint1(double xyz[3]);
182
184
187 void SetPoint2(double x, double y, double z);
188 void SetPoint2(double xyz[3]);
189 double* GetPoint2() VTK_SIZEHINT(3);
190 void GetPoint2(double xyz[3]);
192
194
197 double* GetCenter() VTK_SIZEHINT(3);
198 void GetCenter(double xyz[3]);
200
202
205 double* GetNormal() VTK_SIZEHINT(3);
206 void GetNormal(double xyz[3]);
208
212 void GetVector1(double v1[3]);
213
217 void GetVector2(double v2[3]);
218
222 int GetSliceIndex();
223
227 void SetSliceIndex(int index);
228
232 double GetSlicePosition();
233
237 void SetSlicePosition(double position);
238
240
243 void SetResliceInterpolate(int);
244 vtkGetMacro(ResliceInterpolate, int);
245 void SetResliceInterpolateToNearestNeighbour()
246 {
247 this->SetResliceInterpolate(VTK_NEAREST_RESLICE);
248 }
249 void SetResliceInterpolateToLinear() { this->SetResliceInterpolate(VTK_LINEAR_RESLICE); }
250 void SetResliceInterpolateToCubic() { this->SetResliceInterpolate(VTK_CUBIC_RESLICE); }
252
257
259
263 vtkSetMacro(RestrictPlaneToVolume, vtkTypeBool);
264 vtkGetMacro(RestrictPlaneToVolume, vtkTypeBool);
265 vtkBooleanMacro(RestrictPlaneToVolume, vtkTypeBool);
267
269
274 vtkSetMacro(UserControlledLookupTable, vtkTypeBool);
275 vtkGetMacro(UserControlledLookupTable, vtkTypeBool);
276 vtkBooleanMacro(UserControlledLookupTable, vtkTypeBool);
278
280
286 vtkSetMacro(TextureInterpolate, vtkTypeBool);
287 vtkGetMacro(TextureInterpolate, vtkTypeBool);
288 vtkBooleanMacro(TextureInterpolate, vtkTypeBool);
290
292
297 vtkGetMacro(TextureVisibility, vtkTypeBool);
298 vtkBooleanMacro(TextureVisibility, vtkTypeBool);
300
310
318
323 void UpdatePlacement() override;
324
330
332
338 vtkGetObjectMacro(ColorMap, vtkImageMapToColors);
341
343
348 vtkGetObjectMacro(PlaneProperty, vtkProperty);
350 vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
352
354
359 vtkGetMacro(PlaneOrientation, int);
360 void SetPlaneOrientationToXAxes() { this->SetPlaneOrientation(0); }
361 void SetPlaneOrientationToYAxes() { this->SetPlaneOrientation(1); }
362 void SetPlaneOrientationToZAxes() { this->SetPlaneOrientation(2); }
364
372
374
382 vtkGetObjectMacro(LookupTable, vtkLookupTable);
384
386
390 vtkSetMacro(DisplayText, vtkTypeBool);
391 vtkGetMacro(DisplayText, vtkTypeBool);
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
435 vtkGetObjectMacro(TexturePlaneProperty, vtkProperty);
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
497 vtkSetMacro(UseContinuousCursor, vtkTypeBool);
498 vtkGetMacro(UseContinuousCursor, vtkTypeBool);
499 vtkBooleanMacro(UseContinuousCursor, vtkTypeBool);
501
503
507 vtkGetMacro(Interaction, vtkTypeBool);
508 vtkBooleanMacro(Interaction, vtkTypeBool);
510
512
515 enum
516 {
517 VTK_CURSOR_ACTION = 0,
518 VTK_SLICE_MOTION_ACTION = 1,
519 VTK_WINDOW_LEVEL_ACTION = 2
520 };
521 vtkSetClampMacro(LeftButtonAction, int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
522 vtkGetMacro(LeftButtonAction, int);
523 vtkSetClampMacro(MiddleButtonAction, int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
524 vtkGetMacro(MiddleButtonAction, int);
525 vtkSetClampMacro(RightButtonAction, int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
526 vtkGetMacro(RightButtonAction, int);
528
530
538 enum
539 {
540 VTK_NO_MODIFIER = 0,
541 VTK_SHIFT_MODIFIER = 1,
542 VTK_CONTROL_MODIFIER = 2
543 };
544 vtkSetClampMacro(LeftButtonAutoModifier, int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
545 vtkGetMacro(LeftButtonAutoModifier, int);
546 vtkSetClampMacro(MiddleButtonAutoModifier, int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
547 vtkGetMacro(MiddleButtonAutoModifier, int);
548 vtkSetClampMacro(RightButtonAutoModifier, int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
549 vtkGetMacro(RightButtonAutoModifier, int);
551
552protected:
555
557
561
565
566 enum
567 {
568 VTK_NO_BUTTON = 0,
569 VTK_LEFT_BUTTON = 1,
570 VTK_MIDDLE_BUTTON = 2,
571 VTK_RIGHT_BUTTON = 3
572 };
574
575 // Manage the state of the widget
576 int State;
578 {
579 Start = 0,
587 Outside
588 };
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
688 double CurrentCursorPosition[3];
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
Definition: vtkImageData.h:47
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)
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 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 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
Definition: vtkMatrix4x4.h:32
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
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:72
represent surface properties of a geometric object
Definition: vtkProperty.h:61
An actor that displays text.
Definition: vtkTextActor.h:47
represent text properties.
handles properties associated with a texture map
Definition: vtkTexture.h:59
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:51
@ level
Definition: vtkX3D.h:395
@ position
Definition: vtkX3D.h:261
@ index
Definition: vtkX3D.h:246
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(...)