VTK  9.0.1
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 =========================================================================*/
82 #ifndef vtkBrokenLineWidget_h
83 #define vtkBrokenLineWidget_h
84 
85 #include "vtk3DWidget.h"
86 #include "vtkInteractionWidgetsModule.h" // For export macro
87 
88 class vtkActor;
89 class vtkCellPicker;
90 class vtkLineSource;
91 class vtkPlaneSource;
92 class vtkPoints;
93 class vtkPolyData;
94 class vtkPolyDataMapper;
95 class vtkProp;
96 class vtkProperty;
97 class vtkSphereSource;
98 class vtkTransform;
99 
100 #define VTK_PROJECTION_YZ 0
101 #define VTK_PROJECTION_XZ 1
102 #define VTK_PROJECTION_XY 2
103 #define VTK_PROJECTION_OBLIQUE 3
104 
105 class VTKINTERACTIONWIDGETS_EXPORT vtkBrokenLineWidget : public vtk3DWidget
106 {
107 public:
111  static vtkBrokenLineWidget* New();
112 
114  void PrintSelf(ostream& os, vtkIndent indent) override;
115 
117 
120  void SetEnabled(int) override;
121  void PlaceWidget(double bounds[6]) override;
122  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
124  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
125  {
126  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
127  }
129 
131 
139  vtkSetMacro(ProjectToPlane, vtkTypeBool);
140  vtkGetMacro(ProjectToPlane, vtkTypeBool);
141  vtkBooleanMacro(ProjectToPlane, vtkTypeBool);
143 
148  void SetPlaneSource(vtkPlaneSource* plane);
149 
150  vtkSetClampMacro(ProjectionNormal, int, VTK_PROJECTION_YZ, VTK_PROJECTION_OBLIQUE);
151  vtkGetMacro(ProjectionNormal, int);
152  void SetProjectionNormalToXAxes() { this->SetProjectionNormal(0); }
153  void SetProjectionNormalToYAxes() { this->SetProjectionNormal(1); }
154  void SetProjectionNormalToZAxes() { this->SetProjectionNormal(2); }
155  void SetProjectionNormalToOblique() { this->SetProjectionNormal(3); }
156 
158 
165  void SetProjectionPosition(double position);
166  vtkGetMacro(ProjectionPosition, double);
168 
176  void GetPolyData(vtkPolyData* pd);
177 
179 
183  virtual void SetHandleProperty(vtkProperty*);
184  vtkGetObjectMacro(HandleProperty, vtkProperty);
185  virtual void SetSelectedHandleProperty(vtkProperty*);
186  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
188 
190 
194  virtual void SetLineProperty(vtkProperty*);
195  vtkGetObjectMacro(LineProperty, vtkProperty);
196  virtual void SetSelectedLineProperty(vtkProperty*);
197  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
199 
201 
204  virtual void SetNumberOfHandles(int npts);
205  vtkGetMacro(NumberOfHandles, int);
207 
209 
213  void SetHandlePosition(int handle, double x, double y, double z);
214  void SetHandlePosition(int handle, double xyz[3]);
215  void GetHandlePosition(int handle, double xyz[3]);
216  double* GetHandlePosition(int handle);
218 
222  double GetSummedLength();
223 
228  void InitializeHandles(vtkPoints* points);
229 
231 
235  vtkSetClampMacro(ProcessEvents, vtkTypeBool, 0, 1);
236  vtkGetMacro(ProcessEvents, vtkTypeBool);
237  vtkBooleanMacro(ProcessEvents, vtkTypeBool);
239 
241 
245  vtkSetClampMacro(HandleSizeFactor, double, 0., 100.);
246  vtkGetMacro(HandleSizeFactor, double);
248 
249 protected:
251  ~vtkBrokenLineWidget() override;
252 
253  // Manage the state of the widget
254  int State;
256  {
257  Start = 0,
263  Outside
264  };
265 
266  // handles the events
267  static void ProcessEventsHandler(
268  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
269 
270  // ProcessEventsHandler() dispatches to these methods.
271  void OnLeftButtonDown();
272  void OnLeftButtonUp();
273  void OnMiddleButtonDown();
274  void OnMiddleButtonUp();
275  void OnRightButtonDown();
276  void OnRightButtonUp();
277  void OnMouseMove();
278 
279  // Controlling vars
284 
285  // Projection capabilities
286  void ProjectPointsToPlane();
287  void ProjectPointsToOrthoPlane();
288  void ProjectPointsToObliquePlane();
289 
290  // The broken line
294  void HighlightLine(int highlight);
296  void BuildRepresentation();
297 
298  // Glyphs representing hot spots (e.g., handles)
301  void Initialize();
302  int HighlightHandle(vtkProp* prop); // returns handle index or -1 on fail
303  void SizeHandles() override;
304  void InsertHandleOnLine(double* pos);
305  void EraseHandle(const int&);
306 
307  // Do the picking
312 
313  // Register internal Pickers within PickingManager
314  void RegisterPickers() override;
315 
316  // Methods to manipulate the broken line.
317  void MovePoint(double* p1, double* p2);
318  void Scale(double* p1, double* p2, int X, int Y);
319  void Translate(double* p1, double* p2);
320  void Spin(double* p1, double* p2, double* vpn);
321 
322  // Transform the control points (used for spinning)
324 
325  // Properties used to control the appearance of selected objects and
326  // the manipulator in general.
331  void CreateDefaultProperties();
332 
333  // For efficient spinning
334  double Centroid[3];
335  void CalculateCentroid();
337 
338  // Handle sizing factor
340 
341 private:
342  vtkBrokenLineWidget(const vtkBrokenLineWidget&) = delete;
343  void operator=(const vtkBrokenLineWidget&) = delete;
344 };
345 
346 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:47
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
3D widget for manipulating a broken line
abstract base class for most VTK objects
Definition: vtkObject.h:53
represent surface properties of a geometric object
Definition: vtkProperty.h:61
vtkProperty * SelectedHandleProperty
vtkCellPicker * HandlePicker
vtkPolyDataMapper * LineMapper
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:54
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkSphereSource ** HandleGeometry
#define VTK_PROJECTION_YZ
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
int vtkTypeBool
Definition: vtkABI.h:69
create a polygonal sphere centered at the origin
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkProperty * HandleProperty
vtkProperty * SelectedLineProperty
void PlaceWidget() override
Methods that satisfy the superclass' API.
create an array of quadrilaterals located in a plane
create a line defined by two end points
Definition: vtkLineSource.h:60
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
Methods that satisfy the superclass' API.
map vtkPolyData to graphics primitives
vtkCellPicker * LinePicker
vtkPlaneSource * PlaneSource
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:66
vtkLineSource * LineSource
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:67
virtual void SizeHandles()
Definition: vtk3DWidget.h:152
virtual void PlaceWidget()
This method is used to initially place the widget.
represent and manipulate 3D points
Definition: vtkPoints.h:33
#define VTK_PROJECTION_OBLIQUE