VTK  9.5.2
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
76
77#ifndef vtkLineWidget_h
78#define vtkLineWidget_h
79
80#include "vtk3DWidget.h"
81#include "vtkInteractionWidgetsModule.h" // For export macro
82#include "vtkLineSource.h" // For passing calls to it
83
84VTK_ABI_NAMESPACE_BEGIN
85class vtkActor;
87class vtkPoints;
88class vtkPolyData;
89class vtkProp;
90class vtkProperty;
91class vtkSphereSource;
92class vtkCellPicker;
93class vtkPointWidget;
94class vtkPWCallback;
95class vtkPW1Callback;
96class vtkPW2Callback;
97
98class VTKINTERACTIONWIDGETS_EXPORT vtkLineWidget : public vtk3DWidget
99{
100public:
105
107 void PrintSelf(ostream& os, vtkIndent indent) override;
108
110
113 void SetEnabled(int) override;
114 void PlaceWidget(double bounds[6]) override;
115 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
117 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
118 {
119 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
120 }
121
122
126 void SetResolution(int r) { this->LineSource->SetResolution(r); }
127 int GetResolution() { return this->LineSource->GetResolution(); }
128
132 void SetPoint1(double x, double y, double z);
133 void SetPoint1(double x[3]) { this->SetPoint1(x[0], x[1], x[2]); }
134 double* GetPoint1() VTK_SIZEHINT(3) { return this->LineSource->GetPoint1(); }
135 void GetPoint1(double xyz[3]) { this->LineSource->GetPoint1(xyz); }
136
140 void SetPoint2(double x, double y, double z);
141 void SetPoint2(double x[3]) { this->SetPoint2(x[0], x[1], x[2]); }
142 double* GetPoint2() VTK_SIZEHINT(3) { return this->LineSource->GetPoint2(); }
143 void GetPoint2(double xyz[3]) { this->LineSource->GetPoint2(xyz); }
144
146
152 vtkSetClampMacro(Align, int, XAxis, None);
153 vtkGetMacro(Align, int);
154 void SetAlignToXAxis() { this->SetAlign(XAxis); }
155 void SetAlignToYAxis() { this->SetAlign(YAxis); }
156 void SetAlignToZAxis() { this->SetAlign(ZAxis); }
157 void SetAlignToNone() { this->SetAlign(None); }
159
161
169 vtkBooleanMacro(ClampToBounds, vtkTypeBool);
171
180
182
187 vtkGetObjectMacro(HandleProperty, vtkProperty);
190
192
196 vtkGetObjectMacro(LineProperty, vtkProperty);
199
200protected:
202 ~vtkLineWidget() override;
203
204 // Manage the state of the widget
205 friend class vtkPWCallback;
206
207 int State;
216
217 // handles the events
218 static void ProcessEvents(
219 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
220
221 // ProcessEvents() dispatches to these methods.
228 virtual void OnMouseMove();
229
230 // controlling ivars
231 int Align;
232
240
241 // the line
245 void HighlightLine(int highlight);
246
247 // glyphs representing hot spots (e.g., handles)
251
253 void SizeHandles() override;
254 void HandlesOn(double length);
256 int HighlightHandle(vtkProp* prop); // returns cell id
257 void HighlightHandles(int highlight);
258
259 // Do the picking
263 double LastPosition[3];
264 void SetLinePosition(double x[3]);
265
266 // Register internal Pickers within PickingManager
267 void RegisterPickers() override;
268
269 // Methods to manipulate the hexahedron.
270 void Scale(double* p1, double* p2, int X, int Y);
271
272 // Initial bounds
274 void ClampPosition(double x[3]);
275 int InBounds(double x[3]);
276
277 // Properties used to control the appearance of selected objects and
278 // the manipulator in general.
284
286
287 // Methods for managing the point widgets used to control the endpoints
292 vtkPW1Callback* PW1Callback;
293 vtkPW2Callback* PW2Callback;
297 int ForwardEvent(unsigned long event);
298
299private:
300 vtkLineWidget(const vtkLineWidget&) = delete;
301 void operator=(const vtkLineWidget&) = delete;
302};
303
304VTK_ABI_NAMESPACE_END
305#endif
virtual void PlaceWidget(double bounds[6])=0
This method is used to initially place the widget.
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
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
friend class vtkPWCallback
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
double LastPosition[3]
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()
virtual void SetAlign(int)
Force the line widget to be aligned with one of the x-y-z axes.
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.
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:63
represent surface properties of a geometric object
create a polygonal sphere centered at the origin
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_SIZEHINT(...)