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 =========================================================================*/
81 #ifndef vtkBoxWidget_h
82 #define vtkBoxWidget_h
83 
84 #include "vtk3DWidget.h"
85 #include "vtkInteractionWidgetsModule.h" // For export macro
86 
87 class vtkActor;
88 class vtkCellPicker;
89 class vtkPlanes;
90 class vtkPoints;
91 class vtkPolyData;
92 class vtkPolyDataMapper;
93 class vtkProp;
94 class vtkProperty;
95 class vtkSphereSource;
96 class vtkTransform;
97 
98 class VTKINTERACTIONWIDGETS_EXPORT vtkBoxWidget : public vtk3DWidget
99 {
100 public:
104  static vtkBoxWidget* New();
105 
106  vtkTypeMacro(vtkBoxWidget, vtk3DWidget);
107  void PrintSelf(ostream& os, vtkIndent indent) override;
108 
110 
113  void SetEnabled(int) override;
114  void PlaceWidget(double bounds[6]) override;
115  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
117  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
118  {
119  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
120  }
122 
131  void GetPlanes(vtkPlanes* planes);
132 
134 
139  vtkSetMacro(InsideOut, vtkTypeBool);
140  vtkGetMacro(InsideOut, vtkTypeBool);
141  vtkBooleanMacro(InsideOut, vtkTypeBool);
143 
151  virtual void GetTransform(vtkTransform* t);
152 
159  virtual void SetTransform(vtkTransform* t);
160 
172 
174 
179  vtkGetObjectMacro(HandleProperty, vtkProperty);
180  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
182 
184 
188  void HandlesOn();
189  void HandlesOff();
191 
193 
198  vtkGetObjectMacro(FaceProperty, vtkProperty);
199  vtkGetObjectMacro(SelectedFaceProperty, vtkProperty);
201 
203 
208  vtkGetObjectMacro(OutlineProperty, vtkProperty);
209  vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
211 
213 
218  vtkGetMacro(OutlineFaceWires, int);
219  void OutlineFaceWiresOn() { this->SetOutlineFaceWires(1); }
220  void OutlineFaceWiresOff() { this->SetOutlineFaceWires(0); }
222 
224 
230  vtkGetMacro(OutlineCursorWires, int);
231  void OutlineCursorWiresOn() { this->SetOutlineCursorWires(1); }
232  void OutlineCursorWiresOff() { this->SetOutlineCursorWires(0); }
234 
236 
240  vtkSetMacro(TranslationEnabled, vtkTypeBool);
241  vtkGetMacro(TranslationEnabled, vtkTypeBool);
242  vtkBooleanMacro(TranslationEnabled, vtkTypeBool);
243  vtkSetMacro(ScalingEnabled, vtkTypeBool);
244  vtkGetMacro(ScalingEnabled, vtkTypeBool);
245  vtkBooleanMacro(ScalingEnabled, vtkTypeBool);
246  vtkSetMacro(RotationEnabled, vtkTypeBool);
247  vtkGetMacro(RotationEnabled, vtkTypeBool);
248  vtkBooleanMacro(RotationEnabled, vtkTypeBool);
250 
251 protected:
253  ~vtkBoxWidget() override;
254 
255  // Manage the state of the widget
256  int State;
258  {
259  Start = 0,
262  Outside
263  };
264 
265  // Handles the events
266  static void ProcessEvents(
267  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
268 
269  // ProcessEvents() dispatches to these methods.
270  virtual void OnMouseMove();
271  virtual void OnLeftButtonDown();
272  virtual void OnLeftButtonUp();
273  virtual void OnMiddleButtonDown();
274  virtual void OnMiddleButtonUp();
275  virtual void OnRightButtonDown();
276  virtual void OnRightButtonUp();
277 
278  // the hexahedron (6 faces)
282  vtkPoints* Points; // used by others as well
283  double N[6][3]; // the normals of the faces
284 
285  // A face of the hexahedron
289 
290  // glyphs representing hot spots (e.g., handles)
294  virtual void PositionHandles();
295  int HighlightHandle(vtkProp* prop); // returns cell id
296  void HighlightFace(int cellId);
297  void HighlightOutline(int highlight);
299  void SizeHandles() override;
300 
301  // wireframe outline
305 
306  // Do the picking
311 
312  // Register internal Pickers within PickingManager
313  void RegisterPickers() override;
314 
315  // Methods to manipulate the hexahedron.
316  virtual void Translate(double* p1, double* p2);
317  virtual void Scale(double* p1, double* p2, int X, int Y);
318  virtual void Rotate(int X, int Y, double* p1, double* p2, double* vpn);
319  void MovePlusXFace(double* p1, double* p2);
320  void MoveMinusXFace(double* p1, double* p2);
321  void MovePlusYFace(double* p1, double* p2);
322  void MoveMinusYFace(double* p1, double* p2);
323  void MovePlusZFace(double* p1, double* p2);
324  void MoveMinusZFace(double* p1, double* p2);
325 
326  //"dir" is the direction in which the face can be moved i.e. the axis passing
327  // through the center
328  void MoveFace(double* p1, double* p2, double* dir, double* x1, double* x2, double* x3, double* x4,
329  double* x5);
330  // Helper method to obtain the direction in which the face is to be moved.
331  // Handles special cases where some of the scale factors are 0.
332  void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3]);
333 
334  // Transform the hexahedral points (used for rotations)
336 
337  // Properties used to control the appearance of selected objects and
338  // the manipulator in general.
346 
347  // Control the orientation of the normals
352 
353  // Control whether scaling, rotation, and translation are supported
357 
358 private:
359  vtkBoxWidget(const vtkBoxWidget&) = delete;
360  void operator=(const vtkBoxWidget&) = delete;
361 };
362 
363 #endif
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:71
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:46
orthogonal hexahedron 3D widget
Definition: vtkBoxWidget.h:99
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:116
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:232
void PlaceWidget() override
Methods that satisfy the superclass' API.
Definition: vtkBoxWidget.h:115
virtual void Scale(double *p1, double *p2, int X, int Y)
vtkTypeBool ScalingEnabled
Definition: vtkBoxWidget.h:355
vtkPolyData * HexPolyData
Definition: vtkBoxWidget.h:281
void CreateDefaultProperties()
vtkPolyData * HexFacePolyData
Definition: vtkBoxWidget.h:288
virtual void Translate(double *p1, double *p2)
void PlaceWidget(double bounds[6]) override
Methods that satisfy the superclass' API.
vtkActor * HexOutline
Definition: vtkBoxWidget.h:302
static vtkBoxWidget * New()
Instantiate the object.
void ComputeNormals()
~vtkBoxWidget() override
void HighlightOutline(int highlight)
vtkSphereSource ** HandleGeometry
Definition: vtkBoxWidget.h:293
vtkTransform * Transform
Definition: vtkBoxWidget.h:335
vtkProperty * SelectedFaceProperty
Definition: vtkBoxWidget.h:342
vtkCellPicker * HandlePicker
Definition: vtkBoxWidget.h:307
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:339
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:231
void MovePlusYFace(double *p1, double *p2)
vtkCellPicker * HexPicker
Definition: vtkBoxWidget.h:308
vtkPolyDataMapper * HexMapper
Definition: vtkBoxWidget.h:280
virtual void OnMiddleButtonDown()
vtkPoints * Points
Definition: vtkBoxWidget.h:282
int OutlineCursorWires
Definition: vtkBoxWidget.h:350
void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3])
vtkTypeBool RotationEnabled
Definition: vtkBoxWidget.h:356
void HandlesOn()
Switches handles (the spheres) on or off by manipulating the actor visibility.
int OutlineFaceWires
Definition: vtkBoxWidget.h:349
void SetOutlineFaceWires(int)
Control the representation of the outline.
vtkTypeBool InsideOut
Definition: vtkBoxWidget.h:348
vtkTypeBool TranslationEnabled
Definition: vtkBoxWidget.h:354
vtkPolyDataMapper * HexFaceMapper
Definition: vtkBoxWidget.h:287
int HighlightHandle(vtkProp *prop)
vtkActor * HexActor
Definition: vtkBoxWidget.h:279
vtkProperty * OutlineProperty
Definition: vtkBoxWidget.h:343
vtkActor ** Handle
Definition: vtkBoxWidget.h:291
void OutlineFaceWiresOn()
Control the representation of the outline.
Definition: vtkBoxWidget.h:219
vtkPolyData * OutlinePolyData
Definition: vtkBoxWidget.h:304
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:341
vtkActor * HexFace
Definition: vtkBoxWidget.h:286
void OutlineFaceWiresOff()
Control the representation of the outline.
Definition: vtkBoxWidget.h:220
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:340
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:303
vtkProperty * SelectedOutlineProperty
Definition: vtkBoxWidget.h:344
vtkPolyDataMapper ** HandleMapper
Definition: vtkBoxWidget.h:292
vtkActor * CurrentHandle
Definition: vtkBoxWidget.h:309
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:67
a simple class to control print indentation
Definition: vtkIndent.h:34
abstract base class for most VTK objects
Definition: vtkObject.h:63
implicit function for convex set of planes
Definition: vtkPlanes.h:50
represent and manipulate 3D points
Definition: vtkPoints.h:34
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:86
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:57
represent surface properties of a geometric object
Definition: vtkProperty.h:62
create a polygonal sphere centered at the origin
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:55
@ dir
Definition: vtkX3D.h:330
int vtkTypeBool
Definition: vtkABI.h:69