VTK  9.0.3
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 =========================================================================*/
67 #ifndef vtkLineWidget_h
68 #define vtkLineWidget_h
69 
70 #include "vtk3DWidget.h"
71 #include "vtkInteractionWidgetsModule.h" // For export macro
72 #include "vtkLineSource.h" // For passing calls to it
73 
74 class vtkActor;
75 class vtkPolyDataMapper;
76 class vtkPoints;
77 class vtkPolyData;
78 class vtkProp;
79 class vtkProperty;
80 class vtkSphereSource;
81 class vtkCellPicker;
82 class vtkPointWidget;
83 class vtkPWCallback;
84 class vtkPW1Callback;
85 class vtkPW2Callback;
86 
87 class VTKINTERACTIONWIDGETS_EXPORT vtkLineWidget : public vtk3DWidget
88 {
89 public:
93  static vtkLineWidget* New();
94 
95  vtkTypeMacro(vtkLineWidget, vtk3DWidget);
96  void PrintSelf(ostream& os, vtkIndent indent) override;
97 
99 
102  void SetEnabled(int) override;
103  void PlaceWidget(double bounds[6]) override;
104  void PlaceWidget() override { this->Superclass::PlaceWidget(); }
106  double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
107  {
108  this->Superclass::PlaceWidget(xmin, xmax, ymin, ymax, zmin, zmax);
109  }
111 
115  void SetResolution(int r) { this->LineSource->SetResolution(r); }
116  int GetResolution() { return this->LineSource->GetResolution(); }
117 
121  void SetPoint1(double x, double y, double z);
122  void SetPoint1(double x[3]) { this->SetPoint1(x[0], x[1], x[2]); }
123  double* GetPoint1() VTK_SIZEHINT(3) { return this->LineSource->GetPoint1(); }
124  void GetPoint1(double xyz[3]) { this->LineSource->GetPoint1(xyz); }
125 
129  void SetPoint2(double x, double y, double z);
130  void SetPoint2(double x[3]) { this->SetPoint2(x[0], x[1], x[2]); }
131  double* GetPoint2() VTK_SIZEHINT(3) { return this->LineSource->GetPoint2(); }
132  void GetPoint2(double xyz[3]) { this->LineSource->GetPoint2(xyz); }
133 
135 
141  vtkSetClampMacro(Align, int, XAxis, None);
142  vtkGetMacro(Align, int);
143  void SetAlignToXAxis() { this->SetAlign(XAxis); }
144  void SetAlignToYAxis() { this->SetAlign(YAxis); }
145  void SetAlignToZAxis() { this->SetAlign(ZAxis); }
146  void SetAlignToNone() { this->SetAlign(None); }
148 
150 
156  vtkSetMacro(ClampToBounds, vtkTypeBool);
157  vtkGetMacro(ClampToBounds, vtkTypeBool);
158  vtkBooleanMacro(ClampToBounds, vtkTypeBool);
160 
169 
171 
176  vtkGetObjectMacro(HandleProperty, vtkProperty);
177  vtkGetObjectMacro(SelectedHandleProperty, vtkProperty);
179 
181 
185  vtkGetObjectMacro(LineProperty, vtkProperty);
186  vtkGetObjectMacro(SelectedLineProperty, vtkProperty);
188 
189 protected:
191  ~vtkLineWidget() override;
192 
193  // Manage the state of the widget
194  friend class vtkPWCallback;
195 
196  int State;
198  {
199  Start = 0,
203  Outside
204  };
205 
206  // handles the events
207  static void ProcessEvents(
208  vtkObject* object, unsigned long event, void* clientdata, void* calldata);
209 
210  // ProcessEvents() dispatches to these methods.
217  virtual void OnMouseMove();
218 
219  // controlling ivars
220  int Align;
221 
223  {
227  None
228  };
229 
230  // the line
234  void HighlightLine(int highlight);
235 
236  // glyphs representing hot spots (e.g., handles)
240 
242  void SizeHandles() override;
243  void HandlesOn(double length);
244  void HandlesOff();
245  int HighlightHandle(vtkProp* prop); // returns cell id
246  void HighlightHandles(int highlight);
247 
248  // Do the picking
252  double LastPosition[3];
253  void SetLinePosition(double x[3]);
254 
255  // Register internal Pickers within PickingManager
256  void RegisterPickers() override;
257 
258  // Methods to manipulate the hexahedron.
259  void Scale(double* p1, double* p2, int X, int Y);
260 
261  // Initial bounds
263  void ClampPosition(double x[3]);
264  int InBounds(double x[3]);
265 
266  // Properties used to control the appearance of selected objects and
267  // the manipulator in general.
273 
274  void GenerateLine();
275 
276  // Methods for managing the point widgets used to control the endpoints
280  vtkPWCallback* PWCallback;
281  vtkPW1Callback* PW1Callback;
282  vtkPW2Callback* PW2Callback;
286  int ForwardEvent(unsigned long event);
287 
288 private:
289  vtkLineWidget(const vtkLineWidget&) = delete;
290  void operator=(const vtkLineWidget&) = delete;
291 };
292 
293 #endif
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:68
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:88
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
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
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()
int ForwardEvent(unsigned long event)
void HandlesOn(double length)
vtkActor * LineActor
void GetPoint2(double xyz[3])
vtkPWCallback * PWCallback
void SetAlignToZAxis()
vtkPolyDataMapper * LineMapper
static vtkLineWidget * New()
Instantiate the object.
void SetLinePosition(double x[3])
void SetAlignToNone()
vtkPolyDataMapper ** HandleMapper
void OnMiddleButtonUp()
double * GetPoint1()
void HighlightHandles(int highlight)
void OnRightButtonUp()
void SetAlignToXAxis()
vtkProperty * HandleProperty
void GenerateLine()
int HighlightHandle(vtkProp *prop)
void OnLeftButtonDown()
double * GetPoint2()
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
This method is used to initially place the widget.
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])
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:54
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:48
represent surface properties of a geometric object
Definition: vtkProperty.h:62
create a polygonal sphere centered at the origin
@ length
Definition: vtkX3D.h:399
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_SIZEHINT(...)