Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members Related Pages

# Hybrid/vtkImagePlaneWidget.h

Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program:   Visualization Toolkit
    00004   Module:    $RCSfile: vtkImagePlaneWidget.h,v $
    00005   Language:  C++
    00006
    00007   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
    00008   All rights reserved.
    00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
    00010
    00011      This software is distributed WITHOUT ANY WARRANTY; without even
    00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
    00013      PURPOSE.  See the above copyright notice for more information.
    00014
    00015 =========================================================================*/
    00121 #ifndef __vtkImagePlaneWidget_h
    00122 #define __vtkImagePlaneWidget_h
    00123
    00124 #include "vtkPolyDataSourceWidget.h"
    00125
    00126 class vtkActor;
    00127 class vtkCellPicker;
    00128 class vtkDataSetMapper;
    00129 class vtkImageData;
    00130 class vtkImageMapToColors;
    00131 class vtkImageReslice;
    00132 class vtkLookupTable;
    00133 class vtkMatrix4x4;
    00134 class vtkPlaneSource;
    00135 class vtkPoints;
    00136 class vtkPolyData;
    00137 class vtkPolyDataMapper;
    00138 class vtkProperty;
    00139 class vtkTextActor;
    00140 class vtkTextProperty;
    00141 class vtkTexture;
    00142 class vtkTextureMapToPlane;
    00143 class vtkTransform;
    00144
    00145 #define VTK_NEAREST_RESLICE 0
    00146 #define VTK_LINEAR_RESLICE  1
    00147 #define VTK_CUBIC_RESLICE   2
    00148
    00149 class VTK_EXPORT vtkImagePlaneWidget : public vtkPolyDataSourceWidget
    00150 {
    00151 public:
    00153   static vtkImagePlaneWidget *New();
    00154
    00155   vtkTypeRevisionMacro(vtkImagePlaneWidget,vtkPolyDataSourceWidget);
    00156   void PrintSelf(ostream& os, vtkIndent indent);
    00157
    00159
    00160   virtual void SetEnabled(int);
    00161   virtual void PlaceWidget(float bounds[6]);
    00162   void PlaceWidget()
    00163     {this->Superclass::PlaceWidget();}
    00164   void PlaceWidget(float xmin, float xmax, float ymin, float ymax,
    00165                    float zmin, float zmax)
    00166     {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
    00168
    00170   void SetInput(vtkDataSet* input);
    00171
    00173
    00174   void SetOrigin(float x, float y, float z);
    00175   void SetOrigin(float xyz[3]);
    00176   float* GetOrigin();
    00177   void GetOrigin(float xyz[3]);
    00179
    00181
    00183   void SetPoint1(float x, float y, float z);
    00184   void SetPoint1(float xyz[3]);
    00185   float* GetPoint1();
    00186   void GetPoint1(float xyz[3]);
    00188
    00190
    00192   void SetPoint2(float x, float y, float z);
    00193   void SetPoint2(float xyz[3]);
    00194   float* GetPoint2();
    00195   void GetPoint2(float xyz[3]);
    00197
    00199
    00200   float* GetCenter();
    00201   void GetCenter(float xyz[3]);
    00203
    00205
    00206   float* GetNormal();
    00207   void GetNormal(float xyz[3]);
    00209
    00211   void GetVector1(float v1[3]);
    00212
    00214   void GetVector2(float v2[3]);
    00215
    00217   int GetSliceIndex();
    00218
    00220   void SetSliceIndex(int index);
    00221
    00223   float GetSlicePosition();
    00224
    00226   void SetSlicePosition(float position);
    00227
    00229
    00230   void SetResliceInterpolate(int);
    00231   vtkGetMacro(ResliceInterpolate,int);
    00232   void SetResliceInterpolateToNearestNeighbour()
    00233     { this->SetResliceInterpolate(VTK_NEAREST_RESLICE); }
    00234   void SetResliceInterpolateToLinear()
    00235     { this->SetResliceInterpolate(VTK_LINEAR_RESLICE); }
    00236   void SetResliceInterpolateToCubic()
    00237     { this->SetResliceInterpolate(VTK_CUBIC_RESLICE); }
    00239
    00241   vtkImageData* GetResliceOutput();
    00242
    00244
    00245   vtkSetMacro(RestrictPlaneToVolume,int);
    00246   vtkGetMacro(RestrictPlaneToVolume,int);
    00247   vtkBooleanMacro(RestrictPlaneToVolume,int);
    00249
    00251
    00253   vtkSetMacro(UserControlledLookupTable,int);
    00254   vtkGetMacro(UserControlledLookupTable,int);
    00255   vtkBooleanMacro(UserControlledLookupTable,int);
    00257
    00259
    00263   vtkSetMacro(TextureInterpolate,int);
    00264   vtkGetMacro(TextureInterpolate,int);
    00265   vtkBooleanMacro(TextureInterpolate,int);
    00267
    00275   void GetPolyData(vtkPolyData *pd);
    00276
    00282   vtkPolyDataSource* GetPolyDataSource();
    00283
    00286   void UpdatePlacement(void);
    00287
    00290   vtkTexture *GetTexture();
    00291
    00296   vtkImageMapToColors* GetImageMapToColors();
    00297
    00299
    00301   virtual void SetPlaneProperty(vtkProperty*);
    00302   vtkGetObjectMacro(PlaneProperty,vtkProperty);
    00303   virtual void SetSelectedPlaneProperty(vtkProperty*);
    00304   vtkGetObjectMacro(SelectedPlaneProperty,vtkProperty);
    00306
    00308
    00310   void SetPlaneOrientation(int);
    00311   vtkGetMacro(PlaneOrientation,int);
    00312   void SetPlaneOrientationToXAxes()
    00313     { this->SetPlaneOrientation(0); }
    00314   void SetPlaneOrientationToYAxes()
    00315     { this->SetPlaneOrientation(1); }
    00316   void SetPlaneOrientationToZAxes()
    00317     { this->SetPlaneOrientation(2); }
    00319
    00324   void SetPicker(vtkCellPicker*);
    00325
    00327
    00332   virtual void SetLookupTable(vtkLookupTable*);
    00333   vtkGetObjectMacro(LookupTable,vtkLookupTable);
    00335
    00337
    00339   vtkSetMacro(DisplayText,int);
    00340   vtkGetMacro(DisplayText,int);
    00341   vtkBooleanMacro(DisplayText,int);
    00343
    00345
    00346   virtual void SetCursorProperty(vtkProperty*);
    00347   vtkGetObjectMacro(CursorProperty,vtkProperty);
    00349
    00351
    00352   virtual void SetMarginProperty(vtkProperty*);
    00353   vtkGetObjectMacro(MarginProperty,vtkProperty);
    00355
    00357
    00359   void SetTextProperty(vtkTextProperty* tprop);
    00360   vtkTextProperty* GetTextProperty();
    00362
    00364
    00365   virtual void SetTexturePlaneProperty(vtkProperty*);
    00366   vtkGetObjectMacro(TexturePlaneProperty,vtkProperty);
    00368
    00370   void GetWindowLevel(float wl[2]);
    00371
    00374   int GetCursorData(float xyzv[4]);
    00375
    00377
    00378   void SetInteraction(int interact);
    00379   vtkGetMacro(Interaction,int);
    00380   vtkBooleanMacro(Interaction,int);
    00382
    00383 protected:
    00384   vtkImagePlaneWidget();
    00385   ~vtkImagePlaneWidget();
    00386
    00387 //BTX - manage the state of the widget
    00388   int State;
    00389   enum WidgetState
    00390   {
    00391     Start=0,
    00392     Cursoring,
    00393     WindowLevelling,
    00394     Pushing,
    00395     Spinning,
    00396     Rotating,
    00397     Moving,
    00398     Scaling,
    00399     Outside
    00400   };
    00401 //ETX
    00402
    00403   // Handles the events
    00404   static void ProcessEvents(vtkObject* object,
    00405                             unsigned long event,
    00406                             void* clientdata,
    00407                             void* calldata);
    00408
    00409   // ProcessEvents() dispatches to these methods.
    00410   void OnMouseMove();
    00411   void OnLeftButtonDown();
    00412   void OnLeftButtonUp();
    00413   void OnMiddleButtonDown();
    00414   void OnMiddleButtonUp();
    00415   void OnRightButtonDown();
    00416   void OnRightButtonUp();
    00417
    00418   // controlling ivars
    00419   int   Interaction; // Is the widget responsive to mouse events
    00420   int   PlaneOrientation;
    00421   int   RestrictPlaneToVolume;
    00422   float OriginalWindow;
    00423   float OriginalLevel;
    00424   float CurrentWindow;
    00425   float CurrentLevel;
    00426   int   ResliceInterpolate;
    00427   int   TextureInterpolate;
    00428   int   UserControlledLookupTable;
    00429   int   DisplayText;
    00430
    00431   // The geometric represenation of the plane and it's outline
    00432   vtkPlaneSource    *PlaneSource;
    00433   float              Normal[3]; // plane normal normalized
    00434   vtkPolyData       *PlaneOutlinePolyData;
    00435   vtkActor          *PlaneOutlineActor;
    00436   vtkPolyDataMapper *PlaneOutlineMapper;
    00437   void               HighlightPlane(int highlight);
    00438   void               GeneratePlaneOutline();
    00439
    00440   // Re-builds the plane outline based on the plane source
    00441   void BuildRepresentation();
    00442
    00443   // Do the picking
    00444   vtkCellPicker *PlanePicker;
    00445
    00446   // Methods to manipulate the plane
    00447   void WindowLevel(int X, int Y);
    00448   void Push(double *p1, double *p2);
    00449   void Spin(double *p1, double *p2);
    00450   void Rotate(double *p1, double *p2, double *vpn);
    00451   void Scale(double *p1, double *p2, int X, int Y);
    00452   void Translate(double *p1, double *p2);
    00453
    00454   vtkImageData         *ImageData;
    00455   vtkImageReslice      *Reslice;
    00456   vtkMatrix4x4         *ResliceAxes;
    00457   vtkTransform         *Transform;
    00458   vtkTextureMapToPlane *TexturePlaneCoords;
    00459   vtkDataSetMapper     *TexturePlaneMapper;
    00460   vtkActor             *TexturePlaneActor;
    00461   vtkImageMapToColors  *ColorMap;
    00462   vtkTexture           *Texture;
    00463   vtkLookupTable       *LookupTable;
    00464   vtkLookupTable       *CreateDefaultLookupTable();
    00465
    00466   // Properties used to control the appearance of selected objects and
    00467   // the manipulator in general.  The plane property is actually that for
    00468   // the outline.  The TexturePlaneProperty can be used to control the
    00469   // lighting etc. of the resliced image data.
    00470   vtkProperty   *PlaneProperty;
    00471   vtkProperty   *SelectedPlaneProperty;
    00472   vtkProperty   *CursorProperty;
    00473   vtkProperty   *MarginProperty;
    00474   vtkProperty   *TexturePlaneProperty;
    00475   void           CreateDefaultProperties();
    00476
    00477   // Reslice and texture management
    00478   void UpdateNormal();
    00479   void UpdateOrigin();
    00480   void GenerateTexturePlane();
    00481
    00482   // The cross-hair cursor
    00483   vtkPolyData       *CursorPolyData;
    00484   vtkPolyDataMapper *CursorMapper;
    00485   vtkActor          *CursorActor;
    00486   int                CurrentCursorPosition[3];
    00487   float              CurrentImageValue; // Set to VTK_FLOAT_MAX when invalid
    00488   void               GenerateCursor();
    00489   void               UpdateCursor(int,int);
    00490   void               ActivateCursor(int);
    00491
    00492   // The text to display W/L, image data
    00493   vtkTextActor *TextActor;
    00494   char          TextBuff[128];
    00495   void          GenerateText();
    00496   void          ManageTextDisplay();
    00497   void          ActivateText(int);
    00498
    00499   // Oblique reslice control
    00500   float RotateAxis[3];
    00501   float RadiusVector[3];
    00502   void  AdjustState();
    00503
    00504   // Visible margins to assist user interaction
    00505   vtkPolyData       *MarginPolyData;
    00506   vtkPolyDataMapper *MarginMapper;
    00507   vtkActor          *MarginActor;
    00508   int                MarginSelectMode;
    00509   void               GenerateMargins();
    00510   void               UpdateMargins();
    00511   void               ActivateMargins(int);
    00512
    00513 private:
    00514   vtkImagePlaneWidget(const vtkImagePlaneWidget&);  //Not implemented
    00515   void operator=(const vtkImagePlaneWidget&);  //Not implemented
    00516 };
    00517
    00518 #endif