VTK
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 =========================================================================*/
106 #ifndef vtkImagePlaneWidget_h
107 #define vtkImagePlaneWidget_h
108 
109 #include "vtkInteractionWidgetsModule.h" // For export macro
110 #include "vtkPolyDataSourceWidget.h"
111 
112 class vtkActor;
114 class vtkDataSetMapper;
115 class vtkImageData;
116 class vtkImageMapToColors;
117 class vtkImageReslice;
118 class vtkLookupTable;
119 class vtkMatrix4x4;
120 class vtkPlaneSource;
121 class vtkPoints;
122 class vtkPolyData;
123 class vtkProperty;
124 class vtkTextActor;
125 class vtkTextProperty;
126 class vtkTexture;
127 class vtkTransform;
128 
129 #define VTK_NEAREST_RESLICE 0
130 #define VTK_LINEAR_RESLICE 1
131 #define VTK_CUBIC_RESLICE 2
132 
133 class VTKINTERACTIONWIDGETS_EXPORT vtkImagePlaneWidget : public vtkPolyDataSourceWidget
134 {
135 public:
139  static vtkImagePlaneWidget *New();
140 
142  void PrintSelf(ostream& os, vtkIndent indent);
143 
145 
148  virtual void SetEnabled(int);
149  virtual void PlaceWidget(double bounds[6]);
150  void PlaceWidget()
151  {this->Superclass::PlaceWidget();}
152  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
153  double zmin, double zmax)
154  {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
156 
161 
163 
166  void SetOrigin(double x, double y, double z);
167  void SetOrigin(double xyz[3]);
168  double* GetOrigin();
169  void GetOrigin(double xyz[3]);
171 
173 
176  void SetPoint1(double x, double y, double z);
177  void SetPoint1(double xyz[3]);
178  double* GetPoint1();
179  void GetPoint1(double xyz[3]);
181 
183 
186  void SetPoint2(double x, double y, double z);
187  void SetPoint2(double xyz[3]);
188  double* GetPoint2();
189  void GetPoint2(double xyz[3]);
191 
193 
196  double* GetCenter();
197  void GetCenter(double xyz[3]);
199 
201 
204  double* GetNormal();
205  void GetNormal(double xyz[3]);
207 
211  void GetVector1(double v1[3]);
212 
216  void GetVector2(double v2[3]);
217 
221  int GetSliceIndex();
222 
226  void SetSliceIndex(int index);
227 
231  double GetSlicePosition();
232 
236  void SetSlicePosition(double position);
237 
239 
242  void SetResliceInterpolate(int);
243  vtkGetMacro(ResliceInterpolate,int);
245  { this->SetResliceInterpolate(VTK_NEAREST_RESLICE); }
247  { this->SetResliceInterpolate(VTK_LINEAR_RESLICE); }
249  { this->SetResliceInterpolate(VTK_CUBIC_RESLICE); }
251 
255  vtkImageData* GetResliceOutput();
256 
258 
262  vtkSetMacro(RestrictPlaneToVolume,int);
263  vtkGetMacro(RestrictPlaneToVolume,int);
264  vtkBooleanMacro(RestrictPlaneToVolume,int);
266 
268 
273  vtkSetMacro(UserControlledLookupTable,int);
274  vtkGetMacro(UserControlledLookupTable,int);
275  vtkBooleanMacro(UserControlledLookupTable,int);
277 
279 
285  vtkSetMacro(TextureInterpolate,int);
286  vtkGetMacro(TextureInterpolate,int);
287  vtkBooleanMacro(TextureInterpolate,int);
289 
291 
295  virtual void SetTextureVisibility(int);
296  vtkGetMacro(TextureVisibility,int);
297  vtkBooleanMacro(TextureVisibility,int);
299 
308  void GetPolyData(vtkPolyData *pd);
309 
317 
322  void UpdatePlacement(void);
323 
328  vtkTexture *GetTexture();
329 
331 
337  vtkGetObjectMacro(ColorMap, vtkImageMapToColors);
338  virtual void SetColorMap(vtkImageMapToColors *);
340 
342 
346  virtual void SetPlaneProperty(vtkProperty*);
347  vtkGetObjectMacro(PlaneProperty,vtkProperty);
348  virtual void SetSelectedPlaneProperty(vtkProperty*);
349  vtkGetObjectMacro(SelectedPlaneProperty,vtkProperty);
351 
353 
357  void SetPlaneOrientation(int);
358  vtkGetMacro(PlaneOrientation,int);
360  { this->SetPlaneOrientation(0); }
362  { this->SetPlaneOrientation(1); }
364  { this->SetPlaneOrientation(2); }
366 
373  void SetPicker(vtkAbstractPropPicker*);
374 
376 
383  virtual void SetLookupTable(vtkLookupTable*);
384  vtkGetObjectMacro(LookupTable,vtkLookupTable);
386 
388 
392  vtkSetMacro(DisplayText,int);
393  vtkGetMacro(DisplayText,int);
394  vtkBooleanMacro(DisplayText,int);
396 
398 
401  virtual void SetCursorProperty(vtkProperty*);
402  vtkGetObjectMacro(CursorProperty,vtkProperty);
404 
406 
409  virtual void SetMarginProperty(vtkProperty*);
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 
428  void SetTextProperty(vtkTextProperty* tprop);
429  vtkTextProperty* GetTextProperty();
431 
433 
436  virtual void SetTexturePlaneProperty(vtkProperty*);
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 
464  int GetCursorDataStatus();
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,int);
500  vtkGetMacro(UseContinuousCursor,int);
501  vtkBooleanMacro(UseContinuousCursor,int);
503 
505 
508  void SetInteraction(int interact);
509  vtkGetMacro(Interaction,int);
510  vtkBooleanMacro(Interaction,int);
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(vtkObject* object,
594  unsigned long event,
595  void* clientdata,
596  void* calldata);
597 
598  // internal utility method that adds observers to the RenderWindowInteractor
599  // so that our ProcessEvents is eventually called. this method is called
600  // by SetEnabled as well as SetInteraction
601  void AddObservers();
602 
603  // ProcessEvents() dispatches to these methods.
604  virtual void OnMouseMove();
605  virtual void OnLeftButtonDown();
606  virtual void OnLeftButtonUp();
607  virtual void OnMiddleButtonDown();
608  virtual void OnMiddleButtonUp();
609  virtual void OnRightButtonDown();
610  virtual void OnRightButtonUp();
611  virtual void OnChar();
612 
613  virtual void StartCursor();
614  virtual void StopCursor();
615  virtual void StartSliceMotion();
616  virtual void StopSliceMotion();
617  virtual void StartWindowLevel();
618  virtual void StopWindowLevel();
619 
620  // controlling ivars
621  int Interaction; // Is the widget responsive to mouse events
627  double CurrentLevel;
629  double InitialLevel;
636 
637  // The geometric represenation of the plane and it's outline
641  void HighlightPlane(int highlight);
642  void GeneratePlaneOutline();
643 
644  // Re-builds the plane outline based on the plane source
645  void BuildRepresentation();
646 
647  // Do the picking
649 
650  // Register internal Pickers within PickingManager
651  virtual void RegisterPickers();
652 
653  // for negative window values.
654  void InvertTable();
655 
656  // Methods to manipulate the plane
657  void WindowLevel(int X, int Y);
658  void Push(double *p1, double *p2);
659  void Spin(double *p1, double *p2);
660  void Rotate(double *p1, double *p2, double *vpn);
661  void Scale(double *p1, double *p2, int X, int Y);
662  void Translate(double *p1, double *p2);
663 
672  vtkLookupTable *CreateDefaultLookupTable();
673 
674  // Properties used to control the appearance of selected objects and
675  // the manipulator in general. The plane property is actually that for
676  // the outline. The TexturePlaneProperty can be used to control the
677  // lighting etc. of the resliced image data.
683  void CreateDefaultProperties();
684 
685  // Reslice and texture management
686  void UpdatePlane();
687  void GenerateTexturePlane();
688 
689  // The cross-hair cursor
692  double CurrentCursorPosition[3];
693  double CurrentImageValue; // Set to VTK_DOUBLE_MAX when invalid
694  void GenerateCursor();
695  void UpdateCursor(int,int);
696  void ActivateCursor(int);
697  int UpdateContinuousCursor(double *q);
698  int UpdateDiscreteCursor(double *q);
700 
701  // The text to display W/L, image data
703  char TextBuff[128];
704  void GenerateText();
705  void ManageTextDisplay();
706  void ActivateText(int);
707 
708  // Oblique reslice control
709  double RotateAxis[3];
710  double RadiusVector[3];
711  void AdjustState();
712 
713  // Visible margins to assist user interaction
717  void GenerateMargins();
718  void UpdateMargins();
719  void ActivateMargins(int);
720  double MarginSizeX;
721  double MarginSizeY;
722 
723 private:
724  vtkImagePlaneWidget(const vtkImagePlaneWidget&) VTK_DELETE_FUNCTION;
725  void operator=(const vtkImagePlaneWidget&) VTK_DELETE_FUNCTION;
726 };
727 
728 #endif
#define VTK_CUBIC_RESLICE
void SetPlaneOrientationToZAxes()
Convenience method sets the plane orientation normal to the x, y, or z axes.
virtual vtkPolyDataAlgorithm * GetPolyDataAlgorithm()=0
Returns underlying vtkPolyDataAlgorithm that determines geometry.
void SetResliceInterpolateToCubic()
Set the interpolation to use when texturing the plane.
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
abstract base class for most VTK objects
Definition: vtkObject.h:59
#define VTK_LINEAR_RESLICE
abstract PolyDataSource-based 3D widget
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:41
double GetLevel()
Set/Get the current window and level values.
represent surface properties of a geometric object
Definition: vtkProperty.h:64
vtkPolyData * PlaneOutlinePolyData
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
Handles the char widget activation event.
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
map scalar values into colors via a lookup table
vtkPlaneSource * PlaneSource
vtkProperty * MarginProperty
vtkLookupTable * LookupTable
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:60
vtkProperty * CursorProperty
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
virtual void SetInputConnection(vtkAlgorithmOutput *)
Specify the input dataset.
vtkProperty * SelectedPlaneProperty
virtual void UpdatePlacement()=0
If you've made changes to the underlying vtkPolyDataSource AFTER your initial call to PlaceWidget()...
void SetResliceInterpolateToNearestNeighbour()
Set the interpolation to use when texturing the plane.
Proxy object to connect input/output ports.
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
vtkImageMapToColors * ColorMap
An actor that displays text.
Definition: vtkTextActor.h:56
map vtkDataSet and derived classes to graphics primitives
void PlaceWidget()
Methods that satisfy the superclass' API.
Superclass for algorithms that produce only polydata as output.
a simple class to control print indentation
Definition: vtkIndent.h:39
#define VTK_NEAREST_RESLICE
void SetPlaneOrientationToYAxes()
Convenience method sets the plane orientation normal to the x, y, or z axes.
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
void SetPlaneOrientationToXAxes()
Convenience method sets the plane orientation normal to the x, y, or z axes.
map the input image through a lookup table
vtkProperty * TexturePlaneProperty
handles properties associated with a texture map
Definition: vtkTexture.h:70
represent text properties.
Reslices a volume along a new set of axes.
create an array of quadrilaterals located in a plane
virtual void PlaceWidget()
Overrides vtk3DWidget PlaceWidget() so that it doesn't complain if there's no Input and no Prop3D...
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
vtkImageReslice * Reslice
vtkAbstractPropPicker * PlanePicker
abstract API for pickers that can pick an instance of vtkProp
3D widget for reslicing image data
vtkPolyData * MarginPolyData
double GetWindow()
Set/Get the current window and level values.
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
Methods that satisfy the superclass' API.
vtkMatrix4x4 * ResliceAxes
vtkPolyData * CursorPolyData
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
virtual void OnChar()
Sets up the keypress-i event.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
virtual void PlaceWidget()
This method is used to initially place the widget.
void SetResliceInterpolateToLinear()
Set the interpolation to use when texturing the plane.
represent and manipulate 3D points
Definition: vtkPoints.h:39