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 =========================================================================*/
73 #ifndef vtkLineWidget_h
74 #define vtkLineWidget_h
75 
76 #include "vtkInteractionWidgetsModule.h" // For export macro
77 #include "vtk3DWidget.h"
78 #include "vtkLineSource.h" // For passing calls to it
79 
80 class vtkActor;
81 class vtkPolyDataMapper;
82 class vtkPoints;
83 class vtkPolyData;
84 class vtkProp;
85 class vtkProperty;
86 class vtkSphereSource;
87 class vtkCellPicker;
88 class vtkPointWidget;
89 class vtkPWCallback;
90 class vtkPW1Callback;
91 class vtkPW2Callback;
92 
93 class VTKINTERACTIONWIDGETS_EXPORT vtkLineWidget : public vtk3DWidget
94 {
95 public:
99  static vtkLineWidget *New();
100 
101  vtkTypeMacro(vtkLineWidget,vtk3DWidget);
102  void PrintSelf(ostream& os, vtkIndent indent);
103 
105 
108  virtual void SetEnabled(int);
109  virtual void PlaceWidget(double bounds[6]);
110  void PlaceWidget()
111  {this->Superclass::PlaceWidget();}
112  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
113  double zmin, double zmax)
114  {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
116 
120  void SetResolution(int r)
121  { this->LineSource->SetResolution(r); }
123  { return this->LineSource->GetResolution(); }
124 
128  void SetPoint1(double x, double y, double z);
129  void SetPoint1(double x[3])
130  {this->SetPoint1(x[0], x[1], x[2]); }
131  double* GetPoint1()
132  {return this->LineSource->GetPoint1();}
133  void GetPoint1(double xyz[3])
134  {this->LineSource->GetPoint1(xyz);}
135 
139  void SetPoint2(double x, double y, double z);
140  void SetPoint2(double x[3])
141  {this->SetPoint2(x[0], x[1], x[2]);}
142  double* GetPoint2()
143  {return this->LineSource->GetPoint2();}
144  void GetPoint2(double xyz[3])
145  {this->LineSource->GetPoint2(xyz);}
146 
148 
154  vtkSetClampMacro(Align, int, XAxis, None);
155  vtkGetMacro(Align, int);
156  void SetAlignToXAxis() { this->SetAlign(XAxis); }
157  void SetAlignToYAxis() { this->SetAlign(YAxis); }
158  void SetAlignToZAxis() { this->SetAlign(ZAxis); }
159  void SetAlignToNone() { this->SetAlign(None); }
161 
163 
169  vtkSetMacro(ClampToBounds,int);
170  vtkGetMacro(ClampToBounds,int);
171  vtkBooleanMacro(ClampToBounds,int);
173 
181  void GetPolyData(vtkPolyData *pd);
182 
184 
189  vtkGetObjectMacro(HandleProperty,vtkProperty);
190  vtkGetObjectMacro(SelectedHandleProperty,vtkProperty);
192 
194 
198  vtkGetObjectMacro(LineProperty,vtkProperty);
199  vtkGetObjectMacro(SelectedLineProperty,vtkProperty);
201 
202 protected:
203  vtkLineWidget();
204  ~vtkLineWidget();
205 
206  // Manage the state of the widget
207  friend class vtkPWCallback;
208 
209  int State;
211  {
212  Start=0,
216  Outside
217  };
218 
219  //handles the events
220  static void ProcessEvents(vtkObject* object,
221  unsigned long event,
222  void* clientdata,
223  void* calldata);
224 
225  // ProcessEvents() dispatches to these methods.
226  void OnLeftButtonDown();
227  void OnLeftButtonUp();
228  void OnMiddleButtonDown();
229  void OnMiddleButtonUp();
230  void OnRightButtonDown();
231  void OnRightButtonUp();
232  virtual void OnMouseMove();
233 
234  // controlling ivars
235  int Align;
236 
241  None
242  };
243 
244  // the line
248  void HighlightLine(int highlight);
249 
250  // glyphs representing hot spots (e.g., handles)
254 
255  void BuildRepresentation();
256  virtual void SizeHandles();
257  void HandlesOn(double length);
258  void HandlesOff();
259  int HighlightHandle(vtkProp *prop); //returns cell id
260  void HighlightHandles(int highlight);
261 
262  // Do the picking
266  double LastPosition[3];
267  void SetLinePosition(double x[3]);
268 
269  // Register internal Pickers within PickingManager
270  virtual void RegisterPickers();
271 
272  // Methods to manipulate the hexahedron.
273  void Scale(double *p1, double *p2, int X, int Y);
274 
275  // Initial bounds
277  void ClampPosition(double x[3]);
278  int InBounds(double x[3]);
279 
280  // Properties used to control the appearance of selected objects and
281  // the manipulator in general.
286  void CreateDefaultProperties();
287 
288  void GenerateLine();
289 
290  // Methods for managing the point widgets used to control the endpoints
294  vtkPWCallback *PWCallback;
295  vtkPW1Callback *PW1Callback;
296  vtkPW2Callback *PW2Callback;
298  void EnablePointWidget();
299  void DisablePointWidget();
300  int ForwardEvent(unsigned long event);
301 
302 private:
303  vtkLineWidget(const vtkLineWidget&) VTK_DELETE_FUNCTION;
304  void operator=(const vtkLineWidget&) VTK_DELETE_FUNCTION;
305 };
306 
307 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:50
double * GetPoint1()
vtkProperty * LineProperty
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:51
abstract base class for most VTK objects
Definition: vtkObject.h:59
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
Methods that satisfy the superclass' API.
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:64
vtkLineSource * LineSource
vtkProperty * SelectedLineProperty
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])
vtkPointWidget * PointWidget
vtkPWCallback * PWCallback
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
void SetAlignToXAxis()
Force the line widget to be aligned with one of the x-y-z axes.
void PlaceWidget()
Methods that satisfy the superclass' API.
vtkPW2Callback * PW2Callback
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
create a polygonal sphere centered at the origin
vtkPointWidget * PointWidget2
void GetPoint1(double xyz[3])
vtkPointWidget * PointWidget1
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkPW1Callback * PW1Callback
void SetPoint2(double x[3])
void SetAlignToYAxis()
Force the line widget to be aligned with one of the x-y-z axes.
vtkProperty * SelectedHandleProperty
3D widget for manipulating a line
Definition: vtkLineWidget.h:93
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.
vtkActor * CurrentHandle
create a line defined by two end points
Definition: vtkLineSource.h:42
map vtkPolyData to graphics primitives
position a point in 3D space
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:69
void SetResolution(int r)
Set/Get the resolution (number of subdivisions) of the line.
void SetPoint1(double x[3])
double * GetPoint2()
vtkCellPicker * LinePicker
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
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
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.
vtkCellPicker * HandlePicker
vtkProperty * HandleProperty
represent and manipulate 3D points
Definition: vtkPoints.h:39
vtkPointWidget * CurrentPointWidget