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 
170  void GetPolyData(vtkPolyData *pd);
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 
216  void SetOutlineFaceWires(int);
217  vtkGetMacro(OutlineFaceWires,int);
218  void OutlineFaceWiresOn() {this->SetOutlineFaceWires(1);}
219  void OutlineFaceWiresOff() {this->SetOutlineFaceWires(0);}
221 
223 
228  void SetOutlineCursorWires(int);
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:
251  vtkBoxWidget();
252  ~vtkBoxWidget();
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);
299  void ComputeNormals();
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.
348  void CreateDefaultProperties();
349 
350  // Control the orientation of the normals
354  void GenerateOutline();
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
vtkPolyDataMapper * HexMapper
Definition: vtkBoxWidget.h:281
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:50
vtkActor ** Handle
Definition: vtkBoxWidget.h:292
vtkProperty * HandleProperty
Definition: vtkBoxWidget.h:342
vtkProperty * SelectedOutlineProperty
Definition: vtkBoxWidget.h:347
vtkActor * HexActor
Definition: vtkBoxWidget.h:280
vtkActor * CurrentHandle
Definition: vtkBoxWidget.h:310
void PlaceWidget()
Methods that satisfy the superclass' API.
Definition: vtkBoxWidget.h:115
vtkPolyDataMapper * HexFaceMapper
Definition: vtkBoxWidget.h:288
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
abstract base class for most VTK objects
Definition: vtkObject.h:59
int TranslationEnabled
Definition: vtkBoxWidget.h:357
vtkPolyDataMapper ** HandleMapper
Definition: vtkBoxWidget.h:293
represent surface properties of a geometric object
Definition: vtkProperty.h:64
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
Handles the char widget activation event.
vtkActor * HexFace
Definition: vtkBoxWidget.h:287
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
implicit function for convex set of planes
Definition: vtkPlanes.h:54
void OutlineFaceWiresOff()
Control the representation of the outline.
Definition: vtkBoxWidget.h:219
vtkPolyDataMapper * OutlineMapper
Definition: vtkBoxWidget.h:304
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:60
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
vtkProperty * FaceProperty
Definition: vtkBoxWidget.h:344
vtkPolyData * OutlinePolyData
Definition: vtkBoxWidget.h:305
vtkTransform * Transform
Definition: vtkBoxWidget.h:338
vtkCellPicker * HexPicker
Definition: vtkBoxWidget.h:309
vtkPolyData * HexFacePolyData
Definition: vtkBoxWidget.h:289
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
vtkPoints * Points
Definition: vtkBoxWidget.h:283
create a polygonal sphere centered at the origin
vtkProperty * SelectedFaceProperty
Definition: vtkBoxWidget.h:345
a simple class to control print indentation
Definition: vtkIndent.h:39
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
Methods that satisfy the superclass' API.
Definition: vtkBoxWidget.h:117
vtkProperty * OutlineProperty
Definition: vtkBoxWidget.h:346
vtkCellPicker * HandlePicker
Definition: vtkBoxWidget.h:308
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
vtkActor * HexOutline
Definition: vtkBoxWidget.h:303
map vtkPolyData to graphics primitives
vtkPolyData * HexPolyData
Definition: vtkBoxWidget.h:282
void OutlineCursorWiresOn()
Control the representation of the outline.
Definition: vtkBoxWidget.h:230
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:69
orthogonal hexahedron 3D widget
Definition: vtkBoxWidget.h:98
int OutlineFaceWires
Definition: vtkBoxWidget.h:352
void OutlineCursorWiresOff()
Control the representation of the outline.
Definition: vtkBoxWidget.h:231
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
int OutlineCursorWires
Definition: vtkBoxWidget.h:353
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
void OutlineFaceWiresOn()
Control the representation of the outline.
Definition: vtkBoxWidget.h:218
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:67
virtual void SizeHandles()
Definition: vtk3DWidget.h:152
virtual void PlaceWidget()
This method is used to initially place the widget.
represent and manipulate 3D points
Definition: vtkPoints.h:39
vtkSphereSource ** HandleGeometry
Definition: vtkBoxWidget.h:294
vtkProperty * SelectedHandleProperty
Definition: vtkBoxWidget.h:343