Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qgeocameradata.cpp
Go to the documentation of this file.
1
// Copyright (C) 2015 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
// Qt-Security score:significant reason:default
4
5
#
include
"qgeocameradata_p.h"
6
7
#
include
<
QtCore
/
QVariant
>
8
#
include
<
QtCore
/
QVariantAnimation
>
9
10
#
include
<
QtPositioning
/
private
/
qgeocoordinate_p
.
h
>
11
#
include
<
QtPositioning
/
private
/
qwebmercator_p
.
h
>
12
13
QT_BEGIN_NAMESPACE
14
15
class
QGeoCameraDataPrivate :
public
QSharedData
16
{
17
public
:
18
bool
operator==(
const
QGeoCameraDataPrivate &rhs)
const
noexcept
;
19
20
QGeoCoordinate m_center = {0, 0};
21
double
m_bearing = 0.0;
22
double
m_tilt = 0.0;
23
double
m_roll = 0.0;
24
double
m_fieldOfView = 45.0;
25
double
m_zoomLevel = 0.0;
26
};
27
28
QT_DEFINE_QSDP_SPECIALIZATION_DTOR(QGeoCameraDataPrivate)
29
30
bool
QGeoCameraDataPrivate::operator==(
const
QGeoCameraDataPrivate &rhs)
const
noexcept
31
{
32
return
((m_center == rhs.m_center)
33
&& (m_bearing == rhs.m_bearing)
34
&& (m_tilt == rhs.m_tilt)
35
&& (m_roll == rhs.m_roll)
36
&& (m_fieldOfView == rhs.m_fieldOfView)
37
&& (m_zoomLevel == rhs.m_zoomLevel));
38
}
39
40
QVariant
cameraInterpolator
(
const
QGeoCameraData &start,
41
const
QGeoCameraData &end,
42
qreal progress)
43
{
44
QGeoCameraData
result = start;
45
QGeoCoordinate from = start.center();
46
QGeoCoordinate to = end.center();
47
48
if
(from == to) {
49
if
(progress < 0.5) {
50
result.setCenter(from);
51
}
else
{
52
result.setCenter(to);
53
}
54
}
55
else
{
56
QGeoCoordinate coordinateResult = QWebMercator::coordinateInterpolation(from, to, progress);
57
result.setCenter(coordinateResult);
58
}
59
60
double
sf = 1.0 - progress;
61
double
ef = progress;
62
63
result.setBearing(sf * start.bearing() + ef * end.bearing());
64
result.setTilt(sf * start.tilt() + ef * end.tilt());
65
result.setRoll(sf * start.roll() + ef * end.roll());
66
result.setFieldOfView(sf * start.fieldOfView() + ef * end.fieldOfView());
67
result.setZoomLevel(sf * start.zoomLevel() + ef * end.zoomLevel());
68
69
return
QVariant::fromValue(result);
70
}
71
72
QGeoCameraData::QGeoCameraData()
73
: d(
new
QGeoCameraDataPrivate())
74
{
75
qRegisterMetaType<QGeoCameraData>();
76
qRegisterAnimationInterpolator<QGeoCameraData>(cameraInterpolator);
77
}
78
79
QGeoCameraData::QGeoCameraData(
const
QGeoCameraData &other)
noexcept
=
default
;
80
81
QGeoCameraData::~QGeoCameraData() =
default
;
82
83
QGeoCameraData &QGeoCameraData::operator=(
const
QGeoCameraData &other)
noexcept
84
{
85
if
(
this
== &other)
86
return
*
this
;
87
88
d = other.d;
89
return
*
this
;
90
}
91
92
bool
QGeoCameraData::isEqual(
const
QGeoCameraData &other)
const
93
{
94
return
(*(d.constData()) == *(other.d.constData()));
95
}
96
97
void
QGeoCameraData::setCenter(
const
QGeoCoordinate ¢er)
98
{
99
d->m_center = center;
100
}
101
102
QGeoCoordinate QGeoCameraData::center()
const
103
{
104
return
d->m_center;
105
}
106
107
void
QGeoCameraData::setBearing(
double
bearing)
108
{
109
d->m_bearing = bearing;
110
}
111
112
double
QGeoCameraData::bearing()
const
113
{
114
return
d->m_bearing;
115
}
116
117
void
QGeoCameraData::setTilt(
double
tilt)
118
{
119
d->m_tilt = tilt;
120
}
121
122
double
QGeoCameraData::tilt()
const
123
{
124
return
d->m_tilt;
125
}
126
127
void
QGeoCameraData::setRoll(
double
roll)
128
{
129
d->m_roll = roll;
130
}
131
132
double
QGeoCameraData::roll()
const
133
{
134
return
d->m_roll;
135
}
136
137
void
QGeoCameraData::setFieldOfView(
double
fieldOfView)
138
{
139
d->m_fieldOfView = fieldOfView;
140
}
141
142
double
QGeoCameraData::fieldOfView()
const
143
{
144
return
d->m_fieldOfView;
145
}
146
147
void
QGeoCameraData::setZoomLevel(
double
zoomFactor)
148
{
149
d->m_zoomLevel = zoomFactor;
150
}
151
152
double
QGeoCameraData::zoomLevel()
const
153
{
154
return
d->m_zoomLevel;
155
}
156
157
QT_END_NAMESPACE
QGeoCameraData
Definition
qgeocameradata_p.h:30
cameraInterpolator
QVariant cameraInterpolator(const QGeoCameraData &start, const QGeoCameraData &end, qreal progress)
Definition
qgeocameradata.cpp:40
qtlocation
src
location
maps
qgeocameradata.cpp
Generated on
for Qt by
1.18.0