Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Tuning.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_TUNING_H_
21 #define OMNI_PROJ_TUNING_H_
22 
23 #include <memory>
24 #include <QColor>
25 #include <omni/Id.h>
26 #include <omni/WarpGrid.h>
27 #include <omni/BlendMask.h>
30 #include <omni/proj/Projector.h>
31 #include <omni/proj/Setup.h>
32 #include <omni/mapping/Interface.h>
33 #include <omni/patch/List.h>
34 
35 namespace omni {
36  class Session;
37 
38  namespace visual {
39  /// Forward declaration for tuning visualizer
40  class Tuning;
41  }
42 
43  namespace proj {
44  class Calibration;
45 
46  /**@brief A projector tuning holds adjustment and distorsion data for a
47  single projector and screen
48  @detail A tuning consists of a projector, warp grid, blend mask and color
49  correction.
50  It holds a color as well. It can render a projector calibration
51  **/
52  class Tuning {
53  public:
55 
56  /// Constructor
57  Tuning(Session const&);
58 
59  /// Assign virtual screen to tuning
60  void assignVirtualScreen();
61 
62  /// Set screen for this tuning
63  void setScreen(QScreen const *_screen,
64  int _subScreenIndex);
65 
66  QScreen const * screen() const;
67  int subScreenIndex() const;
68 
69  Projector & projector();
70  Projector const & projector() const;
71 
72  /// Returns reference to warp grid
73  WarpGrid & warpGrid();
74 
75  /// Returns reference to warp grid (const version)
76  WarpGrid const & warpGrid() const;
77 
78  /// Returns reference to blend mask
79  BlendMask & blendMask();
80 
81  /// Returns reference to blend mask (const version)
82  BlendMask const & blendMask() const;
83 
84  /// Return list of patches
85  PatchList & patches();
86 
87  /// Return list of patches (const version)
88  PatchList const & patches() const;
89 
90  /// Color correction for projector
92 
93  /// Color correction for projector (const)
94  ColorCorrection const& colorCorrection() const;
95 
96  /// Returns color for mapping
97  QColor color() const;
98 
99  /// Sets color for mapping
100  void setColor(QColor const&);
101 
102  /// Return pointer to visualizer
104 
105  /// Return pointer to visualizer (const version)
106  visualizer_type const* visualizer() const;
107 
108  /// Make visualizer if it is not instantiated yet
110 
111  /// Return if a screen is associated with mapping
112  bool hasScreen() const;
113 
114  /// Render calibration
115  void renderCalibration(Calibration& _calib)
116  const;
117 
118  /// Rectangle of the output screen on desktop
119  QRect screenGeometry() const;
120 
121  /// Content rectangle (position) inside the screen
122  QRect contentGeometry() const;
123 
124  /// Render and return calibration
127 
128  /// Returns width of screen
129  int width() const;
130 
131  /// Returns height of screen
132  int height() const;
133 
134  /// Return flag if output is disabled, projector output is black
135  bool outputDisabled() const;
136 
137  /// Return flag if output is enabled
138  bool outputEnabled() const;
139 
140  /// Disable output if _disabled is true, enable otherwise
141  void setOutputDisabled(bool _disabled = true);
142 
143  /// Enable output if _enabled is true, disable otherwise
144  void setOutputEnabled(bool _enabled = true);
145 
146  /// Return opacity of overlapped blend mask
147  float overlapOpacity() const;
148 
149  /// Set opacity of overlap mask in blend mode
150  void setOverlapOpacity(float);
151 
152  /// Write tuning to stream
153  void toStream(QDataStream&) const;
154 
155  /// Read tuning from stream
156  void fromStream(QDataStream&);
157 
158  /// Test for equality
159  friend bool operator==(Tuning const&,
160  Tuning const&);
161 
162  /// Return const reference to owning session
163  Session const& session() const;
164 
165  /// Return id of tuning
166  int id() const;
167 
168  private:
169  bool outputDisabled_ = false;
170  bool overlapOpacity_ = 0.0;
171  QColor color_;
173 
174  /**@brief Screen this tuning is assigned to.
175  @detail If screen is nullptr, tuning is assigned to virtual screen
176  **/
177  QScreen const* screen_ = nullptr;
178 
179  /// SubScreen index of this tuning
181 
185  std::unique_ptr<visualizer_type> viz_;
188  };
189  }
190 }
191 
193 
194 #endif /* OMNI_MAPPING_H_ */
A projector with a transformation matrix and setup.
Definition: Projector.h:32
void fromStream(QDataStream &)
Read tuning from stream.
Definition: Tuning.cpp:246
float overlapOpacity() const
Return opacity of overlapped blend mask.
Definition: Tuning.cpp:217
int subScreenIndex_
SubScreen index of this tuning.
Definition: Tuning.h:180
A session consists of a canvas, a mapping, a list of tunings and one or several inputs.
Definition: Session.h:41
visualizer_type * visualizer()
Return pointer to visualizer.
Definition: Tuning.cpp:135
WarpGrid warpGrid_
Definition: Tuning.h:182
void assignVirtualScreen()
Assign virtual screen to tuning.
Definition: Tuning.cpp:44
Session const & session_
Definition: Tuning.h:187
QRect screenGeometry() const
Rectangle of the output screen on desktop.
Definition: Tuning.cpp:162
void setOverlapOpacity(float)
Set opacity of overlap mask in blend mode.
Definition: Tuning.cpp:222
void setOutputDisabled(bool _disabled=true)
Disable output if _disabled is true, enable otherwise.
Definition: Tuning.cpp:208
PatchList patches_
Definition: Tuning.h:186
CalibrationMode
Defines which type of data is in a calibration.
Definition: CalibrationMode.h:28
A projector tuning holds adjustment and distorsion data for a single projector and screen A tuning c...
Definition: Tuning.h:52
visualizer_type * makeVisualizer()
Make visualizer if it is not instantiated yet.
Definition: Tuning.cpp:139
void setOutputEnabled(bool _enabled=true)
Enable output if _enabled is true, disable otherwise.
Definition: Tuning.cpp:213
void setColor(QColor const &)
Sets color for mapping.
Definition: Tuning.cpp:129
int id() const
Return id of tuning.
Definition: Tuning.cpp:286
Projector & projector()
Definition: Tuning.cpp:76
WarpGrid & warpGrid()
Returns reference to warp grid.
Definition: Tuning.cpp:86
Projector projector_
Definition: Tuning.h:172
void renderCalibration(Calibration &_calib) const
Render calibration.
Definition: Tuning.cpp:176
Calibration generated from a tuning Calibration has output mode with either UVW or TEXCOORDS...
Definition: Calibration.h:39
A warp grid is a 2D bezier grid with MxN points Default size 6x6 points. Selected points are also st...
Definition: WarpGrid.h:32
QColor color() const
Returns color for mapping.
Definition: Tuning.cpp:124
BlendMask & blendMask()
Returns reference to blend mask.
Definition: Tuning.cpp:96
bool overlapOpacity_
Definition: Tuning.h:170
#define OMNI_DECL_STREAM_OPERATORS(CLASS)
Definition: Interface.h:53
Color correction for RGB color space.
Definition: ColorCorrection.h:29
Tuning(Session const &)
Constructor.
Definition: Tuning.cpp:37
int subScreenIndex() const
Definition: Tuning.cpp:61
BlendMask blendMask_
Definition: Tuning.h:183
void setScreen(QScreen const *_screen, int _subScreenIndex)
Set screen for this tuning.
Definition: Tuning.cpp:48
std::unique_ptr< visualizer_type > viz_
Definition: Tuning.h:185
PatchList & patches()
Return list of patches.
Definition: Tuning.cpp:107
ColorCorrection colorCorrection_
Definition: Tuning.h:184
bool outputEnabled() const
Return flag if output is enabled.
Definition: Tuning.cpp:203
QScreen const * screen_
Screen this tuning is assigned to. If screen is nullptr, tuning is assigned to virtual screen...
Definition: Tuning.h:177
int height() const
Returns height of screen.
Definition: Tuning.cpp:192
A blend mask consists of an edge mask and stroke mask with a brush Edge mask and stroke mask are sto...
Definition: BlendMask.h:35
Session const & session() const
Return const reference to owning session.
Definition: Tuning.cpp:282
int width() const
Returns width of screen.
Definition: Tuning.cpp:187
void toStream(QDataStream &) const
Write tuning to stream.
Definition: Tuning.cpp:227
QScreen const * screen() const
Definition: Tuning.cpp:56
Definition: List.h:29
QRect contentGeometry() const
Content rectangle (position) inside the screen.
Definition: Tuning.cpp:167
ColorCorrection & colorCorrection()
Color correction for projector.
Definition: Tuning.cpp:116
friend bool operator==(Tuning const &, Tuning const &)
Test for equality.
Definition: Tuning.cpp:269
bool hasScreen() const
Return if a screen is associated with mapping.
Definition: Tuning.cpp:156
omni::visual::Tuning visualizer_type
Definition: Tuning.h:54
QColor color_
Definition: Tuning.h:171
bool outputDisabled_
Definition: Tuning.h:169
bool outputDisabled() const
Return flag if output is disabled, projector output is black.
Definition: Tuning.cpp:198
Tuning visualizer.
Definition: Tuning.h:40