00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00099 #ifndef __vtkBoxWidget_h
00100 #define __vtkBoxWidget_h
00101
00102 #include "vtk3DWidget.h"
00103
00104 class vtkActor;
00105 class vtkCellPicker;
00106 class vtkPlanes;
00107 class vtkPoints;
00108 class vtkPolyData;
00109 class vtkPolyDataMapper;
00110 class vtkProp;
00111 class vtkProperty;
00112 class vtkSphereSource;
00113 class vtkTransform;
00114
00115 class VTK_HYBRID_EXPORT vtkBoxWidget : public vtk3DWidget
00116 {
00117 public:
00119 static vtkBoxWidget *New();
00120
00121 vtkTypeRevisionMacro(vtkBoxWidget,vtk3DWidget);
00122 void PrintSelf(ostream& os, vtkIndent indent);
00123
00125
00126 virtual void SetEnabled(int);
00127 virtual void PlaceWidget(double bounds[6]);
00128 void PlaceWidget()
00129 {this->Superclass::PlaceWidget();}
00130 void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
00131 double zmin, double zmax)
00132 {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
00134
00141 void GetPlanes(vtkPlanes *planes);
00142
00144
00147 vtkSetMacro(InsideOut,int);
00148 vtkGetMacro(InsideOut,int);
00149 vtkBooleanMacro(InsideOut,int);
00151
00157 virtual void GetTransform(vtkTransform *t);
00158
00163 virtual void SetTransform(vtkTransform* t);
00164
00173 void GetPolyData(vtkPolyData *pd);
00174
00176
00178 vtkGetObjectMacro(HandleProperty,vtkProperty);
00179 vtkGetObjectMacro(SelectedHandleProperty,vtkProperty);
00181
00183
00185 void HandlesOn();
00186 void HandlesOff();
00188
00190
00192 vtkGetObjectMacro(FaceProperty,vtkProperty);
00193 vtkGetObjectMacro(SelectedFaceProperty,vtkProperty);
00195
00197
00199 vtkGetObjectMacro(OutlineProperty,vtkProperty);
00200 vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty);
00202
00204
00206 void SetOutlineFaceWires(int);
00207 vtkGetMacro(OutlineFaceWires,int);
00208 void OutlineFaceWiresOn() {this->SetOutlineFaceWires(1);}
00209 void OutlineFaceWiresOff() {this->SetOutlineFaceWires(0);}
00211
00213
00216 void SetOutlineCursorWires(int);
00217 vtkGetMacro(OutlineCursorWires,int);
00218 void OutlineCursorWiresOn() {this->SetOutlineCursorWires(1);}
00219 void OutlineCursorWiresOff() {this->SetOutlineCursorWires(0);}
00221
00223
00225 vtkSetMacro(TranslationEnabled,int);
00226 vtkGetMacro(TranslationEnabled,int);
00227 vtkBooleanMacro(TranslationEnabled,int);
00228 vtkSetMacro(ScalingEnabled,int);
00229 vtkGetMacro(ScalingEnabled,int);
00230 vtkBooleanMacro(ScalingEnabled,int);
00231 vtkSetMacro(RotationEnabled,int);
00232 vtkGetMacro(RotationEnabled,int);
00233 vtkBooleanMacro(RotationEnabled,int);
00235
00236 protected:
00237 vtkBoxWidget();
00238 ~vtkBoxWidget();
00239
00240
00241 int State;
00242 enum WidgetState
00243 {
00244 Start=0,
00245 Moving,
00246 Scaling,
00247 Outside
00248 };
00249
00250
00251
00252 static void ProcessEvents(vtkObject* object,
00253 unsigned long event,
00254 void* clientdata,
00255 void* calldata);
00256
00257
00258 virtual void OnMouseMove();
00259 virtual void OnLeftButtonDown();
00260 virtual void OnLeftButtonUp();
00261 virtual void OnMiddleButtonDown();
00262 virtual void OnMiddleButtonUp();
00263 virtual void OnRightButtonDown();
00264 virtual void OnRightButtonUp();
00265
00266
00267 vtkActor *HexActor;
00268 vtkPolyDataMapper *HexMapper;
00269 vtkPolyData *HexPolyData;
00270 vtkPoints *Points;
00271 double N[6][3];
00272
00273
00274 vtkActor *HexFace;
00275 vtkPolyDataMapper *HexFaceMapper;
00276 vtkPolyData *HexFacePolyData;
00277
00278
00279 vtkActor **Handle;
00280 vtkPolyDataMapper **HandleMapper;
00281 vtkSphereSource **HandleGeometry;
00282 virtual void PositionHandles();
00283 int HighlightHandle(vtkProp *prop);
00284 void HighlightFace(int cellId);
00285 void HighlightOutline(int highlight);
00286 void ComputeNormals();
00287 virtual void SizeHandles();
00288
00289
00290 vtkActor *HexOutline;
00291 vtkPolyDataMapper *OutlineMapper;
00292 vtkPolyData *OutlinePolyData;
00293
00294
00295 vtkCellPicker *HandlePicker;
00296 vtkCellPicker *HexPicker;
00297 vtkActor *CurrentHandle;
00298 int CurrentHexFace;
00299
00300
00301 virtual void Translate(double *p1, double *p2);
00302 virtual void Scale(double *p1, double *p2, int X, int Y);
00303 virtual void Rotate(int X, int Y, double *p1, double *p2, double *vpn);
00304 void MovePlusXFace(double *p1, double *p2);
00305 void MoveMinusXFace(double *p1, double *p2);
00306 void MovePlusYFace(double *p1, double *p2);
00307 void MoveMinusYFace(double *p1, double *p2);
00308 void MovePlusZFace(double *p1, double *p2);
00309 void MoveMinusZFace(double *p1, double *p2);
00310
00311
00312
00313 void MoveFace(double *p1, double *p2, double *dir,
00314 double *x1, double *x2, double *x3, double *x4,
00315 double *x5);
00316
00317
00318 void GetDirection(const double Nx[3],const double Ny[3],
00319 const double Nz[3], double dir[3]);
00320
00321
00322 vtkTransform *Transform;
00323
00324
00325
00326 vtkProperty *HandleProperty;
00327 vtkProperty *SelectedHandleProperty;
00328 vtkProperty *FaceProperty;
00329 vtkProperty *SelectedFaceProperty;
00330 vtkProperty *OutlineProperty;
00331 vtkProperty *SelectedOutlineProperty;
00332 void CreateDefaultProperties();
00333
00334
00335 int InsideOut;
00336 int OutlineFaceWires;
00337 int OutlineCursorWires;
00338 void GenerateOutline();
00339
00340
00341 int TranslationEnabled;
00342 int ScalingEnabled;
00343 int RotationEnabled;
00344
00345 private:
00346 vtkBoxWidget(const vtkBoxWidget&);
00347 void operator=(const vtkBoxWidget&);
00348 };
00349
00350 #endif