VTK  9.4.20250102
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
121#ifndef vtkImagePlaneWidget_h
122#define vtkImagePlaneWidget_h
123
124#include "vtkInteractionWidgetsModule.h" // For export macro
126
127VTK_ABI_NAMESPACE_BEGIN
128class vtkActor;
130class vtkDataSetMapper;
131class vtkImageData;
133class vtkImageReslice;
134class vtkLookupTable;
135class vtkMatrix4x4;
136class vtkPlaneSource;
137class vtkPoints;
138class vtkPolyData;
139class vtkProperty;
140class vtkTextActor;
141class vtkTextProperty;
142class vtkTexture;
143class vtkTransform;
144
145#define VTK_NEAREST_RESLICE 0
146#define VTK_LINEAR_RESLICE 1
147#define VTK_CUBIC_RESLICE 2
148
149// Private.
150#define VTK_IMAGE_PLANE_WIDGET_MAX_TEXTBUFF 128
151
152class VTKINTERACTIONWIDGETS_EXPORT vtkImagePlaneWidget : public vtkPolyDataSourceWidget
153{
154public:
159
161 void PrintSelf(ostream& os, vtkIndent indent) override;
162
164
167 void SetEnabled(int) override;
168 void PlaceWidget(double bounds[6]) override;
169 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
171 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
172 {
173 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
174 }
176
181
183
186 void SetOrigin(double x, double y, double z);
187 void SetOrigin(double xyz[3]);
189 void GetOrigin(double xyz[3]);
191
193
196 void SetPoint1(double x, double y, double z);
197 void SetPoint1(double xyz[3]);
198 double* GetPoint1() VTK_SIZEHINT(3);
199 void GetPoint1(double xyz[3]);
201
203
206 void SetPoint2(double x, double y, double z);
207 void SetPoint2(double xyz[3]);
208 double* GetPoint2() VTK_SIZEHINT(3);
209 void GetPoint2(double xyz[3]);
211
213
216 double* GetCenter() VTK_SIZEHINT(3);
217 void GetCenter(double xyz[3]);
219
221
224 double* GetNormal() VTK_SIZEHINT(3);
225 void GetNormal(double xyz[3]);
227
231 void GetVector1(double v1[3]);
232
236 void GetVector2(double v2[3]);
237
241 int GetSliceIndex();
242
246 void SetSliceIndex(int index);
247
251 double GetSlicePosition();
252
256 void SetSlicePosition(double position);
257
259
262 void SetResliceInterpolate(int);
263 vtkGetMacro(ResliceInterpolate, int);
264 void SetResliceInterpolateToNearestNeighbour()
265 {
266 this->SetResliceInterpolate(VTK_NEAREST_RESLICE);
267 }
268 void SetResliceInterpolateToLinear() { this->SetResliceInterpolate(VTK_LINEAR_RESLICE); }
269 void SetResliceInterpolateToCubic() { this->SetResliceInterpolate(VTK_CUBIC_RESLICE); }
271
276
278
282 vtkSetMacro(RestrictPlaneToVolume, vtkTypeBool);
283 vtkGetMacro(RestrictPlaneToVolume, vtkTypeBool);
284 vtkBooleanMacro(RestrictPlaneToVolume, vtkTypeBool);
286
288
293 vtkSetMacro(UserControlledLookupTable, vtkTypeBool);
294 vtkGetMacro(UserControlledLookupTable, vtkTypeBool);
295 vtkBooleanMacro(UserControlledLookupTable, vtkTypeBool);
297
299
305 vtkSetMacro(TextureInterpolate, vtkTypeBool);
306 vtkGetMacro(TextureInterpolate, vtkTypeBool);
307 vtkBooleanMacro(TextureInterpolate, vtkTypeBool);
309
311
316 vtkGetMacro(TextureVisibility, vtkTypeBool);
317 vtkBooleanMacro(TextureVisibility, vtkTypeBool);
319
329
337
342 void UpdatePlacement() override;
343
349
351
357 vtkGetObjectMacro(ColorMap, vtkImageMapToColors);
360
362
367 vtkGetObjectMacro(PlaneProperty, vtkProperty);
369 vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
371
373
378 vtkGetMacro(PlaneOrientation, int);
379 void SetPlaneOrientationToXAxes() { this->SetPlaneOrientation(0); }
380 void SetPlaneOrientationToYAxes() { this->SetPlaneOrientation(1); }
381 void SetPlaneOrientationToZAxes() { this->SetPlaneOrientation(2); }
383
391
393
401 vtkGetObjectMacro(LookupTable, vtkLookupTable);
403
405
409 vtkSetMacro(DisplayText, vtkTypeBool);
410 vtkGetMacro(DisplayText, vtkTypeBool);
411 vtkBooleanMacro(DisplayText, vtkTypeBool);
413
415
419 vtkGetObjectMacro(CursorProperty, vtkProperty);
421
423
427 vtkGetObjectMacro(MarginProperty, vtkProperty);
429
431
435 vtkSetClampMacro(MarginSizeX, double, 0.0, 0.5);
436 vtkGetMacro(MarginSizeX, double);
437 vtkSetClampMacro(MarginSizeY, double, 0.0, 0.5);
438 vtkGetMacro(MarginSizeY, double);
440
442
448
450
454 vtkGetObjectMacro(TexturePlaneProperty, vtkProperty);
456
458
464 void SetWindowLevel(double window, double level, int copy = 0);
465 void GetWindowLevel(double wl[2]);
466 double GetWindow() { return this->CurrentWindow; }
467 double GetLevel() { return this->CurrentLevel; }
469
474 int GetCursorData(double xyzv[4]);
475
482
484
488 vtkGetVectorMacro(CurrentCursorPosition, double, 3);
490
492
497 vtkGetMacro(CurrentImageValue, double);
499
501
504 vtkGetObjectMacro(ResliceAxes, vtkMatrix4x4);
505 vtkGetObjectMacro(Reslice, vtkImageReslice);
507
509
516 vtkSetMacro(UseContinuousCursor, vtkTypeBool);
517 vtkGetMacro(UseContinuousCursor, vtkTypeBool);
518 vtkBooleanMacro(UseContinuousCursor, vtkTypeBool);
520
522
526 vtkGetMacro(Interaction, vtkTypeBool);
527 vtkBooleanMacro(Interaction, vtkTypeBool);
529
531
534 enum
535 {
536 VTK_CURSOR_ACTION = 0,
537 VTK_SLICE_MOTION_ACTION = 1,
538 VTK_WINDOW_LEVEL_ACTION = 2
539 };
540 vtkSetClampMacro(LeftButtonAction, int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
541 vtkGetMacro(LeftButtonAction, int);
542 vtkSetClampMacro(MiddleButtonAction, int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
543 vtkGetMacro(MiddleButtonAction, int);
544 vtkSetClampMacro(RightButtonAction, int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
545 vtkGetMacro(RightButtonAction, int);
547
549
557 enum
558 {
559 VTK_NO_MODIFIER = 0,
560 VTK_SHIFT_MODIFIER = 1,
561 VTK_CONTROL_MODIFIER = 2
562 };
563 vtkSetClampMacro(LeftButtonAutoModifier, int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
564 vtkGetMacro(LeftButtonAutoModifier, int);
565 vtkSetClampMacro(MiddleButtonAutoModifier, int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
566 vtkGetMacro(MiddleButtonAutoModifier, int);
567 vtkSetClampMacro(RightButtonAutoModifier, int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
568 vtkGetMacro(RightButtonAutoModifier, int);
570
571protected:
574
576
580
584
585 enum
586 {
587 VTK_NO_BUTTON = 0,
588 VTK_LEFT_BUTTON = 1,
589 VTK_MIDDLE_BUTTON = 2,
590 VTK_RIGHT_BUTTON = 3
591 };
593
594 // Manage the state of the widget
595 int State;
597 {
598 Start = 0,
606 Outside
607 };
608
609 // Handles the events
610 static void ProcessEvents(
611 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
612
613 // internal utility method that adds observers to the RenderWindowInteractor
614 // so that our ProcessEvents is eventually called. this method is called
615 // by SetEnabled as well as SetInteraction
617
618 // ProcessEvents() dispatches to these methods.
619 virtual void OnMouseMove();
620 virtual void OnLeftButtonDown();
621 virtual void OnLeftButtonUp();
622 virtual void OnMiddleButtonDown();
623 virtual void OnMiddleButtonUp();
624 virtual void OnRightButtonDown();
625 virtual void OnRightButtonUp();
626 void OnChar() override;
627
628 virtual void StartCursor();
629 virtual void StopCursor();
630 virtual void StartSliceMotion();
631 virtual void StopSliceMotion();
632 virtual void StartWindowLevel();
633 virtual void StopWindowLevel();
634
635 // controlling ivars
636 vtkTypeBool Interaction; // Is the widget responsive to mouse events
651
652 // The geometric representation of the plane and it's outline
656 void HighlightPlane(int highlight);
658
659 // Re-builds the plane outline based on the plane source
661
662 // Do the picking
664
665 // Register internal Pickers within PickingManager
666 void RegisterPickers() override;
667
668 // for negative window values.
670
671 // Methods to manipulate the plane
672 void WindowLevel(int X, int Y);
673 void Push(double* p1, double* p2);
674 void Spin(double* p1, double* p2);
675 void Rotate(double* p1, double* p2, double* vpn);
676 void Scale(double* p1, double* p2, int X, int Y);
677 void Translate(double* p1, double* p2);
678
688
689 // Properties used to control the appearance of selected objects and
690 // the manipulator in general. The plane property is actually that for
691 // the outline. The TexturePlaneProperty can be used to control the
692 // lighting etc. of the resliced image data.
699
700 // Reslice and texture management
703
704 // The cross-hair cursor
707 double CurrentCursorPosition[3];
708 double CurrentImageValue; // Set to VTK_DOUBLE_MAX when invalid
710 void UpdateCursor(int, int);
711 void ActivateCursor(int);
713 int UpdateDiscreteCursor(double* q);
715
716 // The text to display W/L, image data
721 void ActivateText(int);
722
723 // Oblique reslice control
724 double RotateAxis[3];
725 double RadiusVector[3];
727
728 // Visible margins to assist user interaction
737
738private:
740 void operator=(const vtkImagePlaneWidget&) = delete;
741};
742
743VTK_ABI_NAMESPACE_END
744#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
3D widget for reslicing image data
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.
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.
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.
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.
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.
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.
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:162
create an array of quadrilaterals located in a plane
represent and manipulate 3D points
Definition vtkPoints.h:139
Superclass for algorithms that produce only polydata as output.
abstract PolyDataSource-based 3D widget
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 VTK_SIZEHINT(...)