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 =========================================================================*/
81 #ifndef vtkBoxWidget_h
82 #define vtkBoxWidget_h
83 
84 #include "vtkInteractionWidgetsModule.h" // For export macro
85 #include "vtk3DWidget.h"
86 
87 class vtkActor;
88 class vtkCellPicker;
89 class vtkPlanes;
90 class vtkPoints;
91 class vtkPolyData;
92 class vtkPolyDataMapper;
93 class vtkProp;
94 class vtkProperty;
95 class vtkSphereSource;
96 class vtkTransform;
97 
98 class VTKINTERACTIONWIDGETS_EXPORT vtkBoxWidget : public vtk3DWidget
99 {
100 public:
104  static vtkBoxWidget *New();
105 
106  vtkTypeMacro(vtkBoxWidget,vtk3DWidget);
107  void PrintSelf(ostream& os, vtkIndent indent);
108 
110 
113  virtual void SetEnabled(int);
114  virtual void PlaceWidget(double bounds[6]);
115  void PlaceWidget()
116  {this->Superclass::PlaceWidget();}
117  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
118  double zmin, double zmax)
119  {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
121 
130  void GetPlanes(vtkPlanes *planes);
131 
133 
138  vtkSetMacro(InsideOut,int);
139  vtkGetMacro(InsideOut,int);
140  vtkBooleanMacro(InsideOut,int);
142 
150  virtual void GetTransform(vtkTransform *t);
151 
158  virtual void SetTransform(vtkTransform* t);
159 
171 
173 
178  vtkGetObjectMacro(HandleProperty,vtkProperty);
179  vtkGetObjectMacro(SelectedHandleProperty,vtkProperty);
181 
183 
187  void HandlesOn();
188  void HandlesOff();
190 
192 
197  vtkGetObjectMacro(FaceProperty,vtkProperty);
198  vtkGetObjectMacro(SelectedFaceProperty,vtkProperty);
200 
202 
207  vtkGetObjectMacro(OutlineProperty,vtkProperty);
208  vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty);
210 
212 
217  vtkGetMacro(OutlineFaceWires,int);
218  void OutlineFaceWiresOn() {this->SetOutlineFaceWires(1);}
219  void OutlineFaceWiresOff() {this->SetOutlineFaceWires(0);}
221 
223 
229  vtkGetMacro(OutlineCursorWires,int);
230  void OutlineCursorWiresOn() {this->SetOutlineCursorWires(1);}
231  void OutlineCursorWiresOff() {this->SetOutlineCursorWires(0);}
233 
235 
239  vtkSetMacro(TranslationEnabled,int);
240  vtkGetMacro(TranslationEnabled,int);
241  vtkBooleanMacro(TranslationEnabled,int);
242  vtkSetMacro(ScalingEnabled,int);
243  vtkGetMacro(ScalingEnabled,int);
244  vtkBooleanMacro(ScalingEnabled,int);
245  vtkSetMacro(RotationEnabled,int);
246  vtkGetMacro(RotationEnabled,int);
247  vtkBooleanMacro(RotationEnabled,int);
249 
250 protected:
253 
254  // Manage the state of the widget
255  int State;
257  {
258  Start=0,
261  Outside
262  };
263 
264  // Handles the events
265  static void ProcessEvents(vtkObject* object,
266  unsigned long event,
267  void* clientdata,
268  void* calldata);
269 
270  // ProcessEvents() dispatches to these methods.
271  virtual void OnMouseMove();
272  virtual void OnLeftButtonDown();
273  virtual void OnLeftButtonUp();
274  virtual void OnMiddleButtonDown();
275  virtual void OnMiddleButtonUp();
276  virtual void OnRightButtonDown();
277  virtual void OnRightButtonUp();
278 
279  // the hexahedron (6 faces)
283  vtkPoints *Points; //used by others as well
284  double N[6][3]; //the normals of the faces
285 
286  // A face of the hexahedron
290 
291  // glyphs representing hot spots (e.g., handles)
295  virtual void PositionHandles();
296  int HighlightHandle(vtkProp *prop); //returns cell id
297  void HighlightFace(int cellId);
298  void HighlightOutline(int highlight);
300  virtual void SizeHandles();
301 
302  // wireframe outline
306 
307  // Do the picking
312 
313  // Register internal Pickers within PickingManager
314  virtual void RegisterPickers();
315 
316  // Methods to manipulate the hexahedron.
317  virtual void Translate(double *p1, double *p2);
318  virtual void Scale(double *p1, double *p2, int X, int Y);
319  virtual void Rotate(int X, int Y, double *p1, double *p2, double *vpn);
320  void MovePlusXFace(double *p1, double *p2);
321  void MoveMinusXFace(double *p1, double *p2);
322  void MovePlusYFace(double *p1, double *p2);
323  void MoveMinusYFace(double *p1, double *p2);
324  void MovePlusZFace(double *p1, double *p2);
325  void MoveMinusZFace(double *p1, double *p2);
326 
327  //"dir" is the direction in which the face can be moved i.e. the axis passing
328  //through the center
329  void MoveFace(double *p1, double *p2, double *dir,
330  double *x1, double *x2, double *x3, double *x4,
331  double *x5);
332  //Helper method to obtain the direction in which the face is to be moved.
333  //Handles special cases where some of the scale factors are 0.
334  void GetDirection(const double Nx[3],const double Ny[3],
335  const double Nz[3], double dir[3]);
336 
337  // Transform the hexahedral points (used for rotations)
339 
340  // Properties used to control the appearance of selected objects and
341  // the manipulator in general.
349 
350  // Control the orientation of the normals
355 
356  // Control whether scaling, rotation, and translation are supported
360 
361 private:
362  vtkBoxWidget(const vtkBoxWidget&) VTK_DELETE_FUNCTION;
363  void operator=(const vtkBoxWidget&) VTK_DELETE_FUNCTION;
364 };
365 
366 #endif
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:68
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:52
orthogonal hexahedron 3D widget
Definition: vtkBoxWidget.h:99
virtual void OnLeftButtonDown()
void PlaceWidget()
Definition: vtkBoxWidget.h:115
virtual void PositionHandles()
void SetOutlineCursorWires(int)
Control the representation of the outline.
void GenerateOutline()
void OutlineCursorWiresOff()
Definition: vtkBoxWidget.h:231
virtual void Scale(double *p1, double *p2, int X, int Y)
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
Definition: vtkBoxWidget.h:117
vtkPolyData * HexPolyData
Definition: vtkBoxWidget.h:282
void CreateDefaultProperties()
vtkPolyData * HexFacePolyData
Definition: vtkBoxWidget.h:289
virtual void Translate(double *p1, double *p2)
vtkActor * HexOutline
Definition: vtkBoxWidget.h:303
static vtkBoxWidget * New()
Instantiate the object.
void ComputeNormals()
void HighlightOutline(int highlight)
vtkSphereSource ** HandleGeometry
Definition: vtkBoxWidget.h:294
vtkTransform * Transform
Definition: vtkBoxWidget.h:338
vtkProperty * SelectedFaceProperty
Definition: vtkBoxWidget.h:345
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtkCellPicker * HandlePicker
Definition: vtkBoxWidget.h:308
virtual void Rotate(int X, int Y, double *p1, double *p2, double *vpn)
virtual void SizeHandles()
void MoveFace(double *p1, double *p2, double *dir, double *x1, double *x2, double *x3, double *x4, double *x5)
vtkProperty * HandleProperty
Definition: vtkBoxWidget.h:342
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
virtual void OnRightButtonUp()
void OutlineCursorWiresOn()
Definition: vtkBoxWidget.h:230
void MovePlusYFace(double *p1, double *p2)
vtkCellPicker * HexPicker
Definition: vtkBoxWidget.h:309
vtkPolyDataMapper * HexMapper
Definition: vtkBoxWidget.h:281
virtual void OnMiddleButtonDown()
vtkPoints * Points
Definition: vtkBoxWidget.h:283
int OutlineCursorWires
Definition: vtkBoxWidget.h:353
void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3])
void HandlesOn()
Switches handles (the spheres) on or off by manipulating the actor visibility.
int OutlineFaceWires
Definition: vtkBoxWidget.h:352
void SetOutlineFaceWires(int)
Control the representation of the outline.
vtkPolyDataMapper * HexFaceMapper
Definition: vtkBoxWidget.h:288
int HighlightHandle(vtkProp *prop)
vtkActor * HexActor
Definition: vtkBoxWidget.h:280
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
virtual void SetEnabled(int)
Methods that satisfy the superclass' API.
vtkProperty * OutlineProperty
Definition: vtkBoxWidget.h:346
vtkActor ** Handle
Definition: vtkBoxWidget.h:292
void OutlineFaceWiresOn()
Definition: vtkBoxWidget.h:218
vtkPolyData * OutlinePolyData
Definition: vtkBoxWidget.h:305
void MoveMinusXFace(double *p1, double *p2)
void MovePlusXFace(double *p1, double *p2)
virtual void PlaceWidget(double bounds[6])
This method is used to initially place the widget.
virtual void GetTransform(vtkTransform *t)
Retrieve a linear transform characterizing the transformation of the box.
vtkProperty * FaceProperty
Definition: vtkBoxWidget.h:344
vtkActor * HexFace
Definition: vtkBoxWidget.h:287
void OutlineFaceWiresOff()
Definition: vtkBoxWidget.h:219
void MoveMinusZFace(double *p1, double *p2)
virtual void SetTransform(vtkTransform *t)
Set the position, scale and orientation of the box widget using the transform specified.
virtual void OnLeftButtonUp()
void MovePlusZFace(double *p1, double *p2)
virtual void OnRightButtonDown()
virtual void OnMiddleButtonUp()
void HandlesOff()
vtkProperty * SelectedHandleProperty
Definition: vtkBoxWidget.h:343
void MoveMinusYFace(double *p1, double *p2)
virtual void OnMouseMove()
void GetPolyData(vtkPolyData *pd)
Grab the polydata (including points) that define the box widget.
int TranslationEnabled
Definition: vtkBoxWidget.h:357
vtkPolyDataMapper * OutlineMapper
Definition: vtkBoxWidget.h:304
vtkProperty * SelectedOutlineProperty
Definition: vtkBoxWidget.h:347
vtkPolyDataMapper ** HandleMapper
Definition: vtkBoxWidget.h:293
vtkActor * CurrentHandle
Definition: vtkBoxWidget.h:310
void HighlightFace(int cellId)
void GetPlanes(vtkPlanes *planes)
Get the planes describing the implicit function defined by the box widget.
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:70
a simple class to control print indentation
Definition: vtkIndent.h:40
abstract base class for most VTK objects
Definition: vtkObject.h:60
implicit function for convex set of planes
Definition: vtkPlanes.h:55
represent and manipulate 3D points
Definition: vtkPoints.h:40
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:86
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:48
represent surface properties of a geometric object
Definition: vtkProperty.h:65
create a polygonal sphere centered at the origin
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:61
@ dir
Definition: vtkX3D.h:324
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.