Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TuningList.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_TUNINGLIST_H
21 #define OMNI_UI_PROJ_TUNINGLIST_H
22 
23 #include <memory>
24 #include <QScrollArea>
25 #include <omni/util.h>
26 #include <omni/Session.h>
28 #include "proj/Tuning.h"
29 
30 namespace omni
31 {
32  class Session;
33 
34  namespace ui
35  {
36  namespace proj
37  {
38  class Tuning;
39 
40  class TuningList :
41  public QScrollArea,
42  public mixin::SharedDataModel<Session>
43  {
44  Q_OBJECT
46  public:
47  TuningList(QWidget* = nullptr);
48  ~TuningList();
49 
50  /// Return fullscreen and preview widget from index
51  std::set<TuningGLView*> getViews(int _index) const;
52 
53  /// Return tuning widget at index, nullptr if index is not valid
54  Tuning* widget(int _index);
55 
56  /// Return tuning widget at index, nullptr if index is not valid (const)
57  Tuning const* widget(int _index) const;
58 
60 
61  public slots:
62  /// Change current mode for all tuning widgets
63  void sessionModeChange();
64 
65  /// Add a new tuning and tuning widget, with automatically detected settings
66  void addTuning();
67 
68  /// Add tuning with specific projector setup
69  void addTuning(QString const& _projSetupId);
70 
71  /// Remove tuning
72  void removeTuning(int _index);
73 
74  /// Set current tuning from currently selected widget
75  void setCurrentTuning();
76 
77  /// Set current tuning index manually (currentIndexChanged signal is emitted)
78  void setTuningIndex(int);
79 
80  /// Remove all tunings from session and all associated widgets
81  void clear();
82 
83  /// Updates/Repaints GL Views of all tunings widgets
84  void updateViews();
85 
86  /// Adjust sliders to scene scale
87  void updateSceneSize(bool _rescaleValues);
88 
89  /// Set unit of sliders
90  void updateUnits();
91 
92  /// Disable all tunings and fullscreen
93  void disableAllTunings();
94 
95  /// Enable all tunings and fullscreen
96  void enableAllTunings();
97 
98  /// Enable selected tuning and show only this in fullscreen
100 
101  protected:
102  void resizeEvent(QResizeEvent*);
103  void keyPressEvent(QKeyEvent*);
104  bool eventFilter(QObject *obj, QEvent *event);
105 
106  signals:
107  /// Signal which is emitted when the current tuning has changed
108  void currentIndexChanged(int);
109 
110  /// Signal which is emitted when parameters of one tuning have changed
111  void dataModelChanged();
112 
113  /// Signal is emitted when a tuning was added
114  void tuningAdded();
115 
116  /// Signal is emitted when a tuning was removed
117  void tuningRemoved();
118 
119  /// Emitted when a single tuning has changed
120  void tuningChanged();
121 
122  private:
123  /// Update sliders from current session
124  void dataToFrontend();
125 
126  /// Assign slider values to current session
127  inline bool frontendToData() {
128  return false;
129  }
130 
131  /// Add widget from existing tuning
132  void addTuning(omni::proj::Tuning* _tuning);
133 
134  /**@brief Removes all widgets in the scroll area
135  *@detail Unlike clear() it does not remove tunings from session
136  **/
137  void removeWidgets();
138 
139  /// Get most differing color for a new tuning
140  QColor getTuningColor();
141 
142  QWidget* contents_;
143  QLayout* layout_;
144 
145  std::vector<QUniquePtr<Tuning>> widgets_;
146  };
147  }
148  }
149 }
150 
151 #endif /* OMNI_UI_PROJ_TUNINGLIST_H */
void dataModelChanged()
Signal which is emitted when parameters of one tuning have changed.
void removeTuning(int _index)
Remove tuning.
Definition: TuningList.cpp:236
Definition: TuningList.h:40
A session consists of a canvas, a mapping, a list of tunings and one or several inputs.
Definition: Session.h:41
QWidget * contents_
Definition: TuningList.h:142
Tuning * widgetFromTuning(omni::proj::Tuning *)
Definition: TuningList.cpp:72
#define OMNI_UI_SHARED_DATAMODEL(MODEL)
Definition: DataModel.h:216
void updateSceneSize(bool _rescaleValues)
Adjust sliders to scene scale.
Definition: TuningList.cpp:300
void enableAllTunings()
Enable all tunings and fullscreen.
Definition: TuningList.cpp:325
A projector tuning holds adjustment and distorsion data for a single projector and screen A tuning c...
Definition: Tuning.h:52
bool eventFilter(QObject *obj, QEvent *event)
Definition: TuningList.cpp:369
void removeWidgets()
Removes all widgets in the scroll area Unlike clear() it does not remove tunings from session...
Definition: TuningList.cpp:283
void clear()
Remove all tunings from session and all associated widgets.
Definition: TuningList.cpp:275
QColor getTuningColor()
Get most differing color for a new tuning.
Definition: TuningList.cpp:179
std::set< TuningGLView * > getViews(int _index) const
Return fullscreen and preview widget from index.
Definition: TuningList.cpp:89
void tuningAdded()
Signal is emitted when a tuning was added.
void keyPressEvent(QKeyEvent *)
Definition: TuningList.cpp:345
void currentIndexChanged(int)
Signal which is emitted when the current tuning has changed.
TuningList(QWidget *=nullptr)
Definition: TuningList.cpp:37
void sessionModeChange()
Change current mode for all tuning widgets.
Definition: TuningList.cpp:260
void enableSelectedTuningOnly()
Enable selected tuning and show only this in fullscreen.
Definition: TuningList.cpp:332
void addTuning()
Add a new tuning and tuning widget, with automatically detected settings.
Definition: TuningList.cpp:102
void disableAllTunings()
Disable all tunings and fullscreen.
Definition: TuningList.cpp:318
void setTuningIndex(int)
Set current tuning index manually (currentIndexChanged signal is emitted)
Definition: TuningList.cpp:395
void resizeEvent(QResizeEvent *)
Definition: TuningList.cpp:338
void setCurrentTuning()
Set current tuning from currently selected widget.
Definition: TuningList.cpp:377
Holds a specific data model with frontend update mechanism.
Definition: DataModel.h:87
QLayout * layout_
Definition: TuningList.h:143
void updateUnits()
Set unit of sliders.
Definition: TuningList.cpp:309
Widget for manipulating projector parameters Also holds a preview OpenGL widget. ...
Definition: Tuning.h:46
Tuning * widget(int _index)
Return tuning widget at index, nullptr if index is not valid.
Definition: TuningList.cpp:62
std::vector< QUniquePtr< Tuning > > widgets_
Definition: TuningList.h:145
void tuningChanged()
Emitted when a single tuning has changed.
void updateViews()
Updates/Repaints GL Views of all tunings widgets.
Definition: TuningList.cpp:294
bool frontendToData()
Assign slider values to current session.
Definition: TuningList.h:127
void dataToFrontend()
Update sliders from current session.
Definition: TuningList.cpp:79
void tuningRemoved()
Signal is emitted when a tuning was removed.
~TuningList()
Definition: TuningList.cpp:58