00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00087 #ifndef __vtkImplicitPlaneWidget_h
00088 #define __vtkImplicitPlaneWidget_h
00089
00090 #include "vtkPolyDataSourceWidget.h"
00091
00092 class vtkActor;
00093 class vtkPolyDataMapper;
00094 class vtkCellPicker;
00095 class vtkConeSource;
00096 class vtkLineSource;
00097 class vtkSphereSource;
00098 class vtkTubeFilter;
00099 class vtkPlane;
00100 class vtkCutter;
00101 class vtkProperty;
00102 class vtkImageData;
00103 class vtkOutlineFilter;
00104 class vtkFeatureEdges;
00105 class vtkPolyData;
00106 class vtkTransform;
00107
00108 class VTK_HYBRID_EXPORT vtkImplicitPlaneWidget : public vtkPolyDataSourceWidget
00109 {
00110 public:
00112 static vtkImplicitPlaneWidget *New();
00113
00114 vtkTypeRevisionMacro(vtkImplicitPlaneWidget,vtkPolyDataSourceWidget);
00115 void PrintSelf(ostream& os, vtkIndent indent);
00116
00118
00119 virtual void SetEnabled(int);
00120 virtual void PlaceWidget(double bounds[6]);
00121 void PlaceWidget()
00122 {this->Superclass::PlaceWidget();}
00123 void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
00124 double zmin, double zmax)
00125 {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
00127
00129
00130 void SetOrigin(double x, double y, double z);
00131 void SetOrigin(double x[3]);
00132 double* GetOrigin();
00133 void GetOrigin(double xyz[3]);
00135
00137
00138 void SetNormal(double x, double y, double z);
00139 void SetNormal(double x[3]);
00140 double* GetNormal();
00141 void GetNormal(double xyz[3]);
00143
00145
00149 void SetNormalToXAxis(int);
00150 vtkGetMacro(NormalToXAxis,int);
00151 vtkBooleanMacro(NormalToXAxis,int);
00152 void SetNormalToYAxis(int);
00153 vtkGetMacro(NormalToYAxis,int);
00154 vtkBooleanMacro(NormalToYAxis,int);
00155 void SetNormalToZAxis(int);
00156 vtkGetMacro(NormalToZAxis,int);
00157 vtkBooleanMacro(NormalToZAxis,int);
00159
00161
00163 vtkSetMacro(Tubing,int);
00164 vtkGetMacro(Tubing,int);
00165 vtkBooleanMacro(Tubing,int);
00167
00169
00173 void SetDrawPlane(int plane);
00174 vtkGetMacro(DrawPlane,int);
00175 vtkBooleanMacro(DrawPlane,int);
00177
00179
00181 vtkSetMacro(OutlineTranslation,int);
00182 vtkGetMacro(OutlineTranslation,int);
00183 vtkBooleanMacro(OutlineTranslation,int);
00185
00188 void GetPolyData(vtkPolyData *pd);
00189
00192 vtkPolyDataSource* GetPolyDataSource();
00193
00198 void GetPlane(vtkPlane *plane);
00199
00203 void UpdatePlacement(void);
00204
00206
00207 vtkGetObjectMacro(NormalProperty,vtkProperty);
00208 vtkGetObjectMacro(SelectedNormalProperty,vtkProperty);
00210
00212
00214 vtkGetObjectMacro(PlaneProperty,vtkProperty);
00215 vtkGetObjectMacro(SelectedPlaneProperty,vtkProperty);
00217
00219
00220 vtkGetObjectMacro(OutlineProperty,vtkProperty);
00221 vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty);
00223
00225
00227 vtkGetObjectMacro(EdgesProperty,vtkProperty);
00229
00230 protected:
00231 vtkImplicitPlaneWidget();
00232 ~vtkImplicitPlaneWidget();
00233
00234
00235 int State;
00236 enum WidgetState
00237 {
00238 Start=0,
00239 MovingPlane,
00240 MovingOutline,
00241 MovingOrigin,
00242 Scaling,
00243 Pushing,
00244 Rotating,
00245 Outside
00246 };
00247
00248
00249
00250 static void ProcessEvents(vtkObject* object, unsigned long event,
00251 void* clientdata, void* calldata);
00252
00253
00254 void OnLeftButtonDown();
00255 void OnLeftButtonUp();
00256 void OnMiddleButtonDown();
00257 void OnMiddleButtonUp();
00258 void OnRightButtonDown();
00259 void OnRightButtonUp();
00260 void OnMouseMove();
00261
00262
00263 int NormalToXAxis;
00264 int NormalToYAxis;
00265 int NormalToZAxis;
00266 void UpdateRepresentation();
00267
00268
00269 vtkPlane *Plane;
00270
00271
00272 vtkImageData *Box;
00273 vtkOutlineFilter *Outline;
00274 vtkPolyDataMapper *OutlineMapper;
00275 vtkActor *OutlineActor;
00276 void HighlightOutline(int highlight);
00277 int OutlineTranslation;
00278
00279
00280 vtkCutter *Cutter;
00281 vtkPolyDataMapper *CutMapper;
00282 vtkActor *CutActor;
00283 int DrawPlane;
00284 void HighlightPlane(int highlight);
00285
00286
00287 vtkFeatureEdges *Edges;
00288 vtkTubeFilter *EdgesTuber;
00289 vtkPolyDataMapper *EdgesMapper;
00290 vtkActor *EdgesActor;
00291 int Tubing;
00292
00293
00294 vtkConeSource *ConeSource;
00295 vtkPolyDataMapper *ConeMapper;
00296 vtkActor *ConeActor;
00297 void HighlightNormal(int highlight);
00298
00299
00300 vtkLineSource *LineSource;
00301 vtkPolyDataMapper *LineMapper;
00302 vtkActor *LineActor;
00303
00304
00305 vtkConeSource *ConeSource2;
00306 vtkPolyDataMapper *ConeMapper2;
00307 vtkActor *ConeActor2;
00308
00309
00310 vtkLineSource *LineSource2;
00311 vtkPolyDataMapper *LineMapper2;
00312 vtkActor *LineActor2;
00313
00314
00315 vtkSphereSource *Sphere;
00316 vtkPolyDataMapper *SphereMapper;
00317 vtkActor *SphereActor;
00318
00319
00320 vtkCellPicker *Picker;
00321
00322
00323 vtkTransform *Transform;
00324
00325
00326 void ConstrainOrigin(double x[3]);
00327 void Rotate(int X, int Y, double *p1, double *p2, double *vpn);
00328 void TranslatePlane(double *p1, double *p2);
00329 void TranslateOutline(double *p1, double *p2);
00330 void TranslateOrigin(double *p1, double *p2);
00331 void Push(double *p1, double *p2);
00332 void Scale(double *p1, double *p2, int X, int Y);
00333
00334
00335
00336 vtkProperty *NormalProperty;
00337 vtkProperty *SelectedNormalProperty;
00338 vtkProperty *PlaneProperty;
00339 vtkProperty *SelectedPlaneProperty;
00340 vtkProperty *OutlineProperty;
00341 vtkProperty *SelectedOutlineProperty;
00342 vtkProperty *EdgesProperty;
00343 void CreateDefaultProperties();
00344
00345 void GeneratePlane();
00346 virtual void SizeHandles();
00347
00348 private:
00349 vtkImplicitPlaneWidget(const vtkImplicitPlaneWidget&);
00350 void operator=(const vtkImplicitPlaneWidget&);
00351 };
00352
00353 #endif