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);
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 
185  void SetParallelProjection(int flag);
186  vtkGetMacro(ParallelProjection, int);
187  vtkBooleanMacro(ParallelProjection, int);
189 
191 
199  void SetUseHorizontalViewAngle(int flag);
200  vtkGetMacro(UseHorizontalViewAngle, int);
201  vtkBooleanMacro(UseHorizontalViewAngle, int);
203 
205 
214  void SetViewAngle(double angle);
215  vtkGetMacro(ViewAngle, double);
217 
219 
226  void SetParallelScale(double scale);
227  vtkGetMacro(ParallelScale ,double);
229 
235  void Zoom(double factor);
236 
238 
249  void SetClippingRange(double dNear, double dFar);
250  void SetClippingRange(const double a[2])
251  { this->SetClippingRange(a[0], a[1]); }
252  vtkGetVector2Macro(ClippingRange, double);
254 
256 
261  void SetThickness(double);
262  vtkGetMacro(Thickness, double);
264 
266 
273  void SetWindowCenter(double x, double y);
274  vtkGetVector2Macro(WindowCenter, double);
276 
288  void SetObliqueAngles(double alpha, double beta);
289 
295  void ApplyTransform(vtkTransform *t);
296 
298 
303  vtkGetVector3Macro(ViewPlaneNormal, double);
305 
307 
313  void SetViewShear(double dxdz, double dydz, double center);
314  void SetViewShear(double d[3]);
315  vtkGetVector3Macro(ViewShear, double);
317 
319 
323  vtkSetMacro(EyeAngle, double);
324  vtkGetMacro(EyeAngle, double);
326 
328 
334  vtkSetMacro(FocalDisk, double);
335  vtkGetMacro(FocalDisk, double);
337 
339 
346  vtkSetMacro(UseOffAxisProjection, int);
347  vtkGetMacro(UseOffAxisProjection, int);
348  vtkBooleanMacro(UseOffAxisProjection, int);
350 
352 
357  vtkSetVector3Macro(ScreenBottomLeft, double);
358  vtkGetVector3Macro(ScreenBottomLeft, double);
360 
362 
367  vtkSetVector3Macro(ScreenBottomRight, double);
368  vtkGetVector3Macro(ScreenBottomRight, double);
370 
372 
377  vtkSetVector3Macro(ScreenTopRight, double);
378  vtkGetVector3Macro(ScreenTopRight, double);
380 
382 
387  vtkSetMacro(EyeSeparation, double);
388  vtkGetMacro(EyeSeparation, double);
390 
392 
398  void SetEyePosition(double eyePosition[3]);
399  void GetEyePosition(double eyePosition[3]);
401 
406  void GetEyePlaneNormal(double normal[3]);
407 
409 
415  void SetEyeTransformMatrix(vtkMatrix4x4* matrix);
416  vtkGetObjectMacro(EyeTransformMatrix, vtkMatrix4x4);
418 
425  void SetEyeTransformMatrix(const double elements[16]);
426 
428 
433  void SetModelTransformMatrix(vtkMatrix4x4 *matrix);
434  vtkGetObjectMacro(ModelTransformMatrix, vtkMatrix4x4);
436 
442  void SetModelTransformMatrix(const double elements[16]);
443 
447  virtual vtkMatrix4x4 *GetModelViewTransformMatrix();
448 
452  virtual vtkTransform *GetModelViewTransformObject();
453 
461  virtual vtkMatrix4x4 *GetViewTransformMatrix();
462 
472  virtual vtkTransform *GetViewTransformObject();
473 
482  virtual vtkMatrix4x4 *GetProjectionTransformMatrix(double aspect,
483  double nearz,
484  double farz);
485 
494  virtual vtkPerspectiveTransform *GetProjectionTransformObject(double aspect,
495  double nearz,
496  double farz);
497 
507  virtual vtkMatrix4x4 *GetCompositeProjectionTransformMatrix(double aspect,
508  double nearz,
509  double farz);
510 
517  virtual vtkMatrix4x4 *GetProjectionTransformMatrix(vtkRenderer *ren);
518 
520 
525  void SetUserViewTransform(vtkHomogeneousTransform *transform);
526  vtkGetObjectMacro(UserViewTransform,vtkHomogeneousTransform);
528 
530 
535  void SetUserTransform(vtkHomogeneousTransform *transform);
536  vtkGetObjectMacro(UserTransform,vtkHomogeneousTransform);
538 
544  virtual void Render(vtkRenderer *) {}
545 
549  vtkMTimeType GetViewingRaysMTime();
550 
555  void ViewingRaysModified();
556 
566  virtual void GetFrustumPlanes(double aspect, double planes[24]);
567 
569 
572  double *GetOrientation();
573  double *GetOrientationWXYZ();
575 
580  void ComputeViewPlaneNormal();
581 
587  vtkMatrix4x4 *GetCameraLightTransformMatrix();
588 
592  virtual void UpdateViewport(vtkRenderer *vtkNotUsed(ren)) {}
593 
595 
598  vtkSetMacro(LeftEye, int);
599  vtkGetMacro(LeftEye, int);
601 
608  void ShallowCopy(vtkCamera *source);
609 
616  void DeepCopy(vtkCamera *source);
617 
619 
624  vtkSetMacro(FreezeFocalPoint, bool);
625  vtkGetMacro(FreezeFocalPoint, bool);
627 
629 
632  vtkSetMacro(UseScissor, bool);
633  vtkGetMacro(UseScissor, bool);
635 
637 
640  void SetScissorRect(vtkRecti scissorRect);
641  void GetScissorRect(vtkRecti& scissorRect);
643 
644 protected:
645  vtkCamera();
646  ~vtkCamera();
647 
649 
652  void ComputeDistance();
653  virtual void ComputeViewTransform();
655 
659  virtual void ComputeProjectionTransform(double aspect,
660  double nearz,
661  double farz);
662 
666  void ComputeCompositeProjectionTransform(double aspect,
667  double nearz,
668  double farz);
669 
670  void ComputeCameraLightTransform();
671 
672 
677  void ComputeWorldToScreenMatrix();
678 
682  void ComputeOffAxisProjectionFrustum();
683 
687  void ComputeModelViewMatrix();
688 
695  void PartialCopy(vtkCamera *source);
696 
697  double WindowCenter[2];
698  double ObliqueAngles[2];
699  double FocalPoint[3];
700  double Position[3];
701  double ViewUp[3];
702  double ViewAngle;
703  double ClippingRange[2];
704  double EyeAngle;
707  int Stereo;
708  int LeftEye;
709  double Thickness;
710  double Distance;
711  double DirectionOfProjection[3];
712  double ViewPlaneNormal[3];
713  double ViewShear[3];
715 
717 
718  double ScreenBottomLeft[3];
719  double ScreenBottomRight[3];
720  double ScreenTopRight[3];
721 
723 
726 
728 
730 
733 
738 
740 
741  double FocalDisk;
742 
743  vtkCameraCallbackCommand *UserViewTransformCallbackCommand;
744  friend class vtkCameraCallbackCommand;
745 
746  // ViewingRaysMtime keeps track of camera modifications which will
747  // change the calculation of viewing rays for the camera before it is
748  // transformed to the camera's location and orientation.
752 
754 
755 
756 private:
757  vtkCamera(const vtkCamera&) VTK_DELETE_FUNCTION;
758  void operator=(const vtkCamera&) VTK_DELETE_FUNCTION;
759 };
760 
761 #endif
vtkHomogeneousTransform * UserTransform
Definition: vtkCamera.h:731
double EyeSeparation
Definition: vtkCamera.h:722
int ParallelProjection
Definition: vtkCamera.h:705
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
superclass for homogeneous transformations
int UseHorizontalViewAngle
Definition: vtkCamera.h:714
record modification and/or execution time
Definition: vtkTimeStamp.h:35
double ViewAngle
Definition: vtkCamera.h:702
void DeepCopy(vtkPistonReference *self, vtkPistonReference *other)
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:734
vtkTypeUInt64 vtkMTimeType
Definition: vtkType.h:248
double Distance
Definition: vtkCamera.h:710
virtual void UpdateViewport(vtkRenderer *vtkNotUsed(ren))
Update the viewport.
Definition: vtkCamera.h:592
double Thickness
Definition: vtkCamera.h:709
vtkMatrix4x4 * ModelTransformMatrix
Definition: vtkCamera.h:729
supports function callbacks
vtkTimeStamp WorldToScreenMatrixMTime
Definition: vtkCamera.h:725
double ParallelScale
Definition: vtkCamera.h:706
bool UseScissor
Definition: vtkCamera.h:751
a simple class to control print indentation
Definition: vtkIndent.h:39
a virtual camera for 3D rendering
Definition: vtkCamera.h:50
virtual void Render(vtkRenderer *)
This method causes the camera to set up whatever is required for viewing the scene.
Definition: vtkCamera.h:544
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:724
vtkCameraCallbackCommand * UserViewTransformCallbackCommand
Definition: vtkCamera.h:743
int LeftEye
Definition: vtkCamera.h:708
vtkTransform * CameraLightTransform
Definition: vtkCamera.h:737
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:250
int UseOffAxisProjection
Definition: vtkCamera.h:716
double FocalDisk
Definition: vtkCamera.h:741
vtkTransform * ModelViewTransform
Definition: vtkCamera.h:739
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
vtkPerspectiveTransform * Transform
Definition: vtkCamera.h:736
vtkMatrix4x4 * EyeTransformMatrix
Definition: vtkCamera.h:727
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
vtkRecti ScissorRect
Definition: vtkCamera.h:753
vtkTimeStamp ViewingRaysMTime
Definition: vtkCamera.h:749
int Stereo
Definition: vtkCamera.h:707
vtkHomogeneousTransform * UserViewTransform
Definition: vtkCamera.h:732
double EyeAngle
Definition: vtkCamera.h:704
bool FreezeFocalPoint
Definition: vtkCamera.h:750
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
vtkPerspectiveTransform * ProjectionTransform
Definition: vtkCamera.h:735
describes a 4x4 matrix transformation