Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Rendering/vtkCamera.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkCamera.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 =========================================================================*/
00050 #ifndef __vtkCamera_h
00051 #define __vtkCamera_h
00052 
00053 #include "vtkObject.h"
00054 
00055 class vtkMatrix4x4;
00056 class vtkPerspectiveTransform;
00057 class vtkRenderer;
00058 class vtkTransform;
00059 class vtkLinearTransform;
00060 
00061 class VTK_RENDERING_EXPORT vtkCamera : public vtkObject
00062 {
00063  public:
00064   void PrintSelf(ostream& os, vtkIndent indent);
00065   vtkTypeRevisionMacro(vtkCamera,vtkObject);
00066 
00070   static vtkCamera *New();
00071 
00073 
00075   void SetPosition(double x, double y, double z);
00076   void SetPosition(const double a[3]) {
00077     this->SetPosition(a[0], a[1], a[2]); };
00078   void SetPosition(const float a[3]) {
00079     this->SetPosition(a[0], a[1], a[2]); };
00080   vtkGetVector3Macro(Position,double);
00081   void GetPosition(float a[3]) {
00082     double tmp[3]; this->GetPosition(tmp); 
00083     a[0] = static_cast<float>(tmp[0]); 
00084     a[1] = static_cast<float>(tmp[1]); 
00085     a[2] = static_cast<float>(tmp[2]); };     
00087 
00089 
00091   void SetFocalPoint(double x, double y, double z);
00092   void SetFocalPoint(const double a[3]) {
00093     this->SetFocalPoint(a[0], a[1], a[2]);};
00094   void SetFocalPoint(const float a[3]) {
00095     this->SetFocalPoint(a[0], a[1], a[2]);};
00096   vtkGetVector3Macro(FocalPoint,double);
00097   void GetFocalPoint(float a[3]) {
00098     double tmp[3]; this->GetFocalPoint(tmp); 
00099     a[0] = static_cast<float>(tmp[0]); 
00100     a[1] = static_cast<float>(tmp[1]); 
00101     a[2] = static_cast<float>(tmp[2]); }; 
00103   
00105 
00107   void SetViewUp(double vx, double vy, double vz);
00108   void SetViewUp(const double a[3]) {
00109     this->SetViewUp(a[0], a[1], a[2]); }
00110   void SetViewUp(const float a[3]) {
00111     this->SetViewUp(a[0], a[1], a[2]); }
00112   vtkGetVector3Macro(ViewUp,double);
00113   void GetViewUp(float a[3]) {
00114     double tmp[3]; this->GetViewUp(tmp); 
00115     a[0] = static_cast<float>(tmp[0]); 
00116     a[1] = static_cast<float>(tmp[1]); 
00117     a[2] = static_cast<float>(tmp[2]); }; 
00119 
00123   void OrthogonalizeViewUp();
00124 
00126 
00128   void SetDistance(double);
00129   vtkGetMacro(Distance,double);
00131 
00133 
00136   vtkGetVector3Macro(DirectionOfProjection,double);
00137   void GetDirectionOfProjection(float a[3]) {
00138     double tmp[3]; this->GetDirectionOfProjection(tmp); 
00139     a[0] = static_cast<float>(tmp[0]); 
00140     a[1] = static_cast<float>(tmp[1]); 
00141     a[2] = static_cast<float>(tmp[2]); }; 
00143 
00147   void Dolly(double distance);
00148 
00150 
00151   void SetRoll(double angle);
00152   double GetRoll();
00154 
00156   void Roll(double angle);
00157 
00161   void Azimuth(double angle);
00162 
00166   void Yaw(double angle);
00167 
00170   void Elevation(double angle);
00171 
00174   void Pitch(double angle);
00175 
00177 
00180   void SetParallelProjection(int flag);
00181   vtkGetMacro(ParallelProjection,int);
00182   vtkBooleanMacro(ParallelProjection,int);
00184 
00186 
00192   void SetUseHorizontalViewAngle(int flag);
00193   vtkGetMacro(UseHorizontalViewAngle, int);
00194   vtkBooleanMacro(UseHorizontalViewAngle, int);
00196 
00198 
00205   void SetViewAngle(double angle);
00206   vtkGetMacro(ViewAngle,double);
00208 
00210 
00215   void SetParallelScale(double scale);
00216   vtkGetMacro(ParallelScale,double);
00218 
00223   void Zoom(double factor);
00224 
00226 
00233   void SetClippingRange(double near, double far);
00234   void SetClippingRange(const double a[2]) {
00235     this->SetClippingRange(a[0], a[1]); };
00236   void SetClippingRange(const float a[2]) {
00237     this->SetClippingRange(a[0], a[1]); };
00238   vtkGetVector2Macro(ClippingRange,double);
00239   void GetClippingRange(float a[2]) {
00240     double tmp[2]; this->GetClippingRange(tmp); 
00241     a[0] = static_cast<float>(tmp[0]); 
00242     a[1] = static_cast<float>(tmp[1]); }; 
00244 
00246 
00249   void SetThickness(double);
00250   vtkGetMacro(Thickness,double);
00252 
00254 
00259   void SetWindowCenter(double x, double y);
00260   vtkGetVector2Macro(WindowCenter,double);
00262 
00271   void SetObliqueAngles(double alpha, double beta);
00272 
00276   void ApplyTransform(vtkTransform *t);
00277 
00279 
00282   vtkGetVector3Macro(ViewPlaneNormal,double);
00283   void GetViewPlaneNormal(float a[3]) {
00284     double tmp[3]; this->GetViewPlaneNormal(tmp); 
00285     a[0] = static_cast<float>(tmp[0]); 
00286     a[1] = static_cast<float>(tmp[1]); 
00287     a[2] = static_cast<float>(tmp[2]); }; 
00289 
00290 
00292 
00296   void SetViewShear(double dxdz, double dydz, double center);
00297   void SetViewShear(double d[3]);
00298   vtkGetVector3Macro(ViewShear, double);
00300 
00302 
00304   vtkSetMacro(EyeAngle,double);
00305   vtkGetMacro(EyeAngle,double);
00307 
00309 
00313   vtkSetMacro(FocalDisk,double);
00314   vtkGetMacro(FocalDisk,double);
00316 
00318   virtual vtkMatrix4x4 *GetViewTransformMatrix();
00319   
00321 
00326   virtual vtkMatrix4x4 *GetPerspectiveTransformMatrix(double aspect,
00327                                               double nearz, 
00328                                               double farz);
00330 
00332 
00338   virtual vtkMatrix4x4 *GetCompositePerspectiveTransformMatrix(double aspect, 
00339                                                        double nearz, 
00340                                                        double farz);
00342 
00344 
00348   void SetUserTransform(vtkLinearTransform *transform);
00349   vtkGetObjectMacro(UserTransform,vtkLinearTransform);
00351 
00355   virtual void Render(vtkRenderer *) {};
00356 
00359   unsigned long GetViewingRaysMTime();
00360 
00363   void ViewingRaysModified();
00364 
00370   virtual void GetFrustumPlanes(float aspect, float planes[24]);
00371 
00373 
00374   float *GetOrientation();
00375   float *GetOrientationWXYZ();
00377 
00379 
00382   void SetViewPlaneNormal(double x, double y, double z);
00383   void SetViewPlaneNormal(const double a[3]) {
00384     this->SetViewPlaneNormal(a[0], a[1], a[2]); };
00385   void SetViewPlaneNormal(const float a[3]) {
00386     this->SetViewPlaneNormal(a[0], a[1], a[2]); };
00388 
00391   void ComputeViewPlaneNormal();
00392 
00396   vtkMatrix4x4 *GetCameraLightTransformMatrix();
00397   
00399   virtual void UpdateViewport(vtkRenderer *vtkNotUsed(ren)) {}
00400   
00401   virtual vtkTransform *GetViewTransformObject() {return this->ViewTransform;};
00402   
00403 protected:
00404   vtkCamera();
00405   ~vtkCamera();
00406 
00408 
00409   void ComputeDistance();
00410   void ComputeViewTransform();
00411   void ComputePerspectiveTransform(double aspect, double nearz, double farz);
00412   void ComputeCompositePerspectiveTransform(double aspect, 
00413                                             double nearz, double farz);
00414   void ComputeCameraLightTransform();
00416 
00417   double WindowCenter[2];
00418   double ObliqueAngles[2];
00419   double FocalPoint[3];
00420   double Position[3];
00421   double ViewUp[3];
00422   double ViewAngle;
00423   double ClippingRange[2];
00424   double EyeAngle;
00425   int    ParallelProjection;
00426   double ParallelScale;
00427   int    Stereo;
00428   int    LeftEye;
00429   double Thickness;
00430   double Distance;
00431   double DirectionOfProjection[3];
00432   double ViewPlaneNormal[3];
00433   double ViewShear[3];
00434   int    UseHorizontalViewAngle;
00435   vtkLinearTransform *UserTransform;
00436 
00437   vtkTransform *ViewTransform;
00438   vtkPerspectiveTransform *PerspectiveTransform;
00439   vtkPerspectiveTransform *Transform;
00440   vtkTransform *CameraLightTransform;
00441 
00442   double FocalDisk;
00443 
00444   // ViewingRaysMtime keeps track of camera modifications which will 
00445   // change the calculation of viewing rays for the camera before it is 
00446   // transformed to the camera's location and orientation. 
00447   vtkTimeStamp ViewingRaysMTime;
00448 private:
00449   vtkCamera(const vtkCamera&);  // Not implemented.
00450   void operator=(const vtkCamera&);  // Not implemented.
00451 };
00452 
00453 #endif
00454