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 =========================================================================*/
75 #ifndef vtkLineWidget_h
76 #define vtkLineWidget_h
77 
78 #include "vtkInteractionWidgetsModule.h" // For export macro
79 #include "vtk3DWidget.h"
80 #include "vtkLineSource.h" // For passing calls to it
81 
82 class vtkActor;
83 class vtkPolyDataMapper;
84 class vtkPoints;
85 class vtkPolyData;
86 class vtkProp;
87 class vtkProperty;
88 class vtkSphereSource;
89 class vtkCellPicker;
90 class vtkPointWidget;
91 class vtkPWCallback;
92 class vtkPW1Callback;
93 class vtkPW2Callback;
94 
96 {
97 public:
99  static vtkLineWidget *New();
100 
101  vtkTypeMacro(vtkLineWidget,vtk3DWidget);
102  void PrintSelf(ostream& os, vtkIndent indent);
103 
105 
106  virtual void SetEnabled(int);
107  virtual void PlaceWidget(double bounds[6]);
108  void PlaceWidget()
109  {this->Superclass::PlaceWidget();}
110  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
111  double zmin, double zmax)
112  {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
114 
116 
117  void SetResolution(int r)
118  { this->LineSource->SetResolution(r); }
120  { return this->LineSource->GetResolution(); }
122 
124 
125  void SetPoint1(double x, double y, double z);
126  void SetPoint1(double x[3])
127  {this->SetPoint1(x[0], x[1], x[2]); }
128  double* GetPoint1()
129  {return this->LineSource->GetPoint1();}
130  void GetPoint1(double xyz[3])
131  {this->LineSource->GetPoint1(xyz);}
133 
135 
136  void SetPoint2(double x, double y, double z);
137  void SetPoint2(double x[3])
138  {this->SetPoint2(x[0], x[1], x[2]);}
139  double* GetPoint2()
140  {return this->LineSource->GetPoint2();}
141  void GetPoint2(double xyz[3])
142  {this->LineSource->GetPoint2(xyz);}
144 
146 
150  vtkSetClampMacro(Align, int, XAxis, None);
151  vtkGetMacro(Align, int);
152  void SetAlignToXAxis() { this->SetAlign(XAxis); }
153  void SetAlignToYAxis() { this->SetAlign(YAxis); }
154  void SetAlignToZAxis() { this->SetAlign(ZAxis); }
155  void SetAlignToNone() { this->SetAlign(None); }
157 
159 
163  vtkSetMacro(ClampToBounds,int);
164  vtkGetMacro(ClampToBounds,int);
165  vtkBooleanMacro(ClampToBounds,int);
167 
173  void GetPolyData(vtkPolyData *pd);
174 
176 
179  vtkGetObjectMacro(HandleProperty,vtkProperty);
180  vtkGetObjectMacro(SelectedHandleProperty,vtkProperty);
182 
184 
186  vtkGetObjectMacro(LineProperty,vtkProperty);
187  vtkGetObjectMacro(SelectedLineProperty,vtkProperty);
189 
190 protected:
191  vtkLineWidget();
192  ~vtkLineWidget();
193 
194  // Manage the state of the widget
195  friend class vtkPWCallback;
196 
197  int State;
199  {
200  Start=0,
204  Outside
205  };
206 
207  //handles the events
208  static void ProcessEvents(vtkObject* object,
209  unsigned long event,
210  void* clientdata,
211  void* calldata);
212 
213  // ProcessEvents() dispatches to these methods.
214  void OnLeftButtonDown();
215  void OnLeftButtonUp();
216  void OnMiddleButtonDown();
217  void OnMiddleButtonUp();
218  void OnRightButtonDown();
219  void OnRightButtonUp();
220  virtual void OnMouseMove();
221 
222  // controlling ivars
223  int Align;
224 
229  None
230  };
231 
232  // the line
236  void HighlightLine(int highlight);
237 
238  // glyphs representing hot spots (e.g., handles)
242 
243  void BuildRepresentation();
244  virtual void SizeHandles();
245  void HandlesOn(double length);
246  void HandlesOff();
247  int HighlightHandle(vtkProp *prop); //returns cell id
248  void HighlightHandles(int highlight);
249 
250  // Do the picking
254  double LastPosition[3];
255  void SetLinePosition(double x[3]);
256 
257  // Register internal Pickers within PickingManager
258  virtual void RegisterPickers();
259 
260  // Methods to manipulate the hexahedron.
261  void Scale(double *p1, double *p2, int X, int Y);
262 
263  // Initial bounds
265  void ClampPosition(double x[3]);
266  int InBounds(double x[3]);
267 
268  // Properties used to control the appearance of selected objects and
269  // the manipulator in general.
274  void CreateDefaultProperties();
275 
276  void GenerateLine();
277 
278  // Methods for managing the point widgets used to control the endpoints
282  vtkPWCallback *PWCallback;
283  vtkPW1Callback *PW1Callback;
284  vtkPW2Callback *PW2Callback;
286  void EnablePointWidget();
287  void DisablePointWidget();
288  int ForwardEvent(unsigned long event);
289 
290 private:
291  vtkLineWidget(const vtkLineWidget&); //Not implemented
292  void operator=(const vtkLineWidget&); //Not implemented
293 };
294 
295 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:52
double * GetPoint1()
vtkProperty * LineProperty
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:50
abstract base class for most VTK objects
Definition: vtkObject.h:61
void PlaceWidget(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
void SetAlignToZAxis()
represent surface properties of a geometric object
Definition: vtkProperty.h:63
vtkLineSource * LineSource
vtkProperty * SelectedLineProperty
vtkActor * LineActor
static void ProcessEvents(vtkObject *object, unsigned long event, void *clientdata, void *calldata)
virtual void SetEnabled(int)
void GetPoint2(double xyz[3])
vtkPointWidget * PointWidget
vtkPWCallback * PWCallback
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
void SetAlignToXAxis()
void PlaceWidget()
vtkPW2Callback * PW2Callback
virtual void RegisterPickers()
#define VTKINTERACTIONWIDGETS_EXPORT
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:38
vtkPW1Callback * PW1Callback
void SetPoint2(double x[3])
void SetAlignToYAxis()
vtkProperty * SelectedHandleProperty
3D widget for manipulating a line
Definition: vtkLineWidget.h:95
void SetAlignToNone()
vtkPolyDataMapper ** HandleMapper
vtkActor * CurrentHandle
create a line defined by two end points
Definition: vtkLineSource.h:41
map vtkPolyData to graphics primitives
position a point in 3D space
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:68
void SetResolution(int r)
void SetPoint1(double x[3])
double * GetPoint2()
vtkCellPicker * LinePicker
vtkActor ** Handle
vtkSphereSource ** HandleGeometry
static vtkObject * New()
vtkPolyDataMapper * LineMapper
void PrintSelf(ostream &os, vtkIndent indent)
an abstract superclass for 3D widgets
Definition: vtk3DWidget.h:69
virtual void SizeHandles()
Definition: vtk3DWidget.h:145
virtual void PlaceWidget()
vtkCellPicker * HandlePicker
vtkProperty * HandleProperty
represent and manipulate 3D points
Definition: vtkPoints.h:38
vtkPointWidget * CurrentPointWidget