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 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]) {
71  this->SetPosition(a[0], a[1], a[2]); };
72  vtkGetVector3Macro(Position, double);
74 
76 
80  void SetFocalPoint(double x, double y, double z);
81  void SetFocalPoint(const double a[3]) {
82  this->SetFocalPoint(a[0], a[1], a[2]);};
83  vtkGetVector3Macro(FocalPoint, double);
85 
87 
91  void SetViewUp(double vx, double vy, double vz);
92  void SetViewUp(const double a[3]) {
93  this->SetViewUp(a[0], a[1], a[2]); }
94  vtkGetVector3Macro(ViewUp, double);
96 
102  void OrthogonalizeViewUp();
103 
108  void SetDistance(double);
109 
111 
115  vtkGetMacro(Distance, double);
117 
119 
124  vtkGetVector3Macro(DirectionOfProjection, double);
126 
133  void Dolly(double value);
134 
136 
139  void SetRoll(double angle);
140  double GetRoll();
142 
147  void Roll(double angle);
148 
155  void Azimuth(double angle);
156 
164  void Yaw(double angle);
165 
172  void Elevation(double angle);
173 
179  void Pitch(double angle);
180 
182 
188  void SetParallelProjection(vtkTypeBool flag);
189  vtkGetMacro(ParallelProjection, vtkTypeBool);
190  vtkBooleanMacro(ParallelProjection, vtkTypeBool);
192 
194 
204  void SetUseHorizontalViewAngle(vtkTypeBool flag);
205  vtkGetMacro(UseHorizontalViewAngle, vtkTypeBool);
206  vtkBooleanMacro(UseHorizontalViewAngle, vtkTypeBool);
208 
210 
221  void SetViewAngle(double angle);
222  vtkGetMacro(ViewAngle, double);
224 
226 
235  void SetParallelScale(double scale);
236  vtkGetMacro(ParallelScale ,double);
238 
246  void Zoom(double factor);
247 
249 
262  void SetClippingRange(double dNear, double dFar);
263  void SetClippingRange(const double a[2])
264  { this->SetClippingRange(a[0], a[1]); }
265  vtkGetVector2Macro(ClippingRange, double);
267 
269 
276  void SetThickness(double);
277  vtkGetMacro(Thickness, double);
279 
281 
290  void SetWindowCenter(double x, double y);
291  vtkGetVector2Macro(WindowCenter, double);
293 
307  void SetObliqueAngles(double alpha, double beta);
308 
314  void ApplyTransform(vtkTransform *t);
315 
317 
322  vtkGetVector3Macro(ViewPlaneNormal, double);
324 
326 
334  void SetViewShear(double dxdz, double dydz, double center);
335  void SetViewShear(double d[3]);
336  vtkGetVector3Macro(ViewShear, double);
338 
340 
344  vtkSetMacro(EyeAngle, double);
345  vtkGetMacro(EyeAngle, double);
347 
349 
355  vtkSetMacro(FocalDisk, double);
356  vtkGetMacro(FocalDisk, double);
358 
360 
368  vtkSetMacro(FocalDistance, double);
369  vtkGetMacro(FocalDistance, double);
371 
373 
382  vtkSetMacro(UseOffAxisProjection, vtkTypeBool);
383  vtkGetMacro(UseOffAxisProjection, vtkTypeBool);
384  vtkBooleanMacro(UseOffAxisProjection, vtkTypeBool);
386 
388 
393  vtkSetVector3Macro(ScreenBottomLeft, double);
394  vtkGetVector3Macro(ScreenBottomLeft, double);
396 
398 
403  vtkSetVector3Macro(ScreenBottomRight, double);
404  vtkGetVector3Macro(ScreenBottomRight, double);
406 
408 
413  vtkSetVector3Macro(ScreenTopRight, double);
414  vtkGetVector3Macro(ScreenTopRight, double);
416 
418 
423  vtkSetMacro(EyeSeparation, double);
424  vtkGetMacro(EyeSeparation, double);
426 
428 
434  void SetEyePosition(double eyePosition[3]);
435  void GetEyePosition(double eyePosition[3]);
437 
442  void GetEyePlaneNormal(double normal[3]);
443 
445 
451  void SetEyeTransformMatrix(vtkMatrix4x4* matrix);
452  vtkGetObjectMacro(EyeTransformMatrix, vtkMatrix4x4);
454 
461  void SetEyeTransformMatrix(const double elements[16]);
462 
464 
469  void SetModelTransformMatrix(vtkMatrix4x4 *matrix);
470  vtkGetObjectMacro(ModelTransformMatrix, vtkMatrix4x4);
472 
478  void SetModelTransformMatrix(const double elements[16]);
479 
483  virtual vtkMatrix4x4 *GetModelViewTransformMatrix();
484 
488  virtual vtkTransform *GetModelViewTransformObject();
489 
497  virtual vtkMatrix4x4 *GetViewTransformMatrix();
498 
508  virtual vtkTransform *GetViewTransformObject();
509 
516  virtual void SetExplicitProjectionTransformMatrix(vtkMatrix4x4*);
517  vtkGetObjectMacro(ExplicitProjectionTransformMatrix, vtkMatrix4x4)
525  vtkSetMacro(UseExplicitProjectionTransformMatrix, bool)
526  vtkGetMacro(UseExplicitProjectionTransformMatrix, bool)
527  vtkBooleanMacro(UseExplicitProjectionTransformMatrix, bool)
539  virtual vtkMatrix4x4 *GetProjectionTransformMatrix(double aspect,
540  double nearz,
541  double farz);
542 
552  virtual vtkPerspectiveTransform *GetProjectionTransformObject(double aspect,
553  double nearz,
554  double farz);
555 
566  virtual vtkMatrix4x4 *GetCompositeProjectionTransformMatrix(double aspect,
567  double nearz,
568  double farz);
569 
577  virtual vtkMatrix4x4 *GetProjectionTransformMatrix(vtkRenderer *ren);
578 
580 
585  void SetUserViewTransform(vtkHomogeneousTransform *transform);
586  vtkGetObjectMacro(UserViewTransform,vtkHomogeneousTransform);
588 
590 
595  void SetUserTransform(vtkHomogeneousTransform *transform);
596  vtkGetObjectMacro(UserTransform,vtkHomogeneousTransform);
598 
604  virtual void Render(vtkRenderer *) {}
605 
609  vtkMTimeType GetViewingRaysMTime();
610 
615  void ViewingRaysModified();
616 
626  virtual void GetFrustumPlanes(double aspect, double planes[24]);
627 
629 
632  double *GetOrientation() VTK_SIZEHINT(3);
633  double *GetOrientationWXYZ() VTK_SIZEHINT(4);
635 
640  void ComputeViewPlaneNormal();
641 
647  vtkMatrix4x4 *GetCameraLightTransformMatrix();
648 
652  virtual void UpdateViewport(vtkRenderer *vtkNotUsed(ren)) {}
653 
655 
658  vtkSetMacro(LeftEye, int);
659  vtkGetMacro(LeftEye, int);
661 
668  void ShallowCopy(vtkCamera *source);
669 
676  void DeepCopy(vtkCamera *source);
677 
679 
684  vtkSetMacro(FreezeFocalPoint, bool);
685  vtkGetMacro(FreezeFocalPoint, bool);
687 
689 
692  vtkSetMacro(UseScissor, bool);
693  vtkGetMacro(UseScissor, bool);
695 
697 
700  void SetScissorRect(vtkRecti scissorRect);
701  void GetScissorRect(vtkRecti& scissorRect);
703 
705 
708  vtkGetObjectMacro(Information, vtkInformation);
709  virtual void SetInformation(vtkInformation*);
711 
712 protected:
713  vtkCamera();
714  ~vtkCamera() override;
715 
717 
720  void ComputeDistance();
721  virtual void ComputeViewTransform();
723 
727  virtual void ComputeProjectionTransform(double aspect,
728  double nearz,
729  double farz);
730 
734  void ComputeCompositeProjectionTransform(double aspect,
735  double nearz,
736  double farz);
737 
738  void ComputeCameraLightTransform();
739 
740 
745  void ComputeWorldToScreenMatrix();
746 
750  void ComputeOffAxisProjectionFrustum();
751 
755  void ComputeModelViewMatrix();
756 
763  void PartialCopy(vtkCamera *source);
764 
765  double WindowCenter[2];
766  double ObliqueAngles[2];
767  double FocalPoint[3];
768  double Position[3];
769  double ViewUp[3];
770  double ViewAngle;
771  double ClippingRange[2];
772  double EyeAngle;
775  int Stereo;
776  int LeftEye;
777  double Thickness;
778  double Distance;
779  double DirectionOfProjection[3];
780  double ViewPlaneNormal[3];
781  double ViewShear[3];
783 
785 
786  double ScreenBottomLeft[3];
787  double ScreenBottomRight[3];
788  double ScreenTopRight[3];
789 
791 
794 
796 
798 
801 
804 
809 
811 
812  double FocalDisk;
814 
815  vtkCameraCallbackCommand *UserViewTransformCallbackCommand;
816  friend class vtkCameraCallbackCommand;
817 
818  // ViewingRaysMtime keeps track of camera modifications which will
819  // change the calculation of viewing rays for the camera before it is
820  // transformed to the camera's location and orientation.
824 
826 
827  // Arbitrary extra information associated with this camera.
829 
830 private:
831  vtkCamera(const vtkCamera&) = delete;
832  void operator=(const vtkCamera&) = delete;
833 };
834 
835 #endif
vtkInformation * Information
Definition: vtkCamera.h:828
vtkHomogeneousTransform * UserTransform
Definition: vtkCamera.h:799
double EyeSeparation
Definition: vtkCamera.h:790
abstract base class for most VTK objects
Definition: vtkObject.h:59
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:92
Store vtkAlgorithm input/output information.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:304
superclass for homogeneous transformations
record modification and/or execution time
Definition: vtkTimeStamp.h:35
double ViewAngle
Definition: vtkCamera.h:770
abstract specification for renderers
Definition: vtkRenderer.h:64
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:805
vtkTypeBool UseHorizontalViewAngle
Definition: vtkCamera.h:782
double Distance
Definition: vtkCamera.h:778
virtual void UpdateViewport(vtkRenderer *vtkNotUsed(ren))
Update the viewport.
Definition: vtkCamera.h:652
double Thickness
Definition: vtkCamera.h:777
int vtkTypeBool
Definition: vtkABI.h:69
double FocalDistance
Definition: vtkCamera.h:813
vtkMatrix4x4 * ModelTransformMatrix
Definition: vtkCamera.h:797
supports function callbacks
vtkTimeStamp WorldToScreenMatrixMTime
Definition: vtkCamera.h:793
double ParallelScale
Definition: vtkCamera.h:774
bool UseScissor
Definition: vtkCamera.h:823
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:784
virtual void Render(vtkRenderer *)
This method causes the camera to set up whatever is required for viewing the scene.
Definition: vtkCamera.h:604
void SetFocalPoint(const double a[3])
Set/Get the focal of the camera in world coordinates.
Definition: vtkCamera.h:81
vtkMatrix4x4 * WorldToScreenMatrix
Definition: vtkCamera.h:792
vtkCameraCallbackCommand * UserViewTransformCallbackCommand
Definition: vtkCamera.h:815
int LeftEye
Definition: vtkCamera.h:776
vtkTransform * CameraLightTransform
Definition: vtkCamera.h:808
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:263
#define VTK_SIZEHINT(...)
double FocalDisk
Definition: vtkCamera.h:812
vtkTransform * ModelViewTransform
Definition: vtkCamera.h:810
vtkPerspectiveTransform * Transform
Definition: vtkCamera.h:807
vtkTypeBool ParallelProjection
Definition: vtkCamera.h:773
vtkMatrix4x4 * EyeTransformMatrix
Definition: vtkCamera.h:795
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
vtkMatrix4x4 * ExplicitProjectionTransformMatrix
Definition: vtkCamera.h:802
vtkRecti ScissorRect
Definition: vtkCamera.h:825
vtkTimeStamp ViewingRaysMTime
Definition: vtkCamera.h:821
int Stereo
Definition: vtkCamera.h:775
vtkHomogeneousTransform * UserViewTransform
Definition: vtkCamera.h:800
double EyeAngle
Definition: vtkCamera.h:772
bool FreezeFocalPoint
Definition: vtkCamera.h:822
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
bool UseExplicitProjectionTransformMatrix
Definition: vtkCamera.h:803
vtkPerspectiveTransform * ProjectionTransform
Definition: vtkCamera.h:806
describes a 4x4 matrix transformation