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 =========================================================================*/
83 #ifndef vtkBoxWidget_h
84 #define vtkBoxWidget_h
85 
86 #include "vtkInteractionWidgetsModule.h" // For export macro
87 #include "vtk3DWidget.h"
88 
89 class vtkActor;
90 class vtkCellPicker;
91 class vtkPlanes;
92 class vtkPoints;
93 class vtkPolyData;
94 class vtkPolyDataMapper;
95 class vtkProp;
96 class vtkProperty;
97 class vtkSphereSource;
98 class vtkTransform;
99 
101 {
102 public:
104  static vtkBoxWidget *New();
105 
106  vtkTypeMacro(vtkBoxWidget,vtk3DWidget);
107  void PrintSelf(ostream& os, vtkIndent indent);
108 
110 
111  virtual void SetEnabled(int);
112  virtual void PlaceWidget(double bounds[6]);
113  void PlaceWidget()
114  {this->Superclass::PlaceWidget();}
115  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
116  double zmin, double zmax)
117  {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
119 
126  void GetPlanes(vtkPlanes *planes);
127 
129 
132  vtkSetMacro(InsideOut,int);
133  vtkGetMacro(InsideOut,int);
134  vtkBooleanMacro(InsideOut,int);
136 
142  virtual void GetTransform(vtkTransform *t);
143 
148  virtual void SetTransform(vtkTransform* t);
149 
158  void GetPolyData(vtkPolyData *pd);
159 
161 
163  vtkGetObjectMacro(HandleProperty,vtkProperty);
164  vtkGetObjectMacro(SelectedHandleProperty,vtkProperty);
166 
168 
170  void HandlesOn();
171  void HandlesOff();
173 
175 
177  vtkGetObjectMacro(FaceProperty,vtkProperty);
178  vtkGetObjectMacro(SelectedFaceProperty,vtkProperty);
180 
182 
184  vtkGetObjectMacro(OutlineProperty,vtkProperty);
185  vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty);
187 
189 
191  void SetOutlineFaceWires(int);
192  vtkGetMacro(OutlineFaceWires,int);
193  void OutlineFaceWiresOn() {this->SetOutlineFaceWires(1);}
194  void OutlineFaceWiresOff() {this->SetOutlineFaceWires(0);}
196 
198 
201  void SetOutlineCursorWires(int);
202  vtkGetMacro(OutlineCursorWires,int);
203  void OutlineCursorWiresOn() {this->SetOutlineCursorWires(1);}
204  void OutlineCursorWiresOff() {this->SetOutlineCursorWires(0);}
206 
208 
210  vtkSetMacro(TranslationEnabled,int);
211  vtkGetMacro(TranslationEnabled,int);
212  vtkBooleanMacro(TranslationEnabled,int);
213  vtkSetMacro(ScalingEnabled,int);
214  vtkGetMacro(ScalingEnabled,int);
215  vtkBooleanMacro(ScalingEnabled,int);
216  vtkSetMacro(RotationEnabled,int);
217  vtkGetMacro(RotationEnabled,int);
218  vtkBooleanMacro(RotationEnabled,int);
220 
221 protected:
222  vtkBoxWidget();
223  ~vtkBoxWidget();
224 
225 //BTX - manage the state of the widget
226  int State;
228  {
229  Start=0,
232  Outside
233  };
234 //ETX
235 
236  // Handles the events
237  static void ProcessEvents(vtkObject* object,
238  unsigned long event,
239  void* clientdata,
240  void* calldata);
241 
242  // ProcessEvents() dispatches to these methods.
243  virtual void OnMouseMove();
244  virtual void OnLeftButtonDown();
245  virtual void OnLeftButtonUp();
246  virtual void OnMiddleButtonDown();
247  virtual void OnMiddleButtonUp();
248  virtual void OnRightButtonDown();
249  virtual void OnRightButtonUp();
250 
251  // the hexahedron (6 faces)
255  vtkPoints *Points; //used by others as well
256  double N[6][3]; //the normals of the faces
257 
258  // A face of the hexahedron
262 
263  // glyphs representing hot spots (e.g., handles)
267  virtual void PositionHandles();
268  int HighlightHandle(vtkProp *prop); //returns cell id
269  void HighlightFace(int cellId);
270  void HighlightOutline(int highlight);
271  void ComputeNormals();
272  virtual void SizeHandles();
273 
274  // wireframe outline
278 
279  // Do the picking
284 
285  // Register internal Pickers within PickingManager
286  virtual void RegisterPickers();
287 
288  // Methods to manipulate the hexahedron.
289  virtual void Translate(double *p1, double *p2);
290  virtual void Scale(double *p1, double *p2, int X, int Y);
291  virtual void Rotate(int X, int Y, double *p1, double *p2, double *vpn);
292  void MovePlusXFace(double *p1, double *p2);
293  void MoveMinusXFace(double *p1, double *p2);
294  void MovePlusYFace(double *p1, double *p2);
295  void MoveMinusYFace(double *p1, double *p2);
296  void MovePlusZFace(double *p1, double *p2);
297  void MoveMinusZFace(double *p1, double *p2);
298 
299  //"dir" is the direction in which the face can be moved i.e. the axis passing
300  //through the center
301  void MoveFace(double *p1, double *p2, double *dir,
302  double *x1, double *x2, double *x3, double *x4,
303  double *x5);
304  //Helper method to obtain the direction in which the face is to be moved.
305  //Handles special cases where some of the scale factors are 0.
306  void GetDirection(const double Nx[3],const double Ny[3],
307  const double Nz[3], double dir[3]);
308 
309  // Transform the hexahedral points (used for rotations)
311 
312  // Properties used to control the appearance of selected objects and
313  // the manipulator in general.
320  void CreateDefaultProperties();
321 
322  // Control the orientation of the normals
326  void GenerateOutline();
327 
328  // Control whether scaling, rotation, and translation are supported
332 
333 private:
334  vtkBoxWidget(const vtkBoxWidget&); //Not implemented
335  void operator=(const vtkBoxWidget&); //Not implemented
336 };
337 
338 #endif
vtkPolyDataMapper * HexMapper
Definition: vtkBoxWidget.h:253
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:52
vtkActor ** Handle
Definition: vtkBoxWidget.h:264
vtkProperty * HandleProperty
Definition: vtkBoxWidget.h:314
vtkProperty * SelectedOutlineProperty
Definition: vtkBoxWidget.h:319
vtkActor * HexActor
Definition: vtkBoxWidget.h:252
vtkActor * CurrentHandle
Definition: vtkBoxWidget.h:282
void PlaceWidget()
Definition: vtkBoxWidget.h:113
vtkPolyDataMapper * HexFaceMapper
Definition: vtkBoxWidget.h:260
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:50
abstract base class for most VTK objects
Definition: vtkObject.h:61
int TranslationEnabled
Definition: vtkBoxWidget.h:329
vtkPolyDataMapper ** HandleMapper
Definition: vtkBoxWidget.h:265
represent surface properties of a geometric object
Definition: vtkProperty.h:63
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
vtkActor * HexFace
Definition: vtkBoxWidget.h:259
virtual void SetEnabled(int)
implicit function for convex set of planes
Definition: vtkPlanes.h:53
void OutlineFaceWiresOff()
Definition: vtkBoxWidget.h:194
vtkPolyDataMapper * OutlineMapper
Definition: vtkBoxWidget.h:276
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:59
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:83
vtkProperty * FaceProperty
Definition: vtkBoxWidget.h:316
vtkPolyData * OutlinePolyData
Definition: vtkBoxWidget.h:277
vtkTransform * Transform
Definition: vtkBoxWidget.h:310
vtkCellPicker * HexPicker
Definition: vtkBoxWidget.h:281
vtkPolyData * HexFacePolyData
Definition: vtkBoxWidget.h:261
virtual void RegisterPickers()
vtkPoints * Points
Definition: vtkBoxWidget.h:255
#define VTKINTERACTIONWIDGETS_EXPORT
create a polygonal sphere centered at the origin
vtkProperty * SelectedFaceProperty
Definition: vtkBoxWidget.h:317
a simple class to control print indentation
Definition: vtkIndent.h:38
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
Definition: vtkBoxWidget.h:115
vtkProperty * OutlineProperty
Definition: vtkBoxWidget.h:318
vtkCellPicker * HandlePicker
Definition: vtkBoxWidget.h:280
vtkActor * HexOutline
Definition: vtkBoxWidget.h:275
map vtkPolyData to graphics primitives
vtkPolyData * HexPolyData
Definition: vtkBoxWidget.h:254
void OutlineCursorWiresOn()
Definition: vtkBoxWidget.h:203
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:68
orthogonal hexahedron 3D widget
Definition: vtkBoxWidget.h:100
int OutlineFaceWires
Definition: vtkBoxWidget.h:324
void OutlineCursorWiresOff()
Definition: vtkBoxWidget.h:204
int OutlineCursorWires
Definition: vtkBoxWidget.h:325
static vtkObject * New()
void OutlineFaceWiresOn()
Definition: vtkBoxWidget.h:193
void PrintSelf(ostream &os, vtkIndent indent)
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:69
virtual void SizeHandles()
Definition: vtk3DWidget.h:145
virtual void PlaceWidget()
represent and manipulate 3D points
Definition: vtkPoints.h:38
vtkSphereSource ** HandleGeometry
Definition: vtkBoxWidget.h:266
vtkProperty * SelectedHandleProperty
Definition: vtkBoxWidget.h:315