Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickparticleemitter_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef PARTICLEEMITTER_H
5#define PARTICLEEMITTER_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtQuick/QQuickItem>
19#include <QDebug>
22#include "qquickdirection_p.h"
23
24#include <QList>
25#include <QPair>
26#include <QPointF>
28
29class Q_QUICKPARTICLES_EXPORT QQuickParticleEmitter : public QQuickItem
30{
32 Q_PROPERTY(QQuickParticleSystem* system READ system WRITE setSystem NOTIFY systemChanged)
33 Q_PROPERTY(QString group READ group WRITE setGroup NOTIFY groupChanged)
34 Q_PROPERTY(QQuickParticleExtruder* shape READ extruder WRITE setExtruder NOTIFY extruderChanged)
35 Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
36 Q_PROPERTY(int startTime READ startTime WRITE setStartTime NOTIFY startTimeChanged)
37
38 Q_PROPERTY(qreal emitRate READ particlesPerSecond WRITE setParticlesPerSecond NOTIFY particlesPerSecondChanged)
39 Q_PROPERTY(int lifeSpan READ particleDuration WRITE setParticleDuration NOTIFY particleDurationChanged)
40 Q_PROPERTY(int lifeSpanVariation READ particleDurationVariation WRITE setParticleDurationVariation NOTIFY particleDurationVariationChanged)
41 Q_PROPERTY(int maximumEmitted READ maxParticleCount WRITE setMaxParticleCount NOTIFY maximumEmittedChanged)
42
43 Q_PROPERTY(qreal size READ particleSize WRITE setParticleSize NOTIFY particleSizeChanged)
44 Q_PROPERTY(qreal endSize READ particleEndSize WRITE setParticleEndSize NOTIFY particleEndSizeChanged)
45 Q_PROPERTY(qreal sizeVariation READ particleSizeVariation WRITE setParticleSizeVariation NOTIFY particleSizeVariationChanged)
46
47 Q_PROPERTY(QQuickDirection *velocity READ velocity WRITE setVelocity NOTIFY velocityChanged)
48 Q_PROPERTY(QQuickDirection *acceleration READ acceleration WRITE setAcceleration NOTIFY accelerationChanged)
49 Q_PROPERTY(qreal velocityFromMovement READ velocityFromMovement WRITE setVelocityFromMovement NOTIFY velocityFromMovementChanged)
50 QML_NAMED_ELEMENT(Emitter)
52
53public:
54 explicit QQuickParticleEmitter(QQuickItem *parent = nullptr);
55 virtual ~QQuickParticleEmitter();
56 virtual void emitWindow(int timeStamp);
57
58 enum Lifetime {
60 };
61 Q_ENUM(Lifetime)
62
63 bool enabled() const
64 {
65 return m_enabled;
66 }
67
69 {
70 return m_particlesPerSecond;
71 }
72
73 int particleDuration() const
74 {
75 return m_particleDuration;
76 }
77
79 {
80 return m_system;
81 }
82
83 QString group() const
84 {
85 return m_group;
86 }
87
89 {
90 if (m_groupIdNeedRecalculation)
91 reclaculateGroupId();
92 return m_groupId;
93 }
94
96 {
97 return m_particleDurationVariation;
98 }
99
100 qreal velocityFromMovement() const { return m_velocity_from_movement; }
101 void setVelocityFromMovement(qreal s);
102 void componentComplete() override;
104 void emitParticles(const QList<QQuickV4ParticleData> &particles);
107 void enabledChanged(bool);
108
110
112
114
116
118
120
122
124
126
129
131
133
134public Q_SLOTS:
135 void pulse(int milliseconds);
136 void burst(int num);
137 void burst(int num, qreal x, qreal y);
138
139 void setEnabled(bool arg);
140
142 {
143 if (m_particlesPerSecond != arg) {
144 m_particlesPerSecond = arg;
145 Q_EMIT particlesPerSecondChanged(arg);
146 }
147 }
148
150 {
151 if (m_particleDuration != arg) {
152 m_particleDuration = arg;
153 Q_EMIT particleDurationChanged(arg);
154 }
155 }
156
158 {
159 if (m_system != arg) {
160 m_system = arg;
161 m_groupIdNeedRecalculation = true;
162 if (m_system)
163 m_system->registerParticleEmitter(this);
164 Q_EMIT systemChanged(arg);
165 }
166 }
167
168 void setGroup(const QString &arg)
169 {
170 if (m_group != arg) {
171 m_group = arg;
172 m_groupIdNeedRecalculation = true;
173 Q_EMIT groupChanged(arg);
174 }
175 }
176
178 {
179 if (m_particleDurationVariation != arg) {
180 m_particleDurationVariation = arg;
181 Q_EMIT particleDurationVariationChanged(arg);
182 }
183 }
185 {
186 if (m_extruder != arg) {
187 m_extruder = arg;
188 Q_EMIT extruderChanged(arg);
189 }
190 }
191
193 {
194 if (m_particleSize != arg) {
195 m_particleSize = arg;
196 Q_EMIT particleSizeChanged(arg);
197 }
198 }
199
201 {
202 if (m_particleEndSize != arg) {
203 m_particleEndSize = arg;
204 Q_EMIT particleEndSizeChanged(arg);
205 }
206 }
207
209 {
210 if (m_particleSizeVariation != arg) {
211 m_particleSizeVariation = arg;
212 Q_EMIT particleSizeVariationChanged(arg);
213 }
214 }
215
217 {
218 if (m_velocity != arg) {
219 m_velocity = arg;
220 Q_EMIT velocityChanged(arg);
221 }
222 }
223
225 {
226 if (m_acceleration != arg) {
227 m_acceleration = arg;
228 Q_EMIT accelerationChanged(arg);
229 }
230 }
231
232 void setMaxParticleCount(int arg);
233
235 {
236 if (m_startTime != arg) {
237 m_startTime = arg;
238 Q_EMIT startTimeChanged(arg);
239 }
240 }
241
242 virtual void reset();
243public:
244 int particleCount() const
245 {
246 if (m_maxParticleCount >= 0)
247 return m_maxParticleCount;
248 return m_particlesPerSecond*((m_particleDuration+m_particleDurationVariation)/1000.0);
249 }
250
252 {
253 return m_extruder;
254 }
255
257 {
258 return m_particleSize;
259 }
260
262 {
263 return m_particleEndSize;
264 }
265
267 {
268 return m_particleSizeVariation;
269 }
270
272 {
273 return m_velocity;
274 }
275
277 {
278 return m_acceleration;
279 }
280
282 {
283 return m_maxParticleCount;
284 }
285
286 int startTime() const
287 {
288 return m_startTime;
289 }
290
291 void reclaculateGroupId() const;
292
293protected:
301 QQuickParticleExtruder* effectiveExtruder();
307
310
312 QList<QPair<int, QPointF > > m_burstQueue;
314
315 //Used in default implementation, but might be useful
317
322
325
326 bool isEmitConnected();
327
328private: // data
329 QString m_group;
330 mutable bool m_groupIdNeedRecalculation;
331 mutable QQuickParticleGroupData::ID m_groupId;
332 QQuickDirection m_nullVector;
333
334};
335
337
338#endif // PARTICLEEMITTER_H
\inmodule QtCore\reentrant
Definition qpoint.h:217
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
void groupChanged(const QString &arg)
QQuickDirection * velocity() const
QQuickDirection * acceleration() const
QQuickParticleExtruder * m_extruder
void setSystem(QQuickParticleSystem *arg)
void setVelocity(QQuickDirection *arg)
void emitParticles(const QList< QQuickV4ParticleData > &particles)
void startTimeChanged(int arg)
QQuickParticleExtruder * m_defaultExtruder
QQuickParticleSystem * m_system
void setParticleSizeVariation(qreal arg)
QQuickParticleExtruder * extruder() const
void enabledChanged(bool)
void extruderChanged(QQuickParticleExtruder *arg)
void particleDurationVariationChanged(int arg)
void accelerationChanged(QQuickDirection *arg)
void maximumEmittedChanged(int arg)
void particleEndSizeChanged(qreal arg)
void setAcceleration(QQuickDirection *arg)
void particleDurationChanged(int)
QList< QPair< int, QPointF > > m_burstQueue
void velocityFromMovementChanged()
void velocityChanged(QQuickDirection *arg)
void particleSizeChanged(qreal arg)
void particleSizeVariationChanged(qreal arg)
QQuickParticleSystem * system() const
void particlesPerSecondChanged(qreal)
void setExtruder(QQuickParticleExtruder *arg)
void setGroup(const QString &arg)
void systemChanged(QQuickParticleSystem *arg)
QQuickParticleGroupData::ID groupId() const
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
Combined button and popup list for selecting options.
qint64 startTime
GLint GLint GLint GLint GLint x
[0]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLboolean GLuint group
GLint y
GLdouble s
[6]
Definition qopenglext.h:235
GLboolean reset
GLuint num
#define QML_NAMED_ELEMENT(NAME)
#define QML_ADDED_IN_VERSION(MAJOR, MINOR)
SSL_CTX int void * arg
#define Q_ENUM(x)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_EMIT
#define Q_SLOTS
#define Q_SIGNALS
double qreal
Definition qtypes.h:187
#define explicit