VTK
vtkPlaneWidget.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkPlaneWidget.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 vtkPlaneWidget_h
84 #define vtkPlaneWidget_h
85 
86 #include "vtkInteractionWidgetsModule.h" // For export macro
88 
89 class vtkActor;
90 class vtkCellPicker;
91 class vtkConeSource;
92 class vtkLineSource;
93 class vtkPlaneSource;
94 class vtkPoints;
95 class vtkPolyData;
96 class vtkPolyDataMapper;
97 class vtkProp;
98 class vtkProperty;
99 class vtkSphereSource;
100 class vtkTransform;
101 class vtkPlane;
102 
103 #define VTK_PLANE_OFF 0
104 #define VTK_PLANE_OUTLINE 1
105 #define VTK_PLANE_WIREFRAME 2
106 #define VTK_PLANE_SURFACE 3
107 
109 {
110 public:
112  static vtkPlaneWidget *New();
113 
115  void PrintSelf(ostream& os, vtkIndent indent);
116 
118 
119  virtual void SetEnabled(int);
120  virtual void PlaceWidget(double bounds[6]);
121  void PlaceWidget()
122  {this->Superclass::PlaceWidget();}
123  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
124  double zmin, double zmax)
125  {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
127 
129 
130  void SetResolution(int r);
131  int GetResolution();
133 
135 
136  void SetOrigin(double x, double y, double z);
137  void SetOrigin(double x[3]);
138  double* GetOrigin();
139  void GetOrigin(double xyz[3]);
141 
143 
145  void SetPoint1(double x, double y, double z);
146  void SetPoint1(double x[3]);
147  double* GetPoint1();
148  void GetPoint1(double xyz[3]);
150 
152 
154  void SetPoint2(double x, double y, double z);
155  void SetPoint2(double x[3]);
156  double* GetPoint2();
157  void GetPoint2(double xyz[3]);
159 
161 
162  void SetCenter(double x, double y, double z);
163  void SetCenter(double x[3]);
164  double* GetCenter();
165  void GetCenter(double xyz[3]);
167 
169 
170  void SetNormal(double x, double y, double z);
171  void SetNormal(double x[3]);
172  double* GetNormal();
173  void GetNormal(double xyz[3]);
175 
177 
182  vtkSetClampMacro(Representation,int,VTK_PLANE_OFF,VTK_PLANE_SURFACE);
183  vtkGetMacro(Representation,int);
185  {this->SetRepresentation(VTK_PLANE_OFF);}
187  {this->SetRepresentation(VTK_PLANE_OUTLINE);}
189  {this->SetRepresentation(VTK_PLANE_WIREFRAME);}
191  {this->SetRepresentation(VTK_PLANE_SURFACE);}
193 
195 
199  vtkSetMacro(NormalToXAxis,int);
200  vtkGetMacro(NormalToXAxis,int);
201  vtkBooleanMacro(NormalToXAxis,int);
202  vtkSetMacro(NormalToYAxis,int);
203  vtkGetMacro(NormalToYAxis,int);
204  vtkBooleanMacro(NormalToYAxis,int);
205  vtkSetMacro(NormalToZAxis,int);
206  vtkGetMacro(NormalToZAxis,int);
207  vtkBooleanMacro(NormalToZAxis,int);
209 
217  void GetPolyData(vtkPolyData *pd);
218 
224  void GetPlane(vtkPlane *plane);
225 
232 
235  void UpdatePlacement(void);
236 
238 
241  vtkGetObjectMacro(HandleProperty,vtkProperty);
242  vtkGetObjectMacro(SelectedHandleProperty,vtkProperty);
244 
246 
248  virtual void SetPlaneProperty(vtkProperty*);
249  vtkGetObjectMacro(PlaneProperty,vtkProperty);
250  vtkGetObjectMacro(SelectedPlaneProperty,vtkProperty);
252 
253 protected:
254  vtkPlaneWidget();
255  ~vtkPlaneWidget();
256 
257 //BTX - manage the state of the widget
258  int State;
260  {
261  Start=0,
267  Outside
268  };
269 //ETX
270 
271  //handles the events
272  static void ProcessEvents(vtkObject* object,
273  unsigned long event,
274  void* clientdata,
275  void* calldata);
276 
277  // ProcessEvents() dispatches to these methods.
278  void OnLeftButtonDown();
279  void OnLeftButtonUp();
280  void OnMiddleButtonDown();
281  void OnMiddleButtonUp();
282  void OnRightButtonDown();
283  void OnRightButtonUp();
284  void OnMouseMove();
285 
286  // controlling ivars
291  void SelectRepresentation();
292 
293  // the plane
298  void HighlightPlane(int highlight);
299 
300  // glyphs representing hot spots (e.g., handles)
304  void PositionHandles();
305  void HandlesOn(double length);
306  void HandlesOff();
307  int HighlightHandle(vtkProp *prop); //returns cell id
308  virtual void SizeHandles();
309 
310  // the normal cone
314  void HighlightNormal(int highlight);
315 
316  // the normal line
320 
321  // the normal cone
325 
326  // the normal line
330 
331  // Do the picking
335 
336  // Register internal Pickers within PickingManager
337  virtual void RegisterPickers();
338 
339  // Methods to manipulate the hexahedron.
340  void MoveOrigin(double *p1, double *p2);
341  void MovePoint1(double *p1, double *p2);
342  void MovePoint2(double *p1, double *p2);
343  void MovePoint3(double *p1, double *p2);
344  void Rotate(int X, int Y, double *p1, double *p2, double *vpn);
345  void Spin(double *p1, double *p2);
346  void Scale(double *p1, double *p2, int X, int Y);
347  void Translate(double *p1, double *p2);
348  void Push(double *p1, double *p2);
349 
350  // Plane normal, normalized
351  double Normal[3];
352 
353  // Transform the hexahedral points (used for rotations)
355 
356  // Properties used to control the appearance of selected objects and
357  // the manipulator in general.
362  void CreateDefaultProperties();
363 
364  void GeneratePlane();
365 
368 
369 private:
370  vtkPlaneWidget(const vtkPlaneWidget&); //Not implemented
371  void operator=(const vtkPlaneWidget&); //Not implemented
372 };
373 
374 #endif
vtkProperty * HandleProperty
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:52
virtual vtkPolyDataAlgorithm * GetPolyDataAlgorithm()=0
vtkLineSource * LineSource
vtkProperty * SelectedHandleProperty
void PrintSelf(ostream &os, vtkIndent indent)
vtkPolyDataMapper * ConeMapper
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:50
abstract base class for most VTK objects
Definition: vtkObject.h:61
abstract PolyDataSource-based 3D widget
vtkPolyDataMapper * LineMapper
void SetRepresentationToWireframe()
represent surface properties of a geometric object
Definition: vtkProperty.h:63
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
vtkActor * ConeActor
vtkSphereSource ** HandleGeometry
virtual void SetEnabled(int)
vtkProperty * PlaneProperty
vtkPolyData * PlaneOutline
void SetRepresentationToOutline()
vtkActor * LineActor
generate polygonal cone
Definition: vtkConeSource.h:43
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:59
vtkActor ** Handle
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:83
vtkActor * ConeActor2
virtual void UpdatePlacement()=0
void SetRepresentationToOff()
void SetRepresentationToSurface()
vtkLineSource * LineSource2
virtual void RegisterPickers()
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
vtkConeSource * ConeSource
#define VTKINTERACTIONWIDGETS_EXPORT
create a polygonal sphere centered at the origin
Superclass for algorithms that produce only polydata as output.
vtkActor * LineActor2
a simple class to control print indentation
Definition: vtkIndent.h:38
#define VTK_PLANE_SURFACE
vtkTransform * Transform
perform various plane computations
Definition: vtkPlane.h:36
#define VTK_PLANE_WIREFRAME
vtkProperty * SelectedPlaneProperty
vtkPolyDataMapper * PlaneMapper
vtkPlaneSource * PlaneSource
create an array of quadrilaterals located in a plane
virtual void PlaceWidget()
vtkPolyDataMapper * LineMapper2
create a line defined by two end points
Definition: vtkLineSource.h:41
map vtkPolyData to graphics primitives
vtkActor * PlaneActor
#define VTK_PLANE_OUTLINE
#define VTK_PLANE_OFF
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:68
vtkCellPicker * HandlePicker
3D widget for manipulating a finite plane
static vtkObject * New()
vtkCellPicker * PlanePicker
vtkActor * CurrentHandle
virtual void SizeHandles()
Definition: vtk3DWidget.h:145
virtual void PlaceWidget()
vtkPolyDataMapper ** HandleMapper
double HandleSizeFactor
represent and manipulate 3D points
Definition: vtkPoints.h:38
vtkConeSource * ConeSource2
vtkPolyDataMapper * ConeMapper2