VTK  9.0.20200813
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 "vtkObject.h"
33 #include "vtkRect.h" // for ivar
34 #include "vtkRenderingCoreModule.h" // For export macro
35 
37 class vtkInformation;
38 class vtkMatrix4x4;
40 class vtkRenderer;
41 class vtkTransform;
42 class vtkCallbackCommand;
43 class vtkCameraCallbackCommand;
44 
45 class VTKRENDERINGCORE_EXPORT vtkCamera : public vtkObject
46 {
47 public:
48  vtkTypeMacro(vtkCamera, vtkObject);
49  void PrintSelf(ostream& os, vtkIndent indent) override;
50 
56  static vtkCamera* New();
57 
59 
63  void SetPosition(double x, double y, double z);
64  void SetPosition(const double a[3]) { 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]) { this->SetFocalPoint(a[0], a[1], a[2]); }
75  vtkGetVector3Macro(FocalPoint, double);
77 
79 
83  void SetViewUp(double vx, double vy, double vz);
84  void SetViewUp(const double a[3]) { this->SetViewUp(a[0], a[1], a[2]); }
85  vtkGetVector3Macro(ViewUp, double);
87 
93  void OrthogonalizeViewUp();
94 
99  void SetDistance(double);
100 
102 
106  vtkGetMacro(Distance, double);
108 
110 
115  vtkGetVector3Macro(DirectionOfProjection, double);
117 
124  void Dolly(double value);
125 
127 
130  void SetRoll(double angle);
131  double GetRoll();
133 
138  void Roll(double angle);
139 
146  void Azimuth(double angle);
147 
155  void Yaw(double angle);
156 
163  void Elevation(double angle);
164 
170  void Pitch(double angle);
171 
173 
179  void SetParallelProjection(vtkTypeBool flag);
180  vtkGetMacro(ParallelProjection, vtkTypeBool);
181  vtkBooleanMacro(ParallelProjection, vtkTypeBool);
183 
185 
195  void SetUseHorizontalViewAngle(vtkTypeBool flag);
196  vtkGetMacro(UseHorizontalViewAngle, vtkTypeBool);
197  vtkBooleanMacro(UseHorizontalViewAngle, vtkTypeBool);
199 
201 
212  void SetViewAngle(double angle);
213  vtkGetMacro(ViewAngle, double);
215 
217 
226  void SetParallelScale(double scale);
227  vtkGetMacro(ParallelScale, double);
229 
237  void Zoom(double factor);
238 
240 
253  void SetClippingRange(double dNear, double dFar);
254  void SetClippingRange(const double a[2]) { this->SetClippingRange(a[0], a[1]); }
255  vtkGetVector2Macro(ClippingRange, double);
257 
259 
266  void SetThickness(double);
267  vtkGetMacro(Thickness, double);
269 
271 
280  void SetWindowCenter(double x, double y);
281  vtkGetVector2Macro(WindowCenter, double);
283 
297  void SetObliqueAngles(double alpha, double beta);
298 
304  void ApplyTransform(vtkTransform* t);
305 
307 
312  vtkGetVector3Macro(ViewPlaneNormal, double);
314 
316 
324  void SetViewShear(double dxdz, double dydz, double center);
325  void SetViewShear(double d[3]);
326  vtkGetVector3Macro(ViewShear, double);
328 
330 
334  vtkSetMacro(EyeAngle, double);
335  vtkGetMacro(EyeAngle, double);
337 
339 
345  vtkSetMacro(FocalDisk, double);
346  vtkGetMacro(FocalDisk, double);
348 
350 
358  vtkSetMacro(FocalDistance, double);
359  vtkGetMacro(FocalDistance, double);
361 
363 
372  vtkSetMacro(UseOffAxisProjection, vtkTypeBool);
373  vtkGetMacro(UseOffAxisProjection, vtkTypeBool);
374  vtkBooleanMacro(UseOffAxisProjection, vtkTypeBool);
376 
378 
383  vtkSetVector3Macro(ScreenBottomLeft, double);
384  vtkGetVector3Macro(ScreenBottomLeft, double);
386 
388 
393  vtkSetVector3Macro(ScreenBottomRight, double);
394  vtkGetVector3Macro(ScreenBottomRight, double);
396 
398 
403  vtkSetVector3Macro(ScreenTopRight, double);
404  vtkGetVector3Macro(ScreenTopRight, double);
406 
408 
413  vtkSetMacro(EyeSeparation, double);
414  vtkGetMacro(EyeSeparation, double);
416 
418 
424  void SetEyePosition(double eyePosition[3]);
425  void GetEyePosition(double eyePosition[3]);
427 
432  void GetEyePlaneNormal(double normal[3]);
433 
435 
441  void SetEyeTransformMatrix(vtkMatrix4x4* matrix);
442  vtkGetObjectMacro(EyeTransformMatrix, vtkMatrix4x4);
444 
451  void SetEyeTransformMatrix(const double elements[16]);
452 
454 
459  void SetModelTransformMatrix(vtkMatrix4x4* matrix);
460  vtkGetObjectMacro(ModelTransformMatrix, vtkMatrix4x4);
462 
468  void SetModelTransformMatrix(const double elements[16]);
469 
473  virtual vtkMatrix4x4* GetModelViewTransformMatrix();
474 
478  virtual vtkTransform* GetModelViewTransformObject();
479 
487  virtual vtkMatrix4x4* GetViewTransformMatrix();
488 
498  virtual vtkTransform* GetViewTransformObject();
499 
506  virtual void SetExplicitProjectionTransformMatrix(vtkMatrix4x4*);
507  vtkGetObjectMacro(ExplicitProjectionTransformMatrix, vtkMatrix4x4);
515  vtkSetMacro(UseExplicitProjectionTransformMatrix, bool);
516  vtkGetMacro(UseExplicitProjectionTransformMatrix, bool);
517  vtkBooleanMacro(UseExplicitProjectionTransformMatrix, bool);
525  vtkSetMacro(ExplicitAspectRatio, double);
526  vtkGetMacro(ExplicitAspectRatio, double);
535  vtkSetMacro(UseExplicitAspectRatio, bool);
536  vtkGetMacro(UseExplicitAspectRatio, bool);
537  vtkBooleanMacro(UseExplicitAspectRatio, bool);
550  virtual vtkMatrix4x4* GetProjectionTransformMatrix(double aspect, double nearz, double farz);
551 
562  virtual vtkPerspectiveTransform* GetProjectionTransformObject(
563  double aspect, double nearz, double farz);
564 
576  virtual vtkMatrix4x4* GetCompositeProjectionTransformMatrix(
577  double aspect, double nearz, double farz);
578 
586  virtual vtkMatrix4x4* GetProjectionTransformMatrix(vtkRenderer* ren);
587 
589 
594  void SetUserViewTransform(vtkHomogeneousTransform* transform);
595  vtkGetObjectMacro(UserViewTransform, vtkHomogeneousTransform);
597 
599 
604  void SetUserTransform(vtkHomogeneousTransform* transform);
605  vtkGetObjectMacro(UserTransform, vtkHomogeneousTransform);
607 
613  virtual void Render(vtkRenderer*) {}
614 
618  vtkMTimeType GetViewingRaysMTime();
619 
624  void ViewingRaysModified();
625 
636  virtual void GetFrustumPlanes(double aspect, double planes[24]);
637 
639 
649  virtual void UpdateIdealShiftScale(double aspect);
650  vtkGetVector3Macro(FocalPointShift, double);
651  vtkGetMacro(FocalPointScale, double);
652  vtkGetVector3Macro(NearPlaneShift, double);
653  vtkGetMacro(NearPlaneScale, double);
654  vtkSetMacro(ShiftScaleThreshold, double);
655  vtkGetMacro(ShiftScaleThreshold, double);
657 
659 
662  double* GetOrientation() VTK_SIZEHINT(3);
663  double* GetOrientationWXYZ() VTK_SIZEHINT(4);
665 
670  void ComputeViewPlaneNormal();
671 
677  vtkMatrix4x4* GetCameraLightTransformMatrix();
678 
682  virtual void UpdateViewport(vtkRenderer* vtkNotUsed(ren)) {}
683 
685 
688  vtkSetMacro(LeftEye, int);
689  vtkGetMacro(LeftEye, int);
691 
698  void ShallowCopy(vtkCamera* source);
699 
706  void DeepCopy(vtkCamera* source);
707 
709 
714  vtkSetMacro(FreezeFocalPoint, bool);
715  vtkGetMacro(FreezeFocalPoint, bool);
717 
719 
722  vtkSetMacro(UseScissor, bool);
723  vtkGetMacro(UseScissor, bool);
725 
727 
730  void SetScissorRect(vtkRecti scissorRect);
731  void GetScissorRect(vtkRecti& scissorRect);
733 
735 
738  vtkGetObjectMacro(Information, vtkInformation);
739  virtual void SetInformation(vtkInformation*);
741 
742 protected:
743  vtkCamera();
744  ~vtkCamera() override;
745 
747 
750  void ComputeDistance();
751  virtual void ComputeViewTransform();
753 
757  virtual void ComputeProjectionTransform(double aspect, double nearz, double farz);
758 
762  void ComputeCompositeProjectionTransform(double aspect, double nearz, double farz);
763 
764  void ComputeCameraLightTransform();
765 
770  void ComputeWorldToScreenMatrix();
771 
775  void ComputeOffAxisProjectionFrustum();
776 
780  void ComputeModelViewMatrix();
781 
788  void PartialCopy(vtkCamera* source);
789 
790  double WindowCenter[2];
791  double ObliqueAngles[2];
792  double FocalPoint[3];
793  double Position[3];
794  double ViewUp[3];
795  double ViewAngle;
796  double ClippingRange[2];
797  double EyeAngle;
800  int Stereo;
801  int LeftEye;
802  double Thickness;
803  double Distance;
804  double DirectionOfProjection[3];
805  double ViewPlaneNormal[3];
806  double ViewShear[3];
808 
810 
811  double ScreenBottomLeft[3];
812  double ScreenBottomRight[3];
813  double ScreenTopRight[3];
814 
816 
819 
821 
823 
826 
829 
832 
837 
839 
840  double FocalDisk;
842 
843  double FocalPointShift[3];
845  double NearPlaneShift[3];
848 
849  vtkCameraCallbackCommand* UserViewTransformCallbackCommand;
850  friend class vtkCameraCallbackCommand;
851 
852  // ViewingRaysMtime keeps track of camera modifications which will
853  // change the calculation of viewing rays for the camera before it is
854  // transformed to the camera's location and orientation.
858 
860 
861  // Arbitrary extra information associated with this camera.
863 
864 private:
865  vtkCamera(const vtkCamera&) = delete;
866  void operator=(const vtkCamera&) = delete;
867 };
868 
869 #endif
vtkCamera::ShiftScaleThreshold
double ShiftScaleThreshold
Definition: vtkCamera.h:847
vtkCamera::ViewTransform
vtkTransform * ViewTransform
Definition: vtkCamera.h:833
vtkCamera::UseScissor
bool UseScissor
Definition: vtkCamera.h:857
vtkCamera::CameraLightTransform
vtkTransform * CameraLightTransform
Definition: vtkCamera.h:836
vtkHomogeneousTransform
superclass for homogeneous transformations
Definition: vtkHomogeneousTransform.h:34
vtkX3D::alpha
Definition: vtkX3D.h:256
vtkX3D::scale
Definition: vtkX3D.h:235
vtkX3D::value
Definition: vtkX3D.h:226
vtkCamera::ParallelProjection
vtkTypeBool ParallelProjection
Definition: vtkCamera.h:798
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:32
vtkCamera::ExplicitAspectRatio
double ExplicitAspectRatio
Definition: vtkCamera.h:830
vtkCamera::ViewingRaysMTime
vtkTimeStamp ViewingRaysMTime
Definition: vtkCamera.h:855
vtkCamera::SetViewUp
void SetViewUp(const double a[3])
Definition: vtkCamera.h:84
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:62
vtkCamera::FocalPointScale
double FocalPointScale
Definition: vtkCamera.h:844
vtkCamera::LeftEye
int LeftEye
Definition: vtkCamera.h:801
vtkX3D::center
Definition: vtkX3D.h:236
vtkCamera::SetClippingRange
void SetClippingRange(const double a[2])
Definition: vtkCamera.h:254
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:54
vtkCamera::Stereo
int Stereo
Definition: vtkCamera.h:800
vtkCamera::Transform
vtkPerspectiveTransform * Transform
Definition: vtkCamera.h:835
vtkCamera::EyeAngle
double EyeAngle
Definition: vtkCamera.h:797
vtkCamera::UseOffAxisProjection
vtkTypeBool UseOffAxisProjection
Definition: vtkCamera.h:809
vtkCamera::UseExplicitProjectionTransformMatrix
bool UseExplicitProjectionTransformMatrix
Definition: vtkCamera.h:828
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:45
vtkCamera::UseExplicitAspectRatio
bool UseExplicitAspectRatio
Definition: vtkCamera.h:831
vtkCamera::ExplicitProjectionTransformMatrix
vtkMatrix4x4 * ExplicitProjectionTransformMatrix
Definition: vtkCamera.h:827
vtkCamera::ScissorRect
vtkRecti ScissorRect
Definition: vtkCamera.h:859
vtkRect.h
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:35
vtkCamera::ModelTransformMatrix
vtkMatrix4x4 * ModelTransformMatrix
Definition: vtkCamera.h:822
vtkCamera
a virtual camera for 3D rendering
Definition: vtkCamera.h:45
vtkCamera::SetPosition
void SetPosition(const double a[3])
Definition: vtkCamera.h:64
vtkCamera::WorldToScreenMatrixMTime
vtkTimeStamp WorldToScreenMatrixMTime
Definition: vtkCamera.h:818
vtkObject::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkCamera::Thickness
double Thickness
Definition: vtkCamera.h:802
vtkPerspectiveTransform
describes a 4x4 matrix transformation
Definition: vtkPerspectiveTransform.h:53
vtkObject.h
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:73
vtkCamera::FreezeFocalPoint
bool FreezeFocalPoint
Definition: vtkCamera.h:856
vtkParticleTracerBaseNamespace::Position
struct Position_t Position
Definition: vtkParticleTracerBase.h:63
vtkCamera::UserTransform
vtkHomogeneousTransform * UserTransform
Definition: vtkCamera.h:824
vtkCamera::FocalDisk
double FocalDisk
Definition: vtkCamera.h:840
vtkCamera::EyeSeparation
double EyeSeparation
Definition: vtkCamera.h:815
vtkCamera::Information
vtkInformation * Information
Definition: vtkCamera.h:862
vtkCamera::Render
virtual void Render(vtkRenderer *)
This method causes the camera to set up whatever is required for viewing the scene.
Definition: vtkCamera.h:613
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:67
vtkCamera::ProjectionTransform
vtkPerspectiveTransform * ProjectionTransform
Definition: vtkCamera.h:834
vtkCamera::ParallelScale
double ParallelScale
Definition: vtkCamera.h:799
vtkCallbackCommand
supports function callbacks
Definition: vtkCallbackCommand.h:44
vtkCamera::UseHorizontalViewAngle
vtkTypeBool UseHorizontalViewAngle
Definition: vtkCamera.h:807
vtkCamera::NearPlaneScale
double NearPlaneScale
Definition: vtkCamera.h:846
vtkCamera::UserViewTransformCallbackCommand
vtkCameraCallbackCommand * UserViewTransformCallbackCommand
Definition: vtkCamera.h:849
vtkCamera::SetFocalPoint
void SetFocalPoint(const double a[3])
Definition: vtkCamera.h:74
vtkRecti
Definition: vtkRect.h:312
source
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
Definition: vtkBoostGraphAdapter.h:959
vtkCamera::FocalDistance
double FocalDistance
Definition: vtkCamera.h:841
vtkCamera::Distance
double Distance
Definition: vtkCamera.h:803
vtkCamera::UserViewTransform
vtkHomogeneousTransform * UserViewTransform
Definition: vtkCamera.h:825
vtkCamera::ModelViewTransform
vtkTransform * ModelViewTransform
Definition: vtkCamera.h:838
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkCamera::EyeTransformMatrix
vtkMatrix4x4 * EyeTransformMatrix
Definition: vtkCamera.h:820
vtkCamera::ViewAngle
double ViewAngle
Definition: vtkCamera.h:795
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:285
vtkCamera::WorldToScreenMatrix
vtkMatrix4x4 * WorldToScreenMatrix
Definition: vtkCamera.h:817