11#include <QtQuick/QQuickWindow>
12#include <QtGui/QVector3D>
14#include <QtCore/private/qobject_p.h>
15#include <QtPositioning/private/qdoublevector3d_p.h>
16#include <QtPositioning/private/qlocationutils_p.h>
17#include <QtPositioning/private/qdoublematrix4x4_p.h>
18#include <QtPositioning/private/qwebmercator_p.h>
41 d->m_screenSize =
size;
44void QGeoTiledMapScene::updateSceneParameters()
47 d->m_intZoomLevel =
static_cast<int>(std::floor(
d->m_cameraData.zoomLevel()));
48 const float delta =
d->m_cameraData.zoomLevel() -
d->m_intZoomLevel;
49 d->m_linearScaling =
qAbs(delta) > 0.05 ||
d->isTiltedOrRotated();
50 d->m_sideLength = 1 <<
d->m_intZoomLevel;
60 updateSceneParameters();
66 d->m_cameraData = cameraData;
67 updateSceneParameters();
73 if (
d->m_visibleArea == visibleArea)
75 d->m_visibleArea = visibleArea;
76 updateSceneParameters();
82 d->setVisibleTiles(tiles);
88 return d->m_visibleTiles;
101 for (
auto it =
d->m_textures.cbegin();
it !=
d->m_textures.cend(); ++
it)
102 textured +=
it.value()->spec;
110 d->m_textures.clear();
111 d->m_dropTextures =
true;
142 double x2 =
x1 + 1.0;
145 double y2 =
y1 - 1.0;
158 if (
it.value()->spec.zoom() < spec.
zoom()) {
160 const int tilesPerTexture = 1 << (spec.
zoom() -
it.value()->spec.zoom());
162 const int x = (spec.
x() % tilesPerTexture) * mappedSize;
163 const int y = (spec.
y() % tilesPerTexture) * mappedSize;
170 qWarning() <<
"!! buildGeometry: tileSpec not present in m_textures !!";
208 for (;
i !=
end; ++
i) {
230 bool hasFarLeft =
false;
231 bool hasFarRight =
false;
232 bool hasMidLeft =
false;
233 bool hasMidRight =
false;
235 for (;
i !=
end; ++
i) {
254 if (hasFarLeft && hasFarRight) {
257 }
else if (!hasMidLeft) {
278 for (;
i !=
end; ++
i) {
306 double altitude =
f / (2.0 *
z);
327 double apertureSize = 1.0;
331 eye.
setZ(altitude * edge / apertureSize);
350 eye = mTilt *
view + center;
364 double nearPlane = 1.0;
369 double farPlane = (altitude + 10000.0) * edge;
376 float halfWidth = 1 * apertureSize;
377 float halfHeight = 1 * apertureSize;
378 halfWidth *= aspectRatio;
391 QPointF diff = screenCenter - vaCenter;
396 float l = -halfWidth + (2 * halfWidth) * xdiffpct;
397 float r = halfWidth + (2 * halfWidth) * xdiffpct;
398 float t = halfHeight + (2 * halfHeight) * ydiffpct;
399 float b = -halfHeight + (2 * halfHeight) * ydiffpct;
405 nearPlane, farPlane);
444 eye.
setX(eye.
x() + camAdjust);
446 center.setX(center.x() + camAdjust);
458 delete root->tiles.take(
s);
459 bool straight = !
d->isTiltedOrRotated();
461 qreal pixelRatio =
window->effectiveDevicePixelRatio();
462#ifdef QT_LOCATION_DEBUG
466 it !=
root->tiles.end(); ) {
468 bool ok =
d->buildGeometry(
it.key(), node, overzooming)
471 QSGNode::DirtyState dirtyBits = {};
474#ifdef QT_LOCATION_DEBUG
498#ifdef QT_LOCATION_DEBUG
506 if (
d->buildGeometry(
s, tileNode, overzooming)
514 root->addChild(
s, tileNode);
516#ifdef QT_LOCATION_DEBUG
523#ifdef QT_LOCATION_DEBUG
524 m_droppedTiles[camAdjust] = droppedTiles;
531 float w =
d->m_screenSize.width();
532 float h =
d->m_screenSize.height();
533 if (
w <= 0 ||
h <= 0) {
542#ifdef QT_LOCATION_DEBUG
543 mapRoot->m_droppedTiles.clear();
544 d->m_mapRoot = mapRoot;
551 itemSpaceMatrix.
scale(
w / 2,
h / 2);
553 itemSpaceMatrix.
scale(1, -1);
556 if (
d->m_dropTextures) {
565 d->m_dropTextures =
false;
569 if (
d->m_updatedTextures.size()) {
584 d->m_updatedTextures.clear();
602 double sideLength =
d->m_scaleFactor *
d->m_tileSize *
d->m_sideLength;
603#ifdef QT_LOCATION_DEBUG
604 d->m_sideLengthPixel = sideLength;
void rotate(double angle, const QDoubleVector3D &vector)
Q_DECL_CONSTEXPR double x() const
static QDoubleVector3D normal(const QDoubleVector3D &v1, const QDoubleVector3D &v2)
double fieldOfView() const
QGeoCoordinate center() const
QGeoTiledMapTileContainerNode * wrapRight
QHash< QGeoTileSpec, QSGTexture * > textures
QGeoTiledMapTileContainerNode * wrapLeft
QGeoTiledMapTileContainerNode * tiles
void setClipRect(const QRect &rect)
void updateTiles(QGeoTiledMapTileContainerNode *root, QGeoTiledMapScenePrivate *d, double camAdjust, QQuickWindow *window)
QHash< QGeoTileSpec, QSharedPointer< QGeoTileTexture > > m_textures
bool buildGeometry(const QGeoTileSpec &spec, QSGImageNode *imageNode, bool &overzooming)
QList< QGeoTileSpec > m_updatedTextures
~QGeoTiledMapScenePrivate()
QGeoTiledMapScenePrivate()
QGeoCameraData m_cameraData
QDoubleVector3D m_cameraUp
QDoubleVector3D m_cameraEye
void removeTiles(const QSet< QGeoTileSpec > &oldTiles)
QMatrix4x4 m_projectionMatrix
QDoubleVector3D m_cameraCenter
void updateTileBounds(const QSet< QGeoTileSpec > &tiles)
void addTile(const QGeoTileSpec &spec, QSharedPointer< QGeoTileTexture > texture)
void setVisibleTiles(const QSet< QGeoTileSpec > &visibleTiles)
QSet< QGeoTileSpec > m_visibleTiles
virtual ~QGeoTiledMapScene()
const QSet< QGeoTileSpec > & visibleTiles() const
void setCameraData(const QGeoCameraData &cameraData)
QGeoTiledMapScene(QObject *parent=nullptr)
void setScreenSize(const QSize &size)
void addTile(const QGeoTileSpec &spec, QSharedPointer< QGeoTileTexture > texture)
QSet< QGeoTileSpec > texturedTiles()
void setVisibleTiles(const QSet< QGeoTileSpec > &tiles)
QSGNode * updateSceneGraph(QSGNode *oldNode, QQuickWindow *window)
void setTileSize(int tileSize)
void clearTexturedTiles()
void setVisibleArea(const QRectF &visibleArea)
QHash< QGeoTileSpec, QSGImageNode * > tiles
bool remove(const Key &key)
Removes the item that has the key from the hash.
const_iterator cbegin() const noexcept
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
T take(const Key &key)
Removes the item with the key from the hash and returns the value associated with it.
QList< Key > keys() const
Returns a list containing all the keys in the hash, in an arbitrary order.
bool contains(const Key &key) const noexcept
Returns true if the hash contains an item with the key; otherwise returns false.
iterator end() noexcept
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last ...
const_iterator cend() const noexcept
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
bool isNull() const
Returns true if it is a null image, otherwise returns false.
void append(parameter_type t)
static double radians(double degrees)
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
void frustum(float left, float right, float bottom, float top, float nearPlane, float farPlane)
Multiplies this matrix by another that applies a perspective frustum projection for a window with low...
void lookAt(const QVector3D &eye, const QVector3D ¢er, const QVector3D &up)
Multiplies this matrix by a viewing matrix derived from an eye point.
void scale(const QVector3D &vector)
Multiplies this matrix by another that scales coordinates by the components of vector.
void setToIdentity()
Sets this matrix to the identity.
void translate(const QVector3D &vector)
Multiplies this matrix by another that translates coordinates by the components of vector.
void deleteLater()
\threadsafe
\inmodule QtCore\reentrant
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
\inmodule QtCore\reentrant
constexpr QPointF bottomLeft() const noexcept
Returns the position of the rectangle's bottom-left corner.
bool intersects(const QRectF &r) const noexcept
Returns true if this rectangle intersects with the given rectangle (i.e.
constexpr bool isNull() const noexcept
Returns true if the rectangle is a null rectangle, otherwise returns false.
constexpr QPointF topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
constexpr QPointF center() const noexcept
Returns the center point of the rectangle.
constexpr QPointF bottomRight() const noexcept
Returns the position of the rectangle's bottom-right corner.
constexpr QPointF topRight() const noexcept
Returns the position of the rectangle's top-right corner.
\inmodule QtCore\reentrant
The QSGImageNode class is provided for convenience to easily draw textured content using the QML scen...
virtual void setSourceRect(const QRectF &r)=0
Sets the source rect of this image node to rect.
virtual void setFiltering(QSGTexture::Filtering filtering)=0
Sets the filtering to be used for this image node to filtering.
virtual void setTextureCoordinatesTransform(TextureCoordinatesTransformMode mode)=0
Sets the method used to generate texture coordinates to mode.
virtual QRectF rect() const =0
Returns the target rect of this image node.
virtual void setRect(const QRectF &rect)=0
Sets the target rect of this image node to rect.
virtual QSGTexture * texture() const =0
Returns the texture for this image node.
virtual void setTexture(QSGTexture *texture)=0
Sets the texture of this image node to texture.
virtual void setMipmapFiltering(QSGTexture::Filtering filtering)=0
Sets the mipmap filtering to be used for this image node to filtering.
\group qtquick-scenegraph-nodes \title Qt Quick Scene Graph Node classes
void markDirty(DirtyState bits)
Notifies all connected renderers that the node has dirty bits.
virtual QSize textureSize() const =0
Returns the size of the texture in pixels.
const_iterator constBegin() const noexcept
const_iterator constEnd() const noexcept
bool contains(const T &value) const
iterator insert(const T &value)
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
The QVector3D class represents a vector or vertex in 3D space.
static QDoubleVector2D coordToMercator(const QGeoCoordinate &coord)
QSet< QString >::iterator it
Combined button and popup list for selecting options.
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter * iter
static QVector3D toVector3D(const QDoubleVector3D &in)
static bool qgeotiledmapscene_isTileInViewport_rotationTilt(const QRectF &tileRect, const QMatrix4x4 &matrix)
static bool qgeotiledmapscene_isTileInViewport(const QRectF &tileRect, const QMatrix4x4 &matrix, const bool straight)
static bool qgeotiledmapscene_isTileInViewport_Straight(const QRectF &tileRect, const QMatrix4x4 &matrix)
static QVector3D toVector3D(const QDoubleVector3D &in)
static QT_BEGIN_NAMESPACE const int tileSize
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
constexpr T qAbs(const T &t)
GLboolean GLboolean GLboolean b
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat z
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLuint GLfloat GLfloat GLfloat GLfloat y1
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint const GLuint GLuint const GLuint * textures
GLuint GLfloat GLfloat GLfloat x1
GLfloat GLfloat GLfloat GLfloat h
GLfixed GLfixed GLfixed y2
static const QRectF boundingRect(const QPointF *points, int pointCount)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent