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

Singleton class which manages the current screen setup. More...

#include <ScreenSetup.h>

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

Public Member Functions

 ScreenSetup (Session const *_session)
 
QRect screenGeometry (QScreen const *=nullptr) const
 Returns the screen geometry for a screen If screen is null, the geometry for the virtual screen is returned. More...
 
Session const * session () const
 Return const pointer to session. More...
 
int subScreenCount (QScreen const *=nullptr) const
 Returns the number of subscreens for a single screen If screen is nullptr, number of subscreen for virtual screen is returned. More...
 
int subScreenWidth (QScreen const *=nullptr) const
 Returns the number of subscreens for a single screen If screen is nullptr, number of subscreen for virtual screen is returned. More...
 
QRect subScreenRect (int _index, QScreen const *=nullptr) const
 Returns the rectangle of a subscreen with a certain index. More...
 
qreal subScreenAspectRatio (QScreen const *=nullptr) const
 Return aspect ratio of subscreen. More...
 
QRect virtualScreenRect () const
 Virtual desktop rect contains all non-assigned tunings. More...
 
QRect combinedDesktopRect () const
 Returns combined desktop and virtual desktop rect. More...
 
bool noTuningsAssigned () const
 Returns true if no tuning is assigned to a screen. More...
 
bool noTuningsAssigned (QScreen const *) const
 
std::set< QScreen const * > usedScreens () const
 
std::set< proj::Tuning const * > tunings (bool _excludeNonAssigned) const
 
QRect tuningRect () const
 Bounding rect that unifies all tunings. More...
 
bool operator== (const ScreenSetup &) const
 

Static Public Member Functions

static std::vector< QSize > const & screenResolutions ()
 Returns screen size that supports triple heads. More...
 
static QScreen const * standardScreen ()
 Return standard screen, where omnidome has to be placed. More...
 
static int subScreenCountForScreen (QScreen const *)
 Static method for getting subscreen count for screen Screen must not be nullptr! More...
 
static int subScreenWidthForScreen (QScreen const *)
 Static method for getting subscreen width for screen Screen must not be nullptr! More...
 
static QRect subScreenRectForScreen (int _index, QScreen const *)
 Static method for getting subscreen count for screen Screen must not be nullptr! More...
 
static QRect desktopRect (bool _excludeStandardScreen=true)
 
static std::vector< QScreen
const * > 
screens (bool _excludeStandardScreen=true)
 Return vector, optionally excluded standard screen. More...
 
static QScreen const * screenFromRect (QRect const &)
 Return pointer to screen for rectangle, nullptr if no screen with. More...
 

Private Attributes

Session const * session_
 

Detailed Description

Singleton class which manages the current screen setup.

Constructor & Destructor Documentation

omni::proj::ScreenSetup::ScreenSetup ( Session const *  _session)
29  :
30  session_(_session)
31  {}
Session const * session_
Definition: ScreenSetup.h:119

Member Function Documentation

QRect omni::proj::ScreenSetup::combinedDesktopRect ( ) const

Returns combined desktop and virtual desktop rect.

If there are no tunings assigned, ignore desktopRect

98  {
99  /// If there are no tunings assigned, ignore desktopRect
100 
101  /*QRect _desktopRect;
102  auto _screens = ScreenSetup::screens();
103  for (auto& _screen : _screens) {
104  if (noTuningsAssigned(_screen)) continue;
105  _desktopRect |= _screen->geometry();
106  }*/
107  return desktopRect() | virtualScreenRect();
108  }
QRect virtualScreenRect() const
Virtual desktop rect contains all non-assigned tunings.
Definition: ScreenSetup.cpp:61
static QRect desktopRect(bool _excludeStandardScreen=true)
Definition: ScreenSetup.cpp:180
QRect omni::proj::ScreenSetup::desktopRect ( bool  _excludeStandardScreen = true)
static
181  {
182  QRect _desktopRect;
183  auto _screens = ScreenSetup::screens(_excludeStandardScreen);
184 
185  for (auto& _screen : _screens) _desktopRect |= _screen->geometry();
186  return _desktopRect;
187  }
static std::vector< QScreen const * > screens(bool _excludeStandardScreen=true)
Return vector, optionally excluded standard screen.
Definition: ScreenSetup.cpp:189
bool omni::proj::ScreenSetup::noTuningsAssigned ( ) const

