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
vtkPolyDataMapper
map vtkPolyData to graphics primitives
Definition: vtkPolyDataMapper.h:43
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:40
vtkBoxWidget::MoveFace
void MoveFace(double *p1, double *p2, double *dir, double *x1, double *x2, double *x3, double *x4, double *x5)
vtkBoxWidget::PlaceWidget
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
Definition: vtkBoxWidget.h:117
vtkBoxWidget::MovePlusZFace
void MovePlusZFace(double *p1, double *p2)
vtkBoxWidget::OutlineProperty
vtkProperty * OutlineProperty
Definition: vtkBoxWidget.h:346
vtkBoxWidget::GenerateOutline
void GenerateOutline()
vtkBoxWidget::SizeHandles
virtual void SizeHandles()
vtkBoxWidget::HighlightOutline
void HighlightOutline(int highlight)
vtkBoxWidget::OutlineFaceWiresOn
void OutlineFaceWiresOn()
Definition: vtkBoxWidget.h:218
vtkBoxWidget::OnMiddleButtonDown
virtual void OnMiddleButtonDown()
vtkBoxWidget::FaceProperty
vtkProperty * FaceProperty
Definition: vtkBoxWidget.h:344
vtkBoxWidget::~vtkBoxWidget
~vtkBoxWidget()
vtkBoxWidget::HexPolyData
vtkPolyData * HexPolyData
Definition: vtkBoxWidget.h:282
vtkBoxWidget::SetOutlineFaceWires
void SetOutlineFaceWires(int)
Control the representation of the outline.
vtkBoxWidget::InsideOut
int InsideOut
Definition: vtkBoxWidget.h:351
vtkBoxWidget::MovePlusYFace
void MovePlusYFace(double *p1, double *p2)
vtkBoxWidget::HexPicker
vtkCellPicker * HexPicker
Definition: vtkBoxWidget.h:309
vtkBoxWidget::HexMapper
vtkPolyDataMapper * HexMapper
Definition: vtkBoxWidget.h:281
vtkBoxWidget::HandlePicker
vtkCellPicker * HandlePicker
Definition: vtkBoxWidget.h:308
vtkBoxWidget::SelectedOutlineProperty
vtkProperty * SelectedOutlineProperty
Definition: vtkBoxWidget.h:347
vtkBoxWidget::GetPlanes
void GetPlanes(vtkPlanes *planes)
Get the planes describing the implicit function defined by the box widget.
vtkBoxWidget::SetEnabled
virtual void SetEnabled(int)
Methods that satisfy the superclass' API.
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:60
vtkX3D::dir
@ dir
Definition: vtkX3D.h:324
vtkBoxWidget::OnRightButtonDown
virtual void OnRightButtonDown()
vtkBoxWidget::OnLeftButtonUp
virtual void OnLeftButtonUp()
vtkPlanes
implicit function for convex set of planes
Definition: vtkPlanes.h:55
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:61
vtkBoxWidget::TranslationEnabled
int TranslationEnabled
Definition: vtkBoxWidget.h:357
vtkBoxWidget::SelectedFaceProperty
vtkProperty * SelectedFaceProperty
Definition: vtkBoxWidget.h:345
vtkBoxWidget::OutlineCursorWiresOn
void OutlineCursorWiresOn()
Definition: vtkBoxWidget.h:230
vtkBoxWidget::HexFace
vtkActor * HexFace
Definition: vtkBoxWidget.h:287
vtkBoxWidget::OutlineCursorWiresOff
void OutlineCursorWiresOff()
Definition: vtkBoxWidget.h:231
vtkBoxWidget::Translate
virtual void Translate(double *p1, double *p2)
vtkBoxWidget::HandleGeometry
vtkSphereSource ** HandleGeometry
Definition: vtkBoxWidget.h:294
vtkBoxWidget::MoveMinusXFace
void MoveMinusXFace(double *p1, double *p2)
vtkBoxWidget::MoveMinusZFace
void MoveMinusZFace(double *p1, double *p2)
vtkBoxWidget::SelectedHandleProperty
vtkProperty * SelectedHandleProperty
Definition: vtkBoxWidget.h:343
vtkBoxWidget::OnMouseMove
virtual void OnMouseMove()
vtkBoxWidget::GetTransform
virtual void GetTransform(vtkTransform *t)
Retrieve a linear transform characterizing the transformation of the box.
vtkBoxWidget::OutlineCursorWires
int OutlineCursorWires
Definition: vtkBoxWidget.h:353
vtkBoxWidget::WidgetState
WidgetState
Definition: vtkBoxWidget.h:257
vtkBoxWidget::RegisterPickers
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
vtkBoxWidget::Handle
vtkActor ** Handle
Definition: vtkBoxWidget.h:292
vtkBoxWidget::OutlineFaceWiresOff
void OutlineFaceWiresOff()
Definition: vtkBoxWidget.h:219
vtkBoxWidget::CurrentHexFace
int CurrentHexFace
Definition: vtkBoxWidget.h:311
vtkBoxWidget::HighlightFace
void HighlightFace(int cellId)
vtkBoxWidget::OutlineMapper
vtkPolyDataMapper * OutlineMapper
Definition: vtkBoxWidget.h:304
vtkSphereSource
create a polygonal sphere centered at the origin
Definition: vtkSphereSource.h:47
vtkBoxWidget::OnLeftButtonDown
virtual void OnLeftButtonDown()
vtkBoxWidget::HandleProperty
vtkProperty * HandleProperty
Definition: vtkBoxWidget.h:342
vtkBoxWidget::CreateDefaultProperties
void CreateDefaultProperties()
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:52
vtkBoxWidget::MovePlusXFace
void MovePlusXFace(double *p1, double *p2)
vtkBoxWidget::PlaceWidget
void PlaceWidget()
Definition: vtkBoxWidget.h:115
vtkBoxWidget
orthogonal hexahedron 3D widget
Definition: vtkBoxWidget.h:99
vtkBoxWidget::HexFaceMapper
vtkPolyDataMapper * HexFaceMapper
Definition: vtkBoxWidget.h:288
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkBoxWidget::CurrentHandle
vtkActor * CurrentHandle
Definition: vtkBoxWidget.h:310
vtkBoxWidget::Rotate
virtual void Rotate(int X, int Y, double *p1, double *p2, double *vpn)
vtk3DWidget
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:68
vtkBoxWidget::HexActor
vtkActor * HexActor
Definition: vtkBoxWidget.h:280
vtkBoxWidget::OnRightButtonUp
virtual void OnRightButtonUp()
vtkBoxWidget::GetPolyData
void GetPolyData(vtkPolyData *pd)
Grab the polydata (including points) that define the box widget.
vtkBoxWidget::PositionHandles
virtual void PositionHandles()
vtkBoxWidget::Scaling
@ Scaling
Definition: vtkBoxWidget.h:260
vtkBoxWidget::OutlineFaceWires
int OutlineFaceWires
Definition: vtkBoxWidget.h:352
vtkBoxWidget::New
static vtkBoxWidget * New()
Instantiate the object.
vtkBoxWidget::ScalingEnabled
int ScalingEnabled
Definition: vtkBoxWidget.h:358
vtkBoxWidget::RotationEnabled
int RotationEnabled
Definition: vtkBoxWidget.h:359
vtkBooleanMacro
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkSetMacro
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkProp
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:48
vtkBoxWidget::Moving
@ Moving
Definition: vtkBoxWidget.h:259
vtkBoxWidget::HandlesOn
void HandlesOn()
Switches handles (the spheres) on or off by manipulating the actor visibility.
vtkBoxWidget::MoveMinusYFace
void MoveMinusYFace(double *p1, double *p2)
vtkBoxWidget::PlaceWidget
virtual void PlaceWidget(double bounds[6])
This method is used to initially place the widget.
vtkBoxWidget::State
int State
Definition: vtkBoxWidget.h:255
vtkBoxWidget::OutlinePolyData
vtkPolyData * OutlinePolyData
Definition: vtkBoxWidget.h:305
vtkBoxWidget::SetOutlineCursorWires
void SetOutlineCursorWires(int)
Control the representation of the outline.
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:86
vtkBoxWidget::HighlightHandle
int HighlightHandle(vtkProp *prop)
vtkBoxWidget::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtkBoxWidget::HexOutline
vtkActor * HexOutline
Definition: vtkBoxWidget.h:303
vtkBoxWidget::Transform
vtkTransform * Transform
Definition: vtkBoxWidget.h:338
vtk3DWidget.h
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:65
vtkBoxWidget::ProcessEvents
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
vtkBoxWidget::HexFacePolyData
vtkPolyData * HexFacePolyData
Definition: vtkBoxWidget.h:289
vtkCellPicker
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:70
vtkBoxWidget::SetTransform
virtual void SetTransform(vtkTransform *t)
Set the position, scale and orientation of the box widget using the transform specified.
vtkBoxWidget::vtkBoxWidget
vtkBoxWidget()
vtkBoxWidget::Points
vtkPoints * Points
Definition: vtkBoxWidget.h:283
vtkBoxWidget::GetDirection
void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3])
vtkBoxWidget::HandlesOff
void HandlesOff()
vtkBoxWidget::HandleMapper
vtkPolyDataMapper ** HandleMapper
Definition: vtkBoxWidget.h:293
vtkBoxWidget::ComputeNormals
void ComputeNormals()
vtkBoxWidget::Scale
virtual void Scale(double *p1, double *p2, int X, int Y)
vtkBoxWidget::OnMiddleButtonUp
virtual void OnMiddleButtonUp()