From 3856f0185442b5c4b85c770888072db0bc3fff1a Mon Sep 17 00:00:00 2001 From: Paolo Angelelli Date: Tue, 15 Aug 2017 13:21:48 +0200 Subject: Add a configure feature for each geoservice plugin This patch makes it possible to disable geoservice plugins at configuration time using the QtLite -no-feature-geoservices_xxx syntax. Change-Id: I276382833db8cfca27383705cbb3f994ced47cb3 Reviewed-by: Alex Blasche --- src/plugins/geoservices/geoservices.pro | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/plugins/geoservices') diff --git a/src/plugins/geoservices/geoservices.pro b/src/plugins/geoservices/geoservices.pro index 07c34798..b81ad34a 100644 --- a/src/plugins/geoservices/geoservices.pro +++ b/src/plugins/geoservices/geoservices.pro @@ -1,12 +1,14 @@ TEMPLATE = subdirs -SUBDIRS = nokia mapbox esri itemsoverlay +QT_FOR_CONFIG += location-private # pulls in the features defined in configure.json -qtConfig(concurrent) { - SUBDIRS += osm -} +qtConfig(geoservices_here): SUBDIRS += nokia +qtConfig(geoservices_mapbox): SUBDIRS += mapbox +qtConfig(geoservices_esri): SUBDIRS += esri +qtConfig(geoservices_itemsoverlay): SUBDIRS += itemsoverlay +qtConfig(geoservices_osm): SUBDIRS += osm -qtConfig(opengl):qtConfig(c++14):!win32|mingw:!qnx { +qtConfig(geoservices_mapboxgl) { !exists(../../3rdparty/mapbox-gl-native/mapbox-gl-native.pro) { warning("Submodule mapbox-gl-native does not exist. Run 'git submodule update --init' on qtlocation.") } else { -- cgit v1.2.1 From 7738ed4a18699d9d96f14dfe08dcc5ddfacf848f Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Wed, 30 Aug 2017 15:57:30 +0300 Subject: Fix broken native text rendering with Mapbox GL plugin Mapbox is "leaking" the pixel storage mode. So we need to restore it after we render otherwise it breaks native text rendering. Task-number: QTBUG-62861 Change-Id: I12643e34e462cce58cdf30da52ab927499f38442 Reviewed-by: Paolo Angelelli --- src/plugins/geoservices/mapboxgl/qsgmapboxglnode.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/plugins/geoservices') 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 -- cgit v1.2.1 From 6024168ef21dd4fe6c5ddd7e837d56076e886e01 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Tue, 28 Feb 2017 18:26:19 -0800 Subject: Mapbox GL native circle support Circles crossing one pole are drawn inverted. Circles crossing 2 poles do not even have the correct geometry. Nevertheless, a first approximation. Task-number: QTBUG-58869 Change-Id: I5a508f5d6e27c4f08412a7ae327883866068a1e9 Reviewed-by: Paolo Angelelli --- .../geoservices/mapboxgl/qgeomapmapboxgl.cpp | 22 ++++++---- .../geoservices/mapboxgl/qmapboxglstylechange.cpp | 48 ++++++++++++++++++++++ .../geoservices/mapboxgl/qmapboxglstylechange_p.h | 1 + 3 files changed, 64 insertions(+), 7 deletions(-) (limited to 'src/plugins/geoservices') diff --git a/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.cpp b/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.cpp index 1001ca31..2f506325 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,32 @@ 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(item); + QDeclarativeRectangleMapItem *mapItem = static_cast(item); 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(item); + 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(item); + QDeclarativePolygonMapItem *mapItem = static_cast(item); 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(item); + QDeclarativePolylineMapItem *mapItem = static_cast(item); 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 +234,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(item)->border()); break; + case QGeoMap::MapCircle: + q->disconnect(static_cast(item)->border()); + break; case QGeoMap::MapPolygon: q->disconnect(static_cast(item)->border()); break; diff --git a/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp b/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp index f79f0a38..f8bd9b4d 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 path; + QGeoCoordinate leftBound; + QDeclarativeCircleMapItem::calculatePeripheralPoints(path, mapItem->center(), mapItem->radius(), circleSamples, leftBound); + QList 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(&mapItem->geoShape()); @@ -126,6 +152,8 @@ QMapbox::Feature featureFromMapItem(QDeclarativeGeoMapItemBase *item) switch (item->itemType()) { case QGeoMap::MapRectangle: return featureFromMapRectangle(static_cast(item)); + case QGeoMap::MapCircle: + return featureFromMapCircle(static_cast(item)); case QGeoMap::MapPolygon: return featureFromMapPolygon(static_cast(item)); case QGeoMap::MapPolyline: @@ -182,6 +210,7 @@ QList> QMapboxGLStyleChange::addMapItem(QDe switch (item->itemType()) { case QGeoMap::MapRectangle: + case QGeoMap::MapCircle: case QGeoMap::MapPolygon: case QGeoMap::MapPolyline: break; @@ -325,6 +354,8 @@ QList> QMapboxGLStyleSetPaintProperty::from switch (item->itemType()) { case QGeoMap::MapRectangle: return fromMapItem(static_cast(item)); + case QGeoMap::MapCircle: + return fromMapItem(static_cast(item)); case QGeoMap::MapPolygon: return fromMapItem(static_cast(item)); case QGeoMap::MapPolyline: @@ -352,6 +383,23 @@ QList> QMapboxGLStyleSetPaintProperty::from return changes; } +QList> QMapboxGLStyleSetPaintProperty::fromMapItem(QDeclarativeCircleMapItem *item) +{ + QList> changes; + changes.reserve(3); + + const QString id = getId(item); + + changes << QSharedPointer( + new QMapboxGLStyleSetPaintProperty(id, QStringLiteral("fill-opacity"), item->mapItemOpacity())); + changes << QSharedPointer( + new QMapboxGLStyleSetPaintProperty(id, QStringLiteral("fill-color"), item->color())); + changes << QSharedPointer( + new QMapboxGLStyleSetPaintProperty(id, QStringLiteral("fill-outline-color"), item->border()->color())); + + return changes; +} + QList> QMapboxGLStyleSetPaintProperty::fromMapItem(QDeclarativePolygonMapItem *item) { QList> 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> fromMapItem(QDeclarativeRectangleMapItem *); + static QList> fromMapItem(QDeclarativeCircleMapItem *); static QList> fromMapItem(QDeclarativePolygonMapItem *); static QList> fromMapItem(QDeclarativePolylineMapItem *); -- cgit v1.2.1 From 8f80da7ea0165adb492c71255d0eea5f08c0af8e Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Fri, 1 Sep 2017 19:07:29 +0300 Subject: Fix Mapbox GL plugin not respecting MapItem visibility and opacity Now opacity and visibility will be respected for the fill color as borders are not supported yet. Change-Id: I58f982dc9285537fde770e14238c5d6d903913e6 Reviewed-by: Paolo Angelelli --- src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.cpp | 9 +++++++++ src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp | 13 ++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) (limited to 'src/plugins/geoservices') diff --git a/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.cpp b/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.cpp index 2f506325..e56fe9b0 100644 --- a/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.cpp +++ b/src/plugins/geoservices/mapboxgl/qgeomapmapboxgl.cpp @@ -190,6 +190,8 @@ void QGeoMapMapboxGLPrivate::addMapItem(QDeclarativeGeoMapItemBase *item) return; case QGeoMap::MapRectangle: { QDeclarativeRectangleMapItem *mapItem = static_cast(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); @@ -198,6 +200,8 @@ void QGeoMapMapboxGLPrivate::addMapItem(QDeclarativeGeoMapItemBase *item) } break; case QGeoMap::MapCircle: { QDeclarativeCircleMapItem *mapItem = static_cast(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); @@ -206,6 +210,8 @@ void QGeoMapMapboxGLPrivate::addMapItem(QDeclarativeGeoMapItemBase *item) } break; case QGeoMap::MapPolygon: { QDeclarativePolygonMapItem *mapItem = static_cast(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); @@ -213,6 +219,8 @@ void QGeoMapMapboxGLPrivate::addMapItem(QDeclarativeGeoMapItemBase *item) } break; case QGeoMap::MapPolyline: { QDeclarativePolylineMapItem *mapItem = static_cast(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); @@ -391,6 +399,7 @@ void QGeoMapMapboxGL::onMapItemPropertyChanged() QDeclarativeGeoMapItemBase *item = static_cast(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 f8bd9b4d..69bb6e4b 100644 --- a/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp +++ b/src/plugins/geoservices/mapboxgl/qmapboxglstylechange.cpp @@ -279,13 +279,20 @@ QList> QMapboxGLStyleSetLayoutProperty::fro QList> QMapboxGLStyleSetLayoutProperty::fromMapItem(QDeclarativeGeoMapItemBase *item) { + QList> changes; + switch (item->itemType()) { case QGeoMap::MapPolyline: - return fromMapItem(static_cast(item)); + changes = fromMapItem(static_cast(item)); default: - qWarning() << "Unsupported QGeoMap item type: " << item->itemType(); - return QList>(); + break; } + + changes << QSharedPointer( + new QMapboxGLStyleSetLayoutProperty(getId(item), QStringLiteral("visibility"), + item->isVisible() ? QStringLiteral("visible") : QStringLiteral("none"))); + + return changes; } QList> QMapboxGLStyleSetLayoutProperty::fromMapItem(QDeclarativePolylineMapItem *item) -- cgit v1.2.1