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=========================================================================*/
86#ifndef vtkLineWidget_h
87#define vtkLineWidget_h
88
89#include "vtk3DWidget.h"
90#include "vtkInteractionWidgetsModule.h" // For export macro
91#include "vtkLineSource.h" // For passing calls to it
92
93class vtkActor;
95class vtkPoints;
96class vtkPolyData;
97class vtkProp;
98class vtkProperty;
99class vtkSphereSource;
100class vtkCellPicker;
101class vtkPointWidget;
102class vtkPWCallback;
103class vtkPW1Callback;
104class vtkPW2Callback;
105
106class VTKINTERACTIONWIDGETS_EXPORT vtkLineWidget : public vtk3DWidget
107{
108public:
113
115 void PrintSelf(ostream& os, vtkIndent indent) override;
116
118
121 void SetEnabled(int) override;
122 void PlaceWidget(double bounds[6]) override;
123 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
125 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
126 {
127 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
128 }
130
134 void SetResolution(int r) { this->LineSource->SetResolution(r); }
135 int GetResolution() { return this->LineSource->GetResolution(); }
136
140 void SetPoint1(double x, double y, double z);
141 void SetPoint1(double x[3]) { this->SetPoint1(x[0], x[1], x[2]); }
142 double* GetPoint1() VTK_SIZEHINT(3) { return this->LineSource->GetPoint1(); }
143 void GetPoint1(double xyz[3]) { this->LineSource->GetPoint1(xyz); }
144
148 void SetPoint2(double x, double y, double z);
149 void SetPoint2(double x[3]) { this->SetPoint2(x[0], x[1], x[2]); }
150 double* GetPoint2() VTK_SIZEHINT(3) { return this->LineSource->GetPoint2(); }
151 void GetPoint2(double xyz[3]) { this->LineSource->GetPoint2(xyz); }
152
154
160 vtkSetClampMacro(Align, int, XAxis, None);
161 vtkGetMacro(Align, int);
162 void SetAlignToXAxis() { this->SetAlign(XAxis); }
163 void SetAlignToYAxis() { this->SetAlign(YAxis); }
164 void SetAlignToZAxis() { this->SetAlign(ZAxis); }
165 void SetAlignToNone() { this->SetAlign(None); }
167
169
175 vtkSetMacro(ClampToBounds, vtkTypeBool);
176 vtkGetMacro(ClampToBounds, vtkTypeBool);
177 vtkBooleanMacro(ClampToBounds, vtkTypeBool);
179
188
190
195 vtkGetObjectMacro(HandleProperty, vtkProperty);
196 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
198
200
204 vtkGetObjectMacro(LineProperty, vtkProperty);
205 vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
207
208protected:
210 ~vtkLineWidget() override;
211
212 // Manage the state of the widget
213 friend class vtkPWCallback;
214
215 int State;
217 {
218 Start = 0,
222 Outside
223 };
224
225 // handles the events
226 static void ProcessEvents(
227 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
228
229 // ProcessEvents() dispatches to these methods.
236 virtual void OnMouseMove();
237
238 // controlling ivars
239 int Align;
240
242 {
246 None
247 };
248
249 // the line
253 void HighlightLine(int highlight);
254
255 // glyphs representing hot spots (e.g., handles)
259
261 void SizeHandles() override;
262 void HandlesOn(double length);
264 int HighlightHandle(vtkProp* prop); // returns cell id
265 void HighlightHandles(int highlight);
266
267 // Do the picking
271 double LastPosition[3];
272 void SetLinePosition(double x[3]);
273
274 // Register internal Pickers within PickingManager
275 void RegisterPickers() override;
276
277 // Methods to manipulate the hexahedron.
278 void Scale(double* p1, double* p2, int X, int Y);
279
280 // Initial bounds
282 void ClampPosition(double x[3]);
283 int InBounds(double x[3]);
284
285 // Properties used to control the appearance of selected objects and
286 // the manipulator in general.
292
294
295 // Methods for managing the point widgets used to control the endpoints
299 vtkPWCallback* PWCallback;
300 vtkPW1Callback* PW1Callback;
301 vtkPW2Callback* PW2Callback;
305 int ForwardEvent(unsigned long event);
306
307private:
308 vtkLineWidget(const vtkLineWidget&) = delete;
309 void operator=(const vtkLineWidget&) = delete;
310};
311
312#endif
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:68
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:73
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:67
represent surface properties of a geometric object
Definition: vtkProperty.h:171
create a polygonal sphere centered at the origin
@ length
Definition: vtkX3D.h:399
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_SIZEHINT(...)