VTK  9.2.6
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 =========================================================================*/
123 #ifndef vtkImagePlaneWidget_h
124 #define vtkImagePlaneWidget_h
125 
126 #include "vtkInteractionWidgetsModule.h" // For export macro
127 #include "vtkPolyDataSourceWidget.h"
128 
129 class vtkActor;
131 class vtkDataSetMapper;
132 class vtkImageData;
133 class vtkImageMapToColors;
134 class vtkImageReslice;
135 class vtkLookupTable;
136 class vtkMatrix4x4;
137 class vtkPlaneSource;
138 class vtkPoints;
139 class vtkPolyData;
140 class vtkProperty;
141 class vtkTextActor;
142 class vtkTextProperty;
143 class vtkTexture;
144 class vtkTransform;
145 
146 #define VTK_NEAREST_RESLICE 0
147 #define VTK_LINEAR_RESLICE 1
148 #define VTK_CUBIC_RESLICE 2
149 
150 // Private.
151 #define VTK_IMAGE_PLANE_WIDGET_MAX_TEXTBUFF 128
152 
153 class VTKINTERACTIONWIDGETS_EXPORT vtkImagePlaneWidget : public vtkPolyDataSourceWidget
154 {
155 public:
160 
162  void PrintSelf(ostream& os, vtkIndent indent) override;
163 
165 
168  void SetEnabled(int) override;
169  void PlaceWidget(double bounds[6]) override;
170  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
172  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
173  {
174  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
175  }
177 
182 
184 
187  void SetOrigin(double x, double y, double z);
188  void SetOrigin(double xyz[3]);
189  double* GetOrigin() VTK_SIZEHINT(3);
190  void GetOrigin(double xyz[3]);
192 
194 
197  void SetPoint1(double x, double y, double z);
198  void SetPoint1(double xyz[3]);
199  double* GetPoint1() VTK_SIZEHINT(3);
200  void GetPoint1(double xyz[3]);
202 
204 
207  void SetPoint2(double x, double y, double z);
208  void SetPoint2(double xyz[3]);
209  double* GetPoint2() VTK_SIZEHINT(3);
210  void GetPoint2(double xyz[3]);
212 
214 
217  double* GetCenter() VTK_SIZEHINT(3);
218  void GetCenter(double xyz[3]);
220 
222 
225  double* GetNormal() VTK_SIZEHINT(3);
226  void GetNormal(double xyz[3]);
228 
232  void GetVector1(double v1[3]);
233 
237  void GetVector2(double v2[3]);
238 
242  int GetSliceIndex();
243 
247  void SetSliceIndex(int index);
248 
252  double GetSlicePosition();
253 
257  void SetSlicePosition(double position);
258 
260 
263  void SetResliceInterpolate(int);
264  vtkGetMacro(ResliceInterpolate, int);
265  void SetResliceInterpolateToNearestNeighbour()
266  {
267  this->SetResliceInterpolate(VTK_NEAREST_RESLICE);
268  }
269  void SetResliceInterpolateToLinear() { this->SetResliceInterpolate(VTK_LINEAR_RESLICE); }
270  void SetResliceInterpolateToCubic() { this->SetResliceInterpolate(VTK_CUBIC_RESLICE); }
272 
277 
279 
283  vtkSetMacro(RestrictPlaneToVolume, vtkTypeBool);
284  vtkGetMacro(RestrictPlaneToVolume, vtkTypeBool);
285  vtkBooleanMacro(RestrictPlaneToVolume, vtkTypeBool);
287 
289 
294  vtkSetMacro(UserControlledLookupTable, vtkTypeBool);
295  vtkGetMacro(UserControlledLookupTable, vtkTypeBool);
296  vtkBooleanMacro(UserControlledLookupTable, vtkTypeBool);
298 
300 
306  vtkSetMacro(TextureInterpolate, vtkTypeBool);
307  vtkGetMacro(TextureInterpolate, vtkTypeBool);
308  vtkBooleanMacro(TextureInterpolate, vtkTypeBool);
310 
312 
317  vtkGetMacro(TextureVisibility, vtkTypeBool);
318  vtkBooleanMacro(TextureVisibility, vtkTypeBool);
320 
330 
338 
343  void UpdatePlacement(void) override;
344 
350 
352 
358  vtkGetObjectMacro(ColorMap, vtkImageMapToColors);
361 
363 
368  vtkGetObjectMacro(PlaneProperty, vtkProperty);
370  vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
372 
374 
379  vtkGetMacro(PlaneOrientation, int);
380  void SetPlaneOrientationToXAxes() { this->SetPlaneOrientation(0); }
381  void SetPlaneOrientationToYAxes() { this->SetPlaneOrientation(1); }
382  void SetPlaneOrientationToZAxes() { this->SetPlaneOrientation(2); }
384 
392 
394 
402  vtkGetObjectMacro(LookupTable, vtkLookupTable);
404 
406 
410  vtkSetMacro(DisplayText, vtkTypeBool);
411  vtkGetMacro(DisplayText, vtkTypeBool);
412  vtkBooleanMacro(DisplayText, vtkTypeBool);
414 
416 
420  vtkGetObjectMacro(CursorProperty, vtkProperty);
422 
424 
428  vtkGetObjectMacro(MarginProperty, vtkProperty);
430 
432 
436  vtkSetClampMacro(MarginSizeX, double, 0.0, 0.5);
437  vtkGetMacro(MarginSizeX, double);
438  vtkSetClampMacro(MarginSizeY, double, 0.0, 0.5);
439  vtkGetMacro(MarginSizeY, double);
441 
443 
449 
451 
455  vtkGetObjectMacro(TexturePlaneProperty, vtkProperty);
457 
459 
465  void SetWindowLevel(double window, double level, int copy = 0);
466  void GetWindowLevel(double wl[2]);
467  double GetWindow() { return this->CurrentWindow; }
468  double GetLevel() { return this->CurrentLevel; }
470 
475  int GetCursorData(double xyzv[4]);
476 
483 
485 
489  vtkGetVectorMacro(CurrentCursorPosition, double, 3);
491 
493 
498  vtkGetMacro(CurrentImageValue, double);
500 
502 
505  vtkGetObjectMacro(ResliceAxes, vtkMatrix4x4);
506  vtkGetObjectMacro(Reslice, vtkImageReslice);
508 
510 
517  vtkSetMacro(UseContinuousCursor, vtkTypeBool);
518  vtkGetMacro(UseContinuousCursor, vtkTypeBool);
519  vtkBooleanMacro(UseContinuousCursor, vtkTypeBool);
521 
523 
526  void SetInteraction(vtkTypeBool interact);
527  vtkGetMacro(Interaction, vtkTypeBool);
528  vtkBooleanMacro(Interaction, vtkTypeBool);
530 
532 
535  enum
536  {
537  VTK_CURSOR_ACTION = 0,
538  VTK_SLICE_MOTION_ACTION = 1,
539  VTK_WINDOW_LEVEL_ACTION = 2
540  };
541  vtkSetClampMacro(LeftButtonAction, int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
542  vtkGetMacro(LeftButtonAction, int);
543  vtkSetClampMacro(MiddleButtonAction, int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
544  vtkGetMacro(MiddleButtonAction, int);
545  vtkSetClampMacro(RightButtonAction, int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
546  vtkGetMacro(RightButtonAction, int);
548 
550 
558  enum
559  {
560  VTK_NO_MODIFIER = 0,
561  VTK_SHIFT_MODIFIER = 1,
562  VTK_CONTROL_MODIFIER = 2
563  };
564  vtkSetClampMacro(LeftButtonAutoModifier, int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
565  vtkGetMacro(LeftButtonAutoModifier, int);
566  vtkSetClampMacro(MiddleButtonAutoModifier, int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
567  vtkGetMacro(MiddleButtonAutoModifier, int);
568  vtkSetClampMacro(RightButtonAutoModifier, int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
569  vtkGetMacro(RightButtonAutoModifier, int);
571 
572 protected:
575 
577 
581 
585 
586  enum
587  {
588  VTK_NO_BUTTON = 0,
589  VTK_LEFT_BUTTON = 1,
590  VTK_MIDDLE_BUTTON = 2,
591  VTK_RIGHT_BUTTON = 3
592  };
594 
595  // Manage the state of the widget
596  int State;
598  {
599  Start = 0,
607  Outside
608  };
609 
610  // Handles the events
611  static void ProcessEvents(
612  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
613 
614  // internal utility method that adds observers to the RenderWindowInteractor
615  // so that our ProcessEvents is eventually called. this method is called
616  // by SetEnabled as well as SetInteraction
617  void AddObservers();
618 
619  // ProcessEvents() dispatches to these methods.
620  virtual void OnMouseMove();
621  virtual void OnLeftButtonDown();
622  virtual void OnLeftButtonUp();
623  virtual void OnMiddleButtonDown();
624  virtual void OnMiddleButtonUp();
625  virtual void OnRightButtonDown();
626  virtual void OnRightButtonUp();
627  void OnChar() override;
628 
629  virtual void StartCursor();
630  virtual void StopCursor();
631  virtual void StartSliceMotion();
632  virtual void StopSliceMotion();
633  virtual void StartWindowLevel();
634  virtual void StopWindowLevel();
635 
636  // controlling ivars
637  vtkTypeBool Interaction; // Is the widget responsive to mouse events
643  double CurrentLevel;
645  double InitialLevel;
652 
653  // The geometric representation of the plane and it's outline
657  void HighlightPlane(int highlight);
659 
660  // Re-builds the plane outline based on the plane source
662 
663  // Do the picking
665 
666  // Register internal Pickers within PickingManager
667  void RegisterPickers() override;
668 
669  // for negative window values.
670  void InvertTable();
671 
672  // Methods to manipulate the plane
673  void WindowLevel(int X, int Y);
674  void Push(double* p1, double* p2);
675  void Spin(double* p1, double* p2);
676  void Rotate(double* p1, double* p2, double* vpn);
677  void Scale(double* p1, double* p2, int X, int Y);
678  void Translate(double* p1, double* p2);
679 
689 
690  // Properties used to control the appearance of selected objects and
691  // the manipulator in general. The plane property is actually that for
692  // the outline. The TexturePlaneProperty can be used to control the
693  // lighting etc. of the resliced image data.
700 
701  // Reslice and texture management
702  void UpdatePlane();
704 
705  // The cross-hair cursor
708  double CurrentCursorPosition[3];
709  double CurrentImageValue; // Set to VTK_DOUBLE_MAX when invalid
711  void UpdateCursor(int, int);
712  void ActivateCursor(int);
713  int UpdateContinuousCursor(double* q);
714  int UpdateDiscreteCursor(double* q);
716 
717  // The text to display W/L, image data
720  void GenerateText();
722  void ActivateText(int);
723 
724  // Oblique reslice control
725  double RotateAxis[3];
726  double RadiusVector[3];
727  void AdjustState();
728 
729  // Visible margins to assist user interaction
735  void ActivateMargins(int);
736  double MarginSizeX;
737  double MarginSizeY;
738 
739 private:
740  vtkImagePlaneWidget(const vtkImagePlaneWidget&) = delete;
741  void operator=(const vtkImagePlaneWidget&) = delete;
742 };
743 
744 #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:61
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:63
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:49
map scalar values into colors via a lookup table
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:51
abstract base class for most VTK objects
Definition: vtkObject.h:72
create an array of quadrilaterals located in a plane
represent and manipulate 3D points
Definition: vtkPoints.h:49
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:100
represent surface properties of a geometric object
Definition: vtkProperty.h:77
An actor that displays text.
Definition: vtkTextActor.h:66
represent text properties.
handles properties associated with a texture map
Definition: vtkTexture.h:78
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:70
@ 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(...)