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