VTK  9.3.0
vtkLineWidget.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
58#ifndef vtkLineWidget_h
59#define vtkLineWidget_h
60
61#include "vtk3DWidget.h"
62#include "vtkInteractionWidgetsModule.h" // For export macro
63#include "vtkLineSource.h" // For passing calls to it
64
65VTK_ABI_NAMESPACE_BEGIN
66class vtkActor;
68class vtkPoints;
69class vtkPolyData;
70class vtkProp;
71class vtkProperty;
72class vtkSphereSource;
73class vtkCellPicker;
74class vtkPointWidget;
75class vtkPWCallback;
76class vtkPW1Callback;
77class vtkPW2Callback;
78
79class VTKINTERACTIONWIDGETS_EXPORT vtkLineWidget : public vtk3DWidget
80{
81public:
85 static vtkLineWidget* New();
86
87 vtkTypeMacro(vtkLineWidget, vtk3DWidget);
88 void PrintSelf(ostream& os, vtkIndent indent) override;
89
91
94 void SetEnabled(int) override;
95 void PlaceWidget(double bounds[6]) override;
96 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
98 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
99 {
100 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
101 }
103
107 void SetResolution(int r) { this->LineSource->SetResolution(r); }
108 int GetResolution() { return this->LineSource->GetResolution(); }
109
113 void SetPoint1(double x, double y, double z);
114 void SetPoint1(double x[3]) { this->SetPoint1(x[0], x[1], x[2]); }
115 double* GetPoint1() VTK_SIZEHINT(3) { return this->LineSource->GetPoint1(); }
116 void GetPoint1(double xyz[3]) { this->LineSource->GetPoint1(xyz); }
117
121 void SetPoint2(double x, double y, double z);
122 void SetPoint2(double x[3]) { this->SetPoint2(x[0], x[1], x[2]); }
123 double* GetPoint2() VTK_SIZEHINT(3) { return this->LineSource->GetPoint2(); }
124 void GetPoint2(double xyz[3]) { this->LineSource->GetPoint2(xyz); }
125
127
133 vtkSetClampMacro(Align, int, XAxis, None);
134 vtkGetMacro(Align, int);
135 void SetAlignToXAxis() { this->SetAlign(XAxis); }
136 void SetAlignToYAxis() { this->SetAlign(YAxis); }
137 void SetAlignToZAxis() { this->SetAlign(ZAxis); }
138 void SetAlignToNone() { this->SetAlign(None); }
140
142
148 vtkSetMacro(ClampToBounds, vtkTypeBool);
149 vtkGetMacro(ClampToBounds, vtkTypeBool);
150 vtkBooleanMacro(ClampToBounds, vtkTypeBool);
152
161
163
168 vtkGetObjectMacro(HandleProperty, vtkProperty);
169 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
171
173
177 vtkGetObjectMacro(LineProperty, vtkProperty);
178 vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
180
181protected:
183 ~vtkLineWidget() override;
184
185 // Manage the state of the widget
186 friend class vtkPWCallback;
187
188 int State;
190 {
191 Start = 0,
195 Outside
196 };
197
198 // handles the events
199 static void ProcessEvents(
200 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
201
202 // ProcessEvents() dispatches to these methods.
209 virtual void OnMouseMove();
210
211 // controlling ivars
212 int Align;
213
215 {
219 None
220 };
221
222 // the line
226 void HighlightLine(int highlight);
227
228 // glyphs representing hot spots (e.g., handles)
232
234 void SizeHandles() override;
235 void HandlesOn(double length);
237 int HighlightHandle(vtkProp* prop); // returns cell id
238 void HighlightHandles(int highlight);
239
240 // Do the picking
244 double LastPosition[3];
245 void SetLinePosition(double x[3]);
246
247 // Register internal Pickers within PickingManager
248 void RegisterPickers() override;
249
250 // Methods to manipulate the hexahedron.
251 void Scale(double* p1, double* p2, int X, int Y);
252
253 // Initial bounds
255 void ClampPosition(double x[3]);
256 int InBounds(double x[3]);
257
258 // Properties used to control the appearance of selected objects and
259 // the manipulator in general.
265
267
268 // Methods for managing the point widgets used to control the endpoints
272 vtkPWCallback* PWCallback;
273 vtkPW1Callback* PW1Callback;
274 vtkPW2Callback* PW2Callback;
278 int ForwardEvent(unsigned long event);
279
280private:
281 vtkLineWidget(const vtkLineWidget&) = delete;
282 void operator=(const vtkLineWidget&) = delete;
283};
284
285VTK_ABI_NAMESPACE_END
286#endif
an abstract superclass for 3D widgets
Definition vtk3DWidget.h:57
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:41
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
3D widget for manipulating a line
vtkProperty * SelectedLineProperty
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
void SetPoint2(double x[3])
vtkCellPicker * HandlePicker
vtkPointWidget * CurrentPointWidget
~vtkLineWidget() override
vtkActor * CurrentHandle
vtkPointWidget * PointWidget
void GetPoint1(double xyz[3])
void OnRightButtonDown()
void SetPoint1(double x, double y, double z)
Set/Get the position of first end point.
void PlaceWidget() override
Methods that satisfy the superclass' API.
vtkPointWidget * PointWidget2
void Scale(double *p1, double *p2, int X, int Y)
void HandlesOff()
void SizeHandles() override
void ClampPosition(double x[3])
vtkPW1Callback * PW1Callback
vtkTypeBool ClampToBounds
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
Methods that satisfy the superclass' API.
vtkProperty * SelectedHandleProperty
void OnLeftButtonUp()
vtkSphereSource ** HandleGeometry
vtkProperty * LineProperty
int InBounds(double x[3])
void CreateDefaultProperties()
void SetEnabled(int) override
Methods that satisfy the superclass' API.
void EnablePointWidget()
vtkPointWidget * PointWidget1
void SetAlignToYAxis()
Force the line widget to be aligned with one of the x-y-z axes.
int ForwardEvent(unsigned long event)
void HandlesOn(double length)
vtkActor * LineActor
void GetPoint2(double xyz[3])
vtkPWCallback * PWCallback
void SetAlignToZAxis()
Force the line widget to be aligned with one of the x-y-z axes.
vtkPolyDataMapper * LineMapper
void SetLinePosition(double x[3])
void SetAlignToNone()
Force the line widget to be aligned with one of the x-y-z axes.
vtkPolyDataMapper ** HandleMapper
void OnMiddleButtonUp()
double * GetPoint1()
void HighlightHandles(int highlight)
void OnRightButtonUp()
void SetAlignToXAxis()
Force the line widget to be aligned with one of the x-y-z axes.
vtkProperty * HandleProperty
double * GetPoint2()
void GenerateLine()
int HighlightHandle(vtkProp *prop)
void OnLeftButtonDown()
void BuildRepresentation()
void SetPoint2(double x, double y, double z)
Set position of other end point.
void DisablePointWidget()
void HighlightLine(int highlight)
void PlaceWidget(double bounds[6]) override
Methods that satisfy the superclass' API.
vtkLineSource * LineSource
vtkPW2Callback * PW2Callback
vtkActor ** Handle
void OnMiddleButtonDown()
vtkCellPicker * LinePicker
virtual void OnMouseMove()
void GetPolyData(vtkPolyData *pd)
Grab the polydata (including points) that defines the line.
void SetResolution(int r)
Set/Get the resolution (number of subdivisions) of the line.
void SetPoint1(double x[3])
static vtkLineWidget * New()
Instantiate the object.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
abstract base class for most VTK objects
Definition vtkObject.h:49
position a point in 3D space
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
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_SIZEHINT(...)