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
qdeclarativecirclemapitem_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// Qt-Security score:significant reason:default
5
6#ifndef QDECLARATIVECIRCLEMAPITEM_P_P_H
7#define QDECLARATIVECIRCLEMAPITEM_P_P_H
8
9//
10// W A R N I N G
11// -------------
12//
13// This file is not part of the Qt API. It exists purely as an
14// implementation detail. This header file may change from version to
15// version without notice, or even be removed.
16//
17// We mean it.
18//
19
20#include <QtLocation/private/qlocationglobal_p.h>
21#include <QtLocation/private/qdeclarativepolygonmapitem_p_p.h>
22#include <QtLocation/private/qdeclarativecirclemapitem_p.h>
23
24QT_BEGIN_NAMESPACE
25
26class QQuickShape;
27class QQuickShapePath;
28
29class Q_LOCATION_EXPORT QGeoMapCircleGeometry : public QGeoMapPolygonGeometry
30{
31public:
32 QGeoMapCircleGeometry();
33
34 void updateSourceAndScreenPointsInvert(const QList<QDoubleVector2D> &circlePath, const QGeoMap &map);
35};
36
37class Q_LOCATION_EXPORT QDeclarativeCircleMapItemPrivate
38{
39 Q_DISABLE_COPY_MOVE(QDeclarativeCircleMapItemPrivate)
40public:
41 static const int CircleSamples = 128; // ToDo: make this radius && ZL dependent?
42
43 QDeclarativeCircleMapItemPrivate(QDeclarativeCircleMapItem &circle)
44 : m_circle(circle)
45 {
46 }
47
49 virtual void onLinePropertiesChanged() = 0;
50 virtual void markSourceDirtyAndUpdate() = 0;
51 virtual void onMapSet() = 0;
52 virtual void onGeoGeometryChanged() = 0;
53 virtual void onItemGeometryChanged() = 0;
54 virtual void updatePolish() = 0;
55 virtual void afterViewportChanged() = 0;
56 virtual QSGNode * updateMapItemPaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *data) = 0;
57 virtual bool contains(const QPointF &point) const = 0;
58
60 {
61 if (!m_circle.map() || m_circle.map()->geoProjection().projectionType() != QGeoProjection::ProjectionWebMercator)
62 return;
63
64 m_circlePath.clear();
65 const QGeoProjectionWebMercator &p = static_cast<const QGeoProjectionWebMercator&>(m_circle.map()->geoProjection());
66 if (m_circle.referenceSurface() == QLocation::ReferenceSurface::Map)
67 calculatePeripheralPointsSimple(m_circlePath, m_circle.center(), m_circle.radius(), p, CircleSamples);
68 else
69 calculatePeripheralPointsGreatCircle(m_circlePath, m_circle.center(), m_circle.radius(), p, CircleSamples);
70 }
71
72 static int crossEarthPole(const QGeoCoordinate &center, qreal distance);
73
74 static void includeOnePoleInPath(QList<QDoubleVector2D> &path, const QGeoCoordinate &center,
75 qreal distance, const QGeoProjectionWebMercator &p);
76
77 static void calculatePeripheralPointsSimple(QList<QDoubleVector2D> &path, const QGeoCoordinate &center,
78 qreal distance, const QGeoProjectionWebMercator &p, int steps);
79
80 static void calculatePeripheralPointsGreatCircle(QList<QDoubleVector2D> &path, const QGeoCoordinate &center,
81 qreal distance, const QGeoProjectionWebMercator &p, int steps);
82
85};
86
87class Q_LOCATION_EXPORT QDeclarativeCircleMapItemPrivateCPU: public QDeclarativeCircleMapItemPrivate
88{
89public:
90 QDeclarativeCircleMapItemPrivateCPU(QDeclarativeCircleMapItem &circle);
91 ~QDeclarativeCircleMapItemPrivateCPU() override;
92
93 void onLinePropertiesChanged() override
94 {
95 // mark dirty just in case we're a width change
96 markSourceDirtyAndUpdate();
97 }
98 void markSourceDirtyAndUpdate() override
99 {
100 m_geometry.markSourceDirty();
101 m_circle.polishAndUpdate();
102 }
103 void onMapSet() override
104 {
105 updateCirclePath();
106 markSourceDirtyAndUpdate();
107 }
108 void onGeoGeometryChanged() override
109 {
110 updateCirclePath();
111 markSourceDirtyAndUpdate();
112 }
113 void onItemGeometryChanged() override
114 {
115 onGeoGeometryChanged();
116 }
117 void afterViewportChanged() override
118 {
119 markSourceDirtyAndUpdate();
120 }
121 void updatePolish() override;
122 QSGNode * updateMapItemPaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *data) override;
123 bool contains(const QPointF &point) const override;
124
125 QGeoMapCircleGeometry m_geometry;
126 QQuickShape *m_shape = nullptr;
127 QQuickShapePath *m_shapePath = nullptr;
128 QDeclarativeGeoMapPainterPath *m_painterPath = nullptr;
129};
130
131QT_END_NAMESPACE
132
133#endif // QDECLARATIVECIRCLEMAPITEM_P_P_H
static void calculatePeripheralPointsGreatCircle(QList< QDoubleVector2D > &path, const QGeoCoordinate &center, qreal distance, const QGeoProjectionWebMercator &p, int steps)
virtual void afterViewportChanged()=0
static void calculatePeripheralPointsSimple(QList< QDoubleVector2D > &path, const QGeoCoordinate &center, qreal distance, const QGeoProjectionWebMercator &p, int steps)
virtual QSGNode * updateMapItemPaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *data)=0
virtual void onItemGeometryChanged()=0
static void includeOnePoleInPath(QList< QDoubleVector2D > &path, const QGeoCoordinate &center, qreal distance, const QGeoProjectionWebMercator &p)
static int crossEarthPole(const QGeoCoordinate &center, qreal distance)
virtual void onGeoGeometryChanged()=0
virtual bool contains(const QPointF &point) const =0
virtual void onLinePropertiesChanged()=0
virtual void markSourceDirtyAndUpdate()=0
#define M_PI
Definition qmath.h:201