summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2018-04-17 13:34:17 +0200
committerPaolo Angelelli <paolo.angelelli@qt.io>2018-04-19 11:46:01 +0000
commitbe8b7b6d62203f3d9749a6420cf3260f8be8f7fc (patch)
tree6e2a13ad71dfc5c6b881b9b125e34d4965e2bfea
parentecc8182f6c6c8b1448a35de46c3f5598bbf35150 (diff)
downloadqtlocation-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>
-rw-r--r--src/location/declarativemaps/qdeclarativepolylinemapitem.cpp31
-rw-r--r--src/location/declarativemaps/qdeclarativepolylinemapitem_p.h2
-rw-r--r--src/location/declarativemaps/qgeomapitemgeometry_p.h2
3 files changed, 22 insertions, 13 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
diff --git a/src/location/declarativemaps/qdeclarativepolylinemapitem_p.h b/src/location/declarativemaps/qdeclarativepolylinemapitem_p.h
index a34acad4..ca01de12 100644
--- a/src/location/declarativemaps/qdeclarativepolylinemapitem_p.h
+++ b/src/location/declarativemaps/qdeclarativepolylinemapitem_p.h
@@ -100,6 +100,8 @@ public:
void clearSource();
+ bool contains(const QPointF &point) const override;
+
QList<QList<QDoubleVector2D> > clipPath(const QGeoMap &map,
const QList<QDoubleVector2D> &path,
QDoubleVector2D &leftBoundWrapped);
diff --git a/src/location/declarativemaps/qgeomapitemgeometry_p.h b/src/location/declarativemaps/qgeomapitemgeometry_p.h
index 1011cd0c..ab81ff0b 100644
--- a/src/location/declarativemaps/qgeomapitemgeometry_p.h
+++ b/src/location/declarativemaps/qgeomapitemgeometry_p.h
@@ -95,7 +95,7 @@ public:
return screenOutline_;
}
- inline bool contains(const QPointF &screenPoint) const {
+ virtual bool contains(const QPointF &screenPoint) const {
return screenOutline_.contains(screenPoint);
}