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
qgeocameracapabilities.cpp
Go to the documentation of this file.
1
// Copyright (C) 2022 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
"qgeocameracapabilities_p.h"
6
7
#
include
<
QSharedData
>
8
#
include
<
cmath
>
9
10
static
double
zoomLevelTo256
(
double
zoomLevelForTileSize,
double
tileSize)
11
{
12
return
std
::log(
std
::pow(2.0, zoomLevelForTileSize) * tileSize / 256.0) * (1.0 /
std
::log(2.0));
13
}
14
15
QT_BEGIN_NAMESPACE
16
17
class
QGeoCameraCapabilitiesPrivate :
public
QSharedData
18
{
19
public
:
20
bool
operator==(
const
QGeoCameraCapabilitiesPrivate &rhs)
const
noexcept
;
21
22
bool
supportsBearing_ =
false
;
23
bool
supportsRolling_ =
false
;
24
bool
supportsTilting_ =
false
;
25
26
// this is mutable so that it can be set from accessor functions that are const
27
// TODO: remove the mutable here
28
mutable
bool
valid_ =
false
;
29
30
double
minZoom_ = 0.0;
31
double
maxZoom_ = 0.0;
32
double
minTilt_ = 0.0;
33
double
maxTilt_ = 0.0;
34
int
tileSize_ = 256;
35
double
minimumFieldOfView_ = 45.0;
// Defaulting to a fixed FOV of 45 degrees.
36
double
maximumFieldOfView_ = 45.0;
// Too large FOVs cause the loading of too many tiles.
37
bool
overzoomEnabled_ =
false
;
38
};
39
40
QT_DEFINE_QSDP_SPECIALIZATION_DTOR(QGeoCameraCapabilitiesPrivate)
41
42
bool
QGeoCameraCapabilitiesPrivate::operator==(
const
QGeoCameraCapabilitiesPrivate &rhs)
const
noexcept
43
{
44
return
((supportsBearing_ == rhs.supportsBearing_)
45
&& (supportsRolling_ == rhs.supportsRolling_)
46
&& (supportsTilting_ == rhs.supportsTilting_)
47
&& (valid_ == rhs.valid_)
48
&& (minZoom_ == rhs.minZoom_)
49
&& (maxZoom_ == rhs.maxZoom_)
50
&& (minTilt_ == rhs.minTilt_)
51
&& (maxTilt_ == rhs.maxTilt_)
52
&& (tileSize_ == rhs.tileSize_)
53
&& (minimumFieldOfView_ == rhs.minimumFieldOfView_)
54
&& (maximumFieldOfView_ == rhs.maximumFieldOfView_)
55
&& (overzoomEnabled_ == rhs.overzoomEnabled_));
56
}
57
58
/*!
59
\class QGeoCameraCapabilities
60
\inmodule QtLocation
61
\ingroup QtLocation-impl
62
\since 5.6
63
\internal
64
65
\brief The QGeoCameraCapabilities class describes the limitations on camera settings imposed by a mapping plugin.
66
67
Different mapping plugins will support different ranges of zoom levels, and not all mapping plugins will
68
be able to support, bearing, tilting and rolling of the camera.
69
70
This class describes what the plugin supports, and is used to restrict changes to the camera information
71
associated with a \l QGeoMap such that the camera information stays within these limits.
72
*/
73
74
/*!
75
\qmlvaluetype cameraCapabilities
76
\inqmlmodule QtLocation
77
\ingroup qml-QtLocation5-maps
78
\since QtLocation 5.10
79
80
\brief The cameraCapabilities type holds information about the camera capabilities for a specific map type.
81
82
This includes the map minimum and maximum zoom level, minimum and maximum tilt angle and
83
minimum and maximum field of view.
84
*/
85
86
/*!
87
Constructs a camera capabilities object.
88
*/
89
QGeoCameraCapabilities::QGeoCameraCapabilities()
90
: d(
new
QGeoCameraCapabilitiesPrivate()) {}
91
92
/*!
93
Constructs a camera capabilities object from the contents of \a other.
94
*/
95
QGeoCameraCapabilities::QGeoCameraCapabilities(
const
QGeoCameraCapabilities &other)
noexcept
=
default
;
96
97
/*!
98
Destroys this camera capabilities object.
99
*/
100
QGeoCameraCapabilities::~QGeoCameraCapabilities() =
default
;
101
102
/*!
103
Assigns the contents of \a other to this camera capabilities object and
104
returns a reference to this camera capabilities object.
105
*/
106
QGeoCameraCapabilities &QGeoCameraCapabilities::operator=(
const
QGeoCameraCapabilities &other)
noexcept
107
{
108
if
(
this
== &other)
109
return
*
this
;
110
111
d = other.d;
112
return
*
this
;
113
}
114
115
bool
QGeoCameraCapabilities::isEqual(
const
QGeoCameraCapabilities &other)
const
116
{
117
return
(*(d.constData()) == *(other.d.constData()));
118
}
119
120
void
QGeoCameraCapabilities::setTileSize(
int
tileSize)
121
{
122
if
(tileSize < 1)
123
return
;
124
d->tileSize_ = tileSize;
125
}
126
127
int
QGeoCameraCapabilities::tileSize()
const
128
{
129
return
d->tileSize_;
130
}
131
132
/*!
133
Returns whether this instance of the class is considered "valid". To be
134
valid, the instance must have had at least one capability set (to either
135
true or false) using a set method, or copied from another instance
136
(such as by the assignment operator).
137
*/
138
bool
QGeoCameraCapabilities::isValid()
const
139
{
140
return
d->valid_;
141
}
142
143
/*!
144
\qmlproperty real cameraCapabilities::minimumZoomLevel
145
146
This read-only property holds the minimum available zoom level with this map type.
147
*/
148
149
/*!
150
\property QGeoCameraCapabilities::minimumZoomLevel
151
\brief the minimum zoom level supported by the associated plugin.
152
153
Larger values of the zoom level correspond to more detailed views of the
154
map.
155
*/
156
void
QGeoCameraCapabilities::setMinimumZoomLevel(
double
minimumZoomLevel)
157
{
158
d->minZoom_ = minimumZoomLevel;
159
d->valid_ =
true
;
160
}
161
162
double
QGeoCameraCapabilities::minimumZoomLevel()
const
163
{
164
return
d->minZoom_;
165
}
166
167
double
QGeoCameraCapabilities::minimumZoomLevelAt256()
const
168
{
169
if
(d->tileSize_ == 256)
170
return
d->minZoom_;
171
return
qMax<
double
>(0, zoomLevelTo256(d->minZoom_, d->tileSize_));
172
}
173
174
/*!
175
\qmlproperty real cameraCapabilities::maximumZoomLevel
176
177
This read-only property holds the maximum available zoom level with this map type.
178
*/
179
180
/*!
181
\property QGeoCameraCapabilities::maximumZoomLevel
182
\brief the maximum zoom level supported by the associated plugin.
183
184
Larger values of the zoom level correspond to more detailed views of the
185
map.
186
*/
187
void
QGeoCameraCapabilities::setMaximumZoomLevel(
double
maximumZoomLevel)
188
{
189
d->maxZoom_ = maximumZoomLevel;
190
d->valid_ =
true
;
191
}
192
193
double
QGeoCameraCapabilities::maximumZoomLevel()
const
194
{
195
return
d->maxZoom_;
196
}
197
198
double
QGeoCameraCapabilities::maximumZoomLevelAt256()
const
199
{
200
if
(d->tileSize_ == 256)
201
return
d->maxZoom_;
202
return
qMax<
double
>(0, zoomLevelTo256(d->maxZoom_, d->tileSize_));
203
}
204
205
/*!
206
Sets whether the associated plugin can render a map when the camera
207
has an arbitrary bearing to \a supportsBearing.
208
*/
209
void
QGeoCameraCapabilities::setSupportsBearing(
bool
supportsBearing)
210
{
211
d->supportsBearing_ = supportsBearing;
212
d->valid_ =
true
;
213
}
214
215
/*!
216
Returns whether the associated plugin can render a map when the camera
217
has an arbitrary bearing.
218
*/
219
bool
QGeoCameraCapabilities::supportsBearing()
const
220
{
221
return
d->supportsBearing_;
222
}
223
224
/*!
225
Sets whether the associated plugin can render a map when the
226
camera is rolled to \a supportsRolling.
227
*/
228
void
QGeoCameraCapabilities::setSupportsRolling(
bool
supportsRolling)
229
{
230
d->supportsRolling_ = supportsRolling;
231
d->valid_ =
true
;
232
}
233
234
/*!
235
Returns whether the associated plugin can render a map when the
236
camera is rolled.
237
*/
238
bool
QGeoCameraCapabilities::supportsRolling()
const
239
{
240
return
d->supportsRolling_;
241
}
242
243
/*!
244
Sets whether the associated plugin can render a map when the
245
camera is tilted to \a supportsTilting.
246
*/
247
void
QGeoCameraCapabilities::setSupportsTilting(
bool
supportsTilting)
248
{
249
d->supportsTilting_ = supportsTilting;
250
d->valid_ =
true
;
251
}
252
253
/*!
254
Returns whether the associated plugin can render a map when the
255
camera is tilted.
256
*/
257
bool
QGeoCameraCapabilities::supportsTilting()
const
258
{
259
return
d->supportsTilting_;
260
}
261
262
/*!
263
\qmlproperty real cameraCapabilities::minimumTilt
264
265
This read-only property holds the minimum available tilt with this map type.
266
*/
267
268
/*!
269
\property QGeoCameraCapabilities::minimumTilt
270
\brief the minimum tilt supported by the associated plugin.
271
272
The value is in degrees where 0 is equivalent to 90 degrees between
273
the line of view and earth's surface, that is, looking straight down to earth.
274
*/
275
void
QGeoCameraCapabilities::setMinimumTilt(
double
minimumTilt)
276
{
277
d->minTilt_ = minimumTilt;
278
d->valid_ =
true
;
279
}
280
281
double
QGeoCameraCapabilities::minimumTilt()
const
282
{
283
return
d->minTilt_;
284
}
285
286
/*!
287
\qmlproperty real cameraCapabilities::maximumTilt
288
289
This read-only property holds the maximum available tilt with this map type.
290
*/
291
292
/*!
293
\property QGeoCameraCapabilities::maximumTilt
294
\brief the maximum tilt supported by the associated plugin.
295
296
The value is in degrees where 0 is equivalent to 90 degrees between
297
the line of view and earth's surface, that is, looking straight down to earth.
298
*/
299
void
QGeoCameraCapabilities::setMaximumTilt(
double
maximumTilt)
300
{
301
d->maxTilt_ = maximumTilt;
302
d->valid_ =
true
;
303
}
304
305
double
QGeoCameraCapabilities::maximumTilt()
const
306
{
307
return
d->maxTilt_;
308
}
309
310
/*!
311
\qmlproperty real cameraCapabilities::minimumFieldOfView
312
313
This read-only property holds the minimum available field of view with this map type.
314
*/
315
316
/*!
317
\property QGeoCameraCapabilities::minimumFieldOfView
318
\brief the minimum field of view supported by the associated plugin.
319
320
The value is in degrees and is clamped against a [1, 179] range.
321
322
\since 5.9
323
*/
324
void
QGeoCameraCapabilities::setMinimumFieldOfView(
double
minimumFieldOfView)
325
{
326
d->minimumFieldOfView_ = qBound(1.0, minimumFieldOfView, 179.0);
327
d->valid_ =
true
;
328
}
329
330
double
QGeoCameraCapabilities::minimumFieldOfView()
const
331
{
332
return
d->minimumFieldOfView_;
333
}
334
335
/*!
336
\qmlproperty real cameraCapabilities::maximumFieldOfView
337
338
This read-only property holds the maximum available field of view with this map type.
339
*/
340
341
/*!
342
\property QGeoCameraCapabilities::maximumFieldOfView
343
\brief the maximum field of view supported by the associated plugin.
344
345
The value is in degrees and is clamped against a [1, 179] range.
346
347
\since 5.9
348
*/
349
void
QGeoCameraCapabilities::setMaximumFieldOfView(
double
maximumFieldOfView)
350
{
351
d->maximumFieldOfView_ = qBound(1.0, maximumFieldOfView, 179.0);
352
d->valid_ =
true
;
353
}
354
355
double
QGeoCameraCapabilities::maximumFieldOfView()
const
356
{
357
return
d->maximumFieldOfView_;
358
}
359
360
/*!
361
Sets whether overzooming is supported by the associated plugin.
362
363
Overzooming means that zoom levels outside the [minimumZL, maximumZL] range can be set,
364
and if tiles aren't available for those zoom levels, either tiles from other zoom levels
365
will be used, or nothing will be shown.
366
367
Set this value to false if the plugin is not capable of that. For example if using
368
a mapping engine that always clamp the zoomLevel value, which may cause misalignment in case
369
of stacked map elements.
370
371
\since 5.9
372
*/
373
void
QGeoCameraCapabilities::setOverzoomEnabled(
bool
overzoomEnabled)
374
{
375
d->overzoomEnabled_ = overzoomEnabled;
376
d->valid_ =
true
;
377
}
378
379
/*!
380
Returns whether overzooming is supported by the associated plugin.
381
382
\since 5.9
383
*/
384
bool
QGeoCameraCapabilities::overzoomEnabled()
const
385
{
386
return
d->overzoomEnabled_;
387
}
388
389
390
QT_END_NAMESPACE
391
392
#
include
"moc_qgeocameracapabilities_p.cpp"
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
zoomLevelTo256
static double zoomLevelTo256(double zoomLevelForTileSize, double tileSize)
Definition
qgeocameracapabilities.cpp:10
qtlocation
src
location
maps
qgeocameracapabilities.cpp
Generated on
for Qt by
1.18.0