From f94e0d1a107807065ab43deee25f3cde1764bdd4 Mon Sep 17 00:00:00 2001 From: Archibald Neil MacDonald Date: Thu, 30 Jan 2020 12:56:35 +0000 Subject: [PATCH 1/8] Symbol rendering changes. * Location display is now a PictureMarkerSymbol * DrapedFlat is DrapedBillboarded for messages. * Removed deprecated portions of application code. --- Shared/LocationController.cpp | 76 +++------------------- Shared/LocationController.h | 14 +--- Shared/LocationDisplay3d.cpp | 19 ++---- Shared/LocationDisplay3d.h | 7 +- Shared/messages/MessageFeedsController.cpp | 2 +- Shared/messages/MessagesOverlay.cpp | 2 +- 6 files changed, 23 insertions(+), 97 deletions(-) diff --git a/Shared/LocationController.cpp b/Shared/LocationController.cpp index 0f70ba20..3a8e1f90 100644 --- a/Shared/LocationController.cpp +++ b/Shared/LocationController.cpp @@ -31,6 +31,7 @@ // C++ API headers #include "GraphicsOverlay.h" #include "ModelSceneSymbol.h" +#include "PictureMarkerSymbol.h" #include "Point.h" #include "SceneQuickView.h" #include "SimpleRenderer.h" @@ -108,7 +109,6 @@ void LocationController::initPositionInfoSource() m_lastKnownHeading = heading; emit headingChanged(heading); - emit relativeHeadingChanged(heading - m_lastViewHeading); }); } else @@ -358,25 +358,6 @@ void LocationController::setGpxFilePath(const QString& gpxFilePath) emit propertyChanged(GPX_FILE_PROPERTYNAME, m_gpxFilePath); } -/*! - \brief Sets the \a sceneView to use for relative heading changes. - */ -void LocationController::setRelativeHeadingSceneView(SceneQuickView* sceneView) -{ - connect(sceneView, &SceneQuickView::viewpointChanged, this, [this, sceneView]() - { - const auto sceneViewHeading = sceneView->currentViewpointCamera().heading(); - if (std::abs(m_lastViewHeading - sceneViewHeading) < 0.1) - return; - - m_lastViewHeading = sceneViewHeading; - - // keep the orientation correct if we're not doing any updates - if (!m_enabled) - emit relativeHeadingChanged(m_lastKnownHeading + m_lastViewHeading); - }); -} - /*! \internal */ @@ -388,17 +369,13 @@ void LocationController::updateGeoView() geoView->graphicsOverlays()->append(m_locationDisplay3d->locationOverlay()); constexpr float symbolSize = 25.0; - constexpr double rangeMultiplier = 1.04; // the closer to 1.0, the smoother the transitions - constexpr double maxRange = 10000000.0; - - const QUrl modelPath = modelSymbolPath(); - ModelSceneSymbol* modelSceneSymbol = new ModelSceneSymbol(modelPath, this); - modelSceneSymbol->setWidth(symbolSize); - modelSceneSymbol->setDepth(symbolSize); - modelSceneSymbol->setSymbolSizeUnits(SymbolSizeUnits::DIPs); - - m_locationDisplay3d->setDefaultSymbol(modelSceneSymbol); + PictureMarkerSymbol* pictureMarkerSymbol = new PictureMarkerSymbol(iconSymbol(), this); + pictureMarkerSymbol->setWidth(symbolSize); + pictureMarkerSymbol->setHeight(symbolSize); + pictureMarkerSymbol->setRotationType(RotationType::Geographic); + pictureMarkerSymbol->setAngleAlignment(SymbolAngleAlignment::Map); + m_locationDisplay3d->setDefaultSymbol(pictureMarkerSymbol); } } @@ -417,45 +394,12 @@ void LocationController::setIconDataPath(const QString& dataPath) /*! \brief Returns the URL of the model symbol used for location display. */ -QUrl LocationController::modelSymbolPath() const +QImage LocationController::iconSymbol() const { - // both files are needed: LocationDisplay.dae - // and navigation.png and both must be local (not resources) - QString modelPath = m_iconDataPath + "/LocationDisplay.dae"; QString imagePath = m_iconDataPath + "/navigation.png"; - if (QFile::exists(modelPath) && QFile::exists(imagePath)) - return QUrl::fromLocalFile(modelPath); - - const QString tempPath = QDir::tempPath(); - modelPath = tempPath + "/LocationDisplay.dae"; - imagePath = tempPath + "/navigation.png"; - - // check if we've already copied them to temp - if (QFile::exists(modelPath) && QFile::exists(imagePath)) - return QUrl::fromLocalFile(modelPath); - - // if they're not both available, save both from resources to temp - // and access from there - QFile modelResource(":Resources/LocationDisplay.dae"); - QFile imageResource(":Resources/icons/xhdpi/navigation.png"); - - modelResource.open(QIODevice::ReadOnly); - imageResource.open(QIODevice::ReadOnly); - - QFile modelFileTemp(modelPath); - QFile imageFileTemp(imagePath); - - modelFileTemp.open(QIODevice::WriteOnly); - imageFileTemp.open(QIODevice::WriteOnly); - - modelFileTemp.write(modelResource.readAll()); - imageFileTemp.write(imageResource.readAll()); - - for (QFile* file : { &modelResource, &imageResource, &modelFileTemp, &imageFileTemp }) - file->close(); - - return QUrl::fromLocalFile(modelPath); + return (QFile::exists(imagePath)) ? QImage(imagePath) + : QImage(":Resources/icons/xhdpi/navigation.png"); } } // Dsa diff --git a/Shared/LocationController.h b/Shared/LocationController.h index a2bff154..148767f2 100644 --- a/Shared/LocationController.h +++ b/Shared/LocationController.h @@ -79,14 +79,6 @@ class LocationController : public Esri::ArcGISRuntime::Toolkit::AbstractTool QString iconDataPath() const { return m_iconDataPath; } void setIconDataPath(const QString& dataPath); - // if using GraphicsRenderingMode::Dynamic for rendering, then we need to massage - // the heading value to make sure it's correct when the scene is rotated. - // Set the sceneView here and connect to relativeHeadingChanged and that will - // be handled automatically. - // Note: this is only needed for PictureMarkerSymbol. ModelSceneSybol already - // takes this into account - void setRelativeHeadingSceneView(Esri::ArcGISRuntime::SceneQuickView* sceneView); - signals: void locationChanged(const Esri::ArcGISRuntime::Point& newLocation); void headingChanged(double newHeading); @@ -96,23 +88,19 @@ class LocationController : public Esri::ArcGISRuntime::Toolkit::AbstractTool void simulationEnabledChanged(); void toolErrorOccurred(const QString& errorMessage, const QString& additionalMessage); - // see setRelativeHeadingSceneView - void relativeHeadingChanged(double relativeHeading); - private slots: void updateGeoView(); private: void initPositionInfoSource(); void clearPositionInfoSource(); - QUrl modelSymbolPath() const; + QImage iconSymbol() const; QGeoPositionInfoSource* m_positionSource = nullptr; QCompass* m_compass = nullptr; LocationDisplay3d* m_locationDisplay3d = nullptr; bool m_enabled = false; bool m_simulated = false; - double m_lastViewHeading = 0.0; double m_lastKnownHeading = 0.0; Esri::ArcGISRuntime::Point m_currentLocation; QString m_gpxFilePath; diff --git a/Shared/LocationDisplay3d.cpp b/Shared/LocationDisplay3d.cpp index 9167a0a9..f365b6fa 100644 --- a/Shared/LocationDisplay3d.cpp +++ b/Shared/LocationDisplay3d.cpp @@ -24,6 +24,7 @@ // C++ API headers #include "GraphicsOverlay.h" +#include "PictureMarkerSymbol.h" #include "SimpleRenderer.h" // Qt headers @@ -36,8 +37,6 @@ using namespace Esri::ArcGISRuntime; namespace Dsa { -static const QString s_headingAttribute{"heading"}; - /*! \class Dsa::LocationDisplay3d \inmodule Dsa @@ -57,11 +56,9 @@ LocationDisplay3d::LocationDisplay3d(QObject* parent) : m_locationGraphic(new Graphic(this)) { m_locationOverlay->setOverlayId(QStringLiteral("SCENEVIEWLOCATIONOVERLAY")); - m_locationOverlay->setSceneProperties(LayerSceneProperties(SurfacePlacement::Relative)); + m_locationOverlay->setSceneProperties(LayerSceneProperties(SurfacePlacement::DrapedFlat)); m_locationOverlay->setRenderingMode(GraphicsRenderingMode::Dynamic); m_locationOverlay->setVisible(false); - - m_locationGraphic->attributes()->insertAttribute(s_headingAttribute, 0.0); m_locationOverlay->graphics()->append(m_locationGraphic); } @@ -164,7 +161,7 @@ void LocationDisplay3d::setPositionSource(QGeoPositionInfoSource* positionSource m_headingConnection = connect(gpxLocationSimulator, &GPXLocationSimulator::headingChanged, this, [this](double heading) { - m_locationGraphic->attributes()->replaceAttribute(s_headingAttribute, heading); + m_defaultSymbol->setAngle(static_cast(-heading)); }); } @@ -202,7 +199,7 @@ void LocationDisplay3d::setCompass(QCompass* compass) if (!reading) return; - m_locationGraphic->attributes()->replaceAttribute(s_headingAttribute, static_cast(reading->azimuth())); + m_defaultSymbol->setAngle(static_cast(-reading->azimuth())); emit headingChanged(); }); @@ -229,7 +226,7 @@ Graphic* LocationDisplay3d::locationGraphic() const /*! \brief Returns the default symbol for the location display. */ -Symbol* LocationDisplay3d::defaultSymbol() const +PictureMarkerSymbol* LocationDisplay3d::defaultSymbol() const { return m_defaultSymbol; } @@ -237,17 +234,13 @@ Symbol* LocationDisplay3d::defaultSymbol() const /*! \brief Sets the default symbol for the location display to \a defaultSymbol. */ -void LocationDisplay3d::setDefaultSymbol(Symbol* defaultSymbol) +void LocationDisplay3d::setDefaultSymbol(PictureMarkerSymbol* defaultSymbol) { m_defaultSymbol = defaultSymbol; if (!m_locationRenderer) { m_locationRenderer = new SimpleRenderer(defaultSymbol, this); - RendererSceneProperties renderProperties = m_locationRenderer->sceneProperties(); - renderProperties.setHeadingExpression(QString("[%1]").arg(s_headingAttribute)); - m_locationRenderer->setSceneProperties(renderProperties); - m_locationOverlay->setRenderer(m_locationRenderer); } else diff --git a/Shared/LocationDisplay3d.h b/Shared/LocationDisplay3d.h index 22de8166..3dafe3c5 100644 --- a/Shared/LocationDisplay3d.h +++ b/Shared/LocationDisplay3d.h @@ -27,6 +27,7 @@ namespace Esri { namespace ArcGISRuntime { class Graphic; class GraphicsOverlay; + class PictureMarkerSymbol; class Symbol; class SimpleRenderer; }} @@ -58,8 +59,8 @@ class LocationDisplay3d : public QObject Esri::ArcGISRuntime::Graphic* locationGraphic() const; - Esri::ArcGISRuntime::Symbol* defaultSymbol() const; - void setDefaultSymbol(Esri::ArcGISRuntime::Symbol* defaultSymbol); + Esri::ArcGISRuntime::PictureMarkerSymbol* defaultSymbol() const; + void setDefaultSymbol(Esri::ArcGISRuntime::PictureMarkerSymbol* defaultSymbol); signals: void locationChanged(const Esri::ArcGISRuntime::Point& location); @@ -73,7 +74,7 @@ class LocationDisplay3d : public QObject mutable Esri::ArcGISRuntime::GraphicsOverlay* m_locationOverlay = nullptr; Esri::ArcGISRuntime::SimpleRenderer* m_locationRenderer = nullptr; Esri::ArcGISRuntime::Graphic* m_locationGraphic = nullptr; - Esri::ArcGISRuntime::Symbol* m_defaultSymbol = nullptr; + Esri::ArcGISRuntime::PictureMarkerSymbol* m_defaultSymbol = nullptr; QGeoPositionInfoSource* m_geoPositionInfoSource = nullptr; QCompass* m_compass = nullptr; Esri::ArcGISRuntime::Point m_lastKnownLocation; diff --git a/Shared/messages/MessageFeedsController.cpp b/Shared/messages/MessageFeedsController.cpp index 8aa770d8..c27f7089 100644 --- a/Shared/messages/MessageFeedsController.cpp +++ b/Shared/messages/MessageFeedsController.cpp @@ -371,7 +371,7 @@ SurfacePlacement MessageFeedsController::toSurfacePlacement(const QString& surfa if (surfacePlacement.compare("absolute", Qt::CaseInsensitive) == 0) return SurfacePlacement::Absolute; - return SurfacePlacement::DrapedFlat; // default + return SurfacePlacement::DrapedBillboarded; // default } /*! diff --git a/Shared/messages/MessagesOverlay.cpp b/Shared/messages/MessagesOverlay.cpp index dee9685c..59fbec26 100644 --- a/Shared/messages/MessagesOverlay.cpp +++ b/Shared/messages/MessagesOverlay.cpp @@ -46,7 +46,7 @@ namespace Dsa { \brief Constructor taking a \a geoView and an optional \a parent. */ MessagesOverlay::MessagesOverlay(GeoView* geoView, QObject* parent) : - MessagesOverlay(geoView, nullptr, QString(), SurfacePlacement::DrapedFlat, parent) + MessagesOverlay(geoView, nullptr, QString(), SurfacePlacement::DrapedBillboarded, parent) { } From c8b2bdf1c50fc13aa543cdcfc6d3c01b606dc927 Mon Sep 17 00:00:00 2001 From: Archibald Neil MacDonald <42203545+anmacdonald@users.noreply.github.com> Date: Thu, 30 Jan 2020 14:09:13 +0000 Subject: [PATCH 2/8] Update Shared/LocationController.cpp Co-Authored-By: Luke Smallwood --- Shared/LocationController.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Shared/LocationController.cpp b/Shared/LocationController.cpp index 3a8e1f90..7da1ec72 100644 --- a/Shared/LocationController.cpp +++ b/Shared/LocationController.cpp @@ -370,7 +370,7 @@ void LocationController::updateGeoView() constexpr float symbolSize = 25.0; - PictureMarkerSymbol* pictureMarkerSymbol = new PictureMarkerSymbol(iconSymbol(), this); + auto pictureMarkerSymbol = new PictureMarkerSymbol(iconSymbol(), this); pictureMarkerSymbol->setWidth(symbolSize); pictureMarkerSymbol->setHeight(symbolSize); pictureMarkerSymbol->setRotationType(RotationType::Geographic); @@ -442,4 +442,3 @@ QImage LocationController::iconSymbol() const An \a errorMessage and \a additionalMessage are passed through as parameters, describing the error that occurred. */ - From 7f8070767325e08559e0a6d2843d45393c3dc0f6 Mon Sep 17 00:00:00 2001 From: Archibald Neil MacDonald <42203545+anmacdonald@users.noreply.github.com> Date: Thu, 30 Jan 2020 14:09:37 +0000 Subject: [PATCH 3/8] Update Shared/LocationController.cpp Co-Authored-By: Luke Smallwood --- Shared/LocationController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Shared/LocationController.cpp b/Shared/LocationController.cpp index 7da1ec72..ec2c05b7 100644 --- a/Shared/LocationController.cpp +++ b/Shared/LocationController.cpp @@ -396,7 +396,7 @@ void LocationController::setIconDataPath(const QString& dataPath) */ QImage LocationController::iconSymbol() const { - QString imagePath = m_iconDataPath + "/navigation.png"; + const QString imagePath = m_iconDataPath + "/navigation.png"; return (QFile::exists(imagePath)) ? QImage(imagePath) : QImage(":Resources/icons/xhdpi/navigation.png"); From 5db0f9e43bd2aa6969c8691f4994146f77d5d817 Mon Sep 17 00:00:00 2001 From: Archibald Neil MacDonald <42203545+anmacdonald@users.noreply.github.com> Date: Thu, 30 Jan 2020 14:09:46 +0000 Subject: [PATCH 4/8] Update Shared/LocationController.h Co-Authored-By: Luke Smallwood --- Shared/LocationController.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Shared/LocationController.h b/Shared/LocationController.h index 148767f2..b0ce39ad 100644 --- a/Shared/LocationController.h +++ b/Shared/LocationController.h @@ -94,7 +94,7 @@ private slots: private: void initPositionInfoSource(); void clearPositionInfoSource(); - QImage iconSymbol() const; + QImage iconImage() const; QGeoPositionInfoSource* m_positionSource = nullptr; QCompass* m_compass = nullptr; From abcf66ec710e6db18b1571c38e9614e83109275b Mon Sep 17 00:00:00 2001 From: Archibald Neil MacDonald <42203545+anmacdonald@users.noreply.github.com> Date: Thu, 30 Jan 2020 14:09:53 +0000 Subject: [PATCH 5/8] Update Shared/LocationController.cpp Co-Authored-By: Luke Smallwood --- Shared/LocationController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Shared/LocationController.cpp b/Shared/LocationController.cpp index ec2c05b7..b0718989 100644 --- a/Shared/LocationController.cpp +++ b/Shared/LocationController.cpp @@ -394,7 +394,7 @@ void LocationController::setIconDataPath(const QString& dataPath) /*! \brief Returns the URL of the model symbol used for location display. */ -QImage LocationController::iconSymbol() const +QImage LocationController::iconImage() const { const QString imagePath = m_iconDataPath + "/navigation.png"; From 2513e8c47ee0a0a32f91f1a3578ed33990e167ef Mon Sep 17 00:00:00 2001 From: Archibald Neil MacDonald Date: Thu, 30 Jan 2020 14:12:10 +0000 Subject: [PATCH 6/8] Updated doc. --- Shared/LocationController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Shared/LocationController.cpp b/Shared/LocationController.cpp index b0718989..5bb2ebc7 100644 --- a/Shared/LocationController.cpp +++ b/Shared/LocationController.cpp @@ -392,7 +392,7 @@ void LocationController::setIconDataPath(const QString& dataPath) } /*! - \brief Returns the URL of the model symbol used for location display. + \brief Returns the QImage of the model symbol used for location display. */ QImage LocationController::iconImage() const { From a9bd51fad8daec75633b9bf0256fe98263875267 Mon Sep 17 00:00:00 2001 From: Archibald Neil MacDonald Date: Thu, 30 Jan 2020 14:26:45 +0000 Subject: [PATCH 7/8] Minor doc fix. --- Shared/LocationController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Shared/LocationController.cpp b/Shared/LocationController.cpp index 5bb2ebc7..ee4fc29e 100644 --- a/Shared/LocationController.cpp +++ b/Shared/LocationController.cpp @@ -392,7 +392,7 @@ void LocationController::setIconDataPath(const QString& dataPath) } /*! - \brief Returns the QImage of the model symbol used for location display. + \brief Returns the QImage of the navigation icon used for location display. */ QImage LocationController::iconImage() const { From 4efafe59492c4d024522fbe9d5c05a77dc795c13 Mon Sep 17 00:00:00 2001 From: Archibald Neil MacDonald Date: Thu, 30 Jan 2020 14:41:59 +0000 Subject: [PATCH 8/8] Fixed merge error. --- Shared/LocationController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Shared/LocationController.cpp b/Shared/LocationController.cpp index ee4fc29e..5ae71898 100644 --- a/Shared/LocationController.cpp +++ b/Shared/LocationController.cpp @@ -370,7 +370,7 @@ void LocationController::updateGeoView() constexpr float symbolSize = 25.0; - auto pictureMarkerSymbol = new PictureMarkerSymbol(iconSymbol(), this); + auto pictureMarkerSymbol = new PictureMarkerSymbol(iconImage(), this); pictureMarkerSymbol->setWidth(symbolSize); pictureMarkerSymbol->setHeight(symbolSize); pictureMarkerSymbol->setRotationType(RotationType::Geographic);