VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkImplicitPlaneRepresentation.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00040 #ifndef __vtkImplicitPlaneRepresentation_h 00041 #define __vtkImplicitPlaneRepresentation_h 00042 00043 #include "vtkWidgetRepresentation.h" 00044 00045 class vtkActor; 00046 class vtkPolyDataMapper; 00047 class vtkCellPicker; 00048 class vtkConeSource; 00049 class vtkLineSource; 00050 class vtkSphereSource; 00051 class vtkTubeFilter; 00052 class vtkPlane; 00053 class vtkCutter; 00054 class vtkProperty; 00055 class vtkImageData; 00056 class vtkOutlineFilter; 00057 class vtkFeatureEdges; 00058 class vtkPolyData; 00059 class vtkPolyDataAlgorithm; 00060 class vtkTransform; 00061 class vtkBox; 00062 class vtkLookupTable; 00063 00064 class VTK_WIDGETS_EXPORT vtkImplicitPlaneRepresentation : public vtkWidgetRepresentation 00065 { 00066 public: 00068 static vtkImplicitPlaneRepresentation *New(); 00069 00071 00072 vtkTypeMacro(vtkImplicitPlaneRepresentation,vtkWidgetRepresentation); 00073 void PrintSelf(ostream& os, vtkIndent indent); 00075 00077 00078 void SetOrigin(double x, double y, double z); 00079 void SetOrigin(double x[3]); 00080 double* GetOrigin(); 00081 void GetOrigin(double xyz[3]); 00083 00085 00086 void SetNormal(double x, double y, double z); 00087 void SetNormal(double x[3]); 00088 void SetNormalToCamera(); 00089 double* GetNormal(); 00090 void GetNormal(double xyz[3]); 00092 00094 00098 void SetNormalToXAxis(int); 00099 vtkGetMacro(NormalToXAxis,int); 00100 vtkBooleanMacro(NormalToXAxis,int); 00101 void SetNormalToYAxis(int); 00102 vtkGetMacro(NormalToYAxis,int); 00103 vtkBooleanMacro(NormalToYAxis,int); 00104 void SetNormalToZAxis(int); 00105 vtkGetMacro(NormalToZAxis,int); 00106 vtkBooleanMacro(NormalToZAxis,int); 00108 00110 00113 virtual void SetLockNormalToCamera(int); 00114 vtkGetMacro(LockNormalToCamera,int); 00115 vtkBooleanMacro(LockNormalToCamera,int); 00117 00119 00121 vtkSetMacro(Tubing,int); 00122 vtkGetMacro(Tubing,int); 00123 vtkBooleanMacro(Tubing,int); 00125 00127 00131 void SetDrawPlane(int plane); 00132 vtkGetMacro(DrawPlane,int); 00133 vtkBooleanMacro(DrawPlane,int); 00135 00137 00139 vtkSetMacro(OutlineTranslation,int); 00140 vtkGetMacro(OutlineTranslation,int); 00141 vtkBooleanMacro(OutlineTranslation,int); 00143 00145 00147 vtkSetMacro(OutsideBounds,int); 00148 vtkGetMacro(OutsideBounds,int); 00149 vtkBooleanMacro(OutsideBounds,int); 00151 00153 00154 vtkSetMacro(ScaleEnabled,int); 00155 vtkGetMacro(ScaleEnabled,int); 00156 vtkBooleanMacro(ScaleEnabled,int); 00158 00161 void GetPolyData(vtkPolyData *pd); 00162 00165 vtkPolyDataAlgorithm* GetPolyDataAlgorithm(); 00166 00171 void GetPlane(vtkPlane *plane); 00172 00176 void UpdatePlacement(void); 00177 00179 00180 vtkGetObjectMacro(NormalProperty,vtkProperty); 00181 vtkGetObjectMacro(SelectedNormalProperty,vtkProperty); 00183 00185 00187 vtkGetObjectMacro(PlaneProperty,vtkProperty); 00188 vtkGetObjectMacro(SelectedPlaneProperty,vtkProperty); 00190 00192 00193 vtkGetObjectMacro(OutlineProperty,vtkProperty); 00194 vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty); 00196 00198 00200 vtkGetObjectMacro(EdgesProperty,vtkProperty); 00202 00203 00204 void SetEdgeColor(vtkLookupTable*); 00205 void SetEdgeColor(double, double, double); 00206 void SetEdgeColor(double x[3]); 00208 00210 00213 vtkSetClampMacro(BumpDistance,double,0.000001,1); 00214 vtkGetMacro(BumpDistance,double); 00216 00222 void BumpPlane(int dir, double factor); 00223 00228 void PushPlane(double distance); 00229 00231 00232 virtual int ComputeInteractionState(int X, int Y, int modify=0); 00233 virtual void PlaceWidget(double bounds[6]); 00234 virtual void BuildRepresentation(); 00235 virtual void StartWidgetInteraction(double eventPos[2]); 00236 virtual void WidgetInteraction(double newEventPos[2]); 00237 virtual void EndWidgetInteraction(double newEventPos[2]); 00239 00240 00241 virtual double *GetBounds(); 00242 virtual void GetActors(vtkPropCollection *pc); 00243 virtual void ReleaseGraphicsResources(vtkWindow*); 00244 virtual int RenderOpaqueGeometry(vtkViewport*); 00245 virtual int RenderTranslucentPolygonalGeometry(vtkViewport*); 00246 virtual int HasTranslucentPolygonalGeometry(); 00248 00249 //BTX - manage the state of the widget 00250 enum _InteractionState 00251 { 00252 Outside=0, 00253 Moving, 00254 MovingOutline, 00255 MovingOrigin, 00256 Rotating, 00257 Pushing, 00258 Scaling 00259 }; 00260 //ETX 00261 00263 00270 vtkSetClampMacro(InteractionState,int,Outside,Scaling); 00272 00274 00276 virtual void SetRepresentationState(int); 00277 vtkGetMacro(RepresentationState, int); 00279 00280 protected: 00281 vtkImplicitPlaneRepresentation(); 00282 ~vtkImplicitPlaneRepresentation(); 00283 00284 int RepresentationState; 00285 00286 // Keep track of event positions 00287 double LastEventPosition[3]; 00288 00289 // Controlling ivars 00290 int NormalToXAxis; 00291 int NormalToYAxis; 00292 int NormalToZAxis; 00293 00294 // Locking normal to camera 00295 int LockNormalToCamera; 00296 00297 // Controlling the push operation 00298 double BumpDistance; 00299 00300 // The actual plane which is being manipulated 00301 vtkPlane *Plane; 00302 00303 // The bounding box is represented by a single voxel image data 00304 vtkImageData *Box; 00305 vtkOutlineFilter *Outline; 00306 vtkPolyDataMapper *OutlineMapper; 00307 vtkActor *OutlineActor; 00308 void HighlightOutline(int highlight); 00309 int OutlineTranslation; //whether the outline can be moved 00310 int ScaleEnabled; //whether the widget can be scaled 00311 int OutsideBounds; //whether the widget can be moved outside input's bounds 00312 00313 // The cut plane is produced with a vtkCutter 00314 vtkCutter *Cutter; 00315 vtkPolyDataMapper *CutMapper; 00316 vtkActor *CutActor; 00317 int DrawPlane; 00318 void HighlightPlane(int highlight); 00319 00320 // Optional tubes are represented by extracting boundary edges and tubing 00321 vtkFeatureEdges *Edges; 00322 vtkTubeFilter *EdgesTuber; 00323 vtkPolyDataMapper *EdgesMapper; 00324 vtkActor *EdgesActor; 00325 int Tubing; //control whether tubing is on 00326 00327 // The + normal cone 00328 vtkConeSource *ConeSource; 00329 vtkPolyDataMapper *ConeMapper; 00330 vtkActor *ConeActor; 00331 void HighlightNormal(int highlight); 00332 00333 // The + normal line 00334 vtkLineSource *LineSource; 00335 vtkPolyDataMapper *LineMapper; 00336 vtkActor *LineActor; 00337 00338 // The - normal cone 00339 vtkConeSource *ConeSource2; 00340 vtkPolyDataMapper *ConeMapper2; 00341 vtkActor *ConeActor2; 00342 00343 // The - normal line 00344 vtkLineSource *LineSource2; 00345 vtkPolyDataMapper *LineMapper2; 00346 vtkActor *LineActor2; 00347 00348 // The origin positioning handle 00349 vtkSphereSource *Sphere; 00350 vtkPolyDataMapper *SphereMapper; 00351 vtkActor *SphereActor; 00352 00353 // Do the picking 00354 vtkCellPicker *Picker; 00355 00356 // Transform the normal (used for rotation) 00357 vtkTransform *Transform; 00358 00359 // Methods to manipulate the plane 00360 void ConstrainOrigin(double x[3]); 00361 void Rotate(double X, double Y, double *p1, double *p2, double *vpn); 00362 void TranslatePlane(double *p1, double *p2); 00363 void TranslateOutline(double *p1, double *p2); 00364 void TranslateOrigin(double *p1, double *p2); 00365 void Push(double *p1, double *p2); 00366 void Scale(double *p1, double *p2, double X, double Y); 00367 void SizeHandles(); 00368 00369 // Properties used to control the appearance of selected objects and 00370 // the manipulator in general. 00371 vtkProperty *NormalProperty; 00372 vtkProperty *SelectedNormalProperty; 00373 vtkProperty *PlaneProperty; 00374 vtkProperty *SelectedPlaneProperty; 00375 vtkProperty *OutlineProperty; 00376 vtkProperty *SelectedOutlineProperty; 00377 vtkProperty *EdgesProperty; 00378 void CreateDefaultProperties(); 00379 00380 void GeneratePlane(); 00381 00382 // Support GetBounds() method 00383 vtkBox *BoundingBox; 00384 00385 private: 00386 vtkImplicitPlaneRepresentation(const vtkImplicitPlaneRepresentation&); //Not implemented 00387 void operator=(const vtkImplicitPlaneRepresentation&); //Not implemented 00388 }; 00389 00390 #endif