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 =========================================================================*/
114 #ifndef vtkBoxWidget_h
115 #define vtkBoxWidget_h
116 
117 #include "vtk3DWidget.h"
118 #include "vtkInteractionWidgetsModule.h" // For export macro
119 
120 class vtkActor;
121 class vtkCellPicker;
122 class vtkPlanes;
123 class vtkPoints;
124 class vtkPolyData;
125 class vtkPolyDataMapper;
126 class vtkProp;
127 class vtkProperty;
128 class vtkSphereSource;
129 class vtkTransform;
130 
131 class VTKINTERACTIONWIDGETS_EXPORT vtkBoxWidget : public vtk3DWidget
132 {
133 public:
137  static vtkBoxWidget* New();
138 
139  vtkTypeMacro(vtkBoxWidget, vtk3DWidget);
140  void PrintSelf(ostream& os, vtkIndent indent) override;
141 
143 
146  void SetEnabled(int) override;
147  void PlaceWidget(double bounds[6]) override;
148  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
150  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
151  {
152  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
153  }
155 
164  void GetPlanes(vtkPlanes* planes);
165 
167 
172  vtkSetMacro(InsideOut, vtkTypeBool);
173  vtkGetMacro(InsideOut, vtkTypeBool);
174  vtkBooleanMacro(InsideOut, vtkTypeBool);
176 
184  virtual void GetTransform(vtkTransform* t);
185 
192  virtual void SetTransform(vtkTransform* t);
193 
205 
207 
212  vtkGetObjectMacro(HandleProperty, vtkProperty);
213  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
215 
217 
221  void HandlesOn();
222  void HandlesOff();
224 
226 
231  vtkGetObjectMacro(FaceProperty, vtkProperty);
232  vtkGetObjectMacro(SelectedFaceProperty, vtkProperty);
234 
236 
241  vtkGetObjectMacro(OutlineProperty, vtkProperty);
242  vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
244 
246 
251  vtkGetMacro(OutlineFaceWires, int);
252  void OutlineFaceWiresOn() { this->SetOutlineFaceWires(1); }
253  void OutlineFaceWiresOff() { this->SetOutlineFaceWires(0); }
255 
257 
263  vtkGetMacro(OutlineCursorWires, int);
264  void OutlineCursorWiresOn() { this->SetOutlineCursorWires(1); }
265  void OutlineCursorWiresOff() { this->SetOutlineCursorWires(0); }
267 
269 
273  vtkSetMacro(TranslationEnabled, vtkTypeBool);
274  vtkGetMacro(TranslationEnabled, vtkTypeBool);
275  vtkBooleanMacro(TranslationEnabled, vtkTypeBool);
276  vtkSetMacro(ScalingEnabled, vtkTypeBool);
277  vtkGetMacro(ScalingEnabled, vtkTypeBool);
278  vtkBooleanMacro(ScalingEnabled, vtkTypeBool);
279  vtkSetMacro(RotationEnabled, vtkTypeBool);
280  vtkGetMacro(RotationEnabled, vtkTypeBool);
281  vtkBooleanMacro(RotationEnabled, vtkTypeBool);
283 
284 protected:
286  ~vtkBoxWidget() override;
287 
288  // Manage the state of the widget
289  int State;
291  {
292  Start = 0,
295  Outside
296  };
297 
298  // Handles the events
299  static void ProcessEvents(
300  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
301 
302  // ProcessEvents() dispatches to these methods.
303  virtual void OnMouseMove();
304  virtual void OnLeftButtonDown();
305  virtual void OnLeftButtonUp();
306  virtual void OnMiddleButtonDown();
307  virtual void OnMiddleButtonUp();
308  virtual void OnRightButtonDown();
309  virtual void OnRightButtonUp();
310 
311  // the hexahedron (6 faces)
315  vtkPoints* Points; // used by others as well
316  double N[6][3]; // the normals of the faces
317 
318  // A face of the hexahedron
322 
323  // glyphs representing hot spots (e.g., handles)
327  virtual void PositionHandles();
328  int HighlightHandle(vtkProp* prop); // returns cell id
329  void HighlightFace(int cellId);
330  void HighlightOutline(int highlight);
332  void SizeHandles() override;
333 
334  // wireframe outline
338 
339  // Do the picking
344 
345  // Register internal Pickers within PickingManager
346  void RegisterPickers() override;
347 
348  // Methods to manipulate the hexahedron.
349  virtual void Translate(double* p1, double* p2);
350  virtual void Scale(double* p1, double* p2, int X, int Y);
351  virtual void Rotate(int X, int Y, double* p1, double* p2, double* vpn);
352  void MovePlusXFace(double* p1, double* p2);
353  void MoveMinusXFace(double* p1, double* p2);
354  void MovePlusYFace(double* p1, double* p2);
355  void MoveMinusYFace(double* p1, double* p2);
356  void MovePlusZFace(double* p1, double* p2);
357  void MoveMinusZFace(double* p1, double* p2);
358 
359  //"dir" is the direction in which the face can be moved i.e. the axis passing
360  // through the center
361  void MoveFace(double* p1, double* p2, double* dir, double* x1, double* x2, double* x3, double* x4,
362  double* x5);
363  // Helper method to obtain the direction in which the face is to be moved.
364  // Handles special cases where some of the scale factors are 0.
365  void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3]);
366 
367  // Transform the hexahedral points (used for rotations)
369 
370  // Properties used to control the appearance of selected objects and
371  // the manipulator in general.
379 
380  // Control the orientation of the normals
385 
386  // Control whether scaling, rotation, and translation are supported
390 
391 private:
392  vtkBoxWidget(const vtkBoxWidget&) = delete;
393  void operator=(const vtkBoxWidget&) = delete;
394 };
395 
396 #endif
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:68
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:155
orthogonal hexahedron 3D widget
Definition: vtkBoxWidget.h:132
virtual void OnLeftButtonDown()
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
Methods that satisfy the superclass' API.
Definition: vtkBoxWidget.h:149
virtual void PositionHandles()
void SetOutlineCursorWires(int)
Control the representation of the outline.
void GenerateOutline()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void OutlineCursorWiresOff()
Control the representation of the outline.
Definition: vtkBoxWidget.h:265
void PlaceWidget() override
Methods that satisfy the superclass' API.
Definition: vtkBoxWidget.h:148
virtual void Scale(double *p1, double *p2, int X, int Y)
vtkTypeBool ScalingEnabled
Definition: vtkBoxWidget.h:388
vtkPolyData * HexPolyData
Definition: vtkBoxWidget.h:314
void CreateDefaultProperties()
vtkPolyData * HexFacePolyData
Definition: vtkBoxWidget.h:321
virtual void Translate(double *p1, double *p2)
void PlaceWidget(double bounds[6]) override
Methods that satisfy the superclass' API.
vtkActor * HexOutline
Definition: vtkBoxWidget.h:335
static vtkBoxWidget * New()
Instantiate the object.
void ComputeNormals()
~vtkBoxWidget() override
void HighlightOutline(int highlight)
vtkSphereSource ** HandleGeometry
Definition: vtkBoxWidget.h:326
vtkTransform * Transform
Definition: vtkBoxWidget.h:368
vtkProperty * SelectedFaceProperty
Definition: vtkBoxWidget.h:375
vtkCellPicker * HandlePicker
Definition: vtkBoxWidget.h:340
virtual void Rotate(int X, int Y, double *p1, double *p2, double *vpn)
void SetEnabled(int) override
Methods that satisfy the superclass' API.
void MoveFace(double *p1, double *p2, double *dir, double *x1, double *x2, double *x3, double *x4, double *x5)
vtkProperty * HandleProperty
Definition: vtkBoxWidget.h:372
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
virtual void OnRightButtonUp()
void OutlineCursorWiresOn()
Control the representation of the outline.
Definition: vtkBoxWidget.h:264
void MovePlusYFace(double *p1, double *p2)
vtkCellPicker * HexPicker
Definition: vtkBoxWidget.h:341
vtkPolyDataMapper * HexMapper
Definition: vtkBoxWidget.h:313
virtual void OnMiddleButtonDown()
vtkPoints * Points
Definition: vtkBoxWidget.h:315
int OutlineCursorWires
Definition: vtkBoxWidget.h:383
void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3])
vtkTypeBool RotationEnabled
Definition: vtkBoxWidget.h:389
void HandlesOn()
Switches handles (the spheres) on or off by manipulating the actor visibility.
int OutlineFaceWires
Definition: vtkBoxWidget.h:382
void SetOutlineFaceWires(int)
Control the representation of the outline.
vtkTypeBool InsideOut
Definition: vtkBoxWidget.h:381
vtkTypeBool TranslationEnabled
Definition: vtkBoxWidget.h:387
vtkPolyDataMapper * HexFaceMapper
Definition: vtkBoxWidget.h:320
int HighlightHandle(vtkProp *prop)
vtkActor * HexActor
Definition: vtkBoxWidget.h:312
vtkProperty * OutlineProperty
Definition: vtkBoxWidget.h:376
vtkActor ** Handle
Definition: vtkBoxWidget.h:324
void OutlineFaceWiresOn()
Control the representation of the outline.
Definition: vtkBoxWidget.h:252
vtkPolyData * OutlinePolyData
Definition: vtkBoxWidget.h:337
void MoveMinusXFace(double *p1, double *p2)
void MovePlusXFace(double *p1, double *p2)
virtual void GetTransform(vtkTransform *t)
Retrieve a linear transform characterizing the transformation of the box.
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
vtkProperty * FaceProperty
Definition: vtkBoxWidget.h:374
vtkActor * HexFace
Definition: vtkBoxWidget.h:319
void OutlineFaceWiresOff()
Control the representation of the outline.
Definition: vtkBoxWidget.h:253
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()
Switches handles (the spheres) on or off by manipulating the actor visibility.
vtkProperty * SelectedHandleProperty
Definition: vtkBoxWidget.h:373
void MoveMinusYFace(double *p1, double *p2)
virtual void OnMouseMove()
void GetPolyData(vtkPolyData *pd)
Grab the polydata (including points) that define the box widget.
void SizeHandles() override
vtkPolyDataMapper * OutlineMapper
Definition: vtkBoxWidget.h:336
vtkProperty * SelectedOutlineProperty
Definition: vtkBoxWidget.h:377
vtkPolyDataMapper ** HandleMapper
Definition: vtkBoxWidget.h:325
vtkActor * CurrentHandle
Definition: vtkBoxWidget.h:342
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:96
a simple class to control print indentation
Definition: vtkIndent.h:113
abstract base class for most VTK objects
Definition: vtkObject.h:73
implicit function for convex set of planes
Definition: vtkPlanes.h:159
represent and manipulate 3D points
Definition: vtkPoints.h:143
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:195
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:67
represent surface properties of a geometric object
Definition: vtkProperty.h:171
create a polygonal sphere centered at the origin
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:164
@ dir
Definition: vtkX3D.h:330
int vtkTypeBool
Definition: vtkABI.h:69