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 =========================================================================*/
82 #ifndef vtkBrokenLineWidget_h
83 #define vtkBrokenLineWidget_h
84 
85 #include "vtkInteractionWidgetsModule.h" // For export macro
86 #include "vtk3DWidget.h"
87 
88 class vtkActor;
89 class vtkCellPicker;
90 class vtkLineSource;
91 class vtkPlaneSource;
92 class vtkPoints;
93 class vtkPolyData;
94 class vtkPolyDataMapper;
95 class vtkProp;
96 class vtkProperty;
97 class vtkSphereSource;
98 class vtkTransform;
99 
100 #define VTK_PROJECTION_YZ 0
101 #define VTK_PROJECTION_XZ 1
102 #define VTK_PROJECTION_XY 2
103 #define VTK_PROJECTION_OBLIQUE 3
104 
105 class VTKINTERACTIONWIDGETS_EXPORT vtkBrokenLineWidget : public vtk3DWidget
106 {
107 public:
111  static vtkBrokenLineWidget *New();
112 
114  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
115 
117 
120  void SetEnabled(int) VTK_OVERRIDE;
121  void PlaceWidget(double bounds[6]) VTK_OVERRIDE;
122  void PlaceWidget() VTK_OVERRIDE
123  {this->Superclass::PlaceWidget();}
124  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
125  double zmin, double zmax) VTK_OVERRIDE
126  {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
128 
130 
138  vtkSetMacro(ProjectToPlane,int);
139  vtkGetMacro(ProjectToPlane,int);
140  vtkBooleanMacro(ProjectToPlane,int);
142 
147  void SetPlaneSource(vtkPlaneSource* plane);
148 
149  vtkSetClampMacro(ProjectionNormal,int,VTK_PROJECTION_YZ,VTK_PROJECTION_OBLIQUE);
150  vtkGetMacro(ProjectionNormal,int);
152  { this->SetProjectionNormal(0); }
154  { this->SetProjectionNormal(1); }
156  { this->SetProjectionNormal(2); }
158  { this->SetProjectionNormal(3); }
159 
161 
168  void SetProjectionPosition(double position);
169  vtkGetMacro(ProjectionPosition, double);
171 
179  void GetPolyData(vtkPolyData *pd);
180 
182 
186  virtual void SetHandleProperty(vtkProperty*);
187  vtkGetObjectMacro(HandleProperty, vtkProperty);
188  virtual void SetSelectedHandleProperty(vtkProperty*);
189  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
191 
193 
197  virtual void SetLineProperty(vtkProperty*);
198  vtkGetObjectMacro(LineProperty, vtkProperty);
199  virtual void SetSelectedLineProperty(vtkProperty*);
200  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
202 
204 
207  virtual void SetNumberOfHandles(int npts);
208  vtkGetMacro(NumberOfHandles, int);
210 
212 
216  void SetHandlePosition(int handle, double x, double y, double z);
217  void SetHandlePosition(int handle, double xyz[3]);
218  void GetHandlePosition(int handle, double xyz[3]);
219  double* GetHandlePosition(int handle);
221 
225  double GetSummedLength();
226 
231  void InitializeHandles(vtkPoints* points);
232 
234 
238  vtkSetClampMacro(ProcessEvents, int, 0, 1);
239  vtkGetMacro(ProcessEvents, int);
240  vtkBooleanMacro( ProcessEvents, int );
242 
244 
248  vtkSetClampMacro(HandleSizeFactor, double, 0., 100.);
249  vtkGetMacro(HandleSizeFactor, double);
251 
252 protected:
254  ~vtkBrokenLineWidget() VTK_OVERRIDE;
255 
256  // Manage the state of the widget
257  int State;
259  {
260  Start=0,
266  Outside
267  };
268 
269  //handles the events
270  static void ProcessEventsHandler(vtkObject* object,
271  unsigned long event,
272  void* clientdata,
273  void* calldata);
274 
275  // ProcessEventsHandler() dispatches to these methods.
276  void OnLeftButtonDown();
277  void OnLeftButtonUp();
278  void OnMiddleButtonDown();
279  void OnMiddleButtonUp();
280  void OnRightButtonDown();
281  void OnRightButtonUp();
282  void OnMouseMove();
283 
284  // Controlling vars
289 
290  // Projection capabilities
291  void ProjectPointsToPlane();
292  void ProjectPointsToOrthoPlane();
293  void ProjectPointsToObliquePlane();
294 
295  // The broken line
299  void HighlightLine(int highlight);
301  void BuildRepresentation();
302 
303  // Glyphs representing hot spots (e.g., handles)
306  void Initialize();
307  int HighlightHandle(vtkProp *prop); //returns handle index or -1 on fail
308  void SizeHandles() VTK_OVERRIDE;
309  void InsertHandleOnLine(double* pos);
310  void EraseHandle(const int&);
311 
312  // Do the picking
313  vtkCellPicker *HandlePicker;
314  vtkCellPicker *LinePicker;
315  vtkActor *CurrentHandle;
316  int CurrentHandleIndex;
317 
318  // Register internal Pickers within PickingManager
319  void RegisterPickers() VTK_OVERRIDE;
320 
321  // Methods to manipulate the broken line.
322  void MovePoint(double *p1, double *p2);
323  void Scale(double *p1, double *p2, int X, int Y);
324  void Translate(double *p1, double *p2);
325  void Spin(double *p1, double *p2, double *vpn);
326 
327  // Transform the control points (used for spinning)
329 
330  // Properties used to control the appearance of selected objects and
331  // the manipulator in general.
332  vtkProperty *HandleProperty;
333  vtkProperty *SelectedHandleProperty;
334  vtkProperty *LineProperty;
335  vtkProperty *SelectedLineProperty;
336  void CreateDefaultProperties();
337 
338  // For efficient spinning
339  double Centroid[3];
340  void CalculateCentroid();
341  int ProcessEvents;
342 
343  // Handle sizing factor
344  double HandleSizeFactor;
345 
346 private:
347  vtkBrokenLineWidget(const vtkBrokenLineWidget&) VTK_DELETE_FUNCTION;
348  void operator=(const vtkBrokenLineWidget&) VTK_DELETE_FUNCTION;
349 };
350 
351 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:44
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
3D widget for manipulating a broken line
abstract base class for most VTK objects
Definition: vtkObject.h:53
represent surface properties of a geometric object
Definition: vtkProperty.h:58
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:54
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkSphereSource ** HandleGeometry
#define VTK_PROJECTION_YZ
create a polygonal sphere centered at the origin
a simple class to control print indentation
Definition: vtkIndent.h:33
void PlaceWidget() override
Methods that satisfy the superclass' API.
create an array of quadrilaterals located in a plane
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
create a line defined by two end points
Definition: vtkLineSource.h:36
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
Methods that satisfy the superclass' API.
map vtkPolyData to graphics primitives
vtkPlaneSource * PlaneSource
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:63
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...
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:33
#define VTK_PROJECTION_OBLIQUE
Transform
Definition: ADIOSDefs.h:39