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=========================================================================*/
70#ifndef vtkLineWidget_h
71#define vtkLineWidget_h
72
73#include "vtk3DWidget.h"
74#include "vtkInteractionWidgetsModule.h" // For export macro
75#include "vtkLineSource.h" // For passing calls to it
76
77class vtkActor;
79class vtkPoints;
80class vtkPolyData;
81class vtkProp;
82class vtkProperty;
83class vtkSphereSource;
84class vtkCellPicker;
85class vtkPointWidget;
86class vtkPWCallback;
87class vtkPW1Callback;
88class vtkPW2Callback;
89
90class VTKINTERACTIONWIDGETS_EXPORT vtkLineWidget : public vtk3DWidget
91{
92public:
96 static vtkLineWidget* New();
97
98 vtkTypeMacro(vtkLineWidget, vtk3DWidget);
99 void PrintSelf(ostream& os, vtkIndent indent) override;
100
102
105 void SetEnabled(int) override;
106 void PlaceWidget(double bounds[6]) override;
107 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
109 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
110 {
111 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
112 }
114
118 void SetResolution(int r) { this->LineSource->SetResolution(r); }
119 int GetResolution() { return this->LineSource->GetResolution(); }
120
124 void SetPoint1(double x, double y, double z);
125 void SetPoint1(double x[3]) { this->SetPoint1(x[0], x[1], x[2]); }
126 double* GetPoint1() VTK_SIZEHINT(3) { return this->LineSource->GetPoint1(); }
127 void GetPoint1(double xyz[3]) { this->LineSource->GetPoint1(xyz); }
128
132 void SetPoint2(double x, double y, double z);
133 void SetPoint2(double x[3]) { this->SetPoint2(x[0], x[1], x[2]); }
134 double* GetPoint2() VTK_SIZEHINT(3) { return this->LineSource->GetPoint2(); }
135 void GetPoint2(double xyz[3]) { this->LineSource->GetPoint2(xyz); }
136
138
144 vtkSetClampMacro(Align, int, XAxis, None);
145 vtkGetMacro(Align, int);
146 void SetAlignToXAxis() { this->SetAlign(XAxis); }
147 void SetAlignToYAxis() { this->SetAlign(YAxis); }
148 void SetAlignToZAxis() { this->SetAlign(ZAxis); }
149 void SetAlignToNone() { this->SetAlign(None); }
151
153
159 vtkSetMacro(ClampToBounds, vtkTypeBool);
160 vtkGetMacro(ClampToBounds, vtkTypeBool);
161 vtkBooleanMacro(ClampToBounds, vtkTypeBool);
163
172
174
179 vtkGetObjectMacro(HandleProperty, vtkProperty);
180 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
182
184
188 vtkGetObjectMacro(LineProperty, vtkProperty);
189 vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
191
192protected:
194 ~vtkLineWidget() override;
195
196 // Manage the state of the widget
197 friend class vtkPWCallback;
198
199 int State;
201 {
202 Start = 0,
206 Outside
207 };
208
209 // handles the events
210 static void ProcessEvents(
211 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
212
213 // ProcessEvents() dispatches to these methods.
220 virtual void OnMouseMove();
221
222 // controlling ivars
223 int Align;
224
226 {
230 None
231 };
232
233 // the line
237 void HighlightLine(int highlight);
238
239 // glyphs representing hot spots (e.g., handles)
243
245 void SizeHandles() override;
246 void HandlesOn(double length);
248 int HighlightHandle(vtkProp* prop); // returns cell id
249 void HighlightHandles(int highlight);
250
251 // Do the picking
255 double LastPosition[3];
256 void SetLinePosition(double x[3]);
257
258 // Register internal Pickers within PickingManager
259 void RegisterPickers() override;
260
261 // Methods to manipulate the hexahedron.
262 void Scale(double* p1, double* p2, int X, int Y);
263
264 // Initial bounds
266 void ClampPosition(double x[3]);
267 int InBounds(double x[3]);
268
269 // Properties used to control the appearance of selected objects and
270 // the manipulator in general.
276
278
279 // Methods for managing the point widgets used to control the endpoints
283 vtkPWCallback* PWCallback;
284 vtkPW1Callback* PW1Callback;
285 vtkPW2Callback* PW2Callback;
289 int ForwardEvent(unsigned long event);
290
291private:
292 vtkLineWidget(const vtkLineWidget&) = delete;
293 void operator=(const vtkLineWidget&) = delete;
294};
295
296#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
a simple class to control print indentation
Definition vtkIndent.h:34
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:57
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:85
abstract superclass for all actors, volumes and annotations
Definition vtkProp.h:51
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(...)