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 =========================================================================*/
89 #ifndef __vtkBrokenLineWidget_h
90 #define __vtkBrokenLineWidget_h
91 
92 #include "vtk3DWidget.h"
93 
94 class vtkActor;
95 class vtkCellPicker;
96 class vtkLineSource;
97 class vtkPlaneSource;
98 class vtkPoints;
99 class vtkPolyData;
100 class vtkPolyDataMapper;
101 class vtkProp;
102 class vtkProperty;
103 class vtkSphereSource;
104 class vtkTransform;
105 
106 #define VTK_PROJECTION_YZ 0
107 #define VTK_PROJECTION_XZ 1
108 #define VTK_PROJECTION_XY 2
109 #define VTK_PROJECTION_OBLIQUE 3
110 
112 {
113 public:
115  static vtkBrokenLineWidget *New();
116 
118  void PrintSelf(ostream& os, vtkIndent indent);
119 
121 
122  virtual void SetEnabled(int);
123  virtual void PlaceWidget(double bounds[6]);
124  void PlaceWidget()
125  {this->Superclass::PlaceWidget();}
126  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
127  double zmin, double zmax)
128  {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
130 
132 
139  vtkSetMacro(ProjectToPlane,int);
140  vtkGetMacro(ProjectToPlane,int);
141  vtkBooleanMacro(ProjectToPlane,int);
143 
146  void SetPlaneSource(vtkPlaneSource* plane);
147 
148  vtkSetClampMacro(ProjectionNormal,int,VTK_PROJECTION_YZ,VTK_PROJECTION_OBLIQUE);
149  vtkGetMacro(ProjectionNormal,int);
150  void SetProjectionNormalToXAxes()
151  { this->SetProjectionNormal(0); }
152  void SetProjectionNormalToYAxes()
153  { this->SetProjectionNormal(1); }
154  void SetProjectionNormalToZAxes()
155  { this->SetProjectionNormal(2); }
156  void SetProjectionNormalToOblique()
157  { this->SetProjectionNormal(3); }
158 
160 
165  void SetProjectionPosition(double position);
166  vtkGetMacro(ProjectionPosition, double);
168 
175  void GetPolyData(vtkPolyData *pd);
176 
178 
181  virtual void SetHandleProperty(vtkProperty*);
182  vtkGetObjectMacro(HandleProperty, vtkProperty);
183  virtual void SetSelectedHandleProperty(vtkProperty*);
184  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
186 
188 
190  virtual void SetLineProperty(vtkProperty*);
191  vtkGetObjectMacro(LineProperty, vtkProperty);
192  virtual void SetSelectedLineProperty(vtkProperty*);
193  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
195 
197 
198  virtual void SetNumberOfHandles(int npts);
199  vtkGetMacro(NumberOfHandles, int);
201 
203 
205  void SetHandlePosition(int handle, double x, double y, double z);
206  void SetHandlePosition(int handle, double xyz[3]);
207  void GetHandlePosition(int handle, double xyz[3]);
208  double* GetHandlePosition(int handle);
210 
212  double GetSummedLength();
213 
216  void InitializeHandles(vtkPoints* points);
217 
219 
221  vtkSetClampMacro(ProcessEvents, int, 0, 1);
222  vtkGetMacro(ProcessEvents, int);
223  vtkBooleanMacro( ProcessEvents, int );
225 
227 
229  vtkSetClampMacro(HandleSizeFactor, double, 0., 100.);
230  vtkGetMacro(HandleSizeFactor, double);
232 
233 protected:
236 
237 //BTX - manage the state of the widget
238  int State;
240  {
241  Start=0,
247  Outside
248  };
249 //ETX
250 
251  //handles the events
252  static void ProcessEventsHandler(vtkObject* object,
253  unsigned long event,
254  void* clientdata,
255  void* calldata);
256 
257  // ProcessEventsHandler() dispatches to these methods.
258  void OnLeftButtonDown();
259  void OnLeftButtonUp();
260  void OnMiddleButtonDown();
261  void OnMiddleButtonUp();
262  void OnRightButtonDown();
263  void OnRightButtonUp();
264  void OnMouseMove();
265 
266  // Controlling vars
271 
272  // Projection capabilities
273  void ProjectPointsToPlane();
274  void ProjectPointsToOrthoPlane();
275  void ProjectPointsToObliquePlane();
276 
277  // The broken line
281  void HighlightLine(int highlight);
283  void BuildRepresentation();
284 
285  // Glyphs representing hot spots (e.g., handles)
288  void Initialize();
289  int HighlightHandle(vtkProp *prop); //returns handle index or -1 on fail
290  virtual void SizeHandles();
291  void InsertHandleOnLine(double* pos);
292  void EraseHandle(const int&);
293 
294  // Do the picking
299 
300  // Methods to manipulate the broken line.
301  void MovePoint(double *p1, double *p2);
302  void Scale(double *p1, double *p2, int X, int Y);
303  void Translate(double *p1, double *p2);
304  void Spin(double *p1, double *p2, double *vpn);
305 
306  // Transform the control points (used for spinning)
308 
309  // Properties used to control the appearance of selected objects and
310  // the manipulator in general.
315  void CreateDefaultProperties();
316 
317  // For efficient spinning
318  double Centroid[3];
319  void CalculateCentroid();
321 
322  // Handle sizing factor
324 
325 private:
326  vtkBrokenLineWidget(const vtkBrokenLineWidget&); //Not implemented
327  void operator=(const vtkBrokenLineWidget&); //Not implemented
328 };
329 
330 #endif