From e52c7f4395e0f19fe66ccd6534136c935a657d6e Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Fri, 7 Jul 2017 19:07:19 -0700 Subject: [PATCH] Add more efficient overlay getters, don't use blocking calls --- interface/src/ui/overlays/Overlays.cpp | 41 +++++++++++++++++++++----- interface/src/ui/overlays/Overlays.h | 4 +++ 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/interface/src/ui/overlays/Overlays.cpp b/interface/src/ui/overlays/Overlays.cpp index bcf9897dd8..2f22b62306 100644 --- a/interface/src/ui/overlays/Overlays.cpp +++ b/interface/src/ui/overlays/Overlays.cpp @@ -414,20 +414,47 @@ OverlayID Overlays::getOverlayAtPoint(const glm::vec2& point) { } OverlayPropertyResult Overlays::getProperty(OverlayID id, const QString& property) { - if (QThread::currentThread() != thread()) { - OverlayPropertyResult result; - BLOCKING_INVOKE_METHOD(this, "getProperty", Q_RETURN_ARG(OverlayPropertyResult, result), Q_ARG(OverlayID, id), Q_ARG(QString, property)); - return result; - } - - OverlayPropertyResult result; Overlay::Pointer thisOverlay = getOverlay(id); + OverlayPropertyResult result; if (thisOverlay && thisOverlay->supportsGetProperty()) { result.value = thisOverlay->getProperty(property); } return result; } +OverlayPropertyResult Overlays::getProperties(const OverlayID& id, const QStringList& properties) { + Overlay::Pointer thisOverlay = getOverlay(id); + OverlayPropertyResult result; + if (thisOverlay && thisOverlay->supportsGetProperty()) { + QVariantMap mapResult; + for (const auto& property : properties) { + mapResult.insert(property, thisOverlay->getProperty(property)); + } + result.value = mapResult; + } + return result; +} + +OverlayPropertyResult Overlays::getOverlaysProperties(const QVariant& propertiesById) { + QVariantMap map = propertiesById.toMap(); + OverlayPropertyResult result; + QVariantMap resultMap; + for (const auto& key : map.keys()) { + OverlayID id = OverlayID(key); + QVariantMap overlayResult; + Overlay::Pointer thisOverlay = getOverlay(id); + if (thisOverlay && thisOverlay->supportsGetProperty()) { + QStringList propertiesToFetch = map[key].toStringList(); + for (const auto& property : propertiesToFetch) { + overlayResult[property] = thisOverlay->getProperty(property); + } + } + resultMap[key] = overlayResult; + } + result.value = resultMap; + return result; +} + OverlayPropertyResult::OverlayPropertyResult() { } diff --git a/interface/src/ui/overlays/Overlays.h b/interface/src/ui/overlays/Overlays.h index bfb775b041..100f853a96 100644 --- a/interface/src/ui/overlays/Overlays.h +++ b/interface/src/ui/overlays/Overlays.h @@ -190,6 +190,10 @@ public slots: */ OverlayPropertyResult getProperty(OverlayID id, const QString& property); + OverlayPropertyResult getProperties(const OverlayID& id, const QStringList& properties); + + OverlayPropertyResult getOverlaysProperties(const QVariant& overlaysProperties); + /*jsdoc * Find the closest 3D overlay hit by a pick ray. *