VTK
vtkBoxWidget.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkBoxWidget.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
88 #ifndef __vtkBoxWidget_h
89 #define __vtkBoxWidget_h
90 
91 #include "vtk3DWidget.h"
92 
93 class vtkActor;
94 class vtkCellPicker;
95 class vtkPlanes;
96 class vtkPoints;
97 class vtkPolyData;
98 class vtkPolyDataMapper;
99 class vtkProp;
100 class vtkProperty;
101 class vtkSphereSource;
102 class vtkTransform;
103 
105 {
106 public:
108  static vtkBoxWidget *New();
109 
110  vtkTypeMacro(vtkBoxWidget,vtk3DWidget);
111  void PrintSelf(ostream& os, vtkIndent indent);
112 
114 
115  virtual void SetEnabled(int);
116  virtual void PlaceWidget(double bounds[6]);
117  void PlaceWidget()
118  {this->Superclass::PlaceWidget();}
119  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
120  double zmin, double zmax)
121  {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
123 
130  void GetPlanes(vtkPlanes *planes);
131 
133 
136  vtkSetMacro(InsideOut,int);
137  vtkGetMacro(InsideOut,int);
138  vtkBooleanMacro(InsideOut,int);
140 
146  virtual void GetTransform(vtkTransform *t);
147 
152  virtual void SetTransform(vtkTransform* t);
153 
162  void GetPolyData(vtkPolyData *pd);
163 
165 
167  vtkGetObjectMacro(HandleProperty,vtkProperty);
168  vtkGetObjectMacro(SelectedHandleProperty,vtkProperty);
170 
172 
174  void HandlesOn();
175  void HandlesOff();
177 
179 
181  vtkGetObjectMacro(FaceProperty,vtkProperty);
182  vtkGetObjectMacro(SelectedFaceProperty,vtkProperty);
184 
186 
188  vtkGetObjectMacro(OutlineProperty,vtkProperty);
189  vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty);
191 
193 
195  void SetOutlineFaceWires(int);
196  vtkGetMacro(OutlineFaceWires,int);
197  void OutlineFaceWiresOn() {this->SetOutlineFaceWires(1);}
198  void OutlineFaceWiresOff() {this->SetOutlineFaceWires(0);}
200 
202 
205  void SetOutlineCursorWires(int);
206  vtkGetMacro(OutlineCursorWires,int);
207  void OutlineCursorWiresOn() {this->SetOutlineCursorWires(1);}
208  void OutlineCursorWiresOff() {this->SetOutlineCursorWires(0);}
210 
212 
214  vtkSetMacro(TranslationEnabled,int);
215  vtkGetMacro(TranslationEnabled,int);
216  vtkBooleanMacro(TranslationEnabled,int);
217  vtkSetMacro(ScalingEnabled,int);
218  vtkGetMacro(ScalingEnabled,int);
219  vtkBooleanMacro(ScalingEnabled,int);
220  vtkSetMacro(RotationEnabled,int);
221  vtkGetMacro(RotationEnabled,int);
222  vtkBooleanMacro(RotationEnabled,int);
224 
225 protected:
226  vtkBoxWidget();
227  ~vtkBoxWidget();
228 
229 //BTX - manage the state of the widget
230  int State;
232  {
233  Start=0,
236  Outside
237  };
238 //ETX
239 
240  // Handles the events
241  static void ProcessEvents(vtkObject* object,
242  unsigned long event,
243  void* clientdata,
244  void* calldata);
245 
246  // ProcessEvents() dispatches to these methods.
247  virtual void OnMouseMove();
248  virtual void OnLeftButtonDown();
249  virtual void OnLeftButtonUp();
250  virtual void OnMiddleButtonDown();
251  virtual void OnMiddleButtonUp();
252  virtual void OnRightButtonDown();
253  virtual void OnRightButtonUp();
254 
255  // the hexahedron (6 faces)
259  vtkPoints *Points; //used by others as well
260  double N[6][3]; //the normals of the faces
261 
262  // A face of the hexahedron
266 
267  // glyphs representing hot spots (e.g., handles)
271  virtual void PositionHandles();
272  int HighlightHandle(vtkProp *prop); //returns cell id
273  void HighlightFace(int cellId);
274  void HighlightOutline(int highlight);
275  void ComputeNormals();
276  virtual void SizeHandles();
277 
278  // wireframe outline
282 
283  // Do the picking
288 
289  // Methods to manipulate the hexahedron.
290  virtual void Translate(double *p1, double *p2);
291  virtual void Scale(double *p1, double *p2, int X, int Y);
292  virtual void Rotate(int X, int Y, double *p1, double *p2, double *vpn);
293  void MovePlusXFace(double *p1, double *p2);
294  void MoveMinusXFace(double *p1, double *p2);
295  void MovePlusYFace(double *p1, double *p2);
296  void MoveMinusYFace(double *p1, double *p2);
297  void MovePlusZFace(double *p1, double *p2);
298  void MoveMinusZFace(double *p1, double *p2);
299 
300  //"dir" is the direction in which the face can be moved i.e. the axis passing
301  //through the center
302  void MoveFace(double *p1, double *p2, double *dir,
303  double *x1, double *x2, double *x3, double *x4,
304  double *x5);
305  //Helper method to obtain the direction in which the face is to be moved.
306  //Handles special cases where some of the scale factors are 0.
307  void GetDirection(const double Nx[3],const double Ny[3],
308  const double Nz[3], double dir[3]);
309 
310  // Transform the hexahedral points (used for rotations)
312 
313  // Properties used to control the appearance of selected objects and
314  // the manipulator in general.
321  void CreateDefaultProperties();
322 
323  // Control the orientation of the normals
327  void GenerateOutline();
328 
329  // Control whether scaling, rotation, and translation are supported
333 
334 private:
335  vtkBoxWidget(const vtkBoxWidget&); //Not implemented
336  void operator=(const vtkBoxWidget&); //Not implemented
337 };
338 
339 #endif