1/****************************************************************************
2**
3** Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB).
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt3D module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#include "qframeaction.h"
41
42#include "qframeaction_p.h"
43
44QT_BEGIN_NAMESPACE
45
46namespace Qt3DLogic {
47
48QFrameActionPrivate::QFrameActionPrivate()
49 : QComponentPrivate()
50{
51}
52
53/*!
54 \namespace Qt3DLogic::Logic
55 \inmodule Qt3DLogic
56
57 \brief Used to import and use the module's QML types.
58*/
59/*!
60 \class Qt3DLogic::QFrameAction
61 \inmodule Qt3DLogic
62 \since 5.5
63 \brief Provides a way to have a synchronous function executed each frame.
64
65 The QFrameAction provides a way to perform tasks each frame in a
66 synchronized way with the Qt3D backend. This is useful to implement some
67 aspects of application logic and to prototype functionality that can later
68 be folded into an additional Qt3D aspect.
69
70 For example, the QFrameAction can be used to animate a property in sync
71 with the Qt3D engine where a Qt Quick animation element is not perfectly
72 synchronized and may lead to stutters in some cases.
73
74 To execute your own code each frame connect to the QFrameAction::triggered signal.
75*/
76
77/*!
78 \qmltype FrameAction
79 \inqmlmodule Qt3D.Logic
80 \instantiates Qt3DLogic::QFrameAction
81 \inherits Component3D
82 \since 5.5
83 \brief Provides a way to have a synchronous function executed each frame.
84
85 The FrameAction provides a way to perform tasks each frame in a
86 synchronized way with the Qt3D backend. This is useful to implement some
87 aspects of application logic and to prototype functionality that can later
88 be folded into an additional Qt3D aspect.
89
90 For example, the FrameAction can be used to animate a property in sync
91 with the Qt3D engine where a Qt Quick animation element is not perfectly
92 synchronized and may lead to stutters in some cases.
93
94 To execute your own code each frame connect to the FrameAction::triggered signal.
95*/
96
97/*!
98 Constructs a new QFrameAction instance with parent \a parent.
99 */
100QFrameAction::QFrameAction(QNode *parent)
101 : QComponent(*new QFrameActionPrivate, parent)
102{
103}
104
105/*! \internal */
106QFrameAction::~QFrameAction()
107{
108}
109
110/*! \internal */
111QFrameAction::QFrameAction(QFrameActionPrivate &dd, QNode *parent)
112 : QComponent(dd, parent)
113{
114}
115
116/*!
117 \internal
118 This function will be called in a synchronous manner once each frame by
119 the Logic aspect.
120*/
121void QFrameAction::onTriggered(float dt)
122{
123 // Emit signal so that QML instances get the onTriggered() signal
124 // handler called
125 emit triggered(dt);
126}
127
128/*!
129 \qmlsignal Qt3D.Logic::FrameAction::triggered(real dt)
130 This signal is emitted each frame with \a dt being the time (in seconds) since the last triggering.
131*/
132
133/*!
134 \fn Qt3DLogic::QFrameAction::triggered(float dt)
135 This signal is emitted each frame with \a dt being the time (in seconds) since the last triggering.
136*/
137} // namespace Qt3DLogic
138
139QT_END_NAMESPACE
140