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