VTK  9.3.0
vtkBrokenLineWidget.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
73#ifndef vtkBrokenLineWidget_h
74#define vtkBrokenLineWidget_h
75
76#include "vtk3DWidget.h"
77#include "vtkInteractionWidgetsModule.h" // For export macro
78
79VTK_ABI_NAMESPACE_BEGIN
80class vtkActor;
81class vtkCellPicker;
82class vtkLineSource;
83class vtkPlaneSource;
84class vtkPoints;
85class vtkPolyData;
87class vtkProp;
88class vtkProperty;
89class vtkSphereSource;
90class vtkTransform;
91
92#define VTK_PROJECTION_YZ 0
93#define VTK_PROJECTION_XZ 1
94#define VTK_PROJECTION_XY 2
95#define VTK_PROJECTION_OBLIQUE 3
96
97class VTKINTERACTIONWIDGETS_EXPORT vtkBrokenLineWidget : public vtk3DWidget
98{
99public:
104
106 void PrintSelf(ostream& os, vtkIndent indent) override;
107
109
112 void SetEnabled(int) override;
113 void PlaceWidget(double bounds[6]) override;
114 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
116 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
117 {
118 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
119 }
121
123
131 vtkSetMacro(ProjectToPlane, vtkTypeBool);
132 vtkGetMacro(ProjectToPlane, vtkTypeBool);
133 vtkBooleanMacro(ProjectToPlane, vtkTypeBool);
135
141
142 vtkSetClampMacro(ProjectionNormal, int, VTK_PROJECTION_YZ, VTK_PROJECTION_OBLIQUE);
143 vtkGetMacro(ProjectionNormal, int);
144 void SetProjectionNormalToXAxes() { this->SetProjectionNormal(0); }
145 void SetProjectionNormalToYAxes() { this->SetProjectionNormal(1); }
146 void SetProjectionNormalToZAxes() { this->SetProjectionNormal(2); }
147 void SetProjectionNormalToOblique() { this->SetProjectionNormal(3); }
148
150
157 void SetProjectionPosition(double position);
158 vtkGetMacro(ProjectionPosition, double);
160
169
171
176 vtkGetObjectMacro(HandleProperty, vtkProperty);
178 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
180
182
187 vtkGetObjectMacro(LineProperty, vtkProperty);
189 vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
191
193
196 virtual void SetNumberOfHandles(int npts);
197 vtkGetMacro(NumberOfHandles, int);
199
201
205 void SetHandlePosition(int handle, double x, double y, double z);
206 void SetHandlePosition(int handle, double xyz[3]);
207 void GetHandlePosition(int handle, double xyz[3]);
208 double* GetHandlePosition(int handle);
210
215
221
223
227 vtkSetClampMacro(ProcessEvents, vtkTypeBool, 0, 1);
228 vtkGetMacro(ProcessEvents, vtkTypeBool);
229 vtkBooleanMacro(ProcessEvents, vtkTypeBool);
231
233
237 vtkSetClampMacro(HandleSizeFactor, double, 0., 100.);
238 vtkGetMacro(HandleSizeFactor, double);
240
241protected:
244
245 // Manage the state of the widget
246 int State;
248 {
249 Start = 0,
255 Outside
256 };
257
258 // handles the events
260 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
261
262 // ProcessEventsHandler() dispatches to these methods.
270
271 // Controlling vars
276
277 // Projection capabilities
281
282 // The broken line
286 void HighlightLine(int highlight);
289
290 // Glyphs representing hot spots (e.g., handles)
294 int HighlightHandle(vtkProp* prop); // returns handle index or -1 on fail
295 void SizeHandles() override;
296 void InsertHandleOnLine(double* pos);
297 void EraseHandle(const int&);
298
299 // Do the picking
304
305 // Register internal Pickers within PickingManager
306 void RegisterPickers() override;
307
308 // Methods to manipulate the broken line.
309 void MovePoint(double* p1, double* p2);
310 void Scale(double* p1, double* p2, int X, int Y);
311 void Translate(double* p1, double* p2);
312 void Spin(double* p1, double* p2, double* vpn);
313
314 // Transform the control points (used for spinning)
316
317 // Properties used to control the appearance of selected objects and
318 // the manipulator in general.
324
325 // For efficient spinning
326 double Centroid[3];
329
330 // Handle sizing factor
332
333private:
335 void operator=(const vtkBrokenLineWidget&) = delete;
336};
337
338VTK_ABI_NAMESPACE_END
339#endif
an abstract superclass for 3D widgets
Definition vtk3DWidget.h:57
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:41
3D widget for manipulating a broken line
double GetSummedLength()
Get the summed lengths of the individual straight line segments.
void EraseHandle(const int &)
void InsertHandleOnLine(double *pos)
int HighlightHandle(vtkProp *prop)
double * GetHandlePosition(int handle)
Set/Get the position of the broken line handles.
vtkProperty * SelectedLineProperty
static void ProcessEventsHandler(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
vtkPolyDataMapper * LineMapper
vtkSphereSource ** HandleGeometry
virtual void SetSelectedLineProperty(vtkProperty *)
Set/Get the line properties.
virtual void SetHandleProperty(vtkProperty *)
Set/Get the handle properties (the spheres are the handles).
void SetHandlePosition(int handle, double x, double y, double z)
Set/Get the position of the broken line handles.
void InitializeHandles(vtkPoints *points)
Convenience method to allocate and set the handles from a vtkPoints instance.
vtkPlaneSource * PlaneSource
void ProjectPointsToObliquePlane()
~vtkBrokenLineWidget() override
void SetPlaneSource(vtkPlaneSource *plane)
Set up a reference to a vtkPlaneSource that could be from another widget object, e....
void SetProjectionPosition(double position)
Set the position of broken line handles and points in terms of a plane's position.
void GetPolyData(vtkPolyData *pd)
Grab the polydata (including points) that defines the broken line.
void GetHandlePosition(int handle, double xyz[3])
Set/Get the position of the broken line handles.
virtual void SetSelectedHandleProperty(vtkProperty *)
Set/Get the handle properties (the spheres are the handles).
void Spin(double *p1, double *p2, double *vpn)
static vtkBrokenLineWidget * New()
Instantiate the object.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetEnabled(int) override
Methods that satisfy the superclass' API.
void Translate(double *p1, double *p2)
void CreateDefaultProperties()
void SetHandlePosition(int handle, double xyz[3])
Set/Get the position of the broken line handles.
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
void HighlightLine(int highlight)
void PlaceWidget(double bounds[6]) override
Methods that satisfy the superclass' API.
virtual void SetNumberOfHandles(int npts)
Set/Get the number of handles for this widget.
void Scale(double *p1, double *p2, int X, int Y)
void ProjectPointsToOrthoPlane()
void PlaceWidget() override
Methods that satisfy the superclass' API.
vtkCellPicker * HandlePicker
virtual void SetLineProperty(vtkProperty *)
Set/Get the line properties.
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
Methods that satisfy the superclass' API.
void MovePoint(double *p1, double *p2)
void SizeHandles() override
vtkProperty * SelectedHandleProperty
ray-cast cell picker for all kinds of Prop3Ds
a simple class to control print indentation
Definition vtkIndent.h:29
create a line defined by two end points
abstract base class for most VTK objects
Definition vtkObject.h:49
create an array of quadrilaterals located in a plane
represent and manipulate 3D points
Definition vtkPoints.h:29
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:80
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:43
represent surface properties of a geometric object
Definition vtkProperty.h:57
create a polygonal sphere centered at the origin
describes linear transformations via a 4x4 matrix
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_PROJECTION_YZ
#define VTK_PROJECTION_OBLIQUE