Returns true if no tuning is assigned to a screen.

75  {
76  if (!session()) return true;
77 
78  for (auto& _tuning : session()->tunings()) {
79  if (_tuning->hasScreen()) {
80  return false;
81  }
82  }
83  return true;
84  }
std::set< proj::Tuning const * > tunings(bool _excludeNonAssigned) const
Definition: ScreenSetup.cpp:230
Session const * session() const
Return const pointer to session.
Definition: ScreenSetup.cpp:57
bool omni::proj::ScreenSetup::noTuningsAssigned ( QScreen const *  _screen) const
86  {
87  if (!session()) return true;
88 
89  for (auto& _tuning : session()->tunings()) {
90  if (_tuning->screen() == _screen) {
91  return false;
92  }
93  }
94  return true;
95  }
std::set< proj::Tuning const * > tunings(bool _excludeNonAssigned) const
Definition: ScreenSetup.cpp:230
Session const * session() const
Return const pointer to session.
Definition: ScreenSetup.cpp:57
bool omni::proj::ScreenSetup::operator== ( const ScreenSetup _rhs) const
254  {
255  return false;
256  }
QScreen const * omni::proj::ScreenSetup::screenFromRect ( QRect const &  _rect)
static

Return pointer to screen for rectangle, nullptr if no screen with.

243  {
244  std::vector<QScreen const *> _screens;
245  auto _allScreens = QGuiApplication::screens();
246 
247  for (auto& _screen : _allScreens) {
248  if (_screen->geometry() == _rect) return _screen;
249  }
250  return nullptr;
251  }
QRect omni::proj::ScreenSetup::screenGeometry ( QScreen const *  _screen = nullptr) const

Returns the screen geometry for a screen If screen is null, the geometry for the virtual screen is returned.

Return geometry of virtual screen

Return geometry of actual screen

110  {
111  /// Return geometry of virtual screen
112  if (!_screen) {
113  return virtualScreenRect();
114  }
115 
116  /// Return geometry of actual screen
117  return _screen->geometry();
118  }
QRect virtualScreenRect() const
Virtual desktop rect contains all non-assigned tunings.
Definition: ScreenSetup.cpp:61
std::vector< QSize > const & omni::proj::ScreenSetup::screenResolutions ( )
static

Returns screen size that supports triple heads.

34  {
35  static std::vector<QSize> _sizes;
36 
37  if (_sizes.empty())
38  _sizes = {
39  QSize(640, 480),
40  QSize(800, 600),
41  QSize(1024, 768),
42  QSize(1280, 720),
43  QSize(1280, 800),
44  QSize(1920, 1080),
45  QSize(1920, 1200),
46  QSize(2560, 1440)
47  };
48 
49  return _sizes;
50  }
std::vector< QScreen const * > omni::proj::ScreenSetup::screens ( bool  _excludeStandardScreen = true)
static

Return vector, optionally excluded standard screen.

191  {
192  std::vector<QScreen const *> _screens;
193  auto _allScreens = QGuiApplication::screens();
194 
195  for (auto& _screen : _allScreens) {
196  if (_screen == standardScreen()) continue;
197 
198  _screens.push_back(_screen);
199  }
200 
201  if (!_excludeStandardScreen) {
202  _screens.push_back(nullptr);
203  }
204  return _screens;
205  }
static QScreen const * standardScreen()
Return standard screen, where omnidome has to be placed.
Definition: ScreenSetup.cpp:52
Session const * omni::proj::ScreenSetup::session ( ) const

Return const pointer to session.

57  {
58  return session_;
59  }
Session const * session_
Definition: ScreenSetup.h:119
QScreen const * omni::proj::ScreenSetup::standardScreen ( )
static

