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
81 #ifndef vtkBoxWidget_h
82 #define vtkBoxWidget_h
83 
84 #include "vtk3DWidget.h"
85 #include "vtkInteractionWidgetsModule.h" // For export macro
86 
87 VTK_ABI_NAMESPACE_BEGIN
88 class vtkActor;
89 class vtkCellPicker;
90 class vtkPlanes;
91 class vtkPoints;
92 class vtkPolyData;
93 class vtkPolyDataMapper;
94 class vtkProp;
95 class vtkProperty;
96 class vtkSphereSource;
97 class vtkTransform;
98 
99 class VTKINTERACTIONWIDGETS_EXPORT vtkBoxWidget : public vtk3DWidget
100 {
101 public:
105  static vtkBoxWidget* New();
106 
107  vtkTypeMacro(vtkBoxWidget, vtk3DWidget);
108  void PrintSelf(ostream& os, vtkIndent indent) override;
109 
111 
114  void SetEnabled(int) override;
115  void PlaceWidget(double bounds[6]) override;
116  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
118  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
119  {
120  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
121  }
123 
132  void GetPlanes(vtkPlanes* planes);
133 
135 
140  vtkSetMacro(InsideOut, vtkTypeBool);
141  vtkGetMacro(InsideOut, vtkTypeBool);
142  vtkBooleanMacro(InsideOut, vtkTypeBool);
144 
152  virtual void GetTransform(vtkTransform* t);
153 
160  virtual void SetTransform(vtkTransform* t);
161 
173 
175 
180  vtkGetObjectMacro(HandleProperty, vtkProperty);
181  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
183 
185 
189  void HandlesOn();
190  void HandlesOff();
192 
194 
199  vtkGetObjectMacro(FaceProperty, vtkProperty);
200  vtkGetObjectMacro(SelectedFaceProperty, vtkProperty);
202 
204 
209  vtkGetObjectMacro(OutlineProperty, vtkProperty);
210  vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
212 
214 
219  vtkGetMacro(OutlineFaceWires, int);
220  void OutlineFaceWiresOn() { this->SetOutlineFaceWires(1); }
221  void OutlineFaceWiresOff() { this->SetOutlineFaceWires(0); }
223 
225 
231  vtkGetMacro(OutlineCursorWires, int);
232  void OutlineCursorWiresOn() { this->SetOutlineCursorWires(1); }
233  void OutlineCursorWiresOff() { this->SetOutlineCursorWires(0); }
235 
237 
241  vtkSetMacro(TranslationEnabled, vtkTypeBool);
242  vtkGetMacro(TranslationEnabled, vtkTypeBool);
243  vtkBooleanMacro(TranslationEnabled, vtkTypeBool);
244  vtkSetMacro(ScalingEnabled, vtkTypeBool);
245  vtkGetMacro(ScalingEnabled, vtkTypeBool);
246  vtkBooleanMacro(ScalingEnabled, vtkTypeBool);
247  vtkSetMacro(RotationEnabled, vtkTypeBool);
248  vtkGetMacro(RotationEnabled, vtkTypeBool);
249  vtkBooleanMacro(RotationEnabled, vtkTypeBool);
251 
252 protected:
254  ~vtkBoxWidget() override;
255 
256  // Manage the state of the widget
257  int State;
259  {
260  Start = 0,
263  Outside
264  };
265 
266  // Handles the events
267  static void ProcessEvents(
268  vtkObject* object, unsigned long event, void* clientdata, 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  void SizeHandles() override;
301 
302  // wireframe outline
306 
307  // Do the picking
312 
313  // Register internal Pickers within PickingManager
314  void RegisterPickers() override;
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, double* x1, double* x2, double* x3, double* x4,
330  double* x5);
331  // Helper method to obtain the direction in which the face is to be moved.
332  // Handles special cases where some of the scale factors are 0.
333  void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3]);
334 
335  // Transform the hexahedral points (used for rotations)
337 
338  // Properties used to control the appearance of selected objects and
339  // the manipulator in general.
347 
348  // Control the orientation of the normals
353 
354  // Control whether scaling, rotation, and translation are supported
358 
359 private:
360  vtkBoxWidget(const vtkBoxWidget&) = delete;
361  void operator=(const vtkBoxWidget&) = delete;
362 };
363 
364 VTK_ABI_NAMESPACE_END
365 #endif
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:60
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:50
orthogonal hexahedron 3D widget
Definition: vtkBoxWidget.h:100
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:117
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:233
void PlaceWidget() override
Methods that satisfy the superclass' API.
Definition: vtkBoxWidget.h:116
virtual void Scale(double *p1, double *p2, int X, int Y)
vtkTypeBool ScalingEnabled
Definition: vtkBoxWidget.h:356
vtkPolyData * HexPolyData
Definition: vtkBoxWidget.h:282
void CreateDefaultProperties()
vtkPolyData * HexFacePolyData
Definition: vtkBoxWidget.h:289
virtual void Translate(double *p1, double *p2)
void PlaceWidget(double bounds[6]) override
Methods that satisfy the superclass' API.
vtkActor * HexOutline
Definition: vtkBoxWidget.h:303
static vtkBoxWidget * New()
Instantiate the object.
void ComputeNormals()
~vtkBoxWidget() override
void HighlightOutline(int highlight)
vtkSphereSource ** HandleGeometry
Definition: vtkBoxWidget.h:294
vtkTransform * Transform
Definition: vtkBoxWidget.h:336
vtkProperty * SelectedFaceProperty
Definition: vtkBoxWidget.h:343
vtkCellPicker * HandlePicker
Definition: vtkBoxWidget.h:308
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:340
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:232
void MovePlusYFace(double *p1, double *p2)
vtkCellPicker * HexPicker
Definition: vtkBoxWidget.h:309
vtkPolyDataMapper * HexMapper
Definition: vtkBoxWidget.h:281
virtual void OnMiddleButtonDown()
vtkPoints * Points
Definition: vtkBoxWidget.h:283
int OutlineCursorWires
Definition: vtkBoxWidget.h:351
void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3])
vtkTypeBool RotationEnabled
Definition: vtkBoxWidget.h:357
void HandlesOn()
Switches handles (the spheres) on or off by manipulating the actor visibility.
int OutlineFaceWires
Definition: vtkBoxWidget.h:350
void SetOutlineFaceWires(int)
Control the representation of the outline.
vtkTypeBool InsideOut
Definition: vtkBoxWidget.h:349
vtkTypeBool TranslationEnabled
Definition: vtkBoxWidget.h:355
vtkPolyDataMapper * HexFaceMapper
Definition: vtkBoxWidget.h:288
int HighlightHandle(vtkProp *prop)
vtkActor * HexActor
Definition: vtkBoxWidget.h:280
vtkProperty * OutlineProperty
Definition: vtkBoxWidget.h:344
vtkActor ** Handle
Definition: vtkBoxWidget.h:292
void OutlineFaceWiresOn()
Control the representation of the outline.
Definition: vtkBoxWidget.h:220
vtkPolyData * OutlinePolyData
Definition: vtkBoxWidget.h:305
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:342
vtkActor * HexFace
Definition: vtkBoxWidget.h:287
void OutlineFaceWiresOff()
Control the representation of the outline.
Definition: vtkBoxWidget.h:221
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:341
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:304
vtkProperty * SelectedOutlineProperty
Definition: vtkBoxWidget.h:345
vtkPolyDataMapper ** HandleMapper
Definition: vtkBoxWidget.h:293
vtkActor * CurrentHandle
Definition: vtkBoxWidget.h:310
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:71
a simple class to control print indentation
Definition: vtkIndent.h:38
abstract base class for most VTK objects
Definition: vtkObject.h:61
implicit function for convex set of planes
Definition: vtkPlanes.h:51
represent and manipulate 3D points
Definition: vtkPoints.h:38
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:89
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:55
represent surface properties of a geometric object
Definition: vtkProperty.h:66
create a polygonal sphere centered at the origin
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:59
@ dir
Definition: vtkX3D.h:324
int vtkTypeBool
Definition: vtkABI.h:64