• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

dox/Widgets/vtkImplicitPlaneRepresentation.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkImplicitPlaneRepresentation.h,v $
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 
00063 class VTK_WIDGETS_EXPORT vtkImplicitPlaneRepresentation : public vtkWidgetRepresentation
00064 {
00065 public:
00067   static vtkImplicitPlaneRepresentation *New();
00068 
00070 
00071   vtkTypeRevisionMacro(vtkImplicitPlaneRepresentation,vtkWidgetRepresentation);
00072   void PrintSelf(ostream& os, vtkIndent indent);
00074 
00076 
00077   void SetOrigin(double x, double y, double z);
00078   void SetOrigin(double x[3]);
00079   double* GetOrigin();
00080   void GetOrigin(double xyz[3]);
00082 
00084 
00085   void SetNormal(double x, double y, double z);
00086   void SetNormal(double x[3]);
00087   double* GetNormal();
00088   void GetNormal(double xyz[3]);
00090   
00092 
00096   void SetNormalToXAxis(int);
00097   vtkGetMacro(NormalToXAxis,int);
00098   vtkBooleanMacro(NormalToXAxis,int);
00099   void SetNormalToYAxis(int);
00100   vtkGetMacro(NormalToYAxis,int);
00101   vtkBooleanMacro(NormalToYAxis,int);
00102   void SetNormalToZAxis(int);
00103   vtkGetMacro(NormalToZAxis,int);
00104   vtkBooleanMacro(NormalToZAxis,int);
00106 
00108 
00110   vtkSetMacro(Tubing,int);
00111   vtkGetMacro(Tubing,int);
00112   vtkBooleanMacro(Tubing,int);
00114 
00116 
00120   void SetDrawPlane(int plane);
00121   vtkGetMacro(DrawPlane,int);
00122   vtkBooleanMacro(DrawPlane,int);
00124 
00126 
00128   vtkSetMacro(OutlineTranslation,int);
00129   vtkGetMacro(OutlineTranslation,int);
00130   vtkBooleanMacro(OutlineTranslation,int);
00132 
00134 
00136   vtkSetMacro(OutsideBounds,int);
00137   vtkGetMacro(OutsideBounds,int);
00138   vtkBooleanMacro(OutsideBounds,int);
00140 
00142 
00143   vtkSetMacro(ScaleEnabled,int);
00144   vtkGetMacro(ScaleEnabled,int);
00145   vtkBooleanMacro(ScaleEnabled,int);
00147 
00150   void GetPolyData(vtkPolyData *pd);
00151 
00154   vtkPolyDataAlgorithm* GetPolyDataAlgorithm();
00155    
00160   void GetPlane(vtkPlane *plane);
00161 
00165   void UpdatePlacement(void);
00166 
00168 
00169   vtkGetObjectMacro(NormalProperty,vtkProperty);
00170   vtkGetObjectMacro(SelectedNormalProperty,vtkProperty);
00172   
00174 
00176   vtkGetObjectMacro(PlaneProperty,vtkProperty);
00177   vtkGetObjectMacro(SelectedPlaneProperty,vtkProperty);
00179 
00181 
00182   vtkGetObjectMacro(OutlineProperty,vtkProperty);
00183   vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty);
00185 
00187 
00189   vtkGetObjectMacro(EdgesProperty,vtkProperty);
00191 
00193 
00194   virtual int ComputeInteractionState(int X, int Y, int modify=0);
00195   virtual void PlaceWidget(double bounds[6]);
00196   virtual void BuildRepresentation();
00197   virtual void StartWidgetInteraction(double eventPos[2]);
00198   virtual void WidgetInteraction(double newEventPos[2]);
00199   virtual void EndWidgetInteraction(double newEventPos[2]);
00201 
00203 
00204   virtual double *GetBounds();
00205   virtual void GetActors(vtkPropCollection *pc);
00206   virtual void ReleaseGraphicsResources(vtkWindow*);
00207   virtual int RenderOpaqueGeometry(vtkViewport*);
00208   virtual int RenderTranslucentPolygonalGeometry(vtkViewport*);
00209   virtual int HasTranslucentPolygonalGeometry();
00211   
00212 //BTX - manage the state of the widget
00213   enum _InteractionState
00214   {
00215     Outside=0,
00216     Moving,
00217     MovingOutline,
00218     MovingOrigin,
00219     Rotating,
00220     Pushing,
00221     MovingPlane,
00222     Scaling
00223   };
00224 //ETX
00225 
00227 
00234   vtkSetClampMacro(InteractionState,int,Outside,Scaling);
00236 
00238 
00240   virtual void SetRepresentationState(int);
00241   vtkGetMacro(RepresentationState, int);
00243 
00244 protected:
00245   vtkImplicitPlaneRepresentation();
00246   ~vtkImplicitPlaneRepresentation();
00247 
00248   int RepresentationState;
00249 
00250   // Keep track of event positions
00251   double LastEventPosition[3];
00252 
00253   // Controlling ivars
00254   int NormalToXAxis;
00255   int NormalToYAxis;
00256   int NormalToZAxis;
00257 
00258   // The actual plane which is being manipulated
00259   vtkPlane *Plane;
00260 
00261   // The bounding box is represented by a single voxel image data
00262   vtkImageData      *Box;
00263   vtkOutlineFilter  *Outline;
00264   vtkPolyDataMapper *OutlineMapper;
00265   vtkActor          *OutlineActor;
00266   void HighlightOutline(int highlight);
00267   int  OutlineTranslation; //whether the outline can be moved
00268   int  ScaleEnabled; //whether the widget can be scaled 
00269   int  OutsideBounds; //whether the widget can be moved outside input's bounds
00270   
00271   // The cut plane is produced with a vtkCutter
00272   vtkCutter         *Cutter;
00273   vtkPolyDataMapper *CutMapper;
00274   vtkActor          *CutActor;
00275   int                DrawPlane;
00276   void HighlightPlane(int highlight);
00277   
00278   // Optional tubes are represented by extracting boundary edges and tubing
00279   vtkFeatureEdges   *Edges;
00280   vtkTubeFilter     *EdgesTuber;
00281   vtkPolyDataMapper *EdgesMapper;
00282   vtkActor          *EdgesActor;
00283   int                Tubing; //control whether tubing is on
00284 
00285   // The + normal cone
00286   vtkConeSource     *ConeSource;
00287   vtkPolyDataMapper *ConeMapper;
00288   vtkActor          *ConeActor;
00289   void HighlightNormal(int highlight);
00290 
00291   // The + normal line
00292   vtkLineSource     *LineSource;
00293   vtkPolyDataMapper *LineMapper;
00294   vtkActor          *LineActor;
00295 
00296   // The - normal cone
00297   vtkConeSource     *ConeSource2;
00298   vtkPolyDataMapper *ConeMapper2;
00299   vtkActor          *ConeActor2;
00300 
00301   // The - normal line
00302   vtkLineSource     *LineSource2;
00303   vtkPolyDataMapper *LineMapper2;
00304   vtkActor          *LineActor2;
00305 
00306   // The origin positioning handle
00307   vtkSphereSource   *Sphere;
00308   vtkPolyDataMapper *SphereMapper;
00309   vtkActor          *SphereActor;
00310 
00311   // Do the picking
00312   vtkCellPicker *Picker;
00313   
00314   // Transform the normal (used for rotation)
00315   vtkTransform *Transform;
00316   
00317   // Methods to manipulate the plane
00318   void ConstrainOrigin(double x[3]);
00319   void Rotate(double X, double Y, double *p1, double *p2, double *vpn);
00320   void TranslatePlane(double *p1, double *p2);
00321   void TranslateOutline(double *p1, double *p2);
00322   void TranslateOrigin(double *p1, double *p2);
00323   void Push(double *p1, double *p2);
00324   void Scale(double *p1, double *p2, double X, double Y);
00325   void SizeHandles();
00326 
00327   // Properties used to control the appearance of selected objects and
00328   // the manipulator in general.
00329   vtkProperty *NormalProperty;
00330   vtkProperty *SelectedNormalProperty;
00331   vtkProperty *PlaneProperty;
00332   vtkProperty *SelectedPlaneProperty;
00333   vtkProperty *OutlineProperty;
00334   vtkProperty *SelectedOutlineProperty;
00335   vtkProperty *EdgesProperty;
00336   void CreateDefaultProperties();
00337   
00338   void GeneratePlane();
00339   
00340   // Support GetBounds() method
00341   vtkBox *BoundingBox;
00342   
00343 private:
00344   vtkImplicitPlaneRepresentation(const vtkImplicitPlaneRepresentation&);  //Not implemented
00345   void operator=(const vtkImplicitPlaneRepresentation&);  //Not implemented
00346 };
00347 
00348 #endif

Generated by  doxygen 1.7.1