VTK
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 =========================================================================*/
75 #ifndef vtkBoxWidget_h
76 #define vtkBoxWidget_h
77 
78 #include "vtkInteractionWidgetsModule.h" // For export macro
79 #include "vtk3DWidget.h"
80 
81 class vtkActor;
82 class vtkCellPicker;
83 class vtkPlanes;
84 class vtkPoints;
85 class vtkPolyData;
86 class vtkPolyDataMapper;
87 class vtkProp;
88 class vtkProperty;
89 class vtkSphereSource;
90 class vtkTransform;
91 
92 class VTKINTERACTIONWIDGETS_EXPORT vtkBoxWidget : public vtk3DWidget
93 {
94 public:
98  static vtkBoxWidget *New();
99 
100  vtkTypeMacro(vtkBoxWidget,vtk3DWidget);
101  void PrintSelf(ostream& os, vtkIndent indent) override;
102 
104 
107  void SetEnabled(int) override;
108  void PlaceWidget(double bounds[6]) override;
109  void PlaceWidget() override
110  {this->Superclass::PlaceWidget();}
111  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
112  double zmin, double zmax) override
113  {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
115 
124  void GetPlanes(vtkPlanes *planes);
125 
127 
132  vtkSetMacro(InsideOut,vtkTypeBool);
133  vtkGetMacro(InsideOut,vtkTypeBool);
134  vtkBooleanMacro(InsideOut,vtkTypeBool);
136 
144  virtual void GetTransform(vtkTransform *t);
145 
152  virtual void SetTransform(vtkTransform* t);
153 
164  void GetPolyData(vtkPolyData *pd);
165 
167 
172  vtkGetObjectMacro(HandleProperty,vtkProperty);
173  vtkGetObjectMacro(SelectedHandleProperty,vtkProperty);
175 
177 
181  void HandlesOn();
182  void HandlesOff();
184 
186 
191  vtkGetObjectMacro(FaceProperty,vtkProperty);
192  vtkGetObjectMacro(SelectedFaceProperty,vtkProperty);
194 
196 
201  vtkGetObjectMacro(OutlineProperty,vtkProperty);
202  vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty);
204 
206 
210  void SetOutlineFaceWires(int);
211  vtkGetMacro(OutlineFaceWires,int);
212  void OutlineFaceWiresOn() {this->SetOutlineFaceWires(1);}
213  void OutlineFaceWiresOff() {this->SetOutlineFaceWires(0);}
215 
217 
222  void SetOutlineCursorWires(int);
223  vtkGetMacro(OutlineCursorWires,int);
224  void OutlineCursorWiresOn() {this->SetOutlineCursorWires(1);}
225  void OutlineCursorWiresOff() {this->SetOutlineCursorWires(0);}
227 
229 
233  vtkSetMacro(TranslationEnabled,vtkTypeBool);
234  vtkGetMacro(TranslationEnabled,vtkTypeBool);
235  vtkBooleanMacro(TranslationEnabled,vtkTypeBool);
236  vtkSetMacro(ScalingEnabled,vtkTypeBool);
237  vtkGetMacro(ScalingEnabled,vtkTypeBool);
238  vtkBooleanMacro(ScalingEnabled,vtkTypeBool);
239  vtkSetMacro(RotationEnabled,vtkTypeBool);
240  vtkGetMacro(RotationEnabled,vtkTypeBool);
241  vtkBooleanMacro(RotationEnabled,vtkTypeBool);
243 
244 protected:
245  vtkBoxWidget();
246  ~vtkBoxWidget() override;
247 
248  // Manage the state of the widget
249  int State;
251  {
252  Start=0,
255  Outside
256  };
257 
258  // Handles the events
259  static void ProcessEvents(vtkObject* object,
260  unsigned long event,
261  void* clientdata,
262  void* calldata);
263 
264  // ProcessEvents() dispatches to these methods.
265  virtual void OnMouseMove();
266  virtual void OnLeftButtonDown();
267  virtual void OnLeftButtonUp();
268  virtual void OnMiddleButtonDown();
269  virtual void OnMiddleButtonUp();
270  virtual void OnRightButtonDown();
271  virtual void OnRightButtonUp();
272 
273  // the hexahedron (6 faces)
277  vtkPoints *Points; //used by others as well
278  double N[6][3]; //the normals of the faces
279 
280  // A face of the hexahedron
284 
285  // glyphs representing hot spots (e.g., handles)
289  virtual void PositionHandles();
290  int HighlightHandle(vtkProp *prop); //returns cell id
291  void HighlightFace(int cellId);
292  void HighlightOutline(int highlight);
293  void ComputeNormals();
294  void SizeHandles() override;
295 
296  // wireframe outline
300 
301  // Do the picking
306 
307  // Register internal Pickers within PickingManager
308  void RegisterPickers() override;
309 
310  // Methods to manipulate the hexahedron.
311  virtual void Translate(double *p1, double *p2);
312  virtual void Scale(double *p1, double *p2, int X, int Y);
313  virtual void Rotate(int X, int Y, double *p1, double *p2, double *vpn);
314  void MovePlusXFace(double *p1, double *p2);
315  void MoveMinusXFace(double *p1, double *p2);
316  void MovePlusYFace(double *p1, double *p2);
317  void MoveMinusYFace(double *p1, double *p2);
318  void MovePlusZFace(double *p1, double *p2);
319  void MoveMinusZFace(double *p1, double *p2);
320 
321  //"dir" is the direction in which the face can be moved i.e. the axis passing
322  //through the center
323  void MoveFace(double *p1, double *p2, double *dir,
324  double *x1, double *x2, double *x3, double *x4,
325  double *x5);
326  //Helper method to obtain the direction in which the face is to be moved.
327  //Handles special cases where some of the scale factors are 0.
328  void GetDirection(const double Nx[3],const double Ny[3],
329  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:275
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:44
vtkActor ** Handle
Definition: vtkBoxWidget.h:286
vtkProperty * HandleProperty
Definition: vtkBoxWidget.h:336
vtkProperty * SelectedOutlineProperty
Definition: vtkBoxWidget.h:341
vtkActor * HexActor
Definition: vtkBoxWidget.h:274
vtkActor * CurrentHandle
Definition: vtkBoxWidget.h:304
vtkPolyDataMapper * HexFaceMapper
Definition: vtkBoxWidget.h:282
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
abstract base class for most VTK objects
Definition: vtkObject.h:53
vtkPolyDataMapper ** HandleMapper
Definition: vtkBoxWidget.h:287
vtkTypeBool ScalingEnabled
Definition: vtkBoxWidget.h:352
represent surface properties of a geometric object
Definition: vtkProperty.h:60
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
Handles the char widget activation event.
vtkActor * HexFace
Definition: vtkBoxWidget.h:281
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:48
void OutlineFaceWiresOff()
Control the representation of the outline.
Definition: vtkBoxWidget.h:213
vtkPolyDataMapper * OutlineMapper
Definition: vtkBoxWidget.h:298
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:54
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
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:299
vtkTransform * Transform
Definition: vtkBoxWidget.h:332
vtkCellPicker * HexPicker
Definition: vtkBoxWidget.h:303
vtkPolyData * HexFacePolyData
Definition: vtkBoxWidget.h:283
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
int vtkTypeBool
Definition: vtkABI.h:69
vtkPoints * Points
Definition: vtkBoxWidget.h:277
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:109
vtkProperty * OutlineProperty
Definition: vtkBoxWidget.h:340
vtkTypeBool RotationEnabled
Definition: vtkBoxWidget.h:353
vtkCellPicker * HandlePicker
Definition: vtkBoxWidget.h:302
vtkActor * HexOutline
Definition: vtkBoxWidget.h:297
vtkTypeBool TranslationEnabled
Definition: vtkBoxWidget.h:351
map vtkPolyData to graphics primitives
vtkPolyData * HexPolyData
Definition: vtkBoxWidget.h:276
void OutlineCursorWiresOn()
Control the representation of the outline.
Definition: vtkBoxWidget.h:224
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:63
orthogonal hexahedron 3D widget
Definition: vtkBoxWidget.h:92
int OutlineFaceWires
Definition: vtkBoxWidget.h:346
void OutlineCursorWiresOff()
Control the representation of the outline.
Definition: vtkBoxWidget.h:225
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:212
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:67
virtual void SizeHandles()
Definition: vtk3DWidget.h:152
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:111
vtkSphereSource ** HandleGeometry
Definition: vtkBoxWidget.h:288
vtkProperty * SelectedHandleProperty
Definition: vtkBoxWidget.h:337