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 =========================================================================*/
85 #ifndef vtkBrokenLineWidget_h
86 #define vtkBrokenLineWidget_h
87 
88 #include "vtkInteractionWidgetsModule.h" // For export macro
89 #include "vtk3DWidget.h"
90 
91 class vtkActor;
92 class vtkCellPicker;
93 class vtkLineSource;
94 class vtkPlaneSource;
95 class vtkPoints;
96 class vtkPolyData;
97 class vtkPolyDataMapper;
98 class vtkProp;
99 class vtkProperty;
100 class vtkSphereSource;
101 class vtkTransform;
102 
103 #define VTK_PROJECTION_YZ 0
104 #define VTK_PROJECTION_XZ 1
105 #define VTK_PROJECTION_XY 2
106 #define VTK_PROJECTION_OBLIQUE 3
107 
108 class VTKINTERACTIONWIDGETS_EXPORT vtkBrokenLineWidget : public vtk3DWidget
109 {
110 public:
114  static vtkBrokenLineWidget *New();
115 
117  void PrintSelf(ostream& os, vtkIndent indent);
118 
120 
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 
141  vtkSetMacro(ProjectToPlane,int);
142  vtkGetMacro(ProjectToPlane,int);
143  vtkBooleanMacro(ProjectToPlane,int);
145 
150  void SetPlaneSource(vtkPlaneSource* plane);
151 
152  vtkSetClampMacro(ProjectionNormal,int,VTK_PROJECTION_YZ,VTK_PROJECTION_OBLIQUE);
153  vtkGetMacro(ProjectionNormal,int);
155  { this->SetProjectionNormal(0); }
157  { this->SetProjectionNormal(1); }
159  { this->SetProjectionNormal(2); }
161  { this->SetProjectionNormal(3); }
162 
164 
171  void SetProjectionPosition(double position);
172  vtkGetMacro(ProjectionPosition, double);
174 
182  void GetPolyData(vtkPolyData *pd);
183 
185 
189  virtual void SetHandleProperty(vtkProperty*);
190  vtkGetObjectMacro(HandleProperty, vtkProperty);
191  virtual void SetSelectedHandleProperty(vtkProperty*);
192  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
194 
196 
200  virtual void SetLineProperty(vtkProperty*);
201  vtkGetObjectMacro(LineProperty, vtkProperty);
202  virtual void SetSelectedLineProperty(vtkProperty*);
203  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
205 
207 
210  virtual void SetNumberOfHandles(int npts);
211  vtkGetMacro(NumberOfHandles, int);
213 
215 
219  void SetHandlePosition(int handle, double x, double y, double z);
220  void SetHandlePosition(int handle, double xyz[3]);
221  void GetHandlePosition(int handle, double xyz[3]);
222  double* GetHandlePosition(int handle);
224 
228  double GetSummedLength();
229 
234  void InitializeHandles(vtkPoints* points);
235 
237 
241  vtkSetClampMacro(ProcessEvents, int, 0, 1);
242  vtkGetMacro(ProcessEvents, int);
243  vtkBooleanMacro( ProcessEvents, int );
245 
247 
251  vtkSetClampMacro(HandleSizeFactor, double, 0., 100.);
252  vtkGetMacro(HandleSizeFactor, double);
254 
255 protected:
258 
259  // Manage the state of the widget
260  int State;
262  {
263  Start=0,
269  Outside
270  };
271 
272  //handles the events
273  static void ProcessEventsHandler(vtkObject* object,
274  unsigned long event,
275  void* clientdata,
276  void* calldata);
277 
278  // ProcessEventsHandler() dispatches to these methods.
279  void OnLeftButtonDown();
280  void OnLeftButtonUp();
281  void OnMiddleButtonDown();
282  void OnMiddleButtonUp();
283  void OnRightButtonDown();
284  void OnRightButtonUp();
285  void OnMouseMove();
286 
287  // Controlling vars
292 
293  // Projection capabilities
294  void ProjectPointsToPlane();
295  void ProjectPointsToOrthoPlane();
296  void ProjectPointsToObliquePlane();
297 
298  // The broken line
302  void HighlightLine(int highlight);
304  void BuildRepresentation();
305 
306  // Glyphs representing hot spots (e.g., handles)
309  void Initialize();
310  int HighlightHandle(vtkProp *prop); //returns handle index or -1 on fail
311  virtual void SizeHandles();
312  void InsertHandleOnLine(double* pos);
313  void EraseHandle(const int&);
314 
315  // Do the picking
320 
321  // Register internal Pickers within PickingManager
322  virtual void RegisterPickers();
323 
324  // Methods to manipulate the broken line.
325  void MovePoint(double *p1, double *p2);
326  void Scale(double *p1, double *p2, int X, int Y);
327  void Translate(double *p1, double *p2);
328  void Spin(double *p1, double *p2, double *vpn);
329 
330  // Transform the control points (used for spinning)
332 
333  // Properties used to control the appearance of selected objects and
334  // the manipulator in general.
339  void CreateDefaultProperties();
340 
341  // For efficient spinning
342  double Centroid[3];
343  void CalculateCentroid();
345 
346  // Handle sizing factor
348 
349 private:
350  vtkBrokenLineWidget(const vtkBrokenLineWidget&) VTK_DELETE_FUNCTION;
351  void operator=(const vtkBrokenLineWidget&) VTK_DELETE_FUNCTION;
352 };
353 
354 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:50
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
3D widget for manipulating a broken line
abstract base class for most VTK objects
Definition: vtkObject.h:59
represent surface properties of a geometric object
Definition: vtkProperty.h:64
vtkProperty * SelectedHandleProperty
vtkCellPicker * HandlePicker
vtkPolyDataMapper * LineMapper
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:60
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
vtkSphereSource ** HandleGeometry
#define VTK_PROJECTION_YZ
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
create a polygonal sphere centered at the origin
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkProperty * HandleProperty
vtkProperty * SelectedLineProperty
create an array of quadrilaterals located in a plane
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
Methods that satisfy the superclass' API.
create a line defined by two end points
Definition: vtkLineSource.h:42
map vtkPolyData to graphics primitives
vtkCellPicker * LinePicker
vtkPlaneSource * PlaneSource
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:69
vtkLineSource * LineSource
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:67
virtual void SizeHandles()
Definition: vtk3DWidget.h:152
virtual void PlaceWidget()
This method is used to initially place the widget.
represent and manipulate 3D points
Definition: vtkPoints.h:39
#define VTK_PROJECTION_OBLIQUE
void PlaceWidget()
Methods that satisfy the superclass' API.