Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Private Attributes
omni::ui::mixin::TransformedRect< WIDGET > Class Template Referenceabstract

Mixin which calculates transformed screen rectangles Used in export output preview and screen setup widgets. More...

#include <TransformedRect.h>

Public Types

typedef WIDGET widget_type
 

Public Member Functions

 TransformedRect (widget_type *_widget)
 
virtual QRect desktopRect () const =0
 Pure virtual method which returns overall desktop rect. More...
 
float scalingFactor () const
 Returns the scaling factor which is needed so that desktopRect_. More...
 
QRectF transformedRect () const
 Returns transformed bounding rect which fits into window and keeps. More...
 
QRectF transformedRect (QRectF const &_rect) const
 Returns Transformed copy of the rect, based on transformed desktop. More...
 
float zoom () const
 Return zoom factor. More...
 
void setZoom (float _zoom)
 Set zoom factor. More...
 

Private Attributes

widget_typewidget_ = nullptr
 
float zoom_ = 0.9
 

Detailed Description

template<typename WIDGET>
class omni::ui::mixin::TransformedRect< WIDGET >

Mixin which calculates transformed screen rectangles Used in export output preview and screen setup widgets.

Member Typedef Documentation

template<typename WIDGET>
typedef WIDGET omni::ui::mixin::TransformedRect< WIDGET >::widget_type

Constructor & Destructor Documentation

template<typename WIDGET>
omni::ui::mixin::TransformedRect< WIDGET >::TransformedRect ( widget_type _widget)
inline
36 : widget_(_widget) {}
widget_type * widget_
Definition: TransformedRect.h:117

Member Function Documentation

template<typename WIDGET>
virtual QRect omni::ui::mixin::TransformedRect< WIDGET >::desktopRect ( ) const
pure virtual

Pure virtual method which returns overall desktop rect.

Implemented in omni::ui::ScreenSetup, and omni::ui::OutputPreview.

template<typename WIDGET>
float omni::ui::mixin::TransformedRect< WIDGET >::scalingFactor ( ) const
inline

Returns the scaling factor which is needed so that desktopRect_.

44  {
45  if (!widget_) return 0.0;
46 
47  auto _windowRect = widget_->rect();
48 
49  if ((_windowRect.height() == 0) ||
50  (_windowRect.width() == 0)) return 0.0;
51 
52  QRect _desktopRect = this->desktopRect();
53 
54  if ((_desktopRect.height() == 0) ||
55  (_desktopRect.width() == 0)) return 0.0;
56 
57  float _rectAspect = float(_desktopRect.width()) /
58  float(_desktopRect.height());
59  float _windowAspect = float(_windowRect.width()) /
60  float(_windowRect.height());
61 
62  float _factor = 1.0f;
63 
64  if (_windowAspect < _rectAspect) {
65  _factor = float(_windowRect.width()) / _desktopRect.width();
66  } else {
67  _factor = float(_windowRect.height()) / _desktopRect.height();
68  }
69 
70  return _factor * zoom();
71  }
virtual QRect desktopRect() const =0
Pure virtual method which returns overall desktop rect.
float zoom() const
Return zoom factor.
Definition: TransformedRect.h:105
widget_type * widget_
Definition: TransformedRect.h:117
template<typename WIDGET>
void omni::ui::mixin::TransformedRect< WIDGET >::setZoom ( float  _zoom)
inline

Set zoom factor.

111  {
112  zoom_ = _zoom;
113  widget_->update();
114  }
float zoom_
Definition: TransformedRect.h:118
widget_type * widget_
Definition: TransformedRect.h:117
template<typename WIDGET>
QRectF omni::ui::mixin::TransformedRect< WIDGET >::transformedRect ( ) const
inline

Returns transformed bounding rect which fits into window and keeps.

76  {
77  auto _windowRect = widget_->rect();
78  auto _zoom = scalingFactor();
79  QRect _desktopRect = this->desktopRect();
80 
81  return QRectF(
82  0.5 * (_windowRect.width() - _zoom * (_desktopRect.width())),
83  0.5 * (_windowRect.height() - _zoom * (_desktopRect.height())),
84  _zoom * _desktopRect.width(),
85  _zoom * _desktopRect.height());
86  }
virtual QRect desktopRect() const =0
Pure virtual method which returns overall desktop rect.
float scalingFactor() const
Returns the scaling factor which is needed so that desktopRect_.
Definition: TransformedRect.h:43
widget_type * widget_
Definition: TransformedRect.h:117
template<typename WIDGET>
QRectF omni::ui::mixin::TransformedRect< WIDGET >::transformedRect ( QRectF const &  _rect) const
inline

Returns Transformed copy of the rect, based on transformed desktop.

Transformed desktop rect

91  {
92  auto _zoom = scalingFactor();
93 
94  /// Transformed desktop rect
95  auto _desktopRect = transformedRect();
96 
97  return QRectF(
98  _desktopRect.x() + _rect.x() * _zoom,
99  _desktopRect.y() + _rect.y() * _zoom,
100  _rect.width() * _zoom,
101  _rect.height() * _zoom);
102  }
QRectF transformedRect() const
Returns transformed bounding rect which fits into window and keeps.
Definition: TransformedRect.h:75
float scalingFactor() const
Returns the scaling factor which is needed so that desktopRect_.
Definition: TransformedRect.h:43
template<typename WIDGET>
float omni::ui::mixin::TransformedRect< WIDGET >::zoom ( ) const
inline

Return zoom factor.

105  {
106  return zoom_;
107  }
float zoom_
Definition: TransformedRect.h:118

Field Documentation

template<typename WIDGET>
widget_type* omni::ui::mixin::TransformedRect< WIDGET >::widget_ = nullptr
private
template<typename WIDGET>
float omni::ui::mixin::TransformedRect< WIDGET >::zoom_ = 0.9
private

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