Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Attributes | Friends
omni::proj::Projector Class Reference

A projector with a transformation matrix and setup. More...

#include <Projector.h>

Collaboration diagram for omni::proj::Projector:
Collaboration graph
[legend]

Public Member Functions

 Projector ()
 
 Projector (qreal _aspectRatio, Angle _fov=45.0)
 
Setupsetup (Id const &_setupId, float _sceneScale=1.0)
 Make a new projector setup with a certain id and delete old one. More...
 
Setupsetup ()
 Update projector matrix by current setup and return setup. More...
 
Setup const * setup () const
 Returns projector setup (const version) More...
 
qreal aspectRatio () const
 Aspect ratio of screen. More...
 
void setAspectRatio (qreal)
 Set aspect ratio of screen. More...
 
qreal throwRatio () const
 Return throw ratio of projector ( = 1/2 * tan(fov / 2)) More...
 
void setThrowRatio (qreal)
 Set new throw ratio. More...
 
Angle fov () const
 Return field of view. More...
 
void setFov (Angle _fov)
 Set new field of view. More...
 
qreal keystone () const
 Return keystone correction value for projector. More...
 
void setKeystone (qreal)
 Set new keystone correction value (0.0 = default) More...
 
QMatrix4x4 const & matrix () const
 Return transformation matrix. More...
 
void setMatrix (QMatrix4x4 const &)
 Set transformation matrix. More...
 
QMatrix4x4 projectionMatrix () const
 Return projector matrix. More...
 
QVector3D pos () const
 Return projector position (3rd column of projector matrix) More...
 
void toStream (QDataStream &) const
 Write projector to stream. More...
 
void fromStream (QDataStream &)
 Read projector from stream. More...
 

Private Attributes

QMatrix4x4 matrix_
 
qreal aspectRatio_ = 0.75
 
Angle fov_
 
qreal keystone_ = 0.0
 
std::unique_ptr< Setupsetup_
 

Friends

bool operator== (Projector const &, Projector const &)
 Test for equality. More...
 

Detailed Description

A projector with a transformation matrix and setup.

Constructor & Destructor Documentation

omni::proj::Projector::Projector ( )
30  :
31  fov_(45.0)
32  {}
Angle fov_
Definition: Projector.h:103
omni::proj::Projector::Projector ( qreal  _aspectRatio,
Angle  _fov = 45.0 
)
35  :
36  aspectRatio_(_aspectRatio),
37  fov_(_fov)
38  {}
Angle fov_
Definition: Projector.h:103
qreal aspectRatio_
Definition: Projector.h:102

Member Function Documentation

qreal omni::proj::Projector::aspectRatio ( ) const

Aspect ratio of screen.

61  {
62  return aspectRatio_;
63  }
qreal aspectRatio_
Definition: Projector.h:102
Angle omni::proj::Projector::fov ( ) const

Return field of view.

89  {
90  return fov_;
91  }
Angle fov_
Definition: Projector.h:103
void omni::proj::Projector::fromStream ( QDataStream &  _is)

Read projector from stream.

141  {
142  PropertyMap _map;
143  _is >> _map;
144  _map.get("fov", fov_);
145  _map.get("keystone", keystone_);
146  _map.get("aspectRatio",aspectRatio_);
147  _map.getPtr("setup", [this](const Id& _id) -> Setup * {
148  return this->setup(_id);
149  });
150  }
Setup * setup()
Update projector matrix by current setup and return setup.
Definition: Projector.cpp:47
Angle fov_
Definition: Projector.h:103
qreal keystone_
Definition: Projector.h:104
qreal aspectRatio_
Definition: Projector.h:102
qreal omni::proj::Projector::keystone ( ) const

Return keystone correction value for projector.

93  {
94  return keystone_;
95  }
qreal keystone_
Definition: Projector.h:104
QMatrix4x4 const & omni::proj::Projector::matrix ( ) const

Return transformation matrix.

102  {
103  return matrix_;
104  }
QMatrix4x4 matrix_
Definition: Projector.h:101
QVector3D omni::proj::Projector::pos ( ) const

Return projector position (3rd column of projector matrix)

127  {
128  return matrix().column(3).toVector3D();
129  }
QMatrix4x4 const & matrix() const
Return transformation matrix.
Definition: Projector.cpp:101
QMatrix4x4 omni::proj::Projector::projectionMatrix ( ) const

Return projector matrix.

112  {
113  QMatrix4x4 _m;
114 
115  Frustum _frustum(*this);
116  float _near = 0.01;
117  QRectF _rect = _frustum.rect(_near, 1000.0);
118 
119  _m.frustum(_rect.left(), _rect.right(), _rect.bottom(),
120  _rect.top(), _near, 1000.0);
121  _m.lookAt(pos(), pos() + matrix().column(0).toVector3D(), matrix().column(
122  2).toVector3D());
123  return _m;
124  }
QMatrix4x4 const & matrix() const
Return transformation matrix.
Definition: Projector.cpp:101
QVector3D pos() const
Return projector position (3rd column of projector matrix)
Definition: Projector.cpp:126
void omni::proj::Projector::setAspectRatio ( qreal  _aspectRatio)

