VTK  9.1.0
vtkBrokenLineWidget.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: vtkBrokenLineWidget.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=========================================================================*/
88#ifndef vtkBrokenLineWidget_h
89#define vtkBrokenLineWidget_h
90
91#include "vtk3DWidget.h"
92#include "vtkInteractionWidgetsModule.h" // For export macro
93
94class vtkActor;
95class vtkCellPicker;
96class vtkLineSource;
97class vtkPlaneSource;
98class vtkPoints;
99class vtkPolyData;
101class vtkProp;
102class vtkProperty;
103class vtkSphereSource;
104class vtkTransform;
105
106#define VTK_PROJECTION_YZ 0
107#define VTK_PROJECTION_XZ 1
108#define VTK_PROJECTION_XY 2
109#define VTK_PROJECTION_OBLIQUE 3
110
111class VTKINTERACTIONWIDGETS_EXPORT vtkBrokenLineWidget : public vtk3DWidget
112{
113public:
118
120 void PrintSelf(ostream& os, vtkIndent indent) override;
121
123
126 void SetEnabled(int) override;
127 void PlaceWidget(double bounds[6]) override;
128 void PlaceWidget() override { this->Superclass::PlaceWidget(); }
130 double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
131 {
132 this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
133 }
135
137
145 vtkSetMacro(ProjectToPlane, vtkTypeBool);
146 vtkGetMacro(ProjectToPlane, vtkTypeBool);
147 vtkBooleanMacro(ProjectToPlane, vtkTypeBool);
149
155
156 vtkSetClampMacro(ProjectionNormal, int, VTK_PROJECTION_YZ, VTK_PROJECTION_OBLIQUE);
157 vtkGetMacro(ProjectionNormal, int);
158 void SetProjectionNormalToXAxes() { this->SetProjectionNormal(0); }
159 void SetProjectionNormalToYAxes() { this->SetProjectionNormal(1); }
160 void SetProjectionNormalToZAxes() { this->SetProjectionNormal(2); }
161 void SetProjectionNormalToOblique() { this->SetProjectionNormal(3); }
162
164
171 void SetProjectionPosition(double position);
172 vtkGetMacro(ProjectionPosition, double);
174
183
185
190 vtkGetObjectMacro(HandleProperty, vtkProperty);
192 vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
194
196
201 vtkGetObjectMacro(LineProperty, vtkProperty);
203 vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
205
207
210 virtual void SetNumberOfHandles(int npts);
211 vtkGetMacro(NumberOfHandles, int);
213
215
219 void SetHandlePosition(int handle, double x, double y, double z);
220 void SetHandlePosition(int handle, double xyz[3]);
221 void GetHandlePosition(int handle, double xyz[3]);
222 double* GetHandlePosition(int handle);
224
229
235
237
241 vtkSetClampMacro(ProcessEvents, vtkTypeBool, 0, 1);
242 vtkGetMacro(ProcessEvents, vtkTypeBool);
243 vtkBooleanMacro(ProcessEvents, vtkTypeBool);
245
247
251 vtkSetClampMacro(HandleSizeFactor, double, 0., 100.);
252 vtkGetMacro(HandleSizeFactor, double);
254
255protected:
258
259 // Manage the state of the widget
260 int State;
262 {
263 Start = 0,
269 Outside
270 };
271
272 // handles the events
274 vtkObject* object, unsigned long event, void* clientdata, void* calldata);
275
276 // ProcessEventsHandler() dispatches to these methods.
284
285 // Controlling vars
290
291 // Projection capabilities
295
296 // The broken line
300 void HighlightLine(int highlight);
303
304 // Glyphs representing hot spots (e.g., handles)
308 int HighlightHandle(vtkProp* prop); // returns handle index or -1 on fail
309 void SizeHandles() override;
310 void InsertHandleOnLine(double* pos);
311 void EraseHandle(const int&);
312
313 // Do the picking
318
319 // Register internal Pickers within PickingManager
320 void RegisterPickers() override;
321
322 // Methods to manipulate the broken line.
323 void MovePoint(double* p1, double* p2);
324 void Scale(double* p1, double* p2, int X, int Y);
325 void Translate(double* p1, double* p2);
326 void Spin(double* p1, double* p2, double* vpn);
327
328 // Transform the control points (used for spinning)
330
331 // Properties used to control the appearance of selected objects and
332 // the manipulator in general.
338
339 // For efficient spinning
340 double Centroid[3];
343
344 // Handle sizing factor
346
347private:
349 void operator=(const vtkBrokenLineWidget&) = delete;
350};
351
352#endif
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:71
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:155
3D widget for manipulating a broken line
double GetSummedLength()
Get the summed lengths of the individual straight line segments.
void EraseHandle(const int &)
void InsertHandleOnLine(double *pos)
int HighlightHandle(vtkProp *prop)
double * GetHandlePosition(int handle)
Set/Get the position of the broken line handles.
vtkProperty * SelectedLineProperty
vtkProperty * HandleProperty
static void ProcessEventsHandler(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
vtkPolyDataMapper * LineMapper
vtkSphereSource ** HandleGeometry
virtual void SetSelectedLineProperty(vtkProperty *)
Set/Get the line properties.
virtual void SetHandleProperty(vtkProperty *)
Set/Get the handle properties (the spheres are the handles).
void SetHandlePosition(int handle, double x, double y, double z)
Set/Get the position of the broken line handles.
void InitializeHandles(vtkPoints *points)
Convenience method to allocate and set the handles from a vtkPoints instance.
vtkPlaneSource * PlaneSource
void ProjectPointsToObliquePlane()
~vtkBrokenLineWidget() override
void SetPlaneSource(vtkPlaneSource *plane)
Set up a reference to a vtkPlaneSource that could be from another widget object, e....
void SetProjectionPosition(double position)
Set the position of broken line handles and points in terms of a plane's position.
void GetPolyData(vtkPolyData *pd)
Grab the polydata (including points) that defines the broken line.
void GetHandlePosition(int handle, double xyz[3])
Set/Get the position of the broken line handles.
virtual void SetSelectedHandleProperty(vtkProperty *)
Set/Get the handle properties (the spheres are the handles).
void Spin(double *p1, double *p2, double *vpn)
static vtkBrokenLineWidget * New()
Instantiate the object.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetEnabled(int) override
Methods that satisfy the superclass' API.
void Translate(double *p1, double *p2)
vtkLineSource * LineSource
void CreateDefaultProperties()
void SetHandlePosition(int handle, double xyz[3])
Set/Get the position of the broken line handles.
void RegisterPickers() override
Register internal Pickers in the Picking Manager.
void HighlightLine(int highlight)
void PlaceWidget(double bounds[6]) override
Methods that satisfy the superclass' API.
virtual void SetNumberOfHandles(int npts)
Set/Get the number of handles for this widget.
void Scale(double *p1, double *p2, int X, int Y)
void ProjectPointsToOrthoPlane()
void PlaceWidget() override
Methods that satisfy the superclass' API.
vtkCellPicker * HandlePicker
virtual void SetLineProperty(vtkProperty *)
Set/Get the line properties.
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
Methods that satisfy the superclass' API.
void MovePoint(double *p1, double *p2)
void SizeHandles() override
vtkCellPicker * LinePicker
vtkProperty * SelectedHandleProperty
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
abstract base class for most VTK objects
Definition: vtkObject.h:82
create an array of quadrilaterals located in a plane
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:76
represent surface properties of a geometric object
Definition: vtkProperty.h:171
create a polygonal sphere centered at the origin
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:164
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_PROJECTION_YZ
#define VTK_PROJECTION_OBLIQUE