VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkImplicitPlaneWidget.h 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 =========================================================================*/ 00072 #ifndef __vtkImplicitPlaneWidget_h 00073 #define __vtkImplicitPlaneWidget_h 00074 00075 #include "vtkInteractionWidgetsModule.h" // For export macro 00076 #include "vtkPolyDataSourceWidget.h" 00077 00078 class vtkActor; 00079 class vtkPolyDataMapper; 00080 class vtkCellPicker; 00081 class vtkConeSource; 00082 class vtkLineSource; 00083 class vtkSphereSource; 00084 class vtkTubeFilter; 00085 class vtkPlane; 00086 class vtkCutter; 00087 class vtkProperty; 00088 class vtkImageData; 00089 class vtkOutlineFilter; 00090 class vtkFeatureEdges; 00091 class vtkPolyData; 00092 class vtkTransform; 00093 00094 class VTKINTERACTIONWIDGETS_EXPORT vtkImplicitPlaneWidget : public vtkPolyDataSourceWidget 00095 { 00096 public: 00098 static vtkImplicitPlaneWidget *New(); 00099 00100 vtkTypeMacro(vtkImplicitPlaneWidget,vtkPolyDataSourceWidget); 00101 void PrintSelf(ostream& os, vtkIndent indent); 00102 00104 00105 virtual void SetEnabled(int); 00106 virtual void PlaceWidget(double bounds[6]); 00107 void PlaceWidget() 00108 {this->Superclass::PlaceWidget();} 00109 void PlaceWidget(double xmin, double xmax, double ymin, double ymax, 00110 double zmin, double zmax) 00111 {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);} 00113 00115 00116 virtual void SetOrigin(double x, double y, double z); 00117 virtual void SetOrigin(double x[3]); 00118 double* GetOrigin(); 00119 void GetOrigin(double xyz[3]); 00121 00123 00124 void SetNormal(double x, double y, double z); 00125 void SetNormal(double x[3]); 00126 double* GetNormal(); 00127 void GetNormal(double xyz[3]); 00129 00131 00135 void SetNormalToXAxis(int); 00136 vtkGetMacro(NormalToXAxis,int); 00137 vtkBooleanMacro(NormalToXAxis,int); 00138 void SetNormalToYAxis(int); 00139 vtkGetMacro(NormalToYAxis,int); 00140 vtkBooleanMacro(NormalToYAxis,int); 00141 void SetNormalToZAxis(int); 00142 vtkGetMacro(NormalToZAxis,int); 00143 vtkBooleanMacro(NormalToZAxis,int); 00145 00147 00149 vtkSetMacro(Tubing,int); 00150 vtkGetMacro(Tubing,int); 00151 vtkBooleanMacro(Tubing,int); 00153 00155 00159 void SetDrawPlane(int plane); 00160 vtkGetMacro(DrawPlane,int); 00161 vtkBooleanMacro(DrawPlane,int); 00163 00165 00167 vtkSetMacro(OutlineTranslation,int); 00168 vtkGetMacro(OutlineTranslation,int); 00169 vtkBooleanMacro(OutlineTranslation,int); 00171 00173 00175 vtkSetMacro(OutsideBounds,int); 00176 vtkGetMacro(OutsideBounds,int); 00177 vtkBooleanMacro(OutsideBounds,int); 00179 00181 00182 vtkSetMacro(ScaleEnabled,int); 00183 vtkGetMacro(ScaleEnabled,int); 00184 vtkBooleanMacro(ScaleEnabled,int); 00186 00188 00190 vtkSetMacro(OriginTranslation,int); 00191 vtkGetMacro(OriginTranslation,int); 00192 vtkBooleanMacro(OriginTranslation,int); 00194 00196 00198 vtkSetClampMacro(DiagonalRatio,double,0,2); 00199 vtkGetMacro(DiagonalRatio,double); 00201 00204 void GetPolyData(vtkPolyData *pd); 00205 00208 vtkPolyDataAlgorithm* GetPolyDataAlgorithm(); 00209 00214 void GetPlane(vtkPlane *plane); 00215 00219 void UpdatePlacement(); 00220 00222 virtual void SizeHandles(); 00223 00225 00226 vtkGetObjectMacro(NormalProperty,vtkProperty); 00227 vtkGetObjectMacro(SelectedNormalProperty,vtkProperty); 00229 00231 00233 vtkGetObjectMacro(PlaneProperty,vtkProperty); 00234 vtkGetObjectMacro(SelectedPlaneProperty,vtkProperty); 00236 00238 00239 vtkGetObjectMacro(OutlineProperty,vtkProperty); 00240 vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty); 00242 00244 00246 vtkGetObjectMacro(EdgesProperty,vtkProperty); 00248 00249 protected: 00250 vtkImplicitPlaneWidget(); 00251 ~vtkImplicitPlaneWidget(); 00252 00253 //BTX - manage the state of the widget 00254 int State; 00255 enum WidgetState 00256 { 00257 Start=0, 00258 MovingPlane, 00259 MovingOutline, 00260 MovingOrigin, 00261 Scaling, 00262 Pushing, 00263 Rotating, 00264 Outside 00265 }; 00266 //ETX 00267 00268 //handles the events 00269 static void ProcessEvents(vtkObject* object, unsigned long event, 00270 void* clientdata, 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 ivars 00282 int NormalToXAxis; 00283 int NormalToYAxis; 00284 int NormalToZAxis; 00285 void UpdateRepresentation(); 00286 00287 // The actual plane which is being manipulated 00288 vtkPlane *Plane; 00289 00290 // The bounding box is represented by a single voxel image data 00291 vtkImageData *Box; 00292 vtkOutlineFilter *Outline; 00293 vtkPolyDataMapper *OutlineMapper; 00294 vtkActor *OutlineActor; 00295 void HighlightOutline(int highlight); 00296 int OutlineTranslation; //whether the outline can be moved 00297 int ScaleEnabled; //whether the widget can be scaled 00298 int OutsideBounds; //whether the widget can be moved outside input's bounds 00299 00300 // The cut plane is produced with a vtkCutter 00301 vtkCutter *Cutter; 00302 vtkPolyDataMapper *CutMapper; 00303 vtkActor *CutActor; 00304 int DrawPlane; 00305 virtual void HighlightPlane(int highlight); 00306 00307 // Optional tubes are represented by extracting boundary edges and tubing 00308 vtkFeatureEdges *Edges; 00309 vtkTubeFilter *EdgesTuber; 00310 vtkPolyDataMapper *EdgesMapper; 00311 vtkActor *EdgesActor; 00312 int Tubing; //control whether tubing is on 00313 00314 // Control final length of the arrow: 00315 double DiagonalRatio; 00316 00317 // The + normal cone 00318 vtkConeSource *ConeSource; 00319 vtkPolyDataMapper *ConeMapper; 00320 vtkActor *ConeActor; 00321 void HighlightNormal(int highlight); 00322 00323 // The + normal line 00324 vtkLineSource *LineSource; 00325 vtkPolyDataMapper *LineMapper; 00326 vtkActor *LineActor; 00327 00328 // The - normal cone 00329 vtkConeSource *ConeSource2; 00330 vtkPolyDataMapper *ConeMapper2; 00331 vtkActor *ConeActor2; 00332 00333 // The - normal line 00334 vtkLineSource *LineSource2; 00335 vtkPolyDataMapper *LineMapper2; 00336 vtkActor *LineActor2; 00337 00338 // The origin positioning handle 00339 vtkSphereSource *Sphere; 00340 vtkPolyDataMapper *SphereMapper; 00341 vtkActor *SphereActor; 00342 int OriginTranslation; //whether the origin (sphere) can be moved 00343 00344 // Do the picking 00345 vtkCellPicker *Picker; 00346 00347 // Register internal Pickers within PickingManager 00348 virtual void RegisterPickers(); 00349 00350 // Transform the normal (used for rotation) 00351 vtkTransform *Transform; 00352 00353 // Methods to manipulate the plane 00354 void ConstrainOrigin(double x[3]); 00355 void Rotate(int X, int Y, double *p1, double *p2, double *vpn); 00356 void TranslatePlane(double *p1, double *p2); 00357 void TranslateOutline(double *p1, double *p2); 00358 void TranslateOrigin(double *p1, double *p2); 00359 void Push(double *p1, double *p2); 00360 void Scale(double *p1, double *p2, int X, int Y); 00361 00362 // Properties used to control the appearance of selected objects and 00363 // the manipulator in general. 00364 vtkProperty *NormalProperty; 00365 vtkProperty *SelectedNormalProperty; 00366 vtkProperty *PlaneProperty; 00367 vtkProperty *SelectedPlaneProperty; 00368 vtkProperty *OutlineProperty; 00369 vtkProperty *SelectedOutlineProperty; 00370 vtkProperty *EdgesProperty; 00371 void CreateDefaultProperties(); 00372 00373 void GeneratePlane(); 00374 00375 private: 00376 vtkImplicitPlaneWidget(const vtkImplicitPlaneWidget&); //Not implemented 00377 void operator=(const vtkImplicitPlaneWidget&); //Not implemented 00378 }; 00379 00380 #endif