Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | 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   Language:  C++
00006 
00007   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
00008   All rights reserved.
00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00010 
00011      This software is distributed WITHOUT ANY WARRANTY; without even 
00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00013      PURPOSE.  See the above copyright notice for more information.
00014 
00015 =========================================================================*/
00016 
00017 /*
00018  * This work (vtkInteractorStyleUnicam.h) was produced under a grant from
00019  * the Department of Energy to Brown University.  Neither Brown University
00020  * nor the authors assert any copyright with respect to this work and it may
00021  * be used, reproduced, and distributed without permission.  
00022  */
00023 
00083 #ifndef __vtkInteractorStyleUnicam_h
00084 #define __vtkInteractorStyleUnicam_h
00085 
00086 #include "vtkInteractorStyle.h"
00087 
00088 class vtkCamera;
00089 class vtkWorldPointPicker;
00090 
00091 // 
00092 // XXX - would have preferred to make these enumerations within the class,
00093 //    enum { NONE=0, BUTTON_LEFT, BUTTON_MIDDLE, BUTTON_RIGHT };
00094 //    enum {CAM_INT_ROT, CAM_INT_CHOOSE, CAM_INT_PAN, CAM_INT_DOLLY};
00095 // but vtkWrapTcl signaled a "syntax error" when it parsed the 'enum' line.
00096 // So, am making them defines which is what the other classes that want
00097 // to have constants appear to do.
00098 // 
00099 // buttons pressed
00100 #define VTK_UNICAM_NONE           0
00101 #define VTK_UNICAM_BUTTON_LEFT    1
00102 #define VTK_UNICAM_BUTTON_MIDDLE  2
00103 #define VTK_UNICAM_BUTTON_RIGHT   3
00104 // 
00105 // camera modes
00106 #define VTK_UNICAM_CAM_INT_ROT    0
00107 #define VTK_UNICAM_CAM_INT_CHOOSE 1
00108 #define VTK_UNICAM_CAM_INT_PAN    2
00109 #define VTK_UNICAM_CAM_INT_DOLLY  3
00110 
00111 class VTK_RENDERING_EXPORT vtkInteractorStyleUnicam : public vtkInteractorStyle 
00112 {
00113 public:
00114   static vtkInteractorStyleUnicam *New();
00115   vtkTypeRevisionMacro(vtkInteractorStyleUnicam,vtkInteractorStyle);
00116   void PrintSelf(ostream& os, vtkIndent indent);
00117   
00118   void SetWorldUpVector(double a[3]) {this->SetWorldUpVector(a[0],a[1],a[2]);}
00119   void SetWorldUpVector(float  a[3]) {this->SetWorldUpVector(a[0],a[1],a[2]);}
00120   void SetWorldUpVector(float x, float y, float z);
00121   vtkGetVectorMacro(WorldUpVector, float, 3);
00122 
00124 
00125   virtual void OnMouseMove();
00126   virtual void OnLeftButtonDown();
00127   virtual void OnLeftButtonUp();
00128   virtual void OnLeftButtonMove();
00130 
00133   virtual void OnTimer();
00134 
00135 protected:
00136   vtkInteractorStyleUnicam();
00137   virtual ~vtkInteractorStyleUnicam();
00138 
00139   vtkWorldPointPicker *InteractionPicker;
00140   
00141   int      ButtonDown;   // which button is down
00142   double   DTime;        // time mouse button was pressed
00143   double   Dist;         // distance the mouse has moved since button press
00144   float    StartPix[2]; // pixel mouse movement started at
00145   float    LastPos[2];  // normalized position of mouse last frame
00146   float    LastPix[2];  // pixel position of mouse last frame
00147   float    DownPt[3];   // 3D point under cursor when mouse button pressed
00148   float    Center [3];   // center of camera rotation
00149 
00150   float    WorldUpVector[3]; // what the world thinks the 'up' vector is
00151 
00152   vtkActor    *FocusSphere; // geometry for indicating center of rotation
00153   int          IsDot;       // flag-- is the FocusSphere being displayed?
00154   vtkRenderer *FocusSphereRenderer;  // renderer for 'FocusSphere'
00155 
00156   int state;                 // which navigation mode was selected?
00157 
00158   void ChooseXY( int X, int Y );  // method for choosing type of navigation
00159   void RotateXY( int X, int Y );  // method for rotating
00160   void DollyXY( int X, int Y );  // method for dollying
00161   void PanXY( int X, int Y );  // method for panning
00162 
00163   // conveinence methods for translating & rotating the camera
00164   void  MyTranslateCamera(float v[3]);
00165   void  MyRotateCamera(float cx, float cy, float cz,
00166                        float ax, float ay, float az,
00167                        float angle);
00168 
00169   // Given a 3D point & a vtkCamera, compute the vectors that extend
00170   // from the projection of the center of projection to the center of
00171   // the right-edge and the center of the top-edge onto the plane
00172   // containing the 3D point & with normal parallel to the camera's
00173   // projection plane.
00174   void  GetRightVandUpV(float *p, vtkCamera *cam,
00175                         float *rightV, float *upV);
00176 
00177   // takes in pixels, returns normalized window coordinates
00178   void  NormalizeMouseXY(int X, int Y, float *NX, float *NY);
00179 
00180   // return the aspect ratio of the current window
00181   float WindowAspect();
00182 private:
00183   vtkInteractorStyleUnicam(const vtkInteractorStyleUnicam&);  // Not implemented.
00184   void operator=(const vtkInteractorStyleUnicam&);  // Not implemented.
00185 };
00186 
00187 #endif  // __vtkInteractorStyleUnicam_h
00188 
00189 
00190