• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

dox/Widgets/vtkSplineWidget.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkSplineWidget.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 =========================================================================*/
00090 #ifndef __vtkSplineWidget_h
00091 #define __vtkSplineWidget_h
00092 
00093 #include "vtk3DWidget.h"
00094 
00095 class vtkActor;
00096 class vtkCellPicker;
00097 class vtkParametricSpline;
00098 class vtkParametricFunctionSource;
00099 class vtkPlaneSource;
00100 class vtkPoints;
00101 class vtkPolyData;
00102 class vtkProp;
00103 class vtkProperty;
00104 class vtkSphereSource;
00105 class vtkTransform;
00106 
00107 #define VTK_PROJECTION_YZ 0
00108 #define VTK_PROJECTION_XZ 1
00109 #define VTK_PROJECTION_XY 2
00110 #define VTK_PROJECTION_OBLIQUE 3
00111 
00112 class VTK_WIDGETS_EXPORT vtkSplineWidget : public vtk3DWidget
00113 {
00114 public:
00116   static vtkSplineWidget *New();
00117 
00118   vtkTypeRevisionMacro(vtkSplineWidget,vtk3DWidget);
00119   void PrintSelf(ostream& os, vtkIndent indent);
00120 
00122 
00123   virtual void SetEnabled(int);
00124   virtual void PlaceWidget(double bounds[6]);
00125   void PlaceWidget()
00126     {this->Superclass::PlaceWidget();}
00127   void PlaceWidget(double xmin, double xmax, double ymin, double ymax, 
00128                    double zmin, double zmax)
00129     {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
00131 
00133 
00139   vtkSetMacro(ProjectToPlane,int);
00140   vtkGetMacro(ProjectToPlane,int);
00141   vtkBooleanMacro(ProjectToPlane,int);
00143 
00146   void SetPlaneSource(vtkPlaneSource* plane);
00147 
00148   vtkSetClampMacro(ProjectionNormal,int,VTK_PROJECTION_YZ,VTK_PROJECTION_OBLIQUE);
00149   vtkGetMacro(ProjectionNormal,int);
00150   void SetProjectionNormalToXAxes()
00151     { this->SetProjectionNormal(0); }
00152   void SetProjectionNormalToYAxes()
00153     { this->SetProjectionNormal(1); }
00154   void SetProjectionNormalToZAxes()
00155     { this->SetProjectionNormal(2); }
00156   void SetProjectionNormalToOblique()
00157     { this->SetProjectionNormal(3); }
00158 
00160 
00165   void SetProjectionPosition(double position);
00166   vtkGetMacro(ProjectionPosition, double);
00168 
00175   void GetPolyData(vtkPolyData *pd);
00176 
00178 
00181   virtual void SetHandleProperty(vtkProperty*);
00182   vtkGetObjectMacro(HandleProperty, vtkProperty);
00183   virtual void SetSelectedHandleProperty(vtkProperty*);
00184   vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
00186 
00188 
00190   virtual void SetLineProperty(vtkProperty*);
00191   vtkGetObjectMacro(LineProperty, vtkProperty);
00192   virtual void SetSelectedLineProperty(vtkProperty*);
00193   vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
00195 
00197 
00198   virtual void SetNumberOfHandles(int npts);
00199   vtkGetMacro(NumberOfHandles, int);
00201 
00203 
00205   void SetResolution(int resolution);
00206   vtkGetMacro(Resolution,int);
00208 
00210 
00216   virtual void SetParametricSpline(vtkParametricSpline*);
00217   vtkGetObjectMacro(ParametricSpline,vtkParametricSpline);
00219 
00221 
00223   void SetHandlePosition(int handle, double x, double y, double z);
00224   void SetHandlePosition(int handle, double xyz[3]);
00225   void GetHandlePosition(int handle, double xyz[3]);
00226   double* GetHandlePosition(int handle);
00228 
00230 
00235   void SetClosed(int closed);
00236   vtkGetMacro(Closed,int);
00237   vtkBooleanMacro(Closed,int);
00239 
00243   int IsClosed();
00244 
00248   double GetSummedLength();
00249 
00254   void InitializeHandles(vtkPoints* points);
00255 
00256 protected:
00257   vtkSplineWidget();
00258   ~vtkSplineWidget();
00259 
00260 //BTX - manage the state of the widget
00261   int State;
00262   enum WidgetState
00263   {
00264     Start=0,
00265     Moving,
00266     Scaling,
00267     Spinning,
00268     Inserting,
00269     Erasing,
00270     Outside
00271   };
00272 //ETX
00273 
00274   //handles the events
00275   static void ProcessEvents(vtkObject* object,
00276                             unsigned long event,
00277                             void* clientdata,
00278                             void* calldata);
00279 
00280   // ProcessEvents() dispatches to these methods.
00281   void OnLeftButtonDown();
00282   void OnLeftButtonUp();
00283   void OnMiddleButtonDown();
00284   void OnMiddleButtonUp();
00285   void OnRightButtonDown();
00286   void OnRightButtonUp();
00287   void OnMouseMove();
00288 
00289   // Controlling vars
00290   int   ProjectionNormal;
00291   double ProjectionPosition;
00292   int   ProjectToPlane;
00293   vtkPlaneSource* PlaneSource;
00294 
00295   // Projection capabilities
00296   void ProjectPointsToPlane();
00297   void ProjectPointsToOrthoPlane();
00298   void ProjectPointsToObliquePlane();
00299 
00300   // The spline
00301   vtkParametricSpline *ParametricSpline;
00302   vtkParametricFunctionSource *ParametricFunctionSource;
00303   int NumberOfHandles;
00304   int Closed;
00305   void BuildRepresentation();
00306   
00307   // The line segments
00308   vtkActor           *LineActor;
00309   void HighlightLine(int highlight);
00310   int Resolution;
00311 
00312   // Glyphs representing hot spots (e.g., handles)
00313   vtkActor          **Handle;
00314   vtkSphereSource   **HandleGeometry;
00315   void Initialize();
00316   int  HighlightHandle(vtkProp *prop); //returns handle index or -1 on fail
00317   virtual void SizeHandles();
00318   void InsertHandleOnLine(double* pos);
00319   void EraseHandle(const int&);
00320 
00321   // Do the picking
00322   vtkCellPicker *HandlePicker;
00323   vtkCellPicker *LinePicker;
00324   vtkActor *CurrentHandle;
00325   int CurrentHandleIndex;
00326 
00327   // Methods to manipulate the spline.
00328   void MovePoint(double *p1, double *p2);
00329   void Scale(double *p1, double *p2, int X, int Y);
00330   void Translate(double *p1, double *p2);
00331   void Spin(double *p1, double *p2, double *vpn);
00332 
00333   // Transform the control points (used for spinning)
00334   vtkTransform *Transform;
00335 
00336   // Properties used to control the appearance of selected objects and
00337   // the manipulator in general.
00338   vtkProperty *HandleProperty;
00339   vtkProperty *SelectedHandleProperty;
00340   vtkProperty *LineProperty;
00341   vtkProperty *SelectedLineProperty;
00342   void CreateDefaultProperties();
00343 
00344   // For efficient spinning
00345   double Centroid[3];
00346   void CalculateCentroid();
00347 
00348 private:
00349   vtkSplineWidget(const vtkSplineWidget&);  //Not implemented
00350   void operator=(const vtkSplineWidget&);  //Not implemented
00351 };
00352 
00353 #endif

Generated by  doxygen 1.7.1