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
qdeclarativepolylinemapitem_p.h
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
4#ifndef QDECLARATIVEPOLYLINEMAPITEM
5#define QDECLARATIVEPOLYLINEMAPITEM
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QSGGeometryNode>
19#include <QSGFlatColorMaterial>
20#include <QtPositioning/QGeoPath>
21
22#include <QtLocation/private/qlocationglobal_p.h>
23#include <QtLocation/private/qdeclarativegeomapitembase_p.h>
24#include <QtLocation/private/qgeomapitemgeometry_p.h>
25
26#include <QtPositioning/private/qdoublevector2d_p.h>
27
28QT_BEGIN_NAMESPACE
29
30class Q_LOCATION_EXPORT QDeclarativeMapLineProperties : public QObject
31{
32 Q_OBJECT
33 QML_ANONYMOUS
34
35 Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged)
36 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
37
38public:
39 explicit QDeclarativeMapLineProperties(QObject *parent = nullptr);
40
41 QColor color() const;
42 void setColor(const QColor &color);
43
44 qreal width() const;
45 void setWidth(qreal width);
46
47Q_SIGNALS:
48 void widthChanged(qreal width);
49 void colorChanged(const QColor &color);
50
51private:
52 qreal width_ = 1.0;
53 QColor color_ = Qt::black;
54};
55
56class QDeclarativePolylineMapItemPrivate;
57class Q_LOCATION_EXPORT QDeclarativePolylineMapItem : public QDeclarativeGeoMapItemBase
58{
59 Q_OBJECT
60 QML_NAMED_ELEMENT(MapPolyline)
61 QML_ADDED_IN_VERSION(5, 0)
62
63 Q_PROPERTY(QList<QGeoCoordinate> path READ path WRITE setPath NOTIFY pathChanged)
64 Q_PROPERTY(QDeclarativeMapLineProperties *line READ line CONSTANT)
65
66public:
67 explicit QDeclarativePolylineMapItem(QQuickItem *parent = nullptr);
68 ~QDeclarativePolylineMapItem();
69
70 void setMap(QDeclarativeGeoMap *quickMap, QGeoMap *map) override;
71 //from QuickItem
72 QSGNode *updateMapItemPaintNode(QSGNode *, UpdatePaintNodeData *) override;
73
74 Q_INVOKABLE int pathLength() const;
75 Q_INVOKABLE void addCoordinate(const QGeoCoordinate &coordinate);
76 Q_INVOKABLE void insertCoordinate(int index, const QGeoCoordinate &coordinate);
77 Q_INVOKABLE void replaceCoordinate(int index, const QGeoCoordinate &coordinate);
78 Q_INVOKABLE QGeoCoordinate coordinateAt(int index) const;
79 Q_INVOKABLE bool containsCoordinate(const QGeoCoordinate &coordinate);
80 Q_INVOKABLE void removeCoordinate(const QGeoCoordinate &coordinate);
81 Q_INVOKABLE void removeCoordinate(int index);
82
83 QList<QGeoCoordinate> path() const;
84 virtual void setPath(const QList<QGeoCoordinate> &value);
85 Q_INVOKABLE void setPath(const QGeoPath &path);
86
87 bool contains(const QPointF &point) const override;
88 const QGeoShape &geoShape() const override;
89 void setGeoShape(const QGeoShape &shape) override;
90
91 QDeclarativeMapLineProperties *line();
92
93Q_SIGNALS:
94 void pathChanged();
95
96protected Q_SLOTS:
97 void updateAfterLinePropertiesChanged();
98 void afterViewportChanged(const QGeoMapViewportChangeEvent &event) override;
99
100protected:
101 void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
102 void setPathFromGeoList(const QList<QGeoCoordinate> &path);
103 void updatePolish() override;
104
105#ifdef QT_LOCATION_DEBUG
106public:
107#endif
108 QGeoPath m_geopath;
109 QDeclarativeMapLineProperties m_line;
110
111 bool m_updatingGeometry = false;
112
113 std::unique_ptr<QDeclarativePolylineMapItemPrivate> m_d;
114
115 friend class QDeclarativePolylineMapItemPrivate;
116 friend class QDeclarativePolylineMapItemPrivateCPU;
117};
118
119QT_END_NAMESPACE
120
121QML_DECLARE_TYPE(QDeclarativeMapLineProperties)
122QML_DECLARE_TYPE(QDeclarativePolylineMapItem)
123
124#endif /* QDECLARATIVEPOLYLINEMAPITEM_H_ */
static QT_BEGIN_NAMESPACE bool get_line_intersection(const double p0_x, const double p0_y, const double p1_x, const double p1_y, const double p2_x, const double p2_y, const double p3_x, const double p3_y, double *i_x, double *i_y, double *i_t)
static QList< QList< QDoubleVector2D > > clipLine(const QList< QDoubleVector2D > &l, const QList< QDoubleVector2D > &poly)
void updateSourcePoints(const QGeoMap &map, const QList< QDoubleVector2D > &basePath)