Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
InputPreview.h
Go to the documentation of this file.
1 /* Copyright (c) 2014-2016 "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_INPUTPREVIEW_H_
21 #define OMNI_UI_INPUTPREVIEW_H_
22 
23 #include <QOpenGLShaderProgram>
24 #include <omni/input/Interface.h>
25 #include <omni/ui/GLView.h>
26 
27 namespace omni
28 {
29  namespace ui
30  {
31  /// GLView for visualizing an input
32  class InputPreview : public GLView
33  {
34  Q_OBJECT
35  public:
36  InputPreview(QWidget* = nullptr);
37  InputPreview(input::Interface* _input, QWidget* = nullptr);
38  ~InputPreview();
39 
40  /// Return relative border value
41  float border() const;
42 
43  /// Return pointer to input
45 
46  /// Return pointer to input (const version)
47  input::Interface const* input() const;
48 
49  /// Set pointer to input
51 
52  /**@brief Transforms mouse position on widget to normalized position on input
53  * @detail Position in range (0.0,0.0) and (1.0,1.0)
54  **/
55  QPointF screenPos(QPointF const& _pos) const;
56 
57  public slots:
58  /// Set relative border distance
59  void setBorder(float);
60 
61  protected:
62  void paintGL();
63  void showEvent(QShowEvent*);
64  signals:
65  void inputChanged();
66 
67  private:
68  /// Return view rect
69  QRectF viewRect() const;
70 
71  bool initialize();
72 
73  /// Relative border
74  float border_ = 0.0;
75 
76  std::unique_ptr<QOpenGLShaderProgram> shader_;
78  };
79  }
80 }
81 
82 #endif /* OMNI_UI_INPUTPREVIEW_H_ */
void showEvent(QShowEvent *)
Definition: InputPreview.cpp:63
float border_
Relative border.
Definition: InputPreview.h:74
input::Interface * input_
Definition: InputPreview.h:77
InputPreview(QWidget *=nullptr)
Definition: InputPreview.cpp:31
bool initialize()
Pure virtual function to initialize GL contents.
Definition: InputPreview.cpp:81
float border() const
Return relative border value.
Definition: InputPreview.cpp:47
QRectF viewRect() const
Return view rect.
Definition: InputPreview.cpp:87
Generic input interface.
Definition: Interface.h:53
std::unique_ptr< QOpenGLShaderProgram > shader_
Definition: InputPreview.h:76
void setInput(input::Interface *)
Set pointer to input.
Definition: InputPreview.cpp:76
GLView for visualizing an input.
Definition: InputPreview.h:32
QPointF screenPos(QPointF const &_pos) const
Transforms mouse position on widget to normalized position on input Position in range (0...
Definition: InputPreview.cpp:95
GLView for visualizing tunings or session Holds shared_ptr to session as data model.
Definition: GLView.h:35
void setBorder(float)
Set relative border distance.
Definition: InputPreview.cpp:52
input::Interface * input()
Return pointer to input.
Definition: InputPreview.cpp:58
~InputPreview()
Definition: InputPreview.cpp:44
void paintGL()
Paint GL routine.
Definition: InputPreview.cpp:102