| 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 "qaxissetting.h" | 
| 41 | #include "qaxissetting_p.h" | 
| 42 |  | 
| 43 | #include <Qt3DCore/qnodecreatedchange.h> | 
| 44 |  | 
| 45 | QT_BEGIN_NAMESPACE | 
| 46 |  | 
| 47 | namespace Qt3DInput { | 
| 48 | /*! | 
| 49 |     \class Qt3DInput::QAxisSetting | 
| 50 |     \inmodule Qt3DInput | 
| 51 |     \inherits Qt3DCore::QNode | 
| 52 |     \brief QAxisSetting stores settings for the specified list of Axis. | 
| 53 |  | 
| 54 |     Stores the dead zone associated with this axis and defines if smoothing is enabled | 
| 55 |     \since 5.5 | 
| 56 | */ | 
| 57 |  | 
| 58 | /*! | 
| 59 |  | 
| 60 |     \qmltype AxisSetting | 
| 61 |     \inqmlmodule Qt3D.Input | 
| 62 |     \instantiates Qt3DInput::QAxisSetting | 
| 63 |     \brief QML frontend for the Qt3DInput::QAxisSetting C++ class. | 
| 64 |  | 
| 65 |     Stores settings for the specified list of Axis | 
| 66 |     \since 5.5 | 
| 67 | */ | 
| 68 |  | 
| 69 | /*! | 
| 70 |   \qmlproperty list<int> AxisSetting::axes | 
| 71 |  */ | 
| 72 |  | 
| 73 |  | 
| 74 | /*! | 
| 75 |     Constructs a new QAxisSetting instance with \a parent. | 
| 76 |  */ | 
| 77 | QAxisSetting::QAxisSetting(Qt3DCore::QNode *parent) | 
| 78 |     : QNode(*new QAxisSettingPrivate(), parent) | 
| 79 | { | 
| 80 | } | 
| 81 |  | 
| 82 | /*! \internal */ | 
| 83 | QAxisSetting::~QAxisSetting() | 
| 84 | { | 
| 85 | } | 
| 86 |  | 
| 87 | /*! | 
| 88 |     \property QAxisSetting::axes | 
| 89 |  */ | 
| 90 |  | 
| 91 | /*! | 
| 92 |  * \brief QAxisSetting::axes | 
| 93 |  * \return the current list of Axis these settings apply to. | 
| 94 |  */ | 
| 95 | QVector<int> QAxisSetting::axes() const | 
| 96 | { | 
| 97 |     Q_D(const QAxisSetting); | 
| 98 |     return d->m_axes; | 
| 99 | } | 
| 100 |  | 
| 101 | /*! | 
| 102 |     \property QAxisSetting::deadZoneRadius | 
| 103 |  */ | 
| 104 |  | 
| 105 | /*! | 
| 106 |  * \brief QAxisSetting::deadZoneRadius | 
| 107 |  * \return the set dead zone radius. | 
| 108 |  */ | 
| 109 | float QAxisSetting::deadZoneRadius() const | 
| 110 | { | 
| 111 |     Q_D(const QAxisSetting); | 
| 112 |     return d->m_deadZoneRadius; | 
| 113 | } | 
| 114 |  | 
| 115 | /*! | 
| 116 |     \property QAxisSetting::smooth | 
| 117 |  */ | 
| 118 |  | 
| 119 | /*! | 
| 120 |  * \brief QAxisSetting::isSmoothEnabled | 
| 121 |  * \return if smoothing is enabled. | 
| 122 |  */ | 
| 123 | bool QAxisSetting::isSmoothEnabled() const | 
| 124 | { | 
| 125 |     Q_D(const QAxisSetting); | 
| 126 |     return d->m_smooth; | 
| 127 | } | 
| 128 |  | 
| 129 |  | 
| 130 | /*! | 
| 131 |   \fn Qt3DInput::QAxisSetting::deadZoneRadiusChanged(float deadZoneRadius) | 
| 132 |  | 
| 133 |   This signal is emitted when the Dead Zone radius associated with the axis setting is changed to \a deadZoneRadius. | 
| 134 | */ | 
| 135 |  | 
| 136 | /*! | 
| 137 |   \qmlproperty float Qt3D.Input::AxisSetting::deadZoneRadius | 
| 138 |  | 
| 139 |   The current deadZone radius of the AxisSetting | 
| 140 | */ | 
| 141 |  | 
| 142 | /*! | 
| 143 |     \qmlsignal Qt3D.Input::AxisSetting::deadZoneRadiusChanged() | 
| 144 |  | 
| 145 |     This signal is emitted when the dead zone associated with the axis setting is changed. | 
| 146 |  | 
| 147 |     The corresponding handler is \c onDeadZoneRadiusChanged | 
| 148 | */ | 
| 149 |  | 
| 150 | /*! | 
| 151 |     Set the current dead zone radius of the QAxisSetting instance to \a deadZoneRadius. | 
| 152 |  */ | 
| 153 | void QAxisSetting::setDeadZoneRadius(float deadZoneRadius) | 
| 154 | { | 
| 155 |     Q_D(QAxisSetting); | 
| 156 |     if (d->m_deadZoneRadius == deadZoneRadius) | 
| 157 |         return; | 
| 158 |  | 
| 159 |     d->m_deadZoneRadius = deadZoneRadius; | 
| 160 |     emit deadZoneRadiusChanged(deadZoneRadius); | 
| 161 | } | 
| 162 |  | 
| 163 | /*! | 
| 164 |   \fn Qt3DInput::QAxisSetting::axesChanged(const QVector<int> &axes) | 
| 165 |  | 
| 166 |   This signal is emitted when the axes associated with the axis setting is changed to \a axes. | 
| 167 | */ | 
| 168 |  | 
| 169 | /*! | 
| 170 |   \qmlproperty QVariantList Qt3D.Input::AxisSetting::axis | 
| 171 |  | 
| 172 |   The current axis of the AxisSetting | 
| 173 | */ | 
| 174 |  | 
| 175 | /*! | 
| 176 |     \qmlsignal Qt3D.Input::AxisSetting::axisChanged() | 
| 177 |  | 
| 178 |     This signal is emitted when the axis associated with the axis setting is changed. | 
| 179 |  | 
| 180 |     The corresponding handler is \c onAxisChanged | 
| 181 | */ | 
| 182 |  | 
| 183 | /*! | 
| 184 |     Set the current axes of the QAxisSetting instance to \a axes. | 
| 185 |  */ | 
| 186 | void QAxisSetting::setAxes(const QVector<int> &axes) | 
| 187 | { | 
| 188 |     Q_D(QAxisSetting); | 
| 189 |     if (d->m_axes == axes) | 
| 190 |         return; | 
| 191 |  | 
| 192 |     d->m_axes = axes; | 
| 193 |     emit axesChanged(axes); | 
| 194 | } | 
| 195 |  | 
| 196 | /*! | 
| 197 |   \fn Qt3DInput::QAxisSetting::smoothChanged(bool smooth) | 
| 198 |  | 
| 199 |   This signal is emitted when the smoothing state is changed to \a smooth. | 
| 200 | */ | 
| 201 |  | 
| 202 | /*! | 
| 203 |   \qmlproperty bool Qt3D.Input::AxisSetting::smooth | 
| 204 |  | 
| 205 |   The current state of smoothing | 
| 206 | */ | 
| 207 |  | 
| 208 | /*! | 
| 209 |     \qmlsignal Qt3D.Input::AxisSetting::smoothChanged() | 
| 210 |  | 
| 211 |     This signal is emitted when the when the smoothing state is changed. | 
| 212 |  | 
| 213 |     The corresponding handler is \c onSmoothChanged | 
| 214 | */ | 
| 215 |  | 
| 216 | /*! | 
| 217 |     Set the current state of the QAxisSettings smoothing to \a enabled. | 
| 218 |  */ | 
| 219 | void QAxisSetting::setSmoothEnabled(bool enabled) | 
| 220 | { | 
| 221 |     Q_D(QAxisSetting); | 
| 222 |     if (d->m_smooth == enabled) | 
| 223 |         return; | 
| 224 |  | 
| 225 |     d->m_smooth = enabled; | 
| 226 |     emit smoothChanged(smooth: enabled); | 
| 227 | } | 
| 228 |  | 
| 229 | Qt3DCore::QNodeCreatedChangeBasePtr QAxisSetting::createNodeCreationChange() const | 
| 230 | { | 
| 231 |     auto creationChange = Qt3DCore::QNodeCreatedChangePtr<QAxisSettingData>::create(arguments: this); | 
| 232 |     auto &data = creationChange->data; | 
| 233 |  | 
| 234 |     Q_D(const QAxisSetting); | 
| 235 |     data.deadZoneRadius = d->m_deadZoneRadius; | 
| 236 |     data.axes = d->m_axes; | 
| 237 |     data.smooth = d->m_smooth; | 
| 238 |  | 
| 239 |     return creationChange; | 
| 240 | } | 
| 241 |  | 
| 242 | } // namespace Qt3DInput | 
| 243 |  | 
| 244 | QT_END_NAMESPACE | 
| 245 |  |