diff options
author | Paolo Angelelli <paolo.angelelli@qt.io> | 2018-04-17 13:34:17 +0200 |
---|---|---|
committer | Paolo Angelelli <paolo.angelelli@qt.io> | 2018-04-19 11:46:01 +0000 |
commit | be8b7b6d62203f3d9749a6420cf3260f8be8f7fc (patch) | |
tree | 6e2a13ad71dfc5c6b881b9b125e34d4965e2bfea /src/location/declarativemaps/qdeclarativepolylinemapitem.cpp | |
parent | ecc8182f6c6c8b1448a35de46c3f5598bbf35150 (diff) | |
download | qtlocation-be8b7b6d62203f3d9749a6420cf3260f8be8f7fc.tar.gz |
Add QGeoMapPolylineGeometry::contains
This patch makes QGeoMapItemGeometry::contains virtual, and overrides
it in QGeoMapPolylineGeometry, so that it can be used in items
that have QGeoMapPolylineGeometry for borders.
This patch fixes the issue of map polygons not being interactive
on their borders.
Task-number: QTBUG-67765
Change-Id: I7c571e57b9f1d26203f3e5857d47e85380281b28
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src/location/declarativemaps/qdeclarativepolylinemapitem.cpp')
-rw-r--r-- | src/location/declarativemaps/qdeclarativepolylinemapitem.cpp | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp b/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp index 2f045121..2568f8ac 100644 --- a/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp +++ b/src/location/declarativemaps/qdeclarativepolylinemapitem.cpp @@ -594,6 +594,24 @@ void QGeoMapPolylineGeometry::clearSource() srcPointTypes_.clear(); } +bool QGeoMapPolylineGeometry::contains(const QPointF &point) const +{ + // screenOutline_.contains(screenPoint) doesn't work, as, it appears, that + // screenOutline_ for QGeoMapPolylineGeometry is empty (QRectF(0,0 0x0)) + const QVector<QPointF> &verts = vertices(); + QPolygonF tri; + for (int i = 0; i < verts.size(); ++i) { + tri << verts[i]; + if (tri.size() == 3) { + if (tri.containsPoint(point,Qt::OddEvenFill)) + return true; + tri.remove(0); + } + } + + return false; +} + QDeclarativePolylineMapItem::QDeclarativePolylineMapItem(QQuickItem *parent) : QDeclarativeGeoMapItemBase(parent), line_(this), dirtyMaterial_(true), updatingGeometry_(false) { @@ -984,18 +1002,7 @@ QSGNode *QDeclarativePolylineMapItem::updateMapItemPaintNode(QSGNode *oldNode, U bool QDeclarativePolylineMapItem::contains(const QPointF &point) const { - QVector<QPointF> vertices = geometry_.vertices(); - QPolygonF tri; - for (int i = 0; i < vertices.size(); ++i) { - tri << vertices[i]; - if (tri.size() == 3) { - if (tri.containsPoint(point,Qt::OddEvenFill)) - return true; - tri.remove(0); - } - } - - return false; + return geometry_.contains(point); } const QGeoShape &QDeclarativePolylineMapItem::geoShape() const |