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 =========================================================================*/
79 #ifndef __vtkLineWidget_h
80 #define __vtkLineWidget_h
81 
82 #include "vtk3DWidget.h"
83 #include "vtkLineSource.h" // For passing calls to it
84 
85 class vtkActor;
86 class vtkPolyDataMapper;
87 class vtkPoints;
88 class vtkPolyData;
89 class vtkProp;
90 class vtkProperty;
91 class vtkSphereSource;
92 class vtkCellPicker;
93 class vtkPointWidget;
94 class vtkPWCallback;
95 class vtkPW1Callback;
96 class vtkPW2Callback;
97 
99 {
100 public:
102  static vtkLineWidget *New();
103 
104  vtkTypeMacro(vtkLineWidget,vtk3DWidget);
105  void PrintSelf(ostream& os, vtkIndent indent);
106 
108 
109  virtual void SetEnabled(int);
110  virtual void PlaceWidget(double bounds[6]);
111  void PlaceWidget()
112  {this->Superclass::PlaceWidget();}
113  void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
114  double zmin, double zmax)
115  {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
117 
119 
120  void SetResolution(int r)
121  { this->LineSource->SetResolution(r); }
122  int GetResolution()
123  { return this->LineSource->GetResolution(); }
125 
127 
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);}
136 
138 
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);}
147 
149 
153  vtkSetClampMacro(Align, int, XAxis, None);
154  vtkGetMacro(Align, int);
155  void SetAlignToXAxis() { this->SetAlign(XAxis); }
156  void SetAlignToYAxis() { this->SetAlign(YAxis); }
157  void SetAlignToZAxis() { this->SetAlign(ZAxis); }
158  void SetAlignToNone() { this->SetAlign(None); }
160 
162 
166  vtkSetMacro(ClampToBounds,int);
167  vtkGetMacro(ClampToBounds,int);
168  vtkBooleanMacro(ClampToBounds,int);
170 
176  void GetPolyData(vtkPolyData *pd);
177 
179 
182  vtkGetObjectMacro(HandleProperty,vtkProperty);
183  vtkGetObjectMacro(SelectedHandleProperty,vtkProperty);
185 
187 
189  vtkGetObjectMacro(LineProperty,vtkProperty);
190  vtkGetObjectMacro(SelectedLineProperty,vtkProperty);
192 
193 protected:
194  vtkLineWidget();
195  ~vtkLineWidget();
196 
197 //BTX - manage the state of the widget
198  friend class vtkPWCallback;
199 
200  int State;
202  {
203  Start=0,
207  Outside
208  };
209 //ETX
210 
211  //handles the events
212  static void ProcessEvents(vtkObject* object,
213  unsigned long event,
214  void* clientdata,
215  void* calldata);
216 
217  // ProcessEvents() dispatches to these methods.
218  void OnLeftButtonDown();
219  void OnLeftButtonUp();
220  void OnMiddleButtonDown();
221  void OnMiddleButtonUp();
222  void OnRightButtonDown();
223  void OnRightButtonUp();
224  virtual void OnMouseMove();
225 
226  // controlling ivars
227  int Align;
228 
229 //BTX
234  None
235  };
236 //ETX
237 
238  // the line
242  void HighlightLine(int highlight);
243 
244  // glyphs representing hot spots (e.g., handles)
248 
249  void BuildRepresentation();
250  virtual void SizeHandles();
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
260  double LastPosition[3];
261  void SetLinePosition(double x[3]);
262 
263  // Methods to manipulate the hexahedron.
264  void Scale(double *p1, double *p2, int X, int Y);
265 
266  // Initial bounds
268  void ClampPosition(double x[3]);
269  int InBounds(double x[3]);
270 
271  // Properties used to control the appearance of selected objects and
272  // the manipulator in general.
277  void CreateDefaultProperties();
278 
279  void GenerateLine();
280 
281  // Methods for managing the point widgets used to control the endpoints
285  vtkPWCallback *PWCallback;
286  vtkPW1Callback *PW1Callback;
287  vtkPW2Callback *PW2Callback;
289  void EnablePointWidget();
290  void DisablePointWidget();
291  int ForwardEvent(unsigned long event);
292 
293 private:
294  vtkLineWidget(const vtkLineWidget&); //Not implemented
295  void operator=(const vtkLineWidget&); //Not implemented
296 };
297 
298 #endif