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