| 1 | // Copyright (C) 2015 Klaralvdalens Datakonsult AB (KDAB). |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #include "qframeaction.h" |
| 5 | |
| 6 | #include "qframeaction_p.h" |
| 7 | |
| 8 | QT_BEGIN_NAMESPACE |
| 9 | |
| 10 | namespace Qt3DLogic { |
| 11 | |
| 12 | QFrameActionPrivate::QFrameActionPrivate() |
| 13 | : QComponentPrivate() |
| 14 | { |
| 15 | } |
| 16 | |
| 17 | /*! |
| 18 | \namespace Qt3DLogic::Logic |
| 19 | \inmodule Qt3DLogic |
| 20 | |
| 21 | \brief Used to import and use the module's QML types. |
| 22 | */ |
| 23 | /*! |
| 24 | \class Qt3DLogic::QFrameAction |
| 25 | \inmodule Qt3DLogic |
| 26 | \since 5.5 |
| 27 | \brief Provides a way to have a synchronous function executed each frame. |
| 28 | |
| 29 | The QFrameAction provides a way to perform tasks each frame in a |
| 30 | synchronized way with the Qt3D backend. This is useful to implement some |
| 31 | aspects of application logic and to prototype functionality that can later |
| 32 | be folded into an additional Qt3D aspect. |
| 33 | |
| 34 | For example, the QFrameAction can be used to animate a property in sync |
| 35 | with the Qt3D engine where a Qt Quick animation element is not perfectly |
| 36 | synchronized and may lead to stutters in some cases. |
| 37 | |
| 38 | To execute your own code each frame connect to the QFrameAction::triggered signal. |
| 39 | */ |
| 40 | |
| 41 | /*! |
| 42 | \qmltype FrameAction |
| 43 | \inqmlmodule Qt3D.Logic |
| 44 | \nativetype Qt3DLogic::QFrameAction |
| 45 | \inherits Component3D |
| 46 | \since 5.5 |
| 47 | \brief Provides a way to have a synchronous function executed each frame. |
| 48 | |
| 49 | The FrameAction provides a way to perform tasks each frame in a |
| 50 | synchronized way with the Qt3D backend. This is useful to implement some |
| 51 | aspects of application logic and to prototype functionality that can later |
| 52 | be folded into an additional Qt3D aspect. |
| 53 | |
| 54 | For example, the FrameAction can be used to animate a property in sync |
| 55 | with the Qt3D engine where a Qt Quick animation element is not perfectly |
| 56 | synchronized and may lead to stutters in some cases. |
| 57 | |
| 58 | To execute your own code each frame connect to the FrameAction::triggered signal. |
| 59 | */ |
| 60 | |
| 61 | /*! |
| 62 | Constructs a new QFrameAction instance with parent \a parent. |
| 63 | */ |
| 64 | QFrameAction::QFrameAction(QNode *parent) |
| 65 | : QComponent(*new QFrameActionPrivate, parent) |
| 66 | { |
| 67 | } |
| 68 | |
| 69 | /*! \internal */ |
| 70 | QFrameAction::~QFrameAction() |
| 71 | { |
| 72 | } |
| 73 | |
| 74 | /*! \internal */ |
| 75 | QFrameAction::QFrameAction(QFrameActionPrivate &dd, QNode *parent) |
| 76 | : QComponent(dd, parent) |
| 77 | { |
| 78 | } |
| 79 | |
| 80 | /*! |
| 81 | \internal |
| 82 | This function will be called in a synchronous manner once each frame by |
| 83 | the Logic aspect. |
| 84 | */ |
| 85 | void QFrameAction::onTriggered(float dt) |
| 86 | { |
| 87 | // Emit signal so that QML instances get the onTriggered() signal |
| 88 | // handler called |
| 89 | emit triggered(dt); |
| 90 | } |
| 91 | |
| 92 | /*! |
| 93 | \qmlsignal Qt3D.Logic::FrameAction::triggered(real dt) |
| 94 | This signal is emitted each frame with \a dt being the time (in seconds) since the last triggering. |
| 95 | */ |
| 96 | |
| 97 | /*! |
| 98 | \fn Qt3DLogic::QFrameAction::triggered(float dt) |
| 99 | This signal is emitted each frame with \a dt being the time (in seconds) since the last triggering. |
| 100 | */ |
| 101 | } // namespace Qt3DLogic |
| 102 | |
| 103 | QT_END_NAMESPACE |
| 104 | |
| 105 | #include "moc_qframeaction.cpp" |
| 106 | |