00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00095 #ifndef __vtkLineWidget_h
00096 #define __vtkLineWidget_h
00097
00098 #include "vtk3DWidget.h"
00099 #include "vtkLineSource.h"
00100
00101 class vtkActor;
00102 class vtkPolyDataMapper;
00103 class vtkPoints;
00104 class vtkPolyData;
00105 class vtkProp;
00106 class vtkProperty;
00107 class vtkSphereSource;
00108 class vtkCellPicker;
00109 class vtkPointWidget;
00110 class vtkPWCallback;
00111 class vtkPW1Callback;
00112 class vtkPW2Callback;
00113
00114 class VTK_HYBRID_EXPORT vtkLineWidget : public vtk3DWidget
00115 {
00116 public:
00118 static vtkLineWidget *New();
00119
00120 vtkTypeRevisionMacro(vtkLineWidget,vtk3DWidget);
00121 void PrintSelf(ostream& os, vtkIndent indent);
00122
00124
00125 virtual void SetEnabled(int);
00126 virtual void PlaceWidget(float bounds[6]);
00127 void PlaceWidget()
00128 {this->Superclass::PlaceWidget();}
00129 void PlaceWidget(float xmin, float xmax, float ymin, float ymax,
00130 float zmin, float zmax)
00131 {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
00133
00135
00136 void SetResolution(int r)
00137 { this->LineSource->SetResolution(r); }
00138 int GetResolution()
00139 { return this->LineSource->GetResolution(); }
00141
00143
00144 void SetPoint1(float x, float y, float z);
00145 void SetPoint1(float x[3])
00146 {this->SetPoint1(x[0], x[1], x[2]); }
00147 float* GetPoint1()
00148 {return this->LineSource->GetPoint1();}
00149 void GetPoint1(float xyz[3])
00150 {this->LineSource->GetPoint1(xyz);}
00152
00154
00155 void SetPoint2(float x, float y, float z);
00156 void SetPoint2(float x[3])
00157 {this->SetPoint2(x[0], x[1], x[2]);}
00158 float* GetPoint2()
00159 {return this->LineSource->GetPoint2();}
00160 void GetPoint2(float xyz[3])
00161 {this->LineSource->GetPoint2(xyz);}
00163
00165
00169 vtkSetClampMacro(Align, int, XAxis, None);
00170 vtkGetMacro(Align, int);
00171 void SetAlignToXAxis() { this->SetAlign(XAxis); }
00172 void SetAlignToYAxis() { this->SetAlign(YAxis); }
00173 void SetAlignToZAxis() { this->SetAlign(ZAxis); }
00174 void SetAlignToNone() { this->SetAlign(None); }
00176
00178
00182 vtkSetMacro(ClampToBounds,int);
00183 vtkGetMacro(ClampToBounds,int);
00184 vtkBooleanMacro(ClampToBounds,int);
00186
00192 void GetPolyData(vtkPolyData *pd);
00193
00195
00198 vtkGetObjectMacro(HandleProperty,vtkProperty);
00199 vtkGetObjectMacro(SelectedHandleProperty,vtkProperty);
00201
00203
00205 vtkGetObjectMacro(LineProperty,vtkProperty);
00206 vtkGetObjectMacro(SelectedLineProperty,vtkProperty);
00208
00209 protected:
00210 vtkLineWidget();
00211 ~vtkLineWidget();
00212
00213
00214 friend class vtkPWCallback;
00215
00216 int State;
00217 enum WidgetState
00218 {
00219 Start=0,
00220 MovingHandle,
00221 MovingLine,
00222 Scaling,
00223 Outside
00224 };
00225
00226
00227
00228 static void ProcessEvents(vtkObject* object,
00229 unsigned long event,
00230 void* clientdata,
00231 void* calldata);
00232
00233
00234 void OnLeftButtonDown();
00235 void OnLeftButtonUp();
00236 void OnMiddleButtonDown();
00237 void OnMiddleButtonUp();
00238 void OnRightButtonDown();
00239 void OnRightButtonUp();
00240 virtual void OnMouseMove();
00241
00242
00243 int Align;
00244
00245
00246 enum AlignmentState {
00247 XAxis,
00248 YAxis,
00249 ZAxis,
00250 None
00251 };
00252
00253
00254
00255 vtkActor *LineActor;
00256 vtkPolyDataMapper *LineMapper;
00257 vtkLineSource *LineSource;
00258 void HighlightLine(int highlight);
00259
00260
00261 vtkActor **Handle;
00262 vtkPolyDataMapper **HandleMapper;
00263 vtkSphereSource **HandleGeometry;
00264
00265 void BuildRepresentation();
00266 virtual void SizeHandles();
00267 void HandlesOn(double length);
00268 void HandlesOff();
00269 int HighlightHandle(vtkProp *prop);
00270 void HighlightHandles(int highlight);
00271
00272
00273 vtkCellPicker *HandlePicker;
00274 vtkCellPicker *LinePicker;
00275 vtkActor *CurrentHandle;
00276 float LastPosition[3];
00277 void SetLinePosition(float x[3]);
00278
00279
00280 void Scale(double *p1, double *p2, int X, int Y);
00281
00282
00283 int ClampToBounds;
00284 void ClampPosition(float x[3]);
00285 int InBounds(float x[3]);
00286
00287
00288
00289 vtkProperty *HandleProperty;
00290 vtkProperty *SelectedHandleProperty;
00291 vtkProperty *LineProperty;
00292 vtkProperty *SelectedLineProperty;
00293 void CreateDefaultProperties();
00294
00295 void GenerateLine();
00296
00297
00298 vtkPointWidget *PointWidget;
00299 vtkPointWidget *PointWidget1;
00300 vtkPointWidget *PointWidget2;
00301 vtkPWCallback *PWCallback;
00302 vtkPW1Callback *PW1Callback;
00303 vtkPW2Callback *PW2Callback;
00304 vtkPointWidget *CurrentPointWidget;
00305 void EnablePointWidget();
00306 void DisablePointWidget();
00307 int ForwardEvent(unsigned long event);
00308
00309 private:
00310 vtkLineWidget(const vtkLineWidget&);
00311 void operator=(const vtkLineWidget&);
00312 };
00313
00314 #endif