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
99#ifndef vtkImagePlaneWidget_h
100#define vtkImagePlaneWidget_h
101
102#include "vtkInteractionWidgetsModule.h" // For export macro
104
105VTK_ABI_NAMESPACE_BEGIN
106class vtkActor;
108class vtkDataSetMapper;
109class vtkImageData;
111class vtkImageReslice;
112class vtkLookupTable;
113class vtkMatrix4x4;
114class vtkPlaneSource;
115class vtkPoints;
116class vtkPolyData;
117class vtkProperty;
118class vtkTextActor;
119class vtkTextProperty;
120class vtkTexture;
121class vtkTransform;
122
123#define VTK_NEAREST_RESLICE 0
124#define VTK_LINEAR_RESLICE 1
125#define VTK_CUBIC_RESLICE 2
126
127// Private.
128#define VTK_IMAGE_PLANE_WIDGET_MAX_TEXTBUFF 128
129
130class VTKINTERACTIONWIDGETS_EXPORT vtkImagePlaneWidget : public vtkPolyDataSourceWidget
131{
132public:
137
139 void PrintSelf(ostream& os, vtkIndent indent) override;
140
142
145 void SetEnabled(int) override;
146 void PlaceWidget(double bounds[6]) override;
147 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
149 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
150 {
151 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
152 }
154
159
161
164 void SetOrigin(double x, double y, double z);
165 void SetOrigin(double xyz[3]);
167 void GetOrigin(double xyz[3]);
169
171
174 void SetPoint1(double x, double y, double z);
175 void SetPoint1(double xyz[3]);
176 double* GetPoint1() VTK_SIZEHINT(3);
177 void GetPoint1(double xyz[3]);
179
181
184 void SetPoint2(double x, double y, double z);
185 void SetPoint2(double xyz[3]);
186 double* GetPoint2() VTK_SIZEHINT(3);
187 void GetPoint2(double xyz[3]);
189
191
194 double* GetCenter() VTK_SIZEHINT(3);
195 void GetCenter(double xyz[3]);
197
199
202 double* GetNormal() VTK_SIZEHINT(3);
203 void GetNormal(double xyz[3]);
205
209 void GetVector1(double v1[3]);
210
214 void GetVector2(double v2[3]);
215
219 int GetSliceIndex();
220
224 void SetSliceIndex(int index);
225
229 double GetSlicePosition();
230
234 void SetSlicePosition(double position);
235
237
240 void SetResliceInterpolate(int);
241 vtkGetMacro(ResliceInterpolate, int);
242 void SetResliceInterpolateToNearestNeighbour()
243 {
244 this->SetResliceInterpolate(VTK_NEAREST_RESLICE);
245 }
246 void SetResliceInterpolateToLinear() { this->SetResliceInterpolate(VTK_LINEAR_RESLICE); }
247 void SetResliceInterpolateToCubic() { this->SetResliceInterpolate(VTK_CUBIC_RESLICE); }
249
254
256
260 vtkSetMacro(RestrictPlaneToVolume, vtkTypeBool);
261 vtkGetMacro(RestrictPlaneToVolume, vtkTypeBool);
262 vtkBooleanMacro(RestrictPlaneToVolume, vtkTypeBool);
264
266
271 vtkSetMacro(UserControlledLookupTable, vtkTypeBool);
272 vtkGetMacro(UserControlledLookupTable, vtkTypeBool);
273 vtkBooleanMacro(UserControlledLookupTable, vtkTypeBool);
275
277
283 vtkSetMacro(TextureInterpolate, vtkTypeBool);
284 vtkGetMacro(TextureInterpolate, vtkTypeBool);
285 vtkBooleanMacro(TextureInterpolate, vtkTypeBool);
287
289
294 vtkGetMacro(TextureVisibility, vtkTypeBool);
295 vtkBooleanMacro(TextureVisibility, vtkTypeBool);
297
307
315
320 void UpdatePlacement() override;
321
327
329
335 vtkGetObjectMacro(ColorMap, vtkImageMapToColors);
338
340
345 vtkGetObjectMacro(PlaneProperty, vtkProperty);
347 vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
349
351
356 vtkGetMacro(PlaneOrientation, int);
357 void SetPlaneOrientationToXAxes() { this->SetPlaneOrientation(0); }
358 void SetPlaneOrientationToYAxes() { this->SetPlaneOrientation(1); }
359 void SetPlaneOrientationToZAxes() { this->SetPlaneOrientation(2); }
361
369
371
379 vtkGetObjectMacro(LookupTable, vtkLookupTable);
381
383
387 vtkSetMacro(DisplayText, vtkTypeBool);
388 vtkGetMacro(DisplayText, vtkTypeBool);
389 vtkBooleanMacro(DisplayText, vtkTypeBool);
391
393
397 vtkGetObjectMacro(CursorProperty, vtkProperty);
399
401
405 vtkGetObjectMacro(MarginProperty, vtkProperty);
407
409
413 vtkSetClampMacro(MarginSizeX, double, 0.0, 0.5);
414 vtkGetMacro(MarginSizeX, double);
415 vtkSetClampMacro(MarginSizeY, double, 0.0, 0.5);
416 vtkGetMacro(MarginSizeY, double);
418
420
426
428
432 vtkGetObjectMacro(TexturePlaneProperty, vtkProperty);
434
436
442 void SetWindowLevel(double window, double level, int copy = 0);
443 void GetWindowLevel(double wl[2]);
444 double GetWindow() { return this->CurrentWindow; }
445 double GetLevel() { return this->CurrentLevel; }
447
452 int GetCursorData(double xyzv[4]);
453
460
462
466 vtkGetVectorMacro(CurrentCursorPosition, double, 3);
468
470
475 vtkGetMacro(CurrentImageValue, double);
477
479
482 vtkGetObjectMacro(ResliceAxes, vtkMatrix4x4);
483 vtkGetObjectMacro(Reslice, vtkImageReslice);
485
487
494 vtkSetMacro(UseContinuousCursor, vtkTypeBool);
495 vtkGetMacro(UseContinuousCursor, vtkTypeBool);
496 vtkBooleanMacro(UseContinuousCursor, vtkTypeBool);
498
500
504 vtkGetMacro(Interaction, vtkTypeBool);
505 vtkBooleanMacro(Interaction, vtkTypeBool);
507
509
512 enum
513 {
514 VTK_CURSOR_ACTION = 0,
515 VTK_SLICE_MOTION_ACTION = 1,
516 VTK_WINDOW_LEVEL_ACTION = 2
517 };
518 vtkSetClampMacro(LeftButtonAction, int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
519 vtkGetMacro(LeftButtonAction, int);
520 vtkSetClampMacro(MiddleButtonAction, int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
521 vtkGetMacro(MiddleButtonAction, int);
522 vtkSetClampMacro(RightButtonAction, int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
523 vtkGetMacro(RightButtonAction, int);
525
527
535 enum
536 {
537 VTK_NO_MODIFIER = 0,
538 VTK_SHIFT_MODIFIER = 1,
539 VTK_CONTROL_MODIFIER = 2
540 };
541 vtkSetClampMacro(LeftButtonAutoModifier, int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
542 vtkGetMacro(LeftButtonAutoModifier, int);
543 vtkSetClampMacro(MiddleButtonAutoModifier, int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
544 vtkGetMacro(MiddleButtonAutoModifier, int);
545 vtkSetClampMacro(RightButtonAutoModifier, int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
546 vtkGetMacro(RightButtonAutoModifier, int);
548
549protected:
552
554
558
562
563 enum
564 {
565 VTK_NO_BUTTON = 0,
566 VTK_LEFT_BUTTON = 1,
567 VTK_MIDDLE_BUTTON = 2,
568 VTK_RIGHT_BUTTON = 3
569 };
571
572 // Manage the state of the widget
573 int State;
575 {
576 Start = 0,
584 Outside
585 };
586
587 // Handles the events
588 static void ProcessEvents(
589 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
590
591 // internal utility method that adds observers to the RenderWindowInteractor
592 // so that our ProcessEvents is eventually called. this method is called
593 // by SetEnabled as well as SetInteraction
595
596 // ProcessEvents() dispatches to these methods.
597 virtual void OnMouseMove();
598 virtual void OnLeftButtonDown();
599 virtual void OnLeftButtonUp();
600 virtual void OnMiddleButtonDown();
601 virtual void OnMiddleButtonUp();
602 virtual void OnRightButtonDown();
603 virtual void OnRightButtonUp();
604 void OnChar() override;
605
606 virtual void StartCursor();
607 virtual void StopCursor();
608 virtual void StartSliceMotion();
609 virtual void StopSliceMotion();
610 virtual void StartWindowLevel();
611 virtual void StopWindowLevel();
612
613 // controlling ivars
614 vtkTypeBool Interaction; // Is the widget responsive to mouse events
629
630 // The geometric representation of the plane and it's outline
634 void HighlightPlane(int highlight);
636
637 // Re-builds the plane outline based on the plane source
639
640 // Do the picking
642
643 // Register internal Pickers within PickingManager
644 void RegisterPickers() override;
645
646 // for negative window values.
648
649 // Methods to manipulate the plane
650 void WindowLevel(int X, int Y);
651 void Push(double* p1, double* p2);
652 void Spin(double* p1, double* p2);
653 void Rotate(double* p1, double* p2, double* vpn);
654 void Scale(double* p1, double* p2, int X, int Y);
655 void Translate(double* p1, double* p2);
656
666
667 // Properties used to control the appearance of selected objects and
668 // the manipulator in general. The plane property is actually that for
669 // the outline. The TexturePlaneProperty can be used to control the
670 // lighting etc. of the resliced image data.
677
678 // Reslice and texture management
681
682 // The cross-hair cursor
685 double CurrentCursorPosition[3];
686 double CurrentImageValue; // Set to VTK_DOUBLE_MAX when invalid
688 void UpdateCursor(int, int);
689 void ActivateCursor(int);
691 int UpdateDiscreteCursor(double* q);
693
694 // The text to display W/L, image data
699 void ActivateText(int);
700
701 // Oblique reslice control
702 double RotateAxis[3];
703 double RadiusVector[3];
705
706 // Visible margins to assist user interaction
715
716private:
718 void operator=(const vtkImagePlaneWidget&) = delete;
719};
720
721VTK_ABI_NAMESPACE_END
722#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:41
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: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:49
create an array of quadrilaterals located in a plane
represent and manipulate 3D points
Definition vtkPoints.h:29
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:80
represent surface properties of a geometric object
Definition vtkProperty.h:57
An actor that displays text.
represent text properties.
handles properties associated with a texture map
Definition vtkTexture.h:58
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(...)