VTK  9.1.0
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 =========================================================================*/
120 #ifndef vtkBoxWidget_h
121 #define vtkBoxWidget_h
122 
123 #include "vtk3DWidget.h"
124 #include "vtkInteractionWidgetsModule.h" // For export macro
125 
126 class vtkActor;
127 class vtkCellPicker;
128 class vtkPlanes;
129 class vtkPoints;
130 class vtkPolyData;
131 class vtkPolyDataMapper;
132 class vtkProp;
133 class vtkProperty;
134 class vtkSphereSource;
135 class vtkTransform;
136 
137 class VTKINTERACTIONWIDGETS_EXPORT vtkBoxWidget : public vtk3DWidget
138 {
139 public:
143  static vtkBoxWidget* New();
144 
145  vtkTypeMacro(vtkBoxWidget, vtk3DWidget);
146  void PrintSelf(ostream& os, vtkIndent indent) override;
147 
149 
152  void SetEnabled(int) override;
153  void PlaceWidget(double bounds[6]) override;
154  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
156  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
157  {
158  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
159  }
161 
170  void GetPlanes(vtkPlanes* planes);
171 
173 
178  vtkSetMacro(InsideOut, vtkTypeBool);
179  vtkGetMacro(InsideOut, vtkTypeBool);
180  vtkBooleanMacro(InsideOut, vtkTypeBool);
182 
190  virtual void GetTransform(vtkTransform* t);
191 
198  virtual void SetTransform(vtkTransform* t);
199 
211 
213 
218  vtkGetObjectMacro(HandleProperty, vtkProperty);
219  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
221 
223 
227  void HandlesOn();
228  void HandlesOff();
230 
232 
237  vtkGetObjectMacro(FaceProperty, vtkProperty);
238  vtkGetObjectMacro(SelectedFaceProperty, vtkProperty);
240 
242 
247  vtkGetObjectMacro(OutlineProperty, vtkProperty);
248  vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
250 
252 
257  vtkGetMacro(OutlineFaceWires, int);
258  void OutlineFaceWiresOn() { this->SetOutlineFaceWires(1); }
259  void OutlineFaceWiresOff() { this->SetOutlineFaceWires(0); }
261 
263 
269  vtkGetMacro(OutlineCursorWires, int);
270  void OutlineCursorWiresOn() { this->SetOutlineCursorWires(1); }
271  void OutlineCursorWiresOff() { this->SetOutlineCursorWires(0); }
273 
275 
279  vtkSetMacro(TranslationEnabled, vtkTypeBool);
280  vtkGetMacro(TranslationEnabled, vtkTypeBool);
281  vtkBooleanMacro(TranslationEnabled, vtkTypeBool);
282  vtkSetMacro(ScalingEnabled, vtkTypeBool);
283  vtkGetMacro(ScalingEnabled, vtkTypeBool);
284  vtkBooleanMacro(ScalingEnabled, vtkTypeBool);
285  vtkSetMacro(RotationEnabled, vtkTypeBool);
286  vtkGetMacro(RotationEnabled, vtkTypeBool);
287  vtkBooleanMacro(RotationEnabled, vtkTypeBool);
289 
290 protected:
292  ~vtkBoxWidget() override;
293 
294  // Manage the state of the widget
295  int State;
297  {
298  Start = 0,
301  Outside
302  };
303 
304  // Handles the events
305  static void ProcessEvents(
306  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
307 
308  // ProcessEvents() dispatches to these methods.
309  virtual void OnMouseMove();
310  virtual void OnLeftButtonDown();
311  virtual void OnLeftButtonUp();
312  virtual void OnMiddleButtonDown();
313  virtual void OnMiddleButtonUp();
314  virtual void OnRightButtonDown();
315  virtual void OnRightButtonUp();
316 
317  // the hexahedron (6 faces)
321  vtkPoints* Points; // used by others as well
322  double N[6][3]; // the normals of the faces
323 
324  // A face of the hexahedron
328 
329  // glyphs representing hot spots (e.g., handles)
333  virtual void PositionHandles();
334  int HighlightHandle(vtkProp* prop); // returns cell id
335  void HighlightFace(int cellId);
336  void HighlightOutline(int highlight);
338  void SizeHandles() override;
339 
340  // wireframe outline
344 
345  // Do the picking
350 
351  // Register internal Pickers within PickingManager
352  void RegisterPickers() override;
353 
354  // Methods to manipulate the hexahedron.
355  virtual void Translate(double* p1, double* p2);
356  virtual void Scale(double* p1, double* p2, int X, int Y);
357  virtual void Rotate(int X, int Y, double* p1, double* p2, double* vpn);
358  void MovePlusXFace(double* p1, double* p2);
359  void MoveMinusXFace(double* p1, double* p2);
360  void MovePlusYFace(double* p1, double* p2);
361  void MoveMinusYFace(double* p1, double* p2);
362  void MovePlusZFace(double* p1, double* p2);
363  void MoveMinusZFace(double* p1, double* p2);
364 
365  //"dir" is the direction in which the face can be moved i.e. the axis passing
366  // through the center
367  void MoveFace(double* p1, double* p2, double* dir, double* x1, double* x2, double* x3, double* x4,
368  double* x5);
369  // Helper method to obtain the direction in which the face is to be moved.
370  // Handles special cases where some of the scale factors are 0.
371  void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3]);
372 
373  // Transform the hexahedral points (used for rotations)
375 
376  // Properties used to control the appearance of selected objects and
377  // the manipulator in general.
385 
386  // Control the orientation of the normals
391 
392  // Control whether scaling, rotation, and translation are supported
396 
397 private:
398  vtkBoxWidget(const vtkBoxWidget&) = delete;
399  void operator=(const vtkBoxWidget&) = delete;
400 };
401 
402 #endif
vtkPolyDataMapper
map vtkPolyData to graphics primitives
Definition: vtkPolyDataMapper.h:146
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:143
vtkBoxWidget::MoveFace
void MoveFace(double *p1, double *p2, double *dir, double *x1, double *x2, double *x3, double *x4, double *x5)
vtkBoxWidget::MovePlusZFace
void MovePlusZFace(double *p1, double *p2)
vtkBoxWidget::OutlineProperty
vtkProperty * OutlineProperty
Definition: vtkBoxWidget.h:382
vtkBoxWidget::GenerateOutline
void GenerateOutline()
vtkBoxWidget::HighlightOutline
void HighlightOutline(int highlight)
vtkBoxWidget::OutlineFaceWiresOn
void OutlineFaceWiresOn()
Control the representation of the outline.
Definition: vtkBoxWidget.h:258
vtkBoxWidget::OnMiddleButtonDown
virtual void OnMiddleButtonDown()
vtkBoxWidget::FaceProperty
vtkProperty * FaceProperty
Definition: vtkBoxWidget.h:380
vtkBoxWidget::SizeHandles
void SizeHandles() override
vtkBoxWidget::HexPolyData
vtkPolyData * HexPolyData
Definition: vtkBoxWidget.h:320
vtkBoxWidget::SetOutlineFaceWires
void SetOutlineFaceWires(int)
Control the representation of the outline.
vtkBoxWidget::MovePlusYFace
void MovePlusYFace(double *p1, double *p2)
vtkBoxWidget::HexPicker
vtkCellPicker * HexPicker
Definition: vtkBoxWidget.h:347
vtkBoxWidget::HexMapper
vtkPolyDataMapper * HexMapper
Definition: vtkBoxWidget.h:319
vtkBoxWidget::HandlePicker
vtkCellPicker * HandlePicker
Definition: vtkBoxWidget.h:346
vtkBoxWidget::SelectedOutlineProperty
vtkProperty * SelectedOutlineProperty
Definition: vtkBoxWidget.h:383
vtkBoxWidget::GetPlanes
void GetPlanes(vtkPlanes *planes)
Get the planes describing the implicit function defined by the box widget.
vtkBoxWidget::TranslationEnabled
vtkTypeBool TranslationEnabled
Definition: vtkBoxWidget.h:393
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:82
vtkX3D::dir
@ dir
Definition: vtkX3D.h:330
vtkBoxWidget::OnRightButtonDown
virtual void OnRightButtonDown()
vtkBoxWidget::OnLeftButtonUp
virtual void OnLeftButtonUp()
vtkPlanes
implicit function for convex set of planes
Definition: vtkPlanes.h:159
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:164
vtkBoxWidget::SelectedFaceProperty
vtkProperty * SelectedFaceProperty
Definition: vtkBoxWidget.h:381
vtkBoxWidget::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkBoxWidget::OutlineCursorWiresOn
void OutlineCursorWiresOn()
Control the representation of the outline.
Definition: vtkBoxWidget.h:270
vtkBoxWidget::HexFace
vtkActor * HexFace
Definition: vtkBoxWidget.h:325
vtkBoxWidget::OutlineCursorWiresOff
void OutlineCursorWiresOff()
Control the representation of the outline.
Definition: vtkBoxWidget.h:271
vtkBoxWidget::Translate
virtual void Translate(double *p1, double *p2)
vtkBoxWidget::HandleGeometry
vtkSphereSource ** HandleGeometry
Definition: vtkBoxWidget.h:332
vtkBoxWidget::MoveMinusXFace
void MoveMinusXFace(double *p1, double *p2)
vtkBoxWidget::MoveMinusZFace
void MoveMinusZFace(double *p1, double *p2)
vtkBoxWidget::SelectedHandleProperty
vtkProperty * SelectedHandleProperty
Definition: vtkBoxWidget.h:379
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:389
vtkBoxWidget::~vtkBoxWidget
~vtkBoxWidget() override
vtkBoxWidget::WidgetState
WidgetState
Definition: vtkBoxWidget.h:297
vtkBoxWidget::Handle
vtkActor ** Handle
Definition: vtkBoxWidget.h:330
vtkBoxWidget::PlaceWidget
void PlaceWidget(double bounds[6]) override
Methods that satisfy the superclass' API.
vtkBoxWidget::OutlineFaceWiresOff
void OutlineFaceWiresOff()
Control the representation of the outline.
Definition: vtkBoxWidget.h:259
vtkBoxWidget::CurrentHexFace
int CurrentHexFace
Definition: vtkBoxWidget.h:349
vtkBoxWidget::HighlightFace
void HighlightFace(int cellId)
vtkBoxWidget::OutlineMapper
vtkPolyDataMapper * OutlineMapper
Definition: vtkBoxWidget.h:342
vtkSphereSource
create a polygonal sphere centered at the origin
Definition: vtkSphereSource.h:149
vtkBoxWidget::OnLeftButtonDown
virtual void OnLeftButtonDown()
vtkBoxWidget::HandleProperty
vtkProperty * HandleProperty
Definition: vtkBoxWidget.h:378
vtkBoxWidget::CreateDefaultProperties
void CreateDefaultProperties()
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:155
vtkBoxWidget::MovePlusXFace
void MovePlusXFace(double *p1, double *p2)
vtkBoxWidget
orthogonal hexahedron 3D widget
Definition: vtkBoxWidget.h:138
vtkBoxWidget::HexFaceMapper
vtkPolyDataMapper * HexFaceMapper
Definition: vtkBoxWidget.h:326
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkBoxWidget::CurrentHandle
vtkActor * CurrentHandle
Definition: vtkBoxWidget.h:348
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:71
vtkBoxWidget::HexActor
vtkActor * HexActor
Definition: vtkBoxWidget.h:318
vtkBoxWidget::InsideOut
vtkTypeBool InsideOut
Definition: vtkBoxWidget.h:387
vtkBoxWidget::OnRightButtonUp
virtual void OnRightButtonUp()
vtkBoxWidget::RegisterPickers
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
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:300
vtkBoxWidget::OutlineFaceWires
int OutlineFaceWires
Definition: vtkBoxWidget.h:388
vtkBoxWidget::New
static vtkBoxWidget * New()
Instantiate the object.
vtkProp
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:76
vtkBoxWidget::PlaceWidget
void PlaceWidget() override
Methods that satisfy the superclass' API.
Definition: vtkBoxWidget.h:154
vtkBoxWidget::Moving
@ Moving
Definition: vtkBoxWidget.h:299
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::State
int State
Definition: vtkBoxWidget.h:295
vtkBoxWidget::OutlinePolyData
vtkPolyData * OutlinePolyData
Definition: vtkBoxWidget.h:343
vtkBoxWidget::SetOutlineCursorWires
void SetOutlineCursorWires(int)
Control the representation of the outline.
vtkBoxWidget::PlaceWidget
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
Methods that satisfy the superclass' API.
Definition: vtkBoxWidget.h:155
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:195
vtkBoxWidget::HighlightHandle
int HighlightHandle(vtkProp *prop)
vtkBoxWidget::HexOutline
vtkActor * HexOutline
Definition: vtkBoxWidget.h:341
vtkBoxWidget::RotationEnabled
vtkTypeBool RotationEnabled
Definition: vtkBoxWidget.h:395
vtkBoxWidget::Transform
vtkTransform * Transform
Definition: vtkBoxWidget.h:374
vtk3DWidget.h
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:171
vtkBoxWidget::ProcessEvents
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
vtkBoxWidget::HexFacePolyData
vtkPolyData * HexFacePolyData
Definition: vtkBoxWidget.h:327
vtkCellPicker
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:96
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:321
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkBoxWidget::GetDirection
void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3])
vtkBoxWidget::HandlesOff
void HandlesOff()
Switches handles (the spheres) on or off by manipulating the actor visibility.
vtkBoxWidget::HandleMapper
vtkPolyDataMapper ** HandleMapper
Definition: vtkBoxWidget.h:331
vtkBoxWidget::ComputeNormals
void ComputeNormals()
vtkBoxWidget::Scale
virtual void Scale(double *p1, double *p2, int X, int Y)
vtkBoxWidget::OnMiddleButtonUp
virtual void OnMiddleButtonUp()
vtkBoxWidget::ScalingEnabled
vtkTypeBool ScalingEnabled
Definition: vtkBoxWidget.h:394
vtkBoxWidget::SetEnabled
void SetEnabled(int) override
Methods that satisfy the superclass' API.