| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/particles/qquickparticleemitter_p.h |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||
| 2 | ** | - | ||||||
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||
| 4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||
| 5 | ** | - | ||||||
| 6 | ** This file is part of the QtQuick 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 | #ifndef PARTICLEEMITTER_H | - | ||||||
| 41 | #define PARTICLEEMITTER_H | - | ||||||
| 42 | - | |||||||
| 43 | // | - | ||||||
| 44 | // W A R N I N G | - | ||||||
| 45 | // ------------- | - | ||||||
| 46 | // | - | ||||||
| 47 | // This file is not part of the Qt API. It exists purely as an | - | ||||||
| 48 | // implementation detail. This header file may change from version to | - | ||||||
| 49 | // version without notice, or even be removed. | - | ||||||
| 50 | // | - | ||||||
| 51 | // We mean it. | - | ||||||
| 52 | // | - | ||||||
| 53 | - | |||||||
| 54 | #include <QtQuick/QQuickItem> | - | ||||||
| 55 | #include <QDebug> | - | ||||||
| 56 | #include "qquickparticlesystem_p.h" | - | ||||||
| 57 | #include "qquickparticleextruder_p.h" | - | ||||||
| 58 | #include "qquickdirection_p.h" | - | ||||||
| 59 | - | |||||||
| 60 | #include <QList> | - | ||||||
| 61 | #include <QPair> | - | ||||||
| 62 | #include <QPointF> | - | ||||||
| 63 | QT_BEGIN_NAMESPACE | - | ||||||
| 64 | - | |||||||
| 65 | class Q_QUICKPARTICLES_PRIVATE_EXPORT QQuickParticleEmitter : public QQuickItem | - | ||||||
| 66 | { | - | ||||||
| 67 | Q_OBJECT | - | ||||||
| 68 | Q_PROPERTY(QQuickParticleSystem* system READ system WRITE setSystem NOTIFY systemChanged) | - | ||||||
| 69 | Q_PROPERTY(QString group READ group WRITE setGroup NOTIFY groupChanged) | - | ||||||
| 70 | Q_PROPERTY(QQuickParticleExtruder* shape READ extruder WRITE setExtruder NOTIFY extruderChanged) | - | ||||||
| 71 | Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) | - | ||||||
| 72 | Q_PROPERTY(int startTime READ startTime WRITE setStartTime NOTIFY startTimeChanged) | - | ||||||
| 73 | - | |||||||
| 74 | Q_PROPERTY(qreal emitRate READ particlesPerSecond WRITE setParticlesPerSecond NOTIFY particlesPerSecondChanged) | - | ||||||
| 75 | Q_PROPERTY(int lifeSpan READ particleDuration WRITE setParticleDuration NOTIFY particleDurationChanged) | - | ||||||
| 76 | Q_PROPERTY(int lifeSpanVariation READ particleDurationVariation WRITE setParticleDurationVariation NOTIFY particleDurationVariationChanged) | - | ||||||
| 77 | Q_PROPERTY(int maximumEmitted READ maxParticleCount WRITE setMaxParticleCount NOTIFY maximumEmittedChanged) | - | ||||||
| 78 | - | |||||||
| 79 | Q_PROPERTY(qreal size READ particleSize WRITE setParticleSize NOTIFY particleSizeChanged) | - | ||||||
| 80 | Q_PROPERTY(qreal endSize READ particleEndSize WRITE setParticleEndSize NOTIFY particleEndSizeChanged) | - | ||||||
| 81 | Q_PROPERTY(qreal sizeVariation READ particleSizeVariation WRITE setParticleSizeVariation NOTIFY particleSizeVariationChanged) | - | ||||||
| 82 | - | |||||||
| 83 | Q_PROPERTY(QQuickDirection *velocity READ velocity WRITE setVelocity NOTIFY velocityChanged) | - | ||||||
| 84 | Q_PROPERTY(QQuickDirection *acceleration READ acceleration WRITE setAcceleration NOTIFY accelerationChanged) | - | ||||||
| 85 | Q_PROPERTY(qreal velocityFromMovement READ velocityFromMovement WRITE setVelocityFromMovement NOTIFY velocityFromMovementChanged) | - | ||||||
| 86 | - | |||||||
| 87 | public: | - | ||||||
| 88 | explicit QQuickParticleEmitter(QQuickItem *parent = 0); | - | ||||||
| 89 | virtual ~QQuickParticleEmitter(); | - | ||||||
| 90 | virtual void emitWindow(int timeStamp); | - | ||||||
| 91 | - | |||||||
| 92 | enum Lifetime { | - | ||||||
| 93 | InfiniteLife = QQuickParticleSystem::maxLife | - | ||||||
| 94 | }; | - | ||||||
| 95 | Q_ENUM(Lifetime) | - | ||||||
| 96 | - | |||||||
| 97 | bool enabled() const | - | ||||||
| 98 | { | - | ||||||
| 99 | return m_enabled; never executed: return m_enabled; | 0 | ||||||
| 100 | } | - | ||||||
| 101 | - | |||||||
| 102 | qreal particlesPerSecond() const | - | ||||||
| 103 | { | - | ||||||
| 104 | return m_particlesPerSecond; executed 4 times by 1 test: return m_particlesPerSecond;Executed by:
| 4 | ||||||
| 105 | } | - | ||||||
| 106 | - | |||||||
| 107 | int particleDuration() const | - | ||||||
| 108 | { | - | ||||||
| 109 | return m_particleDuration; never executed: return m_particleDuration; | 0 | ||||||
| 110 | } | - | ||||||
| 111 | - | |||||||
| 112 | QQuickParticleSystem* system() const | - | ||||||
| 113 | { | - | ||||||
| 114 | return m_system; never executed: return m_system; | 0 | ||||||
| 115 | } | - | ||||||
| 116 | - | |||||||
| 117 | QString group() const | - | ||||||
| 118 | { | - | ||||||
| 119 | return m_group; executed 610 times by 24 tests: return m_group;Executed by:
| 610 | ||||||
| 120 | } | - | ||||||
| 121 | - | |||||||
| 122 | QQuickParticleGroupData::ID groupId() const | - | ||||||
| 123 | { | - | ||||||
| 124 | if (m_groupIdNeedRecalculation)
| 280-546 | ||||||
| 125 | reclaculateGroupId(); executed 280 times by 24 tests: reclaculateGroupId();Executed by:
| 280 | ||||||
| 126 | return m_groupId; executed 826 times by 24 tests: return m_groupId;Executed by:
| 826 | ||||||
| 127 | } | - | ||||||
| 128 | - | |||||||
| 129 | int particleDurationVariation() const | - | ||||||
| 130 | { | - | ||||||
| 131 | return m_particleDurationVariation; never executed: return m_particleDurationVariation; | 0 | ||||||
| 132 | } | - | ||||||
| 133 | - | |||||||
| 134 | qreal velocityFromMovement() const { return m_velocity_from_movement; } never executed: return m_velocity_from_movement; | 0 | ||||||
| 135 | void setVelocityFromMovement(qreal s); | - | ||||||
| 136 | void componentComplete() override; | - | ||||||
| 137 | Q_SIGNALS: | - | ||||||
| 138 | void emitParticles(QQmlV4Handle particles); | - | ||||||
| 139 | void particlesPerSecondChanged(qreal); | - | ||||||
| 140 | void particleDurationChanged(int); | - | ||||||
| 141 | void enabledChanged(bool); | - | ||||||
| 142 | - | |||||||
| 143 | void systemChanged(QQuickParticleSystem* arg); | - | ||||||
| 144 | - | |||||||
| 145 | void groupChanged(const QString &arg); | - | ||||||
| 146 | - | |||||||
| 147 | void particleDurationVariationChanged(int arg); | - | ||||||
| 148 | - | |||||||
| 149 | void extruderChanged(QQuickParticleExtruder* arg); | - | ||||||
| 150 | - | |||||||
| 151 | void particleSizeChanged(qreal arg); | - | ||||||
| 152 | - | |||||||
| 153 | void particleEndSizeChanged(qreal arg); | - | ||||||
| 154 | - | |||||||
| 155 | void particleSizeVariationChanged(qreal arg); | - | ||||||
| 156 | - | |||||||
| 157 | void velocityChanged(QQuickDirection * arg); | - | ||||||
| 158 | - | |||||||
| 159 | void accelerationChanged(QQuickDirection * arg); | - | ||||||
| 160 | - | |||||||
| 161 | void maximumEmittedChanged(int arg); | - | ||||||
| 162 | void particleCountChanged(); | - | ||||||
| 163 | - | |||||||
| 164 | void velocityFromMovementChanged(); | - | ||||||
| 165 | - | |||||||
| 166 | void startTimeChanged(int arg); | - | ||||||
| 167 | - | |||||||
| 168 | public Q_SLOTS: | - | ||||||
| 169 | void pulse(int milliseconds); | - | ||||||
| 170 | void burst(int num); | - | ||||||
| 171 | void burst(int num, qreal x, qreal y); | - | ||||||
| 172 | - | |||||||
| 173 | void setEnabled(bool arg); | - | ||||||
| 174 | - | |||||||
| 175 | void setParticlesPerSecond(qreal arg) | - | ||||||
| 176 | { | - | ||||||
| 177 | if (m_particlesPerSecond != arg) {
| 4-278 | ||||||
| 178 | m_particlesPerSecond = arg; | - | ||||||
| 179 | Q_EMIT particlesPerSecondChanged(arg); | - | ||||||
| 180 | } executed 278 times by 24 tests: end of blockExecuted by:
| 278 | ||||||
| 181 | } executed 282 times by 24 tests: end of blockExecuted by:
| 282 | ||||||
| 182 | - | |||||||
| 183 | void setParticleDuration(int arg) | - | ||||||
| 184 | { | - | ||||||
| 185 | if (m_particleDuration != arg) {
| 6-276 | ||||||
| 186 | m_particleDuration = arg; | - | ||||||
| 187 | Q_EMIT particleDurationChanged(arg); | - | ||||||
| 188 | } executed 276 times by 24 tests: end of blockExecuted by:
| 276 | ||||||
| 189 | } executed 282 times by 24 tests: end of blockExecuted by:
| 282 | ||||||
| 190 | - | |||||||
| 191 | void setSystem(QQuickParticleSystem* arg) | - | ||||||
| 192 | { | - | ||||||
| 193 | if (m_system != arg) {
| 0-276 | ||||||
| 194 | m_system = arg; | - | ||||||
| 195 | m_groupIdNeedRecalculation = true; | - | ||||||
| 196 | if (m_system)
| 0-276 | ||||||
| 197 | m_system->registerParticleEmitter(this); executed 276 times by 24 tests: m_system->registerParticleEmitter(this);Executed by:
| 276 | ||||||
| 198 | Q_EMIT systemChanged(arg); | - | ||||||
| 199 | } executed 276 times by 24 tests: end of blockExecuted by:
| 276 | ||||||
| 200 | } executed 276 times by 24 tests: end of blockExecuted by:
| 276 | ||||||
| 201 | - | |||||||
| 202 | void setGroup(const QString &arg) | - | ||||||
| 203 | { | - | ||||||
| 204 | if (m_group != arg) {
| 2-122 | ||||||
| 205 | m_group = arg; | - | ||||||
| 206 | m_groupIdNeedRecalculation = true; | - | ||||||
| 207 | Q_EMIT groupChanged(arg); | - | ||||||
| 208 | } executed 122 times by 8 tests: end of blockExecuted by:
| 122 | ||||||
| 209 | } executed 124 times by 8 tests: end of blockExecuted by:
| 124 | ||||||
| 210 | - | |||||||
| 211 | void setParticleDurationVariation(int arg) | - | ||||||
| 212 | { | - | ||||||
| 213 | if (m_particleDurationVariation != arg) {
| 0-8 | ||||||
| 214 | m_particleDurationVariation = arg; | - | ||||||
| 215 | Q_EMIT particleDurationVariationChanged(arg); | - | ||||||
| 216 | } executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||
| 217 | } executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||
| 218 | void setExtruder(QQuickParticleExtruder* arg) | - | ||||||
| 219 | { | - | ||||||
| 220 | if (m_extruder != arg) {
| 0-32 | ||||||
| 221 | m_extruder = arg; | - | ||||||
| 222 | Q_EMIT extruderChanged(arg); | - | ||||||
| 223 | } executed 32 times by 5 tests: end of blockExecuted by:
| 32 | ||||||
| 224 | } executed 32 times by 5 tests: end of blockExecuted by:
| 32 | ||||||
| 225 | - | |||||||
| 226 | void setParticleSize(qreal arg) | - | ||||||
| 227 | { | - | ||||||
| 228 | if (m_particleSize != arg) {
| 30-244 | ||||||
| 229 | m_particleSize = arg; | - | ||||||
| 230 | Q_EMIT particleSizeChanged(arg); | - | ||||||
| 231 | } executed 244 times by 24 tests: end of blockExecuted by:
| 244 | ||||||
| 232 | } executed 274 times by 24 tests: end of blockExecuted by:
| 274 | ||||||
| 233 | - | |||||||
| 234 | void setParticleEndSize(qreal arg) | - | ||||||
| 235 | { | - | ||||||
| 236 | if (m_particleEndSize != arg) {
| 0-112 | ||||||
| 237 | m_particleEndSize = arg; | - | ||||||
| 238 | Q_EMIT particleEndSizeChanged(arg); | - | ||||||
| 239 | } executed 112 times by 1 test: end of blockExecuted by:
| 112 | ||||||
| 240 | } executed 112 times by 1 test: end of blockExecuted by:
| 112 | ||||||
| 241 | - | |||||||
| 242 | void setParticleSizeVariation(qreal arg) | - | ||||||
| 243 | { | - | ||||||
| 244 | if (m_particleSizeVariation != arg) {
| 0-84 | ||||||
| 245 | m_particleSizeVariation = arg; | - | ||||||
| 246 | Q_EMIT particleSizeVariationChanged(arg); | - | ||||||
| 247 | } executed 84 times by 1 test: end of blockExecuted by:
| 84 | ||||||
| 248 | } executed 84 times by 1 test: end of blockExecuted by:
| 84 | ||||||
| 249 | - | |||||||
| 250 | void setVelocity(QQuickDirection * arg) | - | ||||||
| 251 | { | - | ||||||
| 252 | if (m_velocity != arg) {
| 0-180 | ||||||
| 253 | m_velocity = arg; | - | ||||||
| 254 | Q_EMIT velocityChanged(arg); | - | ||||||
| 255 | } executed 180 times by 8 tests: end of blockExecuted by:
| 180 | ||||||
| 256 | } executed 180 times by 8 tests: end of blockExecuted by:
| 180 | ||||||
| 257 | - | |||||||
| 258 | void setAcceleration(QQuickDirection * arg) | - | ||||||
| 259 | { | - | ||||||
| 260 | if (m_acceleration != arg) {
| 0-74 | ||||||
| 261 | m_acceleration = arg; | - | ||||||
| 262 | Q_EMIT accelerationChanged(arg); | - | ||||||
| 263 | } executed 74 times by 4 tests: end of blockExecuted by:
| 74 | ||||||
| 264 | } executed 74 times by 4 tests: end of blockExecuted by:
| 74 | ||||||
| 265 | - | |||||||
| 266 | void setMaxParticleCount(int arg); | - | ||||||
| 267 | - | |||||||
| 268 | void setStartTime(int arg) | - | ||||||
| 269 | { | - | ||||||
| 270 | if (m_startTime != arg) {
| 0-6 | ||||||
| 271 | m_startTime = arg; | - | ||||||
| 272 | Q_EMIT startTimeChanged(arg); | - | ||||||
| 273 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||
| 274 | } executed 6 times by 1 test: end of blockExecuted by:
| 6 | ||||||
| 275 | - | |||||||
| 276 | virtual void reset(); | - | ||||||
| 277 | public: | - | ||||||
| 278 | int particleCount() const | - | ||||||
| 279 | { | - | ||||||
| 280 | if (m_maxParticleCount >= 0)
| 30-722 | ||||||
| 281 | return m_maxParticleCount; executed 30 times by 1 test: return m_maxParticleCount;Executed by:
| 30 | ||||||
| 282 | return m_particlesPerSecond*((m_particleDuration+m_particleDurationVariation)/1000.0); executed 722 times by 24 tests: return m_particlesPerSecond*((m_particleDuration+m_particleDurationVariation)/1000.0);Executed by:
| 722 | ||||||
| 283 | } | - | ||||||
| 284 | - | |||||||
| 285 | QQuickParticleExtruder* extruder() const | - | ||||||
| 286 | { | - | ||||||
| 287 | return m_extruder; never executed: return m_extruder; | 0 | ||||||
| 288 | } | - | ||||||
| 289 | - | |||||||
| 290 | qreal particleSize() const | - | ||||||
| 291 | { | - | ||||||
| 292 | return m_particleSize; never executed: return m_particleSize; | 0 | ||||||
| 293 | } | - | ||||||
| 294 | - | |||||||
| 295 | qreal particleEndSize() const | - | ||||||
| 296 | { | - | ||||||
| 297 | return m_particleEndSize; never executed: return m_particleEndSize; | 0 | ||||||
| 298 | } | - | ||||||
| 299 | - | |||||||
| 300 | qreal particleSizeVariation() const | - | ||||||
| 301 | { | - | ||||||
| 302 | return m_particleSizeVariation; never executed: return m_particleSizeVariation; | 0 | ||||||
| 303 | } | - | ||||||
| 304 | - | |||||||
| 305 | QQuickDirection * velocity() const | - | ||||||
| 306 | { | - | ||||||
| 307 | return m_velocity; never executed: return m_velocity; | 0 | ||||||
| 308 | } | - | ||||||
| 309 | - | |||||||
| 310 | QQuickDirection * acceleration() const | - | ||||||
| 311 | { | - | ||||||
| 312 | return m_acceleration; never executed: return m_acceleration; | 0 | ||||||
| 313 | } | - | ||||||
| 314 | - | |||||||
| 315 | int maxParticleCount() const | - | ||||||
| 316 | { | - | ||||||
| 317 | return m_maxParticleCount; never executed: return m_maxParticleCount; | 0 | ||||||
| 318 | } | - | ||||||
| 319 | - | |||||||
| 320 | int startTime() const | - | ||||||
| 321 | { | - | ||||||
| 322 | return m_startTime; never executed: return m_startTime; | 0 | ||||||
| 323 | } | - | ||||||
| 324 | - | |||||||
| 325 | void reclaculateGroupId() const; | - | ||||||
| 326 | - | |||||||
| 327 | protected: | - | ||||||
| 328 | qreal m_particlesPerSecond; | - | ||||||
| 329 | int m_particleDuration; | - | ||||||
| 330 | int m_particleDurationVariation; | - | ||||||
| 331 | bool m_enabled; | - | ||||||
| 332 | QQuickParticleSystem* m_system; | - | ||||||
| 333 | QQuickParticleExtruder* m_extruder; | - | ||||||
| 334 | QQuickParticleExtruder* m_defaultExtruder; | - | ||||||
| 335 | QQuickParticleExtruder* effectiveExtruder(); | - | ||||||
| 336 | QQuickDirection * m_velocity; | - | ||||||
| 337 | QQuickDirection * m_acceleration; | - | ||||||
| 338 | qreal m_particleSize; | - | ||||||
| 339 | qreal m_particleEndSize; | - | ||||||
| 340 | qreal m_particleSizeVariation; | - | ||||||
| 341 | - | |||||||
| 342 | qreal m_velocityFromMovement; | - | ||||||
| 343 | int m_startTime; | - | ||||||
| 344 | bool m_overwrite; | - | ||||||
| 345 | - | |||||||
| 346 | int m_pulseLeft; | - | ||||||
| 347 | QList<QPair<int, QPointF > > m_burstQueue; | - | ||||||
| 348 | int m_maxParticleCount; | - | ||||||
| 349 | - | |||||||
| 350 | //Used in default implementation, but might be useful | - | ||||||
| 351 | qreal m_velocity_from_movement; | - | ||||||
| 352 | - | |||||||
| 353 | int m_emitCap; | - | ||||||
| 354 | bool m_reset_last; | - | ||||||
| 355 | qreal m_last_timestamp; | - | ||||||
| 356 | qreal m_last_emission; | - | ||||||
| 357 | - | |||||||
| 358 | QPointF m_last_emitter; | - | ||||||
| 359 | QPointF m_last_last_emitter; | - | ||||||
| 360 | QPointF m_last_last_last_emitter; | - | ||||||
| 361 | - | |||||||
| 362 | bool isEmitConnected(); | - | ||||||
| 363 | - | |||||||
| 364 | private: // data | - | ||||||
| 365 | QString m_group; | - | ||||||
| 366 | mutable bool m_groupIdNeedRecalculation; | - | ||||||
| 367 | mutable QQuickParticleGroupData::ID m_groupId; | - | ||||||
| 368 | QQuickDirection m_nullVector; | - | ||||||
| 369 | - | |||||||
| 370 | }; | - | ||||||
| 371 | - | |||||||
| 372 | QT_END_NAMESPACE | - | ||||||
| 373 | - | |||||||
| 374 | #endif // PARTICLEEMITTER_H | - | ||||||
| Source code | Switch to Preprocessed file |