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
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
5
6#include <QSharedData>
7#include <cmath>
8
9static double zoomLevelTo256(double zoomLevelForTileSize, double tileSize)
10{
11 return std::log(std::pow(2.0, zoomLevelForTileSize) * tileSize / 256.0) * (1.0 / std::log(2.0));
12}
13
15
17{
18public:
19 bool operator==(const QGeoCameraCapabilitiesPrivate &rhs) const noexcept;
20
21 bool supportsBearing_ = false;
22 bool supportsRolling_ = false;
23 bool supportsTilting_ = false;
24
25 // this is mutable so that it can be set from accessor functions that are const
26 // TODO: remove the mutable here
27 mutable bool valid_ = false;
28
29 double minZoom_ = 0.0;
30 double maxZoom_ = 0.0;
31 double minTilt_ = 0.0;
32 double maxTilt_ = 0.0;
33 int tileSize_ = 256;
34 double minimumFieldOfView_ = 45.0; // Defaulting to a fixed FOV of 45 degrees.
35 double maximumFieldOfView_ = 45.0; // Too large FOVs cause the loading of too many tiles.
36 bool overzoomEnabled_ = false;
37};
38
40
41bool QGeoCameraCapabilitiesPrivate::operator==(const QGeoCameraCapabilitiesPrivate &rhs) const noexcept
42{
43 return ((supportsBearing_ == rhs.supportsBearing_)
44 && (supportsRolling_ == rhs.supportsRolling_)
45 && (supportsTilting_ == rhs.supportsTilting_)
46 && (valid_ == rhs.valid_)
47 && (minZoom_ == rhs.minZoom_)
48 && (maxZoom_ == rhs.maxZoom_)
49 && (minTilt_ == rhs.minTilt_)
50 && (maxTilt_ == rhs.maxTilt_)
51 && (tileSize_ == rhs.tileSize_)
52 && (minimumFieldOfView_ == rhs.minimumFieldOfView_)
53 && (maximumFieldOfView_ == rhs.maximumFieldOfView_)
54 && (overzoomEnabled_ == rhs.overzoomEnabled_));
55}
56
90
95
100
106{
107 if (this == &other)
108 return *this;
109
110 d = other.d;
111 return *this;
112}
113
114bool QGeoCameraCapabilities::isEqual(const QGeoCameraCapabilities &other) const
115{
116 return (*(d.constData()) == *(other.d.constData()));
117}
118
120{
121 if (tileSize < 1)
122 return;
123 d->tileSize_ = tileSize;
124}
125
127{
128 return d->tileSize_;
129}
130
138{
139 return d->valid_;
140}
141
156{
158 d->valid_ = true;
159}
160
162{
163 return d->minZoom_;
164}
165
167{
168 if (d->tileSize_ == 256)
169 return d->minZoom_;
170 return qMax<double>(0, zoomLevelTo256(d->minZoom_, d->tileSize_));
171}
172
187{
189 d->valid_ = true;
190}
191
193{
194 return d->maxZoom_;
195}
196
198{
199 if (d->tileSize_ == 256)
200 return d->maxZoom_;
201 return qMax<double>(0, zoomLevelTo256(d->maxZoom_, d->tileSize_));
202}
203
209{
211 d->valid_ = true;
212}
213
219{
220 return d->supportsBearing_;
221}
222
228{
230 d->valid_ = true;
231}
232
238{
239 return d->supportsRolling_;
240}
241
247{
249 d->valid_ = true;
250}
251
257{
258 return d->supportsTilting_;
259}
260
275{
277 d->valid_ = true;
278}
279
281{
282 return d->minTilt_;
283}
284
299{
301 d->valid_ = true;
302}
303
305{
306 return d->maxTilt_;
307}
308
324{
326 d->valid_ = true;
327}
328
333
349{
351 d->valid_ = true;
352}
353
358
373{
375 d->valid_ = true;
376}
377
384{
385 return d->overzoomEnabled_;
386}
387
388
390
391#include "moc_qgeocameracapabilities_p.cpp"
bool operator==(const QGeoCameraCapabilitiesPrivate &rhs) const noexcept
void setSupportsBearing(bool supportsBearing)
Sets whether the associated plugin can render a map when the camera has an arbitrary bearing to suppo...
qreal maximumTilt
\qmlproperty qreal cameraCapabilities::maximumTilt
void setMaximumZoomLevel(double maximumZoomLevel)
bool overzoomEnabled() const
Returns whether overzooming is supported by the associated plugin.
bool supportsBearing() const
Returns whether the associated plugin can render a map when the camera has an arbitrary bearing.
qreal minimumZoomLevel
\qmlproperty qreal cameraCapabilities::minimumZoomLevel
QGeoCameraCapabilities & operator=(const QGeoCameraCapabilities &other) noexcept
Assigns the contents of other to this camera capabilities object and returns a reference to this came...
void setMaximumTilt(double maximumTilt)
QGeoCameraCapabilities()
\qmlvaluetype cameraCapabilities \inqmlmodule QtLocation
qreal maximumZoomLevel
\qmlproperty qreal cameraCapabilities::maximumZoomLevel
void setSupportsRolling(bool supportsRolling)
Sets whether the associated plugin can render a map when the camera is rolled to supportsRolling.
~QGeoCameraCapabilities()
Destroys this camera capabilities object.
void setMaximumFieldOfView(double maximumFieldOfView)
void setMinimumFieldOfView(double minimumFieldOfView)
void setOverzoomEnabled(bool overzoomEnabled)
Sets whether overzooming is supported by the associated plugin.
void setMinimumTilt(double minimumTilt)
bool supportsRolling() const
Returns whether the associated plugin can render a map when the camera is rolled.
void setMinimumZoomLevel(double minimumZoomLevel)
qreal maximumFieldOfView
\qmlproperty qreal cameraCapabilities::maximumFieldOfView
qreal minimumTilt
\qmlproperty qreal cameraCapabilities::minimumTilt
bool supportsTilting() const
Returns whether the associated plugin can render a map when the camera is tilted.
void setSupportsTilting(bool supportsTilting)
Sets whether the associated plugin can render a map when the camera is tilted to supportsTilting.
qreal minimumFieldOfView
\qmlproperty qreal cameraCapabilities::minimumFieldOfView
bool isValid() const
Returns whether this instance of the class is considered "valid".
const T * constData() const noexcept
Returns a const pointer to the shared data object.
Definition qshareddata.h:51
\inmodule QtCore
Definition qshareddata.h:19
Combined button and popup list for selecting options.
static double zoomLevelTo256(double zoomLevelForTileSize, double tileSize)
static QT_BEGIN_NAMESPACE const int tileSize
Definition qmemrotate.cpp:9
constexpr const T & qBound(const T &min, const T &val, const T &max)
Definition qminmax.h:44
#define QT_DEFINE_QSDP_SPECIALIZATION_DTOR(Class)
QSharedPointer< T > other(t)
[5]