VTK
vtkBrokenLineWidget.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkBrokenLineWidget.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 =========================================================================*/
87 #ifndef vtkBrokenLineWidget_h
88 #define vtkBrokenLineWidget_h
89 
90 #include "vtkInteractionWidgetsModule.h" // For export macro
91 #include "vtk3DWidget.h"
92 
93 class vtkActor;
94 class vtkCellPicker;
95 class vtkLineSource;
96 class vtkPlaneSource;
97 class vtkPoints;
98 class vtkPolyData;
99 class vtkPolyDataMapper;
100 class vtkProp;
101 class vtkProperty;
102 class vtkSphereSource;
103 class vtkTransform;
104 
105 #define VTK_PROJECTION_YZ 0
106 #define VTK_PROJECTION_XZ 1
107 #define VTK_PROJECTION_XY 2
108 #define VTK_PROJECTION_OBLIQUE 3
109 
111 {
112 public:
114  static vtkBrokenLineWidget *New();
115 
117  void PrintSelf(ostream& os, vtkIndent indent);
118 
120 
121  virtual void SetEnabled(int);
122  virtual void PlaceWidget(double bounds[6]);
123  void PlaceWidget()
124  {this->Superclass::PlaceWidget();}
125  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
126  double zmin, double zmax)
127  {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
129 
131 
138  vtkSetMacro(ProjectToPlane,int);
139  vtkGetMacro(ProjectToPlane,int);
140  vtkBooleanMacro(ProjectToPlane,int);
142 
145  void SetPlaneSource(vtkPlaneSource* plane);
146 
147  vtkSetClampMacro(ProjectionNormal,int,VTK_PROJECTION_YZ,VTK_PROJECTION_OBLIQUE);
148  vtkGetMacro(ProjectionNormal,int);
150  { this->SetProjectionNormal(0); }
152  { this->SetProjectionNormal(1); }
154  { this->SetProjectionNormal(2); }
156  { this->SetProjectionNormal(3); }
157 
159 
164  void SetProjectionPosition(double position);
165  vtkGetMacro(ProjectionPosition, double);
167 
174  void GetPolyData(vtkPolyData *pd);
175 
177 
180  virtual void SetHandleProperty(vtkProperty*);
181  vtkGetObjectMacro(HandleProperty, vtkProperty);
182  virtual void SetSelectedHandleProperty(vtkProperty*);
183  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
185 
187 
189  virtual void SetLineProperty(vtkProperty*);
190  vtkGetObjectMacro(LineProperty, vtkProperty);
191  virtual void SetSelectedLineProperty(vtkProperty*);
192  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
194 
196 
197  virtual void SetNumberOfHandles(int npts);
198  vtkGetMacro(NumberOfHandles, int);
200 
202 
204  void SetHandlePosition(int handle, double x, double y, double z);
205  void SetHandlePosition(int handle, double xyz[3]);
206  void GetHandlePosition(int handle, double xyz[3]);
207  double* GetHandlePosition(int handle);
209 
211  double GetSummedLength();
212 
215  void InitializeHandles(vtkPoints* points);
216 
218 
220  vtkSetClampMacro(ProcessEvents, int, 0, 1);
221  vtkGetMacro(ProcessEvents, int);
222  vtkBooleanMacro( ProcessEvents, int );
224 
226 
228  vtkSetClampMacro(HandleSizeFactor, double, 0., 100.);
229  vtkGetMacro(HandleSizeFactor, double);
231 
232 protected:
235 
236  // Manage the state of the widget
237  int State;
239  {
240  Start=0,
246  Outside
247  };
248 
249  //handles the events
250  static void ProcessEventsHandler(vtkObject* object,
251  unsigned long event,
252  void* clientdata,
253  void* calldata);
254 
255  // ProcessEventsHandler() dispatches to these methods.
256  void OnLeftButtonDown();
257  void OnLeftButtonUp();
258  void OnMiddleButtonDown();
259  void OnMiddleButtonUp();
260  void OnRightButtonDown();
261  void OnRightButtonUp();
262  void OnMouseMove();
263 
264  // Controlling vars
269 
270  // Projection capabilities
271  void ProjectPointsToPlane();
272  void ProjectPointsToOrthoPlane();
273  void ProjectPointsToObliquePlane();
274 
275  // The broken line
279  void HighlightLine(int highlight);
281  void BuildRepresentation();
282 
283  // Glyphs representing hot spots (e.g., handles)
286  void Initialize();
287  int HighlightHandle(vtkProp *prop); //returns handle index or -1 on fail
288  virtual void SizeHandles();
289  void InsertHandleOnLine(double* pos);
290  void EraseHandle(const int&);
291 
292  // Do the picking
297 
298  // Register internal Pickers within PickingManager
299  virtual void RegisterPickers();
300 
301  // Methods to manipulate the broken line.
302  void MovePoint(double *p1, double *p2);
303  void Scale(double *p1, double *p2, int X, int Y);
304  void Translate(double *p1, double *p2);
305  void Spin(double *p1, double *p2, double *vpn);
306 
307  // Transform the control points (used for spinning)
309 
310  // Properties used to control the appearance of selected objects and
311  // the manipulator in general.
316  void CreateDefaultProperties();
317 
318  // For efficient spinning
319  double Centroid[3];
320  void CalculateCentroid();
322 
323  // Handle sizing factor
325 
326 private:
327  vtkBrokenLineWidget(const vtkBrokenLineWidget&); //Not implemented
328  void operator=(const vtkBrokenLineWidget&); //Not implemented
329 };
330 
331 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:52
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:50
3D widget for manipulating a broken line
abstract base class for most VTK objects
Definition: vtkObject.h:61
represent surface properties of a geometric object
Definition: vtkProperty.h:63
vtkProperty * SelectedHandleProperty
vtkCellPicker * HandlePicker
vtkPolyDataMapper * LineMapper
virtual void SetEnabled(int)
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:59
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
vtkSphereSource ** HandleGeometry
#define VTK_PROJECTION_YZ
virtual void RegisterPickers()
#define VTKINTERACTIONWIDGETS_EXPORT
create a polygonal sphere centered at the origin
a simple class to control print indentation
Definition: vtkIndent.h:38
vtkProperty * HandleProperty
vtkProperty * SelectedLineProperty
create an array of quadrilaterals located in a plane
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
create a line defined by two end points
Definition: vtkLineSource.h:41
map vtkPolyData to graphics primitives
vtkCellPicker * LinePicker
vtkPlaneSource * PlaneSource
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:68
vtkLineSource * LineSource
static vtkObject * New()
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
#define VTK_PROJECTION_OBLIQUE