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 =========================================================================*/
83 #ifndef vtkBoxWidget_h
84 #define vtkBoxWidget_h
85 
86 #include "vtkInteractionWidgetsModule.h" // For export macro
87 #include "vtk3DWidget.h"
88 
89 class vtkActor;
90 class vtkCellPicker;
91 class vtkPlanes;
92 class vtkPoints;
93 class vtkPolyData;
94 class vtkPolyDataMapper;
95 class vtkProp;
96 class vtkProperty;
97 class vtkSphereSource;
98 class vtkTransform;
99 
101 {
102 public:
104  static vtkBoxWidget *New();
105 
106  vtkTypeMacro(vtkBoxWidget,vtk3DWidget);
107  void PrintSelf(ostream& os, vtkIndent indent);
108 
110 
111  virtual void SetEnabled(int);
112  virtual void PlaceWidget(double bounds[6]);
113  void PlaceWidget()
114  {this->Superclass::PlaceWidget();}
115  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
116  double zmin, double zmax)
117  {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
119 
126  void GetPlanes(vtkPlanes *planes);
127 
129 
132  vtkSetMacro(InsideOut,int);
133  vtkGetMacro(InsideOut,int);
134  vtkBooleanMacro(InsideOut,int);
136 
142  virtual void GetTransform(vtkTransform *t);
143 
148  virtual void SetTransform(vtkTransform* t);
149 
158  void GetPolyData(vtkPolyData *pd);
159 
161 
163  vtkGetObjectMacro(HandleProperty,vtkProperty);
164  vtkGetObjectMacro(SelectedHandleProperty,vtkProperty);
166 
168 
170  void HandlesOn();
171  void HandlesOff();
173 
175 
177  vtkGetObjectMacro(FaceProperty,vtkProperty);
178  vtkGetObjectMacro(SelectedFaceProperty,vtkProperty);
180 
182 
184  vtkGetObjectMacro(OutlineProperty,vtkProperty);
185  vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty);
187 
189 
191  void SetOutlineFaceWires(int);
192  vtkGetMacro(OutlineFaceWires,int);
193  void OutlineFaceWiresOn() {this->SetOutlineFaceWires(1);}
194  void OutlineFaceWiresOff() {this->SetOutlineFaceWires(0);}
196 
198 
201  void SetOutlineCursorWires(int);
202  vtkGetMacro(OutlineCursorWires,int);
203  void OutlineCursorWiresOn() {this->SetOutlineCursorWires(1);}
204  void OutlineCursorWiresOff() {this->SetOutlineCursorWires(0);}
206 
208 
210  vtkSetMacro(TranslationEnabled,int);
211  vtkGetMacro(TranslationEnabled,int);
212  vtkBooleanMacro(TranslationEnabled,int);
213  vtkSetMacro(ScalingEnabled,int);
214  vtkGetMacro(ScalingEnabled,int);
215  vtkBooleanMacro(ScalingEnabled,int);
216  vtkSetMacro(RotationEnabled,int);
217  vtkGetMacro(RotationEnabled,int);
218  vtkBooleanMacro(RotationEnabled,int);
220 
221 protected:
222  vtkBoxWidget();
223  ~vtkBoxWidget();
224 
225  // Manage the state of the widget
226  int State;
228  {
229  Start=0,
232  Outside
233  };
234 
235  // Handles the events
236  static void ProcessEvents(vtkObject* object,
237  unsigned long event,
238  void* clientdata,
239  void* calldata);
240 
241  // ProcessEvents() dispatches to these methods.
242  virtual void OnMouseMove();
243  virtual void OnLeftButtonDown();
244  virtual void OnLeftButtonUp();
245  virtual void OnMiddleButtonDown();
246  virtual void OnMiddleButtonUp();
247  virtual void OnRightButtonDown();
248  virtual void OnRightButtonUp();
249 
250  // the hexahedron (6 faces)
254  vtkPoints *Points; //used by others as well
255  double N[6][3]; //the normals of the faces
256 
257  // A face of the hexahedron
261 
262  // glyphs representing hot spots (e.g., handles)
266  virtual void PositionHandles();
267  int HighlightHandle(vtkProp *prop); //returns cell id
268  void HighlightFace(int cellId);
269  void HighlightOutline(int highlight);
270  void ComputeNormals();
271  virtual void SizeHandles();
272 
273  // wireframe outline
277 
278  // Do the picking
283 
284  // Register internal Pickers within PickingManager
285  virtual void RegisterPickers();
286 
287  // Methods to manipulate the hexahedron.
288  virtual void Translate(double *p1, double *p2);
289  virtual void Scale(double *p1, double *p2, int X, int Y);
290  virtual void Rotate(int X, int Y, double *p1, double *p2, double *vpn);
291  void MovePlusXFace(double *p1, double *p2);
292  void MoveMinusXFace(double *p1, double *p2);
293  void MovePlusYFace(double *p1, double *p2);
294  void MoveMinusYFace(double *p1, double *p2);
295  void MovePlusZFace(double *p1, double *p2);
296  void MoveMinusZFace(double *p1, double *p2);
297 
298  //"dir" is the direction in which the face can be moved i.e. the axis passing
299  //through the center
300  void MoveFace(double *p1, double *p2, double *dir,
301  double *x1, double *x2, double *x3, double *x4,
302  double *x5);
303  //Helper method to obtain the direction in which the face is to be moved.
304  //Handles special cases where some of the scale factors are 0.
305  void GetDirection(const double Nx[3],const double Ny[3],
306  const double Nz[3], double dir[3]);
307 
308  // Transform the hexahedral points (used for rotations)
310 
311  // Properties used to control the appearance of selected objects and
312  // the manipulator in general.
319  void CreateDefaultProperties();
320 
321  // Control the orientation of the normals
325  void GenerateOutline();
326 
327  // Control whether scaling, rotation, and translation are supported
331 
332 private:
333  vtkBoxWidget(const vtkBoxWidget&); //Not implemented
334  void operator=(const vtkBoxWidget&); //Not implemented
335 };
336 
337 #endif
vtkPolyDataMapper * HexMapper
Definition: vtkBoxWidget.h:252
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:52
vtkActor ** Handle
Definition: vtkBoxWidget.h:263
vtkProperty * HandleProperty
Definition: vtkBoxWidget.h:313
vtkProperty * SelectedOutlineProperty
Definition: vtkBoxWidget.h:318
vtkActor * HexActor
Definition: vtkBoxWidget.h:251
vtkActor * CurrentHandle
Definition: vtkBoxWidget.h:281
void PlaceWidget()
Definition: vtkBoxWidget.h:113
vtkPolyDataMapper * HexFaceMapper
Definition: vtkBoxWidget.h:259
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:50
abstract base class for most VTK objects
Definition: vtkObject.h:61
int TranslationEnabled
Definition: vtkBoxWidget.h:328
vtkPolyDataMapper ** HandleMapper
Definition: vtkBoxWidget.h:264
represent surface properties of a geometric object
Definition: vtkProperty.h:63
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
vtkActor * HexFace
Definition: vtkBoxWidget.h:258
virtual void SetEnabled(int)
implicit function for convex set of planes
Definition: vtkPlanes.h:53
void OutlineFaceWiresOff()
Definition: vtkBoxWidget.h:194
vtkPolyDataMapper * OutlineMapper
Definition: vtkBoxWidget.h:275
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:59
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
vtkProperty * FaceProperty
Definition: vtkBoxWidget.h:315
vtkPolyData * OutlinePolyData
Definition: vtkBoxWidget.h:276
vtkTransform * Transform
Definition: vtkBoxWidget.h:309
vtkCellPicker * HexPicker
Definition: vtkBoxWidget.h:280
vtkPolyData * HexFacePolyData
Definition: vtkBoxWidget.h:260
virtual void RegisterPickers()
vtkPoints * Points
Definition: vtkBoxWidget.h:254
#define VTKINTERACTIONWIDGETS_EXPORT
create a polygonal sphere centered at the origin
vtkProperty * SelectedFaceProperty
Definition: vtkBoxWidget.h:316
a simple class to control print indentation
Definition: vtkIndent.h:38
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
Definition: vtkBoxWidget.h:115
vtkProperty * OutlineProperty
Definition: vtkBoxWidget.h:317
vtkCellPicker * HandlePicker
Definition: vtkBoxWidget.h:279
vtkActor * HexOutline
Definition: vtkBoxWidget.h:274
map vtkPolyData to graphics primitives
vtkPolyData * HexPolyData
Definition: vtkBoxWidget.h:253
void OutlineCursorWiresOn()
Definition: vtkBoxWidget.h:203
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:68
orthogonal hexahedron 3D widget
Definition: vtkBoxWidget.h:100
int OutlineFaceWires
Definition: vtkBoxWidget.h:323
void OutlineCursorWiresOff()
Definition: vtkBoxWidget.h:204
int OutlineCursorWires
Definition: vtkBoxWidget.h:324
static vtkObject * New()
void OutlineFaceWiresOn()
Definition: vtkBoxWidget.h:193
void PrintSelf(ostream &os, vtkIndent indent)
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:69
virtual void SizeHandles()
Definition: vtk3DWidget.h:145
virtual void PlaceWidget()
represent and manipulate 3D points
Definition: vtkPoints.h:38
vtkSphereSource ** HandleGeometry
Definition: vtkBoxWidget.h:265
vtkProperty * SelectedHandleProperty
Definition: vtkBoxWidget.h:314