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 "vtkInteractionWidgetsModule.h" // For export macro
93 #include "vtk3DWidget.h"
94 
95 class vtkActor;
96 class vtkCellPicker;
97 class vtkLineSource;
98 class vtkPlaneSource;
99 class vtkPoints;
100 class vtkPolyData;
101 class vtkPolyDataMapper;
102 class vtkProp;
103 class vtkProperty;
104 class vtkSphereSource;
105 class vtkTransform;
106 
107 #define VTK_PROJECTION_YZ 0
108 #define VTK_PROJECTION_XZ 1
109 #define VTK_PROJECTION_XY 2
110 #define VTK_PROJECTION_OBLIQUE 3
111 
112 class VTKINTERACTIONWIDGETS_EXPORT vtkBrokenLineWidget : public vtk3DWidget
113 {
114 public:
116  static vtkBrokenLineWidget *New();
117 
119  void PrintSelf(ostream& os, vtkIndent indent);
120 
122 
123  virtual void SetEnabled(int);
124  virtual void PlaceWidget(double bounds[6]);
125  void PlaceWidget()
126  {this->Superclass::PlaceWidget();}
127  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
128  double zmin, double zmax)
129  {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
131 
133 
140  vtkSetMacro(ProjectToPlane,int);
141  vtkGetMacro(ProjectToPlane,int);
142  vtkBooleanMacro(ProjectToPlane,int);
144 
147  void SetPlaneSource(vtkPlaneSource* plane);
148 
149  vtkSetClampMacro(ProjectionNormal,int,VTK_PROJECTION_YZ,VTK_PROJECTION_OBLIQUE);
150  vtkGetMacro(ProjectionNormal,int);
151  void SetProjectionNormalToXAxes()
152  { this->SetProjectionNormal(0); }
153  void SetProjectionNormalToYAxes()
154  { this->SetProjectionNormal(1); }
155  void SetProjectionNormalToZAxes()
156  { this->SetProjectionNormal(2); }
157  void SetProjectionNormalToOblique()
158  { this->SetProjectionNormal(3); }
159 
161 
166  void SetProjectionPosition(double position);
167  vtkGetMacro(ProjectionPosition, double);
169 
176  void GetPolyData(vtkPolyData *pd);
177 
179 
182  virtual void SetHandleProperty(vtkProperty*);
183  vtkGetObjectMacro(HandleProperty, vtkProperty);
184  virtual void SetSelectedHandleProperty(vtkProperty*);
185  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
187 
189 
191  virtual void SetLineProperty(vtkProperty*);
192  vtkGetObjectMacro(LineProperty, vtkProperty);
193  virtual void SetSelectedLineProperty(vtkProperty*);
194  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
196 
198 
199  virtual void SetNumberOfHandles(int npts);
200  vtkGetMacro(NumberOfHandles, int);
202 
204 
206  void SetHandlePosition(int handle, double x, double y, double z);
207  void SetHandlePosition(int handle, double xyz[3]);
208  void GetHandlePosition(int handle, double xyz[3]);
209  double* GetHandlePosition(int handle);
211 
213  double GetSummedLength();
214 
217  void InitializeHandles(vtkPoints* points);
218 
220 
222  vtkSetClampMacro(ProcessEvents, int, 0, 1);
223  vtkGetMacro(ProcessEvents, int);
224  vtkBooleanMacro( ProcessEvents, int );
226 
228 
230  vtkSetClampMacro(HandleSizeFactor, double, 0., 100.);
231  vtkGetMacro(HandleSizeFactor, double);
233 
234 protected:
237 
238 //BTX - manage the state of the widget
239  int State;
241  {
242  Start=0,
248  Outside
249  };
250 //ETX
251 
252  //handles the events
253  static void ProcessEventsHandler(vtkObject* object,
254  unsigned long event,
255  void* clientdata,
256  void* calldata);
257 
258  // ProcessEventsHandler() dispatches to these methods.
259  void OnLeftButtonDown();
260  void OnLeftButtonUp();
261  void OnMiddleButtonDown();
262  void OnMiddleButtonUp();
263  void OnRightButtonDown();
264  void OnRightButtonUp();
265  void OnMouseMove();
266 
267  // Controlling vars
272 
273  // Projection capabilities
274  void ProjectPointsToPlane();
275  void ProjectPointsToOrthoPlane();
276  void ProjectPointsToObliquePlane();
277 
278  // The broken line
282  void HighlightLine(int highlight);
284  void BuildRepresentation();
285 
286  // Glyphs representing hot spots (e.g., handles)
289  void Initialize();
290  int HighlightHandle(vtkProp *prop); //returns handle index or -1 on fail
291  virtual void SizeHandles();
292  void InsertHandleOnLine(double* pos);
293  void EraseHandle(const int&);
294 
295  // Do the picking
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