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// Qt-Security score:significant reason:default
4
5#ifndef QDECLARATIVEPOLYLINEMAPITEM
6#define QDECLARATIVEPOLYLINEMAPITEM
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 <QSGGeometryNode>
20#include <QSGFlatColorMaterial>
21#include <QtPositioning/QGeoPath>
22
23#include <QtLocation/private/qlocationglobal_p.h>
24#include <QtLocation/private/qdeclarativegeomapitembase_p.h>
25#include <QtLocation/private/qgeomapitemgeometry_p.h>
26
27#include <QtPositioning/private/qdoublevector2d_p.h>
28
29QT_BEGIN_NAMESPACE
30
31class Q_LOCATION_EXPORT QDeclarativeMapLineProperties : public QObject
32{
33 Q_OBJECT
34 QML_ANONYMOUS
35
36 Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged)
37 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
38
39public:
40 explicit QDeclarativeMapLineProperties(QObject *parent = nullptr);
41
42 QColor color() const;
43 void setColor(const QColor &color);
44
45 qreal width() const;
46 void setWidth(qreal width);
47
48Q_SIGNALS:
49 void widthChanged(qreal width);
50 void colorChanged(const QColor &color);
51
52private:
53 qreal width_ = 1.0;
54 QColor color_ = Qt::black;
55};
56
57class QDeclarativePolylineMapItemPrivate;
58class Q_LOCATION_EXPORT QDeclarativePolylineMapItem : public QDeclarativeGeoMapItemBase
59{
60 Q_OBJECT
61 QML_NAMED_ELEMENT(MapPolyline)
62 QML_ADDED_IN_VERSION(5, 0)
63
64 Q_PROPERTY(QList<QGeoCoordinate> path READ path WRITE setPath NOTIFY pathChanged)
65 Q_PROPERTY(QDeclarativeMapLineProperties *line READ line CONSTANT)
66
67public:
68 explicit QDeclarativePolylineMapItem(QQuickItem *parent = nullptr);
69 ~QDeclarativePolylineMapItem();
70
71 void setMap(QDeclarativeGeoMap *quickMap, QGeoMap *map) override;
72 //from QuickItem
73 QSGNode *updateMapItemPaintNode(QSGNode *, UpdatePaintNodeData *) override;
74
75 Q_INVOKABLE int pathLength() const;
76 Q_INVOKABLE void addCoordinate(const QGeoCoordinate &coordinate);
77 Q_INVOKABLE void insertCoordinate(int index, const QGeoCoordinate &coordinate);
78 Q_INVOKABLE void replaceCoordinate(int index, const QGeoCoordinate &coordinate);
79 Q_INVOKABLE QGeoCoordinate coordinateAt(int index) const;
80 Q_INVOKABLE bool containsCoordinate(const QGeoCoordinate &coordinate);
81 Q_INVOKABLE void removeCoordinate(const QGeoCoordinate &coordinate);
82 Q_INVOKABLE void removeCoordinate(int index);
83
84 QList<QGeoCoordinate> path() const;
85 virtual void setPath(const QList<QGeoCoordinate> &value);
86 Q_INVOKABLE void setPath(const QGeoPath &path);
87
88 bool contains(const QPointF &point) const override;
89 const QGeoShape &geoShape() const override;
90 void setGeoShape(const QGeoShape &shape) override;
91
92 QDeclarativeMapLineProperties *line();
93
94Q_SIGNALS:
95 void pathChanged();
96
97protected Q_SLOTS:
98 void updateAfterLinePropertiesChanged();
99 void afterViewportChanged(const QGeoMapViewportChangeEvent &event) override;
100
101protected:
102 void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
103 void setPathFromGeoList(const QList<QGeoCoordinate> &path);
104 void updatePolish() override;
105
106#ifdef QT_LOCATION_DEBUG
107public:
108#endif
109 QGeoPath m_geopath;
110 QDeclarativeMapLineProperties m_line;
111
112 bool m_updatingGeometry = false;
113
114 std::unique_ptr<QDeclarativePolylineMapItemPrivate> m_d;
115
116 friend class QDeclarativePolylineMapItemPrivate;
117 friend class QDeclarativePolylineMapItemPrivateCPU;
118};
119
120QT_END_NAMESPACE
121
122QML_DECLARE_TYPE(QDeclarativeMapLineProperties)
123QML_DECLARE_TYPE(QDeclarativePolylineMapItem)
124
125#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)