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

#include <Renderer.h>

Collaboration diagram for omni::render::Renderer:
Collaboration graph
[legend]

Public Member Functions

 Renderer (Session const &_session)
 
void renderToFile (QString const &_filename)
 
void renderOmniCalibration (QString const &_filename)
 Render to omni calibration (OmniC) file. More...
 
std::map< QScreen const *, QImage > stitchScreens (std::vector< const proj::Tuning * >const &) const
 

Private Attributes

Session const & session_
 

Constructor & Destructor Documentation

omni::render::Renderer::Renderer ( Session const &  _session)
34  :
35  session_(_session)
36  {}
Session const & session_
Definition: Renderer.h:49

Member Function Documentation

void omni::render::Renderer::renderOmniCalibration ( QString const &  _filename)

Render to omni calibration (OmniC) file.

Write render buffer

Brightness correction, not used currently

167  {
168  auto& _settings = session_.exportSettings();
169 
170  std::vector<proj::Tuning const *> _tunings;
171 
172  // Get all tunings
173  for (auto& _tuning : session_.tunings())
174  {
175  if (!_tuning->hasScreen() &&
176  _settings.excludeUnassignedProjectors()) continue;
177  _tunings.push_back(_tuning.get());
178  }
179 
180  std::ofstream _file(_filename.toStdString(),std::ofstream::out);
181 
182  // Write header
183  std::string _header("OMNIC_v1.0.0.0");
184  _header.resize(80);
185  _file.write(_header.c_str(),80);
186 
187  _file << uint32_t(_settings.outputMode());
188  _file << uint32_t(_tunings.size());
189 
190  auto _writeRect = [&](QRect const& _r) {
191  _file << int32_t(_r.left()); // offset_x
192  _file << int32_t(_r.top()); // offset_y
193  _file << uint32_t(_r.width()); // width
194  _file << uint32_t(_r.height()); // height
195  };
196 
197  auto _writeChannelCorrection = [&](proj::ChannelCorrection const& _c) {
198  _file << float(_c.gamma());
199  _file << float(_c.brightness());
200  _file << float(_c.contrast());
201  _file << float(_c.multiplier());
202  };
203 
204  for (auto* _tuning : _tunings) {
205  proj::Calibration _calib(*_tuning,_settings.outputMode());
206 
207  _file << uint32_t(_calib.virtualScreen());
208  _writeRect(_calib.screenGeometry());
209  _writeRect(_calib.contentGeometry());
210 
211  _writeChannelCorrection(_calib.colorCorrection().red());
212  _writeChannelCorrection(_calib.colorCorrection().green());
213  _writeChannelCorrection(_calib.colorCorrection().blue());
214  _writeChannelCorrection(_calib.colorCorrection().all());
215 
216  /// Write render buffer
217  uint32_t _w = _calib.renderSize().width();
218  uint32_t _h = _calib.renderSize().height();
219  _file << _w;
220  _file << _h;
221  _file.write((const char*)_calib.buffer().ptr(),sizeof(RGBAFloat)*_w*_h);
222 
223  /// Brightness correction, not used currently
224  _file << uint32_t(0) << uint32_t(0);
225  }
226  }
ExportSettings & exportSettings()
Return reference to export settings.
Definition: Session.cpp:152
proj::TuningList & tunings()
Returns reference to projector tunings.
Definition: Session.cpp:55
Session const & session_
Definition: Renderer.h:49
void omni::render::Renderer::renderToFile ( QString const &  _filename)

Merge all together

A file for each screen

