Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qgeotiledmapscene_p_p.h
Go to the documentation of this file.
1// Copyright (C) 2018 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#ifndef QGEOTILEDMAPSCENE_P_P_H
4#define QGEOTILEDMAPSCENE_P_P_H
5
6//
7// W A R N I N G
8// -------------
9//
10// This file is not part of the Qt API. It exists purely as an
11// implementation detail. This header file may change from version to
12// version without notice, or even be removed.
13//
14// We mean it.
15//
16
19#include "qgeotilespec_p.h"
20
21#include <QtQuick/QSGImageNode>
22#include <QtQuick/QQuickWindow>
23
24#include <QtCore/private/qobject_p.h>
25#include <QtPositioning/private/qdoublevector3d_p.h>
26
27QT_BEGIN_NAMESPACE
28
29class Q_LOCATION_EXPORT QGeoTiledMapTileContainerNode : public QSGTransformNode
30{
31public:
32 void addChild(const QGeoTileSpec &spec, QSGImageNode *node)
33 {
34 tiles.insert(spec, node);
35 appendChildNode(node);
36 }
37 QHash<QGeoTileSpec, QSGImageNode *> tiles;
38};
39
40class Q_LOCATION_EXPORT QGeoTiledMapRootNode : public QSGClipNode
41{
42public:
43 QGeoTiledMapRootNode()
44 : isTextureLinear(false)
45 , geometry(QSGGeometry::defaultAttributes_Point2D(), 4)
46 , root(new QSGTransformNode())
47 , tiles(new QGeoTiledMapTileContainerNode())
48 , wrapLeft(new QGeoTiledMapTileContainerNode())
49 , wrapRight(new QGeoTiledMapTileContainerNode())
50 {
51 setIsRectangular(true);
52 setGeometry(&geometry);
53 root->appendChildNode(tiles);
54 root->appendChildNode(wrapLeft);
55 root->appendChildNode(wrapRight);
56 appendChildNode(root);
57 }
58
59 ~QGeoTiledMapRootNode()
60 {
61 qDeleteAll(textures);
62 }
63
64 void setClipRect(const QRect &rect)
65 {
66 if (rect != clipRect) {
67 QSGGeometry::updateRectGeometry(&geometry, rect);
68 QSGClipNode::setClipRect(rect);
69 clipRect = rect;
70 markDirty(DirtyGeometry);
71 }
72 }
73
74 void updateTiles(QGeoTiledMapTileContainerNode *root,
75 QGeoTiledMapScenePrivate *d,
76 double camAdjust,
77 QQuickWindow *window);
78
79 bool isTextureLinear;
80
81 QSGGeometry geometry;
82 QRect clipRect;
83
84 QSGTransformNode *root;
85
86 QGeoTiledMapTileContainerNode *tiles; // The majority of the tiles
87 QGeoTiledMapTileContainerNode *wrapLeft; // When zoomed out, the tiles that wrap around on the left.
88 QGeoTiledMapTileContainerNode *wrapRight; // When zoomed out, the tiles that wrap around on the right
89
90 QHash<QGeoTileSpec, QSGTexture *> textures;
91
92#ifdef QT_LOCATION_DEBUG
93 double m_sideLengthPixel;
94 QMap<double, QList<QGeoTileSpec>> m_droppedTiles;
95#endif
96};
97
98class Q_LOCATION_EXPORT QGeoTiledMapScenePrivate : public QObjectPrivate
99{
100 Q_DECLARE_PUBLIC(QGeoTiledMapScene)
101public:
102 QGeoTiledMapScenePrivate();
103 ~QGeoTiledMapScenePrivate();
104
105 void addTile(const QGeoTileSpec &spec, QSharedPointer<QGeoTileTexture> texture);
106
107 void setVisibleTiles(const QSet<QGeoTileSpec> &visibleTiles);
108 void removeTiles(const QSet<QGeoTileSpec> &oldTiles);
109 bool buildGeometry(const QGeoTileSpec &spec, QSGImageNode *imageNode, bool &overzooming);
110 void updateTileBounds(const QSet<QGeoTileSpec> &tiles);
111 void setupCamera();
112 inline bool isTiltedOrRotated() const { return (m_cameraData.tilt() > 0.0) || (m_cameraData.bearing() > 0.0); }
113
114public:
115
116 QSize m_screenSize; // in pixels
117 int m_tileSize = 0; // the pixel resolution for each tile
118 QGeoCameraData m_cameraData;
119 QRectF m_visibleArea;
120 QSet<QGeoTileSpec> m_visibleTiles;
121
122 QDoubleVector3D m_cameraUp;
123 QDoubleVector3D m_cameraEye;
124 QDoubleVector3D m_cameraCenter;
125 QMatrix4x4 m_projectionMatrix;
126
127 // scales up the tile geometry and the camera altitude, resulting in no visible effect
128 // other than to control the accuracy of the render by keeping the values in a sensible range
129 double m_scaleFactor =
130#ifdef QT_LOCATION_DEBUG
131 1.0;
132#else
133 10.0;
134#endif
135
136 // rounded down, positive zoom is zooming in, corresponding to reduced altitude
137 int m_intZoomLevel = 0;
138
139 // mercatorToGrid transform
140 // the number of tiles in each direction for the whole map (earth) at the current zoom level.
141 // it is 1<<zoomLevel
142 int m_sideLength = 0;
143
144 QHash<QGeoTileSpec, QSharedPointer<QGeoTileTexture> > m_textures;
145 QList<QGeoTileSpec> m_updatedTextures;
146
147 // tilesToGrid transform
148 int m_minTileX = -1; // the minimum tile index, i.e. 0 to sideLength which is 1<< zoomLevel
149 int m_minTileY = -1;
150 int m_maxTileX = -1;
151 int m_maxTileY = -1;
152 int m_tileXWrapsBelow = 0; // the wrap point as a tile index
153 bool m_linearScaling = false;
154 bool m_dropTextures = false;
155
156#ifdef QT_LOCATION_DEBUG
157 double m_sideLengthPixel;
158 QGeoTiledMapRootNode *m_mapRoot = nullptr;
159#endif
160};
161
162QT_END_NAMESPACE
163
164#endif // QGEOTILEDMAPSCENE_P_P_H
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)