Gem Illuminator
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
painterqml.h
Go to the documentation of this file.
1 #ifndef PAINTERQML_H
2 #define PAINTERQML_H
3 
4 #include <QQuickItem>
5 
6 class QTime;
7 
8 class LightRay;
9 class Painter;
10 class Scene;
11 
18 class PainterQML : public QQuickItem
19 {
20  Q_OBJECT
21  Q_PROPERTY(bool isActive READ isActive NOTIFY isActiveChanged)
22  Q_PROPERTY(bool isAppActive READ isAppActive WRITE setIsAppActive NOTIFY isAppActiveChanged)
23  Q_PROPERTY(bool isGameActive READ isGameActive WRITE setIsGameActive NOTIFY isGameActiveChanged)
24  Q_PROPERTY(Scene* scene READ scene WRITE setScene NOTIFY sceneChanged)
25 public:
26  explicit PainterQML(QQuickItem *parent = 0);
27  virtual ~PainterQML();
28 
34  bool event(QEvent *ev) override;
35 
43  bool isGameActive() const;
48  void setIsGameActive(bool active);
49 
54  QEvent::Type paintingDoneEventType();
55 
59  Q_INVOKABLE void reloadEnvMap();
63  Q_INVOKABLE void resetTimer();
64 
69  Scene *scene() const;
74  void setScene(Scene *scene);
75 
80  bool isAppActive() const;
85  void setIsAppActive(bool active);
86 
91  bool isActive() const;
92 
93 signals:
94  void isActiveChanged();
95  void isAppActiveChanged();
96  void isGameActiveChanged();
97  void sceneChanged();
98 
99 protected slots:
105  void synchronize();
110  void cleanup();
111 
112 protected:
120  QTime *m_time;
121 
122 private slots:
123  void handleWindowChanged(QQuickWindow *win);
124 };
125 
126 #endif // PAINTERQML_H
The Painter class Includes the rendering process, thus creating the whole picture. The Painter will be used by QML within rendering thread.
Definition: painter.h:26
void setIsAppActive(bool active)
Informs the painter if app is active or not. Setting this attribute to false leads to pause of game (...
Definition: painterqml.cpp:140
virtual ~PainterQML()
Definition: painterqml.cpp:26
Painter * m_painter
Definition: painterqml.h:117
QTime * m_time
Definition: painterqml.h:120
The LightRay class describes the lightrays sent into Scene. Because LightRays are sent into Scene ri...
Definition: lightray.h:24
PainterQML(QQuickItem *parent=0)
Definition: painterqml.cpp:13
void cleanup()
Cleans up the rendering thread ressources. This slot is also connected by PainterQML to correspondin...
Definition: painterqml.cpp:188
bool m_isAppActive
Definition: painterqml.h:113
Q_INVOKABLE void reloadEnvMap()
Reloads environment map of game using Config.
Definition: painterqml.cpp:102
int m_paintingDoneEventType
Definition: painterqml.h:118
void synchronize()
Synchronizes game logic and rendering. Because QML uses different threads for ui and rendering...
Definition: painterqml.cpp:161
bool event(QEvent *ev) override
Process incoming qt events.
Definition: painterqml.cpp:32
void setIsGameActive(bool active)
Sets active state of PainterQML.
Definition: painterqml.cpp:68
Scene * scene() const
The scene that is painted by PainterQML.
void isGameActiveChanged()
Q_INVOKABLE void resetTimer()
Resets update timer. This method is provided to allow manual resetting update time.
Definition: painterqml.cpp:109
bool isAppActive() const
Checks if the PainterQML assumes the app is active or not.
void sceneChanged()
void setScene(Scene *scene)
Sets the scene which should be drawn by PainterQML.
Definition: painterqml.cpp:121
bool isActive() const
Checks if the game will be updated. This means there is no reason to not update the game...
The Scene class provides access to geometry and collision detection methods. Furthermore, some game logic is implemented, so the scene holds the player, the gem influenced by player and cameras.
Definition: scene.h:22
void isActiveChanged()
bool m_isGameActive
Definition: painterqml.h:114
QEvent::Type paintingDoneEventType()
Queries registered event type, that should be sent after rendering of current frame is done...
Definition: painterqml.cpp:93
void isAppActiveChanged()
bool m_isSceneDeletionRequired
Definition: painterqml.h:115
The PainterQML class is responsible for making our game visible within QML using Painter. This class is intended to be added and created within QML. As the element showing our game it recognizes resize events and update events needed by our application. Also it keeps our rendering alive. Furthermore, it is the interface between game logic and rendering.
Definition: painterqml.h:18
bool m_isUpdatePending
Definition: painterqml.h:116
bool isGameActive() const
Checks if our painter and therfor aour game is active. Active means that the game should be updated ...
Scene * m_scene
Definition: painterqml.h:119