Return standard screen, where omnidome has to be placed.

53  {
54  return QGuiApplication::primaryScreen();
55  }
qreal omni::proj::ScreenSetup::subScreenAspectRatio ( QScreen const *  _screen = nullptr) const

Return aspect ratio of subscreen.

176  {
177  return float(subScreenWidth(_screen)) / float(screenGeometry(_screen).height());
178  }
QRect screenGeometry(QScreen const *=nullptr) const
Returns the screen geometry for a screen If screen is null, the geometry for the virtual screen is r...
Definition: ScreenSetup.cpp:110
int subScreenWidth(QScreen const *=nullptr) const
Returns the number of subscreens for a single screen If screen is nullptr, number of subscreen for v...
Definition: ScreenSetup.cpp:153
int omni::proj::ScreenSetup::subScreenCount ( QScreen const *  _screen = nullptr) const

Returns the number of subscreens for a single screen If screen is nullptr, number of subscreen for virtual screen is returned.

121  {
122  // Return subscreen count for virtual screen,
123  // which is equal to the number of unassigned projectors
124  if (!_screen) {
125  int _numberOfUnassignedProjectors = 0;
126 
127  for (auto& _tuning : session_->tunings()) {
128  if (!_tuning->screen()) ++_numberOfUnassignedProjectors;
129  }
130  return _numberOfUnassignedProjectors;
131  }
132 
133  return subScreenCountForScreen(_screen);
134  }
static int subScreenCountForScreen(QScreen const *)
Static method for getting subscreen count for screen Screen must not be nullptr! ...
Definition: ScreenSetup.cpp:136
Session const * session_
Definition: ScreenSetup.h:119
proj::TuningList & tunings()
Returns reference to projector tunings.
Definition: Session.cpp:55
int omni::proj::ScreenSetup::subScreenCountForScreen ( QScreen const *  _screen)
static

Static method for getting subscreen count for screen Screen must not be nullptr!

136  {
137  // Go through list of screen resolutions and see if the
138  // current screen has subscreens
139  for (auto& _screenSize : screenResolutions())
140  {
141  if (_screenSize.height() == _screen->geometry().height())
142  {
143  if ((_screen->geometry().width() % _screenSize.width()) == 0)
144  {
145  return _screen->geometry().width() / _screenSize.width();
146  }
147  }
148  }
149  return 1;
150 
151  }
static std::vector< QSize > const & screenResolutions()
Returns screen size that supports triple heads.
Definition: ScreenSetup.cpp:33
QRect omni::proj::ScreenSetup::subScreenRect ( int  _index,
QScreen const *  _screen = nullptr 
) const

Returns the rectangle of a subscreen with a certain index.

166  {
167  int _w = subScreenWidth(_screen);
168  return QRect(_w * _subScreenIndex, 0, _w, screenGeometry(_screen).height());
169  }
QRect screenGeometry(QScreen const *=nullptr) const
Returns the screen geometry for a screen If screen is null, the geometry for the virtual screen is r...
Definition: ScreenSetup.cpp:110
int subScreenWidth(QScreen const *=nullptr) const
Returns the number of subscreens for a single screen If screen is nullptr, number of subscreen for v...
Definition: ScreenSetup.cpp:153
QRect omni::proj::ScreenSetup::subScreenRectForScreen ( int  _index,
QScreen const *  _screen 
)
static

Static method for getting subscreen count for screen Screen must not be nullptr!

171  {
172  int _w = subScreenWidthForScreen(_screen);
173  return QRect(_w * _subScreenIndex, 0, _w, _screen->size().height());
174  }
static int subScreenWidthForScreen(QScreen const *)
Static method for getting subscreen width for screen Screen must not be nullptr! ...
Definition: ScreenSetup.cpp:158
int omni::proj::ScreenSetup::subScreenWidth ( QScreen const *  _screen = nullptr) const

Returns the number of subscreens for a single screen If screen is nullptr, number of subscreen for virtual screen is returned.

