00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00079 #ifndef __vtkInteractorStyleUnicam_h
00080 #define __vtkInteractorStyleUnicam_h
00081 
00082 #include "vtkInteractorStyle.h"
00083 
00084 class vtkCamera;
00085 class vtkWorldPointPicker;
00086 
00087 
00088 
00089 
00090 
00091 
00092 
00093 
00094 
00095 
00096 #define VTK_UNICAM_NONE           0
00097 #define VTK_UNICAM_BUTTON_LEFT    1
00098 #define VTK_UNICAM_BUTTON_MIDDLE  2
00099 #define VTK_UNICAM_BUTTON_RIGHT   3
00100 
00101 
00102 #define VTK_UNICAM_CAM_INT_ROT    0
00103 #define VTK_UNICAM_CAM_INT_CHOOSE 1
00104 #define VTK_UNICAM_CAM_INT_PAN    2
00105 #define VTK_UNICAM_CAM_INT_DOLLY  3
00106 
00107 class VTK_RENDERING_EXPORT vtkInteractorStyleUnicam : public vtkInteractorStyle 
00108 {
00109 public:
00110   static vtkInteractorStyleUnicam *New();
00111   vtkTypeMacro(vtkInteractorStyleUnicam,vtkInteractorStyle);
00112   void PrintSelf(ostream& os, vtkIndent indent);
00113   
00114   void SetWorldUpVector(double a[3]) {this->SetWorldUpVector(a[0],a[1],a[2]);}
00115   void SetWorldUpVector(double x, double y, double z);
00116   vtkGetVectorMacro(WorldUpVector, double, 3);
00117 
00119 
00120   virtual void OnMouseMove();
00121   virtual void OnLeftButtonDown();
00122   virtual void OnLeftButtonUp();
00123   virtual void OnLeftButtonMove();
00125 
00128   virtual void OnTimer();
00129 
00130 protected:
00131   vtkInteractorStyleUnicam();
00132   virtual ~vtkInteractorStyleUnicam();
00133 
00134   vtkWorldPointPicker *InteractionPicker;
00135   
00136   int      ButtonDown;   
00137   double   DTime;        
00138   double   Dist;         
00139   double    StartPix[2]; 
00140   double    LastPos[2];  
00141   double    LastPix[2];  
00142   double    DownPt[3];   
00143   double    Center [3];   
00144 
00145   double    WorldUpVector[3]; 
00146 
00147   vtkActor    *FocusSphere; 
00148   int          IsDot;       
00149   vtkRenderer *FocusSphereRenderer;  
00150 
00151   int state;                 
00152 
00153   void ChooseXY( int X, int Y );  
00154   void RotateXY( int X, int Y );  
00155   void DollyXY( int X, int Y );  
00156   void PanXY( int X, int Y );  
00157 
00158   
00159   void  MyTranslateCamera(double v[3]);
00160   void  MyRotateCamera(double cx, double cy, double cz,
00161                        double ax, double ay, double az,
00162                        double angle);
00163 
00164   
00165   
00166   
00167   
00168   
00169   void  GetRightVandUpV(double *p, vtkCamera *cam,
00170                         double *rightV, double *upV);
00171 
00172   
00173   void  NormalizeMouseXY(int X, int Y, double *NX, double *NY);
00174 
00175   
00176   double WindowAspect();
00177 private:
00178   vtkInteractorStyleUnicam(const vtkInteractorStyleUnicam&);  
00179   void operator=(const vtkInteractorStyleUnicam&);  
00180 };
00181 
00182 #endif  // __vtkInteractorStyleUnicam_h
00183 
00184 
00185