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=========================================================================*/
82#ifndef vtkLineWidget_h
83#define vtkLineWidget_h
84
85#include "vtk3DWidget.h"
86#include "vtkInteractionWidgetsModule.h" // For export macro
87#include "vtkLineSource.h" // For passing calls to it
88
89class vtkActor;
91class vtkPoints;
92class vtkPolyData;
93class vtkProp;
94class vtkProperty;
95class vtkSphereSource;
96class vtkCellPicker;
97class vtkPointWidget;
98class vtkPWCallback;
99class vtkPW1Callback;
100class vtkPW2Callback;
101
102class VTKINTERACTIONWIDGETS_EXPORT vtkLineWidget : public vtk3DWidget
103{
104public:
109
111 void PrintSelf(ostream& os, vtkIndent indent) override;
112
114
117 void SetEnabled(int) override;
118 void PlaceWidget(double bounds[6]) override;
119 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
121 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
122 {
123 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
124 }
126
130 void SetResolution(int r) { this->LineSource->SetResolution(r); }
131 int GetResolution() { return this->LineSource->GetResolution(); }
132
136 void SetPoint1(double x, double y, double z);
137 void SetPoint1(double x[3]) { this->SetPoint1(x[0], x[1], x[2]); }
138 double* GetPoint1() VTK_SIZEHINT(3) { return this->LineSource->GetPoint1(); }
139 void GetPoint1(double xyz[3]) { this->LineSource->GetPoint1(xyz); }
140
144 void SetPoint2(double x, double y, double z);
145 void SetPoint2(double x[3]) { this->SetPoint2(x[0], x[1], x[2]); }
146 double* GetPoint2() VTK_SIZEHINT(3) { return this->LineSource->GetPoint2(); }
147 void GetPoint2(double xyz[3]) { this->LineSource->GetPoint2(xyz); }
148
150
156 vtkSetClampMacro(Align, int, XAxis, None);
157 vtkGetMacro(Align, int);
158 void SetAlignToXAxis() { this->SetAlign(XAxis); }
159 void SetAlignToYAxis() { this->SetAlign(YAxis); }
160 void SetAlignToZAxis() { this->SetAlign(ZAxis); }
161 void SetAlignToNone() { this->SetAlign(None); }
163
165
171 vtkSetMacro(ClampToBounds, vtkTypeBool);
172 vtkGetMacro(ClampToBounds, vtkTypeBool);
173 vtkBooleanMacro(ClampToBounds, vtkTypeBool);
175
184
186
191 vtkGetObjectMacro(HandleProperty, vtkProperty);
192 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
194
196
200 vtkGetObjectMacro(LineProperty, vtkProperty);
201 vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
203
204protected:
206 ~vtkLineWidget() override;
207
208 // Manage the state of the widget
209 friend class vtkPWCallback;
210
211 int State;
213 {
214 Start = 0,
218 Outside
219 };
220
221 // handles the events
222 static void ProcessEvents(
223 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
224
225 // ProcessEvents() dispatches to these methods.
232 virtual void OnMouseMove();
233
234 // controlling ivars
235 int Align;
236
238 {
242 None
243 };
244
245 // the line
249 void HighlightLine(int highlight);
250
251 // glyphs representing hot spots (e.g., handles)
255
257 void SizeHandles() override;
258 void HandlesOn(double length);
260 int HighlightHandle(vtkProp* prop); // returns cell id
261 void HighlightHandles(int highlight);
262
263 // Do the picking
267 double LastPosition[3];
268 void SetLinePosition(double x[3]);
269
270 // Register internal Pickers within PickingManager
271 void RegisterPickers() override;
272
273 // Methods to manipulate the hexahedron.
274 void Scale(double* p1, double* p2, int X, int Y);
275
276 // Initial bounds
278 void ClampPosition(double x[3]);
279 int InBounds(double x[3]);
280
281 // Properties used to control the appearance of selected objects and
282 // the manipulator in general.
288
290
291 // Methods for managing the point widgets used to control the endpoints
295 vtkPWCallback* PWCallback;
296 vtkPW1Callback* PW1Callback;
297 vtkPW2Callback* PW2Callback;
301 int ForwardEvent(unsigned long event);
302
303private:
304 vtkLineWidget(const vtkLineWidget&) = delete;
305 void operator=(const vtkLineWidget&) = delete;
306};
307
308#endif
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:71
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
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:72
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:66
represent surface properties of a geometric object
Definition: vtkProperty.h:71
create a polygonal sphere centered at the origin
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_SIZEHINT(...)