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