VTK
vtkCamera.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkCamera.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
29 #ifndef vtkCamera_h
30 #define vtkCamera_h
31 
32 #include "vtkRenderingCoreModule.h" // For export macro
33 #include "vtkObject.h"
34 #include "vtkRect.h" // for ivar
35 
37 class vtkMatrix4x4;
39 class vtkRenderer;
40 class vtkTransform;
41 class vtkCallbackCommand;
42 class vtkCameraCallbackCommand;
43 
44 class VTKRENDERINGCORE_EXPORT vtkCamera : public vtkObject
45 {
46 public:
47  vtkTypeMacro(vtkCamera, vtkObject);
48  void PrintSelf(ostream& os, vtkIndent indent) override;
49 
55  static vtkCamera *New();
56 
58 
62  void SetPosition(double x, double y, double z);
63  void SetPosition(const double a[3]) {
64  this->SetPosition(a[0], a[1], a[2]); };
65  vtkGetVector3Macro(Position, double);
67 
69 
73  void SetFocalPoint(double x, double y, double z);
74  void SetFocalPoint(const double a[3]) {
75  this->SetFocalPoint(a[0], a[1], a[2]);};
76  vtkGetVector3Macro(FocalPoint, double);
78 
80 
84  void SetViewUp(double vx, double vy, double vz);
85  void SetViewUp(const double a[3]) {
86  this->SetViewUp(a[0], a[1], a[2]); }
87  vtkGetVector3Macro(ViewUp, double);
89 
95  void OrthogonalizeViewUp();
96 
101  void SetDistance(double);
102 
104 
108  vtkGetMacro(Distance, double);
110 
112 
117  vtkGetVector3Macro(DirectionOfProjection, double);
119 
126  void Dolly(double value);
127 
129 
132  void SetRoll(double angle);
133  double GetRoll();
135 
140  void Roll(double angle);
141 
148  void Azimuth(double angle);
149 
157  void Yaw(double angle);
158 
165  void Elevation(double angle);
166 
172  void Pitch(double angle);
173 
175 
181  void SetParallelProjection(vtkTypeBool flag);
182  vtkGetMacro(ParallelProjection, vtkTypeBool);
183  vtkBooleanMacro(ParallelProjection, vtkTypeBool);
185 
187 
197  void SetUseHorizontalViewAngle(vtkTypeBool flag);
198  vtkGetMacro(UseHorizontalViewAngle, vtkTypeBool);
199  vtkBooleanMacro(UseHorizontalViewAngle, vtkTypeBool);
201 
203 
214  void SetViewAngle(double angle);
215  vtkGetMacro(ViewAngle, double);
217 
219 
228  void SetParallelScale(double scale);
229  vtkGetMacro(ParallelScale ,double);
231 
239  void Zoom(double factor);
240 
242 
255  void SetClippingRange(double dNear, double dFar);
256  void SetClippingRange(const double a[2])
257  { this->SetClippingRange(a[0], a[1]); }
258  vtkGetVector2Macro(ClippingRange, double);
260 
262 
269  void SetThickness(double);
270  vtkGetMacro(Thickness, double);
272 
274 
283  void SetWindowCenter(double x, double y);
284  vtkGetVector2Macro(WindowCenter, double);
286 
300  void SetObliqueAngles(double alpha, double beta);
301 
307  void ApplyTransform(vtkTransform *t);
308 
310 
315  vtkGetVector3Macro(ViewPlaneNormal, double);
317 
319 
327  void SetViewShear(double dxdz, double dydz, double center);
328  void SetViewShear(double d[3]);
329  vtkGetVector3Macro(ViewShear, double);
331 
333 
337  vtkSetMacro(EyeAngle, double);
338  vtkGetMacro(EyeAngle, double);
340 
342 
348  vtkSetMacro(FocalDisk, double);
349  vtkGetMacro(FocalDisk, double);
351 
353 
362  vtkSetMacro(UseOffAxisProjection, vtkTypeBool);
363  vtkGetMacro(UseOffAxisProjection, vtkTypeBool);
364  vtkBooleanMacro(UseOffAxisProjection, vtkTypeBool);
366 
368 
373  vtkSetVector3Macro(ScreenBottomLeft, double);
374  vtkGetVector3Macro(ScreenBottomLeft, double);
376 
378 
383  vtkSetVector3Macro(ScreenBottomRight, double);
384  vtkGetVector3Macro(ScreenBottomRight, double);
386 
388 
393  vtkSetVector3Macro(ScreenTopRight, double);
394  vtkGetVector3Macro(ScreenTopRight, double);
396 
398 
403  vtkSetMacro(EyeSeparation, double);
404  vtkGetMacro(EyeSeparation, double);
406 
408 
414  void SetEyePosition(double eyePosition[3]);
415  void GetEyePosition(double eyePosition[3]);
417 
422  void GetEyePlaneNormal(double normal[3]);
423 
425 
431  void SetEyeTransformMatrix(vtkMatrix4x4* matrix);
432  vtkGetObjectMacro(EyeTransformMatrix, vtkMatrix4x4);
434 
441  void SetEyeTransformMatrix(const double elements[16]);
442 
444 
449  void SetModelTransformMatrix(vtkMatrix4x4 *matrix);
450  vtkGetObjectMacro(ModelTransformMatrix, vtkMatrix4x4);
452 
458  void SetModelTransformMatrix(const double elements[16]);
459 
463  virtual vtkMatrix4x4 *GetModelViewTransformMatrix();
464 
468  virtual vtkTransform *GetModelViewTransformObject();
469 
477  virtual vtkMatrix4x4 *GetViewTransformMatrix();
478 
488  virtual vtkTransform *GetViewTransformObject();
489 
496  virtual void SetExplicitProjectionTransformMatrix(vtkMatrix4x4*);
497  vtkGetObjectMacro(ExplicitProjectionTransformMatrix, vtkMatrix4x4)
505  vtkSetMacro(UseExplicitProjectionTransformMatrix, bool)
506  vtkGetMacro(UseExplicitProjectionTransformMatrix, bool)
507  vtkBooleanMacro(UseExplicitProjectionTransformMatrix, bool)
519  virtual vtkMatrix4x4 *GetProjectionTransformMatrix(double aspect,
520  double nearz,
521  double farz);
522 
532  virtual vtkPerspectiveTransform *GetProjectionTransformObject(double aspect,
533  double nearz,
534  double farz);
535 
546  virtual vtkMatrix4x4 *GetCompositeProjectionTransformMatrix(double aspect,
547  double nearz,
548  double farz);
549 
557  virtual vtkMatrix4x4 *GetProjectionTransformMatrix(vtkRenderer *ren);
558 
560 
565  void SetUserViewTransform(vtkHomogeneousTransform *transform);
566  vtkGetObjectMacro(UserViewTransform,vtkHomogeneousTransform);
568 
570 
575  void SetUserTransform(vtkHomogeneousTransform *transform);
576  vtkGetObjectMacro(UserTransform,vtkHomogeneousTransform);
578 
584  virtual void Render(vtkRenderer *) {}
585 
589  vtkMTimeType GetViewingRaysMTime();
590 
595  void ViewingRaysModified();
596 
606  virtual void GetFrustumPlanes(double aspect, double planes[24]);
607 
609 
612  double *GetOrientation() VTK_SIZEHINT(3);
613  double *GetOrientationWXYZ() VTK_SIZEHINT(4);
615 
620  void ComputeViewPlaneNormal();
621 
627  vtkMatrix4x4 *GetCameraLightTransformMatrix();
628 
632  virtual void UpdateViewport(vtkRenderer *vtkNotUsed(ren)) {}
633 
635 
638  vtkSetMacro(LeftEye, int);
639  vtkGetMacro(LeftEye, int);
641 
648  void ShallowCopy(vtkCamera *source);
649 
656  void DeepCopy(vtkCamera *source);
657 
659 
664  vtkSetMacro(FreezeFocalPoint, bool);
665  vtkGetMacro(FreezeFocalPoint, bool);
667 
669 
672  vtkSetMacro(UseScissor, bool);
673  vtkGetMacro(UseScissor, bool);
675 
677 
680  void SetScissorRect(vtkRecti scissorRect);
681  void GetScissorRect(vtkRecti& scissorRect);
683 
684 protected:
685  vtkCamera();
686  ~vtkCamera() override;
687 
689 
692  void ComputeDistance();
693  virtual void ComputeViewTransform();
695 
699  virtual void ComputeProjectionTransform(double aspect,
700  double nearz,
701  double farz);
702 
706  void ComputeCompositeProjectionTransform(double aspect,
707  double nearz,
708  double farz);
709 
710  void ComputeCameraLightTransform();
711 
712 
717  void ComputeWorldToScreenMatrix();
718 
722  void ComputeOffAxisProjectionFrustum();
723 
727  void ComputeModelViewMatrix();
728 
735  void PartialCopy(vtkCamera *source);
736 
737  double WindowCenter[2];
738  double ObliqueAngles[2];
739  double FocalPoint[3];
740  double Position[3];
741  double ViewUp[3];
742  double ViewAngle;
743  double ClippingRange[2];
744  double EyeAngle;
747  int Stereo;
748  int LeftEye;
749  double Thickness;
750  double Distance;
751  double DirectionOfProjection[3];
752  double ViewPlaneNormal[3];
753  double ViewShear[3];
755 
757 
758  double ScreenBottomLeft[3];
759  double ScreenBottomRight[3];
760  double ScreenTopRight[3];
761 
763 
766 
768 
770 
773 
776 
781 
783 
784  double FocalDisk;
785 
786  vtkCameraCallbackCommand *UserViewTransformCallbackCommand;
787  friend class vtkCameraCallbackCommand;
788 
789  // ViewingRaysMtime keeps track of camera modifications which will
790  // change the calculation of viewing rays for the camera before it is
791  // transformed to the camera's location and orientation.
795 
797 
798 
799 private:
800  vtkCamera(const vtkCamera&) = delete;
801  void operator=(const vtkCamera&) = delete;
802 };
803 
804 #endif
vtkHomogeneousTransform * UserTransform
Definition: vtkCamera.h:771
double EyeSeparation
Definition: vtkCamera.h:762
abstract base class for most VTK objects
Definition: vtkObject.h:53
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:35
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetViewUp(const double a[3])
Set/Get the view up direction for the camera.
Definition: vtkCamera.h:85
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:302
superclass for homogeneous transformations
record modification and/or execution time
Definition: vtkTimeStamp.h:32
double ViewAngle
Definition: vtkCamera.h:742
abstract specification for renderers
Definition: vtkRenderer.h:57
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:54
void SetPosition(const double a[3])
Set/Get the position of the camera in world coordinates.
Definition: vtkCamera.h:63
vtkTransform * ViewTransform
Definition: vtkCamera.h:777
vtkTypeBool UseHorizontalViewAngle
Definition: vtkCamera.h:754
double Distance
Definition: vtkCamera.h:750
double Thickness
Definition: vtkCamera.h:749
int vtkTypeBool
Definition: vtkABI.h:69
vtkMatrix4x4 * ModelTransformMatrix
Definition: vtkCamera.h:769
supports function callbacks
vtkTimeStamp WorldToScreenMatrixMTime
Definition: vtkCamera.h:765
double ParallelScale
Definition: vtkCamera.h:746
bool UseScissor
Definition: vtkCamera.h:794
a simple class to control print indentation
Definition: vtkIndent.h:33
a virtual camera for 3D rendering
Definition: vtkCamera.h:44
vtkTypeBool UseOffAxisProjection
Definition: vtkCamera.h:756
virtual void Render(vtkRenderer *)
This method causes the camera to set up whatever is required for viewing the scene.
Definition: vtkCamera.h:584
void SetFocalPoint(const double a[3])
Set/Get the focal of the camera in world coordinates.
Definition: vtkCamera.h:74
vtkMatrix4x4 * WorldToScreenMatrix
Definition: vtkCamera.h:764
vtkCameraCallbackCommand * UserViewTransformCallbackCommand
Definition: vtkCamera.h:786
int LeftEye
Definition: vtkCamera.h:748
vtkTransform * CameraLightTransform
Definition: vtkCamera.h:780
void SetClippingRange(const double a[2])
Set/Get the location of the near and far clipping planes along the direction of projection.
Definition: vtkCamera.h:256
#define VTK_SIZEHINT(...)
double FocalDisk
Definition: vtkCamera.h:784
vtkTransform * ModelViewTransform
Definition: vtkCamera.h:782
vtkPerspectiveTransform * Transform
Definition: vtkCamera.h:779
vtkTypeBool ParallelProjection
Definition: vtkCamera.h:745
vtkMatrix4x4 * EyeTransformMatrix
Definition: vtkCamera.h:767
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
vtkMatrix4x4 * ExplicitProjectionTransformMatrix
Definition: vtkCamera.h:774
vtkRecti ScissorRect
Definition: vtkCamera.h:796
vtkTimeStamp ViewingRaysMTime
Definition: vtkCamera.h:792
int Stereo
Definition: vtkCamera.h:747
vtkHomogeneousTransform * UserViewTransform
Definition: vtkCamera.h:772
double EyeAngle
Definition: vtkCamera.h:744
bool FreezeFocalPoint
Definition: vtkCamera.h:793
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
bool UseExplicitProjectionTransformMatrix
Definition: vtkCamera.h:775
vtkPerspectiveTransform * ProjectionTransform
Definition: vtkCamera.h:778
describes a 4x4 matrix transformation