VTK
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 "vtkInteractionWidgetsModule.h" // For export macro
71 #include "vtk3DWidget.h"
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) VTK_OVERRIDE;
97 
99 
102  void SetEnabled(int) VTK_OVERRIDE;
103  void PlaceWidget(double bounds[6]) VTK_OVERRIDE;
104  void PlaceWidget() VTK_OVERRIDE
105  {this->Superclass::PlaceWidget();}
106  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
107  double zmin, double zmax) VTK_OVERRIDE
108  {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
110 
114  void SetResolution(int r)
115  { this->LineSource->SetResolution(r); }
117  { return this->LineSource->GetResolution(); }
118 
122  void SetPoint1(double x, double y, double z);
123  void SetPoint1(double x[3])
124  {this->SetPoint1(x[0], x[1], x[2]); }
125  double* GetPoint1()
126  {return this->LineSource->GetPoint1();}
127  void GetPoint1(double xyz[3])
128  {this->LineSource->GetPoint1(xyz);}
129 
133  void SetPoint2(double x, double y, double z);
134  void SetPoint2(double x[3])
135  {this->SetPoint2(x[0], x[1], x[2]);}
136  double* GetPoint2()
137  {return this->LineSource->GetPoint2();}
138  void GetPoint2(double xyz[3])
139  {this->LineSource->GetPoint2(xyz);}
140 
142 
148  vtkSetClampMacro(Align, int, XAxis, None);
149  vtkGetMacro(Align, int);
150  void SetAlignToXAxis() { this->SetAlign(XAxis); }
151  void SetAlignToYAxis() { this->SetAlign(YAxis); }
152  void SetAlignToZAxis() { this->SetAlign(ZAxis); }
153  void SetAlignToNone() { this->SetAlign(None); }
155 
157 
163  vtkSetMacro(ClampToBounds,int);
164  vtkGetMacro(ClampToBounds,int);
165  vtkBooleanMacro(ClampToBounds,int);
167 
175  void GetPolyData(vtkPolyData *pd);
176 
178 
183  vtkGetObjectMacro(HandleProperty,vtkProperty);
184  vtkGetObjectMacro(SelectedHandleProperty,vtkProperty);
186 
188 
192  vtkGetObjectMacro(LineProperty,vtkProperty);
193  vtkGetObjectMacro(SelectedLineProperty,vtkProperty);
195 
196 protected:
197  vtkLineWidget();
198  ~vtkLineWidget() VTK_OVERRIDE;
199 
200  // Manage the state of the widget
201  friend class vtkPWCallback;
202 
203  int State;
205  {
206  Start=0,
210  Outside
211  };
212 
213  //handles the events
214  static void ProcessEvents(vtkObject* object,
215  unsigned long event,
216  void* clientdata,
217  void* calldata);
218 
219  // ProcessEvents() dispatches to these methods.
220  void OnLeftButtonDown();
221  void OnLeftButtonUp();
222  void OnMiddleButtonDown();
223  void OnMiddleButtonUp();
224  void OnRightButtonDown();
225  void OnRightButtonUp();
226  virtual void OnMouseMove();
227 
228  // controlling ivars
229  int Align;
230 
235  None
236  };
237 
238  // the line
242  void HighlightLine(int highlight);
243 
244  // glyphs representing hot spots (e.g., handles)
248 
249  void BuildRepresentation();
250  void SizeHandles() VTK_OVERRIDE;
251  void HandlesOn(double length);
252  void HandlesOff();
253  int HighlightHandle(vtkProp *prop); //returns cell id
254  void HighlightHandles(int highlight);
255 
256  // Do the picking
257  vtkCellPicker *HandlePicker;
258  vtkCellPicker *LinePicker;
259  vtkActor *CurrentHandle;
260  double LastPosition[3];
261  void SetLinePosition(double x[3]);
262 
263  // Register internal Pickers within PickingManager
264  void RegisterPickers() VTK_OVERRIDE;
265 
266  // Methods to manipulate the hexahedron.
267  void Scale(double *p1, double *p2, int X, int Y);
268 
269  // Initial bounds
270  int ClampToBounds;
271  void ClampPosition(double x[3]);
272  int InBounds(double x[3]);
273 
274  // Properties used to control the appearance of selected objects and
275  // the manipulator in general.
276  vtkProperty *HandleProperty;
277  vtkProperty *SelectedHandleProperty;
278  vtkProperty *LineProperty;
279  vtkProperty *SelectedLineProperty;
280  void CreateDefaultProperties();
281 
282  void GenerateLine();
283 
284  // Methods for managing the point widgets used to control the endpoints
285  vtkPointWidget *PointWidget;
286  vtkPointWidget *PointWidget1;
287  vtkPointWidget *PointWidget2;
288  vtkPWCallback *PWCallback;
289  vtkPW1Callback *PW1Callback;
290  vtkPW2Callback *PW2Callback;
291  vtkPointWidget *CurrentPointWidget;
292  void EnablePointWidget();
293  void DisablePointWidget();
294  int ForwardEvent(unsigned long event);
295 
296 private:
297  vtkLineWidget(const vtkLineWidget&) VTK_DELETE_FUNCTION;
298  void operator=(const vtkLineWidget&) VTK_DELETE_FUNCTION;
299 };
300 
301 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:44
double * GetPoint1()
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
abstract base class for most VTK objects
Definition: vtkObject.h:53
void SetAlignToZAxis()
Force the line widget to be aligned with one of the x-y-z axes.
represent surface properties of a geometric object
Definition: vtkProperty.h:58
vtkLineSource * LineSource
vtkActor * LineActor
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
Handles the char widget activation event.
virtual void SetEnabled(int)
Methods for turning the interactor observer on and off, and determining its state.
void GetPoint2(double xyz[3])
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
void SetAlignToXAxis()
Force the line widget to be aligned with one of the x-y-z axes.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
create a polygonal sphere centered at the origin
void GetPoint1(double xyz[3])
a simple class to control print indentation
Definition: vtkIndent.h:33
void SetPoint2(double x[3])
void SetAlignToYAxis()
Force the line widget to be aligned with one of the x-y-z axes.
3D widget for manipulating a line
Definition: vtkLineWidget.h:87
void SetAlignToNone()
Force the line widget to be aligned with one of the x-y-z axes.
vtkPolyDataMapper ** HandleMapper
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) override
Methods that satisfy the superclass' API.
create a line defined by two end points
Definition: vtkLineSource.h:36
map vtkPolyData to graphics primitives
position a point in 3D space
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:63
void SetResolution(int r)
Set/Get the resolution (number of subdivisions) of the line.
void SetPoint1(double x[3])
double * GetPoint2()
vtkActor ** Handle
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
vtkSphereSource ** HandleGeometry
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
vtkPolyDataMapper * LineMapper
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:67
virtual void SizeHandles()
Definition: vtk3DWidget.h:152
represent and manipulate 3D points
Definition: vtkPoints.h:33