VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkInteractorStyleUnicam.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 =========================================================================*/ 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 00079 #ifndef __vtkInteractorStyleUnicam_h 00080 #define __vtkInteractorStyleUnicam_h 00081 00082 #include "vtkInteractorStyle.h" 00083 00084 class vtkCamera; 00085 class vtkWorldPointPicker; 00086 00087 // 00088 // XXX - would have preferred to make these enumerations within the class, 00089 // enum { NONE=0, BUTTON_LEFT, BUTTON_MIDDLE, BUTTON_RIGHT }; 00090 // enum {CAM_INT_ROT, CAM_INT_CHOOSE, CAM_INT_PAN, CAM_INT_DOLLY}; 00091 // but vtkWrapTcl signaled a "syntax error" when it parsed the 'enum' line. 00092 // So, am making them defines which is what the other classes that want 00093 // to have constants appear to do. 00094 // 00095 // buttons pressed 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 // camera modes 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; // which button is down 00137 double DTime; // time mouse button was pressed 00138 double Dist; // distance the mouse has moved since button press 00139 double StartPix[2]; // pixel mouse movement started at 00140 double LastPos[2]; // normalized position of mouse last frame 00141 double LastPix[2]; // pixel position of mouse last frame 00142 double DownPt[3]; // 3D point under cursor when mouse button pressed 00143 double Center [3]; // center of camera rotation 00144 00145 double WorldUpVector[3]; // what the world thinks the 'up' vector is 00146 00147 vtkActor *FocusSphere; // geometry for indicating center of rotation 00148 int IsDot; // flag-- is the FocusSphere being displayed? 00149 vtkRenderer *FocusSphereRenderer; // renderer for 'FocusSphere' 00150 00151 int state; // which navigation mode was selected? 00152 00153 void ChooseXY( int X, int Y ); // method for choosing type of navigation 00154 void RotateXY( int X, int Y ); // method for rotating 00155 void DollyXY( int X, int Y ); // method for dollying 00156 void PanXY( int X, int Y ); // method for panning 00157 00158 // conveinence methods for translating & rotating the camera 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 // Given a 3D point & a vtkCamera, compute the vectors that extend 00165 // from the projection of the center of projection to the center of 00166 // the right-edge and the center of the top-edge onto the plane 00167 // containing the 3D point & with normal parallel to the camera's 00168 // projection plane. 00169 void GetRightVandUpV(double *p, vtkCamera *cam, 00170 double *rightV, double *upV); 00171 00172 // takes in pixels, returns normalized window coordinates 00173 void NormalizeMouseXY(int X, int Y, double *NX, double *NY); 00174 00175 // return the aspect ratio of the current window 00176 double WindowAspect(); 00177 private: 00178 vtkInteractorStyleUnicam(const vtkInteractorStyleUnicam&); // Not implemented. 00179 void operator=(const vtkInteractorStyleUnicam&); // Not implemented. 00180 }; 00181 00182 #endif // __vtkInteractorStyleUnicam_h 00183 00184 00185