VTK  9.3.20240424
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
80#ifndef vtkLineWidget_h
81#define vtkLineWidget_h
82
83#include "vtk3DWidget.h"
84#include "vtkInteractionWidgetsModule.h" // For export macro
85#include "vtkLineSource.h" // For passing calls to it
86
87VTK_ABI_NAMESPACE_BEGIN
88class vtkActor;
90class vtkPoints;
91class vtkPolyData;
92class vtkProp;
93class vtkProperty;
94class vtkSphereSource;
95class vtkCellPicker;
96class vtkPointWidget;
97class vtkPWCallback;
98class vtkPW1Callback;
99class vtkPW2Callback;
100
101class VTKINTERACTIONWIDGETS_EXPORT vtkLineWidget : public vtk3DWidget
102{
103public:
108
110 void PrintSelf(ostream& os, vtkIndent indent) override;
111
113
116 void SetEnabled(int) override;
117 void PlaceWidget(double bounds[6]) override;
118 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
120 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
121 {
122 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
123 }
125
129 void SetResolution(int r) { this->LineSource->SetResolution(r); }
130 int GetResolution() { return this->LineSource->GetResolution(); }
131
135 void SetPoint1(double x, double y, double z);
136 void SetPoint1(double x[3]) { this->SetPoint1(x[0], x[1], x[2]); }
137 double* GetPoint1() VTK_SIZEHINT(3) { return this->LineSource->GetPoint1(); }
138 void GetPoint1(double xyz[3]) { this->LineSource->GetPoint1(xyz); }
139
143 void SetPoint2(double x, double y, double z);
144 void SetPoint2(double x[3]) { this->SetPoint2(x[0], x[1], x[2]); }
145 double* GetPoint2() VTK_SIZEHINT(3) { return this->LineSource->GetPoint2(); }
146 void GetPoint2(double xyz[3]) { this->LineSource->GetPoint2(xyz); }
147
149
155 vtkSetClampMacro(Align, int, XAxis, None);
156 vtkGetMacro(Align, int);
157 void SetAlignToXAxis() { this->SetAlign(XAxis); }
158 void SetAlignToYAxis() { this->SetAlign(YAxis); }
159 void SetAlignToZAxis() { this->SetAlign(ZAxis); }
160 void SetAlignToNone() { this->SetAlign(None); }
162
164
170 vtkSetMacro(ClampToBounds, vtkTypeBool);
171 vtkGetMacro(ClampToBounds, vtkTypeBool);
172 vtkBooleanMacro(ClampToBounds, vtkTypeBool);
174
183
185
190 vtkGetObjectMacro(HandleProperty, vtkProperty);
191 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
193
195
199 vtkGetObjectMacro(LineProperty, vtkProperty);
200 vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
202
203protected:
205 ~vtkLineWidget() override;
206
207 // Manage the state of the widget
208 friend class vtkPWCallback;
209
210 int State;
212 {
213 Start = 0,
217 Outside
218 };
219
220 // handles the events
221 static void ProcessEvents(
222 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
223
224 // ProcessEvents() dispatches to these methods.
231 virtual void OnMouseMove();
232
233 // controlling ivars
234 int Align;
235
237 {
241 None
242 };
243
244 // the line
248 void HighlightLine(int highlight);
249
250 // glyphs representing hot spots (e.g., handles)
254
256 void SizeHandles() override;
257 void HandlesOn(double length);
259 int HighlightHandle(vtkProp* prop); // returns cell id
260 void HighlightHandles(int highlight);
261
262 // Do the picking
266 double LastPosition[3];
267 void SetLinePosition(double x[3]);
268
269 // Register internal Pickers within PickingManager
270 void RegisterPickers() override;
271
272 // Methods to manipulate the hexahedron.
273 void Scale(double* p1, double* p2, int X, int Y);
274
275 // Initial bounds
277 void ClampPosition(double x[3]);
278 int InBounds(double x[3]);
279
280 // Properties used to control the appearance of selected objects and
281 // the manipulator in general.
287
289
290 // Methods for managing the point widgets used to control the endpoints
294 vtkPWCallback* PWCallback;
295 vtkPW1Callback* PW1Callback;
296 vtkPW2Callback* PW2Callback;
300 int ForwardEvent(unsigned long event);
301
302private:
303 vtkLineWidget(const vtkLineWidget&) = delete;
304 void operator=(const vtkLineWidget&) = delete;
305};
306
307VTK_ABI_NAMESPACE_END
308#endif
an abstract superclass for 3D widgets
Definition vtk3DWidget.h:60
represents an object (geometry & properties) in a rendered scene
Definition vtkActor.h:151
ray-cast cell picker for all kinds of Prop3Ds
a simple class to control print indentation
Definition vtkIndent.h:108
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:162
position a point in 3D space
represent and manipulate 3D points
Definition vtkPoints.h:139
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:66
represent surface properties of a geometric object
create a polygonal sphere centered at the origin
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_SIZEHINT(...)