VTK  9.2.6
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=========================================================================*/
89#ifndef vtkLineWidget_h
90#define vtkLineWidget_h
91
92#include "vtk3DWidget.h"
93#include "vtkInteractionWidgetsModule.h" // For export macro
94#include "vtkLineSource.h" // For passing calls to it
95
96class vtkActor;
98class vtkPoints;
99class vtkPolyData;
100class vtkProp;
101class vtkProperty;
102class vtkSphereSource;
103class vtkCellPicker;
104class vtkPointWidget;
105class vtkPWCallback;
106class vtkPW1Callback;
107class vtkPW2Callback;
108
109class VTKINTERACTIONWIDGETS_EXPORT vtkLineWidget : public vtk3DWidget
110{
111public:
116
118 void PrintSelf(ostream& os, vtkIndent indent) override;
119
121
124 void SetEnabled(int) override;
125 void PlaceWidget(double bounds[6]) override;
126 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
128 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
129 {
130 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
131 }
133
137 void SetResolution(int r) { this->LineSource->SetResolution(r); }
138 int GetResolution() { return this->LineSource->GetResolution(); }
139
143 void SetPoint1(double x, double y, double z);
144 void SetPoint1(double x[3]) { this->SetPoint1(x[0], x[1], x[2]); }
145 double* GetPoint1() VTK_SIZEHINT(3) { return this->LineSource->GetPoint1(); }
146 void GetPoint1(double xyz[3]) { this->LineSource->GetPoint1(xyz); }
147
151 void SetPoint2(double x, double y, double z);
152 void SetPoint2(double x[3]) { this->SetPoint2(x[0], x[1], x[2]); }
153 double* GetPoint2() VTK_SIZEHINT(3) { return this->LineSource->GetPoint2(); }
154 void GetPoint2(double xyz[3]) { this->LineSource->GetPoint2(xyz); }
155
157
163 vtkSetClampMacro(Align, int, XAxis, None);
164 vtkGetMacro(Align, int);
165 void SetAlignToXAxis() { this->SetAlign(XAxis); }
166 void SetAlignToYAxis() { this->SetAlign(YAxis); }
167 void SetAlignToZAxis() { this->SetAlign(ZAxis); }
168 void SetAlignToNone() { this->SetAlign(None); }
170
172
178 vtkSetMacro(ClampToBounds, vtkTypeBool);
179 vtkGetMacro(ClampToBounds, vtkTypeBool);
180 vtkBooleanMacro(ClampToBounds, vtkTypeBool);
182
191
193
198 vtkGetObjectMacro(HandleProperty, vtkProperty);
199 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
201
203
207 vtkGetObjectMacro(LineProperty, vtkProperty);
208 vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
210
211protected:
213 ~vtkLineWidget() override;
214
215 // Manage the state of the widget
216 friend class vtkPWCallback;
217
218 int State;
220 {
221 Start = 0,
225 Outside
226 };
227
228 // handles the events
229 static void ProcessEvents(
230 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
231
232 // ProcessEvents() dispatches to these methods.
239 virtual void OnMouseMove();
240
241 // controlling ivars
242 int Align;
243
245 {
249 None
250 };
251
252 // the line
256 void HighlightLine(int highlight);
257
258 // glyphs representing hot spots (e.g., handles)
262
264 void SizeHandles() override;
265 void HandlesOn(double length);
267 int HighlightHandle(vtkProp* prop); // returns cell id
268 void HighlightHandles(int highlight);
269
270 // Do the picking
274 double LastPosition[3];
275 void SetLinePosition(double x[3]);
276
277 // Register internal Pickers within PickingManager
278 void RegisterPickers() override;
279
280 // Methods to manipulate the hexahedron.
281 void Scale(double* p1, double* p2, int X, int Y);
282
283 // Initial bounds
285 void ClampPosition(double x[3]);
286 int InBounds(double x[3]);
287
288 // Properties used to control the appearance of selected objects and
289 // the manipulator in general.
295
297
298 // Methods for managing the point widgets used to control the endpoints
302 vtkPWCallback* PWCallback;
303 vtkPW1Callback* PW1Callback;
304 vtkPW2Callback* PW2Callback;
308 int ForwardEvent(unsigned long event);
309
310private:
311 vtkLineWidget(const vtkLineWidget&) = delete;
312 void operator=(const vtkLineWidget&) = delete;
313};
314
315#endif
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:68
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:161
ray-cast cell picker for all kinds of Prop3Ds
a simple class to control print indentation
Definition: vtkIndent.h:119
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:79
position a point in 3D space
represent and manipulate 3D points
Definition: vtkPoints.h:149
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:200
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:73
represent surface properties of a geometric object
Definition: vtkProperty.h:177
create a polygonal sphere centered at the origin
@ length
Definition: vtkX3D.h:399
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_SIZEHINT(...)