• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

dox/Widgets/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 =========================================================================*/
00109 #ifndef __vtkImagePlaneWidget_h
00110 #define __vtkImagePlaneWidget_h
00111 
00112 #include "vtkPolyDataSourceWidget.h"
00113 
00114 class vtkActor;
00115 class vtkAbstractPropPicker;
00116 class vtkDataSetMapper;
00117 class vtkImageData;
00118 class vtkImageMapToColors;
00119 class vtkImageReslice;
00120 class vtkLookupTable;
00121 class vtkMatrix4x4;
00122 class vtkPlaneSource;
00123 class vtkPoints;
00124 class vtkPolyData;
00125 class vtkProperty;
00126 class vtkTextActor;
00127 class vtkTextProperty;
00128 class vtkTexture;
00129 class vtkTransform;
00130 
00131 #define VTK_NEAREST_RESLICE 0
00132 #define VTK_LINEAR_RESLICE  1
00133 #define VTK_CUBIC_RESLICE   2
00134 
00135 class VTK_WIDGETS_EXPORT vtkImagePlaneWidget : public vtkPolyDataSourceWidget
00136 {
00137 public:
00139   static vtkImagePlaneWidget *New();
00140 
00141   vtkTypeRevisionMacro(vtkImagePlaneWidget,vtkPolyDataSourceWidget);
00142   void PrintSelf(ostream& os, vtkIndent indent);
00143 
00145 
00146   virtual void SetEnabled(int);
00147   virtual void PlaceWidget(double bounds[6]);
00148   void PlaceWidget()
00149     {this->Superclass::PlaceWidget();}
00150   void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
00151                    double zmin, double zmax)
00152     {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
00154 
00156   void SetInput(vtkDataSet* input);
00157 
00159 
00160   void SetOrigin(double x, double y, double z);
00161   void SetOrigin(double xyz[3]);
00162   double* GetOrigin();
00163   void GetOrigin(double xyz[3]);
00165 
00167 
00169   void SetPoint1(double x, double y, double z);
00170   void SetPoint1(double xyz[3]);
00171   double* GetPoint1();
00172   void GetPoint1(double xyz[3]);
00174 
00176 
00178   void SetPoint2(double x, double y, double z);
00179   void SetPoint2(double xyz[3]);
00180   double* GetPoint2();
00181   void GetPoint2(double xyz[3]);
00183 
00185 
00186   double* GetCenter();
00187   void GetCenter(double xyz[3]);
00189 
00191 
00192   double* GetNormal();
00193   void GetNormal(double xyz[3]);
00195 
00197   void GetVector1(double v1[3]);
00198 
00200   void GetVector2(double v2[3]);
00201 
00203   int GetSliceIndex();
00204 
00206   void SetSliceIndex(int index);
00207 
00209   double GetSlicePosition();
00210 
00212   void SetSlicePosition(double position);
00213 
00215 
00216   void SetResliceInterpolate(int);
00217   vtkGetMacro(ResliceInterpolate,int);
00218   void SetResliceInterpolateToNearestNeighbour()
00219     { this->SetResliceInterpolate(VTK_NEAREST_RESLICE); }
00220   void SetResliceInterpolateToLinear()
00221     { this->SetResliceInterpolate(VTK_LINEAR_RESLICE); }
00222   void SetResliceInterpolateToCubic()
00223     { this->SetResliceInterpolate(VTK_CUBIC_RESLICE); }
00225 
00227   vtkImageData* GetResliceOutput();
00228 
00230 
00231   vtkSetMacro(RestrictPlaneToVolume,int);
00232   vtkGetMacro(RestrictPlaneToVolume,int);
00233   vtkBooleanMacro(RestrictPlaneToVolume,int);
00235 
00237 
00239   vtkSetMacro(UserControlledLookupTable,int);
00240   vtkGetMacro(UserControlledLookupTable,int);
00241   vtkBooleanMacro(UserControlledLookupTable,int);
00243 
00245 
00249   vtkSetMacro(TextureInterpolate,int);
00250   vtkGetMacro(TextureInterpolate,int);
00251   vtkBooleanMacro(TextureInterpolate,int);
00253 
00255 
00257   virtual void SetTextureVisibility(int);
00258   vtkGetMacro(TextureVisibility,int);
00259   vtkBooleanMacro(TextureVisibility,int);
00261   
00268   void GetPolyData(vtkPolyData *pd);
00269 
00275   vtkPolyDataAlgorithm* GetPolyDataAlgorithm();
00276 
00280   void UpdatePlacement(void);
00281 
00284   vtkTexture *GetTexture();
00285 
00287 
00291   vtkGetObjectMacro(ColorMap, vtkImageMapToColors);
00292   virtual void SetColorMap(vtkImageMapToColors *);
00294 
00296 
00298   virtual void SetPlaneProperty(vtkProperty*);
00299   vtkGetObjectMacro(PlaneProperty,vtkProperty);
00300   virtual void SetSelectedPlaneProperty(vtkProperty*);
00301   vtkGetObjectMacro(SelectedPlaneProperty,vtkProperty);
00303 
00305 
00307   void SetPlaneOrientation(int);
00308   vtkGetMacro(PlaneOrientation,int);
00309   void SetPlaneOrientationToXAxes()
00310     { this->SetPlaneOrientation(0); }
00311   void SetPlaneOrientationToYAxes()
00312     { this->SetPlaneOrientation(1); }
00313   void SetPlaneOrientationToZAxes()
00314     { this->SetPlaneOrientation(2); }
00316 
00321   void SetPicker(vtkAbstractPropPicker*);
00322 
00324 
00329   virtual void SetLookupTable(vtkLookupTable*);
00330   vtkGetObjectMacro(LookupTable,vtkLookupTable);
00332 
00334 
00336   vtkSetMacro(DisplayText,int);
00337   vtkGetMacro(DisplayText,int);
00338   vtkBooleanMacro(DisplayText,int);
00340 
00342 
00343   virtual void SetCursorProperty(vtkProperty*);
00344   vtkGetObjectMacro(CursorProperty,vtkProperty);
00346 
00348 
00349   virtual void SetMarginProperty(vtkProperty*);
00350   vtkGetObjectMacro(MarginProperty,vtkProperty);
00352 
00354 
00356   vtkSetClampMacro(MarginSizeX,double, 0.0, 0.5);
00357   vtkGetMacro(MarginSizeX, double);
00358   vtkSetClampMacro(MarginSizeY,double, 0.0, 0.5);
00359   vtkGetMacro(MarginSizeY, double);
00361 
00363 
00365   void SetTextProperty(vtkTextProperty* tprop);
00366   vtkTextProperty* GetTextProperty();
00368 
00370 
00371   virtual void SetTexturePlaneProperty(vtkProperty*);
00372   vtkGetObjectMacro(TexturePlaneProperty,vtkProperty);
00374 
00376 
00380   void SetWindowLevel(double window, double level, int copy = 0);
00381   void GetWindowLevel(double wl[2]);
00382   double GetWindow(){return this->CurrentWindow;}
00383   double GetLevel(){return this->CurrentLevel;}
00385 
00388   int GetCursorData(double xyzv[4]);
00389 
00393   int GetCursorDataStatus();
00394 
00396 
00398   vtkGetVectorMacro(CurrentCursorPosition,double,3);
00400 
00402 
00405   vtkGetMacro(CurrentImageValue,double);
00407 
00409 
00415   vtkSetMacro(UseContinuousCursor,int);
00416   vtkGetMacro(UseContinuousCursor,int);
00417   vtkBooleanMacro(UseContinuousCursor,int);
00419 
00421 
00422   void SetInteraction(int interact);
00423   vtkGetMacro(Interaction,int);
00424   vtkBooleanMacro(Interaction,int);
00426 
00428 
00429   enum
00430   {
00431     VTK_CURSOR_ACTION       = 0,
00432     VTK_SLICE_MOTION_ACTION = 1,
00433     VTK_WINDOW_LEVEL_ACTION = 2
00434   };
00435   //ETX
00436   vtkSetClampMacro(LeftButtonAction,int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
00437   vtkGetMacro(LeftButtonAction, int);
00438   vtkSetClampMacro(MiddleButtonAction,int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
00439   vtkGetMacro(MiddleButtonAction, int);
00440   vtkSetClampMacro(RightButtonAction,int, VTK_CURSOR_ACTION, VTK_WINDOW_LEVEL_ACTION);
00441   vtkGetMacro(RightButtonAction, int);
00443 
00445 
00451   enum
00452   {
00453     VTK_NO_MODIFIER         = 0,
00454     VTK_SHIFT_MODIFIER      = 1,
00455     VTK_CONTROL_MODIFIER    = 2
00456   };
00457   //ETX
00458   vtkSetClampMacro(LeftButtonAutoModifier,int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
00459   vtkGetMacro(LeftButtonAutoModifier, int);
00460   vtkSetClampMacro(MiddleButtonAutoModifier,int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
00461   vtkGetMacro(MiddleButtonAutoModifier, int);
00462   vtkSetClampMacro(RightButtonAutoModifier,int, VTK_NO_MODIFIER, VTK_CONTROL_MODIFIER);
00463   vtkGetMacro(RightButtonAutoModifier, int);
00465 
00466 protected:
00467   vtkImagePlaneWidget();
00468   ~vtkImagePlaneWidget();
00469 
00470   int TextureVisibility;
00471   
00472   int LeftButtonAction;
00473   int MiddleButtonAction;
00474   int RightButtonAction;
00475 
00476   int LeftButtonAutoModifier;
00477   int MiddleButtonAutoModifier;
00478   int RightButtonAutoModifier;
00479 
00480   //BTX
00481   enum
00482   {
00483     VTK_NO_BUTTON     = 0,
00484     VTK_LEFT_BUTTON   = 1,
00485     VTK_MIDDLE_BUTTON = 2,
00486     VTK_RIGHT_BUTTON  = 3
00487   };
00488   //ETX
00489   int LastButtonPressed;
00490 
00491   //BTX - manage the state of the widget
00492   int State;
00493   enum WidgetState
00494   {
00495     Start=0,
00496     Cursoring,
00497     WindowLevelling,
00498     Pushing,
00499     Spinning,
00500     Rotating,
00501     Moving,
00502     Scaling,
00503     Outside
00504   };
00505   //ETX
00506 
00507   // Handles the events
00508   static void ProcessEvents(vtkObject* object,
00509                             unsigned long event,
00510                             void* clientdata,
00511                             void* calldata);
00512 
00513   // internal utility method that adds observers to the RenderWindowInteractor
00514   // so that our ProcessEvents is eventually called.  this method is called
00515   // by SetEnabled as well as SetInteraction
00516   void AddObservers();
00517 
00518   // ProcessEvents() dispatches to these methods.
00519   virtual void OnMouseMove();
00520   virtual void OnLeftButtonDown();
00521   virtual void OnLeftButtonUp();
00522   virtual void OnMiddleButtonDown();
00523   virtual void OnMiddleButtonUp();
00524   virtual void OnRightButtonDown();
00525   virtual void OnRightButtonUp();
00526   virtual void OnChar();
00527 
00528   virtual void StartCursor();
00529   virtual void StopCursor();
00530   virtual void StartSliceMotion();
00531   virtual void StopSliceMotion();
00532   virtual void StartWindowLevel();
00533   virtual void StopWindowLevel();
00534 
00535   // controlling ivars
00536   int    Interaction; // Is the widget responsive to mouse events
00537   int    PlaneOrientation;
00538   int    RestrictPlaneToVolume;
00539   double OriginalWindow;
00540   double OriginalLevel;
00541   double CurrentWindow;
00542   double CurrentLevel;
00543   double InitialWindow;
00544   double InitialLevel;
00545   int    StartWindowLevelPositionX;
00546   int    StartWindowLevelPositionY;
00547   int    ResliceInterpolate;
00548   int    TextureInterpolate;
00549   int    UserControlledLookupTable;
00550   int    DisplayText;
00551 
00552   // The geometric represenation of the plane and it's outline
00553   vtkPlaneSource    *PlaneSource;
00554   vtkPolyData       *PlaneOutlinePolyData;
00555   vtkActor          *PlaneOutlineActor;
00556   void               HighlightPlane(int highlight);
00557   void               GeneratePlaneOutline();
00558 
00559   // Re-builds the plane outline based on the plane source
00560   void BuildRepresentation();
00561 
00562   // Do the picking
00563   vtkAbstractPropPicker *PlanePicker;
00564 
00565   // for negative window values.
00566   void InvertTable();
00567 
00568   // Methods to manipulate the plane
00569   void WindowLevel(int X, int Y);
00570   void Push(double *p1, double *p2);
00571   void Spin(double *p1, double *p2);
00572   void Rotate(double *p1, double *p2, double *vpn);
00573   void Scale(double *p1, double *p2, int X, int Y);
00574   void Translate(double *p1, double *p2);
00575 
00576   vtkImageData         *ImageData;
00577   vtkImageReslice      *Reslice;
00578   vtkMatrix4x4         *ResliceAxes;
00579   vtkTransform         *Transform;
00580   vtkActor             *TexturePlaneActor;
00581   vtkImageMapToColors  *ColorMap;
00582   vtkTexture           *Texture;
00583   vtkLookupTable       *LookupTable;
00584   vtkLookupTable       *CreateDefaultLookupTable();
00585 
00586   // Properties used to control the appearance of selected objects and
00587   // the manipulator in general.  The plane property is actually that for
00588   // the outline.  The TexturePlaneProperty can be used to control the
00589   // lighting etc. of the resliced image data.
00590   vtkProperty   *PlaneProperty;
00591   vtkProperty   *SelectedPlaneProperty;
00592   vtkProperty   *CursorProperty;
00593   vtkProperty   *MarginProperty;
00594   vtkProperty   *TexturePlaneProperty;
00595   void           CreateDefaultProperties();
00596 
00597   // Reslice and texture management
00598   void UpdatePlane();
00599   void GenerateTexturePlane();
00600 
00601   // The cross-hair cursor
00602   vtkPolyData       *CursorPolyData;
00603   vtkActor          *CursorActor;
00604   double             CurrentCursorPosition[3];
00605   double             CurrentImageValue; // Set to VTK_DOUBLE_MAX when invalid
00606   void               GenerateCursor();
00607   void               UpdateCursor(int,int);
00608   void               ActivateCursor(int);
00609   int                UpdateContinuousCursor(double *q);
00610   int                UpdateDiscreteCursor(double *q);
00611   int                UseContinuousCursor;
00612 
00613   // The text to display W/L, image data
00614   vtkTextActor *TextActor;
00615   char          TextBuff[128];
00616   void          GenerateText();
00617   void          ManageTextDisplay();
00618   void          ActivateText(int);
00619 
00620   // Oblique reslice control
00621   double RotateAxis[3];
00622   double RadiusVector[3];
00623   void  AdjustState();
00624 
00625   // Visible margins to assist user interaction
00626   vtkPolyData       *MarginPolyData;
00627   vtkActor          *MarginActor;
00628   int                MarginSelectMode;
00629   void               GenerateMargins();
00630   void               UpdateMargins();
00631   void               ActivateMargins(int);
00632   double             MarginSizeX;
00633   double             MarginSizeY;
00634 
00635 private:
00636   vtkImagePlaneWidget(const vtkImagePlaneWidget&);  //Not implemented
00637   void operator=(const vtkImagePlaneWidget&);  //Not implemented
00638 };
00639 
00640 #endif

Generated by  doxygen 1.7.1