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 =========================================================================*/
34 #ifndef vtkCamera_h
35 #define vtkCamera_h
36 
37 #include "vtkRenderingCoreModule.h" // For export macro
38 #include "vtkObject.h"
39 #include "vtkRect.h" // for ivar
40 
42 class vtkMatrix4x4;
44 class vtkRenderer;
45 class vtkTransform;
46 class vtkCallbackCommand;
47 class vtkCameraCallbackCommand;
48 
50 {
51 public:
52  vtkTypeMacro(vtkCamera, vtkObject);
53  void PrintSelf(ostream& os, vtkIndent indent);
54 
58  static vtkCamera *New();
59 
61 
63  void SetPosition(double x, double y, double z);
64  void SetPosition(const double a[3]) {
65  this->SetPosition(a[0], a[1], a[2]); };
66  vtkGetVector3Macro(Position, double);
68 
70 
72  void SetFocalPoint(double x, double y, double z);
73  void SetFocalPoint(const double a[3]) {
74  this->SetFocalPoint(a[0], a[1], a[2]);};
75  vtkGetVector3Macro(FocalPoint, double);
77 
79 
81  void SetViewUp(double vx, double vy, double vz);
82  void SetViewUp(const double a[3]) {
83  this->SetViewUp(a[0], a[1], a[2]); }
84  vtkGetVector3Macro(ViewUp, double);
86 
90  void OrthogonalizeViewUp();
91 
94  void SetDistance(double);
95 
97 
99  vtkGetMacro(Distance, double);
101 
103 
106  vtkGetVector3Macro(DirectionOfProjection, double);
108 
113  void Dolly(double value);
114 
116 
117  void SetRoll(double angle);
118  double GetRoll();
120 
123  void Roll(double angle);
124 
129  void Azimuth(double angle);
130 
136  void Yaw(double angle);
137 
142  void Elevation(double angle);
143 
147  void Pitch(double angle);
148 
150 
153  void SetParallelProjection(int flag);
154  vtkGetMacro(ParallelProjection, int);
155  vtkBooleanMacro(ParallelProjection, int);
157 
159 
165  void SetUseHorizontalViewAngle(int flag);
166  vtkGetMacro(UseHorizontalViewAngle, int);
167  vtkBooleanMacro(UseHorizontalViewAngle, int);
169 
171 
178  void SetViewAngle(double angle);
179  vtkGetMacro(ViewAngle, double);
181 
183 
188  void SetParallelScale(double scale);
189  vtkGetMacro(ParallelScale ,double);
191 
196  void Zoom(double factor);
197 
199 
208  void SetClippingRange(double dNear, double dFar);
209  void SetClippingRange(const double a[2])
210  { this->SetClippingRange(a[0], a[1]); }
211  vtkGetVector2Macro(ClippingRange, double);
213 
215 
218  void SetThickness(double);
219  vtkGetMacro(Thickness, double);
221 
223 
228  void SetWindowCenter(double x, double y);
229  vtkGetVector2Macro(WindowCenter, double);
231 
240  void SetObliqueAngles(double alpha, double beta);
241 
245  void ApplyTransform(vtkTransform *t);
246 
248 
251  vtkGetVector3Macro(ViewPlaneNormal, double);
253 
255 
259  void SetViewShear(double dxdz, double dydz, double center);
260  void SetViewShear(double d[3]);
261  vtkGetVector3Macro(ViewShear, double);
263 
265 
267  vtkSetMacro(EyeAngle, double);
268  vtkGetMacro(EyeAngle, double);
270 
272 
276  vtkSetMacro(FocalDisk, double);
277  vtkGetMacro(FocalDisk, double);
279 
281 
285  vtkSetMacro(UseOffAxisProjection, int);
286  vtkGetMacro(UseOffAxisProjection, int);
287  vtkBooleanMacro(UseOffAxisProjection, int);
289 
291 
293  vtkSetVector3Macro(ScreenBottomLeft, double);
294  vtkGetVector3Macro(ScreenBottomLeft, double);
296 
298 
300  vtkSetVector3Macro(ScreenBottomRight, double);
301  vtkGetVector3Macro(ScreenBottomRight, double);
303 
305 
307  vtkSetVector3Macro(ScreenTopRight, double);
308  vtkGetVector3Macro(ScreenTopRight, double);
310 
312 
314  vtkSetMacro(EyeSeparation, double);
315  vtkGetMacro(EyeSeparation, double);
317 
319 
323  void SetEyePosition(double eyePosition[3]);
324  void GetEyePosition(double eyePosition[3]);
326 
329  void GetEyePlaneNormal(double normal[3]);
330 
332 
335  void SetEyeTransformMatrix(vtkMatrix4x4* matrix);
336  vtkGetObjectMacro(EyeTransformMatrix, vtkMatrix4x4);
338 
342  void SetEyeTransformMatrix(const double elements[16]);
343 
345 
348  void SetModelTransformMatrix(vtkMatrix4x4 *matrix);
349  vtkGetObjectMacro(ModelTransformMatrix, vtkMatrix4x4);
351 
355  void SetModelTransformMatrix(const double elements[16]);
356 
358  virtual vtkMatrix4x4 *GetModelViewTransformMatrix();
359 
361  virtual vtkTransform *GetModelViewTransformObject();
362 
368  virtual vtkMatrix4x4 *GetViewTransformMatrix();
369 
375  virtual vtkTransform *GetViewTransformObject();
376 
378 
384  virtual vtkMatrix4x4 *GetProjectionTransformMatrix(double aspect,
385  double nearz,
386  double farz);
388 
390 
396  virtual vtkPerspectiveTransform *GetProjectionTransformObject(double aspect,
397  double nearz,
398  double farz);
400 
402 
409  virtual vtkMatrix4x4 *GetCompositeProjectionTransformMatrix(double aspect,
410  double nearz,
411  double farz);
413 
418  virtual vtkMatrix4x4 *GetProjectionTransformMatrix(vtkRenderer *ren);
419 
421 
425  void SetUserViewTransform(vtkHomogeneousTransform *transform);
426  vtkGetObjectMacro(UserViewTransform,vtkHomogeneousTransform);
428 
430 
434  void SetUserTransform(vtkHomogeneousTransform *transform);
435  vtkGetObjectMacro(UserTransform,vtkHomogeneousTransform);
437 
441  virtual void Render(vtkRenderer *) {}
442 
445  unsigned long GetViewingRaysMTime();
446 
449  void ViewingRaysModified();
450 
458  virtual void GetFrustumPlanes(double aspect, double planes[24]);
459 
461 
462  double *GetOrientation();
463  double *GetOrientationWXYZ();
465 
468  void ComputeViewPlaneNormal();
469 
473  vtkMatrix4x4 *GetCameraLightTransformMatrix();
474 
476  virtual void UpdateViewport(vtkRenderer *vtkNotUsed(ren)) {}
477 
479 
480  vtkSetMacro(LeftEye, int);
481  vtkGetMacro(LeftEye, int);
483 
486  void ShallowCopy(vtkCamera *source);
487 
490  void DeepCopy(vtkCamera *source);
491 
493 
496  vtkSetMacro(FreezeFocalPoint, bool);
497  vtkGetMacro(FreezeFocalPoint, bool);
499 
501 
502  vtkSetMacro(UseScissor, bool);
503  vtkGetMacro(UseScissor, bool);
505 
507 
508  void SetScissorRect(vtkRecti scissorRect);
509  void GetScissorRect(vtkRecti& scissorRect);
511 
512 protected:
513  vtkCamera();
514  ~vtkCamera();
515 
517 
518  void ComputeDistance();
519  virtual void ComputeViewTransform();
521 
523 
524  virtual void ComputeProjectionTransform(double aspect,
525  double nearz,
526  double farz);
528 
530 
531  void ComputeCompositeProjectionTransform(double aspect,
532  double nearz,
533  double farz);
535 
536  void ComputeCameraLightTransform();
537 
538 
541  void ComputeWorldToScreenMatrix();
542 
544  void ComputeOffAxisProjectionFrustum();
545 
547  void ComputeModelViewMatrix();
548 
551  void PartialCopy(vtkCamera *source);
552 
553  double WindowCenter[2];
554  double ObliqueAngles[2];
555  double FocalPoint[3];
556  double Position[3];
557  double ViewUp[3];
558  double ViewAngle;
559  double ClippingRange[2];
560  double EyeAngle;
563  int Stereo;
564  int LeftEye;
565  double Thickness;
566  double Distance;
567  double DirectionOfProjection[3];
568  double ViewPlaneNormal[3];
569  double ViewShear[3];
571 
573 
574  double ScreenBottomLeft[3];
575  double ScreenBottomRight[3];
576  double ScreenTopRight[3];
577 
579 
582 
584 
586 
589 
594 
596 
597  double FocalDisk;
598  //BTX
599  vtkCameraCallbackCommand *UserViewTransformCallbackCommand;
600  friend class vtkCameraCallbackCommand;
601  //ETX
602 
603  // ViewingRaysMtime keeps track of camera modifications which will
604  // change the calculation of viewing rays for the camera before it is
605  // transformed to the camera's location and orientation.
609 
611 
612 
613 private:
614  vtkCamera(const vtkCamera&); // Not implemented.
615  void operator=(const vtkCamera&); // Not implemented.
616 };
617 
618 #endif
vtkHomogeneousTransform * UserTransform
Definition: vtkCamera.h:587
double EyeSeparation
Definition: vtkCamera.h:578
int ParallelProjection
Definition: vtkCamera.h:561
abstract base class for most VTK objects
Definition: vtkObject.h:61
represent and manipulate 4x4 transformation matrices
Definition: vtkMatrix4x4.h:38
void SetViewUp(const double a[3])
Definition: vtkCamera.h:82
superclass for homogeneous transformations
int UseHorizontalViewAngle
Definition: vtkCamera.h:570
record modification and/or execution time
Definition: vtkTimeStamp.h:34
double ViewAngle
Definition: vtkCamera.h:558
void DeepCopy(vtkPistonReference *self, vtkPistonReference *other)
abstract specification for renderers
Definition: vtkRenderer.h:62
describes linear transformations via a 4x4 matrix
Definition: vtkTransform.h:59
void SetPosition(const double a[3])
Definition: vtkCamera.h:64
vtkTransform * ViewTransform
Definition: vtkCamera.h:590
double Distance
Definition: vtkCamera.h:566
virtual void UpdateViewport(vtkRenderer *vtkNotUsed(ren))
Definition: vtkCamera.h:476
double Thickness
Definition: vtkCamera.h:565
vtkMatrix4x4 * ModelTransformMatrix
Definition: vtkCamera.h:585
supports function callbacks
vtkTimeStamp WorldToScreenMatrixMTime
Definition: vtkCamera.h:581
virtual void PrintSelf(ostream &os, vtkIndent indent)
double ParallelScale
Definition: vtkCamera.h:562
bool UseScissor
Definition: vtkCamera.h:608
a simple class to control print indentation
Definition: vtkIndent.h:38
a virtual camera for 3D rendering
Definition: vtkCamera.h:49
virtual void Render(vtkRenderer *)
Definition: vtkCamera.h:441
void SetFocalPoint(const double a[3])
Definition: vtkCamera.h:73
vtkMatrix4x4 * WorldToScreenMatrix
Definition: vtkCamera.h:580
vtkCameraCallbackCommand * UserViewTransformCallbackCommand
Definition: vtkCamera.h:599
int LeftEye
Definition: vtkCamera.h:564
vtkTransform * CameraLightTransform
Definition: vtkCamera.h:593
void SetClippingRange(const double a[2])
Definition: vtkCamera.h:209
int UseOffAxisProjection
Definition: vtkCamera.h:572
double FocalDisk
Definition: vtkCamera.h:597
vtkTransform * ModelViewTransform
Definition: vtkCamera.h:595
vtkPerspectiveTransform * Transform
Definition: vtkCamera.h:592
vtkMatrix4x4 * EyeTransformMatrix
Definition: vtkCamera.h:583
boost::graph_traits< vtkGraph * >::vertex_descriptor source(boost::graph_traits< vtkGraph * >::edge_descriptor e, vtkGraph *)
vtkRecti ScissorRect
Definition: vtkCamera.h:610
#define VTKRENDERINGCORE_EXPORT
vtkTimeStamp ViewingRaysMTime
Definition: vtkCamera.h:606
int Stereo
Definition: vtkCamera.h:563
vtkHomogeneousTransform * UserViewTransform
Definition: vtkCamera.h:588
double EyeAngle
Definition: vtkCamera.h:560
bool FreezeFocalPoint
Definition: vtkCamera.h:607
static vtkObject * New()
vtkPerspectiveTransform * ProjectionTransform
Definition: vtkCamera.h:591
describes a 4x4 matrix transformation