VTK  9.3.0
vtkBoxWidget.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
72 #ifndef vtkBoxWidget_h
73 #define vtkBoxWidget_h
74 
75 #include "vtk3DWidget.h"
76 #include "vtkInteractionWidgetsModule.h" // For export macro
77 
78 VTK_ABI_NAMESPACE_BEGIN
79 class vtkActor;
80 class vtkCellPicker;
81 class vtkPlanes;
82 class vtkPoints;
83 class vtkPolyData;
84 class vtkPolyDataMapper;
85 class vtkProp;
86 class vtkProperty;
87 class vtkSphereSource;
88 class vtkTransform;
89 
90 class VTKINTERACTIONWIDGETS_EXPORT vtkBoxWidget : public vtk3DWidget
91 {
92 public:
96  static vtkBoxWidget* New();
97 
98  vtkTypeMacro(vtkBoxWidget, vtk3DWidget);
99  void PrintSelf(ostream& os, vtkIndent indent) override;
100 
102 
105  void SetEnabled(int) override;
106  void PlaceWidget(double bounds[6]) override;
107  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
109  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
110  {
111  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
112  }
114 
123  void GetPlanes(vtkPlanes* planes);
124 
126 
131  vtkSetMacro(InsideOut, vtkTypeBool);
132  vtkGetMacro(InsideOut, vtkTypeBool);
133  vtkBooleanMacro(InsideOut, vtkTypeBool);
135 
143  virtual void GetTransform(vtkTransform* t);
144 
151  virtual void SetTransform(vtkTransform* t);
152 
164 
166 
171  vtkGetObjectMacro(HandleProperty, vtkProperty);
172  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
174 
176 
180  void HandlesOn();
181  void HandlesOff();
183 
185 
190  vtkGetObjectMacro(FaceProperty, vtkProperty);
191  vtkGetObjectMacro(SelectedFaceProperty, vtkProperty);
193 
195 
200  vtkGetObjectMacro(OutlineProperty, vtkProperty);
201  vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
203 
205 
210  vtkGetMacro(OutlineFaceWires, int);
211  void OutlineFaceWiresOn() { this->SetOutlineFaceWires(1); }
212  void OutlineFaceWiresOff() { this->SetOutlineFaceWires(0); }
214 
216 
222  vtkGetMacro(OutlineCursorWires, int);
223  void OutlineCursorWiresOn() { this->SetOutlineCursorWires(1); }
224  void OutlineCursorWiresOff() { this->SetOutlineCursorWires(0); }
226 
228 
232  vtkSetMacro(TranslationEnabled, vtkTypeBool);
233  vtkGetMacro(TranslationEnabled, vtkTypeBool);
234  vtkBooleanMacro(TranslationEnabled, vtkTypeBool);
235  vtkSetMacro(ScalingEnabled, vtkTypeBool);
236  vtkGetMacro(ScalingEnabled, vtkTypeBool);
237  vtkBooleanMacro(ScalingEnabled, vtkTypeBool);
238  vtkSetMacro(RotationEnabled, vtkTypeBool);
239  vtkGetMacro(RotationEnabled, vtkTypeBool);
240  vtkBooleanMacro(RotationEnabled, vtkTypeBool);
242 
243 protected:
245  ~vtkBoxWidget() override;
246 
247  // Manage the state of the widget
248  int State;
250  {
251  Start = 0,
254  Outside
255  };
256 
257  // Handles the events
258  static void ProcessEvents(
259  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
260 
261  // ProcessEvents() dispatches to these methods.
262  virtual void OnMouseMove();
263  virtual void OnLeftButtonDown();
264  virtual void OnLeftButtonUp();
265  virtual void OnMiddleButtonDown();
266  virtual void OnMiddleButtonUp();
267  virtual void OnRightButtonDown();
268  virtual void OnRightButtonUp();
269 
270  // the hexahedron (6 faces)
274  vtkPoints* Points; // used by others as well
275  double N[6][3]; // the normals of the faces
276 
277  // A face of the hexahedron
281 
282  // glyphs representing hot spots (e.g., handles)
286  virtual void PositionHandles();
287  int HighlightHandle(vtkProp* prop); // returns cell id
288  void HighlightFace(int cellId);
289  void HighlightOutline(int highlight);
291  void SizeHandles() override;
292 
293  // wireframe outline
297 
298  // Do the picking
303 
304  // Register internal Pickers within PickingManager
305  void RegisterPickers() override;
306 
307  // Methods to manipulate the hexahedron.
308  virtual void Translate(double* p1, double* p2);
309  virtual void Scale(double* p1, double* p2, int X, int Y);
310  virtual void Rotate(int X, int Y, double* p1, double* p2, double* vpn);
311  void MovePlusXFace(double* p1, double* p2);
312  void MoveMinusXFace(double* p1, double* p2);
313  void MovePlusYFace(double* p1, double* p2);
314  void MoveMinusYFace(double* p1, double* p2);
315  void MovePlusZFace(double* p1, double* p2);
316  void MoveMinusZFace(double* p1, double* p2);
317 
318  //"dir" is the direction in which the face can be moved i.e. the axis passing
319  // through the center
320  void MoveFace(double* p1, double* p2, double* dir, double* x1, double* x2, double* x3, double* x4,
321  double* x5);
322  // Helper method to obtain the direction in which the face is to be moved.
323  // Handles special cases where some of the scale factors are 0.
324  void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3]);
325 
326  // Transform the hexahedral points (used for rotations)
328 
329  // Properties used to control the appearance of selected objects and
330  // the manipulator in general.
338 
339  // Control the orientation of the normals
344 
345  // Control whether scaling, rotation, and translation are supported
349 
350 private:
351  vtkBoxWidget(const vtkBoxWidget&) = delete;
352  void operator=(const vtkBoxWidget&) = delete;
353 };
354 
355 VTK_ABI_NAMESPACE_END
356 #endif
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:60
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:41
orthogonal hexahedron 3D widget
Definition: vtkBoxWidget.h:91
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:108
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:224
void PlaceWidget() override
Methods that satisfy the superclass' API.
Definition: vtkBoxWidget.h:107
virtual void Scale(double *p1, double *p2, int X, int Y)
vtkTypeBool ScalingEnabled
Definition: vtkBoxWidget.h:347
vtkPolyData * HexPolyData
Definition: vtkBoxWidget.h:273
void CreateDefaultProperties()
vtkPolyData * HexFacePolyData
Definition: vtkBoxWidget.h:280
virtual void Translate(double *p1, double *p2)
void PlaceWidget(double bounds[6]) override
Methods that satisfy the superclass' API.
vtkActor * HexOutline
Definition: vtkBoxWidget.h:294
static vtkBoxWidget * New()
Instantiate the object.
void ComputeNormals()
~vtkBoxWidget() override
void HighlightOutline(int highlight)
vtkSphereSource ** HandleGeometry
Definition: vtkBoxWidget.h:285
vtkTransform * Transform
Definition: vtkBoxWidget.h:327
vtkProperty * SelectedFaceProperty
Definition: vtkBoxWidget.h:334
vtkCellPicker * HandlePicker
Definition: vtkBoxWidget.h:299
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:331
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:223
void MovePlusYFace(double *p1, double *p2)
vtkCellPicker * HexPicker
Definition: vtkBoxWidget.h:300
vtkPolyDataMapper * HexMapper
Definition: vtkBoxWidget.h:272
virtual void OnMiddleButtonDown()
vtkPoints * Points
Definition: vtkBoxWidget.h:274
int OutlineCursorWires
Definition: vtkBoxWidget.h:342
void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3])
vtkTypeBool RotationEnabled
Definition: vtkBoxWidget.h:348
void HandlesOn()
Switches handles (the spheres) on or off by manipulating the actor visibility.
int OutlineFaceWires
Definition: vtkBoxWidget.h:341
void SetOutlineFaceWires(int)
Control the representation of the outline.
vtkTypeBool InsideOut
Definition: vtkBoxWidget.h:340
vtkTypeBool TranslationEnabled
Definition: vtkBoxWidget.h:346
vtkPolyDataMapper * HexFaceMapper
Definition: vtkBoxWidget.h:279
int HighlightHandle(vtkProp *prop)
vtkActor * HexActor
Definition: vtkBoxWidget.h:271
vtkProperty * OutlineProperty
Definition: vtkBoxWidget.h:335
vtkActor ** Handle
Definition: vtkBoxWidget.h:283
void OutlineFaceWiresOn()
Control the representation of the outline.
Definition: vtkBoxWidget.h:211
vtkPolyData * OutlinePolyData
Definition: vtkBoxWidget.h:296
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:333
vtkActor * HexFace
Definition: vtkBoxWidget.h:278
void OutlineFaceWiresOff()
Control the representation of the outline.
Definition: vtkBoxWidget.h:212
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:332
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:295
vtkProperty * SelectedOutlineProperty
Definition: vtkBoxWidget.h:336
vtkPolyDataMapper ** HandleMapper
Definition: vtkBoxWidget.h:284
vtkActor * CurrentHandle
Definition: vtkBoxWidget.h:301
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:62
a simple class to control print indentation
Definition: vtkIndent.h:29
abstract base class for most VTK objects
Definition: vtkObject.h:52
implicit function for convex set of planes
Definition: vtkPlanes.h:42
represent and manipulate 3D points
Definition: vtkPoints.h:29
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:80
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:46
represent surface properties of a geometric object
Definition: vtkProperty.h:57
create a polygonal sphere centered at the origin
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:50
@ dir
Definition: vtkX3D.h:324
int vtkTypeBool
Definition: vtkABI.h:64