Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Tuning.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_TUNING_H
21 #define OMNI_UI_PROJ_TUNING_H
22 
23 #include <omni/proj/Tuning.h>
27 #include "proj/TuningLayout.h"
28 
29 namespace omni {
30  class Session;
31 
32  namespace proj {
33  class Tuning;
34  }
35 
36  namespace ui {
37  class TuningGLView;
38 
39  namespace proj {
40  class TitleBar;
41  class TuningLayout;
42 
43  /**@brief Widget for manipulating projector parameters
44  @detail Also holds a preview OpenGL widget
45  **/
46  class Tuning :
47  public ParameterWidget,
48  public mixin::SharedDataModel<Session>,
49  public mixin::TuningFromIndex<Tuning> {
50  Q_OBJECT
52 
53  public:
54  /// View mode (determines which elements are to be displayed)
56  {
57  NO_DISPLAY, // Widget is minimized
58  DISPLAY_ONLY, // Only preview is displayed
59  FOV_SLIDERS, // Only FOV sliders are displayed
60  ADJUSTMENT_SLIDERS, // Only sliders for adjustment are displayed
62  };
63 
65 
66  /// Default constructor
67  Tuning(QWidget *_parent = nullptr);
68 
69  /// Constructs with a given tuning (called by default from TuningList)
70  Tuning(int _index,
71  std::shared_ptr<omni::Session>_session,
72  QWidget *_parent = nullptr);
73 
74  /// Destructor
75  ~Tuning();
76 
77  /// Return pointer to fullscreen widget
79 
80  /// Return pointer to fullscreen widget (const version)
81  TuningGLView const* fullscreenWidget() const;
82 
83  /// Return pointer to preview widget
85 
86  /// Return pointer to preview widget (const version)
87  TuningGLView const* previewWidget() const;
88 
89  /// Return selected flag
90  bool isSelected() const;
91 
92  /// Return current window state
93  WindowState windowState() const;
94 
95  public slots:
96  /// Sets Window State which determines which elements are visible
97  void setWindowState(WindowState _mode);
98 
99  /// Selects succeeding window state
100  void setNextWindowState();
101 
102  /**@brief Sets flag if Tuning Widget is active
103  @detail A tuning widget should only be active when
104  **/
105  void setSelected(bool);
106 
107  /// Display content and widget for specific session mode
108  void sessionModeChange();
109 
110  /// Attaches a screen to this tuning
111  void attachScreen(QScreen const *_screen,
112  int _subScreenIndex);
113 
114  /**@brief Detaches screen from this tuning
115  @detail Also triggered when QGuiApplication::screenAdded or
116  QGuiApplication::screenRemoved were fired
117  **/
118  void detachScreen();
119 
120  /// Update GL View and Fullscreen view, if there is any
121  void updateViews();
122 
123  /// Enable or disable fullscreen display
124  void fullscreenToggle(bool);
125 
126  /// Reset to free projector setup (discards previous projector setup)
127  void resetToFreeSetup();
128 
129  /// Reset to peripheral projector setup (discards previous projector
130  // setup)
131  void resetToPeripheralSetup();
132 
133  signals:
134  void selected(int);
135  void closed(int);
136  void projectorSetupChanged();
137  void dataModelChanged();
138 
139  protected:
140  /// Handles resizing of sliders and preview
141  void resizeEvent(QResizeEvent *);
142 
143  /// Handles proper resizing of the widget
144  void showEvent(QShowEvent *);
145 
146  /// Paint border
147  void paintEvent(QPaintEvent *);
148 
149  /// Mouse Move Event and handler for dragging to ScreenSetup widget
150  void mouseMoveEvent(QMouseEvent *);
151 
152  /// Handles focus events from child widgets
153  bool eventFilter(QObject *,
154  QEvent *);
155 
156  /// Focus in event used by TuningList to set current tuning for
157  // session
158  void focusInEvent(QFocusEvent *);
159 
160  /// Focus out for deselecting tuning
161  void focusOutEvent(QFocusEvent *);
162 
163  private slots:
164  void startDrag();
165 
166  /// Set parameters from sliders to tuning
167  void updateParameters();
168 
169  /// Set FOV to projector from slider
170  void setFov();
171 
172  /// Set Throw Ratio to projector from slider
173  void setThrowRatio();
174 
175  /// Set keystone correction from slider
176  void setKeyStone();
177 
178  /// Update slider and border color
179  void updateColor();
180 
181  /// Clean up.
182  void prepareRemove();
183 
184  private:
185  void dataToFrontend();
186  bool frontendToData();
187 
188  /// Setup (only called in constructor)
189  void setup();
190 
191  /// Id of first focussed widget
192  inline virtual int firstFocusId() const {
193  return std::min(layout()->count()-1,2); // Title bar and view cannot be focussed
194  }
195 
196  /// Adds a new/changes a parameter group
197  void addGroup(QString const& _groupName,
198  widgetgroup_type const& _widgets);
199 
200  void setGroup(QString const& _groupName);
201 
202  /// Title bar widget
203  QUniquePtr<TitleBar> titleBar_;
204 
205  /// GL preview widget
206  QUniquePtr<TuningGLView> glView_;
207 
208  // Fullscreen GL widget
209  QUniquePtr<TuningGLView> fullscreen_;
210 
211  /// Window State
213 
214  /// Is true when this widgets index and current tuning index are equal
215  bool isSelected_ = true;
216 
217  /// Layout
218  TuningLayout *layout_ = nullptr;
219 
220  std::map<QString, widgetgroup_type> groups_;
221  };
222  }
223  }
224 }
225 
226 #endif /* OMNI_UI_PROJ_TUNING_H */
bool frontendToData()
Return true if data has changed by front end.
Definition: Tuning.cpp:117
~Tuning()
Destructor.
Definition: Tuning.cpp:64
void detachScreen()
Detaches screen from this tuning Also triggered when QGuiApplication::screenAdded or QGuiApplication...
Definition: Tuning.cpp:253
QUniquePtr< TuningGLView > glView_
GL preview widget.
Definition: Tuning.h:206
A session consists of a canvas, a mapping, a list of tunings and one or several inputs.
Definition: Session.h:41
void showEvent(QShowEvent *)
Handles proper resizing of the widget.
Definition: Tuning.cpp:597
#define OMNI_UI_SHARED_DATAMODEL(MODEL)
Definition: DataModel.h:216
void resetToFreeSetup()
Reset to free projector setup (discards previous projector setup)
Definition: Tuning.cpp:152
Tuning(QWidget *_parent=nullptr)
Default constructor.
Definition: Tuning.cpp:56
void sessionModeChange()
Display content and widget for specific session mode.
Definition: Tuning.cpp:530
void updateColor()
Update slider and border color.
Definition: Tuning.cpp:512
void setSelected(bool)
Sets flag if Tuning Widget is active A tuning widget should only be active when. ...
Definition: Tuning.cpp:503
void addGroup(QString const &_groupName, widgetgroup_type const &_widgets)
Adds a new/changes a parameter group.
Definition: Tuning.cpp:433
void dataToFrontend()
Pure virtual method which determines how data model is represented in frontend.
Definition: Tuning.cpp:68
void updateViews()
Update GL View and Fullscreen view, if there is any.
Definition: Tuning.cpp:260
void prepareRemove()
Clean up.
Definition: Tuning.cpp:525
void paintEvent(QPaintEvent *)
Paint border.
Definition: Tuning.cpp:600
void setKeyStone()
Set keystone correction from slider.
Definition: Tuning.cpp:237
std::vector< std::pair< QWidget *, Role > > widgetgroup_type
Definition: TuningLayout.h:46
Definition: Tuning.h:57
bool eventFilter(QObject *, QEvent *)
Handles focus events from child widgets.
Definition: Tuning.cpp:665
WindowState windowState_
Window State.
Definition: Tuning.h:212
void setThrowRatio()
Set Throw Ratio to projector from slider.
Definition: Tuning.cpp:226
void setNextWindowState()
Selects succeeding window state.
Definition: Tuning.cpp:474
void focusInEvent(QFocusEvent *)
Focus in event used by TuningList to set current tuning for.
Definition: Tuning.cpp:690
TuningLayout::widgetgroup_type widgetgroup_type
Definition: Tuning.h:64
void resetToPeripheralSetup()
Reset to peripheral projector setup (discards previous projector.
Definition: Tuning.cpp:161
void resizeEvent(QResizeEvent *)
Handles resizing of sliders and preview.
Definition: Tuning.cpp:590
TuningGLView * fullscreenWidget()
Return pointer to fullscreen widget.
Definition: Tuning.cpp:121
void mouseMoveEvent(QMouseEvent *)
Mouse Move Event and handler for dragging to ScreenSetup widget.
Definition: Tuning.cpp:625
void focusOutEvent(QFocusEvent *)
Focus out for deselecting tuning.
Definition: Tuning.cpp:696
Tuning Layout Similar to VBoxLayout, except that widgets with a PREVIEW Role have a size with aspect...
Definition: TuningLayout.h:35
void setFov()
Set FOV to projector from slider.
Definition: Tuning.cpp:213
A widget which holds sub-widgets for manipulating parameters.
Definition: ParameterWidget.h:37
TuningGLView * previewWidget()
Return pointer to preview widget.
Definition: Tuning.cpp:131
WindowState windowState() const
Return current window state.
Definition: Tuning.cpp:463
void fullscreenToggle(bool)
Enable or disable fullscreen display.
Definition: Tuning.cpp:142
void attachScreen(QScreen const *_screen, int _subScreenIndex)
Attaches a screen to this tuning.
Definition: Tuning.cpp:246
Holds a specific data model with frontend update mechanism.
Definition: DataModel.h:87
Definition: TuningFromIndex.h:30
bool isSelected() const
Return selected flag.
Definition: Tuning.cpp:684
QUniquePtr< TitleBar > titleBar_
Title bar widget.
Definition: Tuning.h:203
void updateParameters()
Set parameters from sliders to tuning.
Definition: Tuning.cpp:169
Widget for manipulating projector parameters Also holds a preview OpenGL widget. ...
Definition: Tuning.h:46
std::map< QString, widgetgroup_type > groups_
Definition: Tuning.h:220
void startDrag()
Definition: Tuning.cpp:634
bool isSelected_
Is true when this widgets index and current tuning index are equal.
Definition: Tuning.h:215
WindowState
View mode (determines which elements are to be displayed)
Definition: Tuning.h:55
TuningLayout * layout_
Layout.
Definition: Tuning.h:218
A GLView for visualizing all modes of a projector view (tuning)
Definition: TuningGLView.h:34
void setGroup(QString const &_groupName)
Definition: Tuning.cpp:442
QUniquePtr< TuningGLView > fullscreen_
Definition: Tuning.h:209
void setWindowState(WindowState _mode)
Sets Window State which determines which elements are visible.
Definition: Tuning.cpp:468
virtual int firstFocusId() const
Id of first focussed widget.
Definition: Tuning.h:192
void setup()
Setup (only called in constructor)
Definition: Tuning.cpp:270