VTK  9.3.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 
30 VTK_ABI_NAMESPACE_BEGIN
32 class vtkInformation;
33 class vtkMatrix4x4;
35 class vtkRenderer;
36 class vtkTransform;
37 class vtkCallbackCommand;
38 class vtkCameraCallbackCommand;
39 
40 class VTKRENDERINGCORE_EXPORT vtkCamera : public vtkObject
41 {
42 public:
43  vtkTypeMacro(vtkCamera, vtkObject);
44  void PrintSelf(ostream& os, vtkIndent indent) override;
45 
51  static vtkCamera* New();
52 
54 
58  void SetPosition(double x, double y, double z);
59  void SetPosition(const double a[3]) { this->SetPosition(a[0], a[1], a[2]); }
60  vtkGetVector3Macro(Position, double);
62 
64 
68  void SetFocalPoint(double x, double y, double z);
69  void SetFocalPoint(const double a[3]) { this->SetFocalPoint(a[0], a[1], a[2]); }
70  vtkGetVector3Macro(FocalPoint, double);
72 
74 
78  void SetViewUp(double vx, double vy, double vz);
79  void SetViewUp(const double a[3]) { this->SetViewUp(a[0], a[1], a[2]); }
80  vtkGetVector3Macro(ViewUp, double);
82 
88  void OrthogonalizeViewUp();
89 
94  void SetDistance(double);
95 
97 
101  vtkGetMacro(Distance, double);
103 
105 
110  vtkGetVector3Macro(DirectionOfProjection, double);
112 
119  void Dolly(double value);
120 
122 
125  void SetRoll(double angle);
126  double GetRoll();
128 
133  void Roll(double angle);
134 
141  void Azimuth(double angle);
142 
150  void Yaw(double angle);
151 
158  void Elevation(double angle);
159 
165  void Pitch(double angle);
166 
168 
174  void SetParallelProjection(vtkTypeBool flag);
175  vtkGetMacro(ParallelProjection, vtkTypeBool);
176  vtkBooleanMacro(ParallelProjection, vtkTypeBool);
178 
180 
190  void SetUseHorizontalViewAngle(vtkTypeBool flag);
191  vtkGetMacro(UseHorizontalViewAngle, vtkTypeBool);
192  vtkBooleanMacro(UseHorizontalViewAngle, vtkTypeBool);
194 
196 
207  void SetViewAngle(double angle);
208  vtkGetMacro(ViewAngle, double);
210 
212 
221  void SetParallelScale(double scale);
222  vtkGetMacro(ParallelScale, double);
224 
232  void Zoom(double factor);
233 
235 
248  void SetClippingRange(double dNear, double dFar);
249  void SetClippingRange(const double a[2]) { this->SetClippingRange(a[0], a[1]); }
250  vtkGetVector2Macro(ClippingRange, double);
252 
254 
261  void SetThickness(double);
262  vtkGetMacro(Thickness, double);
264 
266 
275  void SetWindowCenter(double x, double y);
276  vtkGetVector2Macro(WindowCenter, double);
278 
292  void SetObliqueAngles(double alpha, double beta);
293 
299  void ApplyTransform(vtkTransform* t);
300 
302 
307  vtkGetVector3Macro(ViewPlaneNormal, double);
309 
311 
319  void SetViewShear(double dxdz, double dydz, double center);
320  void SetViewShear(double d[3]);
321  vtkGetVector3Macro(ViewShear, double);
323 
325 
329  vtkSetMacro(EyeAngle, double);
330  vtkGetMacro(EyeAngle, double);
332 
334 
340  vtkSetMacro(FocalDisk, double);
341  vtkGetMacro(FocalDisk, double);
343 
345 
353  vtkSetMacro(FocalDistance, double);
354  vtkGetMacro(FocalDistance, double);
356 
358 
367  vtkSetMacro(UseOffAxisProjection, vtkTypeBool);
368  vtkGetMacro(UseOffAxisProjection, vtkTypeBool);
369  vtkBooleanMacro(UseOffAxisProjection, vtkTypeBool);
371 
373 
377  double GetOffAxisClippingAdjustment();
379 
381 
386  vtkSetVector3Macro(ScreenBottomLeft, double);
387  vtkGetVector3Macro(ScreenBottomLeft, double);
389 
391 
396  vtkSetVector3Macro(ScreenBottomRight, double);
397  vtkGetVector3Macro(ScreenBottomRight, double);
399 
401 
406  vtkSetVector3Macro(ScreenTopRight, double);
407  vtkGetVector3Macro(ScreenTopRight, double);
409 
411 
416  vtkSetMacro(EyeSeparation, double);
417  vtkGetMacro(EyeSeparation, double);
419 
421 
427  void SetEyePosition(double eyePosition[3]);
428  void GetEyePosition(double eyePosition[3]);
430 
432 
440  void GetStereoEyePosition(double eyePosition[3]);
442 
447  void GetEyePlaneNormal(double normal[3]);
448 
450 
456  void SetEyeTransformMatrix(vtkMatrix4x4* matrix);
457  vtkGetObjectMacro(EyeTransformMatrix, vtkMatrix4x4);
459 
466  void SetEyeTransformMatrix(const double elements[16]);
467 
469 
474  void SetModelTransformMatrix(vtkMatrix4x4* matrix);
475  vtkGetObjectMacro(ModelTransformMatrix, vtkMatrix4x4);
477 
483  void SetModelTransformMatrix(const double elements[16]);
484 
488  virtual vtkMatrix4x4* GetModelViewTransformMatrix();
489 
493  virtual vtkTransform* GetModelViewTransformObject();
494 
502  virtual vtkMatrix4x4* GetViewTransformMatrix();
503 
513  virtual vtkTransform* GetViewTransformObject();
514 
521  virtual void SetExplicitProjectionTransformMatrix(vtkMatrix4x4*);
522  vtkGetObjectMacro(ExplicitProjectionTransformMatrix, vtkMatrix4x4);
530  vtkSetMacro(UseExplicitProjectionTransformMatrix, bool);
531  vtkGetMacro(UseExplicitProjectionTransformMatrix, bool);
532  vtkBooleanMacro(UseExplicitProjectionTransformMatrix, bool);
540  vtkSetMacro(ExplicitAspectRatio, double);
541  vtkGetMacro(ExplicitAspectRatio, double);
550  vtkSetMacro(UseExplicitAspectRatio, bool);
551  vtkGetMacro(UseExplicitAspectRatio, bool);
552  vtkBooleanMacro(UseExplicitAspectRatio, bool);
565  virtual vtkMatrix4x4* GetProjectionTransformMatrix(double aspect, double nearz, double farz);
566 
577  virtual vtkPerspectiveTransform* GetProjectionTransformObject(
578  double aspect, double nearz, double farz);
579 
591  virtual vtkMatrix4x4* GetCompositeProjectionTransformMatrix(
592  double aspect, double nearz, double farz);
593 
601  virtual vtkMatrix4x4* GetProjectionTransformMatrix(vtkRenderer* ren);
602 
604 
609  void SetUserViewTransform(vtkHomogeneousTransform* transform);
610  vtkGetObjectMacro(UserViewTransform, vtkHomogeneousTransform);
612 
614 
619  void SetUserTransform(vtkHomogeneousTransform* transform);
620  vtkGetObjectMacro(UserTransform, vtkHomogeneousTransform);
622 
628  virtual void Render(vtkRenderer*) {}
629 
633  vtkMTimeType GetViewingRaysMTime();
634 
639  void ViewingRaysModified();
640 
651  virtual void GetFrustumPlanes(double aspect, double planes[24]);
652 
654 
664  virtual void UpdateIdealShiftScale(double aspect);
665  vtkGetVector3Macro(FocalPointShift, double);
666  vtkGetMacro(FocalPointScale, double);
667  vtkGetVector3Macro(NearPlaneShift, double);
668  vtkGetMacro(NearPlaneScale, double);
669  vtkSetMacro(ShiftScaleThreshold, double);
670  vtkGetMacro(ShiftScaleThreshold, double);
672 
674 
677  double* GetOrientation() VTK_SIZEHINT(3);
678  double* GetOrientationWXYZ() VTK_SIZEHINT(4);
680 
685  void ComputeViewPlaneNormal();
686 
692  vtkMatrix4x4* GetCameraLightTransformMatrix();
693 
697  virtual void UpdateViewport(vtkRenderer* vtkNotUsed(ren)) {}
698 
700 
703  vtkGetMacro(Stereo, int);
705 
707 
710  vtkSetMacro(LeftEye, int);
711  vtkGetMacro(LeftEye, int);
713 
720  void ShallowCopy(vtkCamera* source);
721 
728  void DeepCopy(vtkCamera* source);
729 
731 
736  vtkSetMacro(FreezeFocalPoint, bool);
737  vtkGetMacro(FreezeFocalPoint, bool);
739 
741 
744  vtkSetMacro(UseScissor, bool);
745  vtkGetMacro(UseScissor, bool);
747 
749 
752  void SetScissorRect(vtkRecti scissorRect);
753  void GetScissorRect(vtkRecti& scissorRect);
755 
757 
760  vtkGetObjectMacro(Information, vtkInformation);
761  virtual void SetInformation(vtkInformation*);
763 
764 protected:
765  vtkCamera();
766  ~vtkCamera() override;
767 
769 
772  void ComputeDistance();
773  virtual void ComputeViewTransform();
775 
779  virtual void ComputeProjectionTransform(double aspect, double nearz, double farz);
780 
784  void ComputeCompositeProjectionTransform(double aspect, double nearz, double farz);
785 
786  void ComputeCameraLightTransform();
787 
792  void ComputeScreenOrientationMatrix();
793 
797  void ComputeOffAxisProjectionFrustum();
798 
802  void ComputeModelViewMatrix();
803 
810  void PartialCopy(vtkCamera* source);
811 
812  double WindowCenter[2];
813  double ObliqueAngles[2];
814  double FocalPoint[3];
815  double Position[3];
816  double ViewUp[3];
817  double ViewAngle;
818  double ClippingRange[2];
819  double EyeAngle;
822  int Stereo;
823  int LeftEye;
824  double Thickness;
825  double Distance;
826  double DirectionOfProjection[3];
827  double ViewPlaneNormal[3];
828  double ViewShear[3];
830 
832 
833  double ScreenBottomLeft[3];
834  double ScreenBottomRight[3];
835  double ScreenTopRight[3];
836  double ScreenCenter[3];
837 
840 
843 
845 
848 
851 
854 
859 
861 
862  double FocalDisk;
864 
865  double FocalPointShift[3];
867  double NearPlaneShift[3];
870 
871  vtkCameraCallbackCommand* UserViewTransformCallbackCommand;
872  friend class vtkCameraCallbackCommand;
873 
874  // ViewingRaysMtime keeps track of camera modifications which will
875  // change the calculation of viewing rays for the camera before it is
876  // transformed to the camera's location and orientation.
880 
882 
883  // Arbitrary extra information associated with this camera.
885 
886 private:
887  vtkCamera(const vtkCamera&) = delete;
888  void operator=(const vtkCamera&) = delete;
889 };
890 
891 VTK_ABI_NAMESPACE_END
892 #endif
vtkInformation * Information
Definition: vtkCamera.h:884
vtkHomogeneousTransform * UserTransform
Definition: vtkCamera.h:846
double EyeSeparation
Definition: vtkCamera.h:839
abstract base class for most VTK objects
Definition: vtkObject.h:51
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:30
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:79
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:270
superclass for homogeneous transformations
vtkMatrix4x4 * ProjectionPlaneOrientationMatrix
Definition: vtkCamera.h:842
record modification and/or execution time
Definition: vtkTimeStamp.h:24
double ViewAngle
Definition: vtkCamera.h:817
double ShiftScaleThreshold
Definition: vtkCamera.h:869
abstract specification for renderers
Definition: vtkRenderer.h:61
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:49
void SetPosition(const double a[3])
Set/Get the position of the camera in world coordinates.
Definition: vtkCamera.h:59
vtkTransform * ViewTransform
Definition: vtkCamera.h:855
vtkTypeBool UseHorizontalViewAngle
Definition: vtkCamera.h:829
double Distance
Definition: vtkCamera.h:825
double Thickness
Definition: vtkCamera.h:824
int vtkTypeBool
Definition: vtkABI.h:64
double FocalDistance
Definition: vtkCamera.h:863
vtkMatrix4x4 * ModelTransformMatrix
Definition: vtkCamera.h:844
supports function callbacks
double ParallelScale
Definition: vtkCamera.h:821
bool UseScissor
Definition: vtkCamera.h:879
a simple class to control print indentation
Definition: vtkIndent.h:28
a virtual camera for 3D rendering
Definition: vtkCamera.h:40
vtkTypeBool UseOffAxisProjection
Definition: vtkCamera.h:831
virtual void Render(vtkRenderer *)
This method causes the camera to set up whatever is required for viewing the scene.
Definition: vtkCamera.h:628
void SetFocalPoint(const double a[3])
Set/Get the focal of the camera in world coordinates.
Definition: vtkCamera.h:69
double FocalPointScale
Definition: vtkCamera.h:866
double NearPlaneScale
Definition: vtkCamera.h:868
vtkCameraCallbackCommand * UserViewTransformCallbackCommand
Definition: vtkCamera.h:871
int LeftEye
Definition: vtkCamera.h:823
vtkTransform * CameraLightTransform
Definition: vtkCamera.h:858
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:249
#define VTK_SIZEHINT(...)
double FocalDisk
Definition: vtkCamera.h:862
vtkTransform * ModelViewTransform
Definition: vtkCamera.h:860
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
double ExplicitAspectRatio
Definition: vtkCamera.h:852
vtkPerspectiveTransform * Transform
Definition: vtkCamera.h:857
vtkTypeBool ParallelProjection
Definition: vtkCamera.h:820
vtkMatrix4x4 * EyeTransformMatrix
Definition: vtkCamera.h:841
double OffAxisClippingAdjustment
Definition: vtkCamera.h:838
vtkMatrix4x4 * ExplicitProjectionTransformMatrix
Definition: vtkCamera.h:849
vtkRecti ScissorRect
Definition: vtkCamera.h:881
vtkTimeStamp ViewingRaysMTime
Definition: vtkCamera.h:877
int Stereo
Definition: vtkCamera.h:822
vtkHomogeneousTransform * UserViewTransform
Definition: vtkCamera.h:847
double EyeAngle
Definition: vtkCamera.h:819
bool FreezeFocalPoint
Definition: vtkCamera.h:878
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
bool UseExplicitProjectionTransformMatrix
Definition: vtkCamera.h:850
vtkPerspectiveTransform * ProjectionTransform
Definition: vtkCamera.h:856
bool UseExplicitAspectRatio
Definition: vtkCamera.h:853
describes a 4x4 matrix transformation