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

# Hybrid/vtkSplineWidget.h

Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program:   Visualization Toolkit
    00004   Module:    $RCSfile: vtkSplineWidget.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 =========================================================================*/
    00098 #ifndef __vtkSplineWidget_h
    00099 #define __vtkSplineWidget_h
    00100
    00101 #include "vtk3DWidget.h"
    00102
    00103 class vtkActor;
    00104 class vtkCellPicker;
    00105 class vtkPlaneSource;
    00106 class vtkPoints;
    00107 class vtkPolyData;
    00108 class vtkPolyDataMapper;
    00109 class vtkProp;
    00110 class vtkProperty;
    00111 class vtkSphereSource;
    00112 class vtkSpline;
    00113 class vtkTransform;
    00114
    00115 #define VTK_PROJECTION_YZ 0
    00116 #define VTK_PROJECTION_XZ 1
    00117 #define VTK_PROJECTION_XY 2
    00118 #define VTK_PROJECTION_OBLIQUE 3
    00119
    00120 class VTK_HYBRID_EXPORT vtkSplineWidget : public vtk3DWidget
    00121 {
    00122 public:
    00124   static vtkSplineWidget *New();
    00125
    00126   vtkTypeRevisionMacro(vtkSplineWidget,vtk3DWidget);
    00127   void PrintSelf(ostream& os, vtkIndent indent);
    00128
    00130
    00131   virtual void SetEnabled(int);
    00132   virtual void PlaceWidget(float bounds[6]);
    00133   void PlaceWidget()
    00134     {this->Superclass::PlaceWidget();}
    00135   void PlaceWidget(float xmin, float xmax, float ymin, float ymax,
    00136                    float zmin, float zmax)
    00137     {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
    00139
    00141
    00147   vtkSetMacro(ProjectToPlane,int);
    00148   vtkGetMacro(ProjectToPlane,int);
    00149   vtkBooleanMacro(ProjectToPlane,int);
    00151
    00154   void SetPlaneSource(vtkPlaneSource* plane);
    00155
    00156   vtkSetClampMacro(ProjectionNormal,int,VTK_PROJECTION_YZ,VTK_PROJECTION_OBLIQUE);
    00157   vtkGetMacro(ProjectionNormal,int);
    00158   void SetProjectionNormalToXAxes()
    00159     { this->SetProjectionNormal(0); }
    00160   void SetProjectionNormalToYAxes()
    00161     { this->SetProjectionNormal(1); }
    00162   void SetProjectionNormalToZAxes()
    00163     { this->SetProjectionNormal(2); }
    00164   void SetProjectionNormalToOblique()
    00165     { this->SetProjectionNormal(3); }
    00166
    00168
    00173   void SetProjectionPosition(float position);
    00174   vtkGetMacro(ProjectionPosition, float);
    00176
    00182   void GetPolyData(vtkPolyData *pd);
    00183
    00185
    00188   virtual void SetHandleProperty(vtkProperty*);
    00189   vtkGetObjectMacro(HandleProperty, vtkProperty);
    00190   virtual void SetSelectedHandleProperty(vtkProperty*);
    00191   vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
    00193
    00195
    00197   virtual void SetLineProperty(vtkProperty*);
    00198   vtkGetObjectMacro(LineProperty, vtkProperty);
    00199   virtual void SetSelectedLineProperty(vtkProperty*);
    00200   vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
    00202
    00204
    00205   void SetNumberOfHandles(int npts);
    00206   vtkGetMacro(NumberOfHandles, int);
    00208
    00210
    00212   void SetResolution(int resolution);
    00213   vtkGetMacro(Resolution,int);
    00215
    00217
    00221   void SetXSpline(vtkSpline*);
    00222   void SetYSpline(vtkSpline*);
    00223   void SetZSpline(vtkSpline*);
    00225
    00227
    00229   void SetHandlePosition(int handle, float x, float y, float z);
    00230   void SetHandlePosition(int handle, float xyz[3]);
    00231   void GetHandlePosition(int handle, float xyz[3]);
    00232   float* GetHandlePosition(int handle);
    00234
    00236
    00240   void SetClosed(int closed);
    00241   vtkGetMacro(Closed,int);
    00242   vtkBooleanMacro(Closed,int);
    00244
    00248   float GetSummedLength();
    00249
    00250 protected:
    00251   vtkSplineWidget();
    00252   ~vtkSplineWidget();
    00253
    00254 //BTX - manage the state of the widget
    00255   int State;
    00256   enum WidgetState
    00257   {
    00258     Start=0,
    00259     Moving,
    00260     Scaling,
    00261     Spinning,
    00262     Outside
    00263   };
    00264 //ETX
    00265
    00266   //handles the events
    00267   static void ProcessEvents(vtkObject* object,
    00268                             unsigned long event,
    00269                             void* clientdata,
    00270                             void* calldata);
    00271
    00272   // ProcessEvents() dispatches to these methods.
    00273   void OnLeftButtonDown();
    00274   void OnLeftButtonUp();
    00275   void OnMiddleButtonDown();
    00276   void OnMiddleButtonUp();
    00277   void OnRightButtonDown();
    00278   void OnRightButtonUp();
    00279   void OnMouseMove();
    00280
    00281   // Controlling vars
    00282   int   ProjectionNormal;
    00283   float ProjectionPosition;
    00284   int   ProjectToPlane;
    00285   vtkPlaneSource* PlaneSource;
    00286
    00287   // Projection capabilities
    00288   void ProjectPointsToPlane();
    00289   void ProjectPointsToOrthoPlane();
    00290   void ProjectPointsToObliquePlane();
    00291
    00292   // The spline
    00293   vtkSpline *XSpline;
    00294   vtkSpline *YSpline;
    00295   vtkSpline *ZSpline;
    00296   int NumberOfHandles;
    00297   float* HandlePositions;
    00298   vtkSpline* CreateDefaultSpline();// default is vtkCardinalSpline
    00299   int Closed;
    00300   float Offset;
    00301
    00302   // The line segments
    00303   vtkActor          *LineActor;
    00304   vtkPolyDataMapper *LineMapper;
    00305   vtkPolyData       *LineData;
    00306   void HighlightLine(int highlight);
    00307   int NumberOfSplinePoints;
    00308   int Resolution;
    00309   float* SplinePositions;
    00310
    00311   // Glyphs representing hot spots (e.g., handles)
    00312   vtkActor          **Handle;
    00313   vtkPolyDataMapper **HandleMapper;
    00314   vtkSphereSource   **HandleGeometry;
    00315   void Initialize();
    00316   int  HighlightHandle(vtkProp *prop); //returns handle index or -1 on fail
    00317   virtual void SizeHandles();
    00318   void BuildRepresentation();
    00319
    00320   // Do the picking
    00321   vtkCellPicker *HandlePicker;
    00322   vtkCellPicker *LinePicker;
    00323   vtkActor *CurrentHandle;
    00324   int CurrentHandleIndex;
    00325
    00326   // Methods to manipulate the spline.
    00327   void MovePoint(double *p1, double *p2);
    00328   void Scale(double *p1, double *p2, int X, int Y);
    00329   void Translate(double *p1, double *p2);
    00330   void Spin(double *p1, double *p2, double *vpn);
    00331
    00332   // Transform the control points (used for spinning)
    00333   vtkTransform *Transform;
    00334
    00335   // Properties used to control the appearance of selected objects and
    00336   // the manipulator in general.
    00337   vtkProperty *HandleProperty;
    00338   vtkProperty *SelectedHandleProperty;
    00339   vtkProperty *LineProperty;
    00340   vtkProperty *SelectedLineProperty;
    00341   void CreateDefaultProperties();
    00342
    00343 private:
    00344   vtkSplineWidget(const vtkSplineWidget&);  //Not implemented
    00345   void operator=(const vtkSplineWidget&);  //Not implemented
    00346 };
    00347
    00348 #endif