VTK  9.3.1
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 
163  void GetPolyData(vtkPolyData* pd);
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 
209  void SetOutlineFaceWires(int);
210  vtkGetMacro(OutlineFaceWires, int);
211  void OutlineFaceWiresOn() { this->SetOutlineFaceWires(1); }
212  void OutlineFaceWiresOff() { this->SetOutlineFaceWires(0); }
214 
216 
221  void SetOutlineCursorWires(int);
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:
244  vtkBoxWidget();
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);
290  void ComputeNormals();
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.
337  void CreateDefaultProperties();
338 
339  // Control the orientation of the normals
343  void GenerateOutline();
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
vtkPolyDataMapper * HexMapper
Definition: vtkBoxWidget.h:272
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:45
vtkActor ** Handle
Definition: vtkBoxWidget.h:283
vtkProperty * HandleProperty
Definition: vtkBoxWidget.h:331
vtkProperty * SelectedOutlineProperty
Definition: vtkBoxWidget.h:336
vtkActor * HexActor
Definition: vtkBoxWidget.h:271
vtkActor * CurrentHandle
Definition: vtkBoxWidget.h:301
vtkPolyDataMapper * HexFaceMapper
Definition: vtkBoxWidget.h:279
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:40
abstract base class for most VTK objects
Definition: vtkObject.h:51
vtkPolyDataMapper ** HandleMapper
Definition: vtkBoxWidget.h:284
vtkTypeBool ScalingEnabled
Definition: vtkBoxWidget.h:347
represent surface properties of a geometric object
Definition: vtkProperty.h:56
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
Handles the char widget activation event.
vtkActor * HexFace
Definition: vtkBoxWidget.h:278
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
implicit function for convex set of planes
Definition: vtkPlanes.h:41
void OutlineFaceWiresOff()
Control the representation of the outline.
Definition: vtkBoxWidget.h:212
vtkPolyDataMapper * OutlineMapper
Definition: vtkBoxWidget.h:295
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:49
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
vtkProperty * FaceProperty
Definition: vtkBoxWidget.h:333
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkPolyData * OutlinePolyData
Definition: vtkBoxWidget.h:296
vtkTransform * Transform
Definition: vtkBoxWidget.h:327
vtkCellPicker * HexPicker
Definition: vtkBoxWidget.h:300
vtkPolyData * HexFacePolyData
Definition: vtkBoxWidget.h:280
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
int vtkTypeBool
Definition: vtkABI.h:64
vtkPoints * Points
Definition: vtkBoxWidget.h:274
create a polygonal sphere centered at the origin
vtkTypeBool InsideOut
Definition: vtkBoxWidget.h:340
vtkProperty * SelectedFaceProperty
Definition: vtkBoxWidget.h:334
a simple class to control print indentation
Definition: vtkIndent.h:28
void PlaceWidget() override
Methods that satisfy the superclass' API.
Definition: vtkBoxWidget.h:107
vtkProperty * OutlineProperty
Definition: vtkBoxWidget.h:335
vtkTypeBool RotationEnabled
Definition: vtkBoxWidget.h:348
vtkCellPicker * HandlePicker
Definition: vtkBoxWidget.h:299
vtkActor * HexOutline
Definition: vtkBoxWidget.h:294
vtkTypeBool TranslationEnabled
Definition: vtkBoxWidget.h:346
map vtkPolyData to graphics primitives
vtkPolyData * HexPolyData
Definition: vtkBoxWidget.h:273
void OutlineCursorWiresOn()
Control the representation of the outline.
Definition: vtkBoxWidget.h:223
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:61
orthogonal hexahedron 3D widget
Definition: vtkBoxWidget.h:90
int OutlineFaceWires
Definition: vtkBoxWidget.h:341
void OutlineCursorWiresOff()
Control the representation of the outline.
Definition: vtkBoxWidget.h:224
int OutlineCursorWires
Definition: vtkBoxWidget.h:342
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
void OutlineFaceWiresOn()
Control the representation of the outline.
Definition: vtkBoxWidget.h:211
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:59
virtual void SizeHandles()
Definition: vtk3DWidget.h:144
virtual void PlaceWidget()
This method is used to initially place the widget.
represent and manipulate 3D points
Definition: vtkPoints.h:28
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
vtkSphereSource ** HandleGeometry
Definition: vtkBoxWidget.h:285
vtkProperty * SelectedHandleProperty
Definition: vtkBoxWidget.h:332