VTK  9.2.6
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 =========================================================================*/
35 #ifndef vtkCamera_h
36 #define vtkCamera_h
37 
38 #include "vtkObject.h"
39 #include "vtkRect.h" // for ivar
40 #include "vtkRenderingCoreModule.h" // For export macro
41 
43 class vtkInformation;
44 class vtkMatrix4x4;
46 class vtkRenderer;
47 class vtkTransform;
48 class vtkCallbackCommand;
49 class vtkCameraCallbackCommand;
50 
51 class VTKRENDERINGCORE_EXPORT vtkCamera : public vtkObject
52 {
53 public:
54  vtkTypeMacro(vtkCamera, vtkObject);
55  void PrintSelf(ostream& os, vtkIndent indent) override;
56 
62  static vtkCamera* New();
63 
65 
69  void SetPosition(double x, double y, double z);
70  void SetPosition(const double a[3]) { this->SetPosition(a[0], a[1], a[2]); }
71  vtkGetVector3Macro(Position, double);
73 
75 
79  void SetFocalPoint(double x, double y, double z);
80  void SetFocalPoint(const double a[3]) { this->SetFocalPoint(a[0], a[1], a[2]); }
81  vtkGetVector3Macro(FocalPoint, double);
83 
85 
89  void SetViewUp(double vx, double vy, double vz);
90  void SetViewUp(const double a[3]) { this->SetViewUp(a[0], a[1], a[2]); }
91  vtkGetVector3Macro(ViewUp, double);
93 
99  void OrthogonalizeViewUp();
100 
105  void SetDistance(double);
106 
108 
112  vtkGetMacro(Distance, double);
114 
116 
121  vtkGetVector3Macro(DirectionOfProjection, double);
123 
130  void Dolly(double value);
131 
133 
136  void SetRoll(double angle);
137  double GetRoll();
139 
144  void Roll(double angle);
145 
152  void Azimuth(double angle);
153 
161  void Yaw(double angle);
162 
169  void Elevation(double angle);
170 
176  void Pitch(double angle);
177 
179 
185  void SetParallelProjection(vtkTypeBool flag);
186  vtkGetMacro(ParallelProjection, vtkTypeBool);
187  vtkBooleanMacro(ParallelProjection, vtkTypeBool);
189 
191 
201  void SetUseHorizontalViewAngle(vtkTypeBool flag);
202  vtkGetMacro(UseHorizontalViewAngle, vtkTypeBool);
203  vtkBooleanMacro(UseHorizontalViewAngle, vtkTypeBool);
205 
207 
218  void SetViewAngle(double angle);
219  vtkGetMacro(ViewAngle, double);
221 
223 
232  void SetParallelScale(double scale);
233  vtkGetMacro(ParallelScale, double);
235 
243  void Zoom(double factor);
244 
246 
259  void SetClippingRange(double dNear, double dFar);
260  void SetClippingRange(const double a[2]) { this->SetClippingRange(a[0], a[1]); }
261  vtkGetVector2Macro(ClippingRange, double);
263 
265 
272  void SetThickness(double);
273  vtkGetMacro(Thickness, double);
275 
277 
286  void SetWindowCenter(double x, double y);
287  vtkGetVector2Macro(WindowCenter, double);
289 
303  void SetObliqueAngles(double alpha, double beta);
304 
310  void ApplyTransform(vtkTransform* t);
311 
313 
318  vtkGetVector3Macro(ViewPlaneNormal, double);
320 
322 
330  void SetViewShear(double dxdz, double dydz, double center);
331  void SetViewShear(double d[3]);
332  vtkGetVector3Macro(ViewShear, double);
334 
336 
340  vtkSetMacro(EyeAngle, double);
341  vtkGetMacro(EyeAngle, double);
343 
345 
351  vtkSetMacro(FocalDisk, double);
352  vtkGetMacro(FocalDisk, double);
354 
356 
364  vtkSetMacro(FocalDistance, double);
365  vtkGetMacro(FocalDistance, double);
367 
369 
378  vtkSetMacro(UseOffAxisProjection, vtkTypeBool);
379  vtkGetMacro(UseOffAxisProjection, vtkTypeBool);
380  vtkBooleanMacro(UseOffAxisProjection, vtkTypeBool);
382 
384 
389  vtkSetVector3Macro(ScreenBottomLeft, double);
390  vtkGetVector3Macro(ScreenBottomLeft, double);
392 
394 
399  vtkSetVector3Macro(ScreenBottomRight, double);
400  vtkGetVector3Macro(ScreenBottomRight, double);
402 
404 
409  vtkSetVector3Macro(ScreenTopRight, double);
410  vtkGetVector3Macro(ScreenTopRight, double);
412 
414 
419  vtkSetMacro(EyeSeparation, double);
420  vtkGetMacro(EyeSeparation, double);
422 
424 
430  void SetEyePosition(double eyePosition[3]);
431  void GetEyePosition(double eyePosition[3]);
433 
438  void GetEyePlaneNormal(double normal[3]);
439 
441 
447  void SetEyeTransformMatrix(vtkMatrix4x4* matrix);
448  vtkGetObjectMacro(EyeTransformMatrix, vtkMatrix4x4);
450 
457  void SetEyeTransformMatrix(const double elements[16]);
458 
460 
465  void SetModelTransformMatrix(vtkMatrix4x4* matrix);
466  vtkGetObjectMacro(ModelTransformMatrix, vtkMatrix4x4);
468 
474  void SetModelTransformMatrix(const double elements[16]);
475 
479  virtual vtkMatrix4x4* GetModelViewTransformMatrix();
480 
484  virtual vtkTransform* GetModelViewTransformObject();
485 
493  virtual vtkMatrix4x4* GetViewTransformMatrix();
494 
504  virtual vtkTransform* GetViewTransformObject();
505 
512  virtual void SetExplicitProjectionTransformMatrix(vtkMatrix4x4*);
513  vtkGetObjectMacro(ExplicitProjectionTransformMatrix, vtkMatrix4x4);
521  vtkSetMacro(UseExplicitProjectionTransformMatrix, bool);
522  vtkGetMacro(UseExplicitProjectionTransformMatrix, bool);
523  vtkBooleanMacro(UseExplicitProjectionTransformMatrix, bool);
531  vtkSetMacro(ExplicitAspectRatio, double);
532  vtkGetMacro(ExplicitAspectRatio, double);
541  vtkSetMacro(UseExplicitAspectRatio, bool);
542  vtkGetMacro(UseExplicitAspectRatio, bool);
543  vtkBooleanMacro(UseExplicitAspectRatio, bool);
556  virtual vtkMatrix4x4* GetProjectionTransformMatrix(double aspect, double nearz, double farz);
557 
568  virtual vtkPerspectiveTransform* GetProjectionTransformObject(
569  double aspect, double nearz, double farz);
570 
582  virtual vtkMatrix4x4* GetCompositeProjectionTransformMatrix(
583  double aspect, double nearz, double farz);
584 
592  virtual vtkMatrix4x4* GetProjectionTransformMatrix(vtkRenderer* ren);
593 
595 
600  void SetUserViewTransform(vtkHomogeneousTransform* transform);
601  vtkGetObjectMacro(UserViewTransform, vtkHomogeneousTransform);
603 
605 
610  void SetUserTransform(vtkHomogeneousTransform* transform);
611  vtkGetObjectMacro(UserTransform, vtkHomogeneousTransform);
613 
619  virtual void Render(vtkRenderer*) {}
620 
624  vtkMTimeType GetViewingRaysMTime();
625 
630  void ViewingRaysModified();
631 
642  virtual void GetFrustumPlanes(double aspect, double planes[24]);
643 
645 
655  virtual void UpdateIdealShiftScale(double aspect);
656  vtkGetVector3Macro(FocalPointShift, double);
657  vtkGetMacro(FocalPointScale, double);
658  vtkGetVector3Macro(NearPlaneShift, double);
659  vtkGetMacro(NearPlaneScale, double);
660  vtkSetMacro(ShiftScaleThreshold, double);
661  vtkGetMacro(ShiftScaleThreshold, double);
663 
665 
668  double* GetOrientation() VTK_SIZEHINT(3);
669  double* GetOrientationWXYZ() VTK_SIZEHINT(4);
671 
676  void ComputeViewPlaneNormal();
677 
683  vtkMatrix4x4* GetCameraLightTransformMatrix();
684 
688  virtual void UpdateViewport(vtkRenderer* vtkNotUsed(ren)) {}
689 
691 
694  vtkGetMacro(Stereo, int);
696 
698 
701  vtkSetMacro(LeftEye, int);
702  vtkGetMacro(LeftEye, int);
704 
711  void ShallowCopy(vtkCamera* source);
712 
719  void DeepCopy(vtkCamera* source);
720 
722 
727  vtkSetMacro(FreezeFocalPoint, bool);
728  vtkGetMacro(FreezeFocalPoint, bool);
730 
732 
735  vtkSetMacro(UseScissor, bool);
736  vtkGetMacro(UseScissor, bool);
738 
740 
743  void SetScissorRect(vtkRecti scissorRect);
744  void GetScissorRect(vtkRecti& scissorRect);
746 
748 
751  vtkGetObjectMacro(Information, vtkInformation);
752  virtual void SetInformation(vtkInformation*);
754 
755 protected:
756  vtkCamera();
757  ~vtkCamera() override;
758 
760 
763  void ComputeDistance();
764  virtual void ComputeViewTransform();
766 
770  virtual void ComputeProjectionTransform(double aspect, double nearz, double farz);
771 
775  void ComputeCompositeProjectionTransform(double aspect, double nearz, double farz);
776 
777  void ComputeCameraLightTransform();
778 
783  void ComputeWorldToScreenMatrix();
784 
788  void ComputeOffAxisProjectionFrustum();
789 
793  void ComputeModelViewMatrix();
794 
801  void PartialCopy(vtkCamera* source);
802 
803  double WindowCenter[2];
804  double ObliqueAngles[2];
805  double FocalPoint[3];
806  double Position[3];
807  double ViewUp[3];
808  double ViewAngle;
809  double ClippingRange[2];
810  double EyeAngle;
813  int Stereo;
814  int LeftEye;
815  double Thickness;
816  double Distance;
817  double DirectionOfProjection[3];
818  double ViewPlaneNormal[3];
819  double ViewShear[3];
821 
823 
824  double ScreenBottomLeft[3];
825  double ScreenBottomRight[3];
826  double ScreenTopRight[3];
827 
829 
832 
834 
836 
839 
842 
845 
850 
852 
853  double FocalDisk;
855 
856  double FocalPointShift[3];
858  double NearPlaneShift[3];
861 
862  vtkCameraCallbackCommand* UserViewTransformCallbackCommand;
863  friend class vtkCameraCallbackCommand;
864 
865  // ViewingRaysMtime keeps track of camera modifications which will
866  // change the calculation of viewing rays for the camera before it is
867  // transformed to the camera's location and orientation.
871 
873 
874  // Arbitrary extra information associated with this camera.
876 
877 private:
878  vtkCamera(const vtkCamera&) = delete;
879  void operator=(const vtkCamera&) = delete;
880 };
881 
882 #endif
vtkInformation * Information
Definition: vtkCamera.h:875
vtkHomogeneousTransform * UserTransform
Definition: vtkCamera.h:837
double EyeSeparation
Definition: vtkCamera.h:828
abstract base class for most VTK objects
Definition: vtkObject.h:62
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:41
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:90
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287
superclass for homogeneous transformations
record modification and/or execution time
Definition: vtkTimeStamp.h:35
double ViewAngle
Definition: vtkCamera.h:808
double ShiftScaleThreshold
Definition: vtkCamera.h:860
abstract specification for renderers
Definition: vtkRenderer.h:72
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:60
void SetPosition(const double a[3])
Set/Get the position of the camera in world coordinates.
Definition: vtkCamera.h:70
vtkTransform * ViewTransform
Definition: vtkCamera.h:846
vtkTypeBool UseHorizontalViewAngle
Definition: vtkCamera.h:820
double Distance
Definition: vtkCamera.h:816
double Thickness
Definition: vtkCamera.h:815
int vtkTypeBool
Definition: vtkABI.h:69
double FocalDistance
Definition: vtkCamera.h:854
vtkMatrix4x4 * ModelTransformMatrix
Definition: vtkCamera.h:835
supports function callbacks
vtkTimeStamp WorldToScreenMatrixMTime
Definition: vtkCamera.h:831
double ParallelScale
Definition: vtkCamera.h:812
bool UseScissor
Definition: vtkCamera.h:870
a simple class to control print indentation
Definition: vtkIndent.h:39
a virtual camera for 3D rendering
Definition: vtkCamera.h:51
vtkTypeBool UseOffAxisProjection
Definition: vtkCamera.h:822
virtual void Render(vtkRenderer *)
This method causes the camera to set up whatever is required for viewing the scene.
Definition: vtkCamera.h:619
void SetFocalPoint(const double a[3])
Set/Get the focal of the camera in world coordinates.
Definition: vtkCamera.h:80
double FocalPointScale
Definition: vtkCamera.h:857
double NearPlaneScale
Definition: vtkCamera.h:859
vtkMatrix4x4 * WorldToScreenMatrix
Definition: vtkCamera.h:830
vtkCameraCallbackCommand * UserViewTransformCallbackCommand
Definition: vtkCamera.h:862
int LeftEye
Definition: vtkCamera.h:814
vtkTransform * CameraLightTransform
Definition: vtkCamera.h:849
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:260
#define VTK_SIZEHINT(...)
double FocalDisk
Definition: vtkCamera.h:853
vtkTransform * ModelViewTransform
Definition: vtkCamera.h:851
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
double ExplicitAspectRatio
Definition: vtkCamera.h:843
vtkPerspectiveTransform * Transform
Definition: vtkCamera.h:848
vtkTypeBool ParallelProjection
Definition: vtkCamera.h:811
vtkMatrix4x4 * EyeTransformMatrix
Definition: vtkCamera.h:833
vtkMatrix4x4 * ExplicitProjectionTransformMatrix
Definition: vtkCamera.h:840
vtkRecti ScissorRect
Definition: vtkCamera.h:872
vtkTimeStamp ViewingRaysMTime
Definition: vtkCamera.h:868
int Stereo
Definition: vtkCamera.h:813
vtkHomogeneousTransform * UserViewTransform
Definition: vtkCamera.h:838
double EyeAngle
Definition: vtkCamera.h:810
bool FreezeFocalPoint
Definition: vtkCamera.h:869
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
bool UseExplicitProjectionTransformMatrix
Definition: vtkCamera.h:841
vtkPerspectiveTransform * ProjectionTransform
Definition: vtkCamera.h:847
bool UseExplicitAspectRatio
Definition: vtkCamera.h:844
describes a 4x4 matrix transformation