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
qdeclarativepolygonmapitem_p_p.h
Go to the documentation of this file.
1// Copyright (C) 2020 Paolo Angelelli <paolo.angelelli@gmail.com>
2// Copyright (C) 2022 The Qt Company Ltd.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#ifndef QDECLARATIVEPOLYGONMAPITEM_P_P_H
6#define QDECLARATIVEPOLYGONMAPITEM_P_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtCore/QList>
20#include <QtCore/QScopedValueRollback>
21#include <QtGui/QMatrix4x4>
22#include <QtGui/QColor>
23
24#include <QSGFlatColorMaterial>
25
26#include <QtLocation/private/qlocationglobal_p.h>
27#include <QtLocation/private/qgeomapitemgeometry_p.h>
28#include <QtLocation/private/qdeclarativepolygonmapitem_p.h>
29#include <QtLocation/private/qdeclarativepolylinemapitem_p_p.h>
30
31#include <QtPositioning/private/qdoublevector2d_p.h>
32
34
35class QQuickShape;
36class QQuickShapePath;
37
38class Q_LOCATION_EXPORT QGeoMapPolygonGeometry : public QGeoMapItemGeometry
39{
40public:
46
48
49 inline void setAssumeSimple(bool value) { assumeSimple_ = value; }
50
51 void updateSourcePoints(const QGeoMap &map,
52 const QList<QList<QDoubleVector2D>> &path,
53 MapBorderBehaviour wrapping = Duplicate);
54
55 QPainterPath srcPath() const { return srcPath_; }
56 qreal maxCoord() const { return maxCoord_; }
57
58protected:
60 qreal maxCoord_ = 0.0;
61 bool assumeSimple_ = false;
62};
63
64class Q_LOCATION_EXPORT QDeclarativePolygonMapItemPrivate
65{
66 Q_DISABLE_COPY_MOVE(QDeclarativePolygonMapItemPrivate)
67public:
72
74 virtual void onLinePropertiesChanged() = 0;
75 virtual void markSourceDirtyAndUpdate() = 0;
76 virtual void onMapSet() = 0;
77 virtual void onGeoGeometryChanged() = 0;
78 virtual void onGeoGeometryUpdated() = 0;
79 virtual void onItemGeometryChanged() = 0;
80 virtual void updatePolish() = 0;
81 virtual void afterViewportChanged() = 0;
83 virtual bool contains(const QPointF &point) const = 0;
84
86};
87
89{
90public:
93
95 {
96 // mark dirty just in case we're a width change
97 markSourceDirtyAndUpdate();
98 }
100 {
101 m_geometry.markSourceDirty();
102 m_poly.polishAndUpdate();
103 }
105 {
106 if (!m_poly.map() || m_poly.map()->geoProjection().projectionType() != QGeoProjection::ProjectionWebMercator)
107 return;
108 const QGeoProjectionWebMercator &p = static_cast<const QGeoProjectionWebMercator&>(m_poly.map()->geoProjection());
109 m_geopathProjected.clear();
110 m_geopathProjected << QList<QDoubleVector2D>();
111 QList<QDoubleVector2D> &pP = m_geopathProjected.last();
112 if (m_poly.referenceSurface() == QLocation::ReferenceSurface::Globe) {
113 const QList<QGeoCoordinate> realPath = QDeclarativeGeoMapItemUtils::greaterCirclePath(m_poly.m_geopoly.perimeter(),
115 pP.reserve(realPath.size());
116 for (const QGeoCoordinate &c : realPath)
117 pP << p.geoToMapProjection(c);
118 } else {
119 pP.reserve(m_poly.m_geopoly.perimeter().size());
120 const QList<QGeoCoordinate> perimeter = m_poly.m_geopoly.perimeter();
121 for (const QGeoCoordinate &c : perimeter)
122 pP << p.geoToMapProjection(c);
123 }
124 for (int i = 0; i < m_poly.m_geopoly.holesCount(); i++) {
125 m_geopathProjected << QList<QDoubleVector2D>();
126 QList<QDoubleVector2D> &pH = m_geopathProjected.last();
127 if (m_poly.referenceSurface() == QLocation::ReferenceSurface::Globe) {
128 const QList<QGeoCoordinate> realPath = QDeclarativeGeoMapItemUtils::greaterCirclePath(m_poly.m_geopoly.holePath(i),
130 pH.reserve(realPath.size());
131 for (const QGeoCoordinate &c : realPath)
132 pH << p.geoToMapProjection(c);
133 } else {
134 pH.reserve(m_poly.m_geopoly.holePath(i).size());
135 const QList<QGeoCoordinate> holePath = m_poly.m_geopoly.holePath(i);
136 for (const QGeoCoordinate &c : holePath)
137 pH << p.geoToMapProjection(c);
138 }
139 }
140 }
142 {
143 if (!m_poly.map() || m_poly.map()->geoProjection().projectionType() != QGeoProjection::ProjectionWebMercator)
144 return;
145 const QGeoProjectionWebMercator &p = static_cast<const QGeoProjectionWebMercator&>(m_poly.map()->geoProjection());
146 QList<QDoubleVector2D> &pP = m_geopathProjected.first();
147 if (m_poly.referenceSurface() == QLocation::ReferenceSurface::Globe && m_poly.m_geopoly.perimeter().size() > 1) {
148 regenerateCache(); //giving up here. Too difficult to take back all the interpolated points
149 } else {
150 pP << p.geoToMapProjection(m_poly.m_geopoly.perimeter().last());
151 }
152 }
153 void afterViewportChanged() override
154 {
155 markSourceDirtyAndUpdate();
156 }
157 void onMapSet() override
158 {
159 regenerateCache();
160 markSourceDirtyAndUpdate();
161 }
162 void onGeoGeometryChanged() override
163 {
164 regenerateCache();
165 markSourceDirtyAndUpdate();
166 }
167 void onGeoGeometryUpdated() override
168 {
169 updateCache();
170 markSourceDirtyAndUpdate();
171 }
172 void onItemGeometryChanged() override
173 {
174 onGeoGeometryChanged();
175 }
176 void updatePolish() override;
177 QSGNode *updateMapItemPaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *data) override;
178 bool contains(const QPointF &point) const override;
179
180 QList<QList<QDoubleVector2D>> m_geopathProjected;
182 QQuickShape *m_shape = nullptr;
183 QQuickShapePath *m_shapePath = nullptr;
184 QDeclarativeGeoMapPainterPath *m_painterPath = nullptr;
185};
186
188
189#endif // QDECLARATIVEPOLYGONMAPITEM_P_P_H
QList< QList< QDoubleVector2D > > m_geopathProjected
virtual void onItemGeometryChanged()=0
virtual void markSourceDirtyAndUpdate()=0
virtual bool contains(const QPointF &point) const =0
virtual void afterViewportChanged()=0
virtual void onGeoGeometryUpdated()=0
virtual QSGNode * updateMapItemPaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *data)=0
QDeclarativePolygonMapItemPrivate(QDeclarativePolygonMapItem &polygon)
virtual void onGeoGeometryChanged()=0
virtual void onLinePropertiesChanged()=0
\inmodule QtPositioning
QGeoMapPolygonGeometry()
\qmltype MapPolygon \instantiates QDeclarativePolygonMapItem \inqmlmodule QtLocation
Definition qlist.h:75
\inmodule QtGui
\inmodule QtCore\reentrant
Definition qpoint.h:217
\group qtquick-scenegraph-nodes \title Qt Quick Scene Graph Node classes
Definition qsgnode.h:37
QMap< QString, QString > map
[6]
QList< QGeoCoordinate > greaterCirclePath(const QList< QGeoCoordinate > &cornerPoints, greaterCirclePathForm form, int N)
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
static bool contains(const QJsonArray &haystack, unsigned needle)
Definition qopengl.cpp:116
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
const GLubyte * c
GLsizei const GLchar *const * path
GLfloat GLfloat p
[1]
double qreal
Definition qtypes.h:187