VTK  9.0.1
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 =========================================================================*/
78 #ifndef vtkBoxWidget_h
79 #define vtkBoxWidget_h
80 
81 #include "vtk3DWidget.h"
82 #include "vtkInteractionWidgetsModule.h" // For export macro
83 
84 class vtkActor;
85 class vtkCellPicker;
86 class vtkPlanes;
87 class vtkPoints;
88 class vtkPolyData;
89 class vtkPolyDataMapper;
90 class vtkProp;
91 class vtkProperty;
92 class vtkSphereSource;
93 class vtkTransform;
94 
95 class VTKINTERACTIONWIDGETS_EXPORT vtkBoxWidget : public vtk3DWidget
96 {
97 public:
101  static vtkBoxWidget* New();
102 
103  vtkTypeMacro(vtkBoxWidget, vtk3DWidget);
104  void PrintSelf(ostream& os, vtkIndent indent) override;
105 
107 
110  void SetEnabled(int) override;
111  void PlaceWidget(double bounds[6]) override;
112  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
114  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
115  {
116  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
117  }
119 
128  void GetPlanes(vtkPlanes* planes);
129 
131 
136  vtkSetMacro(InsideOut, vtkTypeBool);
137  vtkGetMacro(InsideOut, vtkTypeBool);
138  vtkBooleanMacro(InsideOut, vtkTypeBool);
140 
148  virtual void GetTransform(vtkTransform* t);
149 
156  virtual void SetTransform(vtkTransform* t);
157 
168  void GetPolyData(vtkPolyData* pd);
169 
171 
176  vtkGetObjectMacro(HandleProperty, vtkProperty);
177  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
179 
181 
185  void HandlesOn();
186  void HandlesOff();
188 
190 
195  vtkGetObjectMacro(FaceProperty, vtkProperty);
196  vtkGetObjectMacro(SelectedFaceProperty, vtkProperty);
198 
200 
205  vtkGetObjectMacro(OutlineProperty, vtkProperty);
206  vtkGetObjectMacro(SelectedOutlineProperty, vtkProperty);
208 
210 
214  void SetOutlineFaceWires(int);
215  vtkGetMacro(OutlineFaceWires, int);
216  void OutlineFaceWiresOn() { this->SetOutlineFaceWires(1); }
217  void OutlineFaceWiresOff() { this->SetOutlineFaceWires(0); }
219 
221 
226  void SetOutlineCursorWires(int);
227  vtkGetMacro(OutlineCursorWires, int);
228  void OutlineCursorWiresOn() { this->SetOutlineCursorWires(1); }
229  void OutlineCursorWiresOff() { this->SetOutlineCursorWires(0); }
231 
233 
237  vtkSetMacro(TranslationEnabled, vtkTypeBool);
238  vtkGetMacro(TranslationEnabled, vtkTypeBool);
239  vtkBooleanMacro(TranslationEnabled, vtkTypeBool);
240  vtkSetMacro(ScalingEnabled, vtkTypeBool);
241  vtkGetMacro(ScalingEnabled, vtkTypeBool);
242  vtkBooleanMacro(ScalingEnabled, vtkTypeBool);
243  vtkSetMacro(RotationEnabled, vtkTypeBool);
244  vtkGetMacro(RotationEnabled, vtkTypeBool);
245  vtkBooleanMacro(RotationEnabled, vtkTypeBool);
247 
248 protected:
249  vtkBoxWidget();
250  ~vtkBoxWidget() override;
251 
252  // Manage the state of the widget
253  int State;
255  {
256  Start = 0,
259  Outside
260  };
261 
262  // Handles the events
263  static void ProcessEvents(
264  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
265 
266  // ProcessEvents() dispatches to these methods.
267  virtual void OnMouseMove();
268  virtual void OnLeftButtonDown();
269  virtual void OnLeftButtonUp();
270  virtual void OnMiddleButtonDown();
271  virtual void OnMiddleButtonUp();
272  virtual void OnRightButtonDown();
273  virtual void OnRightButtonUp();
274 
275  // the hexahedron (6 faces)
279  vtkPoints* Points; // used by others as well
280  double N[6][3]; // the normals of the faces
281 
282  // A face of the hexahedron
286 
287  // glyphs representing hot spots (e.g., handles)
291  virtual void PositionHandles();
292  int HighlightHandle(vtkProp* prop); // returns cell id
293  void HighlightFace(int cellId);
294  void HighlightOutline(int highlight);
295  void ComputeNormals();
296  void SizeHandles() override;
297 
298  // wireframe outline
302 
303  // Do the picking
308 
309  // Register internal Pickers within PickingManager
310  void RegisterPickers() override;
311 
312  // Methods to manipulate the hexahedron.
313  virtual void Translate(double* p1, double* p2);
314  virtual void Scale(double* p1, double* p2, int X, int Y);
315  virtual void Rotate(int X, int Y, double* p1, double* p2, double* vpn);
316  void MovePlusXFace(double* p1, double* p2);
317  void MoveMinusXFace(double* p1, double* p2);
318  void MovePlusYFace(double* p1, double* p2);
319  void MoveMinusYFace(double* p1, double* p2);
320  void MovePlusZFace(double* p1, double* p2);
321  void MoveMinusZFace(double* p1, double* p2);
322 
323  //"dir" is the direction in which the face can be moved i.e. the axis passing
324  // through the center
325  void MoveFace(double* p1, double* p2, double* dir, double* x1, double* x2, double* x3, double* x4,
326  double* x5);
327  // Helper method to obtain the direction in which the face is to be moved.
328  // Handles special cases where some of the scale factors are 0.
329  void GetDirection(const double Nx[3], const double Ny[3], const double Nz[3], double dir[3]);
330 
331  // Transform the hexahedral points (used for rotations)
333 
334  // Properties used to control the appearance of selected objects and
335  // the manipulator in general.
342  void CreateDefaultProperties();
343 
344  // Control the orientation of the normals
348  void GenerateOutline();
349 
350  // Control whether scaling, rotation, and translation are supported
354 
355 private:
356  vtkBoxWidget(const vtkBoxWidget&) = delete;
357  void operator=(const vtkBoxWidget&) = delete;
358 };
359 
360 #endif
vtkPolyDataMapper * HexMapper
Definition: vtkBoxWidget.h:277
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:50
vtkActor ** Handle
Definition: vtkBoxWidget.h:288
vtkProperty * HandleProperty
Definition: vtkBoxWidget.h:336
vtkProperty * SelectedOutlineProperty
Definition: vtkBoxWidget.h:341
vtkActor * HexActor
Definition: vtkBoxWidget.h:276
vtkActor * CurrentHandle
Definition: vtkBoxWidget.h:306
vtkPolyDataMapper * HexFaceMapper
Definition: vtkBoxWidget.h:284
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
abstract base class for most VTK objects
Definition: vtkObject.h:56
vtkPolyDataMapper ** HandleMapper
Definition: vtkBoxWidget.h:289
vtkTypeBool ScalingEnabled
Definition: vtkBoxWidget.h:352
represent surface properties of a geometric object
Definition: vtkProperty.h:61
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
Handles the char widget activation event.
vtkActor * HexFace
Definition: vtkBoxWidget.h:283
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:49
void OutlineFaceWiresOff()
Control the representation of the outline.
Definition: vtkBoxWidget.h:217
vtkPolyDataMapper * OutlineMapper
Definition: vtkBoxWidget.h:300
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:54
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
vtkProperty * FaceProperty
Definition: vtkBoxWidget.h:338
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkPolyData * OutlinePolyData
Definition: vtkBoxWidget.h:301
vtkTransform * Transform
Definition: vtkBoxWidget.h:332
vtkCellPicker * HexPicker
Definition: vtkBoxWidget.h:305
vtkPolyData * HexFacePolyData
Definition: vtkBoxWidget.h:285
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
int vtkTypeBool
Definition: vtkABI.h:69
vtkPoints * Points
Definition: vtkBoxWidget.h:279
create a polygonal sphere centered at the origin
vtkTypeBool InsideOut
Definition: vtkBoxWidget.h:345
vtkProperty * SelectedFaceProperty
Definition: vtkBoxWidget.h:339
a simple class to control print indentation
Definition: vtkIndent.h:33
void PlaceWidget() override
Methods that satisfy the superclass' API.
Definition: vtkBoxWidget.h:112
vtkProperty * OutlineProperty
Definition: vtkBoxWidget.h:340
vtkTypeBool RotationEnabled
Definition: vtkBoxWidget.h:353
vtkCellPicker * HandlePicker
Definition: vtkBoxWidget.h:304
vtkActor * HexOutline
Definition: vtkBoxWidget.h:299
vtkTypeBool TranslationEnabled
Definition: vtkBoxWidget.h:351
map vtkPolyData to graphics primitives
vtkPolyData * HexPolyData
Definition: vtkBoxWidget.h:278
void OutlineCursorWiresOn()
Control the representation of the outline.
Definition: vtkBoxWidget.h:228
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:66
orthogonal hexahedron 3D widget
Definition: vtkBoxWidget.h:95
int OutlineFaceWires
Definition: vtkBoxWidget.h:346
void OutlineCursorWiresOff()
Control the representation of the outline.
Definition: vtkBoxWidget.h:229
int OutlineCursorWires
Definition: vtkBoxWidget.h:347
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:216
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:70
virtual void SizeHandles()
Definition: vtk3DWidget.h:155
virtual void PlaceWidget()
This method is used to initially place the widget.
represent and manipulate 3D points
Definition: vtkPoints.h:33
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
Methods that satisfy the superclass' API.
Definition: vtkBoxWidget.h:113
vtkSphereSource ** HandleGeometry
Definition: vtkBoxWidget.h:290
vtkProperty * SelectedHandleProperty
Definition: vtkBoxWidget.h:337