Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Projector.h
Go to the documentation of this file.
1 /* Copyright (c) 2014-2015 "Omnidome" by cr8tr
2  * Dome Mapping Projection Software (http://omnido.me).
3  * Omnidome was created by Michael Winkelmann aka Wilston Oreo (@WilstonOreo)
4  *
5  * This file is part of Omnidome.
6  *
7  * Omnidome is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU Affero General Public License for more details.
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef OMNI_PROJ_PROJECTOR_H_
21 #define OMNI_PROJ_PROJECTOR_H_
22 
23 #include <memory>
24 #include <QMatrix4x4>
25 #include <QScreen>
26 #include <omni/geometry/Angle.h>
27 #include "Setup.h"
28 
29 namespace omni {
30  namespace proj {
31  /// A projector with a transformation matrix and setup
32  class Projector {
33  public:
34  Projector();
35  Projector(
36  qreal _aspectRatio,
37  Angle _fov = 45.0);
38 
39  /**@brief Make a new projector setup with a certain id and delete old
40  one
41  @param Id _setupId Id of setup class
42  @param float _sceneSize Scale factor of setup positioning
43  * @return Pointer to new projector setup
44  **/
45  Setup * setup(Id const& _setupId, float _sceneScale = 1.0);
46 
47  /// Update projector matrix by current setup and return setup
48  Setup * setup();
49 
50  /// Returns projector setup (const version)
51  Setup const * setup() const;
52 
53  /// Aspect ratio of screen
54  qreal aspectRatio() const;
55 
56  /// Set aspect ratio of screen
57  void setAspectRatio(qreal);
58 
59  /// Return throw ratio of projector ( = 1/2 * tan(fov / 2))
60  qreal throwRatio() const;
61 
62  /// Set new throw ratio
63  void setThrowRatio(qreal);
64 
65  /// Return field of view
66  Angle fov() const;
67 
68  /// Set new field of view
69  void setFov(Angle _fov);
70 
71  /// Return keystone correction value for projector
72  qreal keystone() const;
73 
74  /// Set new keystone correction value (0.0 = default)
75  void setKeystone(qreal);
76 
77  /// Return transformation matrix
78  QMatrix4x4 const& matrix() const;
79 
80  /// Set transformation matrix
81  void setMatrix(QMatrix4x4 const&);
82 
83  /// Return projector matrix
84  QMatrix4x4 projectionMatrix() const;
85 
86  /// Return projector position (3rd column of projector matrix)
87  QVector3D pos() const;
88 
89  /// Write projector to stream
90  void toStream(QDataStream&) const;
91 
92  /// Read projector from stream
93  void fromStream(QDataStream&);
94 
95  /// Test for equality
96  friend bool operator==(Projector const&,
97  Projector const&);
98 
99 
100  private:
101  QMatrix4x4 matrix_;
102  qreal aspectRatio_ = 0.75;
103  Angle fov_;
104  qreal keystone_ = 0.0;
105  std::unique_ptr<Setup> setup_;
106  };
107  }
108 
109  using proj::Projector;
110 }
111 
113 
114 #endif /* OMNI_PROJ_PROJECTOR_H_ */
A projector with a transformation matrix and setup.
Definition: Projector.h:32
Setup * setup()
Update projector matrix by current setup and return setup.
Definition: Projector.cpp:47
qreal throwRatio() const
Return throw ratio of projector ( = 1/2 * tan(fov / 2))
Definition: Projector.cpp:69
Id type for classes An Id must only contain alpha numerical characters and must begin with a letter...
Definition: Id.h:34
Angle fov_
Definition: Projector.h:103
QMatrix4x4 const & matrix() const
Return transformation matrix.
Definition: Projector.cpp:101
void setFov(Angle _fov)
Set new field of view.
Definition: Projector.cpp:79
qreal keystone() const
Return keystone correction value for projector.
Definition: Projector.cpp:93
QMatrix4x4 matrix_
Definition: Projector.h:101
qreal keystone_
Definition: Projector.h:104
void setMatrix(QMatrix4x4 const &)
Set transformation matrix.
Definition: Projector.cpp:106
void setAspectRatio(qreal)
Set aspect ratio of screen.
Definition: Projector.cpp:65
std::unique_ptr< Setup > setup_
Definition: Projector.h:105
friend bool operator==(Projector const &, Projector const &)
Test for equality.
Definition: Projector.cpp:152
QMatrix4x4 projectionMatrix() const
Return projector matrix.
Definition: Projector.cpp:111
#define OMNI_DECL_STREAM_OPERATORS(CLASS)
Definition: Interface.h:53
void toStream(QDataStream &) const
Write projector to stream.
Definition: Projector.cpp:131
Projector()
Definition: Projector.cpp:30
void setKeystone(qreal)
Set new keystone correction value (0.0 = default)
Definition: Projector.cpp:97
void fromStream(QDataStream &)
Read projector from stream.
Definition: Projector.cpp:141
void setThrowRatio(qreal)
Set new throw ratio.
Definition: Projector.cpp:74
qreal aspectRatio() const
Aspect ratio of screen.
Definition: Projector.cpp:60
Angle fov() const
Return field of view.
Definition: Projector.cpp:88
qreal aspectRatio_
Definition: Projector.h:102
QVector3D pos() const
Return projector position (3rd column of projector matrix)
Definition: Projector.cpp:126
Interface for a projector setup.
Definition: Setup.h:32