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 
101  void OrthogonalizeViewUp();
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 
187  void SetParallelProjection(vtkTypeBool flag);
188  vtkGetMacro(ParallelProjection, vtkTypeBool);
189  vtkBooleanMacro(ParallelProjection, vtkTypeBool);
191 
193 
203  void SetUseHorizontalViewAngle(vtkTypeBool flag);
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 
313  void ApplyTransform(vtkTransform *t);
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 
437  void SetEyeTransformMatrix(vtkMatrix4x4* matrix);
438  vtkGetObjectMacro(EyeTransformMatrix, vtkMatrix4x4);
440 
447  void SetEyeTransformMatrix(const double elements[16]);
448 
450 
455  void SetModelTransformMatrix(vtkMatrix4x4 *matrix);
456  vtkGetObjectMacro(ModelTransformMatrix, vtkMatrix4x4);
458 
464  void SetModelTransformMatrix(const double elements[16]);
465 
469  virtual vtkMatrix4x4 *GetModelViewTransformMatrix();
470 
474  virtual vtkTransform *GetModelViewTransformObject();
475 
483  virtual vtkMatrix4x4 *GetViewTransformMatrix();
484 
494  virtual vtkTransform *GetViewTransformObject();
495 
502  virtual void SetExplicitProjectionTransformMatrix(vtkMatrix4x4*);
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 
595  vtkMTimeType GetViewingRaysMTime();
596 
601  void ViewingRaysModified();
602 
612  virtual void GetFrustumPlanes(double aspect, double planes[24]);
613 
615 
618  double *GetOrientation() VTK_SIZEHINT(3);
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 
654  void ShallowCopy(vtkCamera *source);
655 
662  void DeepCopy(vtkCamera *source);
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:
691  vtkCamera();
692  ~vtkCamera() override;
693 
695 
698  void ComputeDistance();
699  virtual void ComputeViewTransform();
701 
705  virtual void ComputeProjectionTransform(double aspect,
706  double nearz,
707  double farz);
708 
712  void ComputeCompositeProjectionTransform(double aspect,
713  double nearz,
714  double farz);
715 
716  void ComputeCameraLightTransform();
717 
718 
723  void ComputeWorldToScreenMatrix();
724 
728  void ComputeOffAxisProjectionFrustum();
729 
733  void ComputeModelViewMatrix();
734 
741  void PartialCopy(vtkCamera *source);
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
vtkHomogeneousTransform * UserTransform
Definition: vtkCamera.h:777
double EyeSeparation
Definition: vtkCamera.h:768
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:91
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:302
superclass for homogeneous transformations
record modification and/or execution time
Definition: vtkTimeStamp.h:35
double ViewAngle
Definition: vtkCamera.h:748
abstract specification for renderers
Definition: vtkRenderer.h:63
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:69
vtkTransform * ViewTransform
Definition: vtkCamera.h:783
vtkTypeBool UseHorizontalViewAngle
Definition: vtkCamera.h:760
double Distance
Definition: vtkCamera.h:756
virtual void UpdateViewport(vtkRenderer *vtkNotUsed(ren))
Update the viewport.
Definition: vtkCamera.h:638
double Thickness
Definition: vtkCamera.h:755
int vtkTypeBool
Definition: vtkABI.h:69
vtkMatrix4x4 * ModelTransformMatrix
Definition: vtkCamera.h:775
supports function callbacks
vtkTimeStamp WorldToScreenMatrixMTime
Definition: vtkCamera.h:771
double ParallelScale
Definition: vtkCamera.h:752
bool UseScissor
Definition: vtkCamera.h:800
a simple class to control print indentation
Definition: vtkIndent.h:39
a virtual camera for 3D rendering
Definition: vtkCamera.h:50
vtkTypeBool UseOffAxisProjection
Definition: vtkCamera.h:762
virtual void Render(vtkRenderer *)
This method causes the camera to set up whatever is required for viewing the scene.
Definition: vtkCamera.h:590
void SetFocalPoint(const double a[3])
Set/Get the focal of the camera in world coordinates.
Definition: vtkCamera.h:80
vtkMatrix4x4 * WorldToScreenMatrix
Definition: vtkCamera.h:770
vtkCameraCallbackCommand * UserViewTransformCallbackCommand
Definition: vtkCamera.h:792
int LeftEye
Definition: vtkCamera.h:754
vtkTransform * CameraLightTransform
Definition: vtkCamera.h:786
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:262
#define VTK_SIZEHINT(...)
double FocalDisk
Definition: vtkCamera.h:790
vtkTransform * ModelViewTransform
Definition: vtkCamera.h:788
vtkPerspectiveTransform * Transform
Definition: vtkCamera.h:785
vtkTypeBool ParallelProjection
Definition: vtkCamera.h:751
vtkMatrix4x4 * EyeTransformMatrix
Definition: vtkCamera.h:773
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
vtkMatrix4x4 * ExplicitProjectionTransformMatrix
Definition: vtkCamera.h:780
vtkRecti ScissorRect
Definition: vtkCamera.h:802
vtkTimeStamp ViewingRaysMTime
Definition: vtkCamera.h:798
int Stereo
Definition: vtkCamera.h:753
vtkHomogeneousTransform * UserViewTransform
Definition: vtkCamera.h:778
double EyeAngle
Definition: vtkCamera.h:750
bool FreezeFocalPoint
Definition: vtkCamera.h:799
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
bool UseExplicitProjectionTransformMatrix
Definition: vtkCamera.h:781
vtkPerspectiveTransform * ProjectionTransform
Definition: vtkCamera.h:784
describes a 4x4 matrix transformation