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
111 #ifndef vtkImagePlaneWidget_h
112 #define vtkImagePlaneWidget_h
113 
114 #include "vtkInteractionWidgetsModule.h" // For export macro
115 #include "vtkPolyDataSourceWidget.h"
116 
117 VTK_ABI_NAMESPACE_BEGIN
118 class vtkActor;
120 class vtkDataSetMapper;
121 class vtkImageData;
122 class vtkImageMapToColors;
123 class vtkImageReslice;
124 class vtkLookupTable;
125 class vtkMatrix4x4;
126 class vtkPlaneSource;
127 class vtkPoints;
128 class vtkPolyData;
129 class vtkProperty;
130 class vtkTextActor;
131 class vtkTextProperty;
132 class vtkTexture;
133 class vtkTransform;
134 
135 #define VTK_NEAREST_RESLICE 0
136 #define VTK_LINEAR_RESLICE 1
137 #define VTK_CUBIC_RESLICE 2
138 
139 // Private.
140 #define VTK_IMAGE_PLANE_WIDGET_MAX_TEXTBUFF 128
141 
142 class VTKINTERACTIONWIDGETS_EXPORT vtkImagePlaneWidget : public vtkPolyDataSourceWidget
143 {
144 public:
149 
151  void PrintSelf(ostream& os, vtkIndent indent) override;
152 
154 
157  void SetEnabled(int) override;
158  void PlaceWidget(double bounds[6]) override;
159  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
161  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
162  {
163  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
164  }
166 
171 
173 
176  void SetOrigin(double x, double y, double z);
177  void SetOrigin(double xyz[3]);
178  double* GetOrigin() VTK_SIZEHINT(3);
179  void GetOrigin(double xyz[3]);
181 
183 
186  void SetPoint1(double x, double y, double z);
187  void SetPoint1(double xyz[3]);
188  double* GetPoint1() VTK_SIZEHINT(3);
189  void GetPoint1(double xyz[3]);
191 
193 
196  void SetPoint2(double x, double y, double z);
197  void SetPoint2(double xyz[3]);
198  double* GetPoint2() VTK_SIZEHINT(3);
199  void GetPoint2(double xyz[3]);
201 
203 
206  double* GetCenter() VTK_SIZEHINT(3);
207  void GetCenter(double xyz[3]);
209 
211 
214  double* GetNormal() VTK_SIZEHINT(3);
215  void GetNormal(double xyz[3]);
217 
221  void GetVector1(double v1[3]);
222 
226  void GetVector2(double v2[3]);
227 
231  int GetSliceIndex();
232 
236  void SetSliceIndex(int index);
237 
241  double GetSlicePosition();
242 
246  void SetSlicePosition(double position);
247 
249 
252  void SetResliceInterpolate(int);
253  vtkGetMacro(ResliceInterpolate, int);
254  void SetResliceInterpolateToNearestNeighbour()
255  {
256  this->SetResliceInterpolate(VTK_NEAREST_RESLICE);
257  }
258  void SetResliceInterpolateToLinear() { this->SetResliceInterpolate(VTK_LINEAR_RESLICE); }
259  void SetResliceInterpolateToCubic() { this->SetResliceInterpolate(VTK_CUBIC_RESLICE); }
261 
266 
268 
272  vtkSetMacro(RestrictPlaneToVolume, vtkTypeBool);
273  vtkGetMacro(RestrictPlaneToVolume, vtkTypeBool);
274  vtkBooleanMacro(RestrictPlaneToVolume, vtkTypeBool);
276 
278 
283  vtkSetMacro(UserControlledLookupTable, vtkTypeBool);
284  vtkGetMacro(UserControlledLookupTable, vtkTypeBool);
285  vtkBooleanMacro(UserControlledLookupTable, vtkTypeBool);
287 
289 
295  vtkSetMacro(TextureInterpolate, vtkTypeBool);
296  vtkGetMacro(TextureInterpolate, vtkTypeBool);
297  vtkBooleanMacro(TextureInterpolate, vtkTypeBool);
299 
301 
306  vtkGetMacro(TextureVisibility, vtkTypeBool);
307  vtkBooleanMacro(TextureVisibility, vtkTypeBool);
309 
319 
327 
332  void UpdatePlacement() override;
333 
339 
341 
347  vtkGetObjectMacro(ColorMap, vtkImageMapToColors);
350 
352 
357  vtkGetObjectMacro(PlaneProperty, vtkProperty);
359  vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
361 
363 
368  vtkGetMacro(PlaneOrientation, int);
369  void SetPlaneOrientationToXAxes() { this->SetPlaneOrientation(0); }
370  void SetPlaneOrientationToYAxes() { this->SetPlaneOrientation(1); }
371  void SetPlaneOrientationToZAxes() { this->SetPlaneOrientation(2); }
373 
381 
383 
391  vtkGetObjectMacro(LookupTable, vtkLookupTable);
393 
395 
399  vtkSetMacro(DisplayText, vtkTypeBool);
400  vtkGetMacro(DisplayText, vtkTypeBool);
401  vtkBooleanMacro(DisplayText, vtkTypeBool);
403 
405 
409  vtkGetObjectMacro(CursorProperty, vtkProperty);
411 
413 
417  vtkGetObjectMacro(MarginProperty, vtkProperty);
419 
421 
425  vtkSetClampMacro(MarginSizeX, double, 0.0, 0.5);
426  vtkGetMacro(MarginSizeX, double);
427  vtkSetClampMacro(MarginSizeY, double, 0.0, 0.5);
428  vtkGetMacro(MarginSizeY, double);
430 
432 
438 
440 
444  vtkGetObjectMacro(TexturePlaneProperty, vtkProperty);
446 
448 
454  void SetWindowLevel(double window, double level, int copy = 0);
455  void GetWindowLevel(double wl[2]);
456  double GetWindow() { return this->CurrentWindow; }
457  double GetLevel() { return this->CurrentLevel; }
459 
464  int GetCursorData(double xyzv[4]);
465 
472 
474 
478  vtkGetVectorMacro(CurrentCursorPosition, double, 3);
480 
482 
487  vtkGetMacro(CurrentImageValue, double);
489 
491 
494  vtkGetObjectMacro(ResliceAxes, vtkMatrix4x4);
495  vtkGetObjectMacro(Reslice, vtkImageReslice);
497 
499 
506  vtkSetMacro(UseContinuousCursor, vtkTypeBool);
507  vtkGetMacro(UseContinuousCursor, vtkTypeBool);
508  vtkBooleanMacro(UseContinuousCursor, vtkTypeBool);
510 
512 
515  void SetInteraction(vtkTypeBool interact);
516  vtkGetMacro(Interaction, vtkTypeBool);
517  vtkBooleanMacro(Interaction, vtkTypeBool);
519 
521 
524  enum
525  {
526  VTK_CURSOR_ACTION = 0,
527  VTK_SLICE_MOTION_ACTION = 1,
528  VTK_WINDOW_LEVEL_ACTION = 2
529  };
530  vtkSetClampMacro(LeftButtonAction, int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
531  vtkGetMacro(LeftButtonAction, int);
532  vtkSetClampMacro(MiddleButtonAction, int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
533  vtkGetMacro(MiddleButtonAction, int);
534  vtkSetClampMacro(RightButtonAction, int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
535  vtkGetMacro(RightButtonAction, int);
537 
539 
547  enum
548  {
549  VTK_NO_MODIFIER = 0,
550  VTK_SHIFT_MODIFIER = 1,
551  VTK_CONTROL_MODIFIER = 2
552  };
553  vtkSetClampMacro(LeftButtonAutoModifier, int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
554  vtkGetMacro(LeftButtonAutoModifier, int);
555  vtkSetClampMacro(MiddleButtonAutoModifier, int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
556  vtkGetMacro(MiddleButtonAutoModifier, int);
557  vtkSetClampMacro(RightButtonAutoModifier, int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
558  vtkGetMacro(RightButtonAutoModifier, int);
560 
561 protected:
564 
566 
570 
574 
575  enum
576  {
577  VTK_NO_BUTTON = 0,
578  VTK_LEFT_BUTTON = 1,
579  VTK_MIDDLE_BUTTON = 2,
580  VTK_RIGHT_BUTTON = 3
581  };
583 
584  // Manage the state of the widget
585  int State;
587  {
588  Start = 0,
596  Outside
597  };
598 
599  // Handles the events
600  static void ProcessEvents(
601  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
602 
603  // internal utility method that adds observers to the RenderWindowInteractor
604  // so that our ProcessEvents is eventually called. this method is called
605  // by SetEnabled as well as SetInteraction
606  void AddObservers();
607 
608  // ProcessEvents() dispatches to these methods.
609  virtual void OnMouseMove();
610  virtual void OnLeftButtonDown();
611  virtual void OnLeftButtonUp();
612  virtual void OnMiddleButtonDown();
613  virtual void OnMiddleButtonUp();
614  virtual void OnRightButtonDown();
615  virtual void OnRightButtonUp();
616  void OnChar() override;
617 
618  virtual void StartCursor();
619  virtual void StopCursor();
620  virtual void StartSliceMotion();
621  virtual void StopSliceMotion();
622  virtual void StartWindowLevel();
623  virtual void StopWindowLevel();
624 
625  // controlling ivars
626  vtkTypeBool Interaction; // Is the widget responsive to mouse events
632  double CurrentLevel;
634  double InitialLevel;
641 
642  // The geometric representation of the plane and it's outline
646  void HighlightPlane(int highlight);
648 
649  // Re-builds the plane outline based on the plane source
651 
652  // Do the picking
654 
655  // Register internal Pickers within PickingManager
656  void RegisterPickers() override;
657 
658  // for negative window values.
659  void InvertTable();
660 
661  // Methods to manipulate the plane
662  void WindowLevel(int X, int Y);
663  void Push(double* p1, double* p2);
664  void Spin(double* p1, double* p2);
665  void Rotate(double* p1, double* p2, double* vpn);
666  void Scale(double* p1, double* p2, int X, int Y);
667  void Translate(double* p1, double* p2);
668 
678 
679  // Properties used to control the appearance of selected objects and
680  // the manipulator in general. The plane property is actually that for
681  // the outline. The TexturePlaneProperty can be used to control the
682  // lighting etc. of the resliced image data.
689 
690  // Reslice and texture management
691  void UpdatePlane();
693 
694  // The cross-hair cursor
697  double CurrentCursorPosition[3];
698  double CurrentImageValue; // Set to VTK_DOUBLE_MAX when invalid
700  void UpdateCursor(int, int);
701  void ActivateCursor(int);
702  int UpdateContinuousCursor(double* q);
703  int UpdateDiscreteCursor(double* q);
705 
706  // The text to display W/L, image data
709  void GenerateText();
711  void ActivateText(int);
712 
713  // Oblique reslice control
714  double RotateAxis[3];
715  double RadiusVector[3];
716  void AdjustState();
717 
718  // Visible margins to assist user interaction
724  void ActivateMargins(int);
725  double MarginSizeX;
726  double MarginSizeY;
727 
728 private:
729  vtkImagePlaneWidget(const vtkImagePlaneWidget&) = delete;
730  void operator=(const vtkImagePlaneWidget&) = delete;
731 };
732 
733 VTK_ABI_NAMESPACE_END
734 #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
Definition: vtkImageData.h:52
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.
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()
static vtkImagePlaneWidget * New()
Instantiate the object.
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.
virtual void StopSliceMotion()
double GetLevel()
Set/Get the current window and level values.
vtkPolyDataAlgorithm * GetPolyDataAlgorithm() override
Satisfies superclass API.
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()
void CreateDefaultProperties()
void HighlightPlane(int highlight)
void SetResliceInterpolateToLinear()
Set the interpolation to use when texturing the plane.
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,...
vtkTextProperty * GetTextProperty()
Set/Get the text property for the image data and window-level annotation.
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
vtkTexture * GetTexture()
Convenience method to get the texture used by this widget.
void Spin(double *p1, double *p2)
void ActivateMargins(int)
vtkProperty * CursorProperty
int UpdateDiscreteCursor(double *q)
vtkLookupTable * CreateDefaultLookupTable()
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
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()
double * GetOrigin()
Set/Get the origin of the plane.
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)
vtkImageData * GetResliceOutput()
Convenience method to get the vtkImageReslice output.
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
Definition: vtkMatrix4x4.h:40
abstract base class for most VTK objects
Definition: vtkObject.h:61
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.
Definition: vtkTextActor.h:55
represent text properties.
handles properties associated with a texture map
Definition: vtkTexture.h:67
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:59
@ 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(...)