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

Hybrid/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_HYBRID_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);
00174 
00177   void GetPolyData(vtkPolyData *pd);
00178 
00181   vtkPolyDataSource* GetPolyDataSource();
00182    
00187   void GetPlane(vtkPlane *plane);
00188 
00192   void UpdatePlacement(void);
00193 
00195 
00196   vtkGetObjectMacro(NormalProperty,vtkProperty);
00197   vtkGetObjectMacro(SelectedNormalProperty,vtkProperty);
00199   
00201 
00203   vtkGetObjectMacro(PlaneProperty,vtkProperty);
00204   vtkGetObjectMacro(SelectedPlaneProperty,vtkProperty);
00206 
00208 
00209   vtkGetObjectMacro(OutlineProperty,vtkProperty);
00210   vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty);
00212 
00214 
00216   vtkGetObjectMacro(EdgesProperty,vtkProperty);
00218 
00219 protected:
00220   vtkImplicitPlaneWidget();
00221   ~vtkImplicitPlaneWidget();
00222 
00223 //BTX - manage the state of the widget
00224   int State;
00225   enum WidgetState
00226   {
00227     Start=0,
00228     MovingPlane,
00229     MovingOutline,
00230     MovingOrigin,
00231     Scaling,
00232     Pushing,
00233     Rotating,
00234     Outside
00235   };
00236 //ETX
00237     
00238   //handles the events
00239   static void ProcessEvents(vtkObject* object, unsigned long event,
00240                             void* clientdata, void* calldata);
00241 
00242   // ProcessEvents() dispatches to these methods.
00243   void OnLeftButtonDown();
00244   void OnLeftButtonUp();
00245   void OnMiddleButtonDown();
00246   void OnMiddleButtonUp();
00247   void OnRightButtonDown();
00248   void OnRightButtonUp();
00249   void OnMouseMove();
00250 
00251   // Controlling ivars
00252   int NormalToXAxis;
00253   int NormalToYAxis;
00254   int NormalToZAxis;
00255   void UpdateRepresentation();
00256 
00257   // The actual plane which is being manipulated
00258   vtkPlane *Plane;
00259 
00260   // The bounding box is represented by a single voxel image data
00261   vtkImageData      *Box;
00262   vtkOutlineFilter  *Outline;
00263   vtkPolyDataMapper *OutlineMapper;
00264   vtkActor          *OutlineActor;
00265   void HighlightOutline(int highlight);
00266   int OutlineTranslation; //whether the outline can be moved
00267   
00268   // The cut plane is produced with a vtkCutter
00269   vtkCutter         *Cutter;
00270   vtkPolyDataMapper *CutMapper;
00271   vtkActor          *CutActor;
00272   int               DrawPlane;
00273   void HighlightPlane(int highlight);
00274   
00275   // Optional tubes are represented by extracting boundary edges and tubing
00276   vtkFeatureEdges   *Edges;
00277   vtkTubeFilter     *EdgesTuber;
00278   vtkPolyDataMapper *EdgesMapper;
00279   vtkActor          *EdgesActor;
00280   int               Tubing; //control whether tubing is on
00281 
00282   // The + normal cone
00283   vtkConeSource     *ConeSource;
00284   vtkPolyDataMapper *ConeMapper;
00285   vtkActor          *ConeActor;
00286   void HighlightNormal(int highlight);
00287 
00288   // The + normal line
00289   vtkLineSource     *LineSource;
00290   vtkPolyDataMapper *LineMapper;
00291   vtkActor          *LineActor;
00292 
00293   // The - normal cone
00294   vtkConeSource     *ConeSource2;
00295   vtkPolyDataMapper *ConeMapper2;
00296   vtkActor          *ConeActor2;
00297 
00298   // The - normal line
00299   vtkLineSource     *LineSource2;
00300   vtkPolyDataMapper *LineMapper2;
00301   vtkActor          *LineActor2;
00302 
00303   // The origin positioning handle
00304   vtkSphereSource   *Sphere;
00305   vtkPolyDataMapper *SphereMapper;
00306   vtkActor          *SphereActor;
00307 
00308   // Do the picking
00309   vtkCellPicker *Picker;
00310   
00311   // Transform the normal (used for rotation)
00312   vtkTransform *Transform;
00313   
00314   // Methods to manipulate the plane
00315   void ConstrainOrigin(double x[3]);
00316   void Rotate(int X, int Y, double *p1, double *p2, double *vpn);
00317   void TranslatePlane(double *p1, double *p2);
00318   void TranslateOutline(double *p1, double *p2);
00319   void TranslateOrigin(double *p1, double *p2);
00320   void Push(double *p1, double *p2);
00321   void Scale(double *p1, double *p2, int X, int Y);
00322   
00323   // Properties used to control the appearance of selected objects and
00324   // the manipulator in general.
00325   vtkProperty *NormalProperty;
00326   vtkProperty *SelectedNormalProperty;
00327   vtkProperty *PlaneProperty;
00328   vtkProperty *SelectedPlaneProperty;
00329   vtkProperty *OutlineProperty;
00330   vtkProperty *SelectedOutlineProperty;
00331   vtkProperty *EdgesProperty;
00332   void CreateDefaultProperties();
00333   
00334   void GeneratePlane();
00335   virtual void SizeHandles();
00336   
00337 private:
00338   vtkImplicitPlaneWidget(const vtkImplicitPlaneWidget&);  //Not implemented
00339   void operator=(const vtkImplicitPlaneWidget&);  //Not implemented
00340 };
00341 
00342 #endif