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
67#ifndef vtkLineWidget_h
68#define vtkLineWidget_h
69
70#include "vtk3DWidget.h"
71#include "vtkInteractionWidgetsModule.h" // For export macro
72#include "vtkLineSource.h" // For passing calls to it
73
74VTK_ABI_NAMESPACE_BEGIN
75class vtkActor;
77class vtkPoints;
78class vtkPolyData;
79class vtkProp;
80class vtkProperty;
81class vtkSphereSource;
82class vtkCellPicker;
83class vtkPointWidget;
84class vtkPWCallback;
85class vtkPW1Callback;
86class vtkPW2Callback;
87
88class VTKINTERACTIONWIDGETS_EXPORT vtkLineWidget : public vtk3DWidget
89{
90public:
94 static vtkLineWidget* New();
95
96 vtkTypeMacro(vtkLineWidget, vtk3DWidget);
97 void PrintSelf(ostream& os, vtkIndent indent) override;
98
100
103 void SetEnabled(int) override;
104 void PlaceWidget(double bounds[6]) override;
105 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
107 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
108 {
109 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
110 }
112
116 void SetResolution(int r) { this->LineSource->SetResolution(r); }
117 int GetResolution() { return this->LineSource->GetResolution(); }
118
122 void SetPoint1(double x, double y, double z);
123 void SetPoint1(double x[3]) { this->SetPoint1(x[0], x[1], x[2]); }
124 double* GetPoint1() VTK_SIZEHINT(3) { return this->LineSource->GetPoint1(); }
125 void GetPoint1(double xyz[3]) { this->LineSource->GetPoint1(xyz); }
126
130 void SetPoint2(double x, double y, double z);
131 void SetPoint2(double x[3]) { this->SetPoint2(x[0], x[1], x[2]); }
132 double* GetPoint2() VTK_SIZEHINT(3) { return this->LineSource->GetPoint2(); }
133 void GetPoint2(double xyz[3]) { this->LineSource->GetPoint2(xyz); }
134
136
142 vtkSetClampMacro(Align, int, XAxis, None);
143 vtkGetMacro(Align, int);
144 void SetAlignToXAxis() { this->SetAlign(XAxis); }
145 void SetAlignToYAxis() { this->SetAlign(YAxis); }
146 void SetAlignToZAxis() { this->SetAlign(ZAxis); }
147 void SetAlignToNone() { this->SetAlign(None); }
149
151
157 vtkSetMacro(ClampToBounds, vtkTypeBool);
158 vtkGetMacro(ClampToBounds, vtkTypeBool);
159 vtkBooleanMacro(ClampToBounds, vtkTypeBool);
161
170
172
177 vtkGetObjectMacro(HandleProperty, vtkProperty);
178 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
180
182
186 vtkGetObjectMacro(LineProperty, vtkProperty);
187 vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
189
190protected:
192 ~vtkLineWidget() override;
193
194 // Manage the state of the widget
195 friend class vtkPWCallback;
196
197 int State;
199 {
200 Start = 0,
204 Outside
205 };
206
207 // handles the events
208 static void ProcessEvents(
209 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
210
211 // ProcessEvents() dispatches to these methods.
218 virtual void OnMouseMove();
219
220 // controlling ivars
221 int Align;
222
224 {
228 None
229 };
230
231 // the line
235 void HighlightLine(int highlight);
236
237 // glyphs representing hot spots (e.g., handles)
241
243 void SizeHandles() override;
244 void HandlesOn(double length);
246 int HighlightHandle(vtkProp* prop); // returns cell id
247 void HighlightHandles(int highlight);
248
249 // Do the picking
253 double LastPosition[3];
254 void SetLinePosition(double x[3]);
255
256 // Register internal Pickers within PickingManager
257 void RegisterPickers() override;
258
259 // Methods to manipulate the hexahedron.
260 void Scale(double* p1, double* p2, int X, int Y);
261
262 // Initial bounds
264 void ClampPosition(double x[3]);
265 int InBounds(double x[3]);
266
267 // Properties used to control the appearance of selected objects and
268 // the manipulator in general.
274
276
277 // Methods for managing the point widgets used to control the endpoints
281 vtkPWCallback* PWCallback;
282 vtkPW1Callback* PW1Callback;
283 vtkPW2Callback* PW2Callback;
287 int ForwardEvent(unsigned long event);
288
289private:
290 vtkLineWidget(const vtkLineWidget&) = delete;
291 void operator=(const vtkLineWidget&) = delete;
292};
293
294VTK_ABI_NAMESPACE_END
295#endif
an abstract superclass for 3D widgets
Definition vtk3DWidget.h:57
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:50
ray-cast cell picker for all kinds of Prop3Ds
a simple class to control print indentation
Definition vtkIndent.h:38
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:58
position a point in 3D space
represent and manipulate 3D points
Definition vtkPoints.h:38
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:89
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:52
represent surface properties of a geometric object
Definition vtkProperty.h:66
create a polygonal sphere centered at the origin
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_SIZEHINT(...)