OpenCoverage

qquickparticleaffector_p.h

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/particles/qquickparticleaffector_p.h
Source codeSwitch to Preprocessed file
LineSourceCount
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 PARTICLEAFFECTOR_H-
41#define PARTICLEAFFECTOR_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 <QObject>-
55#include "qquickparticlesystem_p.h"-
56#include "qquickparticleextruder_p.h"-
57#include "qtquickparticlesglobal_p.h"-
58-
59QT_BEGIN_NAMESPACE-
60-
61class Q_QUICKPARTICLES_PRIVATE_EXPORT QQuickParticleAffector : public QQuickItem-
62{-
63 Q_OBJECT-
64 Q_PROPERTY(QQuickParticleSystem* system READ system WRITE setSystem NOTIFY systemChanged)-
65 Q_PROPERTY(QStringList groups READ groups WRITE setGroups NOTIFY groupsChanged)-
66 Q_PROPERTY(QStringList whenCollidingWith READ whenCollidingWith WRITE setWhenCollidingWith NOTIFY whenCollidingWithChanged)-
67 Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)-
68 Q_PROPERTY(bool once READ onceOff WRITE setOnceOff NOTIFY onceChanged)-
69 Q_PROPERTY(QQuickParticleExtruder* shape READ shape WRITE setShape NOTIFY shapeChanged)-
70-
71public:-
72 explicit QQuickParticleAffector(QQuickItem *parent = 0);-
73 virtual void affectSystem(qreal dt);-
74 virtual void reset(QQuickParticleData*);//As some store their own data per particle?-
75 QQuickParticleSystem* system() const-
76 {-
77 return m_system;
never executed: return m_system;
0
78 }-
79-
80 QStringList groups() const-
81 {-
82 return m_groups;
never executed: return m_groups;
0
83 }-
84-
85 bool enabled() const-
86 {-
87 return m_enabled;
never executed: return m_enabled;
0
88 }-
89-
90 bool onceOff() const-
91 {-
92 return m_onceOff;
never executed: return m_onceOff;
0
93 }-
94-
95 QQuickParticleExtruder* shape() const-
96 {-
97 return m_shape;
never executed: return m_shape;
0
98 }-
99-
100 QStringList whenCollidingWith() const-
101 {-
102 return m_whenCollidingWith;
never executed: return m_whenCollidingWith;
0
103 }-
104-
105Q_SIGNALS:-
106-
107 void systemChanged(QQuickParticleSystem* arg);-
108-
109 void groupsChanged(const QStringList &arg);-
110-
111 void enabledChanged(bool arg);-
112-
113 void onceChanged(bool arg);-
114-
115 void shapeChanged(QQuickParticleExtruder* arg);-
116-
117 void affected(qreal x, qreal y);-
118-
119 void whenCollidingWithChanged(const QStringList &arg);-
120-
121public Q_SLOTS:-
122void setSystem(QQuickParticleSystem* arg)-
123{-
124 if (m_system != arg) {
m_system != argDescription
TRUEevaluated 94 times by 11 tests
Evaluated by:
  • tst_examples
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickparticlesystem
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickturbulence
  • tst_qquickwander
FALSEnever evaluated
0-94
125 m_system = arg;-
126 m_system->registerParticleAffector(this);-
127 Q_EMIT systemChanged(arg);-
128 }
executed 94 times by 11 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickparticlesystem
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickturbulence
  • tst_qquickwander
94
129}
executed 94 times by 11 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickage
  • tst_qquickcustomaffector
  • tst_qquickfriction
  • tst_qquickgravity
  • tst_qquickgroupgoal
  • tst_qquickparticlesystem
  • tst_qquickpointattractor
  • tst_qquickspritegoal
  • tst_qquickturbulence
  • tst_qquickwander
94
130-
131void setGroups(const QStringList &arg)-
132{-
133 if (m_groups != arg) {
m_groups != argDescription
TRUEevaluated 26 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickfriction
  • tst_qquickgroupgoal
FALSEnever evaluated
0-26
134 m_groups = arg;-
135 m_updateIntSet = true;-
136 Q_EMIT groupsChanged(arg);-
137 }
executed 26 times by 3 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickfriction
  • tst_qquickgroupgoal
26
138}
executed 26 times by 3 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickfriction
  • tst_qquickgroupgoal
26
139-
140void setEnabled(bool arg)-
141{-
142 if (m_enabled != arg) {
m_enabled != argDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • tst_examples
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_examples
4-12
143 m_enabled = arg;-
144 Q_EMIT enabledChanged(arg);-
145 }
executed 12 times by 1 test: end of block
Executed by:
  • tst_examples
12
146}
executed 16 times by 1 test: end of block
Executed by:
  • tst_examples
16
147-
148void setOnceOff(bool arg)-
149{-
150 if (m_onceOff != arg) {
m_onceOff != argDescription
TRUEevaluated 22 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickage
  • tst_qquickcustomaffector
FALSEevaluated 4 times by 2 tests
Evaluated by:
  • tst_qquickage
  • tst_qquickcustomaffector
4-22
151 m_onceOff = arg;-
152 m_needsReset = true;-
153 Q_EMIT onceChanged(arg);-
154 }
executed 22 times by 3 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickage
  • tst_qquickcustomaffector
22
155}
executed 26 times by 3 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickage
  • tst_qquickcustomaffector
26
156-
157void setShape(QQuickParticleExtruder* arg)-
158{-
159 if (m_shape != arg) {
m_shape != argDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_examples
FALSEnever evaluated
0-2
160 m_shape = arg;-
161 Q_EMIT shapeChanged(arg);-
162 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_examples
2
163}
executed 2 times by 1 test: end of block
Executed by:
  • tst_examples
2
164-
165void setWhenCollidingWith(const QStringList &arg)-
166{-
167 if (m_whenCollidingWith != arg) {
m_whenCollidingWith != argDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_examples
FALSEnever evaluated
0-2
168 m_whenCollidingWith = arg;-
169 Q_EMIT whenCollidingWithChanged(arg);-
170 }
executed 2 times by 1 test: end of block
Executed by:
  • tst_examples
2
171}
executed 2 times by 1 test: end of block
Executed by:
  • tst_examples
2
172public Q_SLOTS:-
173 void updateOffsets();-
174-
175protected:-
176 friend class QQuickParticleSystem;-
177 virtual bool affectParticle(QQuickParticleData *d, qreal dt);-
178 bool m_needsReset:1;//### What is this really saving?-
179 bool m_ignoresTime:1;-
180 bool m_onceOff:1;-
181 bool m_enabled:1;-
182-
183 QQuickParticleSystem* m_system;-
184 QStringList m_groups;-
185 bool activeGroup(int g);-
186 bool shouldAffect(QQuickParticleData* datum);//Call to do the logic on whether it is affecting that datum-
187 void postAffect(QQuickParticleData* datum);//Call to do the post-affect logic on particles which WERE affected(once off, needs reset, affected signal)-
188 void componentComplete() override;-
189 bool isAffectedConnected();-
190 static const qreal simulationDelta;-
191 static const qreal simulationCutoff;-
192-
193 QPointF m_offset;-
194 QSet<QPair<int, int> > m_onceOffed;-
195private:-
196 QSet<int> m_groupIds;-
197 bool m_updateIntSet;-
198-
199 QQuickParticleExtruder* m_shape;-
200-
201 QStringList m_whenCollidingWith;-
202-
203 bool isColliding(QQuickParticleData* d) const;-
204};-
205-
206QT_END_NAMESPACE-
207#endif // PARTICLEAFFECTOR_H-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0