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 //BTX - manage the state of the widget
237  int State;
239  {
240  Start=0,
246  Outside
247  };
248 //ETX
249 
250  //handles the events
251  static void ProcessEventsHandler(vtkObject* object,
252  unsigned long event,
253  void* clientdata,
254  void* calldata);
255 
256  // ProcessEventsHandler() dispatches to these methods.
257  void OnLeftButtonDown();
258  void OnLeftButtonUp();
259  void OnMiddleButtonDown();
260  void OnMiddleButtonUp();
261  void OnRightButtonDown();
262  void OnRightButtonUp();
263  void OnMouseMove();
264 
265  // Controlling vars
270 
271  // Projection capabilities
272  void ProjectPointsToPlane();
273  void ProjectPointsToOrthoPlane();
274  void ProjectPointsToObliquePlane();
275 
276  // The broken line
280  void HighlightLine(int highlight);
282  void BuildRepresentation();
283 
284  // Glyphs representing hot spots (e.g., handles)
287  void Initialize();
288  int HighlightHandle(vtkProp *prop); //returns handle index or -1 on fail
289  virtual void SizeHandles();
290  void InsertHandleOnLine(double* pos);
291  void EraseHandle(const int&);
292 
293  // Do the picking
298 
299  // Register internal Pickers within PickingManager
300  virtual void RegisterPickers();
301 
302  // Methods to manipulate the broken line.
303  void MovePoint(double *p1, double *p2);
304  void Scale(double *p1, double *p2, int X, int Y);
305  void Translate(double *p1, double *p2);
306  void Spin(double *p1, double *p2, double *vpn);
307 
308  // Transform the control points (used for spinning)
310 
311  // Properties used to control the appearance of selected objects and
312  // the manipulator in general.
317  void CreateDefaultProperties();
318 
319  // For efficient spinning
320  double Centroid[3];
321  void CalculateCentroid();
323 
324  // Handle sizing factor
326 
327 private:
328  vtkBrokenLineWidget(const vtkBrokenLineWidget&); //Not implemented
329  void operator=(const vtkBrokenLineWidget&); //Not implemented
330 };
331 
332 #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:83
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