VTK  9.0.1
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 =========================================================================*/
75 #ifndef vtkBoxWidget_h
76 #define vtkBoxWidget_h
77 
78 #include "vtk3DWidget.h"
79 #include "vtkInteractionWidgetsModule.h" // For export macro
80 
81 class vtkActor;
82 class vtkCellPicker;
83 class vtkPlanes;
84 class vtkPoints;
85 class vtkPolyData;
86 class vtkPolyDataMapper;
87 class vtkProp;
88 class vtkProperty;
89 class vtkSphereSource;
90 class vtkTransform;
91 
92 class VTKINTERACTIONWIDGETS_EXPORT vtkBoxWidget : public vtk3DWidget
93 {
94 public:
98  static vtkBoxWidget* New();
99 
100  vtkTypeMacro(vtkBoxWidget, vtk3DWidget);
101  void PrintSelf(ostream& os, vtkIndent indent) override;
102 
104 
107  void SetEnabled(int) override;
108  void PlaceWidget(double bounds[6]) override;
109  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
111  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
112  {
113  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
114  }
116 
125  void GetPlanes(vtkPlanes* planes);
126 
128 
133  vtkSetMacro(InsideOut, vtkTypeBool);
134  vtkGetMacro(InsideOut, vtkTypeBool);
135  vtkBooleanMacro(InsideOut, vtkTypeBool);
137 
145  virtual void GetTransform(vtkTransform* t);
146 
153  virtual void SetTransform(vtkTransform* t);
154 
166 
168 
173  vtkGetObjectMacro(HandleProperty, vtkProperty);
174  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
176 
178 
182  void HandlesOn();
183  void HandlesOff();
185 
187 
192  vtkGetObjectMacro(FaceProperty, vtkProperty);
193  vtkGetObjectMacro(SelectedFaceProperty, vtkProperty);
195 
197 
202  vtkGetObjectMacro(OutlineProperty, vtkProperty);
203  vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
205 
207 
212  vtkGetMacro(OutlineFaceWires, int);
213  void OutlineFaceWiresOn() { this->SetOutlineFaceWires(1); }
214  void OutlineFaceWiresOff() { this->SetOutlineFaceWires(0); }
216 
218 
224  vtkGetMacro(OutlineCursorWires, int);
225  void OutlineCursorWiresOn() { this->SetOutlineCursorWires(1); }
226  void OutlineCursorWiresOff() { this->SetOutlineCursorWires(0); }
228 
230 
234  vtkSetMacro(TranslationEnabled, vtkTypeBool);
235  vtkGetMacro(TranslationEnabled, vtkTypeBool);
236  vtkBooleanMacro(TranslationEnabled, vtkTypeBool);
237  vtkSetMacro(ScalingEnabled, vtkTypeBool);
238  vtkGetMacro(ScalingEnabled, vtkTypeBool);
239  vtkBooleanMacro(ScalingEnabled, vtkTypeBool);
240  vtkSetMacro(RotationEnabled, vtkTypeBool);
241  vtkGetMacro(RotationEnabled, vtkTypeBool);
242  vtkBooleanMacro(RotationEnabled, vtkTypeBool);
244 
245 protected:
247  ~vtkBoxWidget() override;
248 
249  // Manage the state of the widget
250  int State;
252  {
253  Start = 0,
256  Outside
257  };
258 
259  // Handles the events
260  static void ProcessEvents(
261  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
262 
263  // ProcessEvents() dispatches to these methods.
264  virtual void OnMouseMove();
265  virtual void OnLeftButtonDown();
266  virtual void OnLeftButtonUp();
267  virtual void OnMiddleButtonDown();
268  virtual void OnMiddleButtonUp();
269  virtual void OnRightButtonDown();
270  virtual void OnRightButtonUp();
271 
272  // the hexahedron (6 faces)
276  vtkPoints* Points; // used by others as well
277  double N[6][3]; // the normals of the faces
278 
279  // A face of the hexahedron
283 
284  // glyphs representing hot spots (e.g., handles)
288  virtual void PositionHandles();
289  int HighlightHandle(vtkProp* prop); // returns cell id
290  void HighlightFace(int cellId);
291  void HighlightOutline(int highlight);
293  void SizeHandles() override;
294 
295  // wireframe outline
299 
300  // Do the picking
305 
306  // Register internal Pickers within PickingManager
307  void RegisterPickers() override;
308 
309  // Methods to manipulate the hexahedron.
310  virtual void Translate(double* p1, double* p2);
311  virtual void Scale(double* p1, double* p2, int X, int Y);
312  virtual void Rotate(int X, int Y, double* p1, double* p2, double* vpn);
313  void MovePlusXFace(double* p1, double* p2);
314  void MoveMinusXFace(double* p1, double* p2);
315  void MovePlusYFace(double* p1, double* p2);
316  void MoveMinusYFace(double* p1, double* p2);
317  void MovePlusZFace(double* p1, double* p2);
318  void MoveMinusZFace(double* p1, double* p2);
319 
320  //"dir" is the direction in which the face can be moved i.e. the axis passing
321  // through the center
322  void MoveFace(double* p1, double* p2, double* dir, double* x1, double* x2, double* x3, double* x4,
323  double* x5);
324  // Helper method to obtain the direction in which the face is to be moved.
325  // Handles special cases where some of the scale factors are 0.
326  void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3]);
327 
328  // Transform the hexahedral points (used for rotations)
330 
331  // Properties used to control the appearance of selected objects and
332  // the manipulator in general.
340 
341  // Control the orientation of the normals
346 
347  // Control whether scaling, rotation, and translation are supported
351 
352 private:
353  vtkBoxWidget(const vtkBoxWidget&) = delete;
354  void operator=(const vtkBoxWidget&) = delete;
355 };
356 
357 #endif
vtkPolyDataMapper
map vtkPolyData to graphics primitives
Definition: vtkPolyDataMapper.h:37
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:34
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:337
vtkBoxWidget::GenerateOutline
void GenerateOutline()
vtkBoxWidget::HighlightOutline
void HighlightOutline(int highlight)
vtkBoxWidget::OutlineFaceWiresOn
void OutlineFaceWiresOn()
Definition: vtkBoxWidget.h:213
vtkBoxWidget::OnMiddleButtonDown
virtual void OnMiddleButtonDown()
vtkBoxWidget::FaceProperty
vtkProperty * FaceProperty
Definition: vtkBoxWidget.h:335
vtkBoxWidget::SizeHandles
void SizeHandles() override
vtkBoxWidget::HexPolyData
vtkPolyData * HexPolyData
Definition: vtkBoxWidget.h:275
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:302
vtkBoxWidget::HexMapper
vtkPolyDataMapper * HexMapper
Definition: vtkBoxWidget.h:274
vtkBoxWidget::HandlePicker
vtkCellPicker * HandlePicker
Definition: vtkBoxWidget.h:301
vtkBoxWidget::SelectedOutlineProperty
vtkProperty * SelectedOutlineProperty
Definition: vtkBoxWidget.h:338
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:348
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:54
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:50
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:55
vtkBoxWidget::SelectedFaceProperty
vtkProperty * SelectedFaceProperty
Definition: vtkBoxWidget.h:336
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()
Definition: vtkBoxWidget.h:225
vtkBoxWidget::HexFace
vtkActor * HexFace
Definition: vtkBoxWidget.h:280
vtkBoxWidget::OutlineCursorWiresOff
void OutlineCursorWiresOff()
Definition: vtkBoxWidget.h:226
vtkBoxWidget::Translate
virtual void Translate(double *p1, double *p2)
vtkBoxWidget::HandleGeometry
vtkSphereSource ** HandleGeometry
Definition: vtkBoxWidget.h:287
vtkBoxWidget::MoveMinusXFace
void MoveMinusXFace(double *p1, double *p2)
vtkBoxWidget::MoveMinusZFace
void MoveMinusZFace(double *p1, double *p2)
vtkBoxWidget::SelectedHandleProperty
vtkProperty * SelectedHandleProperty
Definition: vtkBoxWidget.h:334
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:344
vtkBoxWidget::~vtkBoxWidget
~vtkBoxWidget() override
vtkBoxWidget::WidgetState
WidgetState
Definition: vtkBoxWidget.h:252
vtkBoxWidget::Handle
vtkActor ** Handle
Definition: vtkBoxWidget.h:285
vtkBoxWidget::PlaceWidget
void PlaceWidget(double bounds[6]) override
This method is used to initially place the widget.
vtkBoxWidget::OutlineFaceWiresOff
void OutlineFaceWiresOff()
Definition: vtkBoxWidget.h:214
vtkBoxWidget::CurrentHexFace
int CurrentHexFace
Definition: vtkBoxWidget.h:304
vtkBoxWidget::HighlightFace
void HighlightFace(int cellId)
vtkBoxWidget::OutlineMapper
vtkPolyDataMapper * OutlineMapper
Definition: vtkBoxWidget.h:297
vtkSphereSource
create a polygonal sphere centered at the origin
Definition: vtkSphereSource.h:41
vtkBoxWidget::OnLeftButtonDown
virtual void OnLeftButtonDown()
vtkBoxWidget::HandleProperty
vtkProperty * HandleProperty
Definition: vtkBoxWidget.h:333
vtkBoxWidget::CreateDefaultProperties
void CreateDefaultProperties()
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:46
vtkBoxWidget::MovePlusXFace
void MovePlusXFace(double *p1, double *p2)
vtkBoxWidget
orthogonal hexahedron 3D widget
Definition: vtkBoxWidget.h:93
vtkBoxWidget::HexFaceMapper
vtkPolyDataMapper * HexFaceMapper
Definition: vtkBoxWidget.h:281
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:34
vtkBoxWidget::CurrentHandle
vtkActor * CurrentHandle
Definition: vtkBoxWidget.h:303
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:273
vtkBoxWidget::InsideOut
vtkTypeBool InsideOut
Definition: vtkBoxWidget.h:342
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:255
vtkBoxWidget::OutlineFaceWires
int OutlineFaceWires
Definition: vtkBoxWidget.h:343
vtkBoxWidget::New
static vtkBoxWidget * New()
Instantiate the object.
vtkProp
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:48
vtkBoxWidget::PlaceWidget
void PlaceWidget() override
Definition: vtkBoxWidget.h:109
vtkBoxWidget::Moving
@ Moving
Definition: vtkBoxWidget.h:254
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:250
vtkBoxWidget::OutlinePolyData
vtkPolyData * OutlinePolyData
Definition: vtkBoxWidget.h:298
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
Definition: vtkBoxWidget.h:110
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
vtkBoxWidget::HighlightHandle
int HighlightHandle(vtkProp *prop)
vtkBoxWidget::HexOutline
vtkActor * HexOutline
Definition: vtkBoxWidget.h:296
vtkBoxWidget::RotationEnabled
vtkTypeBool RotationEnabled
Definition: vtkBoxWidget.h:350
vtkBoxWidget::Transform
vtkTransform * Transform
Definition: vtkBoxWidget.h:329
vtk3DWidget.h
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:62
vtkBoxWidget::ProcessEvents
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
vtkBoxWidget::HexFacePolyData
vtkPolyData * HexFacePolyData
Definition: vtkBoxWidget.h:282
vtkCellPicker
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:67
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:276
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()
vtkBoxWidget::HandleMapper
vtkPolyDataMapper ** HandleMapper
Definition: vtkBoxWidget.h:286
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:349
vtkBoxWidget::SetEnabled
void SetEnabled(int) override
Methods that satisfy the superclass' API.