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
qquickpathinterpolator.cpp
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
5
6#include "qquickpath_p.h"
7
9
26 QObject(parent), _path(nullptr), _x(0), _y(0), _angle(0), _progress(0)
27{
28}
29
37{
38 return _path;
39}
40
42{
43 if (_path == path)
44 return;
45 if (_path)
46 disconnect(_path, SIGNAL(changed()), this, SLOT(_q_pathUpdated()));
47 _path = path;
48 connect(_path, SIGNAL(changed()), this, SLOT(_q_pathUpdated()));
50}
51
63{
64 return _progress;
65}
66
68{
69 progress = qMin(qMax(progress, (qreal)0.0), (qreal)1.0);
70
71 if (progress == _progress)
72 return;
73 _progress = progress;
75 _q_pathUpdated();
76}
77
85{
86 return _x;
87}
88
90{
91 return _y;
92}
93
102{
103 return _angle;
104}
105
106void QQuickPathInterpolator::_q_pathUpdated()
107{
108 if (! _path)
109 return;
110
111 qreal angle = 0;
112 const QPointF pt = _path->sequentialPointAt(_progress, &angle);
113
114 if (_x != pt.x()) {
115 _x = pt.x();
116 emit xChanged();
117 }
118
119 if (_y != pt.y()) {
120 _y = pt.y();
121 emit yChanged();
122 }
123
124 //convert to clockwise
125 angle = qreal(360) - angle;
126 if (qFuzzyCompare(angle, qreal(360)))
127 angle = qreal(0);
128
129 if (angle != _angle) {
130 _angle = angle;
132 }
133}
134
136
137#include "moc_qquickpathinterpolator_p.cpp"
\inmodule QtCore
Definition qobject.h:103
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
\inmodule QtCore\reentrant
Definition qpoint.h:217
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
Definition qpoint.h:343
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
Definition qpoint.h:348
QQuickPathInterpolator(QObject *parent=nullptr)
\qmltype PathInterpolator \instantiates QQuickPathInterpolator \inqmlmodule QtQuick
void setProgress(qreal progress)
void setPath(QQuickPath *path)
QPointF sequentialPointAt(qreal p, qreal *angle=nullptr) const
Combined button and popup list for selecting options.
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
Definition qfloat16.h:333
constexpr const T & qMin(const T &a, const T &b)
Definition qminmax.h:40
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
#define SLOT(a)
Definition qobjectdefs.h:52
#define SIGNAL(a)
Definition qobjectdefs.h:53
GLfloat angle
GLsizei const GLchar *const * path
#define emit
double qreal
Definition qtypes.h:187
QObject::connect nullptr
myObject disconnect()
[26]