VTK  9.1.0
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 
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 
180  vtkGetMacro(ParallelProjection, vtkTypeBool);
181  vtkBooleanMacro(ParallelProjection, vtkTypeBool);
183 
185 
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 
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 
442  vtkGetObjectMacro(EyeTransformMatrix, vtkMatrix4x4);
444 
451  void SetEyeTransformMatrix(const double elements[16]);
452 
454 
460  vtkGetObjectMacro(ModelTransformMatrix, vtkMatrix4x4);
462 
468  void SetModelTransformMatrix(const double elements[16]);
469 
474 
479 
488 
499 
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 
563  double aspect, double nearz, double farz);
564 
577  double aspect, double nearz, double farz);
578 
587 
589 
595  vtkGetObjectMacro(UserViewTransform, vtkHomogeneousTransform);
597 
599 
605  vtkGetObjectMacro(UserTransform, vtkHomogeneousTransform);
607 
613  virtual void Render(vtkRenderer*) {}
614 
619 
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 
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  vtkGetMacro(Stereo, int);
690 
692 
695  vtkSetMacro(LeftEye, int);
696  vtkGetMacro(LeftEye, int);
698 
706 
714 
716 
721  vtkSetMacro(FreezeFocalPoint, bool);
722  vtkGetMacro(FreezeFocalPoint, bool);
724 
726 
729  vtkSetMacro(UseScissor, bool);
730  vtkGetMacro(UseScissor, bool);
732 
734 
737  void SetScissorRect(vtkRecti scissorRect);
738  void GetScissorRect(vtkRecti& scissorRect);
740 
742 
745  vtkGetObjectMacro(Information, vtkInformation);
748 
749 protected:
751  ~vtkCamera() override;
752 
754 
758  virtual void ComputeViewTransform();
760 
764  virtual void ComputeProjectionTransform(double aspect, double nearz, double farz);
765 
769  void ComputeCompositeProjectionTransform(double aspect, double nearz, double farz);
770 
772 
778 
783 
788 
796 
797  double WindowCenter[2];
798  double ObliqueAngles[2];
799  double FocalPoint[3];
800  double Position[3];
801  double ViewUp[3];
802  double ViewAngle;
803  double ClippingRange[2];
804  double EyeAngle;
807  int Stereo;
808  int LeftEye;
809  double Thickness;
810  double Distance;
811  double DirectionOfProjection[3];
812  double ViewPlaneNormal[3];
813  double ViewShear[3];
815 
817 
818  double ScreenBottomLeft[3];
819  double ScreenBottomRight[3];
820  double ScreenTopRight[3];
821 
823 
826 
828 
830 
833 
836 
839 
844 
846 
847  double FocalDisk;
849 
850  double FocalPointShift[3];
852  double NearPlaneShift[3];
855 
856  vtkCameraCallbackCommand* UserViewTransformCallbackCommand;
857  friend class vtkCameraCallbackCommand;
858 
859  // ViewingRaysMtime keeps track of camera modifications which will
860  // change the calculation of viewing rays for the camera before it is
861  // transformed to the camera's location and orientation.
865 
867 
868  // Arbitrary extra information associated with this camera.
870 
871 private:
872  vtkCamera(const vtkCamera&) = delete;
873  void operator=(const vtkCamera&) = delete;
874 };
875 
876 #endif
supports function callbacks
a virtual camera for 3D rendering
Definition: vtkCamera.h:46
bool UseExplicitProjectionTransformMatrix
Definition: vtkCamera.h:835
void ComputeOffAxisProjectionFrustum()
Compute and use frustum using offaxis method.
vtkInformation * Information
Definition: vtkCamera.h:869
virtual void SetInformation(vtkInformation *)
Set/Get the information object associated with this camera.
vtkMatrix4x4 * EyeTransformMatrix
Definition: vtkCamera.h:827
void Roll(double angle)
Rotate the camera about the direction of projection.
vtkTypeBool ParallelProjection
Definition: vtkCamera.h:805
void ApplyTransform(vtkTransform *t)
Apply a transform to the camera.
void SetModelTransformMatrix(vtkMatrix4x4 *matrix)
Set/Get model transformation matrix.
double GetRoll()
Set the roll angle of the camera about the direction of projection.
vtkPerspectiveTransform * Transform
Definition: vtkCamera.h:842
void ComputeCameraLightTransform()
void SetViewUp(const double a[3])
Set/Get the view up direction for the camera.
Definition: vtkCamera.h:84
vtkTransform * ViewTransform
Definition: vtkCamera.h:840
double FocalDistance
Definition: vtkCamera.h:848
void SetUserTransform(vtkHomogeneousTransform *transform)
In addition to the instance variables such as position and orientation, you can add an additional tra...
virtual void ComputeViewTransform()
These methods should only be used within vtkCamera.cxx.
double FocalPointScale
Definition: vtkCamera.h:851
bool FreezeFocalPoint
Definition: vtkCamera.h:863
void SetEyePosition(double eyePosition[3])
Set/Get the eye position (center point between two eyes).
void SetPosition(const double a[3])
Set/Get the position of the camera in world coordinates.
Definition: vtkCamera.h:64
virtual vtkMatrix4x4 * GetViewTransformMatrix()
For backward compatibility.
void Yaw(double angle)
Rotate the focal point about the view up vector, using the camera's position as the center of rotatio...
void SetRoll(double angle)
Set the roll angle of the camera about the direction of projection.
void PartialCopy(vtkCamera *source)
Copy the ivars.
void Elevation(double angle)
Rotate the camera about the cross product of the negative of the direction of projection and the view...
double EyeAngle
Definition: vtkCamera.h:804
void Azimuth(double angle)
Rotate the camera about the view up vector centered at the focal point.
vtkHomogeneousTransform * UserTransform
Definition: vtkCamera.h:831
void DeepCopy(vtkCamera *source)
Copy the properties of ‘source’ into ‘this’.
virtual vtkMatrix4x4 * GetProjectionTransformMatrix(double aspect, double nearz, double farz)
Return the projection transform matrix, which converts from camera coordinates to viewport coordinate...
void Pitch(double angle)
Rotate the focal point about the cross product of the view up vector and the direction of projection,...
vtkTypeBool UseOffAxisProjection
Definition: vtkCamera.h:816
vtkMatrix4x4 * ExplicitProjectionTransformMatrix
Definition: vtkCamera.h:834
void SetObliqueAngles(double alpha, double beta)
Get/Set the oblique viewing angles.
double NearPlaneScale
Definition: vtkCamera.h:853
void SetParallelProjection(vtkTypeBool flag)
Set/Get the value of the ParallelProjection instance variable.
void ComputeModelViewMatrix()
Compute model view matrix for the camera.
int LeftEye
Definition: vtkCamera.h:808
double EyeSeparation
Definition: vtkCamera.h:822
virtual void GetFrustumPlanes(double aspect, double planes[24])
Get the plane equations that bound the view frustum.
void Zoom(double factor)
In perspective mode, decrease the view angle by the specified factor.
void SetPosition(double x, double y, double z)
Set/Get the position of the camera in world coordinates.
void SetViewUp(double vx, double vy, double vz)
Set/Get the view up direction for the camera.
double * GetOrientation()
Get the orientation of the camera.
vtkMatrix4x4 * ModelTransformMatrix
Definition: vtkCamera.h:829
void ShallowCopy(vtkCamera *source)
Copy the properties of ‘source’ into ‘this’.
static vtkCamera * New()
Construct camera instance with its focal point at the origin, and position=(0,0,1).
double FocalDisk
Definition: vtkCamera.h:847
double Distance
Definition: vtkCamera.h:810
bool UseExplicitAspectRatio
Definition: vtkCamera.h:838
void SetModelTransformMatrix(const double elements[16])
Set model transformation matrix.
void SetClippingRange(double dNear, double dFar)
Set/Get the location of the near and far clipping planes along the direction of projection.
void SetThickness(double)
Set the distance between clipping planes.
void GetScissorRect(vtkRecti &scissorRect)
Set/Get the vtkRect value of the scissor.
virtual void Render(vtkRenderer *)
This method causes the camera to set up whatever is required for viewing the scene.
Definition: vtkCamera.h:613
void ViewingRaysModified()
Mark that something has changed which requires the view rays to be recomputed.
void SetFocalPoint(const double a[3])
Set/Get the focal of the camera in world coordinates.
Definition: vtkCamera.h:74
void SetEyeTransformMatrix(vtkMatrix4x4 *matrix)
Set/Get eye transformation matrix.
void GetEyePosition(double eyePosition[3])
Set/Get the eye position (center point between two eyes).
void SetDistance(double)
Move the focal point so that it is the specified distance from the camera position.
virtual vtkTransform * GetModelViewTransformObject()
Return the model view transform.
void SetWindowCenter(double x, double y)
Set/Get the center of the window in viewport coordinates.
void SetEyeTransformMatrix(const double elements[16])
Set the eye transform matrix.
double Thickness
Definition: vtkCamera.h:809
void SetScissorRect(vtkRecti scissorRect)
Set/Get the vtkRect value of the scissor.
virtual vtkMatrix4x4 * GetProjectionTransformMatrix(vtkRenderer *ren)
Return the projection transform matrix, which converts from camera coordinates to viewport coordinate...
void ComputeCompositeProjectionTransform(double aspect, double nearz, double farz)
These methods should only be used within vtkCamera.cxx.
vtkRecti ScissorRect
Definition: vtkCamera.h:866
vtkMatrix4x4 * WorldToScreenMatrix
Definition: vtkCamera.h:824
virtual vtkMatrix4x4 * GetModelViewTransformMatrix()
Return the model view matrix of model view transform.
vtkTransform * CameraLightTransform
Definition: vtkCamera.h:843
bool UseScissor
Definition: vtkCamera.h:864
void SetViewAngle(double angle)
Set/Get the camera view angle, which is the angular height of the camera view measured in degrees.
void GetEyePlaneNormal(double normal[3])
Get normal vector from eye to screen rotated by EyeTransformMatrix.
vtkTypeBool UseHorizontalViewAngle
Definition: vtkCamera.h:814
void ComputeWorldToScreenMatrix()
Given screen screen top, bottom left and top right calculate screen rotation.
void OrthogonalizeViewUp()
Recompute the ViewUp vector to force it to be perpendicular to camera->focalpoint vector.
vtkTimeStamp WorldToScreenMatrixMTime
Definition: vtkCamera.h:825
void Dolly(double value)
Divide the camera's distance from the focal point by the given dolly value.
virtual void SetExplicitProjectionTransformMatrix(vtkMatrix4x4 *)
Set/get an explicit 4x4 projection matrix to use, rather than computing one from other state variable...
vtkMTimeType GetViewingRaysMTime()
Return the MTime that concerns recomputing the view rays of the camera.
void SetFocalPoint(double x, double y, double z)
Set/Get the focal of the camera in world coordinates.
void SetUseHorizontalViewAngle(vtkTypeBool flag)
Set/Get the value of the UseHorizontalViewAngle instance variable.
int Stereo
Definition: vtkCamera.h:807
virtual vtkMatrix4x4 * GetCompositeProjectionTransformMatrix(double aspect, double nearz, double farz)
Return the concatenation of the ViewTransform and the ProjectionTransform.
~vtkCamera() override
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetParallelScale(double scale)
Set/Get the scaling used for a parallel projection, i.e.
double ViewAngle
Definition: vtkCamera.h:802
void SetViewShear(double d[3])
Set/get the shear transform of the viewing frustum.
double ParallelScale
Definition: vtkCamera.h:806
vtkHomogeneousTransform * UserViewTransform
Definition: vtkCamera.h:832
vtkPerspectiveTransform * ProjectionTransform
Definition: vtkCamera.h:841
vtkCameraCallbackCommand * UserViewTransformCallbackCommand
Definition: vtkCamera.h:856
double ShiftScaleThreshold
Definition: vtkCamera.h:854
virtual void ComputeProjectionTransform(double aspect, double nearz, double farz)
These methods should only be used within vtkCamera.cxx.
void SetUserViewTransform(vtkHomogeneousTransform *transform)
In addition to the instance variables such as position and orientation, you can add an additional tra...
void ComputeDistance()
These methods should only be used within vtkCamera.cxx.
virtual vtkTransform * GetViewTransformObject()
For backward compatibility.
void SetViewShear(double dxdz, double dydz, double center)
Set/get the shear transform of the viewing frustum.
virtual void UpdateIdealShiftScale(double aspect)
The following methods are used to support view dependent methods for normalizing data (typically poin...
virtual vtkPerspectiveTransform * GetProjectionTransformObject(double aspect, double nearz, double farz)
Return the projection transform matrix, which converts from camera coordinates to viewport coordinate...
vtkTransform * ModelViewTransform
Definition: vtkCamera.h:845
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:254
vtkTimeStamp ViewingRaysMTime
Definition: vtkCamera.h:862
double ExplicitAspectRatio
Definition: vtkCamera.h:837
superclass for homogeneous transformations
a simple class to control print indentation
Definition: vtkIndent.h:34
Store vtkAlgorithm input/output information.
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:36
abstract base class for most VTK objects
Definition: vtkObject.h:63
describes a 4x4 matrix transformation
abstract specification for renderers
Definition: vtkRenderer.h:73
record modification and/or execution time
Definition: vtkTimeStamp.h:33
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:55
@ value
Definition: vtkX3D.h:226
@ scale
Definition: vtkX3D.h:235
@ center
Definition: vtkX3D.h:236
@ alpha
Definition: vtkX3D.h:256
int vtkTypeBool
Definition: vtkABI.h:69
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:287
#define VTK_SIZEHINT(...)