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
70 #ifndef vtkLineWidget_h
71 #define vtkLineWidget_h
72 
73 #include "vtk3DWidget.h"
74 #include "vtkInteractionWidgetsModule.h" // For export macro
75 #include "vtkLineSource.h" // For passing calls to it
76 
77 VTK_ABI_NAMESPACE_BEGIN
78 class vtkActor;
79 class vtkPolyDataMapper;
80 class vtkPoints;
81 class vtkPolyData;
82 class vtkProp;
83 class vtkProperty;
84 class vtkSphereSource;
85 class vtkCellPicker;
86 class vtkPointWidget;
87 class vtkPWCallback;
88 class vtkPW1Callback;
89 class vtkPW2Callback;
90 
91 class VTKINTERACTIONWIDGETS_EXPORT vtkLineWidget : public vtk3DWidget
92 {
93 public:
97  static vtkLineWidget* New();
98 
99  vtkTypeMacro(vtkLineWidget, vtk3DWidget);
100  void PrintSelf(ostream& os, vtkIndent indent) override;
101 
103 
106  void SetEnabled(int) override;
107  void PlaceWidget(double bounds[6]) override;
108  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
110  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
111  {
112  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
113  }
115 
119  void SetResolution(int r) { this->LineSource->SetResolution(r); }
120  int GetResolution() { return this->LineSource->GetResolution(); }
121 
125  void SetPoint1(double x, double y, double z);
126  void SetPoint1(double x[3]) { this->SetPoint1(x[0], x[1], x[2]); }
127  double* GetPoint1() VTK_SIZEHINT(3) { return this->LineSource->GetPoint1(); }
128  void GetPoint1(double xyz[3]) { this->LineSource->GetPoint1(xyz); }
129 
133  void SetPoint2(double x, double y, double z);
134  void SetPoint2(double x[3]) { this->SetPoint2(x[0], x[1], x[2]); }
135  double* GetPoint2() VTK_SIZEHINT(3) { return this->LineSource->GetPoint2(); }
136  void GetPoint2(double xyz[3]) { this->LineSource->GetPoint2(xyz); }
137 
139 
145  vtkSetClampMacro(Align, int, XAxis, None);
146  vtkGetMacro(Align, int);
147  void SetAlignToXAxis() { this->SetAlign(XAxis); }
148  void SetAlignToYAxis() { this->SetAlign(YAxis); }
149  void SetAlignToZAxis() { this->SetAlign(ZAxis); }
150  void SetAlignToNone() { this->SetAlign(None); }
152 
154 
160  vtkSetMacro(ClampToBounds, vtkTypeBool);
161  vtkGetMacro(ClampToBounds, vtkTypeBool);
162  vtkBooleanMacro(ClampToBounds, vtkTypeBool);
164 
173 
175 
180  vtkGetObjectMacro(HandleProperty, vtkProperty);
181  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
183 
185 
189  vtkGetObjectMacro(LineProperty, vtkProperty);
190  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
192 
193 protected:
195  ~vtkLineWidget() override;
196 
197  // Manage the state of the widget
198  friend class vtkPWCallback;
199 
200  int State;
202  {
203  Start = 0,
207  Outside
208  };
209 
210  // handles the events
211  static void ProcessEvents(
212  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
213 
214  // ProcessEvents() dispatches to these methods.
221  virtual void OnMouseMove();
222 
223  // controlling ivars
224  int Align;
225 
227  {
231  None
232  };
233 
234  // the line
238  void HighlightLine(int highlight);
239 
240  // glyphs representing hot spots (e.g., handles)
244 
246  void SizeHandles() override;
247  void HandlesOn(double length);
248  void HandlesOff();
249  int HighlightHandle(vtkProp* prop); // returns cell id
250  void HighlightHandles(int highlight);
251 
252  // Do the picking
256  double LastPosition[3];
257  void SetLinePosition(double x[3]);
258 
259  // Register internal Pickers within PickingManager
260  void RegisterPickers() override;
261 
262  // Methods to manipulate the hexahedron.
263  void Scale(double* p1, double* p2, int X, int Y);
264 
265  // Initial bounds
267  void ClampPosition(double x[3]);
268  int InBounds(double x[3]);
269 
270  // Properties used to control the appearance of selected objects and
271  // the manipulator in general.
277 
278  void GenerateLine();
279 
280  // Methods for managing the point widgets used to control the endpoints
284  vtkPWCallback* PWCallback;
285  vtkPW1Callback* PW1Callback;
286  vtkPW2Callback* PW2Callback;
290  int ForwardEvent(unsigned long event);
291 
292 private:
293  vtkLineWidget(const vtkLineWidget&) = delete;
294  void operator=(const vtkLineWidget&) = delete;
295 };
296 
297 VTK_ABI_NAMESPACE_END
298 #endif
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:60
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:50
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:71
a simple class to control print indentation
Definition: vtkIndent.h:38
create a line defined by two end points
Definition: vtkLineSource.h:62
3D widget for manipulating a line
Definition: vtkLineWidget.h:92
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
static vtkLineWidget * New()
Instantiate the object.
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
void GenerateLine()
int HighlightHandle(vtkProp *prop)
void OnLeftButtonDown()
double * GetPoint2()
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])
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:61
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:55
represent surface properties of a geometric object
Definition: vtkProperty.h:66
create a polygonal sphere centered at the origin
@ length
Definition: vtkX3D.h:393
int vtkTypeBool
Definition: vtkABI.h:64
#define VTK_SIZEHINT(...)