Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TuningLayout.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_UI_PROJ_TUNINGLAYOUT_H_
21 #define OMNI_UI_PROJ_TUNINGLAYOUT_H_
22 
23 #include <QLayout>
24 #include <omni/proj/Tuning.h>
25 
26 namespace omni {
27  namespace ui {
28  namespace proj {
29  class Tuning;
30 
31  /**@brief Tuning Layout
32  * @detail Similar to VBoxLayout, except that widgets with a PREVIEW Role
33  * have a size with aspect ratio of associated tuning
34  **/
35  class TuningLayout : public QLayout {
36  Q_OBJECT
37 
38  public:
39  /// Role of a widget defines resize behaviour
40  enum class Role {
41  TITLE, // Fixed size
42  PARAMETER, // Fixed size
43  PREVIEW // Size with aspect ratio of tuning
44  };
45 
46  typedef std::vector<std::pair<QWidget *, Role> >widgetgroup_type;
47 
48  TuningLayout(Tuning *parent);
49  ~TuningLayout();
50 
51  /// Add item, with PARAMETER Role
52  void addItem(QLayoutItem *item);
53 
54  /// Add widget with PARAMETER Role
55  void addWidget(QWidget *widget);
56 
57  /// Add widget with Role
58  void addWidget(QWidget * widget, Role);
59 
60  /// Return number of widgets
61  int count() const;
62 
63  /// Get index of given widget
64  int indexOf(QWidget *widget) const;
65 
66  /// Return item at index
67  QLayoutItem * itemAt(int index) const;
68 
69  /// Remove widget at index
70  QLayoutItem * takeAt(int index);
71 
72  /// Set geometry of all widgets
73  void setGeometry(const QRect& rect);
74 
75  QRect geometry() const;
76 
77  /// Clears layout and inserts the given widgets
78  void setWidgets(widgetgroup_type const& _widgets);
79 
80  /// Clear layout
81  void clear();
82 
83  /// Return minimum size
84  QSize minimumSize() const;
85 
86  /// Return size hint, is equal to minimum size
87  QSize sizeHint() const;
88 
89  private:
91  omni::proj::Tuning const* tuning() const;
92 
93  struct ItemWrapper
94  {
95  ItemWrapper(QLayoutItem *_item = nullptr,
96  Role _role = Role::PARAMETER) :
97  item_(_item),
98  role_(_role)
99  {}
100 
101  QLayoutItem *item_;
103 
104  QWidget* widget() const
105  {
106  return item_->widget();
107  }
108  };
109 
110  /// Add a layout item with Role
111  void add(QLayoutItem *_item,
112  Role _role);
113 
115  QSize calculateSize(SizeType sizeType) const;
116 
117  std::vector<ItemWrapper> items_;
118  };
119  }
120  }
121 }
122 
123 #endif /* OMNI_UI_PROJ_TUNINGLAYOUT_H_ */
int indexOf(QWidget *widget) const
Get index of given widget.
Definition: TuningLayout.cpp:57
void addWidget(QWidget *widget)
Add widget with PARAMETER Role.
Definition: TuningLayout.cpp:42
std::vector< ItemWrapper > items_
Definition: TuningLayout.h:117
QWidget * widget() const
Definition: TuningLayout.h:104
void add(QLayoutItem *_item, Role _role)
Add a layout item with Role.
Definition: TuningLayout.cpp:197
QLayoutItem * itemAt(int index) const
Return item at index.
Definition: TuningLayout.cpp:70
QSize minimumSize() const
Return minimum size.
Definition: TuningLayout.cpp:153
A projector tuning holds adjustment and distorsion data for a single projector and screen A tuning c...
Definition: Tuning.h:52
omni::proj::Tuning * tuning()
Definition: TuningLayout.cpp:123
Definition: TuningLayout.h:114
std::vector< std::pair< QWidget *, Role > > widgetgroup_type
Definition: TuningLayout.h:46
QRect geometry() const
Definition: TuningLayout.cpp:190
void setWidgets(widgetgroup_type const &_widgets)
Clears layout and inserts the given widgets.
Definition: TuningLayout.cpp:133
QSize sizeHint() const
Return size hint, is equal to minimum size.
Definition: TuningLayout.cpp:158
QLayoutItem * takeAt(int index)
Remove widget at index.
Definition: TuningLayout.cpp:76
QLayoutItem * item_
Definition: TuningLayout.h:101
SizeType
Definition: TuningLayout.h:114
Tuning Layout Similar to VBoxLayout, except that widgets with a PREVIEW Role have a size with aspect...
Definition: TuningLayout.h:35
TuningLayout(Tuning *parent)
Definition: TuningLayout.cpp:28
void addItem(QLayoutItem *item)
Add item, with PARAMETER Role.
Definition: TuningLayout.cpp:37
QSize calculateSize(SizeType sizeType) const
Definition: TuningLayout.cpp:88
void setGeometry(const QRect &rect)
Set geometry of all widgets.
Definition: TuningLayout.cpp:163
ItemWrapper(QLayoutItem *_item=nullptr, Role _role=Role::PARAMETER)
Definition: TuningLayout.h:95
Widget for manipulating projector parameters Also holds a preview OpenGL widget. ...
Definition: Tuning.h:46
Definition: TuningLayout.h:114
void clear()
Clear layout.
Definition: TuningLayout.cpp:146
~TuningLayout()
Definition: TuningLayout.cpp:32
Definition: TuningLayout.h:93
int count() const
Return number of widgets.
Definition: TuningLayout.cpp:52
Role
Role of a widget defines resize behaviour.
Definition: TuningLayout.h:40
Role role_
Definition: TuningLayout.h:102