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
61 #ifndef vtkLineWidget_h
62 #define vtkLineWidget_h
63 
64 #include "vtk3DWidget.h"
65 #include "vtkInteractionWidgetsModule.h" // For export macro
66 #include "vtkLineSource.h" // For passing calls to it
67 
68 VTK_ABI_NAMESPACE_BEGIN
69 class vtkActor;
70 class vtkPolyDataMapper;
71 class vtkPoints;
72 class vtkPolyData;
73 class vtkProp;
74 class vtkProperty;
75 class vtkSphereSource;
76 class vtkCellPicker;
77 class vtkPointWidget;
78 class vtkPWCallback;
79 class vtkPW1Callback;
80 class vtkPW2Callback;
81 
82 class VTKINTERACTIONWIDGETS_EXPORT vtkLineWidget : public vtk3DWidget
83 {
84 public:
88  static vtkLineWidget* New();
89 
90  vtkTypeMacro(vtkLineWidget, vtk3DWidget);
91  void PrintSelf(ostream& os, vtkIndent indent) override;
92 
94 
97  void SetEnabled(int) override;
98  void PlaceWidget(double bounds[6]) override;
99  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
101  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
102  {
103  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
104  }
106 
110  void SetResolution(int r) { this->LineSource->SetResolution(r); }
111  int GetResolution() { return this->LineSource->GetResolution(); }
112 
116  void SetPoint1(double x, double y, double z);
117  void SetPoint1(double x[3]) { this->SetPoint1(x[0], x[1], x[2]); }
118  double* GetPoint1() VTK_SIZEHINT(3) { return this->LineSource->GetPoint1(); }
119  void GetPoint1(double xyz[3]) { this->LineSource->GetPoint1(xyz); }
120 
124  void SetPoint2(double x, double y, double z);
125  void SetPoint2(double x[3]) { this->SetPoint2(x[0], x[1], x[2]); }
126  double* GetPoint2() VTK_SIZEHINT(3) { return this->LineSource->GetPoint2(); }
127  void GetPoint2(double xyz[3]) { this->LineSource->GetPoint2(xyz); }
128 
130 
136  vtkSetClampMacro(Align, int, XAxis, None);
137  vtkGetMacro(Align, int);
138  void SetAlignToXAxis() { this->SetAlign(XAxis); }
139  void SetAlignToYAxis() { this->SetAlign(YAxis); }
140  void SetAlignToZAxis() { this->SetAlign(ZAxis); }
141  void SetAlignToNone() { this->SetAlign(None); }
143 
145 
151  vtkSetMacro(ClampToBounds, vtkTypeBool);
152  vtkGetMacro(ClampToBounds, vtkTypeBool);
153  vtkBooleanMacro(ClampToBounds, vtkTypeBool);
155 
164 
166 
171  vtkGetObjectMacro(HandleProperty, vtkProperty);
172  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
174 
176 
180  vtkGetObjectMacro(LineProperty, vtkProperty);
181  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
183 
184 protected:
186  ~vtkLineWidget() override;
187 
188  // Manage the state of the widget
189  friend class vtkPWCallback;
190 
191  int State;
193  {
194  Start = 0,
198  Outside
199  };
200 
201  // handles the events
202  static void ProcessEvents(
203  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
204 
205  // ProcessEvents() dispatches to these methods.
212  virtual void OnMouseMove();
213 
214  // controlling ivars
215  int Align;
216 
218  {
222  None
223  };
224 
225  // the line
229  void HighlightLine(int highlight);
230 
231  // glyphs representing hot spots (e.g., handles)
235 
237  void SizeHandles() override;
238  void HandlesOn(double length);
239  void HandlesOff();
240  int HighlightHandle(vtkProp* prop); // returns cell id
241  void HighlightHandles(int highlight);
242 
243  // Do the picking
247  double LastPosition[3];
248  void SetLinePosition(double x[3]);
249 
250  // Register internal Pickers within PickingManager
251  void RegisterPickers() override;
252 
253  // Methods to manipulate the hexahedron.
254  void Scale(double* p1, double* p2, int X, int Y);
255 
256  // Initial bounds
258  void ClampPosition(double x[3]);
259  int InBounds(double x[3]);
260 
261  // Properties used to control the appearance of selected objects and
262  // the manipulator in general.
268 
269  void GenerateLine();
270 
271  // Methods for managing the point widgets used to control the endpoints
275  vtkPWCallback* PWCallback;
276  vtkPW1Callback* PW1Callback;
277  vtkPW2Callback* PW2Callback;
281  int ForwardEvent(unsigned long event);
282 
283 private:
284  vtkLineWidget(const vtkLineWidget&) = delete;
285  void operator=(const vtkLineWidget&) = delete;
286 };
287 
288 VTK_ABI_NAMESPACE_END
289 #endif
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:60
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:41
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:62
a simple class to control print indentation
Definition: vtkIndent.h:29
create a line defined by two end points
Definition: vtkLineSource.h:53
3D widget for manipulating a line
Definition: vtkLineWidget.h:83
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.
Definition: vtkLineWidget.h:99
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:52
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:46
represent surface properties of a geometric object
Definition: vtkProperty.h:57
create a polygonal sphere centered at the origin
@ length
Definition: vtkX3D.h:393
int vtkTypeBool
Definition: vtkABI.h:64
#define VTK_SIZEHINT(...)