VTK  9.0.2
vtkImagePlaneWidget.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkImagePlaneWidget.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
109 #ifndef vtkImagePlaneWidget_h
110 #define vtkImagePlaneWidget_h
111 
112 #include "vtkInteractionWidgetsModule.h" // For export macro
113 #include "vtkPolyDataSourceWidget.h"
114 
115 class vtkActor;
117 class vtkDataSetMapper;
118 class vtkImageData;
119 class vtkImageMapToColors;
120 class vtkImageReslice;
121 class vtkLookupTable;
122 class vtkMatrix4x4;
123 class vtkPlaneSource;
124 class vtkPoints;
125 class vtkPolyData;
126 class vtkProperty;
127 class vtkTextActor;
128 class vtkTextProperty;
129 class vtkTexture;
130 class 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 
139 class VTKINTERACTIONWIDGETS_EXPORT vtkImagePlaneWidget : public vtkPolyDataSourceWidget
140 {
141 public:
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]);
175  double* GetOrigin() VTK_SIZEHINT(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(void) 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 
512  void SetInteraction(vtkTypeBool interact);
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 
558 protected:
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
603  void AddObservers();
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
629  double CurrentLevel;
631  double InitialLevel;
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.
656  void InvertTable();
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
688  void UpdatePlane();
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);
699  int UpdateContinuousCursor(double* q);
700  int UpdateDiscreteCursor(double* q);
702 
703  // The text to display W/L, image data
706  void GenerateText();
708  void ActivateText(int);
709 
710  // Oblique reslice control
711  double RotateAxis[3];
712  double RadiusVector[3];
713  void AdjustState();
714 
715  // Visible margins to assist user interaction
721  void ActivateMargins(int);
722  double MarginSizeX;
723  double MarginSizeY;
724 
725 private:
726  vtkImagePlaneWidget(const vtkImagePlaneWidget&) = delete;
727  void operator=(const vtkImagePlaneWidget&) = delete;
728 };
729 
730 #endif
virtual void PlaceWidget()
abstract API for pickers that can pick an instance of vtkProp
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:46
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:42
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 PlaceWidget() override
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 *)
vtkLookupTable * LookupTable
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()
vtkPolyDataAlgorithm * GetPolyDataAlgorithm() override
Satisfies superclass API.
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
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)
virtual void OnMouseMove()
void CreateDefaultProperties()
void HighlightPlane(int highlight)
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)
virtual void SetLookupTable(vtkLookupTable *)
Set/Get the internal lookuptable (lut) to one defined by the user, or, alternatively,...
vtkTextProperty * GetTextProperty()
void SetEnabled(int) override
Methods that satisfy the superclass' API.
vtkTypeBool UserControlledLookupTable
void SetOrigin(double xyz[3])
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])
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
We have to redeclare this abstract, PlaceWidget() requires it.
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 *)
virtual void OnLeftButtonDown()
void UpdatePlacement(void) override
Satisfies superclass API.
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
virtual void OnRightButtonDown()
double * GetOrigin()
vtkPolyData * PlaneOutlinePolyData
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:34
map scalar values into colors via a lookup table
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:36
abstract base class for most VTK objects
Definition: vtkObject.h:63
create an array of quadrilaterals located in a plane
represent and manipulate 3D points
Definition: vtkPoints.h:34
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:85
represent surface properties of a geometric object
Definition: vtkProperty.h:62
An actor that displays text.
Definition: vtkTextActor.h:51
represent text properties.
handles properties associated with a texture map
Definition: vtkTexture.h:66
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:55
@ level
Definition: vtkX3D.h:401
@ position
Definition: vtkX3D.h:267
@ index
Definition: vtkX3D.h:252
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_LINEAR_RESLICE
#define VTK_CUBIC_RESLICE
#define VTK_IMAGE_PLANE_WIDGET_MAX_TEXTBUFF
#define VTK_NEAREST_RESLICE
#define VTK_SIZEHINT(...)