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

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