VTK  9.0.1
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 =========================================================================*/
88 #ifndef vtkBrokenLineWidget_h
89 #define vtkBrokenLineWidget_h
90 
91 #include "vtk3DWidget.h"
92 #include "vtkInteractionWidgetsModule.h" // For export macro
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 
111 class VTKINTERACTIONWIDGETS_EXPORT vtkBrokenLineWidget : public vtk3DWidget
112 {
113 public:
117  static vtkBrokenLineWidget* New();
118 
120  void PrintSelf(ostream& os, vtkIndent indent) override;
121 
123 
126  void SetEnabled(int) override;
127  void PlaceWidget(double bounds[6]) override;
128  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
130  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
131  {
132  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
133  }
135 
137 
145  vtkSetMacro(ProjectToPlane, vtkTypeBool);
146  vtkGetMacro(ProjectToPlane, vtkTypeBool);
147  vtkBooleanMacro(ProjectToPlane, vtkTypeBool);
149 
154  void SetPlaneSource(vtkPlaneSource* plane);
155 
156  vtkSetClampMacro(ProjectionNormal, int, VTK_PROJECTION_YZ, VTK_PROJECTION_OBLIQUE);
157  vtkGetMacro(ProjectionNormal, int);
158  void SetProjectionNormalToXAxes() { this->SetProjectionNormal(0); }
159  void SetProjectionNormalToYAxes() { this->SetProjectionNormal(1); }
160  void SetProjectionNormalToZAxes() { this->SetProjectionNormal(2); }
161  void SetProjectionNormalToOblique() { 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, vtkTypeBool, 0, 1);
242  vtkGetMacro(ProcessEvents, vtkTypeBool);
243  vtkBooleanMacro(ProcessEvents, vtkTypeBool);
245 
247 
251  vtkSetClampMacro(HandleSizeFactor, double, 0., 100.);
252  vtkGetMacro(HandleSizeFactor, double);
254 
255 protected:
257  ~vtkBrokenLineWidget() override;
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(
274  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
275 
276  // ProcessEventsHandler() dispatches to these methods.
277  void OnLeftButtonDown();
278  void OnLeftButtonUp();
279  void OnMiddleButtonDown();
280  void OnMiddleButtonUp();
281  void OnRightButtonDown();
282  void OnRightButtonUp();
283  void OnMouseMove();
284 
285  // Controlling vars
290 
291  // Projection capabilities
292  void ProjectPointsToPlane();
293  void ProjectPointsToOrthoPlane();
294  void ProjectPointsToObliquePlane();
295 
296  // The broken line
300  void HighlightLine(int highlight);
302  void BuildRepresentation();
303 
304  // Glyphs representing hot spots (e.g., handles)
307  void Initialize();
308  int HighlightHandle(vtkProp* prop); // returns handle index or -1 on fail
309  void SizeHandles() override;
310  void InsertHandleOnLine(double* pos);
311  void EraseHandle(const int&);
312 
313  // Do the picking
318 
319  // Register internal Pickers within PickingManager
320  void RegisterPickers() override;
321 
322  // Methods to manipulate the broken line.
323  void MovePoint(double* p1, double* p2);
324  void Scale(double* p1, double* p2, int X, int Y);
325  void Translate(double* p1, double* p2);
326  void Spin(double* p1, double* p2, double* vpn);
327 
328  // Transform the control points (used for spinning)
330 
331  // Properties used to control the appearance of selected objects and
332  // the manipulator in general.
337  void CreateDefaultProperties();
338 
339  // For efficient spinning
340  double Centroid[3];
341  void CalculateCentroid();
343 
344  // Handle sizing factor
346 
347 private:
348  vtkBrokenLineWidget(const vtkBrokenLineWidget&) = delete;
349  void operator=(const vtkBrokenLineWidget&) = delete;
350 };
351 
352 #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:111
vtkBrokenLineWidget::ProjectToPlane
vtkTypeBool ProjectToPlane
Definition: vtkBrokenLineWidget.h:288
VTK_PROJECTION_OBLIQUE
#define VTK_PROJECTION_OBLIQUE
Definition: vtkBrokenLineWidget.h:109
vtkBrokenLineWidget::NumberOfHandles
int NumberOfHandles
Definition: vtkBrokenLineWidget.h:301
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:297
VTK_PROJECTION_YZ
#define VTK_PROJECTION_YZ
Definition: vtkBrokenLineWidget.h:106
vtkBrokenLineWidget::State
int State
Definition: vtkBrokenLineWidget.h:260
vtkBrokenLineWidget::HandleProperty
vtkProperty * HandleProperty
Definition: vtkBrokenLineWidget.h:333
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtkBrokenLineWidget::Transform
vtkTransform * Transform
Definition: vtkBrokenLineWidget.h:329
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:345
vtkBrokenLineWidget::SelectedLineProperty
vtkProperty * SelectedLineProperty
Definition: vtkBrokenLineWidget.h:336
vtkX3D::position
@ position
Definition: vtkX3D.h:267
vtkX3D::points
@ points
Definition: vtkX3D.h:452
vtkBrokenLineWidget::HandlePicker
vtkCellPicker * HandlePicker
Definition: vtkBrokenLineWidget.h:314
vtkBrokenLineWidget::LineProperty
vtkProperty * LineProperty
Definition: vtkBrokenLineWidget.h:335
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:79
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkBrokenLineWidget::LinePicker
vtkCellPicker * LinePicker
Definition: vtkBrokenLineWidget.h:315
vtkBrokenLineWidget::LineSource
vtkLineSource * LineSource
Definition: vtkBrokenLineWidget.h:299
vtkBrokenLineWidget::SelectedHandleProperty
vtkProperty * SelectedHandleProperty
Definition: vtkBrokenLineWidget.h:334
vtk3DWidget
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:70
vtkBrokenLineWidget::Spinning
@ Spinning
Definition: vtkBrokenLineWidget.h:266
vtkBrokenLineWidget::LineMapper
vtkPolyDataMapper * LineMapper
Definition: vtkBrokenLineWidget.h:298
vtkBrokenLineWidget::SetProjectionNormalToOblique
void SetProjectionNormalToOblique()
Definition: vtkBrokenLineWidget.h:161
vtkLineSource
create a line defined by two end points
Definition: vtkLineSource.h:60
vtkBrokenLineWidget::SetProjectionNormalToXAxes
void SetProjectionNormalToXAxes()
Definition: vtkBrokenLineWidget.h:158
vtkBrokenLineWidget::CurrentHandle
vtkActor * CurrentHandle
Definition: vtkBrokenLineWidget.h:316
vtkBrokenLineWidget::Inserting
@ Inserting
Definition: vtkBrokenLineWidget.h:267
vtkInteractorObserver::RegisterPickers
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
vtkProp
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:53
vtkBrokenLineWidget::Moving
@ Moving
Definition: vtkBrokenLineWidget.h:264
vtkBrokenLineWidget::ProjectionNormal
int ProjectionNormal
Definition: vtkBrokenLineWidget.h:286
vtk3DWidget::SizeHandles
virtual void SizeHandles()
Definition: vtk3DWidget.h:155
vtkBrokenLineWidget::PlaceWidget
void PlaceWidget() override
Definition: vtkBrokenLineWidget.h:128
vtk3DWidget::PlaceWidget
virtual void PlaceWidget()
vtkBrokenLineWidget::Scaling
@ Scaling
Definition: vtkBrokenLineWidget.h:265
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
vtkBrokenLineWidget::SetProjectionNormalToZAxes
void SetProjectionNormalToZAxes()
Definition: vtkBrokenLineWidget.h:160
vtkBrokenLineWidget::Handle
vtkActor ** Handle
Definition: vtkBrokenLineWidget.h:305
vtk3DWidget.h
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:61
vtkBrokenLineWidget::ProcessEvents
vtkTypeBool ProcessEvents
Definition: vtkBrokenLineWidget.h:342
vtkBrokenLineWidget::PlaneSource
vtkPlaneSource * PlaneSource
Definition: vtkBrokenLineWidget.h:289
vtkCellPicker
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:66
vtkBrokenLineWidget::PlaceWidget
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
Definition: vtkBrokenLineWidget.h:129
vtkBrokenLineWidget::Erasing
@ Erasing
Definition: vtkBrokenLineWidget.h:268
vtkBrokenLineWidget::HandleGeometry
vtkSphereSource ** HandleGeometry
Definition: vtkBrokenLineWidget.h:306
vtkBrokenLineWidget::WidgetState
WidgetState
Definition: vtkBrokenLineWidget.h:261
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkBrokenLineWidget::ProjectionPosition
double ProjectionPosition
Definition: vtkBrokenLineWidget.h:287
vtkBrokenLineWidget::SetProjectionNormalToYAxes
void SetProjectionNormalToYAxes()
Definition: vtkBrokenLineWidget.h:159
vtkBrokenLineWidget::CurrentHandleIndex
int CurrentHandleIndex
Definition: vtkBrokenLineWidget.h:317