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 =========================================================================*/
124 #ifndef vtkImagePlaneWidget_h
125 #define vtkImagePlaneWidget_h
126 
127 #include "vtkInteractionWidgetsModule.h" // For export macro
128 #include "vtkPolyDataSourceWidget.h"
129 
130 class vtkActor;
132 class vtkDataSetMapper;
133 class vtkImageData;
134 class vtkImageMapToColors;
135 class vtkImageReslice;
136 class vtkLookupTable;
137 class vtkMatrix4x4;
138 class vtkPlaneSource;
139 class vtkPoints;
140 class vtkPolyData;
141 class vtkProperty;
142 class vtkTextActor;
143 class vtkTextProperty;
144 class vtkTexture;
145 class vtkTransform;
146 
147 #define VTK_NEAREST_RESLICE 0
148 #define VTK_LINEAR_RESLICE 1
149 #define VTK_CUBIC_RESLICE 2
150 
151 // Private.
152 #define VTK_IMAGE_PLANE_WIDGET_MAX_TEXTBUFF 128
153 
154 class VTKINTERACTIONWIDGETS_EXPORT vtkImagePlaneWidget : public vtkPolyDataSourceWidget
155 {
156 public:
161 
163  void PrintSelf(ostream& os, vtkIndent indent) override;
164 
166 
169  void SetEnabled(int) override;
170  void PlaceWidget(double bounds[6]) override;
171  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
173  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
174  {
175  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
176  }
178 
183 
185 
188  void SetOrigin(double x, double y, double z);
189  void SetOrigin(double xyz[3]);
190  double* GetOrigin() VTK_SIZEHINT(3);
191  void GetOrigin(double xyz[3]);
193 
195 
198  void SetPoint1(double x, double y, double z);
199  void SetPoint1(double xyz[3]);
200  double* GetPoint1() VTK_SIZEHINT(3);
201  void GetPoint1(double xyz[3]);
203 
205 
208  void SetPoint2(double x, double y, double z);
209  void SetPoint2(double xyz[3]);
210  double* GetPoint2() VTK_SIZEHINT(3);
211  void GetPoint2(double xyz[3]);
213 
215 
218  double* GetCenter() VTK_SIZEHINT(3);
219  void GetCenter(double xyz[3]);
221 
223 
226  double* GetNormal() VTK_SIZEHINT(3);
227  void GetNormal(double xyz[3]);
229 
233  void GetVector1(double v1[3]);
234 
238  void GetVector2(double v2[3]);
239 
243  int GetSliceIndex();
244 
248  void SetSliceIndex(int index);
249 
253  double GetSlicePosition();
254 
258  void SetSlicePosition(double position);
259 
261 
264  void SetResliceInterpolate(int);
265  vtkGetMacro(ResliceInterpolate, int);
266  void SetResliceInterpolateToNearestNeighbour()
267  {
268  this->SetResliceInterpolate(VTK_NEAREST_RESLICE);
269  }
270  void SetResliceInterpolateToLinear() { this->SetResliceInterpolate(VTK_LINEAR_RESLICE); }
271  void SetResliceInterpolateToCubic() { this->SetResliceInterpolate(VTK_CUBIC_RESLICE); }
273 
278 
280 
284  vtkSetMacro(RestrictPlaneToVolume, vtkTypeBool);
285  vtkGetMacro(RestrictPlaneToVolume, vtkTypeBool);
286  vtkBooleanMacro(RestrictPlaneToVolume, vtkTypeBool);
288 
290 
295  vtkSetMacro(UserControlledLookupTable, vtkTypeBool);
296  vtkGetMacro(UserControlledLookupTable, vtkTypeBool);
297  vtkBooleanMacro(UserControlledLookupTable, vtkTypeBool);
299 
301 
307  vtkSetMacro(TextureInterpolate, vtkTypeBool);
308  vtkGetMacro(TextureInterpolate, vtkTypeBool);
309  vtkBooleanMacro(TextureInterpolate, vtkTypeBool);
311 
313 
318  vtkGetMacro(TextureVisibility, vtkTypeBool);
319  vtkBooleanMacro(TextureVisibility, vtkTypeBool);
321 
331 
339 
344  void UpdatePlacement(void) override;
345 
351 
353 
359  vtkGetObjectMacro(ColorMap, vtkImageMapToColors);
362 
364 
369  vtkGetObjectMacro(PlaneProperty, vtkProperty);
371  vtkGetObjectMacro(SelectedPlaneProperty, vtkProperty);
373 
375 
380  vtkGetMacro(PlaneOrientation, int);
381  void SetPlaneOrientationToXAxes() { this->SetPlaneOrientation(0); }
382  void SetPlaneOrientationToYAxes() { this->SetPlaneOrientation(1); }
383  void SetPlaneOrientationToZAxes() { this->SetPlaneOrientation(2); }
385 
393 
395 
403  vtkGetObjectMacro(LookupTable, vtkLookupTable);
405 
407 
411  vtkSetMacro(DisplayText, vtkTypeBool);
412  vtkGetMacro(DisplayText, vtkTypeBool);
413  vtkBooleanMacro(DisplayText, vtkTypeBool);
415 
417 
421  vtkGetObjectMacro(CursorProperty, vtkProperty);
423 
425 
429  vtkGetObjectMacro(MarginProperty, vtkProperty);
431 
433 
437  vtkSetClampMacro(MarginSizeX, double, 0.0, 0.5);
438  vtkGetMacro(MarginSizeX, double);
439  vtkSetClampMacro(MarginSizeY, double, 0.0, 0.5);
440  vtkGetMacro(MarginSizeY, double);
442 
444 
450 
452 
456  vtkGetObjectMacro(TexturePlaneProperty, vtkProperty);
458 
460 
466  void SetWindowLevel(double window, double level, int copy = 0);
467  void GetWindowLevel(double wl[2]);
468  double GetWindow() { return this->CurrentWindow; }
469  double GetLevel() { return this->CurrentLevel; }
471 
476  int GetCursorData(double xyzv[4]);
477 
484 
486 
490  vtkGetVectorMacro(CurrentCursorPosition, double, 3);
492 
494 
499  vtkGetMacro(CurrentImageValue, double);
501 
503 
506  vtkGetObjectMacro(ResliceAxes, vtkMatrix4x4);
507  vtkGetObjectMacro(Reslice, vtkImageReslice);
509 
511 
518  vtkSetMacro(UseContinuousCursor, vtkTypeBool);
519  vtkGetMacro(UseContinuousCursor, vtkTypeBool);
520  vtkBooleanMacro(UseContinuousCursor, vtkTypeBool);
522 
524 
527  void SetInteraction(vtkTypeBool interact);
528  vtkGetMacro(Interaction, vtkTypeBool);
529  vtkBooleanMacro(Interaction, vtkTypeBool);
531 
533 
536  enum
537  {
538  VTK_CURSOR_ACTION = 0,
539  VTK_SLICE_MOTION_ACTION = 1,
540  VTK_WINDOW_LEVEL_ACTION = 2
541  };
542  vtkSetClampMacro(LeftButtonAction, int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
543  vtkGetMacro(LeftButtonAction, int);
544  vtkSetClampMacro(MiddleButtonAction, int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
545  vtkGetMacro(MiddleButtonAction, int);
546  vtkSetClampMacro(RightButtonAction, int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
547  vtkGetMacro(RightButtonAction, int);
549 
551 
559  enum
560  {
561  VTK_NO_MODIFIER = 0,
562  VTK_SHIFT_MODIFIER = 1,
563  VTK_CONTROL_MODIFIER = 2
564  };
565  vtkSetClampMacro(LeftButtonAutoModifier, int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
566  vtkGetMacro(LeftButtonAutoModifier, int);
567  vtkSetClampMacro(MiddleButtonAutoModifier, int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
568  vtkGetMacro(MiddleButtonAutoModifier, int);
569  vtkSetClampMacro(RightButtonAutoModifier, int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
570  vtkGetMacro(RightButtonAutoModifier, int);
572 
573 protected:
576 
578 
582 
586 
587  enum
588  {
589  VTK_NO_BUTTON = 0,
590  VTK_LEFT_BUTTON = 1,
591  VTK_MIDDLE_BUTTON = 2,
592  VTK_RIGHT_BUTTON = 3
593  };
595 
596  // Manage the state of the widget
597  int State;
599  {
600  Start = 0,
608  Outside
609  };
610 
611  // Handles the events
612  static void ProcessEvents(
613  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
614 
615  // internal utility method that adds observers to the RenderWindowInteractor
616  // so that our ProcessEvents is eventually called. this method is called
617  // by SetEnabled as well as SetInteraction
618  void AddObservers();
619 
620  // ProcessEvents() dispatches to these methods.
621  virtual void OnMouseMove();
622  virtual void OnLeftButtonDown();
623  virtual void OnLeftButtonUp();
624  virtual void OnMiddleButtonDown();
625  virtual void OnMiddleButtonUp();
626  virtual void OnRightButtonDown();
627  virtual void OnRightButtonUp();
628  void OnChar() override;
629 
630  virtual void StartCursor();
631  virtual void StopCursor();
632  virtual void StartSliceMotion();
633  virtual void StopSliceMotion();
634  virtual void StartWindowLevel();
635  virtual void StopWindowLevel();
636 
637  // controlling ivars
638  vtkTypeBool Interaction; // Is the widget responsive to mouse events
644  double CurrentLevel;
646  double InitialLevel;
653 
654  // The geometric representation of the plane and it's outline
658  void HighlightPlane(int highlight);
660 
661  // Re-builds the plane outline based on the plane source
663 
664  // Do the picking
666 
667  // Register internal Pickers within PickingManager
668  void RegisterPickers() override;
669 
670  // for negative window values.
671  void InvertTable();
672 
673  // Methods to manipulate the plane
674  void WindowLevel(int X, int Y);
675  void Push(double* p1, double* p2);
676  void Spin(double* p1, double* p2);
677  void Rotate(double* p1, double* p2, double* vpn);
678  void Scale(double* p1, double* p2, int X, int Y);
679  void Translate(double* p1, double* p2);
680 
690 
691  // Properties used to control the appearance of selected objects and
692  // the manipulator in general. The plane property is actually that for
693  // the outline. The TexturePlaneProperty can be used to control the
694  // lighting etc. of the resliced image data.
701 
702  // Reslice and texture management
703  void UpdatePlane();
705 
706  // The cross-hair cursor
709  double CurrentCursorPosition[3];
710  double CurrentImageValue; // Set to VTK_DOUBLE_MAX when invalid
712  void UpdateCursor(int, int);
713  void ActivateCursor(int);
714  int UpdateContinuousCursor(double* q);
715  int UpdateDiscreteCursor(double* q);
717 
718  // The text to display W/L, image data
721  void GenerateText();
723  void ActivateText(int);
724 
725  // Oblique reslice control
726  double RotateAxis[3];
727  double RadiusVector[3];
728  void AdjustState();
729 
730  // Visible margins to assist user interaction
736  void ActivateMargins(int);
737  double MarginSizeX;
738  double MarginSizeY;
739 
740 private:
741  vtkImagePlaneWidget(const vtkImagePlaneWidget&) = delete;
742  void operator=(const vtkImagePlaneWidget&) = delete;
743 };
744 
745 #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:155
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:157
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:113
map scalar values into colors via a lookup table
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:145
abstract base class for most VTK objects
Definition: vtkObject.h:73
create an array of quadrilaterals located in a plane
represent and manipulate 3D points
Definition: vtkPoints.h:143
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:195
represent surface properties of a geometric object
Definition: vtkProperty.h:171
An actor that displays text.
Definition: vtkTextActor.h:160
represent text properties.
handles properties associated with a texture map
Definition: vtkTexture.h:175
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:164
@ 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(...)