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 =========================================================================*/
114 #ifndef vtkImagePlaneWidget_h
115 #define vtkImagePlaneWidget_h
116 
117 #include "vtkInteractionWidgetsModule.h" // For export macro
118 #include "vtkPolyDataSourceWidget.h"
119 
120 class vtkActor;
122 class vtkDataSetMapper;
123 class vtkImageData;
124 class vtkImageMapToColors;
125 class vtkImageReslice;
126 class vtkLookupTable;
127 class vtkMatrix4x4;
128 class vtkPlaneSource;
129 class vtkPoints;
130 class vtkPolyData;
131 class vtkProperty;
132 class vtkTextActor;
133 class vtkTextProperty;
134 class vtkTexture;
135 class vtkTransform;
136 
137 #define VTK_NEAREST_RESLICE 0
138 #define VTK_LINEAR_RESLICE 1
139 #define VTK_CUBIC_RESLICE 2
140 
141 // Private.
142 #define VTK_IMAGE_PLANE_WIDGET_MAX_TEXTBUFF 128
143 
144 class VTKINTERACTIONWIDGETS_EXPORT vtkImagePlaneWidget : public vtkPolyDataSourceWidget
145 {
146 public:
151 
153  void PrintSelf(ostream& os, vtkIndent indent) override;
154 
156 
159  void SetEnabled(int) override;
160  void PlaceWidget(double bounds[6]) override;
161  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
163  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
164  {
165  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
166  }
168 
173 
175 
178  void SetOrigin(double x, double y, double z);
179  void SetOrigin(double xyz[3]);
180  double* GetOrigin() VTK_SIZEHINT(3);
181  void GetOrigin(double xyz[3]);
183 
185 
188  void SetPoint1(double x, double y, double z);
189  void SetPoint1(double xyz[3]);
190  double* GetPoint1() VTK_SIZEHINT(3);
191  void GetPoint1(double xyz[3]);
193 
195 
198  void SetPoint2(double x, double y, double z);
199  void SetPoint2(double xyz[3]);
200  double* GetPoint2() VTK_SIZEHINT(3);
201  void GetPoint2(double xyz[3]);
203 
205 
208  double* GetCenter() VTK_SIZEHINT(3);
209  void GetCenter(double xyz[3]);
211 
213 
216  double* GetNormal() VTK_SIZEHINT(3);
217  void GetNormal(double xyz[3]);
219 
223  void GetVector1(double v1[3]);
224 
228  void GetVector2(double v2[3]);
229 
233  int GetSliceIndex();
234 
238  void SetSliceIndex(int index);
239 
243  double GetSlicePosition();
244 
248  void SetSlicePosition(double position);
249 
251 
254  void SetResliceInterpolate(int);
255  vtkGetMacro(ResliceInterpolate, int);
256  void SetResliceInterpolateToNearestNeighbour()
257  {
258  this->SetResliceInterpolate(VTK_NEAREST_RESLICE);
259  }
260  void SetResliceInterpolateToLinear() { this->SetResliceInterpolate(VTK_LINEAR_RESLICE); }
261  void SetResliceInterpolateToCubic() { this->SetResliceInterpolate(VTK_CUBIC_RESLICE); }
263 
268 
270 
274  vtkSetMacro(RestrictPlaneToVolume, vtkTypeBool);
275  vtkGetMacro(RestrictPlaneToVolume, vtkTypeBool);
276  vtkBooleanMacro(RestrictPlaneToVolume, vtkTypeBool);
278 
280 
285  vtkSetMacro(UserControlledLookupTable, vtkTypeBool);
286  vtkGetMacro(UserControlledLookupTable, vtkTypeBool);
287  vtkBooleanMacro(UserControlledLookupTable, vtkTypeBool);
289 
291 
297  vtkSetMacro(TextureInterpolate, vtkTypeBool);
298  vtkGetMacro(TextureInterpolate, vtkTypeBool);
299  vtkBooleanMacro(TextureInterpolate, vtkTypeBool);
301 
303 
308  vtkGetMacro(TextureVisibility, vtkTypeBool);
309  vtkBooleanMacro(TextureVisibility, vtkTypeBool);
311 
321 
329 
334  void UpdatePlacement(void) override;
335 
341 
343 
349  vtkGetObjectMacro(ColorMap, vtkImageMapToColors);
352 
354 
359  vtkGetObjectMacro(PlaneProperty, vtkProperty);
361  vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
363 
365 
370  vtkGetMacro(PlaneOrientation, int);
371  void SetPlaneOrientationToXAxes() { this->SetPlaneOrientation(0); }
372  void SetPlaneOrientationToYAxes() { this->SetPlaneOrientation(1); }
373  void SetPlaneOrientationToZAxes() { this->SetPlaneOrientation(2); }
375 
383 
385 
393  vtkGetObjectMacro(LookupTable, vtkLookupTable);
395 
397 
401  vtkSetMacro(DisplayText, vtkTypeBool);
402  vtkGetMacro(DisplayText, vtkTypeBool);
403  vtkBooleanMacro(DisplayText, vtkTypeBool);
405 
407 
411  vtkGetObjectMacro(CursorProperty, vtkProperty);
413 
415 
419  vtkGetObjectMacro(MarginProperty, vtkProperty);
421 
423 
427  vtkSetClampMacro(MarginSizeX, double, 0.0, 0.5);
428  vtkGetMacro(MarginSizeX, double);
429  vtkSetClampMacro(MarginSizeY, double, 0.0, 0.5);
430  vtkGetMacro(MarginSizeY, double);
432 
434 
440 
442 
446  vtkGetObjectMacro(TexturePlaneProperty, vtkProperty);
448 
450 
456  void SetWindowLevel(double window, double level, int copy = 0);
457  void GetWindowLevel(double wl[2]);
458  double GetWindow() { return this->CurrentWindow; }
459  double GetLevel() { return this->CurrentLevel; }
461 
466  int GetCursorData(double xyzv[4]);
467 
474 
476 
480  vtkGetVectorMacro(CurrentCursorPosition, double, 3);
482 
484 
489  vtkGetMacro(CurrentImageValue, double);
491 
493 
496  vtkGetObjectMacro(ResliceAxes, vtkMatrix4x4);
497  vtkGetObjectMacro(Reslice, vtkImageReslice);
499 
501 
508  vtkSetMacro(UseContinuousCursor, vtkTypeBool);
509  vtkGetMacro(UseContinuousCursor, vtkTypeBool);
510  vtkBooleanMacro(UseContinuousCursor, vtkTypeBool);
512 
514 
517  void SetInteraction(vtkTypeBool interact);
518  vtkGetMacro(Interaction, vtkTypeBool);
519  vtkBooleanMacro(Interaction, vtkTypeBool);
521 
523 
526  enum
527  {
528  VTK_CURSOR_ACTION = 0,
529  VTK_SLICE_MOTION_ACTION = 1,
530  VTK_WINDOW_LEVEL_ACTION = 2
531  };
532  vtkSetClampMacro(LeftButtonAction, int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
533  vtkGetMacro(LeftButtonAction, int);
534  vtkSetClampMacro(MiddleButtonAction, int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
535  vtkGetMacro(MiddleButtonAction, int);
536  vtkSetClampMacro(RightButtonAction, int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
537  vtkGetMacro(RightButtonAction, int);
539 
541 
549  enum
550  {
551  VTK_NO_MODIFIER = 0,
552  VTK_SHIFT_MODIFIER = 1,
553  VTK_CONTROL_MODIFIER = 2
554  };
555  vtkSetClampMacro(LeftButtonAutoModifier, int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
556  vtkGetMacro(LeftButtonAutoModifier, int);
557  vtkSetClampMacro(MiddleButtonAutoModifier, int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
558  vtkGetMacro(MiddleButtonAutoModifier, int);
559  vtkSetClampMacro(RightButtonAutoModifier, int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
560  vtkGetMacro(RightButtonAutoModifier, int);
562 
563 protected:
566 
568 
572 
576 
577  enum
578  {
579  VTK_NO_BUTTON = 0,
580  VTK_LEFT_BUTTON = 1,
581  VTK_MIDDLE_BUTTON = 2,
582  VTK_RIGHT_BUTTON = 3
583  };
585 
586  // Manage the state of the widget
587  int State;
589  {
590  Start = 0,
598  Outside
599  };
600 
601  // Handles the events
602  static void ProcessEvents(
603  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
604 
605  // internal utility method that adds observers to the RenderWindowInteractor
606  // so that our ProcessEvents is eventually called. this method is called
607  // by SetEnabled as well as SetInteraction
608  void AddObservers();
609 
610  // ProcessEvents() dispatches to these methods.
611  virtual void OnMouseMove();
612  virtual void OnLeftButtonDown();
613  virtual void OnLeftButtonUp();
614  virtual void OnMiddleButtonDown();
615  virtual void OnMiddleButtonUp();
616  virtual void OnRightButtonDown();
617  virtual void OnRightButtonUp();
618  void OnChar() override;
619 
620  virtual void StartCursor();
621  virtual void StopCursor();
622  virtual void StartSliceMotion();
623  virtual void StopSliceMotion();
624  virtual void StartWindowLevel();
625  virtual void StopWindowLevel();
626 
627  // controlling ivars
628  vtkTypeBool Interaction; // Is the widget responsive to mouse events
634  double CurrentLevel;
636  double InitialLevel;
643 
644  // The geometric representation of the plane and it's outline
648  void HighlightPlane(int highlight);
650 
651  // Re-builds the plane outline based on the plane source
653 
654  // Do the picking
656 
657  // Register internal Pickers within PickingManager
658  void RegisterPickers() override;
659 
660  // for negative window values.
661  void InvertTable();
662 
663  // Methods to manipulate the plane
664  void WindowLevel(int X, int Y);
665  void Push(double* p1, double* p2);
666  void Spin(double* p1, double* p2);
667  void Rotate(double* p1, double* p2, double* vpn);
668  void Scale(double* p1, double* p2, int X, int Y);
669  void Translate(double* p1, double* p2);
670 
680 
681  // Properties used to control the appearance of selected objects and
682  // the manipulator in general. The plane property is actually that for
683  // the outline. The TexturePlaneProperty can be used to control the
684  // lighting etc. of the resliced image data.
691 
692  // Reslice and texture management
693  void UpdatePlane();
695 
696  // The cross-hair cursor
699  double CurrentCursorPosition[3];
700  double CurrentImageValue; // Set to VTK_DOUBLE_MAX when invalid
702  void UpdateCursor(int, int);
703  void ActivateCursor(int);
704  int UpdateContinuousCursor(double* q);
705  int UpdateDiscreteCursor(double* q);
707 
708  // The text to display W/L, image data
711  void GenerateText();
713  void ActivateText(int);
714 
715  // Oblique reslice control
716  double RotateAxis[3];
717  double RadiusVector[3];
718  void AdjustState();
719 
720  // Visible margins to assist user interaction
726  void ActivateMargins(int);
727  double MarginSizeX;
728  double MarginSizeY;
729 
730 private:
731  vtkImagePlaneWidget(const vtkImagePlaneWidget&) = delete;
732  void operator=(const vtkImagePlaneWidget&) = delete;
733 };
734 
735 #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: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: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(...)