VTK  9.2.5
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 =========================================================================*/
120 #ifndef vtkBoxWidget_h
121 #define vtkBoxWidget_h
122 
123 #include "vtk3DWidget.h"
124 #include "vtkInteractionWidgetsModule.h" // For export macro
125 
126 class vtkActor;
127 class vtkCellPicker;
128 class vtkPlanes;
129 class vtkPoints;
130 class vtkPolyData;
131 class vtkPolyDataMapper;
132 class vtkProp;
133 class vtkProperty;
134 class vtkSphereSource;
135 class vtkTransform;
136 
137 class VTKINTERACTIONWIDGETS_EXPORT vtkBoxWidget : public vtk3DWidget
138 {
139 public:
143  static vtkBoxWidget* New();
144 
145  vtkTypeMacro(vtkBoxWidget, vtk3DWidget);
146  void PrintSelf(ostream& os, vtkIndent indent) override;
147 
149 
152  void SetEnabled(int) override;
153  void PlaceWidget(double bounds[6]) override;
154  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
156  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
157  {
158  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
159  }
161 
170  void GetPlanes(vtkPlanes* planes);
171 
173 
178  vtkSetMacro(InsideOut, vtkTypeBool);
179  vtkGetMacro(InsideOut, vtkTypeBool);
180  vtkBooleanMacro(InsideOut, vtkTypeBool);
182 
190  virtual void GetTransform(vtkTransform* t);
191 
198  virtual void SetTransform(vtkTransform* t);
199 
211 
213 
218  vtkGetObjectMacro(HandleProperty, vtkProperty);
219  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
221 
223 
227  void HandlesOn();
228  void HandlesOff();
230 
232 
237  vtkGetObjectMacro(FaceProperty, vtkProperty);
238  vtkGetObjectMacro(SelectedFaceProperty, vtkProperty);
240 
242 
247  vtkGetObjectMacro(OutlineProperty, vtkProperty);
248  vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
250 
252 
257  vtkGetMacro(OutlineFaceWires, int);
258  void OutlineFaceWiresOn() { this->SetOutlineFaceWires(1); }
259  void OutlineFaceWiresOff() { this->SetOutlineFaceWires(0); }
261 
263 
269  vtkGetMacro(OutlineCursorWires, int);
270  void OutlineCursorWiresOn() { this->SetOutlineCursorWires(1); }
271  void OutlineCursorWiresOff() { this->SetOutlineCursorWires(0); }
273 
275 
279  vtkSetMacro(TranslationEnabled, vtkTypeBool);
280  vtkGetMacro(TranslationEnabled, vtkTypeBool);
281  vtkBooleanMacro(TranslationEnabled, vtkTypeBool);
282  vtkSetMacro(ScalingEnabled, vtkTypeBool);
283  vtkGetMacro(ScalingEnabled, vtkTypeBool);
284  vtkBooleanMacro(ScalingEnabled, vtkTypeBool);
285  vtkSetMacro(RotationEnabled, vtkTypeBool);
286  vtkGetMacro(RotationEnabled, vtkTypeBool);
287  vtkBooleanMacro(RotationEnabled, vtkTypeBool);
289 
290 protected:
292  ~vtkBoxWidget() override;
293 
294  // Manage the state of the widget
295  int State;
297  {
298  Start = 0,
301  Outside
302  };
303 
304  // Handles the events
305  static void ProcessEvents(
306  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
307 
308  // ProcessEvents() dispatches to these methods.
309  virtual void OnMouseMove();
310  virtual void OnLeftButtonDown();
311  virtual void OnLeftButtonUp();
312  virtual void OnMiddleButtonDown();
313  virtual void OnMiddleButtonUp();
314  virtual void OnRightButtonDown();
315  virtual void OnRightButtonUp();
316 
317  // the hexahedron (6 faces)
321  vtkPoints* Points; // used by others as well
322  double N[6][3]; // the normals of the faces
323 
324  // A face of the hexahedron
328 
329  // glyphs representing hot spots (e.g., handles)
333  virtual void PositionHandles();
334  int HighlightHandle(vtkProp* prop); // returns cell id
335  void HighlightFace(int cellId);
336  void HighlightOutline(int highlight);
338  void SizeHandles() override;
339 
340  // wireframe outline
344 
345  // Do the picking
350 
351  // Register internal Pickers within PickingManager
352  void RegisterPickers() override;
353 
354  // Methods to manipulate the hexahedron.
355  virtual void Translate(double* p1, double* p2);
356  virtual void Scale(double* p1, double* p2, int X, int Y);
357  virtual void Rotate(int X, int Y, double* p1, double* p2, double* vpn);
358  void MovePlusXFace(double* p1, double* p2);
359  void MoveMinusXFace(double* p1, double* p2);
360  void MovePlusYFace(double* p1, double* p2);
361  void MoveMinusYFace(double* p1, double* p2);
362  void MovePlusZFace(double* p1, double* p2);
363  void MoveMinusZFace(double* p1, double* p2);
364 
365  //"dir" is the direction in which the face can be moved i.e. the axis passing
366  // through the center
367  void MoveFace(double* p1, double* p2, double* dir, double* x1, double* x2, double* x3, double* x4,
368  double* x5);
369  // Helper method to obtain the direction in which the face is to be moved.
370  // Handles special cases where some of the scale factors are 0.
371  void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3]);
372 
373  // Transform the hexahedral points (used for rotations)
375 
376  // Properties used to control the appearance of selected objects and
377  // the manipulator in general.
385 
386  // Control the orientation of the normals
391 
392  // Control whether scaling, rotation, and translation are supported
396 
397 private:
398  vtkBoxWidget(const vtkBoxWidget&) = delete;
399  void operator=(const vtkBoxWidget&) = delete;
400 };
401 
402 #endif
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:71
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:161
orthogonal hexahedron 3D widget
Definition: vtkBoxWidget.h:138
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:155
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:271
void PlaceWidget() override
Methods that satisfy the superclass' API.
Definition: vtkBoxWidget.h:154
virtual void Scale(double *p1, double *p2, int X, int Y)
vtkTypeBool ScalingEnabled
Definition: vtkBoxWidget.h:394
vtkPolyData * HexPolyData
Definition: vtkBoxWidget.h:320
void CreateDefaultProperties()
vtkPolyData * HexFacePolyData
Definition: vtkBoxWidget.h:327
virtual void Translate(double *p1, double *p2)
void PlaceWidget(double bounds[6]) override
Methods that satisfy the superclass' API.
vtkActor * HexOutline
Definition: vtkBoxWidget.h:341
static vtkBoxWidget * New()
Instantiate the object.
void ComputeNormals()
~vtkBoxWidget() override
void HighlightOutline(int highlight)
vtkSphereSource ** HandleGeometry
Definition: vtkBoxWidget.h:332
vtkTransform * Transform
Definition: vtkBoxWidget.h:374
vtkProperty * SelectedFaceProperty
Definition: vtkBoxWidget.h:381
vtkCellPicker * HandlePicker
Definition: vtkBoxWidget.h:346
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:378
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:270
void MovePlusYFace(double *p1, double *p2)
vtkCellPicker * HexPicker
Definition: vtkBoxWidget.h:347
vtkPolyDataMapper * HexMapper
Definition: vtkBoxWidget.h:319
virtual void OnMiddleButtonDown()
vtkPoints * Points
Definition: vtkBoxWidget.h:321
int OutlineCursorWires
Definition: vtkBoxWidget.h:389
void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3])
vtkTypeBool RotationEnabled
Definition: vtkBoxWidget.h:395
void HandlesOn()
Switches handles (the spheres) on or off by manipulating the actor visibility.
int OutlineFaceWires
Definition: vtkBoxWidget.h:388
void SetOutlineFaceWires(int)
Control the representation of the outline.
vtkTypeBool InsideOut
Definition: vtkBoxWidget.h:387
vtkTypeBool TranslationEnabled
Definition: vtkBoxWidget.h:393
vtkPolyDataMapper * HexFaceMapper
Definition: vtkBoxWidget.h:326
int HighlightHandle(vtkProp *prop)
vtkActor * HexActor
Definition: vtkBoxWidget.h:318
vtkProperty * OutlineProperty
Definition: vtkBoxWidget.h:382
vtkActor ** Handle
Definition: vtkBoxWidget.h:330
void OutlineFaceWiresOn()
Control the representation of the outline.
Definition: vtkBoxWidget.h:258
vtkPolyData * OutlinePolyData
Definition: vtkBoxWidget.h:343
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:380
vtkActor * HexFace
Definition: vtkBoxWidget.h:325
void OutlineFaceWiresOff()
Control the representation of the outline.
Definition: vtkBoxWidget.h:259
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:379
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:342
vtkProperty * SelectedOutlineProperty
Definition: vtkBoxWidget.h:383
vtkPolyDataMapper ** HandleMapper
Definition: vtkBoxWidget.h:331
vtkActor * CurrentHandle
Definition: vtkBoxWidget.h:348
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
a simple class to control print indentation
Definition: vtkIndent.h:119
abstract base class for most VTK objects
Definition: vtkObject.h:82
implicit function for convex set of planes
Definition: vtkPlanes.h:162
represent and manipulate 3D points
Definition: vtkPoints.h:149
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:200
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:76
represent surface properties of a geometric object
Definition: vtkProperty.h:177
create a polygonal sphere centered at the origin
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:170
@ dir
Definition: vtkX3D.h:330
int vtkTypeBool
Definition: vtkABI.h:69