VTK  9.1.0
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 =========================================================================*/
105 #ifndef vtkImagePlaneWidget_h
106 #define vtkImagePlaneWidget_h
107 
108 #include "vtkInteractionWidgetsModule.h" // For export macro
109 #include "vtkPolyDataSourceWidget.h"
110 
111 class vtkActor;
113 class vtkDataSetMapper;
114 class vtkImageData;
115 class vtkImageMapToColors;
116 class vtkImageReslice;
117 class vtkLookupTable;
118 class vtkMatrix4x4;
119 class vtkPlaneSource;
120 class vtkPoints;
121 class vtkPolyData;
122 class vtkProperty;
123 class vtkTextActor;
124 class vtkTextProperty;
125 class vtkTexture;
126 class vtkTransform;
127 
128 #define VTK_NEAREST_RESLICE 0
129 #define VTK_LINEAR_RESLICE 1
130 #define VTK_CUBIC_RESLICE 2
131 
132 // Private.
133 #define VTK_IMAGE_PLANE_WIDGET_MAX_TEXTBUFF 128
134 
135 class VTKINTERACTIONWIDGETS_EXPORT vtkImagePlaneWidget : public vtkPolyDataSourceWidget
136 {
137 public:
142 
144  void PrintSelf(ostream& os, vtkIndent indent) override;
145 
147 
150  void SetEnabled(int) override;
151  void PlaceWidget(double bounds[6]) override;
152  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
154  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
155  {
156  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
157  }
159 
164 
166 
169  void SetOrigin(double x, double y, double z);
170  void SetOrigin(double xyz[3]);
171  double* GetOrigin() VTK_SIZEHINT(3);
172  void GetOrigin(double xyz[3]);
174 
176 
179  void SetPoint1(double x, double y, double z);
180  void SetPoint1(double xyz[3]);
181  double* GetPoint1() VTK_SIZEHINT(3);
182  void GetPoint1(double xyz[3]);
184 
186 
189  void SetPoint2(double x, double y, double z);
190  void SetPoint2(double xyz[3]);
191  double* GetPoint2() VTK_SIZEHINT(3);
192  void GetPoint2(double xyz[3]);
194 
196 
199  double* GetCenter() VTK_SIZEHINT(3);
200  void GetCenter(double xyz[3]);
202 
204 
207  double* GetNormal() VTK_SIZEHINT(3);
208  void GetNormal(double xyz[3]);
210 
214  void GetVector1(double v1[3]);
215 
219  void GetVector2(double v2[3]);
220 
224  int GetSliceIndex();
225 
229  void SetSliceIndex(int index);
230 
234  double GetSlicePosition();
235 
239  void SetSlicePosition(double position);
240 
242 
245  void SetResliceInterpolate(int);
246  vtkGetMacro(ResliceInterpolate, int);
247  void SetResliceInterpolateToNearestNeighbour()
248  {
249  this->SetResliceInterpolate(VTK_NEAREST_RESLICE);
250  }
251  void SetResliceInterpolateToLinear() { this->SetResliceInterpolate(VTK_LINEAR_RESLICE); }
252  void SetResliceInterpolateToCubic() { this->SetResliceInterpolate(VTK_CUBIC_RESLICE); }
254 
259 
261 
265  vtkSetMacro(RestrictPlaneToVolume, vtkTypeBool);
266  vtkGetMacro(RestrictPlaneToVolume, vtkTypeBool);
267  vtkBooleanMacro(RestrictPlaneToVolume, vtkTypeBool);
269 
271 
276  vtkSetMacro(UserControlledLookupTable, vtkTypeBool);
277  vtkGetMacro(UserControlledLookupTable, vtkTypeBool);
278  vtkBooleanMacro(UserControlledLookupTable, vtkTypeBool);
280 
282 
288  vtkSetMacro(TextureInterpolate, vtkTypeBool);
289  vtkGetMacro(TextureInterpolate, vtkTypeBool);
290  vtkBooleanMacro(TextureInterpolate, vtkTypeBool);
292 
294 
299  vtkGetMacro(TextureVisibility, vtkTypeBool);
300  vtkBooleanMacro(TextureVisibility, vtkTypeBool);
302 
312 
320 
325  void UpdatePlacement(void) override;
326 
332 
334 
340  vtkGetObjectMacro(ColorMap, vtkImageMapToColors);
343 
345 
350  vtkGetObjectMacro(PlaneProperty, vtkProperty);
352  vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
354 
356 
361  vtkGetMacro(PlaneOrientation, int);
362  void SetPlaneOrientationToXAxes() { this->SetPlaneOrientation(0); }
363  void SetPlaneOrientationToYAxes() { this->SetPlaneOrientation(1); }
364  void SetPlaneOrientationToZAxes() { this->SetPlaneOrientation(2); }
366 
374 
376 
384  vtkGetObjectMacro(LookupTable, vtkLookupTable);
386 
388 
392  vtkSetMacro(DisplayText, vtkTypeBool);
393  vtkGetMacro(DisplayText, vtkTypeBool);
394  vtkBooleanMacro(DisplayText, vtkTypeBool);
396 
398 
402  vtkGetObjectMacro(CursorProperty, vtkProperty);
404 
406 
410  vtkGetObjectMacro(MarginProperty, vtkProperty);
412 
414 
418  vtkSetClampMacro(MarginSizeX, double, 0.0, 0.5);
419  vtkGetMacro(MarginSizeX, double);
420  vtkSetClampMacro(MarginSizeY, double, 0.0, 0.5);
421  vtkGetMacro(MarginSizeY, double);
423 
425 
431 
433 
437  vtkGetObjectMacro(TexturePlaneProperty, vtkProperty);
439 
441 
447  void SetWindowLevel(double window, double level, int copy = 0);
448  void GetWindowLevel(double wl[2]);
449  double GetWindow() { return this->CurrentWindow; }
450  double GetLevel() { return this->CurrentLevel; }
452 
457  int GetCursorData(double xyzv[4]);
458 
465 
467 
471  vtkGetVectorMacro(CurrentCursorPosition, double, 3);
473 
475 
480  vtkGetMacro(CurrentImageValue, double);
482 
484 
487  vtkGetObjectMacro(ResliceAxes, vtkMatrix4x4);
488  vtkGetObjectMacro(Reslice, vtkImageReslice);
490 
492 
499  vtkSetMacro(UseContinuousCursor, vtkTypeBool);
500  vtkGetMacro(UseContinuousCursor, vtkTypeBool);
501  vtkBooleanMacro(UseContinuousCursor, vtkTypeBool);
503 
505 
508  void SetInteraction(vtkTypeBool interact);
509  vtkGetMacro(Interaction, vtkTypeBool);
510  vtkBooleanMacro(Interaction, vtkTypeBool);
512 
514 
517  enum
518  {
519  VTK_CURSOR_ACTION = 0,
520  VTK_SLICE_MOTION_ACTION = 1,
521  VTK_WINDOW_LEVEL_ACTION = 2
522  };
523  vtkSetClampMacro(LeftButtonAction, int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
524  vtkGetMacro(LeftButtonAction, int);
525  vtkSetClampMacro(MiddleButtonAction, int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
526  vtkGetMacro(MiddleButtonAction, int);
527  vtkSetClampMacro(RightButtonAction, int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
528  vtkGetMacro(RightButtonAction, int);
530 
532 
540  enum
541  {
542  VTK_NO_MODIFIER = 0,
543  VTK_SHIFT_MODIFIER = 1,
544  VTK_CONTROL_MODIFIER = 2
545  };
546  vtkSetClampMacro(LeftButtonAutoModifier, int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
547  vtkGetMacro(LeftButtonAutoModifier, int);
548  vtkSetClampMacro(MiddleButtonAutoModifier, int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
549  vtkGetMacro(MiddleButtonAutoModifier, int);
550  vtkSetClampMacro(RightButtonAutoModifier, int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
551  vtkGetMacro(RightButtonAutoModifier, int);
553 
554 protected:
557 
559 
563 
567 
568  enum
569  {
570  VTK_NO_BUTTON = 0,
571  VTK_LEFT_BUTTON = 1,
572  VTK_MIDDLE_BUTTON = 2,
573  VTK_RIGHT_BUTTON = 3
574  };
576 
577  // Manage the state of the widget
578  int State;
580  {
581  Start = 0,
589  Outside
590  };
591 
592  // Handles the events
593  static void ProcessEvents(
594  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
595 
596  // internal utility method that adds observers to the RenderWindowInteractor
597  // so that our ProcessEvents is eventually called. this method is called
598  // by SetEnabled as well as SetInteraction
599  void AddObservers();
600 
601  // ProcessEvents() dispatches to these methods.
602  virtual void OnMouseMove();
603  virtual void OnLeftButtonDown();
604  virtual void OnLeftButtonUp();
605  virtual void OnMiddleButtonDown();
606  virtual void OnMiddleButtonUp();
607  virtual void OnRightButtonDown();
608  virtual void OnRightButtonUp();
609  void OnChar() override;
610 
611  virtual void StartCursor();
612  virtual void StopCursor();
613  virtual void StartSliceMotion();
614  virtual void StopSliceMotion();
615  virtual void StartWindowLevel();
616  virtual void StopWindowLevel();
617 
618  // controlling ivars
619  vtkTypeBool Interaction; // Is the widget responsive to mouse events
625  double CurrentLevel;
627  double InitialLevel;
634 
635  // The geometric representation of the plane and it's outline
639  void HighlightPlane(int highlight);
641 
642  // Re-builds the plane outline based on the plane source
644 
645  // Do the picking
647 
648  // Register internal Pickers within PickingManager
649  void RegisterPickers() override;
650 
651  // for negative window values.
652  void InvertTable();
653 
654  // Methods to manipulate the plane
655  void WindowLevel(int X, int Y);
656  void Push(double* p1, double* p2);
657  void Spin(double* p1, double* p2);
658  void Rotate(double* p1, double* p2, double* vpn);
659  void Scale(double* p1, double* p2, int X, int Y);
660  void Translate(double* p1, double* p2);
661 
671 
672  // Properties used to control the appearance of selected objects and
673  // the manipulator in general. The plane property is actually that for
674  // the outline. The TexturePlaneProperty can be used to control the
675  // lighting etc. of the resliced image data.
682 
683  // Reslice and texture management
684  void UpdatePlane();
686 
687  // The cross-hair cursor
690  double CurrentCursorPosition[3];
691  double CurrentImageValue; // Set to VTK_DOUBLE_MAX when invalid
693  void UpdateCursor(int, int);
694  void ActivateCursor(int);
695  int UpdateContinuousCursor(double* q);
696  int UpdateDiscreteCursor(double* q);
698 
699  // The text to display W/L, image data
702  void GenerateText();
704  void ActivateText(int);
705 
706  // Oblique reslice control
707  double RotateAxis[3];
708  double RadiusVector[3];
709  void AdjustState();
710 
711  // Visible margins to assist user interaction
717  void ActivateMargins(int);
718  double MarginSizeX;
719  double MarginSizeY;
720 
721 private:
722  vtkImagePlaneWidget(const vtkImagePlaneWidget&) = delete;
723  void operator=(const vtkImagePlaneWidget&) = delete;
724 };
725 
726 #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: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:48
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)
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 UpdatePlacement(void) override
Satisfies superclass API.
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: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:54
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:86
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(...)