154  {
155  return screenGeometry(_screen).width() / subScreenCount(_screen);
156  }
int subScreenCount(QScreen const *=nullptr) const
Returns the number of subscreens for a single screen If screen is nullptr, number of subscreen for v...
Definition: ScreenSetup.cpp:120
QRect screenGeometry(QScreen const *=nullptr) const
Returns the screen geometry for a screen If screen is null, the geometry for the virtual screen is r...
Definition: ScreenSetup.cpp:110
int omni::proj::ScreenSetup::subScreenWidthForScreen ( QScreen const *  _screen)
static

Static method for getting subscreen width for screen Screen must not be nullptr!

159  {
160  return _screen->geometry().width() / subScreenCountForScreen(_screen);
161  }
static int subScreenCountForScreen(QScreen const *)
Static method for getting subscreen count for screen Screen must not be nullptr! ...
Definition: ScreenSetup.cpp:136
QRect omni::proj::ScreenSetup::tuningRect ( ) const

Bounding rect that unifies all tunings.

219  {
220  if (!session()) return QRect();
221 
222  QRect _rect;
223 
224  for (auto& _tuning : session()->tunings()) {
225  _rect |= _tuning->contentGeometry().translated(_tuning->screenGeometry().topLeft()) & _tuning->screenGeometry();
226  }
227  return _rect;
228  }
std::set< proj::Tuning const * > tunings(bool _excludeNonAssigned) const
Definition: ScreenSetup.cpp:230
Session const * session() const
Return const pointer to session.
Definition: ScreenSetup.cpp:57
std::set< proj::Tuning const * > omni::proj::ScreenSetup::tunings ( bool  _excludeNonAssigned) const
231  {
232  std::set<proj::Tuning const *> _tunings;
233 
234  for (auto& _tuning : session()->tunings()) {
235  if (!_excludeNonAssigned || _tuning->hasScreen()) {
236  _tunings.insert(_tuning.get());
237  }
238  }
239 
240  return _tunings;
241  }
std::set< proj::Tuning const * > tunings(bool _excludeNonAssigned) const
Definition: ScreenSetup.cpp:230
Session const * session() const
Return const pointer to session.
Definition: ScreenSetup.cpp:57
std::set< QScreen const * > omni::proj::ScreenSetup::usedScreens ( ) const
207  {
208  std::set<QScreen const*> _screens;
209 
210  bool _excludeVirtualScreen = session_->exportSettings().excludeUnassignedProjectors();
211 
212  for (auto& _tuning : session()->tunings()) {
213  if (!_tuning->hasScreen() && _excludeVirtualScreen) continue;
214  _screens.insert(_tuning->screen());
215  }
216  return _screens;
217  }
ExportSettings & exportSettings()
Return reference to export settings.
Definition: Session.cpp:152
std::set< proj::Tuning const * > tunings(bool _excludeNonAssigned) const
Definition: ScreenSetup.cpp:230
Session const * session() const
Return const pointer to session.
Definition: ScreenSetup.cpp:57
Session const * session_
Definition: ScreenSetup.h:119
QRect omni::proj::ScreenSetup::virtualScreenRect ( ) const

Virtual desktop rect contains all non-assigned tunings.

61  {
62  QRect _rect;
63  int _w = standardScreen()->geometry().width();
64  int _h = standardScreen()->geometry().height();
65 
66  for (auto& _tuning : session()->tunings()) {
67  if (_tuning->hasScreen()) continue;
68  _rect |= QRect(_rect.width(), 0,
69  _w, _h);
70  }
71  return _rect.translated(desktopRect().topRight());
72  }
std::set< proj::Tuning const * > tunings(bool _excludeNonAssigned) const
Definition: ScreenSetup.cpp:230
Session const * session() const
Return const pointer to session.
Definition: ScreenSetup.cpp:57
static QScreen const * standardScreen()
Return standard screen, where omnidome has to be placed.
Definition: ScreenSetup.cpp:52
static QRect desktopRect(bool _excludeStandardScreen=true)
Definition: ScreenSetup.cpp:180

Field Documentation

Session const* omni::proj::ScreenSetup::session_
private

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