VTK  9.7.1
vtkCamera.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
23 #ifndef vtkCamera_h
24 #define vtkCamera_h
25 
26 #include "vtkObject.h"
27 #include "vtkRect.h" // for ivar
28 #include "vtkRenderingCoreModule.h" // For export macro
29 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
30 
31 VTK_ABI_NAMESPACE_BEGIN
33 class vtkInformation;
34 class vtkMatrix4x4;
36 class vtkRenderer;
37 class vtkTransform;
38 class vtkCallbackCommand;
39 class vtkCameraCallbackCommand;
40 
41 class VTKRENDERINGCORE_EXPORT VTK_MARSHALAUTO vtkCamera : public vtkObject
42 {
43 public:
44  vtkTypeMacro(vtkCamera, vtkObject);
45  void PrintSelf(ostream& os, vtkIndent indent) override;
46 
52  static vtkCamera* New();
53 
55 
59  void SetPosition(double x, double y, double z);
60  void SetPosition(const double a[3]) { this->SetPosition(a[0], a[1], a[2]); }
61  vtkGetVector3Macro(Position, double);
63 
65 
69  void SetFocalPoint(double x, double y, double z);
70  void SetFocalPoint(const double a[3]) { this->SetFocalPoint(a[0], a[1], a[2]); }
71  vtkGetVector3Macro(FocalPoint, double);
73 
75 
79  void SetViewUp(double vx, double vy, double vz);
80  void SetViewUp(const double a[3]) { this->SetViewUp(a[0], a[1], a[2]); }
81  vtkGetVector3Macro(ViewUp, double);
83 
89  void OrthogonalizeViewUp();
90 
95  void SetDistance(double);
96 
98 
102  vtkGetMacro(Distance, double);
104 
106 
111  vtkGetVector3Macro(DirectionOfProjection, double);
113 
120  void Dolly(double value);
121 
123 
126  void SetRoll(double angle);
127  double GetRoll();
129 
134  void Roll(double angle);
135 
142  void Azimuth(double angle);
143 
151  void Yaw(double angle);
152 
159  void Elevation(double angle);
160 
166  void Pitch(double angle);
167 
169 
175  void SetParallelProjection(vtkTypeBool flag);
176  vtkGetMacro(ParallelProjection, vtkTypeBool);
177  vtkBooleanMacro(ParallelProjection, vtkTypeBool);
179 
181 
191  void SetUseHorizontalViewAngle(vtkTypeBool flag);
192  vtkGetMacro(UseHorizontalViewAngle, vtkTypeBool);
193  vtkBooleanMacro(UseHorizontalViewAngle, vtkTypeBool);
195 
197 
208  void SetViewAngle(double angle);
209  vtkGetMacro(ViewAngle, double);
211 
213 
222  void SetParallelScale(double scale);
223  vtkGetMacro(ParallelScale, double);
225 
233  void Zoom(double factor);
234 
236 
249  void SetClippingRange(double dNear, double dFar);
250  void SetClippingRange(const double a[2]) { this->SetClippingRange(a[0], a[1]); }
251  vtkGetVector2Macro(ClippingRange, double);
253 
255 
262  void SetThickness(double);
263  vtkGetMacro(Thickness, double);
265 
267 
276  void SetWindowCenter(double x, double y);
277  vtkGetVector2Macro(WindowCenter, double);
279 
293  void SetObliqueAngles(double alpha, double beta);
294 
300  void ApplyTransform(vtkTransform* t);
301 
303 
308  vtkGetVector3Macro(ViewPlaneNormal, double);
310 
312 
320  void SetViewShear(double dxdz, double dydz, double center);
321  void SetViewShear(double d[3]);
322  vtkGetVector3Macro(ViewShear, double);
324 
326 
330  vtkSetMacro(EyeAngle, double);
331  vtkGetMacro(EyeAngle, double);
333 
335 
341  vtkSetMacro(FocalDisk, double);
342  vtkGetMacro(FocalDisk, double);
344 
346 
354  vtkSetMacro(FocalDistance, double);
355  vtkGetMacro(FocalDistance, double);
357 
359 
368  vtkSetMacro(UseOffAxisProjection, vtkTypeBool);
369  vtkGetMacro(UseOffAxisProjection, vtkTypeBool);
370  vtkBooleanMacro(UseOffAxisProjection, vtkTypeBool);
372 
374 
378  double GetOffAxisClippingAdjustment();
380 
382 
387  vtkSetVector3Macro(ScreenBottomLeft, double);
388  vtkGetVector3Macro(ScreenBottomLeft, double);
390 
392 
397  vtkSetVector3Macro(ScreenBottomRight, double);
398  vtkGetVector3Macro(ScreenBottomRight, double);
400 
402 
407  vtkSetVector3Macro(ScreenTopRight, double);
408  vtkGetVector3Macro(ScreenTopRight, double);
410 
412 
417  vtkSetMacro(EyeSeparation, double);
418  vtkGetMacro(EyeSeparation, double);
420 
422 
428  void SetEyePosition(double eyePosition[3]);
429  void GetEyePosition(double eyePosition[3]);
431 
433 
441  void GetStereoEyePosition(double eyePosition[3]);
443 
448  void GetEyePlaneNormal(double normal[3]);
449 
451 
457  void SetEyeTransformMatrix(vtkMatrix4x4* matrix);
458  void SetEyeTransformMatrix(const double elements[16]);
459  vtkGetObjectMacro(EyeTransformMatrix, vtkMatrix4x4);
461 
463 
468  void SetModelTransformMatrix(vtkMatrix4x4* matrix);
469  void SetModelTransformMatrix(const double elements[16]);
470  vtkGetObjectMacro(ModelTransformMatrix, vtkMatrix4x4);
472 
476  virtual vtkMatrix4x4* GetModelViewTransformMatrix();
477 
481  virtual vtkTransform* GetModelViewTransformObject();
482 
490  virtual vtkMatrix4x4* GetViewTransformMatrix();
491 
501  virtual vtkTransform* GetViewTransformObject();
502 
509  virtual void SetExplicitProjectionTransformMatrix(vtkMatrix4x4*);
510  vtkGetObjectMacro(ExplicitProjectionTransformMatrix, vtkMatrix4x4);
518  vtkSetMacro(UseExplicitProjectionTransformMatrix, bool);
519  vtkGetMacro(UseExplicitProjectionTransformMatrix, bool);
520  vtkBooleanMacro(UseExplicitProjectionTransformMatrix, bool);
528  vtkSetMacro(ExplicitAspectRatio, double);
529  vtkGetMacro(ExplicitAspectRatio, double);
538  vtkSetMacro(UseExplicitAspectRatio, bool);
539  vtkGetMacro(UseExplicitAspectRatio, bool);
540  vtkBooleanMacro(UseExplicitAspectRatio, bool);
553  virtual vtkMatrix4x4* GetProjectionTransformMatrix(double aspect, double nearz, double farz);
554 
565  virtual vtkPerspectiveTransform* GetProjectionTransformObject(
566  double aspect, double nearz, double farz);
567 
579  virtual vtkMatrix4x4* GetCompositeProjectionTransformMatrix(
580  double aspect, double nearz, double farz);
581 
589  virtual vtkMatrix4x4* GetProjectionTransformMatrix(vtkRenderer* ren);
590 
592 
597  void SetUserViewTransform(vtkHomogeneousTransform* transform);
598  vtkGetObjectMacro(UserViewTransform, vtkHomogeneousTransform);
600 
602 
607  void SetUserTransform(vtkHomogeneousTransform* transform);
608  vtkGetObjectMacro(UserTransform, vtkHomogeneousTransform);
610 
616  virtual void Render(vtkRenderer*) {}
617 
621  vtkMTimeType GetViewingRaysMTime();
622 
627  void ViewingRaysModified();
628 
639  virtual void GetFrustumPlanes(double aspect, double planes[24]);
640 
642 
652  virtual void UpdateIdealShiftScale(double aspect);
653  vtkGetVector3Macro(FocalPointShift, double);
654  vtkGetMacro(FocalPointScale, double);
655  vtkGetVector3Macro(NearPlaneShift, double);
656  vtkGetMacro(NearPlaneScale, double);
657  vtkSetMacro(ShiftScaleThreshold, double);
658  vtkGetMacro(ShiftScaleThreshold, double);
660 
662 
665  double* GetOrientation() VTK_SIZEHINT(3);
666  double* GetOrientationWXYZ() VTK_SIZEHINT(4);
668 
673  void ComputeViewPlaneNormal();
674 
680  vtkMatrix4x4* GetCameraLightTransformMatrix();
681 
685  virtual void UpdateViewport(vtkRenderer* vtkNotUsed(ren)) {}
686 
688 
691  vtkGetMacro(Stereo, int);
693 
695 
698  vtkSetMacro(LeftEye, int);
699  vtkGetMacro(LeftEye, int);
701 
708  void ShallowCopy(vtkCamera* source);
709 
716  void DeepCopy(vtkCamera* source);
717 
719 
724  vtkSetMacro(FreezeFocalPoint, bool);
725  vtkGetMacro(FreezeFocalPoint, bool);
727 
729 
732  vtkSetMacro(UseScissor, bool);
733  vtkGetMacro(UseScissor, bool);
735 
737 
740  void SetScissorRect(vtkRecti scissorRect);
741  void GetScissorRect(vtkRecti& scissorRect);
743 
745 
748  vtkGetObjectMacro(Information, vtkInformation);
749  virtual void SetInformation(vtkInformation*);
751 
752 protected:
753  vtkCamera();
754  ~vtkCamera() override;
755 
757 
760  void ComputeDistance();
761  virtual void ComputeViewTransform();
763 
767  virtual void ComputeProjectionTransform(double aspect, double nearz, double farz);
768 
772  void ComputeCompositeProjectionTransform(double aspect, double nearz, double farz);
773 
774  void ComputeCameraLightTransform();
775 
780  void ComputeScreenOrientationMatrix();
781 
785  void ComputeOffAxisProjectionFrustum();
786 
790  void ComputeModelViewMatrix();
791 
798  void PartialCopy(vtkCamera* source);
799 
800  double WindowCenter[2];
801  double ObliqueAngles[2];
802  double FocalPoint[3];
803  double Position[3];
804  double ViewUp[3];
805  double ViewAngle;
806  double ClippingRange[2];
807  double EyeAngle;
810  int Stereo;
811  int LeftEye;
812  double Thickness;
813  double Distance;
814  double DirectionOfProjection[3];
815  double ViewPlaneNormal[3];
816  double ViewShear[3];
818 
820 
821  double ScreenBottomLeft[3];
822  double ScreenBottomRight[3];
823  double ScreenTopRight[3];
824  double ScreenCenter[3];
825 
828 
831 
833 
836 
839 
842 
847 
849 
850  double FocalDisk;
852 
853  double FocalPointShift[3];
855  double NearPlaneShift[3];
858 
859  vtkCameraCallbackCommand* UserViewTransformCallbackCommand;
860  friend class vtkCameraCallbackCommand;
861 
862  // ViewingRaysMtime keeps track of camera modifications which will
863  // change the calculation of viewing rays for the camera before it is
864  // transformed to the camera's location and orientation.
868 
870 
871  // Arbitrary extra information associated with this camera.
873 
874 private:
875  vtkCamera(const vtkCamera&) = delete;
876  void operator=(const vtkCamera&) = delete;
877 };
878 
879 VTK_ABI_NAMESPACE_END
880 #endif
vtkInformation * Information
Definition: vtkCamera.h:872
vtkHomogeneousTransform * UserTransform
Definition: vtkCamera.h:834
double EyeSeparation
Definition: vtkCamera.h:827
abstract base class for most VTK objects
Definition: vtkObject.h:52
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:31
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:80
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:318
superclass for homogeneous transformations
vtkMatrix4x4 * ProjectionPlaneOrientationMatrix
Definition: vtkCamera.h:830
record modification and/or execution time
Definition: vtkTimeStamp.h:24
double ViewAngle
Definition: vtkCamera.h:805
double ShiftScaleThreshold
Definition: vtkCamera.h:857
abstract specification for renderers
Definition: vtkRenderer.h:63
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:50
void SetPosition(const double a[3])
Set/Get the position of the camera in world coordinates.
Definition: vtkCamera.h:60
vtkTransform * ViewTransform
Definition: vtkCamera.h:843
vtkTypeBool UseHorizontalViewAngle
Definition: vtkCamera.h:817
double Distance
Definition: vtkCamera.h:813
double Thickness
Definition: vtkCamera.h:812
int vtkTypeBool
Definition: vtkABI.h:64
double FocalDistance
Definition: vtkCamera.h:851
vtkMatrix4x4 * ModelTransformMatrix
Definition: vtkCamera.h:832
supports function callbacks
double ParallelScale
Definition: vtkCamera.h:809
bool UseScissor
Definition: vtkCamera.h:867
a simple class to control print indentation
Definition: vtkIndent.h:28
a virtual camera for 3D rendering
Definition: vtkCamera.h:41
vtkTypeBool UseOffAxisProjection
Definition: vtkCamera.h:819
virtual void Render(vtkRenderer *)
This method causes the camera to set up whatever is required for viewing the scene.
Definition: vtkCamera.h:616
void SetFocalPoint(const double a[3])
Set/Get the focal of the camera in world coordinates.
Definition: vtkCamera.h:70
double FocalPointScale
Definition: vtkCamera.h:854
double NearPlaneScale
Definition: vtkCamera.h:856
vtkCameraCallbackCommand * UserViewTransformCallbackCommand
Definition: vtkCamera.h:859
int LeftEye
Definition: vtkCamera.h:811
vtkTransform * CameraLightTransform
Definition: vtkCamera.h:846
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:250
#define VTK_SIZEHINT(...)
double FocalDisk
Definition: vtkCamera.h:850
vtkTransform * ModelViewTransform
Definition: vtkCamera.h:848
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
double ExplicitAspectRatio
Definition: vtkCamera.h:840
vtkPerspectiveTransform * Transform
Definition: vtkCamera.h:845
vtkTypeBool ParallelProjection
Definition: vtkCamera.h:808
vtkMatrix4x4 * EyeTransformMatrix
Definition: vtkCamera.h:829
double OffAxisClippingAdjustment
Definition: vtkCamera.h:826
vtkMatrix4x4 * ExplicitProjectionTransformMatrix
Definition: vtkCamera.h:837
vtkRecti ScissorRect
Definition: vtkCamera.h:869
vtkTimeStamp ViewingRaysMTime
Definition: vtkCamera.h:865
int Stereo
Definition: vtkCamera.h:810
vtkHomogeneousTransform * UserViewTransform
Definition: vtkCamera.h:835
double EyeAngle
Definition: vtkCamera.h:807
bool FreezeFocalPoint
Definition: vtkCamera.h:866
#define VTK_MARSHALAUTO
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
bool UseExplicitProjectionTransformMatrix
Definition: vtkCamera.h:838
vtkPerspectiveTransform * ProjectionTransform
Definition: vtkCamera.h:844
bool UseExplicitAspectRatio
Definition: vtkCamera.h:841
describes a 4x4 matrix transformation