VTK  9.1.0
vtkLineWidget.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkLineWidget.h
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14=========================================================================*/
76#ifndef vtkLineWidget_h
77#define vtkLineWidget_h
78
79#include "vtk3DWidget.h"
80#include "vtkInteractionWidgetsModule.h" // For export macro
81#include "vtkLineSource.h" // For passing calls to it
82
83class vtkActor;
85class vtkPoints;
86class vtkPolyData;
87class vtkProp;
88class vtkProperty;
89class vtkSphereSource;
90class vtkCellPicker;
91class vtkPointWidget;
92class vtkPWCallback;
93class vtkPW1Callback;
94class vtkPW2Callback;
95
96class VTKINTERACTIONWIDGETS_EXPORT vtkLineWidget : public vtk3DWidget
97{
98public:
103
105 void PrintSelf(ostream& os, vtkIndent indent) override;
106
108
111 void SetEnabled(int) override;
112 void PlaceWidget(double bounds[6]) override;
113 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
115 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
116 {
117 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
118 }
120
124 void SetResolution(int r) { this->LineSource->SetResolution(r); }
125 int GetResolution() { return this->LineSource->GetResolution(); }
126
130 void SetPoint1(double x, double y, double z);
131 void SetPoint1(double x[3]) { this->SetPoint1(x[0], x[1], x[2]); }
132 double* GetPoint1() VTK_SIZEHINT(3) { return this->LineSource->GetPoint1(); }
133 void GetPoint1(double xyz[3]) { this->LineSource->GetPoint1(xyz); }
134
138 void SetPoint2(double x, double y, double z);
139 void SetPoint2(double x[3]) { this->SetPoint2(x[0], x[1], x[2]); }
140 double* GetPoint2() VTK_SIZEHINT(3) { return this->LineSource->GetPoint2(); }
141 void GetPoint2(double xyz[3]) { this->LineSource->GetPoint2(xyz); }
142
144
150 vtkSetClampMacro(Align, int, XAxis, None);
151 vtkGetMacro(Align, int);
152 void SetAlignToXAxis() { this->SetAlign(XAxis); }
153 void SetAlignToYAxis() { this->SetAlign(YAxis); }
154 void SetAlignToZAxis() { this->SetAlign(ZAxis); }
155 void SetAlignToNone() { this->SetAlign(None); }
157
159
165 vtkSetMacro(ClampToBounds, vtkTypeBool);
166 vtkGetMacro(ClampToBounds, vtkTypeBool);
167 vtkBooleanMacro(ClampToBounds, vtkTypeBool);
169
178
180
185 vtkGetObjectMacro(HandleProperty, vtkProperty);
186 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
188
190
194 vtkGetObjectMacro(LineProperty, vtkProperty);
195 vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
197
198protected:
200 ~vtkLineWidget() override;
201
202 // Manage the state of the widget
203 friend class vtkPWCallback;
204
205 int State;
207 {
208 Start = 0,
212 Outside
213 };
214
215 // handles the events
216 static void ProcessEvents(
217 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
218
219 // ProcessEvents() dispatches to these methods.
226 virtual void OnMouseMove();
227
228 // controlling ivars
229 int Align;
230
232 {
236 None
237 };
238
239 // the line
243 void HighlightLine(int highlight);
244
245 // glyphs representing hot spots (e.g., handles)
249
251 void SizeHandles() override;
252 void HandlesOn(double length);
254 int HighlightHandle(vtkProp* prop); // returns cell id
255 void HighlightHandles(int highlight);
256
257 // Do the picking
261 double LastPosition[3];
262 void SetLinePosition(double x[3]);
263
264 // Register internal Pickers within PickingManager
265 void RegisterPickers() override;
266
267 // Methods to manipulate the hexahedron.
268 void Scale(double* p1, double* p2, int X, int Y);
269
270 // Initial bounds
272 void ClampPosition(double x[3]);
273 int InBounds(double x[3]);
274
275 // Properties used to control the appearance of selected objects and
276 // the manipulator in general.
282
284
285 // Methods for managing the point widgets used to control the endpoints
289 vtkPWCallback* PWCallback;
290 vtkPW1Callback* PW1Callback;
291 vtkPW2Callback* PW2Callback;
295 int ForwardEvent(unsigned long event);
296
297private:
298 vtkLineWidget(const vtkLineWidget&) = delete;
299 void operator=(const vtkLineWidget&) = delete;
300};
301
302#endif
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:68
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:55
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:76
a simple class to control print indentation
Definition: vtkIndent.h:43
create a line defined by two end points
Definition: vtkLineSource.h:70
3D widget for manipulating a line
Definition: vtkLineWidget.h:97
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:63
position a point in 3D space
represent and manipulate 3D points
Definition: vtkPoints.h:43
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:95
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:57
represent surface properties of a geometric object
Definition: vtkProperty.h:71
create a polygonal sphere centered at the origin
@ length
Definition: vtkX3D.h:399
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_SIZEHINT(...)