90  {
91  auto& _settings = session_.exportSettings();
92 
93  std::vector<proj::Tuning const *> _tunings;
94 
95  QString _rawName = util::removeFileExt(_filename);
96 
97  // Get all tunings
98  for (auto& _tuning : session_.tunings())
99  {
100  if (!_tuning->hasScreen() &&
101  _settings.excludeUnassignedProjectors()) continue;
102  _tunings.push_back(_tuning.get());
103  }
104 
105  switch (_settings.separationMode())
106  {
107  /// Merge all together
109  {
110  auto _desktopRect = proj::ScreenSetup::desktopRect();
111  auto && _screens = stitchScreens(_tunings);
112  QImage _stitchedImage(_desktopRect.width(),
113  _desktopRect.height() * 2,
114  QImage::Format_RGB32);
115  QPainter _p(&_stitchedImage);
116 
117  for (auto& _screenImage : _screens)
118  {
119  auto *_screen = _screenImage.first;
120  auto& _image = _screenImage.second;
121  _p.drawImage(
122  session_.screenSetup().screenGeometry(
123  _screen).topLeft() - _desktopRect.topLeft(),
124  _image);
125  }
126  _stitchedImage.save(_filename);
127  break;
128  }
129 
130  /// A file for each screen
132  {
133  auto && _screens = stitchScreens(_tunings);
134 
135  for (auto& _screenImage : _screens)
136  {
137  auto *_screen = _screenImage.first;
138  auto& _image = _screenImage.second;
139  auto _desktopRect = proj::ScreenSetup::desktopRect();
140  auto && _screenRect = session_.screenSetup().screenGeometry(_screen);
141  QString _screenDesc(QString("_%1_%2_%3x%4.png").
142  arg(_screenRect.left()).
143  arg(_screenRect.top()).
144  arg(_screenRect.width()).
145  arg(_screenRect.height()));
146  _image.save(_rawName + _screenDesc);
147  }
148  break;
149  }
150 
152  {
153  int _tuningIndex = 0;
154 
155  for (auto& _tuning : _tunings)
156  {
157  proj::Calibration _calib(*_tuning,
158  session_.exportSettings().outputMode());
159  auto && _image = _calib.toImage();
160  _image.save(_rawName + QString("_%1.png").arg(_tuningIndex + 1));
161  }
162  break;
163  }
164  }
165  }
ExportSettings & exportSettings()
Return reference to export settings.
Definition: Session.cpp:152
QString removeFileExt(QString const &_filename)
Remove file extension and return string without file extension.
Definition: util.cpp:37
std::map< QScreen const *, QImage > stitchScreens(std::vector< const proj::Tuning * >const &) const
Definition: Renderer.cpp:38
proj::TuningList & tunings()
Returns reference to projector tunings.
Definition: Session.cpp:55
Session const & session_
Definition: Renderer.h:49
ScreenSetup & screenSetup()
Return reference to current screen setup.
Definition: Session.cpp:114
static QRect desktopRect(bool _excludeStandardScreen=true)
Definition: ScreenSetup.cpp:180
std::map< QScreen const *, QImage > omni::render::Renderer::stitchScreens ( std::vector< const proj::Tuning * >const &  _tunings) const

Render screen images from tunings

40  {
41  // Get all tunings for each screen
42  std::map<QScreen const *,
43  std::vector<proj::Tuning const *> > _screenToTunings;
44 
45  for (auto& _tuning : _tunings)
46  {
47  auto *_screen = _tuning->screen();
48 
49  if (_screenToTunings.count(_screen) == 0)
50  {
51  _screenToTunings[_screen] = std::vector<proj::Tuning const *>(
52  { _tuning });
53  }
54  else
55  {
56  _screenToTunings[_screen].push_back(_tuning);
57  }
58  }
59 
60  /// Render screen images from tunings
61  std::map<QScreen const *, QImage> _result;
62 
63  for (auto& _screenTunings : _screenToTunings)
64  {
65  auto *_screen = _screenTunings.first;
66  auto& _tunings = _screenTunings.second;
67 
68  auto _screenRect = session_.screenSetup().screenGeometry(_screen);
69  QImage _image(_screenRect.width(),
70  _screenRect.height() * 3, QImage::Format_RGB32); // Overall
71  // screen
72  // image
73  QPainter _p(&_image);
74 
75  for (auto& _tuning : _tunings)
76  {
77  auto _rect = _tuning->contentGeometry();
78  proj::Calibration _calib(*_tuning,
79  session_.exportSettings().outputMode());
80  auto && _tuningImage = _calib.toImage();
81  _p.drawImage(_rect.x(), 0, _tuningImage);
82  }
83  _p.end();
84  _result[_screen] = _image;
85  }
86  return _result;
87  }
ExportSettings & exportSettings()
Return reference to export settings.
Definition: Session.cpp:152
Session const & session_
Definition: Renderer.h:49
ScreenSetup & screenSetup()
Return reference to current screen setup.
Definition: Session.cpp:114

Field Documentation

Session const& omni::render::Renderer::session_
private

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