VTK  9.3.0
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
108#ifndef vtkImagePlaneWidget_h
109#define vtkImagePlaneWidget_h
110
111#include "vtkInteractionWidgetsModule.h" // For export macro
113
114VTK_ABI_NAMESPACE_BEGIN
115class vtkActor;
117class vtkDataSetMapper;
118class vtkImageData;
120class vtkImageReslice;
121class vtkLookupTable;
122class vtkMatrix4x4;
123class vtkPlaneSource;
124class vtkPoints;
125class vtkPolyData;
126class vtkProperty;
127class vtkTextActor;
128class vtkTextProperty;
129class vtkTexture;
130class vtkTransform;
131
132#define VTK_NEAREST_RESLICE 0
133#define VTK_LINEAR_RESLICE 1
134#define VTK_CUBIC_RESLICE 2
135
136// Private.
137#define VTK_IMAGE_PLANE_WIDGET_MAX_TEXTBUFF 128
138
139class VTKINTERACTIONWIDGETS_EXPORT vtkImagePlaneWidget : public vtkPolyDataSourceWidget
140{
141public:
146
148 void PrintSelf(ostream& os, vtkIndent indent) override;
149
151
154 void SetEnabled(int) override;
155 void PlaceWidget(double bounds[6]) override;
156 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
158 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
159 {
160 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
161 }
163
168
170
173 void SetOrigin(double x, double y, double z);
174 void SetOrigin(double xyz[3]);
176 void GetOrigin(double xyz[3]);
178
180
183 void SetPoint1(double x, double y, double z);
184 void SetPoint1(double xyz[3]);
185 double* GetPoint1() VTK_SIZEHINT(3);
186 void GetPoint1(double xyz[3]);
188
190
193 void SetPoint2(double x, double y, double z);
194 void SetPoint2(double xyz[3]);
195 double* GetPoint2() VTK_SIZEHINT(3);
196 void GetPoint2(double xyz[3]);
198
200
203 double* GetCenter() VTK_SIZEHINT(3);
204 void GetCenter(double xyz[3]);
206
208
211 double* GetNormal() VTK_SIZEHINT(3);
212 void GetNormal(double xyz[3]);
214
218 void GetVector1(double v1[3]);
219
223 void GetVector2(double v2[3]);
224
228 int GetSliceIndex();
229
233 void SetSliceIndex(int index);
234
238 double GetSlicePosition();
239
243 void SetSlicePosition(double position);
244
246
249 void SetResliceInterpolate(int);
250 vtkGetMacro(ResliceInterpolate, int);
251 void SetResliceInterpolateToNearestNeighbour()
252 {
253 this->SetResliceInterpolate(VTK_NEAREST_RESLICE);
254 }
255 void SetResliceInterpolateToLinear() { this->SetResliceInterpolate(VTK_LINEAR_RESLICE); }
256 void SetResliceInterpolateToCubic() { this->SetResliceInterpolate(VTK_CUBIC_RESLICE); }
258
263
265
269 vtkSetMacro(RestrictPlaneToVolume, vtkTypeBool);
270 vtkGetMacro(RestrictPlaneToVolume, vtkTypeBool);
271 vtkBooleanMacro(RestrictPlaneToVolume, vtkTypeBool);
273
275
280 vtkSetMacro(UserControlledLookupTable, vtkTypeBool);
281 vtkGetMacro(UserControlledLookupTable, vtkTypeBool);
282 vtkBooleanMacro(UserControlledLookupTable, vtkTypeBool);
284
286
292 vtkSetMacro(TextureInterpolate, vtkTypeBool);
293 vtkGetMacro(TextureInterpolate, vtkTypeBool);
294 vtkBooleanMacro(TextureInterpolate, vtkTypeBool);
296
298
303 vtkGetMacro(TextureVisibility, vtkTypeBool);
304 vtkBooleanMacro(TextureVisibility, vtkTypeBool);
306
316
324
329 void UpdatePlacement() override;
330
336
338
344 vtkGetObjectMacro(ColorMap, vtkImageMapToColors);
347
349
354 vtkGetObjectMacro(PlaneProperty, vtkProperty);
356 vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
358
360
365 vtkGetMacro(PlaneOrientation, int);
366 void SetPlaneOrientationToXAxes() { this->SetPlaneOrientation(0); }
367 void SetPlaneOrientationToYAxes() { this->SetPlaneOrientation(1); }
368 void SetPlaneOrientationToZAxes() { this->SetPlaneOrientation(2); }
370
378
380
388 vtkGetObjectMacro(LookupTable, vtkLookupTable);
390
392
396 vtkSetMacro(DisplayText, vtkTypeBool);
397 vtkGetMacro(DisplayText, vtkTypeBool);
398 vtkBooleanMacro(DisplayText, vtkTypeBool);
400
402
406 vtkGetObjectMacro(CursorProperty, vtkProperty);
408
410
414 vtkGetObjectMacro(MarginProperty, vtkProperty);
416
418
422 vtkSetClampMacro(MarginSizeX, double, 0.0, 0.5);
423 vtkGetMacro(MarginSizeX, double);
424 vtkSetClampMacro(MarginSizeY, double, 0.0, 0.5);
425 vtkGetMacro(MarginSizeY, double);
427
429
435
437
441 vtkGetObjectMacro(TexturePlaneProperty, vtkProperty);
443
445
451 void SetWindowLevel(double window, double level, int copy = 0);
452 void GetWindowLevel(double wl[2]);
453 double GetWindow() { return this->CurrentWindow; }
454 double GetLevel() { return this->CurrentLevel; }
456
461 int GetCursorData(double xyzv[4]);
462
469
471
475 vtkGetVectorMacro(CurrentCursorPosition, double, 3);
477
479
484 vtkGetMacro(CurrentImageValue, double);
486
488
491 vtkGetObjectMacro(ResliceAxes, vtkMatrix4x4);
492 vtkGetObjectMacro(Reslice, vtkImageReslice);
494
496
503 vtkSetMacro(UseContinuousCursor, vtkTypeBool);
504 vtkGetMacro(UseContinuousCursor, vtkTypeBool);
505 vtkBooleanMacro(UseContinuousCursor, vtkTypeBool);
507
509
513 vtkGetMacro(Interaction, vtkTypeBool);
514 vtkBooleanMacro(Interaction, vtkTypeBool);
516
518
521 enum
522 {
523 VTK_CURSOR_ACTION = 0,
524 VTK_SLICE_MOTION_ACTION = 1,
525 VTK_WINDOW_LEVEL_ACTION = 2
526 };
527 vtkSetClampMacro(LeftButtonAction, int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
528 vtkGetMacro(LeftButtonAction, int);
529 vtkSetClampMacro(MiddleButtonAction, int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
530 vtkGetMacro(MiddleButtonAction, int);
531 vtkSetClampMacro(RightButtonAction, int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
532 vtkGetMacro(RightButtonAction, int);
534
536
544 enum
545 {
546 VTK_NO_MODIFIER = 0,
547 VTK_SHIFT_MODIFIER = 1,
548 VTK_CONTROL_MODIFIER = 2
549 };
550 vtkSetClampMacro(LeftButtonAutoModifier, int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
551 vtkGetMacro(LeftButtonAutoModifier, int);
552 vtkSetClampMacro(MiddleButtonAutoModifier, int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
553 vtkGetMacro(MiddleButtonAutoModifier, int);
554 vtkSetClampMacro(RightButtonAutoModifier, int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
555 vtkGetMacro(RightButtonAutoModifier, int);
557
558protected:
561
563
567
571
572 enum
573 {
574 VTK_NO_BUTTON = 0,
575 VTK_LEFT_BUTTON = 1,
576 VTK_MIDDLE_BUTTON = 2,
577 VTK_RIGHT_BUTTON = 3
578 };
580
581 // Manage the state of the widget
582 int State;
584 {
585 Start = 0,
593 Outside
594 };
595
596 // Handles the events
597 static void ProcessEvents(
598 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
599
600 // internal utility method that adds observers to the RenderWindowInteractor
601 // so that our ProcessEvents is eventually called. this method is called
602 // by SetEnabled as well as SetInteraction
604
605 // ProcessEvents() dispatches to these methods.
606 virtual void OnMouseMove();
607 virtual void OnLeftButtonDown();
608 virtual void OnLeftButtonUp();
609 virtual void OnMiddleButtonDown();
610 virtual void OnMiddleButtonUp();
611 virtual void OnRightButtonDown();
612 virtual void OnRightButtonUp();
613 void OnChar() override;
614
615 virtual void StartCursor();
616 virtual void StopCursor();
617 virtual void StartSliceMotion();
618 virtual void StopSliceMotion();
619 virtual void StartWindowLevel();
620 virtual void StopWindowLevel();
621
622 // controlling ivars
623 vtkTypeBool Interaction; // Is the widget responsive to mouse events
638
639 // The geometric representation of the plane and it's outline
643 void HighlightPlane(int highlight);
645
646 // Re-builds the plane outline based on the plane source
648
649 // Do the picking
651
652 // Register internal Pickers within PickingManager
653 void RegisterPickers() override;
654
655 // for negative window values.
657
658 // Methods to manipulate the plane
659 void WindowLevel(int X, int Y);
660 void Push(double* p1, double* p2);
661 void Spin(double* p1, double* p2);
662 void Rotate(double* p1, double* p2, double* vpn);
663 void Scale(double* p1, double* p2, int X, int Y);
664 void Translate(double* p1, double* p2);
665
675
676 // Properties used to control the appearance of selected objects and
677 // the manipulator in general. The plane property is actually that for
678 // the outline. The TexturePlaneProperty can be used to control the
679 // lighting etc. of the resliced image data.
686
687 // Reslice and texture management
690
691 // The cross-hair cursor
694 double CurrentCursorPosition[3];
695 double CurrentImageValue; // Set to VTK_DOUBLE_MAX when invalid
697 void UpdateCursor(int, int);
698 void ActivateCursor(int);
700 int UpdateDiscreteCursor(double* q);
702
703 // The text to display W/L, image data
708 void ActivateText(int);
709
710 // Oblique reslice control
711 double RotateAxis[3];
712 double RadiusVector[3];
714
715 // Visible margins to assist user interaction
724
725private:
727 void operator=(const vtkImagePlaneWidget&) = delete;
728};
729
730VTK_ABI_NAMESPACE_END
731#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:50
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:38
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:58
create an array of quadrilaterals located in a plane
represent and manipulate 3D points
Definition vtkPoints.h:38
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:89
represent surface properties of a geometric object
Definition vtkProperty.h:66
An actor that displays text.
represent text properties.
handles properties associated with a texture map
Definition vtkTexture.h:67
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(...)