VTK  9.2.6
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 
171  void GetPolyData(vtkPolyData* pd);
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 
217  void SetOutlineFaceWires(int);
218  vtkGetMacro(OutlineFaceWires, int);
219  void OutlineFaceWiresOn() { this->SetOutlineFaceWires(1); }
220  void OutlineFaceWiresOff() { this->SetOutlineFaceWires(0); }
222 
224 
229  void SetOutlineCursorWires(int);
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:
252  vtkBoxWidget();
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);
298  void ComputeNormals();
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.
345  void CreateDefaultProperties();
346 
347  // Control the orientation of the normals
351  void GenerateOutline();
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
vtkPolyDataMapper * HexMapper
Definition: vtkBoxWidget.h:280
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:56
vtkActor ** Handle
Definition: vtkBoxWidget.h:291
vtkProperty * HandleProperty
Definition: vtkBoxWidget.h:339
vtkProperty * SelectedOutlineProperty
Definition: vtkBoxWidget.h:344
vtkActor * HexActor
Definition: vtkBoxWidget.h:279
vtkActor * CurrentHandle
Definition: vtkBoxWidget.h:309
vtkPolyDataMapper * HexFaceMapper
Definition: vtkBoxWidget.h:287
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtkPolyDataMapper ** HandleMapper
Definition: vtkBoxWidget.h:292
vtkTypeBool ScalingEnabled
Definition: vtkBoxWidget.h:355
represent surface properties of a geometric object
Definition: vtkProperty.h:67
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
Handles the char widget activation event.
vtkActor * HexFace
Definition: vtkBoxWidget.h:286
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:52
void OutlineFaceWiresOff()
Control the representation of the outline.
Definition: vtkBoxWidget.h:220
vtkPolyDataMapper * OutlineMapper
Definition: vtkBoxWidget.h:303
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:60
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:90
vtkProperty * FaceProperty
Definition: vtkBoxWidget.h:341
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkPolyData * OutlinePolyData
Definition: vtkBoxWidget.h:304
vtkTransform * Transform
Definition: vtkBoxWidget.h:335
vtkCellPicker * HexPicker
Definition: vtkBoxWidget.h:308
vtkPolyData * HexFacePolyData
Definition: vtkBoxWidget.h:288
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
int vtkTypeBool
Definition: vtkABI.h:69
vtkPoints * Points
Definition: vtkBoxWidget.h:282
create a polygonal sphere centered at the origin
vtkTypeBool InsideOut
Definition: vtkBoxWidget.h:348
vtkProperty * SelectedFaceProperty
Definition: vtkBoxWidget.h:342
a simple class to control print indentation
Definition: vtkIndent.h:39
void PlaceWidget() override
Methods that satisfy the superclass' API.
Definition: vtkBoxWidget.h:115
vtkProperty * OutlineProperty
Definition: vtkBoxWidget.h:343
vtkTypeBool RotationEnabled
Definition: vtkBoxWidget.h:356
vtkCellPicker * HandlePicker
Definition: vtkBoxWidget.h:307
vtkActor * HexOutline
Definition: vtkBoxWidget.h:302
vtkTypeBool TranslationEnabled
Definition: vtkBoxWidget.h:354
map vtkPolyData to graphics primitives
vtkPolyData * HexPolyData
Definition: vtkBoxWidget.h:281
void OutlineCursorWiresOn()
Control the representation of the outline.
Definition: vtkBoxWidget.h:231
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:72
orthogonal hexahedron 3D widget
Definition: vtkBoxWidget.h:98
int OutlineFaceWires
Definition: vtkBoxWidget.h:349
void OutlineCursorWiresOff()
Control the representation of the outline.
Definition: vtkBoxWidget.h:232
int OutlineCursorWires
Definition: vtkBoxWidget.h:350
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:219
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:39
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
vtkSphereSource ** HandleGeometry
Definition: vtkBoxWidget.h:293
vtkProperty * SelectedHandleProperty
Definition: vtkBoxWidget.h:340