Set aspect ratio of screen.

65  {
66  aspectRatio_ = _aspectRatio;
67  }
qreal aspectRatio_
Definition: Projector.h:102
void omni::proj::Projector::setFov ( Angle  _fov)

Set new field of view.

80  {
81  fov_ = _fov;
82 
83  if (fov_.degrees() < 1.0) fov_ = 1.0;
84 
85  if (fov_.degrees() >= 180.0) fov_ = 180.0;
86  }
Angle fov_
Definition: Projector.h:103
void omni::proj::Projector::setKeystone ( qreal  _keystone)

Set new keystone correction value (0.0 = default)

97  {
98  keystone_ = _keystone;
99  }
qreal keystone_
Definition: Projector.h:104
void omni::proj::Projector::setMatrix ( QMatrix4x4 const &  _matrix)

Set transformation matrix.

107  {
108  matrix_ = _matrix;
109  }
QMatrix4x4 matrix_
Definition: Projector.h:101
void omni::proj::Projector::setThrowRatio ( qreal  _throwRatio)

Set new throw ratio.

75  {
76  fov_ = Angle::fromRad(2.0 * atan(1.0 / (_throwRatio * 2.0)));
77  }
Angle fov_
Definition: Projector.h:103
Setup * omni::proj::Projector::setup ( Id const &  _setupId,
float  _sceneScale = 1.0 
)

Make a new projector setup with a certain id and delete old one.

Parameters
Id_setupId Id of setup class
float_sceneSize Scale factor of setup positioning
Returns
Pointer to new projector setup
41  {
42  setup_.reset(SetupFactory::create(_setupId));
43  setup()->scale(_scale);
44  return setup();
45  }
Setup * setup()
Update projector matrix by current setup and return setup.
Definition: Projector.cpp:47
virtual void scale(qreal _factor)=0
Scale projector setup by factor, e.g. to adapt defaults to scene size.
std::unique_ptr< Setup > setup_
Definition: Projector.h:105
static interface_type * create(const key_type &_key, const ARGS &..._args)
Instantiates an object of the class by id and constructor arguments.
Definition: factory.hpp:101
Setup * omni::proj::Projector::setup ( )

Update projector matrix by current setup and return setup.

48  {
49  if (!setup_) return nullptr;
50 
51  setup_->setup(*this);
52  return setup_.get();
53  }
std::unique_ptr< Setup > setup_
Definition: Projector.h:105
Setup const * omni::proj::Projector::setup ( ) const

Returns projector setup (const version)

56  {
57  return setup_.get();
58  }
std::unique_ptr< Setup > setup_
Definition: Projector.h:105
qreal omni::proj::Projector::throwRatio ( ) const

Return throw ratio of projector ( = 1/2 * tan(fov / 2))

70  {
71  return 0.5 / tan(fov_.radians() / 2.0);
72  }
Angle fov_
Definition: Projector.h:103
void omni::proj::Projector::toStream ( QDataStream &  _os) const

Write projector to stream.

131  {
132  PropertyMap _map;
133 
134  _map("fov", fov_);
135  _map("keystone", keystone_);
136  _map("aspectRatio", aspectRatio_);
137  _map("setup", setup_);
138  _os << _map;
139  }
Angle fov_
Definition: Projector.h:103
qreal keystone_
Definition: Projector.h:104
std::unique_ptr< Setup > setup_
Definition: Projector.h:105
qreal aspectRatio_
Definition: Projector.h:102

Friends And Related Function Documentation

bool operator== ( Projector const &  _lhs,
Projector const &  _rhs 
)
friend

Test for equality.

153  {
154  return
160  }
Angle fov_
Definition: Projector.h:103
QMatrix4x4 matrix_
Definition: Projector.h:101
qreal keystone_
Definition: Projector.h:104
std::unique_ptr< Setup > setup_
Definition: Projector.h:105
#define OMNI_TEST_MEMBER_EQUAL(member)
Definition: util.h:125
#define OMNI_TEST_PTR_MEMBER_EQUAL(member)
Definition: util.h:128
qreal aspectRatio_
Definition: Projector.h:102

Field Documentation

qreal omni::proj::Projector::aspectRatio_ = 0.75
private
Angle omni::proj::Projector::fov_
private
qreal omni::proj::Projector::keystone_ = 0.0
private
QMatrix4x4 omni::proj::Projector::matrix_
private
std::unique_ptr<Setup> omni::proj::Projector::setup_
private

The documentation for this class was generated from the following files: