8#include <QtCore/QScopedValueRollback>
10#include <QPainterPath>
12#include <QtLocation/private/qgeomap_p.h>
13#include <QtPositioning/private/qlocationutils_p.h>
14#include <QtPositioning/private/qdoublevector2d_p.h>
15#include <QtPositioning/private/qclipperutils_p.h>
16#include <QtPositioning/private/qgeopolygon_p.h>
17#include <QtPositioning/private/qwebmercator_p.h>
114 const QList<QList <QDoubleVector2D>> &basePaths,
126 QList<QList<QDoubleVector2D>>
paths;
131 paths.reserve(basePaths.size());
133 const QList<QDoubleVector2D> &bp = basePaths[
j];
136 paths << QList<QDoubleVector2D>({bp[0]});
137 QList<QDoubleVector2D> &pp =
paths[
j];
138 pp.reserve(bp.size());
140 if (bp[
i].
x() > pp.last().x() + 0.5)
142 else if (bp[
i].
x() < pp.last().x() - 0.5)
151 QList<QDoubleVector2D> &pp =
paths[
j];
153 if (pp.last().x() - pp.first().x() < -0.5) {
155 pp.swapItemsAt(
i, pp.length() -
i - 1);
157 if (pp.last().x() - pp.first().x() > 0.5) {
159 const double leftBorder = cameraRect.left();
160 const double rightBorder = cameraRect.right();
162 qsizetype originalPathLength = pp.length();
164 if (pp.last().x() < rightBorder) {
168 if (pp.first().x() > leftBorder) {
172 const double newPoleLat = (pp.first().y() + pp.last().y() < 1.0) ? 0.0 : 1.0;
188 QList<QList<QDoubleVector2D>> wrappedPaths;
195 for (
double xoffset : {-1.0, 0.0, 1.0}) {
199 wrappedPaths.append(QList<QDoubleVector2D>());
200 QList<QDoubleVector2D> &wP = wrappedPaths.last();
201 wP.reserve(
path.size());
207 wrappedPaths =
paths;
210 if (wrappedPaths.isEmpty())
215 QList<QList<QDoubleVector2D>> clippedPaths;
216 const QList<QDoubleVector2D> &visibleRegion =
p.visibleGeometryExpanded();
217 for (
const auto &
path : wrappedPaths) {
218 if (visibleRegion.size()) {
221 clipper.addClipPolygon(visibleRegion);
226 clippedPaths.append(
path);
229 if (clippedPaths.isEmpty())
233 for (
const auto &
path: clippedPaths)
239 for (
const auto &
path: clippedPaths) {
251 if (
i ==
path.size() - 1) {
254 nextPoint =
p.wrappedMapProjectionToItemPosition(
path.at(
i+1)) -
origin;
256 bool addPoint = (
i > pointsAdded * 10 ||
259 const double tolerance = 0.1;
262 point.
x(), point.
y(),
263 nextPoint.x(), nextPoint.y(),
264 prevPoint.x(), prevPoint.y());
345 path.
translate(-bb.left() + borderWidth, -bb.top() + borderWidth);
379 m_updatingGeometry(
false)
393 this, [
this]() {
m_d->onGeoGeometryChanged(); });
451 m_d->onGeoGeometryChanged();
469 m_d->onGeoGeometryUpdated();
490 m_d->onGeoGeometryChanged();
522 return m_d->updateMapItemPaintNode(oldNode,
data);
537 m_d->markSourceDirtyAndUpdate();
542 m_d->onLinePropertiesChanged();
550 if (
event.mapSize.isEmpty())
553 m_d->afterViewportChanged();
561 return m_d->contains(point);
575 m_d->onGeoGeometryChanged();
591 if (!newCenter.isValid() || !oldCenter.isValid())
593 double offsetLongi = newCenter.longitude() - oldCenter.longitude();
594 double offsetLati = newCenter.latitude() - oldCenter.latitude();
595 if (offsetLati == 0.0 && offsetLongi == 0.0)
599 m_d->onGeoGeometryChanged();
void addSubjectPath(const QList< QDoubleVector2D > &path, bool closed)
The QColor class provides colors based on RGB, HSV or CMYK values.
int alpha() const noexcept
Returns the alpha color component of this color.
virtual void setPositionOnMap(const QGeoCoordinate &coordinate, const QPointF &offset)
QGeoMap::ItemType m_itemType
void setShapeTriangulationScale(QQuickShape *shape, qreal maxCoord) const
float zoomLevelOpacity() const
virtual void setMap(QDeclarativeGeoMap *quickMap, QGeoMap *map)
void referenceSurfaceChanged()
QLocation::ReferenceSurface referenceSurface
QDeclarativeGeoMap * quickMap() const
void setPath(const QPainterPath &path)
void widthChanged(qreal width)
void colorChanged(const QColor &color)
bool contains(const QPointF &point) const override
void updatePolish() override
QList< QList< QDoubleVector2D > > m_geopathProjected
~QDeclarativePolygonMapItemPrivateCPU() override
QDeclarativeGeoMapPainterPath * m_painterPath
QGeoMapPolygonGeometry m_geometry
QQuickShapePath * m_shapePath
QDeclarativePolygonMapItemPrivateCPU(QDeclarativePolygonMapItem &polygon)
QSGNode * updateMapItemPaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *data) override
QDeclarativePolygonMapItem & m_poly
virtual ~QDeclarativePolygonMapItemPrivate()
void updatePolish() override
Q_INVOKABLE void addCoordinate(const QGeoCoordinate &coordinate)
\qmlmethod void MapPolygon::addCoordinate(coordinate)
bool contains(const QPointF &point) const override
void setGeoShape(const QGeoShape &shape) override
QList< QGeoCoordinate > path
std::unique_ptr< QDeclarativePolygonMapItemPrivate > m_d
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override
void setMap(QDeclarativeGeoMap *quickMap, QGeoMap *map) override
QSGNode * updateMapItemPaintNode(QSGNode *, UpdatePaintNodeData *) override
QDeclarativeMapLineProperties * border
\qmlpropertygroup Location::MapPolygon::border \qmlproperty int MapPolygon::border....
void onLinePropertiesChanged()
~QDeclarativePolygonMapItem() override
void setColor(const QColor &color)
const QGeoShape & geoShape() const override
void afterViewportChanged(const QGeoMapViewportChangeEvent &event) override
void setPath(const QList< QGeoCoordinate > &value)
void markSourceDirtyAndUpdate()
Q_INVOKABLE void removeCoordinate(const QGeoCoordinate &coordinate)
\qmlmethod void MapPolygon::removeCoordinate(coordinate)
QDeclarativeMapLineProperties m_border
QDeclarativePolygonMapItem(QQuickItem *parent=nullptr)
Q_DECL_CONSTEXPR QPointF toPointF() const
Q_DECL_CONSTEXPR double x() const
Q_DECL_CONSTEXPR double y() const
bool isValid
This property holds the validity of this geo coordinate.
QGeoCoordinate srcOrigin_
QRectF sourceBoundingBox() const
const QGeoCoordinate & origin() const
bool isScreenDirty() const
QPainterPath srcPath() const
void updateSourcePoints(const QGeoMap &map, const QList< QList< QDoubleVector2D > > &path, MapBorderBehaviour wrapping=Duplicate)
QGeoMapPolygonGeometry()
\qmltype MapPolygon \instantiates QDeclarativePolygonMapItem \inqmlmodule QtLocation
const QGeoProjection & geoProjection() const
void setPerimeter(const QList< QGeoCoordinate > &path)
Sets the perimeter of the polygon based on a list of coordinates path.
Q_INVOKABLE void removeCoordinate(const QGeoCoordinate &coordinate)
Removes the last occurrence of coordinate from the polygon.
Q_INVOKABLE void translate(double degreesLatitude, double degreesLongitude)
Translates this geo polygon by degreesLatitude northwards and degreesLongitude eastwards.
Q_INVOKABLE void addCoordinate(const QGeoCoordinate &coordinate)
Appends coordinate to the polygon.
QList< QGeoCoordinate > perimeter
virtual QGeoCoordinate itemPositionToCoordinate(const QDoubleVector2D &pos, bool clipToViewport=true) const =0
bool isValid
This property holds the validity of the geo shape.
qsizetype length() const noexcept
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Q_WEAK_OVERLOAD void setObjectName(const QString &name)
Sets the object's name to name.
void translate(qreal dx, qreal dy)
Translates all elements in the path by ({dx}, {dy}).
void moveTo(const QPointF &p)
Moves the current point to the given point, implicitly starting a new subpath and closing the previou...
QPainterPath simplified() const
QRectF boundingRect() const
Returns the bounding rectangle of this painter path as a rectangle with floating point precision.
void closeSubpath()
Closes the current subpath by drawing a line to the beginning of the subpath, automatically starting ...
void lineTo(const QPointF &p)
Adds a straight line from the current position to the given endPoint.
\inmodule QtCore\reentrant
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
void setSize(const QSizeF &size)
void setFlag(Flag flag, bool enabled=true)
Enables the specified flag for this item if enabled is true; if enabled is false, the flag is disable...
virtual void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry)
Q_INVOKABLE QPointF mapToItem(const QQuickItem *item, const QPointF &point) const
Maps the given point in this item's coordinate system to the equivalent point within item's coordinat...
QQmlListProperty< QQuickPathElement > pathElements
\qmlproperty list<PathElement> QtQuick::Path::pathElements This property holds the objects composing ...
void setStrokeColor(const QColor &color)
void setStrokeWidth(qreal w)
void setFillColor(const QColor &color)
bool contains(const QPointF &point) const override
\qmlmethod bool QtQuick::Item::contains(point point)
void setContainsMode(ContainsMode containsMode)
FINALQQmlListProperty< QObject > data
\qmlproperty list<Object> QtQuick.Shapes::Shape::data
\inmodule QtCore\reentrant
constexpr QRectF translated(qreal dx, qreal dy) const noexcept
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis,...
constexpr QPointF topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
constexpr QPointF center() const noexcept
Returns the center point of the rectangle.
\group qtquick-scenegraph-nodes \title Qt Quick Scene Graph Node classes
QMap< QString, QString > map
[6]
QRectF boundingRectangleFromList(const QList< QDoubleVector2D > &list)
double distanceSqrPointLine(double p0_x, double p0_y, double p1_x, double p1_y, double p2_x, double p2_y)
Combined button and popup list for selecting options.
static void addPoint(QPolygon &a, const QPoint &p)
constexpr const T & qMax(const T &a, const T &b)
GLint GLint GLint GLint GLint x
[0]
GLenum GLuint GLenum GLsizei length
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLsizei const GLuint * paths
GLsizei const GLchar *const * path