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=========================================================================*/
92#ifndef vtkLineWidget_h
93#define vtkLineWidget_h
94
95#include "vtk3DWidget.h"
96#include "vtkInteractionWidgetsModule.h" // For export macro
97#include "vtkLineSource.h" // For passing calls to it
98
99class vtkActor;
101class vtkPoints;
102class vtkPolyData;
103class vtkProp;
104class vtkProperty;
105class vtkSphereSource;
106class vtkCellPicker;
107class vtkPointWidget;
108class vtkPWCallback;
109class vtkPW1Callback;
110class vtkPW2Callback;
111
112class VTKINTERACTIONWIDGETS_EXPORT vtkLineWidget : public vtk3DWidget
113{
114public:
119
121 void PrintSelf(ostream& os, vtkIndent indent) override;
122
124
127 void SetEnabled(int) override;
128 void PlaceWidget(double bounds[6]) override;
129 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
131 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
132 {
133 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
134 }
136
140 void SetResolution(int r) { this->LineSource->SetResolution(r); }
141 int GetResolution() { return this->LineSource->GetResolution(); }
142
146 void SetPoint1(double x, double y, double z);
147 void SetPoint1(double x[3]) { this->SetPoint1(x[0], x[1], x[2]); }
148 double* GetPoint1() VTK_SIZEHINT(3) { return this->LineSource->GetPoint1(); }
149 void GetPoint1(double xyz[3]) { this->LineSource->GetPoint1(xyz); }
150
154 void SetPoint2(double x, double y, double z);
155 void SetPoint2(double x[3]) { this->SetPoint2(x[0], x[1], x[2]); }
156 double* GetPoint2() VTK_SIZEHINT(3) { return this->LineSource->GetPoint2(); }
157 void GetPoint2(double xyz[3]) { this->LineSource->GetPoint2(xyz); }
158
160
166 vtkSetClampMacro(Align, int, XAxis, None);
167 vtkGetMacro(Align, int);
168 void SetAlignToXAxis() { this->SetAlign(XAxis); }
169 void SetAlignToYAxis() { this->SetAlign(YAxis); }
170 void SetAlignToZAxis() { this->SetAlign(ZAxis); }
171 void SetAlignToNone() { this->SetAlign(None); }
173
175
181 vtkSetMacro(ClampToBounds, vtkTypeBool);
182 vtkGetMacro(ClampToBounds, vtkTypeBool);
183 vtkBooleanMacro(ClampToBounds, vtkTypeBool);
185
194
196
201 vtkGetObjectMacro(HandleProperty, vtkProperty);
202 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
204
206
210 vtkGetObjectMacro(LineProperty, vtkProperty);
211 vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
213
214protected:
216 ~vtkLineWidget() override;
217
218 // Manage the state of the widget
219 friend class vtkPWCallback;
220
221 int State;
223 {
224 Start = 0,
228 Outside
229 };
230
231 // handles the events
232 static void ProcessEvents(
233 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
234
235 // ProcessEvents() dispatches to these methods.
242 virtual void OnMouseMove();
243
244 // controlling ivars
245 int Align;
246
248 {
252 None
253 };
254
255 // the line
259 void HighlightLine(int highlight);
260
261 // glyphs representing hot spots (e.g., handles)
265
267 void SizeHandles() override;
268 void HandlesOn(double length);
270 int HighlightHandle(vtkProp* prop); // returns cell id
271 void HighlightHandles(int highlight);
272
273 // Do the picking
277 double LastPosition[3];
278 void SetLinePosition(double x[3]);
279
280 // Register internal Pickers within PickingManager
281 void RegisterPickers() override;
282
283 // Methods to manipulate the hexahedron.
284 void Scale(double* p1, double* p2, int X, int Y);
285
286 // Initial bounds
288 void ClampPosition(double x[3]);
289 int InBounds(double x[3]);
290
291 // Properties used to control the appearance of selected objects and
292 // the manipulator in general.
298
300
301 // Methods for managing the point widgets used to control the endpoints
305 vtkPWCallback* PWCallback;
306 vtkPW1Callback* PW1Callback;
307 vtkPW2Callback* PW2Callback;
311 int ForwardEvent(unsigned long event);
312
313private:
314 vtkLineWidget(const vtkLineWidget&) = delete;
315 void operator=(const vtkLineWidget&) = delete;
316};
317
318#endif
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:71
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:155
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:96
a simple class to control print indentation
Definition: vtkIndent.h:113
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:82
position a point in 3D space
represent and manipulate 3D points
Definition: vtkPoints.h:143
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:195
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:76
represent surface properties of a geometric object
Definition: vtkProperty.h:171
create a polygonal sphere centered at the origin
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_SIZEHINT(...)