OpenCoverage

qquickangledirection.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/particles/qquickangledirection.cpp
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#include "qquickangledirection_p.h"-
41#include <QRandomGenerator>-
42#include <qmath.h>-
43-
44QT_BEGIN_NAMESPACE-
45const qreal CONV = 0.017453292519943295;-
46/*!-
47 \qmltype AngleDirection-
48 \instantiates QQuickAngleDirection-
49 \inqmlmodule QtQuick.Particles-
50 \ingroup qtquick-particles-
51 \inherits Direction-
52 \brief For specifying a direction that varies in angle.-
53-
54 The AngledDirection element allows both the specification of a direction by angle and magnitude,-
55 as well as varying the parameters by angle or magnitude.-
56*/-
57/*!-
58 \qmlproperty real QtQuick.Particles::AngleDirection::angle-
59 This property specifies the base angle for the direction.-
60 The angle of this direction will vary by no more than angleVariation-
61 from this angle.-
62-
63 Angle is specified by degrees clockwise from straight right.-
64-
65 The default value is zero.-
66*/-
67/*!-
68 \qmlproperty real QtQuick.Particles::AngleDirection::magnitude-
69 This property specifies the base magnitude for the direction.-
70 The magnitude of this direction will vary by no more than magnitudeVariation-
71 from this magnitude.-
72-
73 Magnitude is specified in units of pixels per second.-
74-
75 The default value is zero.-
76*/-
77/*!-
78 \qmlproperty real QtQuick.Particles::AngleDirection::angleVariation-
79 This property specifies the maximum angle variation for the direction.-
80 The angle of the direction will vary by up to angleVariation clockwise-
81 and anticlockwise from the value specified in angle.-
82-
83 Angle is specified by degrees clockwise from straight right.-
84-
85 The default value is zero.-
86*/-
87/*!-
88 \qmlproperty real QtQuick.Particles::AngleDirection::magnitudeVariation-
89 This property specifies the base magnitude for the direction.-
90 The magnitude of this direction will vary by no more than magnitudeVariation-
91 from the base magnitude.-
92-
93 Magnitude is specified in units of pixels per second.-
94-
95 The default value is zero.-
96*/-
97QQuickAngleDirection::QQuickAngleDirection(QObject *parent) :-
98 QQuickDirection(parent)-
99 , m_angle(0)-
100 , m_magnitude(0)-
101 , m_angleVariation(0)-
102 , m_magnitudeVariation(0)-
103{-
104-
105}
executed 84 times by 3 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickangleddirection
  • tst_qquickcumulativedirection
84
106-
107QPointF QQuickAngleDirection::sample(const QPointF &from)-
108{-
109 Q_UNUSED(from);-
110 QPointF ret;-
111 qreal theta = m_angle*CONV - m_angleVariation*CONV + QRandomGenerator::global()->generateDouble() * m_angleVariation*CONV * 2;-
112 qreal mag = m_magnitude- m_magnitudeVariation + QRandomGenerator::global()->generateDouble() * m_magnitudeVariation * 2;-
113 ret.setX(mag * qCos(theta));-
114 ret.setY(mag * qSin(theta));-
115 return ret;
executed 4864 times by 2 tests: return ret;
Executed by:
  • tst_qquickangleddirection
  • tst_qquickcumulativedirection
4864
116}-
117-
118QT_END_NAMESPACE-
119-
120#include "moc_qquickangledirection_p.cpp"-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0