VTK
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 "vtkRenderingCoreModule.h" // For export macro
39 #include "vtkObject.h"
40 #include "vtkRect.h" // for ivar
41 
43 class vtkMatrix4x4;
45 class vtkRenderer;
46 class vtkTransform;
47 class vtkCallbackCommand;
48 class vtkCameraCallbackCommand;
49 
50 class VTKRENDERINGCORE_EXPORT vtkCamera : public vtkObject
51 {
52 public:
53  vtkTypeMacro(vtkCamera, vtkObject);
54  void PrintSelf(ostream& os, vtkIndent indent) override;
55 
61  static vtkCamera *New();
62 
64 
68  void SetPosition(double x, double y, double z);
69  void SetPosition(const double a[3]) {
70  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]) {
81  this->SetFocalPoint(a[0], a[1], a[2]);};
82  vtkGetVector3Macro(FocalPoint, double);
84 
86 
90  void SetViewUp(double vx, double vy, double vz);
91  void SetViewUp(const double a[3]) {
92  this->SetViewUp(a[0], a[1], a[2]); }
93  vtkGetVector3Macro(ViewUp, double);
95 
102 
107  void SetDistance(double);
108 
110 
114  vtkGetMacro(Distance, double);
116 
118 
123  vtkGetVector3Macro(DirectionOfProjection, double);
125 
132  void Dolly(double value);
133 
135 
138  void SetRoll(double angle);
139  double GetRoll();
141 
146  void Roll(double angle);
147 
154  void Azimuth(double angle);
155 
163  void Yaw(double angle);
164 
171  void Elevation(double angle);
172 
178  void Pitch(double angle);
179 
181 
188  vtkGetMacro(ParallelProjection, vtkTypeBool);
189  vtkBooleanMacro(ParallelProjection, vtkTypeBool);
191 
193 
204  vtkGetMacro(UseHorizontalViewAngle, vtkTypeBool);
205  vtkBooleanMacro(UseHorizontalViewAngle, vtkTypeBool);
207 
209 
220  void SetViewAngle(double angle);
221  vtkGetMacro(ViewAngle, double);
223 
225 
234  void SetParallelScale(double scale);
235  vtkGetMacro(ParallelScale ,double);
237 
245  void Zoom(double factor);
246 
248 
261  void SetClippingRange(double dNear, double dFar);
262  void SetClippingRange(const double a[2])
263  { this->SetClippingRange(a[0], a[1]); }
264  vtkGetVector2Macro(ClippingRange, double);
266 
268 
275  void SetThickness(double);
276  vtkGetMacro(Thickness, double);
278 
280 
289  void SetWindowCenter(double x, double y);
290  vtkGetVector2Macro(WindowCenter, double);
292 
306  void SetObliqueAngles(double alpha, double beta);
307 
314 
316 
321  vtkGetVector3Macro(ViewPlaneNormal, double);
323 
325 
333  void SetViewShear(double dxdz, double dydz, double center);
334  void SetViewShear(double d[3]);
335  vtkGetVector3Macro(ViewShear, double);
337 
339 
343  vtkSetMacro(EyeAngle, double);
344  vtkGetMacro(EyeAngle, double);
346 
348 
354  vtkSetMacro(FocalDisk, double);
355  vtkGetMacro(FocalDisk, double);
357 
359 
368  vtkSetMacro(UseOffAxisProjection, vtkTypeBool);
369  vtkGetMacro(UseOffAxisProjection, vtkTypeBool);
370  vtkBooleanMacro(UseOffAxisProjection, vtkTypeBool);
372 
374 
379  vtkSetVector3Macro(ScreenBottomLeft, double);
380  vtkGetVector3Macro(ScreenBottomLeft, double);
382 
384 
389  vtkSetVector3Macro(ScreenBottomRight, double);
390  vtkGetVector3Macro(ScreenBottomRight, double);
392 
394 
399  vtkSetVector3Macro(ScreenTopRight, double);
400  vtkGetVector3Macro(ScreenTopRight, double);
402 
404 
409  vtkSetMacro(EyeSeparation, double);
410  vtkGetMacro(EyeSeparation, double);
412 
414 
420  void SetEyePosition(double eyePosition[3]);
421  void GetEyePosition(double eyePosition[3]);
423 
428  void GetEyePlaneNormal(double normal[3]);
429 
431 
438  vtkGetObjectMacro(EyeTransformMatrix, vtkMatrix4x4);
440 
447  void SetEyeTransformMatrix(const double elements[16]);
448 
450 
456  vtkGetObjectMacro(ModelTransformMatrix, vtkMatrix4x4);
458 
464  void SetModelTransformMatrix(const double elements[16]);
465 
470 
475 
484 
495 
503  vtkGetObjectMacro(ExplicitProjectionTransformMatrix, vtkMatrix4x4)
511  vtkSetMacro(UseExplicitProjectionTransformMatrix, bool)
512  vtkGetMacro(UseExplicitProjectionTransformMatrix, bool)
513  vtkBooleanMacro(UseExplicitProjectionTransformMatrix, bool)
525  virtual vtkMatrix4x4 *GetProjectionTransformMatrix(double aspect,
526  double nearz,
527  double farz);
528 
538  virtual vtkPerspectiveTransform *GetProjectionTransformObject(double aspect,
539  double nearz,
540  double farz);
541 
552  virtual vtkMatrix4x4 *GetCompositeProjectionTransformMatrix(double aspect,
553  double nearz,
554  double farz);
555 
563  virtual vtkMatrix4x4 *GetProjectionTransformMatrix(vtkRenderer *ren);
564 
566 
571  void SetUserViewTransform(vtkHomogeneousTransform *transform);
572  vtkGetObjectMacro(UserViewTransform,vtkHomogeneousTransform);
574 
576 
581  void SetUserTransform(vtkHomogeneousTransform *transform);
582  vtkGetObjectMacro(UserTransform,vtkHomogeneousTransform);
584 
590  virtual void Render(vtkRenderer *) {}
591 
596 
602 
612  virtual void GetFrustumPlanes(double aspect, double planes[24]);
613 
615 
619  double *GetOrientationWXYZ() VTK_SIZEHINT(4);
621 
626  void ComputeViewPlaneNormal();
627 
633  vtkMatrix4x4 *GetCameraLightTransformMatrix();
634 
638  virtual void UpdateViewport(vtkRenderer *vtkNotUsed(ren)) {}
639 
641 
644  vtkSetMacro(LeftEye, int);
645  vtkGetMacro(LeftEye, int);
647 
655 
663 
665 
670  vtkSetMacro(FreezeFocalPoint, bool);
671  vtkGetMacro(FreezeFocalPoint, bool);
673 
675 
678  vtkSetMacro(UseScissor, bool);
679  vtkGetMacro(UseScissor, bool);
681 
683 
686  void SetScissorRect(vtkRecti scissorRect);
687  void GetScissorRect(vtkRecti& scissorRect);
689 
690 protected:
692  ~vtkCamera() override;
693 
695 
699  virtual void ComputeViewTransform();
701 
705  virtual void ComputeProjectionTransform(double aspect,
706  double nearz,
707  double farz);
708 
713  double nearz,
714  double farz);
715 
717 
718 
724 
729 
734 
742 
743  double WindowCenter[2];
744  double ObliqueAngles[2];
745  double FocalPoint[3];
746  double Position[3];
747  double ViewUp[3];
748  double ViewAngle;
749  double ClippingRange[2];
750  double EyeAngle;
753  int Stereo;
754  int LeftEye;
755  double Thickness;
756  double Distance;
757  double DirectionOfProjection[3];
758  double ViewPlaneNormal[3];
759  double ViewShear[3];
761 
763 
764  double ScreenBottomLeft[3];
765  double ScreenBottomRight[3];
766  double ScreenTopRight[3];
767 
769 
772 
774 
776 
779 
782 
787 
789 
790  double FocalDisk;
791 
792  vtkCameraCallbackCommand *UserViewTransformCallbackCommand;
793  friend class vtkCameraCallbackCommand;
794 
795  // ViewingRaysMtime keeps track of camera modifications which will
796  // change the calculation of viewing rays for the camera before it is
797  // transformed to the camera's location and orientation.
801 
803 
804 
805 private:
806  vtkCamera(const vtkCamera&) = delete;
807  void operator=(const vtkCamera&) = delete;
808 };
809 
810 #endif
vtkCamera::ViewTransform
vtkTransform * ViewTransform
Definition: vtkCamera.h:783
vtkCamera::UseScissor
bool UseScissor
Definition: vtkCamera.h:800
vtkCamera::DeepCopy
void DeepCopy(vtkCamera *source)
Copy the properties of ‘source’ into ‘this’.
vtkCamera::CameraLightTransform
vtkTransform * CameraLightTransform
Definition: vtkCamera.h:786
vtkHomogeneousTransform
superclass for homogeneous transformations
Definition: vtkHomogeneousTransform.h:35
vtkCamera::GetViewTransformMatrix
virtual vtkMatrix4x4 * GetViewTransformMatrix()
For backward compatibility.
vtkX3D::alpha
@ alpha
Definition: vtkX3D.h:250
vtkX3D::scale
@ scale
Definition: vtkX3D.h:229
vtkCamera::GetViewingRaysMTime
vtkMTimeType GetViewingRaysMTime()
Return the MTime that concerns recomputing the view rays of the camera.
vtkX3D::value
@ value
Definition: vtkX3D.h:220
vtkCamera::ParallelProjection
vtkTypeBool ParallelProjection
Definition: vtkCamera.h:751
vtkCamera::PartialCopy
void PartialCopy(vtkCamera *source)
Copy the ivars.
vtkCamera::GetModelViewTransformMatrix
virtual vtkMatrix4x4 * GetModelViewTransformMatrix()
Return the model view matrix of model view transform.
vtkCamera::GetEyePosition
void GetEyePosition(double eyePosition[3])
vtkCamera::OrthogonalizeViewUp
void OrthogonalizeViewUp()
Recompute the ViewUp vector to force it to be perpendicular to camera->focalpoint vector.
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:36
vtkCamera::SetDistance
void SetDistance(double)
Move the focal point so that it is the specified distance from the camera position.
vtkCamera::New
static vtkCamera * New()
Construct camera instance with its focal point at the origin, and position=(0,0,1).
vtkCamera::ViewingRaysMTime
vtkTimeStamp ViewingRaysMTime
Definition: vtkCamera.h:798
vtkCamera::SetViewUp
void SetViewUp(const double a[3])
Definition: vtkCamera.h:91
vtkObject
abstract base class for most VTK objects
Definition: vtkObject.h:60
vtkCamera::LeftEye
int LeftEye
Definition: vtkCamera.h:754
vtkX3D::center
@ center
Definition: vtkX3D.h:230
vtkCamera::SetClippingRange
void SetClippingRange(const double a[2])
Definition: vtkCamera.h:262
vtkTransform
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:61
vtkCamera::SetObliqueAngles
void SetObliqueAngles(double alpha, double beta)
Get/Set the oblique viewing angles.
vtkCamera::Stereo
int Stereo
Definition: vtkCamera.h:753
vtkCamera::Transform
vtkPerspectiveTransform * Transform
Definition: vtkCamera.h:785
vtkCamera::SetFocalPoint
void SetFocalPoint(double x, double y, double z)
Set/Get the focal of the camera in world coordinates.
vtkCamera::EyeAngle
double EyeAngle
Definition: vtkCamera.h:750
vtkCamera::UseOffAxisProjection
vtkTypeBool UseOffAxisProjection
Definition: vtkCamera.h:762
source
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
Definition: vtkBoostGraphAdapter.h:825
vtkCamera::~vtkCamera
~vtkCamera() override
vtkCamera::GetViewTransformObject
virtual vtkTransform * GetViewTransformObject()
For backward compatibility.
vtkCamera::UseExplicitProjectionTransformMatrix
bool UseExplicitProjectionTransformMatrix
Definition: vtkCamera.h:781
vtkCamera::ViewingRaysModified
void ViewingRaysModified()
Mark that something has changed which requires the view rays to be recomputed.
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:42
vtkCamera::GetRoll
double GetRoll()
vtkCamera::SetParallelProjection
void SetParallelProjection(vtkTypeBool flag)
Set/Get the value of the ParallelProjection instance variable.
vtkCamera::ComputeCameraLightTransform
void ComputeCameraLightTransform()
vtkCamera::ComputeWorldToScreenMatrix
void ComputeWorldToScreenMatrix()
Given screen screen top, bottom left and top right calculate screen rotation.
vtkCamera::SetEyePosition
void SetEyePosition(double eyePosition[3])
Set/Get the eye position (center point between two eyes).
vtkCamera::ExplicitProjectionTransformMatrix
vtkMatrix4x4 * ExplicitProjectionTransformMatrix
Definition: vtkCamera.h:780
vtkCamera::SetScissorRect
void SetScissorRect(vtkRecti scissorRect)
Set/Get the vtkRect value of the scissor.
vtkCamera::ScissorRect
vtkRecti ScissorRect
Definition: vtkCamera.h:802
vtkCamera::ComputeModelViewMatrix
void ComputeModelViewMatrix()
Compute model view matrix for the camera.
vtkRect.h
vtkCamera::SetParallelScale
void SetParallelScale(double scale)
Set/Get the scaling used for a parallel projection, i.e.
vtkCamera::GetModelViewTransformObject
virtual vtkTransform * GetModelViewTransformObject()
Return the model view transform.
vtkCamera::SetUseHorizontalViewAngle
void SetUseHorizontalViewAngle(vtkTypeBool flag)
Set/Get the value of the UseHorizontalViewAngle instance variable.
vtkCamera::GetScissorRect
void GetScissorRect(vtkRecti &scissorRect)
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkMatrix4x4
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:42
vtkCamera::ModelTransformMatrix
vtkMatrix4x4 * ModelTransformMatrix
Definition: vtkCamera.h:775
vtkCamera::SetViewAngle
void SetViewAngle(double angle)
Set/Get the camera view angle, which is the angular height of the camera view measured in degrees.
vtkCamera::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkCamera
a virtual camera for 3D rendering
Definition: vtkCamera.h:51
vtkCamera::SetExplicitProjectionTransformMatrix
virtual void SetExplicitProjectionTransformMatrix(vtkMatrix4x4 *)
Set/get an explicit 4x4 projection matrix to use, rather than computing one from other state variable...
vtkCamera::SetPosition
void SetPosition(const double a[3])
Definition: vtkCamera.h:69
vtkCamera::GetFrustumPlanes
virtual void GetFrustumPlanes(double aspect, double planes[24])
Get the plane equations that bound the view frustum.
vtkCamera::WorldToScreenMatrixMTime
vtkTimeStamp WorldToScreenMatrixMTime
Definition: vtkCamera.h:771
vtkCamera::SetPosition
void SetPosition(double x, double y, double z)
Set/Get the position of the camera in world coordinates.
vtkCamera::ComputeCompositeProjectionTransform
void ComputeCompositeProjectionTransform(double aspect, double nearz, double farz)
These methods should only be used within vtkCamera.cxx.
vtkCamera::SetEyeTransformMatrix
void SetEyeTransformMatrix(vtkMatrix4x4 *matrix)
Set/Get eye transformation matrix.
vtkCamera::ComputeProjectionTransform
virtual void ComputeProjectionTransform(double aspect, double nearz, double farz)
These methods should only be used within vtkCamera.cxx.
vtkCamera::ShallowCopy
void ShallowCopy(vtkCamera *source)
Copy the properties of ‘source’ into ‘this’.
vtkCamera::SetViewShear
void SetViewShear(double dxdz, double dydz, double center)
Set/get the shear transform of the viewing frustum.
vtkCamera::Thickness
double Thickness
Definition: vtkCamera.h:755
vtkPerspectiveTransform
describes a 4x4 matrix transformation
Definition: vtkPerspectiveTransform.h:57
vtkObject.h
vtkCamera::SetEyeTransformMatrix
void SetEyeTransformMatrix(const double elements[16])
Set the eye transform matrix.
vtkCamera::vtkCamera
vtkCamera()
vtkCamera::FreezeFocalPoint
bool FreezeFocalPoint
Definition: vtkCamera.h:799
vtkCamera::SetThickness
void SetThickness(double)
Set the distance between clipping planes.
vtkCamera::UserTransform
vtkHomogeneousTransform * UserTransform
Definition: vtkCamera.h:777
vtkCamera::FocalDisk
double FocalDisk
Definition: vtkCamera.h:790
vtkCamera::EyeSeparation
double EyeSeparation
Definition: vtkCamera.h:768
vtkCamera::ComputeOffAxisProjectionFrustum
void ComputeOffAxisProjectionFrustum()
Compute and use frustum using offaxis method.
vtkCamera::SetModelTransformMatrix
void SetModelTransformMatrix(const double elements[16])
Set model transformation matrix.
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:64
vtkCamera::Zoom
void Zoom(double factor)
In perspective mode, decrease the view angle by the specified factor.
vtkCamera::ProjectionTransform
vtkPerspectiveTransform * ProjectionTransform
Definition: vtkCamera.h:784
vtkCamera::SetRoll
void SetRoll(double angle)
Set the roll angle of the camera about the direction of projection.
vtkCamera::ParallelScale
double ParallelScale
Definition: vtkCamera.h:752
vtkCallbackCommand
supports function callbacks
Definition: vtkCallbackCommand.h:51
vtkCamera::UseHorizontalViewAngle
vtkTypeBool UseHorizontalViewAngle
Definition: vtkCamera.h:760
vtkCamera::SetViewShear
void SetViewShear(double d[3])
vtkCamera::SetWindowCenter
void SetWindowCenter(double x, double y)
Set/Get the center of the window in viewport coordinates.
vtkCamera::SetClippingRange
void SetClippingRange(double dNear, double dFar)
Set/Get the location of the near and far clipping planes along the direction of projection.
vtkCamera::UserViewTransformCallbackCommand
vtkCameraCallbackCommand * UserViewTransformCallbackCommand
Definition: vtkCamera.h:792
vtkCamera::Roll
void Roll(double angle)
Rotate the camera about the direction of projection.
vtkCamera::SetFocalPoint
void SetFocalPoint(const double a[3])
Definition: vtkCamera.h:80
vtkCamera::GetOrientation
double * GetOrientation()
Get the orientation of the camera.
vtkRecti
Definition: vtkRect.h:324
vtkCamera::ComputeDistance
void ComputeDistance()
These methods should only be used within vtkCamera.cxx.
vtkCamera::Pitch
void Pitch(double angle)
Rotate the focal point about the cross product of the view up vector and the direction of projection,...
vtkCamera::Yaw
void Yaw(double angle)
Rotate the focal point about the view up vector, using the camera's position as the center of rotatio...
vtkCamera::Elevation
void Elevation(double angle)
Rotate the camera about the cross product of the negative of the direction of projection and the view...
vtkCamera::Dolly
void Dolly(double value)
Divide the camera's distance from the focal point by the given dolly value.
vtkCamera::SetViewUp
void SetViewUp(double vx, double vy, double vz)
Set/Get the view up direction for the camera.
vtkCamera::Azimuth
void Azimuth(double angle)
Rotate the camera about the view up vector centered at the focal point.
vtkCamera::Distance
double Distance
Definition: vtkCamera.h:756
vtkCamera::UserViewTransform
vtkHomogeneousTransform * UserViewTransform
Definition: vtkCamera.h:778
vtkCamera::ApplyTransform
void ApplyTransform(vtkTransform *t)
Apply a transform to the camera.
vtkCamera::SetModelTransformMatrix
void SetModelTransformMatrix(vtkMatrix4x4 *matrix)
Set/Get model transformation matrix.
vtkCamera::ModelViewTransform
vtkTransform * ModelViewTransform
Definition: vtkCamera.h:788
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkCamera::EyeTransformMatrix
vtkMatrix4x4 * EyeTransformMatrix
Definition: vtkCamera.h:773
vtkCamera::GetEyePlaneNormal
void GetEyePlaneNormal(double normal[3])
Get normal vector from eye to screen rotated by EyeTransformMatrix.
vtkCamera::ViewAngle
double ViewAngle
Definition: vtkCamera.h:748
vtkMTimeType
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:302
vtkCamera::ComputeViewTransform
virtual void ComputeViewTransform()
vtkCamera::WorldToScreenMatrix
vtkMatrix4x4 * WorldToScreenMatrix
Definition: vtkCamera.h:770