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

dox/Hybrid/vtkPlaneWidget.h

Go to the documentation of this file.
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkPlaneWidget.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 =========================================================================*/ 00089 #ifndef __vtkPlaneWidget_h 00090 #define __vtkPlaneWidget_h 00091 00092 #include "vtkPolyDataSourceWidget.h" 00093 00094 class vtkActor; 00095 class vtkCellPicker; 00096 class vtkConeSource; 00097 class vtkLineSource; 00098 class vtkPlaneSource; 00099 class vtkPoints; 00100 class vtkPolyData; 00101 class vtkPolyDataMapper; 00102 class vtkProp; 00103 class vtkProperty; 00104 class vtkSphereSource; 00105 class vtkTransform; 00106 class vtkPlane; 00107 00108 #define VTK_PLANE_OFF 0 00109 #define VTK_PLANE_OUTLINE 1 00110 #define VTK_PLANE_WIREFRAME 2 00111 #define VTK_PLANE_SURFACE 3 00112 00113 class VTK_HYBRID_EXPORT vtkPlaneWidget : public vtkPolyDataSourceWidget 00114 { 00115 public: 00117 static vtkPlaneWidget *New(); 00118 00119 vtkTypeRevisionMacro(vtkPlaneWidget,vtkPolyDataSourceWidget); 00120 void PrintSelf(ostream& os, vtkIndent indent); 00121 00123 00124 virtual void SetEnabled(int); 00125 virtual void PlaceWidget(float bounds[6]); 00126 void PlaceWidget() 00127 {this->Superclass::PlaceWidget();} 00129 00131 00132 void SetResolution(int r); 00133 int GetResolution(); 00135 00137 00138 void SetOrigin(float x, float y, float z); 00139 void SetOrigin(float x[3]); 00140 float* GetOrigin(); 00141 void GetOrigin(float xyz[3]); 00143 00145 00147 void SetPoint1(float x, float y, float z); 00148 void SetPoint1(float x[3]); 00149 float* GetPoint1(); 00150 void GetPoint1(float xyz[3]); 00152 00154 00156 void SetPoint2(float x, float y, float z); 00157 void SetPoint2(float x[3]); 00158 float* GetPoint2(); 00159 void GetPoint2(float xyz[3]); 00161 00163 00164 void SetCenter(float x, float y, float z); 00165 void SetCenter(float x[3]); 00166 float* GetCenter(); 00167 void GetCenter(float xyz[3]); 00169 00171 00172 void SetNormal(float x, float y, float z); 00173 void SetNormal(float x[3]); 00174 float* GetNormal(); 00175 void GetNormal(float xyz[3]); 00177 00179 00184 vtkSetClampMacro(Representation,int,VTK_PLANE_OFF,VTK_PLANE_SURFACE); 00185 vtkGetMacro(Representation,int); 00186 void SetRepresentationToOff() 00187 {this->SetRepresentation(VTK_PLANE_OFF);} 00188 void SetRepresentationToOutline() 00189 {this->SetRepresentation(VTK_PLANE_OUTLINE);} 00190 void SetRepresentationToWireframe() 00191 {this->SetRepresentation(VTK_PLANE_WIREFRAME);} 00192 void SetRepresentationToSurface() 00193 {this->SetRepresentation(VTK_PLANE_SURFACE);} 00195 00197 00201 vtkSetMacro(NormalToXAxis,int); 00202 vtkGetMacro(NormalToXAxis,int); 00203 vtkBooleanMacro(NormalToXAxis,int); 00204 vtkSetMacro(NormalToYAxis,int); 00205 vtkGetMacro(NormalToYAxis,int); 00206 vtkBooleanMacro(NormalToYAxis,int); 00207 vtkSetMacro(NormalToZAxis,int); 00208 vtkGetMacro(NormalToZAxis,int); 00209 vtkBooleanMacro(NormalToZAxis,int); 00211 00219 void GetPolyData(vtkPolyData *pd); 00220 00226 void GetPlane(vtkPlane *plane); 00227 00233 vtkPolyDataSource* GetPolyDataSource(); 00234 00237 void UpdatePlacement(void); 00238 00240 00243 vtkGetObjectMacro(HandleProperty,vtkProperty); 00244 vtkGetObjectMacro(SelectedHandleProperty,vtkProperty); 00246 00248 00250 virtual void SetPlaneProperty(vtkProperty*); 00251 vtkGetObjectMacro(PlaneProperty,vtkProperty); 00252 vtkGetObjectMacro(SelectedPlaneProperty,vtkProperty); 00254 00255 protected: 00256 vtkPlaneWidget(); 00257 ~vtkPlaneWidget(); 00258 00259 //BTX - manage the state of the widget 00260 int State; 00261 enum WidgetState 00262 { 00263 Start=0, 00264 Moving, 00265 Scaling, 00266 Pushing, 00267 Rotating, 00268 Outside 00269 }; 00270 //ETX 00271 00272 //handles the events 00273 static void ProcessEvents(vtkObject* object, 00274 unsigned long event, 00275 void* clientdata, 00276 void* calldata); 00277 00278 // ProcessEvents() dispatches to these methods. 00279 void OnLeftButtonDown(); 00280 void OnLeftButtonUp(); 00281 void OnMiddleButtonDown(); 00282 void OnMiddleButtonUp(); 00283 void OnRightButtonDown(); 00284 void OnRightButtonUp(); 00285 void OnMouseMove(); 00286 00287 // controlling ivars 00288 int NormalToXAxis; 00289 int NormalToYAxis; 00290 int NormalToZAxis; 00291 int Representation; 00292 void SelectRepresentation(); 00293 00294 // the plane 00295 vtkActor *PlaneActor; 00296 vtkPolyDataMapper *PlaneMapper; 00297 vtkPlaneSource *PlaneSource; 00298 vtkPolyData *PlaneOutline; 00299 void HighlightPlane(int highlight); 00300 00301 // glyphs representing hot spots (e.g., handles) 00302 vtkActor **Handle; 00303 vtkPolyDataMapper **HandleMapper; 00304 vtkSphereSource **HandleGeometry; 00305 void PositionHandles(); 00306 void HandlesOn(double length); 00307 void HandlesOff(); 00308 int HighlightHandle(vtkProp *prop); //returns cell id 00309 virtual void SizeHandles(); 00310 00311 // the normal cone 00312 vtkActor *ConeActor; 00313 vtkPolyDataMapper *ConeMapper; 00314 vtkConeSource *ConeSource; 00315 void HighlightNormal(int highlight); 00316 00317 // the normal line 00318 vtkActor *LineActor; 00319 vtkPolyDataMapper *LineMapper; 00320 vtkLineSource *LineSource; 00321 00322 // the normal cone 00323 vtkActor *ConeActor2; 00324 vtkPolyDataMapper *ConeMapper2; 00325 vtkConeSource *ConeSource2; 00326 00327 // the normal line 00328 vtkActor *LineActor2; 00329 vtkPolyDataMapper *LineMapper2; 00330 vtkLineSource *LineSource2; 00331 00332 // Do the picking 00333 vtkCellPicker *HandlePicker; 00334 vtkCellPicker *PlanePicker; 00335 vtkActor *CurrentHandle; 00336 00337 // Methods to manipulate the hexahedron. 00338 void MoveOrigin(double *p1, double *p2); 00339 void MovePoint1(double *p1, double *p2); 00340 void MovePoint2(double *p1, double *p2); 00341 void MovePoint3(double *p1, double *p2); 00342 void Rotate(int X, int Y, double *p1, double *p2, double *vpn); 00343 void Scale(double *p1, double *p2, int X, int Y); 00344 void Translate(double *p1, double *p2); 00345 void Push(double *p1, double *p2); 00346 00347 // Plane normal, normalized 00348 float Normal[3]; 00349 00350 // Transform the hexahedral points (used for rotations) 00351 vtkTransform *Transform; 00352 00353 // Properties used to control the appearance of selected objects and 00354 // the manipulator in general. 00355 vtkProperty *HandleProperty; 00356 vtkProperty *SelectedHandleProperty; 00357 vtkProperty *PlaneProperty; 00358 vtkProperty *SelectedPlaneProperty; 00359 void CreateDefaultProperties(); 00360 00361 void GeneratePlane(); 00362 00363 private: 00364 vtkPlaneWidget(const vtkPlaneWidget&); //Not implemented 00365 void operator=(const vtkPlaneWidget&); //Not implemented 00366 }; 00367 00368 #endif