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