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