summaryrefslogtreecommitdiff
path: root/src/plugins/geoservices/mapboxgl
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2017-09-05 18:46:09 +0200
committerPaolo Angelelli <paolo.angelelli@qt.io>2017-09-05 18:47:14 +0200
commit021f2157cd18a6d37a9569bf3aba34f3af173ed5 (patch)
tree6fc11a62ecd3df6e4214ecc2860f904d0e31dbbc /src/plugins/geoservices/mapboxgl
parent222ba4b733f67a51758708e27b7c76cdaaa3e228 (diff)
parent8f80da7ea0165adb492c71255d0eea5f08c0af8e (diff)
downloadqtlocation-021f2157cd18a6d37a9569bf3aba34f3af173ed5.tar.gz
Merge remote-tracking branch 'origin/5.9' into 5.10
Change-Id: Ibfd8b430011abb0a7174bbcc158b03f8e26492eb
Diffstat (limited to 'src/plugins/geoservices/mapboxgl')
-rw-r--r--src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.cpp31
-rw-r--r--src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp61
-rw-r--r--src/plugins/geoservices/mapboxgl/qmapboxglstylechange_p.h1
-rw-r--r--src/plugins/geoservices/mapboxgl/qsgmapboxglnode.cpp12
4 files changed, 95 insertions, 10 deletions
diff --git a/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.cpp b/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.cpp
index 58459e00..8df00905 100644
--- a/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.cpp
+++ b/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.cpp
@@ -176,8 +176,7 @@ void QGeoMapMapboxGLPrivate::removeParameter(QGeoMapParameter *param)
QGeoMap::ItemTypes QGeoMapMapboxGLPrivate::supportedMapItemTypes() const
{
- // TODO https://bugreports.qt.io/browse/QTBUG-58869
- return QGeoMap::MapRectangle | QGeoMap::MapPolygon | QGeoMap::MapPolyline;
+ return QGeoMap::MapRectangle | QGeoMap::MapCircle | QGeoMap::MapPolygon | QGeoMap::MapPolyline;
}
void QGeoMapMapboxGLPrivate::addMapItem(QDeclarativeGeoMapItemBase *item)
@@ -188,25 +187,40 @@ void QGeoMapMapboxGLPrivate::addMapItem(QDeclarativeGeoMapItemBase *item)
case QGeoMap::NoItem:
case QGeoMap::MapQuickItem:
case QGeoMap::CustomMapItem:
- case QGeoMap::MapCircle:
return;
case QGeoMap::MapRectangle: {
- QDeclarativeRectangleMapItem *mapItem = qobject_cast<QDeclarativeRectangleMapItem *>(item);
+ QDeclarativeRectangleMapItem *mapItem = static_cast<QDeclarativeRectangleMapItem *>(item);
+ QObject::connect(mapItem, &QQuickItem::visibleChanged, q, &QGeoMapMapboxGL::onMapItemPropertyChanged);
+ QObject::connect(mapItem, &QDeclarativeGeoMapItemBase::mapItemOpacityChanged, q, &QGeoMapMapboxGL::onMapItemPropertyChanged);
QObject::connect(mapItem, &QDeclarativeRectangleMapItem::bottomRightChanged, q, &QGeoMapMapboxGL::onMapItemGeometryChanged);
QObject::connect(mapItem, &QDeclarativeRectangleMapItem::topLeftChanged, q, &QGeoMapMapboxGL::onMapItemGeometryChanged);
QObject::connect(mapItem, &QDeclarativeRectangleMapItem::colorChanged, q, &QGeoMapMapboxGL::onMapItemPropertyChanged);
QObject::connect(mapItem->border(), &QDeclarativeMapLineProperties::colorChanged, q, &QGeoMapMapboxGL::onMapItemSubPropertyChanged);
QObject::connect(mapItem->border(), &QDeclarativeMapLineProperties::widthChanged, q, &QGeoMapMapboxGL::onMapItemUnsupportedPropertyChanged);
} break;
+ case QGeoMap::MapCircle: {
+ QDeclarativeCircleMapItem *mapItem = static_cast<QDeclarativeCircleMapItem *>(item);
+ QObject::connect(mapItem, &QQuickItem::visibleChanged, q, &QGeoMapMapboxGL::onMapItemPropertyChanged);
+ QObject::connect(mapItem, &QDeclarativeGeoMapItemBase::mapItemOpacityChanged, q, &QGeoMapMapboxGL::onMapItemPropertyChanged);
+ QObject::connect(mapItem, &QDeclarativeCircleMapItem::centerChanged, q, &QGeoMapMapboxGL::onMapItemGeometryChanged);
+ QObject::connect(mapItem, &QDeclarativeCircleMapItem::radiusChanged, q, &QGeoMapMapboxGL::onMapItemGeometryChanged);
+ QObject::connect(mapItem, &QDeclarativeCircleMapItem::colorChanged, q, &QGeoMapMapboxGL::onMapItemPropertyChanged);
+ QObject::connect(mapItem->border(), &QDeclarativeMapLineProperties::colorChanged, q, &QGeoMapMapboxGL::onMapItemSubPropertyChanged);
+ QObject::connect(mapItem->border(), &QDeclarativeMapLineProperties::widthChanged, q, &QGeoMapMapboxGL::onMapItemUnsupportedPropertyChanged);
+ } break;
case QGeoMap::MapPolygon: {
- QDeclarativePolygonMapItem *mapItem = qobject_cast<QDeclarativePolygonMapItem *>(item);
+ QDeclarativePolygonMapItem *mapItem = static_cast<QDeclarativePolygonMapItem *>(item);
+ QObject::connect(mapItem, &QQuickItem::visibleChanged, q, &QGeoMapMapboxGL::onMapItemPropertyChanged);
+ QObject::connect(mapItem, &QDeclarativeGeoMapItemBase::mapItemOpacityChanged, q, &QGeoMapMapboxGL::onMapItemPropertyChanged);
QObject::connect(mapItem, &QDeclarativePolygonMapItem::pathChanged, q, &QGeoMapMapboxGL::onMapItemGeometryChanged);
QObject::connect(mapItem, &QDeclarativePolygonMapItem::colorChanged, q, &QGeoMapMapboxGL::onMapItemGeometryChanged);
QObject::connect(mapItem->border(), &QDeclarativeMapLineProperties::colorChanged, q, &QGeoMapMapboxGL::onMapItemSubPropertyChanged);
QObject::connect(mapItem->border(), &QDeclarativeMapLineProperties::widthChanged, q, &QGeoMapMapboxGL::onMapItemUnsupportedPropertyChanged);
} break;
case QGeoMap::MapPolyline: {
- QDeclarativePolylineMapItem *mapItem = qobject_cast<QDeclarativePolylineMapItem *>(item);
+ QDeclarativePolylineMapItem *mapItem = static_cast<QDeclarativePolylineMapItem *>(item);
+ QObject::connect(mapItem, &QQuickItem::visibleChanged, q, &QGeoMapMapboxGL::onMapItemPropertyChanged);
+ QObject::connect(mapItem, &QDeclarativeGeoMapItemBase::mapItemOpacityChanged, q, &QGeoMapMapboxGL::onMapItemPropertyChanged);
QObject::connect(mapItem, &QDeclarativePolylineMapItem::pathChanged, q, &QGeoMapMapboxGL::onMapItemGeometryChanged);
QObject::connect(mapItem->line(), &QDeclarativeMapLineProperties::colorChanged, q, &QGeoMapMapboxGL::onMapItemSubPropertyChanged);
QObject::connect(mapItem->line(), &QDeclarativeMapLineProperties::widthChanged, q, &QGeoMapMapboxGL::onMapItemSubPropertyChanged);
@@ -228,11 +242,13 @@ void QGeoMapMapboxGLPrivate::removeMapItem(QDeclarativeGeoMapItemBase *item)
case QGeoMap::NoItem:
case QGeoMap::MapQuickItem:
case QGeoMap::CustomMapItem:
- case QGeoMap::MapCircle:
return;
case QGeoMap::MapRectangle:
q->disconnect(static_cast<QDeclarativeRectangleMapItem *>(item)->border());
break;
+ case QGeoMap::MapCircle:
+ q->disconnect(static_cast<QDeclarativeCircleMapItem *>(item)->border());
+ break;
case QGeoMap::MapPolygon:
q->disconnect(static_cast<QDeclarativePolygonMapItem *>(item)->border());
break;
@@ -383,6 +399,7 @@ void QGeoMapMapboxGL::onMapItemPropertyChanged()
QDeclarativeGeoMapItemBase *item = static_cast<QDeclarativeGeoMapItemBase *>(sender());
d->m_styleChanges << QMapboxGLStyleSetPaintProperty::fromMapItem(item);
+ d->m_styleChanges << QMapboxGLStyleSetLayoutProperty::fromMapItem(item);
emit sgNodeChanged();
}
diff --git a/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp b/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp
index f79f0a38..69bb6e4b 100644
--- a/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp
+++ b/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp
@@ -86,6 +86,32 @@ QMapbox::Feature featureFromMapRectangle(QDeclarativeRectangleMapItem *mapItem)
return QMapbox::Feature(QMapbox::Feature::PolygonType, geometry, {}, getId(mapItem));
}
+QMapbox::Feature featureFromMapCircle(QDeclarativeCircleMapItem *mapItem)
+{
+ static const int circleSamples = 128;
+
+ QList<QGeoCoordinate> path;
+ QGeoCoordinate leftBound;
+ QDeclarativeCircleMapItem::calculatePeripheralPoints(path, mapItem->center(), mapItem->radius(), circleSamples, leftBound);
+ QList<QDoubleVector2D> pathProjected;
+ for (const QGeoCoordinate &c : qAsConst(path))
+ pathProjected << mapItem->map()->geoProjection().geoToMapProjection(c);
+ if (QDeclarativeCircleMapItem::crossEarthPole(mapItem->center(), mapItem->radius()))
+ mapItem->preserveCircleGeometry(pathProjected, mapItem->center(), mapItem->radius());
+ path.clear();
+ for (const QDoubleVector2D &c : qAsConst(pathProjected))
+ path << mapItem->map()->geoProjection().mapProjectionToGeo(c);
+
+
+ QMapbox::Coordinates coordinates;
+ for (const QGeoCoordinate &coordinate : path) {
+ coordinates << QMapbox::Coordinate { coordinate.latitude(), coordinate.longitude() };
+ }
+ coordinates.append(coordinates.first()); // closing the path
+ QMapbox::CoordinatesCollections geometry { { coordinates } };
+ return QMapbox::Feature(QMapbox::Feature::PolygonType, geometry, {}, getId(mapItem));
+}
+
QMapbox::Feature featureFromMapPolygon(QDeclarativePolygonMapItem *mapItem)
{
const QGeoPath *path = static_cast<const QGeoPath *>(&mapItem->geoShape());
@@ -126,6 +152,8 @@ QMapbox::Feature featureFromMapItem(QDeclarativeGeoMapItemBase *item)
switch (item->itemType()) {
case QGeoMap::MapRectangle:
return featureFromMapRectangle(static_cast<QDeclarativeRectangleMapItem *>(item));
+ case QGeoMap::MapCircle:
+ return featureFromMapCircle(static_cast<QDeclarativeCircleMapItem *>(item));
case QGeoMap::MapPolygon:
return featureFromMapPolygon(static_cast<QDeclarativePolygonMapItem *>(item));
case QGeoMap::MapPolyline:
@@ -182,6 +210,7 @@ QList<QSharedPointer<QMapboxGLStyleChange>> QMapboxGLStyleChange::addMapItem(QDe
switch (item->itemType()) {
case QGeoMap::MapRectangle:
+ case QGeoMap::MapCircle:
case QGeoMap::MapPolygon:
case QGeoMap::MapPolyline:
break;
@@ -250,13 +279,20 @@ QList<QSharedPointer<QMapboxGLStyleChange>> QMapboxGLStyleSetLayoutProperty::fro
QList<QSharedPointer<QMapboxGLStyleChange>> QMapboxGLStyleSetLayoutProperty::fromMapItem(QDeclarativeGeoMapItemBase *item)
{
+ QList<QSharedPointer<QMapboxGLStyleChange>> changes;
+
switch (item->itemType()) {
case QGeoMap::MapPolyline:
- return fromMapItem(static_cast<QDeclarativePolylineMapItem *>(item));
+ changes = fromMapItem(static_cast<QDeclarativePolylineMapItem *>(item));
default:
- qWarning() << "Unsupported QGeoMap item type: " << item->itemType();
- return QList<QSharedPointer<QMapboxGLStyleChange>>();
+ break;
}
+
+ changes << QSharedPointer<QMapboxGLStyleChange>(
+ new QMapboxGLStyleSetLayoutProperty(getId(item), QStringLiteral("visibility"),
+ item->isVisible() ? QStringLiteral("visible") : QStringLiteral("none")));
+
+ return changes;
}
QList<QSharedPointer<QMapboxGLStyleChange>> QMapboxGLStyleSetLayoutProperty::fromMapItem(QDeclarativePolylineMapItem *item)
@@ -325,6 +361,8 @@ QList<QSharedPointer<QMapboxGLStyleChange>> QMapboxGLStyleSetPaintProperty::from
switch (item->itemType()) {
case QGeoMap::MapRectangle:
return fromMapItem(static_cast<QDeclarativeRectangleMapItem *>(item));
+ case QGeoMap::MapCircle:
+ return fromMapItem(static_cast<QDeclarativeCircleMapItem *>(item));
case QGeoMap::MapPolygon:
return fromMapItem(static_cast<QDeclarativePolygonMapItem *>(item));
case QGeoMap::MapPolyline:
@@ -352,6 +390,23 @@ QList<QSharedPointer<QMapboxGLStyleChange>> QMapboxGLStyleSetPaintProperty::from
return changes;
}
+QList<QSharedPointer<QMapboxGLStyleChange>> QMapboxGLStyleSetPaintProperty::fromMapItem(QDeclarativeCircleMapItem *item)
+{
+ QList<QSharedPointer<QMapboxGLStyleChange>> changes;
+ changes.reserve(3);
+
+ const QString id = getId(item);
+
+ changes << QSharedPointer<QMapboxGLStyleChange>(
+ new QMapboxGLStyleSetPaintProperty(id, QStringLiteral("fill-opacity"), item->mapItemOpacity()));
+ changes << QSharedPointer<QMapboxGLStyleChange>(
+ new QMapboxGLStyleSetPaintProperty(id, QStringLiteral("fill-color"), item->color()));
+ changes << QSharedPointer<QMapboxGLStyleChange>(
+ new QMapboxGLStyleSetPaintProperty(id, QStringLiteral("fill-outline-color"), item->border()->color()));
+
+ return changes;
+}
+
QList<QSharedPointer<QMapboxGLStyleChange>> QMapboxGLStyleSetPaintProperty::fromMapItem(QDeclarativePolygonMapItem *item)
{
QList<QSharedPointer<QMapboxGLStyleChange>> changes;
diff --git a/src/plugins/geoservices/mapboxgl/qmapboxglstylechange_p.h b/src/plugins/geoservices/mapboxgl/qmapboxglstylechange_p.h
index aa81d89f..33737c1d 100644
--- a/src/plugins/geoservices/mapboxgl/qmapboxglstylechange_p.h
+++ b/src/plugins/geoservices/mapboxgl/qmapboxglstylechange_p.h
@@ -93,6 +93,7 @@ public:
private:
static QList<QSharedPointer<QMapboxGLStyleChange>> fromMapItem(QDeclarativeRectangleMapItem *);
+ static QList<QSharedPointer<QMapboxGLStyleChange>> fromMapItem(QDeclarativeCircleMapItem *);
static QList<QSharedPointer<QMapboxGLStyleChange>> fromMapItem(QDeclarativePolygonMapItem *);
static QList<QSharedPointer<QMapboxGLStyleChange>> fromMapItem(QDeclarativePolylineMapItem *);
diff --git a/src/plugins/geoservices/mapboxgl/qsgmapboxglnode.cpp b/src/plugins/geoservices/mapboxgl/qsgmapboxglnode.cpp
index 3f31997c..82aa868f 100644
--- a/src/plugins/geoservices/mapboxgl/qsgmapboxglnode.cpp
+++ b/src/plugins/geoservices/mapboxgl/qsgmapboxglnode.cpp
@@ -88,10 +88,16 @@ void QSGMapboxGLTextureNode::render(QQuickWindow *window)
QOpenGLFunctions *f = window->openglContext()->functions();
f->glViewport(0, 0, m_fbo->width(), m_fbo->height());
+ GLint alignment;
+ f->glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
+
m_fbo->bind();
m_map->render();
m_fbo->release();
+ // QTBUG-62861
+ f->glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
+
window->resetOpenGLState();
markDirty(QSGNode::DirtyMaterial);
}
@@ -125,7 +131,13 @@ void QSGMapboxGLRenderNode::render(const RenderState *state)
f->glScissor(state->scissorRect().x(), state->scissorRect().y(), state->scissorRect().width(), state->scissorRect().height());
f->glEnable(GL_SCISSOR_TEST);
+ GLint alignment;
+ f->glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
+
m_map->render();
+
+ // QTBUG-62861
+ f->glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
}
QSGRenderNode::StateFlags QSGMapboxGLRenderNode::changedStates() const