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=========================================================================*/
73#ifndef vtkLineWidget_h
74#define vtkLineWidget_h
75
76#include "vtk3DWidget.h"
77#include "vtkInteractionWidgetsModule.h" // For export macro
78#include "vtkLineSource.h" // For passing calls to it
79
80class vtkActor;
82class vtkPoints;
83class vtkPolyData;
84class vtkProp;
85class vtkProperty;
86class vtkSphereSource;
87class vtkCellPicker;
88class vtkPointWidget;
89class vtkPWCallback;
90class vtkPW1Callback;
91class vtkPW2Callback;
92
93class VTKINTERACTIONWIDGETS_EXPORT vtkLineWidget : public vtk3DWidget
94{
95public:
99 static vtkLineWidget* New();
100
102 void PrintSelf(ostream& os, vtkIndent indent) override;
103
105
108 void SetEnabled(int) override;
109 void PlaceWidget(double bounds[6]) override;
110 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
112 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
113 {
114 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
115 }
117
121 void SetResolution(int r) { this->LineSource->SetResolution(r); }
122 int GetResolution() { return this->LineSource->GetResolution(); }
123
127 void SetPoint1(double x, double y, double z);
128 void SetPoint1(double x[3]) { this->SetPoint1(x[0], x[1], x[2]); }
129 double* GetPoint1() VTK_SIZEHINT(3) { return this->LineSource->GetPoint1(); }
130 void GetPoint1(double xyz[3]) { this->LineSource->GetPoint1(xyz); }
131
135 void SetPoint2(double x, double y, double z);
136 void SetPoint2(double x[3]) { this->SetPoint2(x[0], x[1], x[2]); }
137 double* GetPoint2() VTK_SIZEHINT(3) { return this->LineSource->GetPoint2(); }
138 void GetPoint2(double xyz[3]) { this->LineSource->GetPoint2(xyz); }
139
141
147 vtkSetClampMacro(Align, int, XAxis, None);
148 vtkGetMacro(Align, int);
149 void SetAlignToXAxis() { this->SetAlign(XAxis); }
150 void SetAlignToYAxis() { this->SetAlign(YAxis); }
151 void SetAlignToZAxis() { this->SetAlign(ZAxis); }
152 void SetAlignToNone() { this->SetAlign(None); }
154
156
162 vtkSetMacro(ClampToBounds, vtkTypeBool);
163 vtkGetMacro(ClampToBounds, vtkTypeBool);
164 vtkBooleanMacro(ClampToBounds, vtkTypeBool);
166
175
177
182 vtkGetObjectMacro(HandleProperty, vtkProperty);
183 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
185
187
191 vtkGetObjectMacro(LineProperty, vtkProperty);
192 vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
194
195protected:
197 ~vtkLineWidget() override;
198
199 // Manage the state of the widget
200 friend class vtkPWCallback;
201
202 int State;
204 {
205 Start = 0,
209 Outside
210 };
211
212 // handles the events
213 static void ProcessEvents(
214 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
215
216 // ProcessEvents() dispatches to these methods.
223 virtual void OnMouseMove();
224
225 // controlling ivars
226 int Align;
227
229 {
233 None
234 };
235
236 // the line
240 void HighlightLine(int highlight);
241
242 // glyphs representing hot spots (e.g., handles)
246
248 void SizeHandles() override;
249 void HandlesOn(double length);
251 int HighlightHandle(vtkProp* prop); // returns cell id
252 void HighlightHandles(int highlight);
253
254 // Do the picking
258 double LastPosition[3];
259 void SetLinePosition(double x[3]);
260
261 // Register internal Pickers within PickingManager
262 void RegisterPickers() override;
263
264 // Methods to manipulate the hexahedron.
265 void Scale(double* p1, double* p2, int X, int Y);
266
267 // Initial bounds
269 void ClampPosition(double x[3]);
270 int InBounds(double x[3]);
271
272 // Properties used to control the appearance of selected objects and
273 // the manipulator in general.
279
281
282 // Methods for managing the point widgets used to control the endpoints
286 vtkPWCallback* PWCallback;
287 vtkPW1Callback* PW1Callback;
288 vtkPW2Callback* PW2Callback;
292 int ForwardEvent(unsigned long event);
293
294private:
295 vtkLineWidget(const vtkLineWidget&) = delete;
296 void operator=(const vtkLineWidget&) = delete;
297};
298
299#endif
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:71
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:46
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:67
a simple class to control print indentation
Definition: vtkIndent.h:34
create a line defined by two end points
Definition: vtkLineSource.h:61
3D widget for manipulating a line
Definition: vtkLineWidget.h:94
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:34
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:86
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:57
represent surface properties of a geometric object
Definition: vtkProperty.h:62
create a polygonal sphere centered at the origin
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_SIZEHINT(...)