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