VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkBoxWidget.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 =========================================================================*/ 00083 #ifndef __vtkBoxWidget_h 00084 #define __vtkBoxWidget_h 00085 00086 #include "vtkInteractionWidgetsModule.h" // For export macro 00087 #include "vtk3DWidget.h" 00088 00089 class vtkActor; 00090 class vtkCellPicker; 00091 class vtkPlanes; 00092 class vtkPoints; 00093 class vtkPolyData; 00094 class vtkPolyDataMapper; 00095 class vtkProp; 00096 class vtkProperty; 00097 class vtkSphereSource; 00098 class vtkTransform; 00099 00100 class VTKINTERACTIONWIDGETS_EXPORT vtkBoxWidget : public vtk3DWidget 00101 { 00102 public: 00104 static vtkBoxWidget *New(); 00105 00106 vtkTypeMacro(vtkBoxWidget,vtk3DWidget); 00107 void PrintSelf(ostream& os, vtkIndent indent); 00108 00110 00111 virtual void SetEnabled(int); 00112 virtual void PlaceWidget(double bounds[6]); 00113 void PlaceWidget() 00114 {this->Superclass::PlaceWidget();} 00115 void PlaceWidget(double xmin, double xmax, double ymin, double ymax, 00116 double zmin, double zmax) 00117 {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);} 00119 00126 void GetPlanes(vtkPlanes *planes); 00127 00129 00132 vtkSetMacro(InsideOut,int); 00133 vtkGetMacro(InsideOut,int); 00134 vtkBooleanMacro(InsideOut,int); 00136 00142 virtual void GetTransform(vtkTransform *t); 00143 00148 virtual void SetTransform(vtkTransform* t); 00149 00158 void GetPolyData(vtkPolyData *pd); 00159 00161 00163 vtkGetObjectMacro(HandleProperty,vtkProperty); 00164 vtkGetObjectMacro(SelectedHandleProperty,vtkProperty); 00166 00168 00170 void HandlesOn(); 00171 void HandlesOff(); 00173 00175 00177 vtkGetObjectMacro(FaceProperty,vtkProperty); 00178 vtkGetObjectMacro(SelectedFaceProperty,vtkProperty); 00180 00182 00184 vtkGetObjectMacro(OutlineProperty,vtkProperty); 00185 vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty); 00187 00189 00191 void SetOutlineFaceWires(int); 00192 vtkGetMacro(OutlineFaceWires,int); 00193 void OutlineFaceWiresOn() {this->SetOutlineFaceWires(1);} 00194 void OutlineFaceWiresOff() {this->SetOutlineFaceWires(0);} 00196 00198 00201 void SetOutlineCursorWires(int); 00202 vtkGetMacro(OutlineCursorWires,int); 00203 void OutlineCursorWiresOn() {this->SetOutlineCursorWires(1);} 00204 void OutlineCursorWiresOff() {this->SetOutlineCursorWires(0);} 00206 00208 00210 vtkSetMacro(TranslationEnabled,int); 00211 vtkGetMacro(TranslationEnabled,int); 00212 vtkBooleanMacro(TranslationEnabled,int); 00213 vtkSetMacro(ScalingEnabled,int); 00214 vtkGetMacro(ScalingEnabled,int); 00215 vtkBooleanMacro(ScalingEnabled,int); 00216 vtkSetMacro(RotationEnabled,int); 00217 vtkGetMacro(RotationEnabled,int); 00218 vtkBooleanMacro(RotationEnabled,int); 00220 00221 protected: 00222 vtkBoxWidget(); 00223 ~vtkBoxWidget(); 00224 00225 //BTX - manage the state of the widget 00226 int State; 00227 enum WidgetState 00228 { 00229 Start=0, 00230 Moving, 00231 Scaling, 00232 Outside 00233 }; 00234 //ETX 00235 00236 // Handles the events 00237 static void ProcessEvents(vtkObject* object, 00238 unsigned long event, 00239 void* clientdata, 00240 void* calldata); 00241 00242 // ProcessEvents() dispatches to these methods. 00243 virtual void OnMouseMove(); 00244 virtual void OnLeftButtonDown(); 00245 virtual void OnLeftButtonUp(); 00246 virtual void OnMiddleButtonDown(); 00247 virtual void OnMiddleButtonUp(); 00248 virtual void OnRightButtonDown(); 00249 virtual void OnRightButtonUp(); 00250 00251 // the hexahedron (6 faces) 00252 vtkActor *HexActor; 00253 vtkPolyDataMapper *HexMapper; 00254 vtkPolyData *HexPolyData; 00255 vtkPoints *Points; //used by others as well 00256 double N[6][3]; //the normals of the faces 00257 00258 // A face of the hexahedron 00259 vtkActor *HexFace; 00260 vtkPolyDataMapper *HexFaceMapper; 00261 vtkPolyData *HexFacePolyData; 00262 00263 // glyphs representing hot spots (e.g., handles) 00264 vtkActor **Handle; 00265 vtkPolyDataMapper **HandleMapper; 00266 vtkSphereSource **HandleGeometry; 00267 virtual void PositionHandles(); 00268 int HighlightHandle(vtkProp *prop); //returns cell id 00269 void HighlightFace(int cellId); 00270 void HighlightOutline(int highlight); 00271 void ComputeNormals(); 00272 virtual void SizeHandles(); 00273 00274 // wireframe outline 00275 vtkActor *HexOutline; 00276 vtkPolyDataMapper *OutlineMapper; 00277 vtkPolyData *OutlinePolyData; 00278 00279 // Do the picking 00280 vtkCellPicker *HandlePicker; 00281 vtkCellPicker *HexPicker; 00282 vtkActor *CurrentHandle; 00283 int CurrentHexFace; 00284 00285 // Register internal Pickers within PickingManager 00286 virtual void RegisterPickers(); 00287 00288 // Methods to manipulate the hexahedron. 00289 virtual void Translate(double *p1, double *p2); 00290 virtual void Scale(double *p1, double *p2, int X, int Y); 00291 virtual void Rotate(int X, int Y, double *p1, double *p2, double *vpn); 00292 void MovePlusXFace(double *p1, double *p2); 00293 void MoveMinusXFace(double *p1, double *p2); 00294 void MovePlusYFace(double *p1, double *p2); 00295 void MoveMinusYFace(double *p1, double *p2); 00296 void MovePlusZFace(double *p1, double *p2); 00297 void MoveMinusZFace(double *p1, double *p2); 00298 00299 //"dir" is the direction in which the face can be moved i.e. the axis passing 00300 //through the center 00301 void MoveFace(double *p1, double *p2, double *dir, 00302 double *x1, double *x2, double *x3, double *x4, 00303 double *x5); 00304 //Helper method to obtain the direction in which the face is to be moved. 00305 //Handles special cases where some of the scale factors are 0. 00306 void GetDirection(const double Nx[3],const double Ny[3], 00307 const double Nz[3], double dir[3]); 00308 00309 // Transform the hexahedral points (used for rotations) 00310 vtkTransform *Transform; 00311 00312 // Properties used to control the appearance of selected objects and 00313 // the manipulator in general. 00314 vtkProperty *HandleProperty; 00315 vtkProperty *SelectedHandleProperty; 00316 vtkProperty *FaceProperty; 00317 vtkProperty *SelectedFaceProperty; 00318 vtkProperty *OutlineProperty; 00319 vtkProperty *SelectedOutlineProperty; 00320 void CreateDefaultProperties(); 00321 00322 // Control the orientation of the normals 00323 int InsideOut; 00324 int OutlineFaceWires; 00325 int OutlineCursorWires; 00326 void GenerateOutline(); 00327 00328 // Control whether scaling, rotation, and translation are supported 00329 int TranslationEnabled; 00330 int ScalingEnabled; 00331 int RotationEnabled; 00332 00333 private: 00334 vtkBoxWidget(const vtkBoxWidget&); //Not implemented 00335 void operator=(const vtkBoxWidget&); //Not implemented 00336 }; 00337 00338 #endif