00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef __VISU_PlanesWidget_h
00030 #define __VISU_PlanesWidget_h
00031
00032 #include "VISUPipeline.hxx"
00033 #include "VISU_ImplicitFunctionWidget.hxx"
00034 class vtkActor;
00035 class vtkPolyDataMapper;
00036 class vtkCellPicker;
00037 class vtkConeSource;
00038 class vtkLineSource;
00039 class vtkSphereSource;
00040 class vtkPlane;
00041 class vtkCutter;
00042 class vtkProperty;
00043 class vtkImageData;
00044 class vtkOutlineFilter;
00045 class vtkFeatureEdges;
00046 class vtkPolyData;
00047 class vtkTransform;
00048 class vtkImplicitBoolean;
00049 class vtkImplicitFunction;
00050 class VISU_UnScaledActor;
00051 class vtkDataSet;
00052
00053 class VISU_PIPELINE_EXPORT VISU_PlanesWidget : public VISU_ImplicitFunctionWidget
00054 {
00055 public:
00056
00057
00058 static VISU_PlanesWidget *New();
00059
00060 vtkTypeRevisionMacro(VISU_PlanesWidget,VISU_ImplicitFunctionWidget);
00061 void PrintSelf(ostream& os, vtkIndent indent);
00062
00063 void
00064 SetDistance(const vtkFloatingPointType theDistance);
00065
00066 vtkFloatingPointType
00067 Distance() const;
00068
00069 vtkGetMacro(InitialLength,vtkFloatingPointType);
00070
00071 virtual
00072 vtkImplicitFunction*
00073 ImplicitFunction();
00074
00075
00076
00077 virtual
00078 void
00079 SetEnabled(int);
00080
00081 virtual
00082 void
00083 PlaceWidget(vtkFloatingPointType bounds[6]);
00084
00085
00086
00087 void
00088 SetOrigin(vtkFloatingPointType x,
00089 vtkFloatingPointType y,
00090 vtkFloatingPointType z);
00091
00092 void
00093 SetOrigin(vtkFloatingPointType x[3]);
00094
00095 vtkFloatingPointType*
00096 GetOrigin();
00097
00098 void
00099 GetOrigin(vtkFloatingPointType xyz[3]);
00100
00101
00102
00103 void
00104 SetNormal(vtkFloatingPointType x,
00105 vtkFloatingPointType y,
00106 vtkFloatingPointType z);
00107
00108 void
00109 SetNormal(vtkFloatingPointType x[3]);
00110
00111 vtkFloatingPointType*
00112 GetNormal();
00113
00114 void
00115 GetNormal(vtkFloatingPointType xyz[3]);
00116
00117
00118
00119
00120
00121
00122
00123 void
00124 SetNormalToXAxis(int);
00125
00126 vtkGetMacro(NormalToXAxis,int);
00127 vtkBooleanMacro(NormalToXAxis,int);
00128
00129 void
00130 SetNormalToYAxis(int);
00131
00132 vtkGetMacro(NormalToYAxis,int);
00133 vtkBooleanMacro(NormalToYAxis,int);
00134
00135 void
00136 SetNormalToZAxis(int);
00137 vtkGetMacro(NormalToZAxis,int);
00138 vtkBooleanMacro(NormalToZAxis,int);
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152 void
00153 SetDrawPlane(int plane);
00154
00155 int
00156 GetDrawPlane()
00157 {
00158 return myDrawPlane;
00159 }
00160
00161
00162
00163
00164 vtkSetMacro(OutlineTranslation,int);
00165 vtkGetMacro(OutlineTranslation,int);
00166 vtkBooleanMacro(OutlineTranslation,int);
00167
00168
00169
00170
00171 void
00172 GetPolyData(vtkPolyData *pd);
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184 void
00185 GetPlane(vtkPlane *plane);
00186
00187
00188
00189
00190 void
00191 UpdatePlacement(void);
00192
00193
00194
00195 vtkGetObjectMacro(NormalProperty,vtkProperty);
00196 vtkGetObjectMacro(SelectedNormalProperty,vtkProperty);
00197
00198
00199
00200
00201 vtkGetObjectMacro(PlaneProperty,vtkProperty);
00202 vtkGetObjectMacro(SelectedPlaneProperty,vtkProperty);
00203
00204
00205
00206 vtkGetObjectMacro(OutlineProperty,vtkProperty);
00207 vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty);
00208
00209
00210
00211
00212 vtkGetObjectMacro(EdgesProperty,vtkProperty);
00213
00214 void
00215 InitialPlaceWidget(vtkFloatingPointType bds[6]);
00216
00217 protected:
00218 VISU_PlanesWidget();
00219 ~VISU_PlanesWidget();
00220
00221
00222 int State;
00223 enum WidgetState
00224 {
00225 Start=0,
00226 MovingPlane,
00227 MovingOutline,
00228 MovingOrigin,
00229 Scaling,
00230 Pushing,
00231 Rotating,
00232 Outside,
00233 ChangeDistance
00234 };
00235
00236
00237
00238 static
00239 void
00240 ProcessEvents(vtkObject* object, unsigned long event,
00241 void* clientdata, void* calldata);
00242
00243
00244 void OnLeftButtonDown();
00245 void OnLeftButtonUp();
00246 void OnMiddleButtonDown();
00247 void OnMiddleButtonUp();
00248 void OnRightButtonDown();
00249 void OnRightButtonUp();
00250 void OnMouseMove();
00251
00252
00253 void ConstrainOrigin(vtkFloatingPointType x[3]);
00254 void Rotate(int X, int Y, double *p1, double *p2, double *vpn);
00255 void TranslatePlane(double *p1, double *p2);
00256 void TranslateOutline(double *p1, double *p2);
00257 void TranslateOrigin(double *p1, double *p2);
00258 void Push(double *p1, double *p2);
00259 void Scale(double *p1, double *p2, int X, int Y);
00260 void PushDistance(double *p1, double *p2);
00261
00262 void CreateDefaultProperties();
00263
00264 void GeneratePlane();
00265
00266 void HighlightPlane(int highlight);
00267 void HighlightNormal(int highlight);
00268 void HighlightOutline(int highlight);
00269 void UpdateRepresentation();
00270 void SetOriginInternal(vtkFloatingPointType x[3]);
00271
00272
00273 int NormalToXAxis;
00274 int NormalToYAxis;
00275 int NormalToZAxis;
00276
00277
00278
00279 bool HandleMoveEvent;
00280 bool HandleLeftButtonEvent;
00281 bool HandleMiddleButtonEvent;
00282 bool HandleRightButtonEvent;
00283
00284 vtkPlane *myPlane1;
00285 vtkPlane *myPlane2;
00286
00287 vtkFloatingPointType myDistance;
00288 vtkImplicitBoolean *myImplicitFunction;
00289
00290
00291 vtkImageData *myBox;
00292 vtkOutlineFilter *myOutline;
00293 vtkPolyDataMapper *myOutlineMapper;
00294 vtkActor *myOutlineActor;
00295
00296 int OutlineTranslation;
00297
00298
00299 vtkCutter *myCutter1;
00300 vtkPolyDataMapper *myCutMapper1;
00301 vtkActor *myCutActor1;
00302
00303 vtkCutter *myCutter2;
00304 vtkPolyDataMapper *myCutMapper2;
00305 vtkActor *myCutActor2;
00306
00307 vtkFeatureEdges *myEdges2;
00308 vtkPolyDataMapper *myEdgesMapper2;
00309 vtkActor *myEdgesActor2;
00310
00311 int myDrawPlane;
00312
00313 vtkFeatureEdges *myEdges1;
00314 vtkPolyDataMapper *myEdgesMapper1;
00315 vtkActor *myEdgesActor1;
00316
00317
00318 vtkConeSource *ConeSource;
00319 vtkPolyDataMapper *ConeMapper;
00320 VISU_UnScaledActor *ConeActor;
00321
00322 vtkLineSource *LineSource;
00323 vtkPolyDataMapper *LineMapper;
00324 vtkActor *LineActor;
00325
00326 vtkConeSource *ConeSource2;
00327 vtkPolyDataMapper *ConeMapper2;
00328 VISU_UnScaledActor *ConeActor2;
00329
00330 vtkLineSource *LineSource2;
00331 vtkPolyDataMapper *LineMapper2;
00332 vtkActor *LineActor2;
00333
00334 vtkSphereSource *Sphere;
00335 vtkPolyDataMapper *SphereMapper;
00336 VISU_UnScaledActor *SphereActor;
00337
00338
00339 vtkCellPicker *Picker;
00340
00341
00342 vtkTransform *Transform;
00343
00344
00345 vtkProperty *NormalProperty;
00346 vtkProperty *SelectedNormalProperty;
00347 vtkProperty *PlaneProperty;
00348 vtkProperty *SelectedPlaneProperty;
00349 vtkProperty *OutlineProperty;
00350 vtkProperty *SelectedOutlineProperty;
00351 vtkProperty *EdgesProperty;
00352
00353 private:
00354 VISU_PlanesWidget(const VISU_PlanesWidget&);
00355 void operator=(const VISU_ImplicitFunctionWidget&);
00356 };
00357
00358 #endif