VTK
dox/Rendering/vtkCamera.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkCamera.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 =========================================================================*/
00034 #ifndef __vtkCamera_h
00035 #define __vtkCamera_h
00036 
00037 #include "vtkObject.h"
00038 
00039 class vtkHomogeneousTransform;
00040 class vtkMatrix4x4;
00041 class vtkPerspectiveTransform;
00042 class vtkRenderer;
00043 class vtkTransform;
00044 class vtkCallbackCommand;
00045 class vtkCameraCallbackCommand;
00046 
00047 class VTK_RENDERING_EXPORT vtkCamera : public vtkObject
00048 {
00049  public:
00050   void PrintSelf(ostream& os, vtkIndent indent);
00051   vtkTypeMacro(vtkCamera,vtkObject);
00052 
00056   static vtkCamera *New();
00057 
00059 
00061   void SetPosition(double x, double y, double z);
00062   void SetPosition(const double a[3]) {
00063     this->SetPosition(a[0], a[1], a[2]); };
00064   vtkGetVector3Macro(Position,double);
00066 
00068 
00070   void SetFocalPoint(double x, double y, double z);
00071   void SetFocalPoint(const double a[3]) {
00072     this->SetFocalPoint(a[0], a[1], a[2]);};
00073   vtkGetVector3Macro(FocalPoint,double);
00075 
00077 
00079   void SetViewUp(double vx, double vy, double vz);
00080   void SetViewUp(const double a[3]) {
00081     this->SetViewUp(a[0], a[1], a[2]); }
00082   vtkGetVector3Macro(ViewUp,double);
00084 
00088   void OrthogonalizeViewUp();
00089 
00092   void SetDistance(double);
00093 
00095 
00097   vtkGetMacro(Distance,double);
00099 
00101 
00104   vtkGetVector3Macro(DirectionOfProjection,double);
00106 
00111   void Dolly(double value);
00112 
00114 
00115   void SetRoll(double angle);
00116   double GetRoll();
00118 
00121   void Roll(double angle);
00122 
00127   void Azimuth(double angle);
00128 
00134   void Yaw(double angle);
00135 
00140   void Elevation(double angle);
00141 
00145   void Pitch(double angle);
00146 
00148 
00151   void SetParallelProjection(int flag);
00152   vtkGetMacro(ParallelProjection,int);
00153   vtkBooleanMacro(ParallelProjection,int);
00155 
00157 
00163   void SetUseHorizontalViewAngle(int flag);
00164   vtkGetMacro(UseHorizontalViewAngle, int);
00165   vtkBooleanMacro(UseHorizontalViewAngle, int);
00167 
00169 
00176   void SetViewAngle(double angle);
00177   vtkGetMacro(ViewAngle,double);
00179 
00181 
00186   void SetParallelScale(double scale);
00187   vtkGetMacro(ParallelScale,double);
00189 
00194   void Zoom(double factor);
00195 
00197 
00204   void SetClippingRange(double dNear, double dFar);
00205   void SetClippingRange(const double a[2]) {
00206     this->SetClippingRange(a[0], a[1]); };
00207   vtkGetVector2Macro(ClippingRange,double);
00209 
00211 
00214   void SetThickness(double);
00215   vtkGetMacro(Thickness,double);
00217 
00219 
00224   void SetWindowCenter(double x, double y);
00225   vtkGetVector2Macro(WindowCenter,double);
00227 
00236   void SetObliqueAngles(double alpha, double beta);
00237 
00241   void ApplyTransform(vtkTransform *t);
00242 
00244 
00247   vtkGetVector3Macro(ViewPlaneNormal,double);
00249 
00251 
00255   void SetViewShear(double dxdz, double dydz, double center);
00256   void SetViewShear(double d[3]);
00257   vtkGetVector3Macro(ViewShear, double);
00259 
00261 
00263   vtkSetMacro(EyeAngle,double);
00264   vtkGetMacro(EyeAngle,double);
00266 
00268 
00272   vtkSetMacro(FocalDisk,double);
00273   vtkGetMacro(FocalDisk,double);
00275 
00280   virtual vtkMatrix4x4 *GetViewTransformMatrix();
00281 
00283 
00287   virtual vtkTransform *GetViewTransformObject()
00288     {
00289       return this->ViewTransform;
00290     }
00292   
00294 
00303   VTK_LEGACY(virtual vtkMatrix4x4 *GetPerspectiveTransformMatrix(double aspect,
00304                                                                  double nearz,
00305                                                                  double farz));
00307   
00309 
00315    virtual vtkMatrix4x4 *GetProjectionTransformMatrix(double aspect,
00316                                                       double nearz,
00317                                                       double farz);
00319   
00321 
00327   virtual vtkPerspectiveTransform *GetProjectionTransformObject(double aspect,
00328                                                                 double nearz,
00329                                                                 double farz);
00331   
00332 
00334 
00344   VTK_LEGACY(virtual vtkMatrix4x4 *GetCompositePerspectiveTransformMatrix(
00345                double aspect,
00346                double nearz,
00347                double farz));
00349   
00351 
00358   virtual vtkMatrix4x4 *GetCompositeProjectionTransformMatrix(double aspect,
00359                                                               double nearz,
00360                                                               double farz);
00362 
00363   
00365 
00369   void SetUserViewTransform(vtkHomogeneousTransform *transform);
00370   vtkGetObjectMacro(UserViewTransform,vtkHomogeneousTransform);
00372 
00374 
00378   void SetUserTransform(vtkHomogeneousTransform *transform);
00379   vtkGetObjectMacro(UserTransform,vtkHomogeneousTransform);
00381 
00385   virtual void Render(vtkRenderer *) {}
00386 
00389   unsigned long GetViewingRaysMTime();
00390 
00393   void ViewingRaysModified();
00394 
00402   virtual void GetFrustumPlanes(double aspect, double planes[24]);
00403 
00405 
00406   double *GetOrientation();
00407   double *GetOrientationWXYZ();
00409 
00411 
00413   VTK_LEGACY(void SetViewPlaneNormal(double x, double y, double z));
00414   VTK_LEGACY(void SetViewPlaneNormal(const double a[3]));
00416 
00419   void ComputeViewPlaneNormal();
00420 
00424   vtkMatrix4x4 *GetCameraLightTransformMatrix();
00425 
00427   virtual void UpdateViewport(vtkRenderer *vtkNotUsed(ren)) {}
00428 
00430 
00431   vtkSetMacro(LeftEye,int);
00432   vtkGetMacro(LeftEye,int);
00434 
00437   void ShallowCopy(vtkCamera *source);
00438   
00441   void DeepCopy(vtkCamera *source);
00442   
00443 protected:
00444   vtkCamera();
00445   ~vtkCamera();
00446 
00448 
00449   void ComputeDistance();
00450   void ComputeViewTransform();
00452   
00453 #ifndef VTK_LEGACY_REMOVE
00454 
00455 
00456   void ComputePerspectiveTransform(double aspect,
00457                                    double nearz,
00458                                    double farz);
00460   
00462 
00464   void ComputeCompositePerspectiveTransform(double aspect,
00465                                             double nearz,
00466                                             double farz);
00468 #endif
00469   
00471 
00472   void ComputeProjectionTransform(double aspect,
00473                                   double nearz,
00474                                   double farz);
00476   
00478 
00479   void ComputeCompositeProjectionTransform(double aspect,
00480                                            double nearz,
00481                                            double farz);
00483   
00484   
00485   void ComputeCameraLightTransform();
00486 
00489   void PartialCopy(vtkCamera *source);
00490   
00491   double WindowCenter[2];
00492   double ObliqueAngles[2];
00493   double FocalPoint[3];
00494   double Position[3];
00495   double ViewUp[3];
00496   double ViewAngle;
00497   double ClippingRange[2];
00498   double EyeAngle;
00499   int    ParallelProjection;
00500   double ParallelScale;
00501   int    Stereo;
00502   int    LeftEye;
00503   double Thickness;
00504   double Distance;
00505   double DirectionOfProjection[3];
00506   double ViewPlaneNormal[3];
00507   double ViewShear[3];
00508   int    UseHorizontalViewAngle;
00509   vtkHomogeneousTransform *UserTransform;
00510   vtkHomogeneousTransform *UserViewTransform;
00511 
00512   vtkTransform *ViewTransform;
00513   vtkPerspectiveTransform *ProjectionTransform;
00514   vtkPerspectiveTransform *Transform;
00515   vtkTransform *CameraLightTransform;
00516 
00517   double FocalDisk;
00518   //BTX
00519   vtkCameraCallbackCommand *UserViewTransformCallbackCommand;
00520   friend class vtkCameraCallbackCommand;
00521   //ETX
00522 
00523   // ViewingRaysMtime keeps track of camera modifications which will 
00524   // change the calculation of viewing rays for the camera before it is 
00525   // transformed to the camera's location and orientation. 
00526   vtkTimeStamp ViewingRaysMTime;
00527 private:
00528   vtkCamera(const vtkCamera&);  // Not implemented.
00529   void operator=(const vtkCamera&);  // Not implemented.
00530 };
00531 
00532 #endif
00533