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

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