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) override;
115 
117 
120  void SetEnabled(int) override;
121  void PlaceWidget(double bounds[6]) override;
122  void PlaceWidget() override
123  {this->Superclass::PlaceWidget();}
124  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
125  double zmin, double zmax) override
126  {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
128 
130 
138  vtkSetMacro(ProjectToPlane,vtkTypeBool);
139  vtkGetMacro(ProjectToPlane,vtkTypeBool);
140  vtkBooleanMacro(ProjectToPlane,vtkTypeBool);
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, vtkTypeBool, 0, 1);
239  vtkGetMacro(ProcessEvents, vtkTypeBool);
240  vtkBooleanMacro( ProcessEvents, vtkTypeBool );
242 
244 
248  vtkSetClampMacro(HandleSizeFactor, double, 0., 100.);
249  vtkGetMacro(HandleSizeFactor, double);
251 
252 protected:
254  ~vtkBrokenLineWidget() 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() override;
309  void InsertHandleOnLine(double* pos);
310  void EraseHandle(const int&);
311 
312  // Do the picking
317 
318  // Register internal Pickers within PickingManager
319  void RegisterPickers() 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.
336  void CreateDefaultProperties();
337 
338  // For efficient spinning
339  double Centroid[3];
340  void CalculateCentroid();
342 
343  // Handle sizing factor
345 
346 private:
347  vtkBrokenLineWidget(const vtkBrokenLineWidget&) = delete;
348  void operator=(const vtkBrokenLineWidget&) = delete;
349 };
350 
351 #endif
vtkPolyDataMapper
map vtkPolyData to graphics primitives
Definition: vtkPolyDataMapper.h:36
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:33
vtkBrokenLineWidget
3D widget for manipulating a broken line
Definition: vtkBrokenLineWidget.h:105
vtkBrokenLineWidget::ProjectToPlane
vtkTypeBool ProjectToPlane
Definition: vtkBrokenLineWidget.h:287
VTK_PROJECTION_OBLIQUE
#define VTK_PROJECTION_OBLIQUE
Definition: vtkBrokenLineWidget.h:103
vtkBrokenLineWidget::NumberOfHandles
int NumberOfHandles
Definition: vtkBrokenLineWidget.h:300
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkPlaneSource
create an array of quadrilaterals located in a plane
Definition: vtkPlaneSource.h:54
vtkBrokenLineWidget::LineActor
vtkActor * LineActor
Definition: vtkBrokenLineWidget.h:296
VTK_PROJECTION_YZ
#define VTK_PROJECTION_YZ
Definition: vtkBrokenLineWidget.h:100
vtkBrokenLineWidget::State
int State
Definition: vtkBrokenLineWidget.h:257
vtkBrokenLineWidget::HandleProperty
vtkProperty * HandleProperty
Definition: vtkBrokenLineWidget.h:332
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:53
vtkBrokenLineWidget::Transform
vtkTransform * Transform
Definition: vtkBrokenLineWidget.h:328
vtk3DWidget::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:54
vtkBrokenLineWidget::HandleSizeFactor
double HandleSizeFactor
Definition: vtkBrokenLineWidget.h:344
vtkBrokenLineWidget::SelectedLineProperty
vtkProperty * SelectedLineProperty
Definition: vtkBrokenLineWidget.h:335
vtkX3D::position
Definition: vtkX3D.h:261
vtkX3D::points
Definition: vtkX3D.h:446
vtkBrokenLineWidget::HandlePicker
vtkCellPicker * HandlePicker
Definition: vtkBrokenLineWidget.h:313
vtkBrokenLineWidget::LineProperty
vtkProperty * LineProperty
Definition: vtkBrokenLineWidget.h:334
vtkSphereSource
create a polygonal sphere centered at the origin
Definition: vtkSphereSource.h:40
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
vtkInteractorObserver::SetEnabled
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
Definition: vtkInteractorObserver.h:73
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkBrokenLineWidget::LinePicker
vtkCellPicker * LinePicker
Definition: vtkBrokenLineWidget.h:314
vtkBrokenLineWidget::LineSource
vtkLineSource * LineSource
Definition: vtkBrokenLineWidget.h:298
vtkBrokenLineWidget::SelectedHandleProperty
vtkProperty * SelectedHandleProperty
Definition: vtkBrokenLineWidget.h:333
vtk3DWidget
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:67
vtkBrokenLineWidget::Spinning
Definition: vtkBrokenLineWidget.h:263
vtkBrokenLineWidget::LineMapper
vtkPolyDataMapper * LineMapper
Definition: vtkBrokenLineWidget.h:297
vtkBrokenLineWidget::SetProjectionNormalToOblique
void SetProjectionNormalToOblique()
Definition: vtkBrokenLineWidget.h:157
vtkLineSource
create a line defined by two end points
Definition: vtkLineSource.h:36
vtkBrokenLineWidget::SetProjectionNormalToXAxes
void SetProjectionNormalToXAxes()
Definition: vtkBrokenLineWidget.h:151
vtkBrokenLineWidget::CurrentHandle
vtkActor * CurrentHandle
Definition: vtkBrokenLineWidget.h:315
vtkBrokenLineWidget::Inserting
Definition: vtkBrokenLineWidget.h:264
vtkInteractorObserver::RegisterPickers
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
vtkProp
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:46
vtkBrokenLineWidget::Moving
Definition: vtkBrokenLineWidget.h:261
vtkBrokenLineWidget::ProjectionNormal
int ProjectionNormal
Definition: vtkBrokenLineWidget.h:285
vtk3DWidget::SizeHandles
virtual void SizeHandles()
Definition: vtk3DWidget.h:152
vtkBrokenLineWidget::PlaceWidget
void PlaceWidget() override
Definition: vtkBrokenLineWidget.h:122
vtk3DWidget::PlaceWidget
virtual void PlaceWidget()
vtkBrokenLineWidget::Scaling
Definition: vtkBrokenLineWidget.h:262
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
vtkBrokenLineWidget::SetProjectionNormalToZAxes
void SetProjectionNormalToZAxes()
Definition: vtkBrokenLineWidget.h:155
vtkBrokenLineWidget::Handle
vtkActor ** Handle
Definition: vtkBrokenLineWidget.h:304
vtk3DWidget.h
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:60
vtkBrokenLineWidget::ProcessEvents
vtkTypeBool ProcessEvents
Definition: vtkBrokenLineWidget.h:341
vtkBrokenLineWidget::PlaneSource
vtkPlaneSource * PlaneSource
Definition: vtkBrokenLineWidget.h:288
vtkCellPicker
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:63
vtkBrokenLineWidget::PlaceWidget
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
Definition: vtkBrokenLineWidget.h:124
vtkBrokenLineWidget::Erasing
Definition: vtkBrokenLineWidget.h:265
vtkBrokenLineWidget::HandleGeometry
vtkSphereSource ** HandleGeometry
Definition: vtkBrokenLineWidget.h:305
vtkBrokenLineWidget::WidgetState
WidgetState
Definition: vtkBrokenLineWidget.h:258
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkBrokenLineWidget::ProjectionPosition
double ProjectionPosition
Definition: vtkBrokenLineWidget.h:286
vtkBrokenLineWidget::SetProjectionNormalToYAxes
void SetProjectionNormalToYAxes()
Definition: vtkBrokenLineWidget.h:153
vtkBrokenLineWidget::CurrentHandleIndex
int CurrentHandleIndex
Definition: vtkBrokenLineWidget.h:316