Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Interface.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_CANVAS_INTERFACE_H_
21 #define OMNI_CANVAS_INTERFACE_H_
22 
23 #include <set>
24 #include <QMatrix4x4>
25 #include <omni/PluginInfo.h>
26 #include <omni/geometry/Box.h>
29 #include <omni/mapping/Interface.h>
30 #include <omni/visual/Interface.h>
31 
32 namespace omni {
33  namespace ui {
34  class CanvasParameters;
35  }
36  namespace visual {
37  class Scene;
38  }
39 
40  namespace canvas {
41  /**@brief Abstract interface for a canvas
42  * @detail A canvas represents the surface on which the projection is
43  *performed.
44  * It might be a dome or a planar surface.
45  **/
46  class Interface :
47  public TypeIdInterface,
48  public PropertyMapSerializer,
49  public visual::Interface {
50  public:
51  Interface();
52 
53  /// Virtual destructor
54  virtual ~Interface();
55 
56  enum class ViewMode {
57  INSIDE,
58  OUTSIDE,
59  BOTH
60  };
61 
62  /// Return current view mode
63  ViewMode viewMode() const;
64 
65  /// Set view mode
66  void setViewMode(ViewMode _viewMode);
67 
68  /// Draws with culled front or back faces, depending on view mode
69  void drawWithViewMode() const;
70 
71  /// Draws auxiliary elements which are not used for mapping (e.g.
72  // positioning grids)
73  inline virtual void drawAux() const
74  {}
75 
76  /// Abstract method for returning bounding box of canvas
77  virtual Box bounds() const = 0;
78 
79  /// Spectator's center of canvas (center of bounding box by default)
80  virtual QVector3D center() const;
81 
82  /// Canvas radius (is half of size by default)
83  virtual qreal radius() const;
84 
85  /// Return const ref to affine transform
86  AffineTransform const& transform() const;
87 
88  /// Return ref to affine transform
89  AffineTransform & transform();
90 
91  /// Set new affine transform
92  void setTransform(AffineTransform const& _transform);
93 
94  /// The scene this canvas belongs to
95  visual::Scene const* scene() const;
96 
97  /**@brief Set the scene this canvas belongs to.
98  @detail Is set automatically when a canvas is added to a session
99  **/
100  void setScene(visual::Scene const*);
101 
102  /// Transformation matrix for canvas
103  virtual QMatrix4x4 matrix() const;
104 
105  /// Returns pointer to new parameter widget
106  virtual ui::CanvasParameters* widget() = 0;
107 
108  /// Write mapping to stream
109  virtual void toPropertyMap(PropertyMap&) const;
110 
111  /// Read mapping from stream
112  virtual void fromPropertyMap(PropertyMap const&);
113 
114  protected:
115  bool needsUpdate_ = true;
116 
117  private:
118  AffineTransform transform_;
120  visual::Scene const* scene_ = nullptr;
121  };
122 
123  /// Our canvas factory
125  }
126 
129 }
130 
131 #define OMNI_CANVAS_INTERFACE_IID "org.omnidome.canvas.Interface"
132 
134 
135 #define OMNI_CANVAS_PLUGIN_DECL \
136  Q_OBJECT \
137  Q_PLUGIN_METADATA(IID OMNI_CANVAS_INTERFACE_IID) \
138  Q_INTERFACES(omni::canvas::Interface) \
139  OMNI_PLUGIN_TYPE("Canvas")
140 
141 #endif /* OMNI_CANVAS_INTERFACE_H_ */
ViewMode viewMode_
Definition: Interface.h:119
ViewMode viewMode() const
Return current view mode.
Definition: Interface.cpp:80
canvas::Factory CanvasFactory
Definition: Interface.h:128
Interface()
Definition: Interface.cpp:28
virtual QVector3D center() const
Spectator's center of canvas (center of bounding box by default)
Definition: Interface.cpp:37
virtual ~Interface()
Virtual destructor.
Definition: Interface.cpp:34
visual::Scene const * scene() const
The scene this canvas belongs to.
Definition: Interface.cpp:93
void setScene(visual::Scene const *)
Set the scene this canvas belongs to. Is set automatically when a canvas is added to a session...
Definition: Interface.cpp:89
Basic visual interface.
Definition: Interface.h:28
void setViewMode(ViewMode _viewMode)
Set view mode.
Definition: Interface.cpp:84
Abstract interface for a canvas A canvas represents the surface on which the projection is performed...
Definition: Interface.h:46
virtual void fromPropertyMap(PropertyMap const &)
Read mapping from stream.
Definition: Interface.cpp:108
void drawWithViewMode() const
Draws with culled front or back faces, depending on view mode.
Definition: Interface.cpp:42
A class that holds settings and elements for session 3d visualization Belongs to a session...
Definition: Scene.h:63
virtual Box bounds() const =0
Abstract method for returning bounding box of canvas.
visual::Scene const * scene_
Definition: Interface.h:120
canvas::Interface Canvas
Definition: Interface.h:127
AbstractFactory< Interface > Factory
Our canvas factory.
Definition: Interface.h:124
virtual void drawAux() const
Draws auxiliary elements which are not used for mapping (e.g.
Definition: Interface.h:73
virtual void toPropertyMap(PropertyMap &) const
Write mapping to stream.
Definition: Interface.cpp:103
virtual ui::CanvasParameters * widget()=0
Returns pointer to new parameter widget.
Abstract Interface with a single virtual member function which returns.
Definition: TypeIdInterface.h:28
virtual qreal radius() const
Canvas radius (is half of size by default)
Definition: Interface.cpp:63
AffineTransform const & transform() const
Return const ref to affine transform.
Definition: Interface.cpp:68
bool needsUpdate_
Definition: Interface.h:115
virtual QMatrix4x4 matrix() const
Transformation matrix for canvas.
Definition: Interface.cpp:98
ViewMode
Definition: Interface.h:56
AffineTransform transform_
Definition: Interface.h:118
Parameter widget for getting and setting canvas parameters.
Definition: CanvasParameters.h:32
The central factory class.
Definition: factory.hpp:38
void setTransform(AffineTransform const &_transform)
Set new affine transform.
Definition: Interface.cpp:76
#define OMNI_CANVAS_INTERFACE_IID
Definition: Interface.h:131