Main Page | Directories | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

vtkInteractorStyleUnicam.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkInteractorStyleUnicam.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 =========================================================================*/
00015 
00016 /*
00017  * This work (vtkInteractorStyleUnicam.h) was produced under a grant from
00018  * the Department of Energy to Brown University.  Neither Brown University
00019  * nor the authors assert any copyright with respect to this work and it may
00020  * be used, reproduced, and distributed without permission.  
00021  */
00022 
00092 #ifndef __vtkInteractorStyleUnicam_h
00093 #define __vtkInteractorStyleUnicam_h
00094 
00095 #include "vtkInteractorStyle.h"
00096 
00097 class vtkCamera;
00098 class vtkWorldPointPicker;
00099 
00100 // 
00101 // XXX - would have preferred to make these enumerations within the class,
00102 //    enum { NONE=0, BUTTON_LEFT, BUTTON_MIDDLE, BUTTON_RIGHT };
00103 //    enum {CAM_INT_ROT, CAM_INT_CHOOSE, CAM_INT_PAN, CAM_INT_DOLLY};
00104 // but vtkWrapTcl signaled a "syntax error" when it parsed the 'enum' line.
00105 // So, am making them defines which is what the other classes that want
00106 // to have constants appear to do.
00107 // 
00108 // buttons pressed
00109 #define VTK_UNICAM_NONE           0
00110 #define VTK_UNICAM_BUTTON_LEFT    1
00111 #define VTK_UNICAM_BUTTON_MIDDLE  2
00112 #define VTK_UNICAM_BUTTON_RIGHT   3
00113 // 
00114 // camera modes
00115 #define VTK_UNICAM_CAM_INT_ROT    0
00116 #define VTK_UNICAM_CAM_INT_CHOOSE 1
00117 #define VTK_UNICAM_CAM_INT_PAN    2
00118 #define VTK_UNICAM_CAM_INT_DOLLY  3
00119 
00120 class VTK_RENDERING_EXPORT vtkInteractorStyleUnicam : public vtkInteractorStyle 
00121 {
00122 public:
00123   static vtkInteractorStyleUnicam *New();
00124   vtkTypeRevisionMacro(vtkInteractorStyleUnicam,vtkInteractorStyle);
00125   void PrintSelf(ostream& os, vtkIndent indent);
00126   
00127   void SetWorldUpVector(double a[3]) {this->SetWorldUpVector(a[0],a[1],a[2]);}
00128   void SetWorldUpVector(double x, double y, double z);
00129   vtkGetVectorMacro(WorldUpVector, double, 3);
00130 
00132 
00133   virtual void OnMouseMove();
00134   virtual void OnLeftButtonDown();
00135   virtual void OnLeftButtonUp();
00136   virtual void OnLeftButtonMove();
00138 
00141   virtual void OnTimer();
00142 
00143 protected:
00144   vtkInteractorStyleUnicam();
00145   virtual ~vtkInteractorStyleUnicam();
00146 
00147   vtkWorldPointPicker *InteractionPicker;
00148   
00149   int      ButtonDown;   // which button is down
00150   double   DTime;        // time mouse button was pressed
00151   double   Dist;         // distance the mouse has moved since button press
00152   double    StartPix[2]; // pixel mouse movement started at
00153   double    LastPos[2];  // normalized position of mouse last frame
00154   double    LastPix[2];  // pixel position of mouse last frame
00155   double    DownPt[3];   // 3D point under cursor when mouse button pressed
00156   double    Center [3];   // center of camera rotation
00157 
00158   double    WorldUpVector[3]; // what the world thinks the 'up' vector is
00159 
00160   vtkActor    *FocusSphere; // geometry for indicating center of rotation
00161   int          IsDot;       // flag-- is the FocusSphere being displayed?
00162   vtkRenderer *FocusSphereRenderer;  // renderer for 'FocusSphere'
00163 
00164   int state;                 // which navigation mode was selected?
00165 
00166   void ChooseXY( int X, int Y );  // method for choosing type of navigation
00167   void RotateXY( int X, int Y );  // method for rotating
00168   void DollyXY( int X, int Y );  // method for dollying
00169   void PanXY( int X, int Y );  // method for panning
00170 
00171   // conveinence methods for translating & rotating the camera
00172   void  MyTranslateCamera(double v[3]);
00173   void  MyRotateCamera(double cx, double cy, double cz,
00174                        double ax, double ay, double az,
00175                        double angle);
00176 
00177   // Given a 3D point & a vtkCamera, compute the vectors that extend
00178   // from the projection of the center of projection to the center of
00179   // the right-edge and the center of the top-edge onto the plane
00180   // containing the 3D point & with normal parallel to the camera's
00181   // projection plane.
00182   void  GetRightVandUpV(double *p, vtkCamera *cam,
00183                         double *rightV, double *upV);
00184 
00185   // takes in pixels, returns normalized window coordinates
00186   void  NormalizeMouseXY(int X, int Y, double *NX, double *NY);
00187 
00188   // return the aspect ratio of the current window
00189   double WindowAspect();
00190 private:
00191   vtkInteractorStyleUnicam(const vtkInteractorStyleUnicam&);  // Not implemented.
00192   void operator=(const vtkInteractorStyleUnicam&);  // Not implemented.
00193 };
00194 
00195 #endif  // __vtkInteractorStyleUnicam_h
00196 
00197 
00198