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

vtkImplicitPlaneWidget.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkImplicitPlaneWidget.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 =========================================================================*/
00076 #ifndef __vtkImplicitPlaneWidget_h
00077 #define __vtkImplicitPlaneWidget_h
00078 
00079 #include "vtkPolyDataSourceWidget.h"
00080 
00081 class vtkActor;
00082 class vtkPolyDataMapper;
00083 class vtkCellPicker;
00084 class vtkConeSource;
00085 class vtkLineSource;
00086 class vtkSphereSource;
00087 class vtkTubeFilter;
00088 class vtkPlane;
00089 class vtkCutter;
00090 class vtkProperty;
00091 class vtkImageData;
00092 class vtkOutlineFilter;
00093 class vtkFeatureEdges;
00094 class vtkPolyData;
00095 class vtkTransform;
00096 
00097 class VTK_WIDGETS_EXPORT vtkImplicitPlaneWidget : public vtkPolyDataSourceWidget
00098 {
00099 public:
00101   static vtkImplicitPlaneWidget *New();
00102 
00103   vtkTypeRevisionMacro(vtkImplicitPlaneWidget,vtkPolyDataSourceWidget);
00104   void PrintSelf(ostream& os, vtkIndent indent);
00105 
00107 
00108   virtual void SetEnabled(int);
00109   virtual void PlaceWidget(double bounds[6]);
00110   void PlaceWidget()
00111     {this->Superclass::PlaceWidget();}
00112   void PlaceWidget(double xmin, double xmax, double ymin, double ymax, 
00113                    double zmin, double zmax)
00114     {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
00116 
00118 
00119   void SetOrigin(double x, double y, double z);
00120   void SetOrigin(double x[3]);
00121   double* GetOrigin();
00122   void GetOrigin(double xyz[3]);
00124 
00126 
00127   void SetNormal(double x, double y, double z);
00128   void SetNormal(double x[3]);
00129   double* GetNormal();
00130   void GetNormal(double xyz[3]);
00132   
00134 
00138   void SetNormalToXAxis(int);
00139   vtkGetMacro(NormalToXAxis,int);
00140   vtkBooleanMacro(NormalToXAxis,int);
00141   void SetNormalToYAxis(int);
00142   vtkGetMacro(NormalToYAxis,int);
00143   vtkBooleanMacro(NormalToYAxis,int);
00144   void SetNormalToZAxis(int);
00145   vtkGetMacro(NormalToZAxis,int);
00146   vtkBooleanMacro(NormalToZAxis,int);
00148 
00150 
00152   vtkSetMacro(Tubing,int);
00153   vtkGetMacro(Tubing,int);
00154   vtkBooleanMacro(Tubing,int);
00156 
00158 
00162   void SetDrawPlane(int plane);
00163   vtkGetMacro(DrawPlane,int);
00164   vtkBooleanMacro(DrawPlane,int);
00166 
00168 
00170   vtkSetMacro(OutlineTranslation,int);
00171   vtkGetMacro(OutlineTranslation,int);
00172   vtkBooleanMacro(OutlineTranslation,int);
00173   // Description:
00174   // Turn on/off the ability to scale with the mouse 
00175   vtkSetMacro(ScaleEnabled,int);
00176   vtkGetMacro(ScaleEnabled,int);
00177   vtkBooleanMacro(ScaleEnabled,int);
00179 
00182   void GetPolyData(vtkPolyData *pd);
00183 
00186   vtkPolyDataAlgorithm* GetPolyDataAlgorithm();
00187    
00192   void GetPlane(vtkPlane *plane);
00193 
00197   void UpdatePlacement(void);
00198 
00200   virtual void SizeHandles();
00201 
00203 
00204   vtkGetObjectMacro(NormalProperty,vtkProperty);
00205   vtkGetObjectMacro(SelectedNormalProperty,vtkProperty);
00207   
00209 
00211   vtkGetObjectMacro(PlaneProperty,vtkProperty);
00212   vtkGetObjectMacro(SelectedPlaneProperty,vtkProperty);
00214 
00216 
00217   vtkGetObjectMacro(OutlineProperty,vtkProperty);
00218   vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty);
00220 
00222 
00224   vtkGetObjectMacro(EdgesProperty,vtkProperty);
00226 
00227 protected:
00228   vtkImplicitPlaneWidget();
00229   ~vtkImplicitPlaneWidget();
00230 
00231 //BTX - manage the state of the widget
00232   int State;
00233   enum WidgetState
00234   {
00235     Start=0,
00236     MovingPlane,
00237     MovingOutline,
00238     MovingOrigin,
00239     Scaling,
00240     Pushing,
00241     Rotating,
00242     Outside
00243   };
00244 //ETX
00245     
00246   //handles the events
00247   static void ProcessEvents(vtkObject* object, unsigned long event,
00248                             void* clientdata, void* calldata);
00249 
00250   // ProcessEvents() dispatches to these methods.
00251   void OnLeftButtonDown();
00252   void OnLeftButtonUp();
00253   void OnMiddleButtonDown();
00254   void OnMiddleButtonUp();
00255   void OnRightButtonDown();
00256   void OnRightButtonUp();
00257   void OnMouseMove();
00258 
00259   // Controlling ivars
00260   int NormalToXAxis;
00261   int NormalToYAxis;
00262   int NormalToZAxis;
00263   void UpdateRepresentation();
00264 
00265   // The actual plane which is being manipulated
00266   vtkPlane *Plane;
00267 
00268   // The bounding box is represented by a single voxel image data
00269   vtkImageData      *Box;
00270   vtkOutlineFilter  *Outline;
00271   vtkPolyDataMapper *OutlineMapper;
00272   vtkActor          *OutlineActor;
00273   void HighlightOutline(int highlight);
00274   int OutlineTranslation; //whether the outline can be moved
00275   int ScaleEnabled; //whether the widget can be scaled 
00276   
00277   // The cut plane is produced with a vtkCutter
00278   vtkCutter         *Cutter;
00279   vtkPolyDataMapper *CutMapper;
00280   vtkActor          *CutActor;
00281   int               DrawPlane;
00282   void HighlightPlane(int highlight);
00283   
00284   // Optional tubes are represented by extracting boundary edges and tubing
00285   vtkFeatureEdges   *Edges;
00286   vtkTubeFilter     *EdgesTuber;
00287   vtkPolyDataMapper *EdgesMapper;
00288   vtkActor          *EdgesActor;
00289   int               Tubing; //control whether tubing is on
00290 
00291   // The + normal cone
00292   vtkConeSource     *ConeSource;
00293   vtkPolyDataMapper *ConeMapper;
00294   vtkActor          *ConeActor;
00295   void HighlightNormal(int highlight);
00296 
00297   // The + normal line
00298   vtkLineSource     *LineSource;
00299   vtkPolyDataMapper *LineMapper;
00300   vtkActor          *LineActor;
00301 
00302   // The - normal cone
00303   vtkConeSource     *ConeSource2;
00304   vtkPolyDataMapper *ConeMapper2;
00305   vtkActor          *ConeActor2;
00306 
00307   // The - normal line
00308   vtkLineSource     *LineSource2;
00309   vtkPolyDataMapper *LineMapper2;
00310   vtkActor          *LineActor2;
00311 
00312   // The origin positioning handle
00313   vtkSphereSource   *Sphere;
00314   vtkPolyDataMapper *SphereMapper;
00315   vtkActor          *SphereActor;
00316 
00317   // Do the picking
00318   vtkCellPicker *Picker;
00319   
00320   // Transform the normal (used for rotation)
00321   vtkTransform *Transform;
00322   
00323   // Methods to manipulate the plane
00324   void ConstrainOrigin(double x[3]);
00325   void Rotate(int X, int Y, double *p1, double *p2, double *vpn);
00326   void TranslatePlane(double *p1, double *p2);
00327   void TranslateOutline(double *p1, double *p2);
00328   void TranslateOrigin(double *p1, double *p2);
00329   void Push(double *p1, double *p2);
00330   void Scale(double *p1, double *p2, int X, int Y);
00331   
00332   // Properties used to control the appearance of selected objects and
00333   // the manipulator in general.
00334   vtkProperty *NormalProperty;
00335   vtkProperty *SelectedNormalProperty;
00336   vtkProperty *PlaneProperty;
00337   vtkProperty *SelectedPlaneProperty;
00338   vtkProperty *OutlineProperty;
00339   vtkProperty *SelectedOutlineProperty;
00340   vtkProperty *EdgesProperty;
00341   void CreateDefaultProperties();
00342   
00343   void GeneratePlane();
00344   
00345 private:
00346   vtkImplicitPlaneWidget(const vtkImplicitPlaneWidget&);  //Not implemented
00347   void operator=(const vtkImplicitPlaneWidget&);  //Not implemented
00348 };
00349 
00350 #endif

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