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 =========================================================================*/
82 #ifndef vtkBrokenLineWidget_h
83 #define vtkBrokenLineWidget_h
84 
85 #include "vtk3DWidget.h"
86 #include "vtkInteractionWidgetsModule.h" // For export macro
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:
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 { this->Superclass::PlaceWidget(); }
124  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
125  {
126  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
127  }
129 
131 
139  vtkSetMacro(ProjectToPlane, vtkTypeBool);
140  vtkGetMacro(ProjectToPlane, vtkTypeBool);
141  vtkBooleanMacro(ProjectToPlane, vtkTypeBool);
143 
149 
150  vtkSetClampMacro(ProjectionNormal, int, VTK_PROJECTION_YZ, VTK_PROJECTION_OBLIQUE);
151  vtkGetMacro(ProjectionNormal, int);
152  void SetProjectionNormalToXAxes() { this->SetProjectionNormal(0); }
153  void SetProjectionNormalToYAxes() { this->SetProjectionNormal(1); }
154  void SetProjectionNormalToZAxes() { this->SetProjectionNormal(2); }
155  void SetProjectionNormalToOblique() { this->SetProjectionNormal(3); }
156 
158 
166  vtkGetMacro(ProjectionPosition, double);
168 
177 
179 
184  vtkGetObjectMacro(HandleProperty, vtkProperty);
186  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
188 
190 
194  virtual void SetLineProperty(vtkProperty*);
195  vtkGetObjectMacro(LineProperty, vtkProperty);
197  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
199 
201 
204  virtual void SetNumberOfHandles(int npts);
205  vtkGetMacro(NumberOfHandles, int);
207 
209 
213  void SetHandlePosition(int handle, double x, double y, double z);
214  void SetHandlePosition(int handle, double xyz[3]);
215  void GetHandlePosition(int handle, double xyz[3]);
216  double* GetHandlePosition(int handle);
218 
222  double GetSummedLength();
223 
229 
231 
235  vtkSetClampMacro(ProcessEvents, vtkTypeBool, 0, 1);
236  vtkGetMacro(ProcessEvents, vtkTypeBool);
237  vtkBooleanMacro(ProcessEvents, vtkTypeBool);
239 
241 
245  vtkSetClampMacro(HandleSizeFactor, double, 0., 100.);
246  vtkGetMacro(HandleSizeFactor, double);
248 
249 protected:
252 
253  // Manage the state of the widget
254  int State;
256  {
257  Start = 0,
263  Outside
264  };
265 
266  // handles the events
267  static void ProcessEventsHandler(
268  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
269 
270  // ProcessEventsHandler() dispatches to these methods.
277  void OnMouseMove();
278 
279  // Controlling vars
284 
285  // Projection capabilities
289 
290  // The broken line
294  void HighlightLine(int highlight);
297 
298  // Glyphs representing hot spots (e.g., handles)
301  void Initialize();
302  int HighlightHandle(vtkProp* prop); // returns handle index or -1 on fail
303  void SizeHandles() override;
304  void InsertHandleOnLine(double* pos);
305  void EraseHandle(const int&);
306 
307  // Do the picking
312 
313  // Register internal Pickers within PickingManager
314  void RegisterPickers() override;
315 
316  // Methods to manipulate the broken line.
317  void MovePoint(double* p1, double* p2);
318  void Scale(double* p1, double* p2, int X, int Y);
319  void Translate(double* p1, double* p2);
320  void Spin(double* p1, double* p2, double* vpn);
321 
322  // Transform the control points (used for spinning)
324 
325  // Properties used to control the appearance of selected objects and
326  // the manipulator in general.
332 
333  // For efficient spinning
334  double Centroid[3];
337 
338  // Handle sizing factor
340 
341 private:
342  vtkBrokenLineWidget(const vtkBrokenLineWidget&) = delete;
343  void operator=(const vtkBrokenLineWidget&) = delete;
344 };
345 
346 #endif
vtkPolyDataMapper
map vtkPolyData to graphics primitives
Definition: vtkPolyDataMapper.h:37
vtkPoints
represent and manipulate 3D points
Definition: vtkPoints.h:34
vtkBrokenLineWidget::GetHandlePosition
void GetHandlePosition(int handle, double xyz[3])
vtkBrokenLineWidget::OnMouseMove
void OnMouseMove()
vtkBrokenLineWidget
3D widget for manipulating a broken line
Definition: vtkBrokenLineWidget.h:106
vtkBrokenLineWidget::GetHandlePosition
double * GetHandlePosition(int handle)
vtkBrokenLineWidget::ProcessEventsHandler
static void ProcessEventsHandler(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
vtkBrokenLineWidget::ProjectPointsToOrthoPlane
void ProjectPointsToOrthoPlane()
vtkBrokenLineWidget::Scale
void Scale(double *p1, double *p2, int X, int Y)
vtkBrokenLineWidget::ProjectToPlane
vtkTypeBool ProjectToPlane
Definition: vtkBrokenLineWidget.h:282
vtkBrokenLineWidget::SetEnabled
void SetEnabled(int) override
Methods that satisfy the superclass' API.
VTK_PROJECTION_OBLIQUE
#define VTK_PROJECTION_OBLIQUE
Definition: vtkBrokenLineWidget.h:103
vtkBrokenLineWidget::New
static vtkBrokenLineWidget * New()
Instantiate the object.
vtkBrokenLineWidget::NumberOfHandles
int NumberOfHandles
Definition: vtkBrokenLineWidget.h:295
vtkBrokenLineWidget::SizeHandles
void SizeHandles() override
vtkBrokenLineWidget::GetPolyData
void GetPolyData(vtkPolyData *pd)
Grab the polydata (including points) that defines the broken line.
vtkPlaneSource
create an array of quadrilaterals located in a plane
Definition: vtkPlaneSource.h:55
vtkBrokenLineWidget::LineActor
vtkActor * LineActor
Definition: vtkBrokenLineWidget.h:291
vtkBrokenLineWidget::~vtkBrokenLineWidget
~vtkBrokenLineWidget() override
VTK_PROJECTION_YZ
#define VTK_PROJECTION_YZ
Definition: vtkBrokenLineWidget.h:100
vtkBrokenLineWidget::State
int State
Definition: vtkBrokenLineWidget.h:254
vtkBrokenLineWidget::RegisterPickers
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
vtkBrokenLineWidget::HandleProperty
vtkProperty * HandleProperty
Definition: vtkBrokenLineWidget.h:327
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:54
vtkBrokenLineWidget::Transform
vtkTransform * Transform
Definition: vtkBrokenLineWidget.h:323
vtkBrokenLineWidget::SetHandlePosition
void SetHandlePosition(int handle, double x, double y, double z)
Set/Get the position of the broken line handles.
vtkBrokenLineWidget::OnMiddleButtonDown
void OnMiddleButtonDown()
vtkBrokenLineWidget::SetHandlePosition
void SetHandlePosition(int handle, double xyz[3])
vtkBrokenLineWidget::CreateDefaultProperties
void CreateDefaultProperties()
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:55
vtkBrokenLineWidget::Initialize
void Initialize()
vtkBrokenLineWidget::ProjectPointsToObliquePlane
void ProjectPointsToObliquePlane()
vtkBrokenLineWidget::PlaceWidget
void PlaceWidget(double bounds[6]) override
This method is used to initially place the widget.
vtkBrokenLineWidget::Translate
void Translate(double *p1, double *p2)
vtkBrokenLineWidget::HandleSizeFactor
double HandleSizeFactor
Definition: vtkBrokenLineWidget.h:339
vtkBrokenLineWidget::OnMiddleButtonUp
void OnMiddleButtonUp()
vtkBrokenLineWidget::SetNumberOfHandles
virtual void SetNumberOfHandles(int npts)
Set/Get the number of handles for this widget.
vtkBrokenLineWidget::SelectedLineProperty
vtkProperty * SelectedLineProperty
Definition: vtkBrokenLineWidget.h:330
vtkX3D::position
@ position
Definition: vtkX3D.h:267
vtkX3D::points
@ points
Definition: vtkX3D.h:452
vtkBrokenLineWidget::HandlePicker
vtkCellPicker * HandlePicker
Definition: vtkBrokenLineWidget.h:308
vtkBrokenLineWidget::LineProperty
vtkProperty * LineProperty
Definition: vtkBrokenLineWidget.h:329
vtkBrokenLineWidget::SetProjectionPosition
void SetProjectionPosition(double position)
Set the position of broken line handles and points in terms of a plane's position.
vtkSphereSource
create a polygonal sphere centered at the origin
Definition: vtkSphereSource.h:41
vtkBrokenLineWidget::SetSelectedHandleProperty
virtual void SetSelectedHandleProperty(vtkProperty *)
vtkBrokenLineWidget::ProjectPointsToPlane
void ProjectPointsToPlane()
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:46
vtkBrokenLineWidget::SetLineProperty
virtual void SetLineProperty(vtkProperty *)
Set/Get the line properties.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:34
vtkBrokenLineWidget::LinePicker
vtkCellPicker * LinePicker
Definition: vtkBrokenLineWidget.h:309
vtkBrokenLineWidget::LineSource
vtkLineSource * LineSource
Definition: vtkBrokenLineWidget.h:293
vtkBrokenLineWidget::SelectedHandleProperty
vtkProperty * SelectedHandleProperty
Definition: vtkBrokenLineWidget.h:328
vtkBrokenLineWidget::SetHandleProperty
virtual void SetHandleProperty(vtkProperty *)
Set/Get the handle properties (the spheres are the handles).
vtkBrokenLineWidget::HighlightLine
void HighlightLine(int highlight)
vtkBrokenLineWidget::Spin
void Spin(double *p1, double *p2, double *vpn)
vtk3DWidget
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:68
vtkBrokenLineWidget::Spinning
@ Spinning
Definition: vtkBrokenLineWidget.h:260
vtkBrokenLineWidget::CalculateCentroid
void CalculateCentroid()
vtkBrokenLineWidget::LineMapper
vtkPolyDataMapper * LineMapper
Definition: vtkBrokenLineWidget.h:292
vtkBrokenLineWidget::OnRightButtonUp
void OnRightButtonUp()
vtkBrokenLineWidget::SetProjectionNormalToOblique
void SetProjectionNormalToOblique()
Definition: vtkBrokenLineWidget.h:155
vtkLineSource
create a line defined by two end points
Definition: vtkLineSource.h:61
vtkBrokenLineWidget::SetProjectionNormalToXAxes
void SetProjectionNormalToXAxes()
Definition: vtkBrokenLineWidget.h:152
vtkBrokenLineWidget::InsertHandleOnLine
void InsertHandleOnLine(double *pos)
vtkBrokenLineWidget::CurrentHandle
vtkActor * CurrentHandle
Definition: vtkBrokenLineWidget.h:310
vtkBrokenLineWidget::Inserting
@ Inserting
Definition: vtkBrokenLineWidget.h:261
vtkBrokenLineWidget::EraseHandle
void EraseHandle(const int &)
vtkBrokenLineWidget::SetSelectedLineProperty
virtual void SetSelectedLineProperty(vtkProperty *)
vtkProp
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:48
vtkBrokenLineWidget::OnRightButtonDown
void OnRightButtonDown()
vtkBrokenLineWidget::OnLeftButtonUp
void OnLeftButtonUp()
vtkBrokenLineWidget::Moving
@ Moving
Definition: vtkBrokenLineWidget.h:258
vtkBrokenLineWidget::ProjectionNormal
int ProjectionNormal
Definition: vtkBrokenLineWidget.h:280
vtkBrokenLineWidget::PlaceWidget
void PlaceWidget() override
Definition: vtkBrokenLineWidget.h:122
vtkBrokenLineWidget::Scaling
@ Scaling
Definition: vtkBrokenLineWidget.h:259
vtkBrokenLineWidget::BuildRepresentation
void BuildRepresentation()
vtkBrokenLineWidget::MovePoint
void MovePoint(double *p1, double *p2)
vtkBrokenLineWidget::InitializeHandles
void InitializeHandles(vtkPoints *points)
Convenience method to allocate and set the handles from a vtkPoints instance.
vtkPolyData
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
vtkBrokenLineWidget::SetProjectionNormalToZAxes
void SetProjectionNormalToZAxes()
Definition: vtkBrokenLineWidget.h:154
vtkBrokenLineWidget::Handle
vtkActor ** Handle
Definition: vtkBrokenLineWidget.h:299
vtk3DWidget.h
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:62
vtkBrokenLineWidget::SetPlaneSource
void SetPlaneSource(vtkPlaneSource *plane)
Set up a reference to a vtkPlaneSource that could be from another widget object, e....
vtkBrokenLineWidget::ProcessEvents
vtkTypeBool ProcessEvents
Definition: vtkBrokenLineWidget.h:336
vtkBrokenLineWidget::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkBrokenLineWidget::HighlightHandle
int HighlightHandle(vtkProp *prop)
vtkBrokenLineWidget::PlaneSource
vtkPlaneSource * PlaneSource
Definition: vtkBrokenLineWidget.h:283
vtkBrokenLineWidget::GetSummedLength
double GetSummedLength()
Get the summed lengths of the individual straight line segments.
vtkBrokenLineWidget::OnLeftButtonDown
void OnLeftButtonDown()
vtkCellPicker
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:67
vtkBrokenLineWidget::PlaceWidget
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
Definition: vtkBrokenLineWidget.h:123
vtkBrokenLineWidget::Erasing
@ Erasing
Definition: vtkBrokenLineWidget.h:262
vtkBrokenLineWidget::HandleGeometry
vtkSphereSource ** HandleGeometry
Definition: vtkBrokenLineWidget.h:300
vtkBrokenLineWidget::WidgetState
WidgetState
Definition: vtkBrokenLineWidget.h:256
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkBrokenLineWidget::ProjectionPosition
double ProjectionPosition
Definition: vtkBrokenLineWidget.h:281
vtkBrokenLineWidget::vtkBrokenLineWidget
vtkBrokenLineWidget()
vtkBrokenLineWidget::SetProjectionNormalToYAxes
void SetProjectionNormalToYAxes()
Definition: vtkBrokenLineWidget.h:153
vtkBrokenLineWidget::CurrentHandleIndex
int CurrentHandleIndex
Definition: vtkBrokenLineWidget.h:311