Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

vtkImagePlaneWidget.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkImagePlaneWidget.h,v $
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00106 #ifndef __vtkImagePlaneWidget_h
00107 #define __vtkImagePlaneWidget_h
00108 
00109 #include "vtkPolyDataSourceWidget.h"
00110 
00111 class vtkActor;
00112 class vtkCellPicker;
00113 class vtkDataSetMapper;
00114 class vtkImageData;
00115 class vtkImageMapToColors;
00116 class vtkImageReslice;
00117 class vtkLookupTable;
00118 class vtkMatrix4x4;
00119 class vtkPlaneSource;
00120 class vtkPoints;
00121 class vtkPolyData;
00122 class vtkProperty;
00123 class vtkTextActor;
00124 class vtkTextProperty;
00125 class vtkTexture;
00126 class vtkTransform;
00127 
00128 #define VTK_NEAREST_RESLICE 0
00129 #define VTK_LINEAR_RESLICE  1
00130 #define VTK_CUBIC_RESLICE   2
00131 
00132 class VTK_WIDGETS_EXPORT vtkImagePlaneWidget : public vtkPolyDataSourceWidget
00133 {
00134 public:
00136   static vtkImagePlaneWidget *New();
00137 
00138   vtkTypeRevisionMacro(vtkImagePlaneWidget,vtkPolyDataSourceWidget);
00139   void PrintSelf(ostream& os, vtkIndent indent);
00140 
00142 
00143   virtual void SetEnabled(int);
00144   virtual void PlaceWidget(double bounds[6]);
00145   void PlaceWidget()
00146     {this->Superclass::PlaceWidget();}
00147   void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
00148                    double zmin, double zmax)
00149     {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
00151 
00153   void SetInput(vtkDataSet* input);
00154 
00156 
00157   void SetOrigin(double x, double y, double z);
00158   void SetOrigin(double xyz[3]);
00159   double* GetOrigin();
00160   void GetOrigin(double xyz[3]);
00162 
00164 
00166   void SetPoint1(double x, double y, double z);
00167   void SetPoint1(double xyz[3]);
00168   double* GetPoint1();
00169   void GetPoint1(double xyz[3]);
00171 
00173 
00175   void SetPoint2(double x, double y, double z);
00176   void SetPoint2(double xyz[3]);
00177   double* GetPoint2();
00178   void GetPoint2(double xyz[3]);
00180 
00182 
00183   double* GetCenter();
00184   void GetCenter(double xyz[3]);
00186 
00188 
00189   double* GetNormal();
00190   void GetNormal(double xyz[3]);
00192 
00194   void GetVector1(double v1[3]);
00195 
00197   void GetVector2(double v2[3]);
00198 
00200   int GetSliceIndex();
00201 
00203   void SetSliceIndex(int index);
00204 
00206   double GetSlicePosition();
00207 
00209   void SetSlicePosition(double position);
00210 
00212 
00213   void SetResliceInterpolate(int);
00214   vtkGetMacro(ResliceInterpolate,int);
00215   void SetResliceInterpolateToNearestNeighbour()
00216     { this->SetResliceInterpolate(VTK_NEAREST_RESLICE); }
00217   void SetResliceInterpolateToLinear()
00218     { this->SetResliceInterpolate(VTK_LINEAR_RESLICE); }
00219   void SetResliceInterpolateToCubic()
00220     { this->SetResliceInterpolate(VTK_CUBIC_RESLICE); }
00222 
00224   vtkImageData* GetResliceOutput();
00225 
00227 
00228   vtkSetMacro(RestrictPlaneToVolume,int);
00229   vtkGetMacro(RestrictPlaneToVolume,int);
00230   vtkBooleanMacro(RestrictPlaneToVolume,int);
00232 
00234 
00236   vtkSetMacro(UserControlledLookupTable,int);
00237   vtkGetMacro(UserControlledLookupTable,int);
00238   vtkBooleanMacro(UserControlledLookupTable,int);
00240 
00242 
00246   vtkSetMacro(TextureInterpolate,int);
00247   vtkGetMacro(TextureInterpolate,int);
00248   vtkBooleanMacro(TextureInterpolate,int);
00250 
00252 
00254   virtual void SetTextureVisibility(int);
00255   vtkGetMacro(TextureVisibility,int);
00256   vtkBooleanMacro(TextureVisibility,int);
00258   
00266   void GetPolyData(vtkPolyData *pd);
00267 
00273   vtkPolyDataAlgorithm* GetPolyDataAlgorithm();
00274 
00277   void UpdatePlacement(void);
00278 
00281   vtkTexture *GetTexture();
00282 
00284 
00288   vtkGetObjectMacro(ColorMap, vtkImageMapToColors);
00289   virtual void SetColorMap(vtkImageMapToColors *);
00291 
00293 
00295   virtual void SetPlaneProperty(vtkProperty*);
00296   vtkGetObjectMacro(PlaneProperty,vtkProperty);
00297   virtual void SetSelectedPlaneProperty(vtkProperty*);
00298   vtkGetObjectMacro(SelectedPlaneProperty,vtkProperty);
00300 
00302 
00304   void SetPlaneOrientation(int);
00305   vtkGetMacro(PlaneOrientation,int);
00306   void SetPlaneOrientationToXAxes()
00307     { this->SetPlaneOrientation(0); }
00308   void SetPlaneOrientationToYAxes()
00309     { this->SetPlaneOrientation(1); }
00310   void SetPlaneOrientationToZAxes()
00311     { this->SetPlaneOrientation(2); }
00313 
00318   void SetPicker(vtkCellPicker*);
00319 
00321 
00326   virtual void SetLookupTable(vtkLookupTable*);
00327   vtkGetObjectMacro(LookupTable,vtkLookupTable);
00329 
00331 
00333   vtkSetMacro(DisplayText,int);
00334   vtkGetMacro(DisplayText,int);
00335   vtkBooleanMacro(DisplayText,int);
00337 
00339 
00340   virtual void SetCursorProperty(vtkProperty*);
00341   vtkGetObjectMacro(CursorProperty,vtkProperty);
00343 
00345 
00346   virtual void SetMarginProperty(vtkProperty*);
00347   vtkGetObjectMacro(MarginProperty,vtkProperty);
00349 
00351 
00353   void SetTextProperty(vtkTextProperty* tprop);
00354   vtkTextProperty* GetTextProperty();
00356 
00358 
00359   virtual void SetTexturePlaneProperty(vtkProperty*);
00360   vtkGetObjectMacro(TexturePlaneProperty,vtkProperty);
00362 
00364 
00366   void SetWindowLevel(double window, double level);
00367   void GetWindowLevel(double wl[2]);
00369 
00372   int GetCursorData(double xyzv[4]);
00373 
00377   int GetCursorDataStatus();
00378 
00380 
00382   vtkGetVectorMacro(CurrentCursorPosition,double,3);
00384 
00386 
00389   vtkGetMacro(CurrentImageValue,double);
00391   
00393 
00399   vtkSetMacro(UseContinuousCursor,int);
00400   vtkGetMacro(UseContinuousCursor,int);
00401   vtkBooleanMacro(UseContinuousCursor,int);
00403 
00405 
00406   void SetInteraction(int interact);
00407   vtkGetMacro(Interaction,int);
00408   vtkBooleanMacro(Interaction,int);
00410 
00412 
00413   enum
00414   {
00415     CURSOR_ACTION       = 0,
00416     SLICE_MOTION_ACTION = 1,
00417     WINDOW_LEVEL_ACTION = 2
00418   };
00419   //ETX
00420   vtkSetClampMacro(LeftButtonAction,int, CURSOR_ACTION, WINDOW_LEVEL_ACTION);
00421   vtkGetMacro(LeftButtonAction, int);
00422   vtkSetClampMacro(MiddleButtonAction,int, CURSOR_ACTION, WINDOW_LEVEL_ACTION);
00423   vtkGetMacro(MiddleButtonAction, int);
00424   vtkSetClampMacro(RightButtonAction,int, CURSOR_ACTION, WINDOW_LEVEL_ACTION);
00425   vtkGetMacro(RightButtonAction, int);
00427 
00429 
00435   enum
00436   {
00437     NO_MODIFIER         = 0,
00438     SHIFT_MODIFIER      = 1,
00439     CONTROL_MODIFIER    = 2
00440   };
00441   //ETX
00442   vtkSetClampMacro(LeftButtonAutoModifier,int, NO_MODIFIER, CONTROL_MODIFIER);
00443   vtkGetMacro(LeftButtonAutoModifier, int);
00444   vtkSetClampMacro(MiddleButtonAutoModifier,int, NO_MODIFIER, CONTROL_MODIFIER);
00445   vtkGetMacro(MiddleButtonAutoModifier, int);
00446   vtkSetClampMacro(RightButtonAutoModifier,int, NO_MODIFIER, CONTROL_MODIFIER);
00447   vtkGetMacro(RightButtonAutoModifier, int);
00449 
00450 protected:
00451   vtkImagePlaneWidget();
00452   ~vtkImagePlaneWidget();
00453 
00454   int TextureVisibility;
00455   
00456   int LeftButtonAction;
00457   int MiddleButtonAction;
00458   int RightButtonAction;
00459 
00460   int LeftButtonAutoModifier;
00461   int MiddleButtonAutoModifier;
00462   int RightButtonAutoModifier;
00463 
00464   //BTX
00465   enum
00466   {
00467     NO_BUTTON     = 0,
00468     LEFT_BUTTON   = 1,
00469     MIDDLE_BUTTON = 2,
00470     RIGHT_BUTTON  = 3
00471   };
00472   //ETX
00473   int LastButtonPressed;
00474 
00475   //BTX - manage the state of the widget
00476   int State;
00477   enum WidgetState
00478   {
00479     Start=0,
00480     Cursoring,
00481     WindowLevelling,
00482     Pushing,
00483     Spinning,
00484     Rotating,
00485     Moving,
00486     Scaling,
00487     Outside
00488   };
00489   //ETX
00490 
00491   // Handles the events
00492   static void ProcessEvents(vtkObject* object,
00493                             unsigned long event,
00494                             void* clientdata,
00495                             void* calldata);
00496 
00497   // internal utility method that adds observers to the RenderWindowInteractor
00498   // so that our ProcessEvents is eventually called.  this method is called
00499   // by SetEnabled as well as SetInteraction
00500   void AddObservers();
00501 
00502   // ProcessEvents() dispatches to these methods.
00503   virtual void OnMouseMove();
00504   virtual void OnLeftButtonDown();
00505   virtual void OnLeftButtonUp();
00506   virtual void OnMiddleButtonDown();
00507   virtual void OnMiddleButtonUp();
00508   virtual void OnRightButtonDown();
00509   virtual void OnRightButtonUp();
00510 
00511   virtual void StartCursor();
00512   virtual void StopCursor();
00513   virtual void StartSliceMotion();
00514   virtual void StopSliceMotion();
00515   virtual void StartWindowLevel();
00516   virtual void StopWindowLevel();
00517 
00518   // controlling ivars
00519   int   Interaction; // Is the widget responsive to mouse events  
00520   int   PlaneOrientation;
00521   int   RestrictPlaneToVolume;
00522   double OriginalWindow;
00523   double OriginalLevel;
00524   double CurrentWindow;
00525   double CurrentLevel;
00526   int   ResliceInterpolate;
00527   int   TextureInterpolate;
00528   int   UserControlledLookupTable;
00529   int   DisplayText;
00530 
00531   // The geometric represenation of the plane and it's outline
00532   vtkPlaneSource    *PlaneSource;
00533   vtkPolyData       *PlaneOutlinePolyData;
00534   vtkActor          *PlaneOutlineActor;
00535   void               HighlightPlane(int highlight);
00536   void               GeneratePlaneOutline();
00537 
00538   // Re-builds the plane outline based on the plane source
00539   void BuildRepresentation();
00540 
00541   // Do the picking
00542   vtkCellPicker *PlanePicker;
00543 
00544   // Methods to manipulate the plane
00545   void WindowLevel(int X, int Y);
00546   void Push(double *p1, double *p2);
00547   void Spin(double *p1, double *p2);
00548   void Rotate(double *p1, double *p2, double *vpn);
00549   void Scale(double *p1, double *p2, int X, int Y);
00550   void Translate(double *p1, double *p2);
00551 
00552   vtkImageData         *ImageData;
00553   vtkImageReslice      *Reslice;
00554   vtkMatrix4x4         *ResliceAxes;
00555   vtkTransform         *Transform;
00556   vtkActor             *TexturePlaneActor;
00557   vtkImageMapToColors  *ColorMap;
00558   vtkTexture           *Texture;
00559   vtkLookupTable       *LookupTable;
00560   vtkLookupTable       *CreateDefaultLookupTable();
00561 
00562   // Properties used to control the appearance of selected objects and
00563   // the manipulator in general.  The plane property is actually that for
00564   // the outline.  The TexturePlaneProperty can be used to control the
00565   // lighting etc. of the resliced image data.
00566   vtkProperty   *PlaneProperty;
00567   vtkProperty   *SelectedPlaneProperty;
00568   vtkProperty   *CursorProperty;
00569   vtkProperty   *MarginProperty;
00570   vtkProperty   *TexturePlaneProperty;
00571   void           CreateDefaultProperties();
00572 
00573   // Reslice and texture management
00574   void UpdatePlane();
00575   void GenerateTexturePlane();
00576 
00577   // The cross-hair cursor
00578   vtkPolyData       *CursorPolyData;
00579   vtkActor          *CursorActor;
00580   double             CurrentCursorPosition[3];
00581   double             CurrentImageValue; // Set to VTK_DOUBLE_MAX when invalid
00582   void               GenerateCursor();
00583   void               UpdateCursor(int,int);
00584   void               ActivateCursor(int);
00585   int                UpdateContinuousCursor(double *q);
00586   int                UpdateDiscreteCursor(double *q);
00587   int                UseContinuousCursor;
00588 
00589   // The text to display W/L, image data
00590   vtkTextActor *TextActor;
00591   char          TextBuff[128];
00592   void          GenerateText();
00593   void          ManageTextDisplay();
00594   void          ActivateText(int);
00595 
00596   // Oblique reslice control
00597   double RotateAxis[3];
00598   double RadiusVector[3];
00599   void  AdjustState();
00600 
00601   // Visible margins to assist user interaction
00602   vtkPolyData       *MarginPolyData;
00603   vtkActor          *MarginActor;
00604   int                MarginSelectMode;
00605   void               GenerateMargins();
00606   void               UpdateMargins();
00607   void               ActivateMargins(int);
00608 
00609 private:
00610   vtkImagePlaneWidget(const vtkImagePlaneWidget&);  //Not implemented
00611   void operator=(const vtkImagePlaneWidget&);  //Not implemented
00612 };
00613 
00614 #endif

Generated on Mon Jan 21 23:07:38 2008 for VTK by  doxygen 1.4.3-20050530