From fcb3cee0924e1625db7a233c1f158f27dd314a8c Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Sun, 5 Nov 2017 11:48:12 -0800 Subject: [PATCH 01/29] exploring how to to expose occluded/unoccluded outline styles --- libraries/render-utils/src/Outline.slh | 29 +++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/libraries/render-utils/src/Outline.slh b/libraries/render-utils/src/Outline.slh index ac56e4c95c..ad3a670cc4 100644 --- a/libraries/render-utils/src/Outline.slh +++ b/libraries/render-utils/src/Outline.slh @@ -39,6 +39,7 @@ void main(void) { vec2 texCoord0 = varTexCoord0+halfTexel; float outlinedDepth = texture(outlinedDepthMap, texCoord0).x; float intensity = 0.0; + float isOccluded = 0.0; if (outlinedDepth < FAR_Z) { // We're not on the far plane so we are on the outlined object, thus no outline to do! @@ -52,6 +53,7 @@ void main(void) { // Are we occluded? if (sceneDepth < (outlinedDepth-LINEAR_DEPTH_BIAS)) { intensity = params._fillOpacityOccluded; + isOccluded = 1.0; } else { intensity = params._fillOpacityUnoccluded; } @@ -66,6 +68,8 @@ void main(void) { int x; int y; + float sumOutlineDepth = 0; + for (y=0 ; y=0.0 && uv.x<=1.0) { outlinedDepth = texture(outlinedDepthMap, uv).x; - intensity += (outlinedDepth < FAR_Z) ? 1.0 : 0.0; + float touch = (outlinedDepth < FAR_Z) ? 1.0 : 0.0; + //sumOutlineDepth = min(outlinedDepth, sumOutlineDepth); + sumOutlineDepth += (outlinedDepth * touch); + intensity += touch; weight += 1.f; } uv.x += deltaUv.x; @@ -83,15 +90,31 @@ void main(void) { } } + if (intensity > 0) { + sumOutlineDepth /= intensity; + } else { + sumOutlineDepth = FAR_Z; + } + intensity /= weight; if (intensity < OPACITY_EPSILON) { discard; } - intensity = min(1.0, intensity / params._threshold) * params._intensity; + + // But we need to check the scene depth aginst the depth of the outline + float sceneDepth = texture(sceneDepthMap, texCoord0).x; + + // Transform to linear depth for better precision + outlinedDepth = -evalZeyeFromZdb(sumOutlineDepth); + sceneDepth = -evalZeyeFromZdb(sceneDepth); + // Are we occluded? + if (sceneDepth < (outlinedDepth/*-LINEAR_DEPTH_BIAS*/)) { + isOccluded = 1.0; + } } - outFragColor = vec4(params._color.rgb, intensity); + outFragColor = vec4(mix(params._color.rgb, vec3(0.1,1,0.1), isOccluded), intensity); } <@endfunc@> From e145e30049585583eddce26dda755edc3e1f4385 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Mon, 6 Nov 2017 22:47:07 -0800 Subject: [PATCH 02/29] Drafting the selection to highlight interface --- .../src/scripting/SelectionScriptingInterface.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/interface/src/scripting/SelectionScriptingInterface.h b/interface/src/scripting/SelectionScriptingInterface.h index d1a372c5c4..1d28f3fdb6 100644 --- a/interface/src/scripting/SelectionScriptingInterface.h +++ b/interface/src/scripting/SelectionScriptingInterface.h @@ -48,6 +48,17 @@ private: }; +class SelectionHighlightStyle { +public: + SelectionHighlightStyle() {} + + bool fromVariantMap(const QVariantMap& properties); + QVariantMap toVariantMap() const; + + + +}; + class SelectionScriptingInterface : public QObject, public Dependency { Q_OBJECT @@ -62,6 +73,10 @@ public: Q_INVOKABLE bool addToSelectedItemsList(const QString& listName, const QString& itemType, const QUuid& id); Q_INVOKABLE bool removeFromSelectedItemsList(const QString& listName, const QString& itemType, const QUuid& id); + Q_INVOKABLE bool enableListHighlight(const QString& listName, const QVariantMap& highlightStyle); + Q_INVOKABLE bool disableListHighlight(const QString& listName); + Q_INVOKABLE QVariantMap getListHighlightStyle(const QString& listName) const; + signals: void selectedItemsListChanged(const QString& listName); From fc53c26190aeed28df1e1c7070bf4fee03814563 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Tue, 14 Nov 2017 00:40:37 -0800 Subject: [PATCH 03/29] drafting the interface --- .../scripting/SelectionScriptingInterface.cpp | 35 ++++++++++++++++++- .../scripting/SelectionScriptingInterface.h | 8 ++++- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/interface/src/scripting/SelectionScriptingInterface.cpp b/interface/src/scripting/SelectionScriptingInterface.cpp index 2bc5e985f2..221c865c9c 100644 --- a/interface/src/scripting/SelectionScriptingInterface.cpp +++ b/interface/src/scripting/SelectionScriptingInterface.cpp @@ -77,11 +77,36 @@ bool SelectionScriptingInterface::clearSelectedItemsList(const QString& listName return true; } -bool SelectionScriptingInterface::enableListHighlight(const QString& listName, const QVariantMap& highlightStyle) { +bool SelectionScriptingInterface::enableListHighlight(const QString& listName, const QVariantMap& highlightStyleValues) { + auto highlightStyle = _highlightedListMap.value(listName); + if (!highlightStyle.isBoundToList()) { + GameplayObjects currentList = _selectedItemsListMap.value(listName); + if (!currentList.getContainsData()) { + _selectedItemsListMap.insert(listName, currentList); + } + } + + highlightStyle.fromVariantMap(highlightStyleValues); + highlightStyle.setBoundToList(true); + + _highlightedListMap.insert(listName, highlightStyle); + + + emit selectedItemsListChanged(listName); return true; } bool SelectionScriptingInterface::disableListHighlight(const QString& listName) { + auto highlightStyle = _highlightedListMap.find(listName); + if (highlightStyle != _highlightedListMap.end()) { + if ((*highlightStyle).isBoundToList()) { + GameplayObjects currentList = _selectedItemsListMap.value(listName); + if (currentList.getContainsData()) { + } + _highlightedListMap.erase(highlightStyle); + } + } + return true; } @@ -211,3 +236,11 @@ void SelectionToSceneHandler::updateSceneFromSelectedList() { qWarning() << "SelectionToSceneHandler::updateRendererSelectedList(), Unexpected null scene, possibly during application shutdown"; } } + + +bool SelectionHighlightStyle::fromVariantMap(const QVariantMap& properties) { + return true; +} +QVariantMap SelectionHighlightStyle::toVariantMap() const { + return QVariantMap(); +} \ No newline at end of file diff --git a/interface/src/scripting/SelectionScriptingInterface.h b/interface/src/scripting/SelectionScriptingInterface.h index 1e460a7698..738cd83e02 100644 --- a/interface/src/scripting/SelectionScriptingInterface.h +++ b/interface/src/scripting/SelectionScriptingInterface.h @@ -52,10 +52,14 @@ class SelectionHighlightStyle { public: SelectionHighlightStyle() {} + void setBoundToList(bool bound) { _isBoundToList = bound; } + bool isBoundToList() const { return _isBoundToList; } + bool fromVariantMap(const QVariantMap& properties); QVariantMap toVariantMap() const; - +protected: + bool _isBoundToList{ false }; }; @@ -117,6 +121,8 @@ signals: private: QMap _selectedItemsListMap; + QMap _highlightedListMap; + template bool addToGameplayObjects(const QString& listName, T idToAdd); template bool removeFromGameplayObjects(const QString& listName, T idToRemove); }; From d4f93b9203413992c99f62e73d14d9dbdd3c7952 Mon Sep 17 00:00:00 2001 From: samcake Date: Tue, 14 Nov 2017 18:21:02 -0800 Subject: [PATCH 04/29] Adding style from VariantMap --- .../scripting/SelectionScriptingInterface.cpp | 35 +++++++++++++++++++ .../scripting/SelectionScriptingInterface.h | 3 +- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/interface/src/scripting/SelectionScriptingInterface.cpp b/interface/src/scripting/SelectionScriptingInterface.cpp index 221c865c9c..3c4533dae5 100644 --- a/interface/src/scripting/SelectionScriptingInterface.cpp +++ b/interface/src/scripting/SelectionScriptingInterface.cpp @@ -239,6 +239,41 @@ void SelectionToSceneHandler::updateSceneFromSelectedList() { bool SelectionHighlightStyle::fromVariantMap(const QVariantMap& properties) { + auto outlineColor = properties["outlineColor"]; + if (outlineColor.isValid()) { + bool isValid; + auto color = xColorFromVariant(properties["outlineColor"], isValid); + if (isValid) { + _style.color = toGlm(color); + } + } + auto outlineWidth = properties["outlineWidth"]; + if (outlineWidth.isValid()) { + _style.outlineWidth = outlineWidth.toFloat(); + } + auto isOutlineSmooth = properties["isOutlineSmooth"]; + if (isOutlineSmooth.isValid()) { + _style.isOutlineSmooth = isOutlineSmooth.toBool(); + } + + auto outlineIntensity = properties["outlineIntensity"]; + if (outlineIntensity.isValid()) { + _style.outlineIntensity = outlineIntensity.toFloat(); + } + + auto isFilled = properties["isFilled"]; + if (isFilled.isValid()) { + _style.isFilled = isFilled.toBool(); + } + auto unoccludedFillOpacity = properties["unoccludedFillOpacity"]; + if (unoccludedFillOpacity.isValid()) { + _style.unoccludedFillOpacity = unoccludedFillOpacity.toFloat(); + } + auto occludedFillOpacity = properties["occludedFillOpacity"]; + if (occludedFillOpacity.isValid()) { + _style.occludedFillOpacity = occludedFillOpacity.toFloat(); + } + return true; } QVariantMap SelectionHighlightStyle::toVariantMap() const { diff --git a/interface/src/scripting/SelectionScriptingInterface.h b/interface/src/scripting/SelectionScriptingInterface.h index 738cd83e02..e5ae398e92 100644 --- a/interface/src/scripting/SelectionScriptingInterface.h +++ b/interface/src/scripting/SelectionScriptingInterface.h @@ -21,6 +21,7 @@ #include "RenderableEntityItem.h" #include "ui/overlays/Overlay.h" #include +#include class GameplayObjects { public: @@ -60,7 +61,7 @@ public: protected: bool _isBoundToList{ false }; - + render::HighlightStyle _style; }; class SelectionScriptingInterface : public QObject, public Dependency { From 771c64fc97d4afe9488ebd17b35423393bcdc23e Mon Sep 17 00:00:00 2001 From: samcake Date: Wed, 15 Nov 2017 18:21:07 -0800 Subject: [PATCH 05/29] Working on the selection highlight js interface --- .../scripting/SelectionScriptingInterface.cpp | 57 +++++++++++++++---- .../scripting/SelectionScriptingInterface.h | 6 ++ libraries/shared/src/GLMHelpers.cpp | 6 ++ libraries/shared/src/GLMHelpers.h | 2 + 4 files changed, 59 insertions(+), 12 deletions(-) diff --git a/interface/src/scripting/SelectionScriptingInterface.cpp b/interface/src/scripting/SelectionScriptingInterface.cpp index 3c4533dae5..50dc5c5b49 100644 --- a/interface/src/scripting/SelectionScriptingInterface.cpp +++ b/interface/src/scripting/SelectionScriptingInterface.cpp @@ -78,21 +78,24 @@ bool SelectionScriptingInterface::clearSelectedItemsList(const QString& listName } bool SelectionScriptingInterface::enableListHighlight(const QString& listName, const QVariantMap& highlightStyleValues) { - auto highlightStyle = _highlightedListMap.value(listName); - if (!highlightStyle.isBoundToList()) { + auto highlightStyle = _highlightedListMap.find(listName); + if (highlightStyle == _highlightedListMap.end()) { + highlightStyle = _highlightedListMap.insert(listName, SelectionHighlightStyle()); + } + + if (!(*highlightStyle).isBoundToList()) { GameplayObjects currentList = _selectedItemsListMap.value(listName); if (!currentList.getContainsData()) { _selectedItemsListMap.insert(listName, currentList); + highlightStyleChanged(listName); } + (*highlightStyle).setBoundToList(true); } - highlightStyle.fromVariantMap(highlightStyleValues); - highlightStyle.setBoundToList(true); - - _highlightedListMap.insert(listName, highlightStyle); + (*highlightStyle).fromVariantMap(highlightStyleValues); - emit selectedItemsListChanged(listName); + emit highlightStyleChanged(listName); return true; } @@ -104,6 +107,7 @@ bool SelectionScriptingInterface::disableListHighlight(const QString& listName) if (currentList.getContainsData()) { } _highlightedListMap.erase(highlightStyle); + emit selectedItemsListChanged(listName); } } @@ -114,6 +118,15 @@ QVariantMap SelectionScriptingInterface::getListHighlightStyle(const QString& li return QVariantMap(); } +render::HighlightStyle SelectionScriptingInterface::getHighlightStyle(const QString& listName) const { + auto highlightStyle = _highlightedListMap.find(listName); + if (highlightStyle != _highlightedListMap.end()) { + return render::HighlightStyle(); + } else { + return (*highlightStyle).getStyle(); + } +} + template bool SelectionScriptingInterface::addToGameplayObjects(const QString& listName, T idToAdd) { GameplayObjects currentList = _selectedItemsListMap.value(listName); currentList.addToGameplayObjects(idToAdd); @@ -237,6 +250,21 @@ void SelectionToSceneHandler::updateSceneFromSelectedList() { } } +void SelectionToSceneHandler::highlightStyleChanged(const QString& listName) { + auto mainScene = qApp->getMain3DScene(); + if (mainScene) { + auto thisStyle = DependencyManager::get()->getHighlightStyle(listName); + render::Transaction transaction; + render::ItemIDs finalList; + + transaction.resetSelectionHighlight(listName.toStdString(), thisStyle); + + mainScene->enqueueTransaction(transaction); + } + else { + qWarning() << "SelectionToSceneHandler::updateRendererSelectedList(), Unexpected null scene, possibly during application shutdown"; + } +} bool SelectionHighlightStyle::fromVariantMap(const QVariantMap& properties) { auto outlineColor = properties["outlineColor"]; @@ -261,10 +289,6 @@ bool SelectionHighlightStyle::fromVariantMap(const QVariantMap& properties) { _style.outlineIntensity = outlineIntensity.toFloat(); } - auto isFilled = properties["isFilled"]; - if (isFilled.isValid()) { - _style.isFilled = isFilled.toBool(); - } auto unoccludedFillOpacity = properties["unoccludedFillOpacity"]; if (unoccludedFillOpacity.isValid()) { _style.unoccludedFillOpacity = unoccludedFillOpacity.toFloat(); @@ -277,5 +301,14 @@ bool SelectionHighlightStyle::fromVariantMap(const QVariantMap& properties) { return true; } QVariantMap SelectionHighlightStyle::toVariantMap() const { - return QVariantMap(); + QVariantMap properties; + + properties["outlineColor"] = xColorToVariant(xColorFromGlm(_style.color)); + properties["outlineWidth"] = _style.outlineWidth; + properties["isOutlineSmooth"] = _style.isOutlineSmooth; + properties["outlineIntensity"] = _style.outlineIntensity; + properties["unoccludedFillOpacity"] = _style.unoccludedFillOpacity; + properties["occludedFillOpacity"] = _style.occludedFillOpacity; + + return properties; } \ No newline at end of file diff --git a/interface/src/scripting/SelectionScriptingInterface.h b/interface/src/scripting/SelectionScriptingInterface.h index e5ae398e92..e4f82c67b9 100644 --- a/interface/src/scripting/SelectionScriptingInterface.h +++ b/interface/src/scripting/SelectionScriptingInterface.h @@ -59,6 +59,8 @@ public: bool fromVariantMap(const QVariantMap& properties); QVariantMap toVariantMap() const; + render::HighlightStyle getStyle() const { return _style; } + protected: bool _isBoundToList{ false }; render::HighlightStyle _style; @@ -116,8 +118,11 @@ public: Q_INVOKABLE bool disableListHighlight(const QString& listName); Q_INVOKABLE QVariantMap getListHighlightStyle(const QString& listName) const; + render::HighlightStyle getHighlightStyle(const QString& listName) const; + signals: void selectedItemsListChanged(const QString& listName); + void highlightStyleChanged(const QString& listName); private: QMap _selectedItemsListMap; @@ -139,6 +144,7 @@ public: public slots: void selectedItemsListChanged(const QString& listName); + void highlightStyleChanged(const QString& listName); private: QString _listName { "" }; diff --git a/libraries/shared/src/GLMHelpers.cpp b/libraries/shared/src/GLMHelpers.cpp index 39fec45d90..ff1d29eed1 100644 --- a/libraries/shared/src/GLMHelpers.cpp +++ b/libraries/shared/src/GLMHelpers.cpp @@ -432,6 +432,12 @@ glm::vec3 toGlm(const xColor& color) { return glm::vec3(color.red, color.green, color.blue) / MAX_COLOR; } +xColor xColorFromGlm(const glm::vec3 & color) { + static const float MAX_COLOR = 255.0f; + return { (uint8_t)(color.x * MAX_COLOR), (uint8_t)(color.y * MAX_COLOR), (uint8_t)(color.z * MAX_COLOR) }; +} + + glm::vec4 toGlm(const QColor& color) { return glm::vec4(color.redF(), color.greenF(), color.blueF(), color.alphaF()); } diff --git a/libraries/shared/src/GLMHelpers.h b/libraries/shared/src/GLMHelpers.h index 7248f4cb46..973998b927 100644 --- a/libraries/shared/src/GLMHelpers.h +++ b/libraries/shared/src/GLMHelpers.h @@ -177,6 +177,8 @@ vec4 toGlm(const QColor& color); ivec4 toGlm(const QRect& rect); vec4 toGlm(const xColor& color, float alpha); +xColor xColorFromGlm(const glm::vec3 & c); + QSize fromGlm(const glm::ivec2 & v); QMatrix4x4 fromGlm(const glm::mat4 & m); From 3a0b2651d51ce2871091ceeefc93ee5142a8b667 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Thu, 16 Nov 2017 00:55:51 -0800 Subject: [PATCH 06/29] Keep spinning on the bridge between js interface and the highlighting feature --- .../scripting/SelectionScriptingInterface.cpp | 60 +++++++++++++++---- .../scripting/SelectionScriptingInterface.h | 38 +++++++----- .../ui/overlays/ContextOverlayInterface.cpp | 5 +- 3 files changed, 74 insertions(+), 29 deletions(-) diff --git a/interface/src/scripting/SelectionScriptingInterface.cpp b/interface/src/scripting/SelectionScriptingInterface.cpp index 50dc5c5b49..c16d60d658 100644 --- a/interface/src/scripting/SelectionScriptingInterface.cpp +++ b/interface/src/scripting/SelectionScriptingInterface.cpp @@ -78,22 +78,28 @@ bool SelectionScriptingInterface::clearSelectedItemsList(const QString& listName } bool SelectionScriptingInterface::enableListHighlight(const QString& listName, const QVariantMap& highlightStyleValues) { + bool doSetupHandler = false; + auto highlightStyle = _highlightedListMap.find(listName); if (highlightStyle == _highlightedListMap.end()) { highlightStyle = _highlightedListMap.insert(listName, SelectionHighlightStyle()); + doSetupHandler = true; } if (!(*highlightStyle).isBoundToList()) { GameplayObjects currentList = _selectedItemsListMap.value(listName); if (!currentList.getContainsData()) { _selectedItemsListMap.insert(listName, currentList); - highlightStyleChanged(listName); + doSetupHandler = true; } (*highlightStyle).setBoundToList(true); } (*highlightStyle).fromVariantMap(highlightStyleValues); + if (doSetupHandler) { + setupHandler(listName); + } emit highlightStyleChanged(listName); return true; @@ -190,12 +196,41 @@ bool SelectionScriptingInterface::removeListFromMap(const QString& listName) { } } +void SelectionScriptingInterface::onSelectedItemsListChanged(const QString& listName) { + emit selectedItemsListChanged(listName); +} + +void SelectionScriptingInterface::onHighlightStyleChanged(const QString& listName) { + emit onHighlightStyleChanged(listName); +} + +void SelectionScriptingInterface::setupHandler(const QString& selectionName) { + auto handler = _handlerMap.find(selectionName); + if (handler == _handlerMap.end()) { + handler = _handlerMap.insert(selectionName, new SelectionToSceneHandler()); + } + + + (*handler)->initialize(selectionName); + +} + SelectionToSceneHandler::SelectionToSceneHandler() { } void SelectionToSceneHandler::initialize(const QString& listName) { _listName = listName; + + connect(&(*DependencyManager::get()), &SelectionScriptingInterface::selectedItemsListChanged, this, &SelectionToSceneHandler::selectedItemsListChanged); + connect(&(*DependencyManager::get()), &SelectionScriptingInterface::highlightStyleChanged, this, &SelectionToSceneHandler::highlightStyleChanged); + + auto mainScene = qApp->getMain3DScene(); + if (mainScene) { + render::Transaction transaction; + transaction.resetSelectionHighlight(listName.toStdString(), DependencyManager::get()->getHighlightStyle(listName)); + mainScene->enqueueTransaction(transaction); + } } void SelectionToSceneHandler::selectedItemsListChanged(const QString& listName) { @@ -251,18 +286,20 @@ void SelectionToSceneHandler::updateSceneFromSelectedList() { } void SelectionToSceneHandler::highlightStyleChanged(const QString& listName) { - auto mainScene = qApp->getMain3DScene(); - if (mainScene) { - auto thisStyle = DependencyManager::get()->getHighlightStyle(listName); - render::Transaction transaction; - render::ItemIDs finalList; + if (listName == _listName) { + auto mainScene = qApp->getMain3DScene(); + if (mainScene) { + auto thisStyle = DependencyManager::get()->getHighlightStyle(listName); + render::Transaction transaction; + render::ItemIDs finalList; - transaction.resetSelectionHighlight(listName.toStdString(), thisStyle); + transaction.resetSelectionHighlight(listName.toStdString(), thisStyle); - mainScene->enqueueTransaction(transaction); - } - else { - qWarning() << "SelectionToSceneHandler::updateRendererSelectedList(), Unexpected null scene, possibly during application shutdown"; + mainScene->enqueueTransaction(transaction); + } + else { + qWarning() << "SelectionToSceneHandler::updateRendererSelectedList(), Unexpected null scene, possibly during application shutdown"; + } } } @@ -300,6 +337,7 @@ bool SelectionHighlightStyle::fromVariantMap(const QVariantMap& properties) { return true; } + QVariantMap SelectionHighlightStyle::toVariantMap() const { QVariantMap properties; diff --git a/interface/src/scripting/SelectionScriptingInterface.h b/interface/src/scripting/SelectionScriptingInterface.h index e4f82c67b9..e27946c2fd 100644 --- a/interface/src/scripting/SelectionScriptingInterface.h +++ b/interface/src/scripting/SelectionScriptingInterface.h @@ -49,6 +49,23 @@ private: }; +class SelectionToSceneHandler : public QObject { + Q_OBJECT +public: + SelectionToSceneHandler(); + void initialize(const QString& listName); + + void updateSceneFromSelectedList(); + +public slots: + void selectedItemsListChanged(const QString& listName); + void highlightStyleChanged(const QString& listName); + +private: + QString _listName{ "" }; +}; +using SelectionToSceneHandlerPointer = QSharedPointer; + class SelectionHighlightStyle { public: SelectionHighlightStyle() {} @@ -120,6 +137,9 @@ public: render::HighlightStyle getHighlightStyle(const QString& listName) const; + void onSelectedItemsListChanged(const QString& listName); + void onHighlightStyleChanged(const QString& listName); + signals: void selectedItemsListChanged(const QString& listName); void highlightStyleChanged(const QString& listName); @@ -128,26 +148,12 @@ private: QMap _selectedItemsListMap; QMap _highlightedListMap; + QMap _handlerMap; template bool addToGameplayObjects(const QString& listName, T idToAdd); template bool removeFromGameplayObjects(const QString& listName, T idToRemove); -}; - -class SelectionToSceneHandler : public QObject { - Q_OBJECT -public: - SelectionToSceneHandler(); - void initialize(const QString& listName); - - void updateSceneFromSelectedList(); - -public slots: - void selectedItemsListChanged(const QString& listName); - void highlightStyleChanged(const QString& listName); - -private: - QString _listName { "" }; + void setupHandler(const QString& selectionName); }; #endif // hifi_SelectionScriptingInterface_h diff --git a/interface/src/ui/overlays/ContextOverlayInterface.cpp b/interface/src/ui/overlays/ContextOverlayInterface.cpp index d40c0972e9..cd55fa33a3 100644 --- a/interface/src/ui/overlays/ContextOverlayInterface.cpp +++ b/interface/src/ui/overlays/ContextOverlayInterface.cpp @@ -69,14 +69,15 @@ ContextOverlayInterface::ContextOverlayInterface() { connect(&qApp->getOverlays(), &Overlays::hoverLeaveOverlay, this, &ContextOverlayInterface::contextOverlays_hoverLeaveOverlay); { - render::Transaction transaction; + _selectionScriptingInterface->enableListHighlight("contextOverlayHighlightList", QVariantMap()); + /* render::Transaction transaction; initializeSelectionToSceneHandler(_selectionToSceneHandlers[0], "contextOverlayHighlightList", transaction); for (auto i = 1; i < MAX_SELECTION_COUNT; i++) { auto selectionName = QString("highlightList") + QString::number(i); initializeSelectionToSceneHandler(_selectionToSceneHandlers[i], selectionName, transaction); } const render::ScenePointer& scene = qApp->getMain3DScene(); - scene->enqueueTransaction(transaction); + scene->enqueueTransaction(transaction);*/ } auto nodeList = DependencyManager::get(); From 08dd76c9a818fdab0ae0a05f005acb85e7439002 Mon Sep 17 00:00:00 2001 From: samcake Date: Thu, 16 Nov 2017 17:52:12 -0800 Subject: [PATCH 07/29] changes of the day --- .../scripting/SelectionScriptingInterface.cpp | 84 +++++++++++-------- .../scripting/SelectionScriptingInterface.h | 11 +-- .../ui/overlays/ContextOverlayInterface.cpp | 14 ---- .../src/ui/overlays/ContextOverlayInterface.h | 3 - 4 files changed, 56 insertions(+), 56 deletions(-) diff --git a/interface/src/scripting/SelectionScriptingInterface.cpp b/interface/src/scripting/SelectionScriptingInterface.cpp index c16d60d658..651edf4501 100644 --- a/interface/src/scripting/SelectionScriptingInterface.cpp +++ b/interface/src/scripting/SelectionScriptingInterface.cpp @@ -83,38 +83,56 @@ bool SelectionScriptingInterface::enableListHighlight(const QString& listName, c auto highlightStyle = _highlightedListMap.find(listName); if (highlightStyle == _highlightedListMap.end()) { highlightStyle = _highlightedListMap.insert(listName, SelectionHighlightStyle()); - doSetupHandler = true; + } if (!(*highlightStyle).isBoundToList()) { - GameplayObjects currentList = _selectedItemsListMap.value(listName); - if (!currentList.getContainsData()) { - _selectedItemsListMap.insert(listName, currentList); - doSetupHandler = true; + auto currentList = _selectedItemsListMap.find(listName); + if (currentList == _selectedItemsListMap.end()) { + _selectedItemsListMap.insert(listName, GameplayObjects()); + setupHandler(listName); + // doSetupHandler = true; } (*highlightStyle).setBoundToList(true); } (*highlightStyle).fromVariantMap(highlightStyleValues); - if (doSetupHandler) { +/* if (doSetupHandler) { setupHandler(listName); + }*/ + + auto mainScene = qApp->getMain3DScene(); + if (mainScene) { + render::Transaction transaction; + transaction.resetSelectionHighlight(listName.toStdString(), (*highlightStyle).getStyle()); + mainScene->enqueueTransaction(transaction); + } + else { + qWarning() << "SelectionToSceneHandler::highlightStyleChanged(), Unexpected null scene, possibly during application shutdown"; } - emit highlightStyleChanged(listName); return true; } bool SelectionScriptingInterface::disableListHighlight(const QString& listName) { auto highlightStyle = _highlightedListMap.find(listName); if (highlightStyle != _highlightedListMap.end()) { - if ((*highlightStyle).isBoundToList()) { - GameplayObjects currentList = _selectedItemsListMap.value(listName); - if (currentList.getContainsData()) { - } + // if ((*highlightStyle).isBoundToList()) { _highlightedListMap.erase(highlightStyle); - emit selectedItemsListChanged(listName); - } + + auto mainScene = qApp->getMain3DScene(); + if (mainScene) { + render::Transaction transaction; + transaction.removeHighlightFromSelection(listName.toStdString()); + mainScene->enqueueTransaction(transaction); + } + else { + qWarning() << "SelectionToSceneHandler::highlightStyleChanged(), Unexpected null scene, possibly during application shutdown"; + } + // emit highlightStyleRemoved(listName); + + // } } return true; @@ -126,7 +144,7 @@ QVariantMap SelectionScriptingInterface::getListHighlightStyle(const QString& li render::HighlightStyle SelectionScriptingInterface::getHighlightStyle(const QString& listName) const { auto highlightStyle = _highlightedListMap.find(listName); - if (highlightStyle != _highlightedListMap.end()) { + if (highlightStyle == _highlightedListMap.end()) { return render::HighlightStyle(); } else { return (*highlightStyle).getStyle(); @@ -196,14 +214,6 @@ bool SelectionScriptingInterface::removeListFromMap(const QString& listName) { } } -void SelectionScriptingInterface::onSelectedItemsListChanged(const QString& listName) { - emit selectedItemsListChanged(listName); -} - -void SelectionScriptingInterface::onHighlightStyleChanged(const QString& listName) { - emit onHighlightStyleChanged(listName); -} - void SelectionScriptingInterface::setupHandler(const QString& selectionName) { auto handler = _handlerMap.find(selectionName); if (handler == _handlerMap.end()) { @@ -223,14 +233,9 @@ void SelectionToSceneHandler::initialize(const QString& listName) { _listName = listName; connect(&(*DependencyManager::get()), &SelectionScriptingInterface::selectedItemsListChanged, this, &SelectionToSceneHandler::selectedItemsListChanged); - connect(&(*DependencyManager::get()), &SelectionScriptingInterface::highlightStyleChanged, this, &SelectionToSceneHandler::highlightStyleChanged); + // connect(&(*DependencyManager::get()), &SelectionScriptingInterface::highlightStyleChanged, this, &SelectionToSceneHandler::highlightStyleChanged); + // connect(&(*DependencyManager::get()), &SelectionScriptingInterface::highlightStyleRemoved, this, &SelectionToSceneHandler::highlightStyleRemoved); - auto mainScene = qApp->getMain3DScene(); - if (mainScene) { - render::Transaction transaction; - transaction.resetSelectionHighlight(listName.toStdString(), DependencyManager::get()->getHighlightStyle(listName)); - mainScene->enqueueTransaction(transaction); - } } void SelectionToSceneHandler::selectedItemsListChanged(const QString& listName) { @@ -284,25 +289,36 @@ void SelectionToSceneHandler::updateSceneFromSelectedList() { qWarning() << "SelectionToSceneHandler::updateRendererSelectedList(), Unexpected null scene, possibly during application shutdown"; } } - +/* void SelectionToSceneHandler::highlightStyleChanged(const QString& listName) { if (listName == _listName) { auto mainScene = qApp->getMain3DScene(); if (mainScene) { auto thisStyle = DependencyManager::get()->getHighlightStyle(listName); render::Transaction transaction; - render::ItemIDs finalList; - transaction.resetSelectionHighlight(listName.toStdString(), thisStyle); - mainScene->enqueueTransaction(transaction); } else { - qWarning() << "SelectionToSceneHandler::updateRendererSelectedList(), Unexpected null scene, possibly during application shutdown"; + qWarning() << "SelectionToSceneHandler::highlightStyleChanged(), Unexpected null scene, possibly during application shutdown"; } } } +void SelectionToSceneHandler::highlightStyleRemoved(const QString& listName) { + if (listName == _listName) { + auto mainScene = qApp->getMain3DScene(); + if (mainScene) { + render::Transaction transaction; + transaction.removeHighlightFromSelection(listName.toStdString()); + mainScene->enqueueTransaction(transaction); + } + else { + qWarning() << "SelectionToSceneHandler::highlightStyleRemoved(), Unexpected null scene, possibly during application shutdown"; + } + } +} +*/ bool SelectionHighlightStyle::fromVariantMap(const QVariantMap& properties) { auto outlineColor = properties["outlineColor"]; if (outlineColor.isValid()) { diff --git a/interface/src/scripting/SelectionScriptingInterface.h b/interface/src/scripting/SelectionScriptingInterface.h index e27946c2fd..96cc71906f 100644 --- a/interface/src/scripting/SelectionScriptingInterface.h +++ b/interface/src/scripting/SelectionScriptingInterface.h @@ -59,7 +59,8 @@ public: public slots: void selectedItemsListChanged(const QString& listName); - void highlightStyleChanged(const QString& listName); + // void highlightStyleChanged(const QString& listName); + // void highlightStyleRemoved(const QString& listName); private: QString _listName{ "" }; @@ -137,12 +138,10 @@ public: render::HighlightStyle getHighlightStyle(const QString& listName) const; - void onSelectedItemsListChanged(const QString& listName); - void onHighlightStyleChanged(const QString& listName); - signals: void selectedItemsListChanged(const QString& listName); - void highlightStyleChanged(const QString& listName); + // void highlightStyleChanged(const QString& listName); + // void highlightStyleRemoved(const QString& listName); private: QMap _selectedItemsListMap; @@ -154,6 +153,8 @@ private: template bool removeFromGameplayObjects(const QString& listName, T idToRemove); void setupHandler(const QString& selectionName); + + }; #endif // hifi_SelectionScriptingInterface_h diff --git a/interface/src/ui/overlays/ContextOverlayInterface.cpp b/interface/src/ui/overlays/ContextOverlayInterface.cpp index cd55fa33a3..81896e7a94 100644 --- a/interface/src/ui/overlays/ContextOverlayInterface.cpp +++ b/interface/src/ui/overlays/ContextOverlayInterface.cpp @@ -70,14 +70,6 @@ ContextOverlayInterface::ContextOverlayInterface() { { _selectionScriptingInterface->enableListHighlight("contextOverlayHighlightList", QVariantMap()); - /* render::Transaction transaction; - initializeSelectionToSceneHandler(_selectionToSceneHandlers[0], "contextOverlayHighlightList", transaction); - for (auto i = 1; i < MAX_SELECTION_COUNT; i++) { - auto selectionName = QString("highlightList") + QString::number(i); - initializeSelectionToSceneHandler(_selectionToSceneHandlers[i], selectionName, transaction); - } - const render::ScenePointer& scene = qApp->getMain3DScene(); - scene->enqueueTransaction(transaction);*/ } auto nodeList = DependencyManager::get(); @@ -86,12 +78,6 @@ ContextOverlayInterface::ContextOverlayInterface() { _challengeOwnershipTimeoutTimer.setSingleShot(true); } -void ContextOverlayInterface::initializeSelectionToSceneHandler(SelectionToSceneHandler& handler, const QString& selectionName, render::Transaction& transaction) { - handler.initialize(selectionName); - connect(_selectionScriptingInterface.data(), &SelectionScriptingInterface::selectedItemsListChanged, &handler, &SelectionToSceneHandler::selectedItemsListChanged); - transaction.resetSelectionHighlight(selectionName.toStdString()); -} - static const uint32_t MOUSE_HW_ID = 0; static const uint32_t LEFT_HAND_HW_ID = 1; static const xColor CONTEXT_OVERLAY_COLOR = { 255, 255, 255 }; diff --git a/interface/src/ui/overlays/ContextOverlayInterface.h b/interface/src/ui/overlays/ContextOverlayInterface.h index 81e398e15d..990a7fe599 100644 --- a/interface/src/ui/overlays/ContextOverlayInterface.h +++ b/interface/src/ui/overlays/ContextOverlayInterface.h @@ -96,9 +96,6 @@ private: void disableEntityHighlight(const EntityItemID& entityItemID); void deletingEntity(const EntityItemID& entityItemID); - void initializeSelectionToSceneHandler(SelectionToSceneHandler& handler, const QString& selectionName, render::Transaction& transaction); - - SelectionToSceneHandler _selectionToSceneHandlers[MAX_SELECTION_COUNT]; Q_INVOKABLE void startChallengeOwnershipTimer(); QTimer _challengeOwnershipTimeoutTimer; From e0740b323da2f8c738c24e24904c0905b2b20d0c Mon Sep 17 00:00:00 2001 From: samcake Date: Fri, 17 Nov 2017 18:11:18 -0800 Subject: [PATCH 08/29] keep debuging the seelction highlight --- .../scripting/SelectionScriptingInterface.cpp | 76 +++++++++++-------- .../scripting/SelectionScriptingInterface.h | 2 + .../render-utils/src/HighlightEffect.cpp | 20 ++++- libraries/render/src/render/HighlightStage.h | 1 + libraries/render/src/render/Scene.cpp | 2 +- 5 files changed, 67 insertions(+), 34 deletions(-) diff --git a/interface/src/scripting/SelectionScriptingInterface.cpp b/interface/src/scripting/SelectionScriptingInterface.cpp index 651edf4501..9af0ed8c82 100644 --- a/interface/src/scripting/SelectionScriptingInterface.cpp +++ b/interface/src/scripting/SelectionScriptingInterface.cpp @@ -73,12 +73,11 @@ bool SelectionScriptingInterface::removeFromSelectedItemsList(const QString& lis bool SelectionScriptingInterface::clearSelectedItemsList(const QString& listName) { _selectedItemsListMap.insert(listName, GameplayObjects()); - emit selectedItemsListChanged(listName); + onSelectedItemsListChanged(listName); return true; } bool SelectionScriptingInterface::enableListHighlight(const QString& listName, const QVariantMap& highlightStyleValues) { - bool doSetupHandler = false; auto highlightStyle = _highlightedListMap.find(listName); if (highlightStyle == _highlightedListMap.end()) { @@ -90,18 +89,14 @@ bool SelectionScriptingInterface::enableListHighlight(const QString& listName, c auto currentList = _selectedItemsListMap.find(listName); if (currentList == _selectedItemsListMap.end()) { _selectedItemsListMap.insert(listName, GameplayObjects()); - setupHandler(listName); - // doSetupHandler = true; } + setupHandler(listName); + (*highlightStyle).setBoundToList(true); } (*highlightStyle).fromVariantMap(highlightStyleValues); -/* if (doSetupHandler) { - setupHandler(listName); - }*/ - auto mainScene = qApp->getMain3DScene(); if (mainScene) { render::Transaction transaction; @@ -139,7 +134,12 @@ bool SelectionScriptingInterface::disableListHighlight(const QString& listName) } QVariantMap SelectionScriptingInterface::getListHighlightStyle(const QString& listName) const { - return QVariantMap(); + auto highlightStyle = _highlightedListMap.find(listName); + if (highlightStyle == _highlightedListMap.end()) { + return QVariantMap(); + } else { + return (*highlightStyle).toVariantMap(); + } } render::HighlightStyle SelectionScriptingInterface::getHighlightStyle(const QString& listName) const { @@ -156,7 +156,7 @@ template bool SelectionScriptingInterface::addToGameplayObjects(const currentList.addToGameplayObjects(idToAdd); _selectedItemsListMap.insert(listName, currentList); - emit selectedItemsListChanged(listName); + onSelectedItemsListChanged(listName); return true; } template bool SelectionScriptingInterface::removeFromGameplayObjects(const QString& listName, T idToRemove) { @@ -165,7 +165,7 @@ template bool SelectionScriptingInterface::removeFromGameplayObjects(c currentList.removeFromGameplayObjects(idToRemove); _selectedItemsListMap.insert(listName, currentList); - emit selectedItemsListChanged(listName); + onSelectedItemsListChanged(listName); return true; } else { return false; @@ -180,34 +180,40 @@ GameplayObjects SelectionScriptingInterface::getList(const QString& listName) { } void SelectionScriptingInterface::printList(const QString& listName) { - GameplayObjects currentList = _selectedItemsListMap.value(listName); - if (currentList.getContainsData()) { + auto currentList = _selectedItemsListMap.find(listName); + if (currentList != _selectedItemsListMap.end()) { + if ((*currentList).getContainsData()) { - qDebug() << "Avatar IDs:"; - for (auto i : currentList.getAvatarIDs()) { - qDebug() << i << ';'; - } - qDebug() << ""; + qDebug() << "List named " << listName << ":"; + qDebug() << "Avatar IDs:"; + for (auto i : (*currentList).getAvatarIDs()) { + qDebug() << i << ';'; + } + qDebug() << ""; - qDebug() << "Entity IDs:"; - for (auto j : currentList.getEntityIDs()) { - qDebug() << j << ';'; - } - qDebug() << ""; + qDebug() << "Entity IDs:"; + for (auto j : (*currentList).getEntityIDs()) { + qDebug() << j << ';'; + } + qDebug() << ""; - qDebug() << "Overlay IDs:"; - for (auto k : currentList.getOverlayIDs()) { - qDebug() << k << ';'; + qDebug() << "Overlay IDs:"; + for (auto k : (*currentList).getOverlayIDs()) { + qDebug() << k << ';'; + } + qDebug() << ""; + } + else { + qDebug() << "List named " << listName << " empty"; } - qDebug() << ""; } else { - qDebug() << "List named" << listName << "doesn't exist."; + qDebug() << "List named " << listName << " doesn't exist."; } } bool SelectionScriptingInterface::removeListFromMap(const QString& listName) { if (_selectedItemsListMap.remove(listName)) { - emit selectedItemsListChanged(listName); + onSelectedItemsListChanged(listName); return true; } else { return false; @@ -222,9 +228,17 @@ void SelectionScriptingInterface::setupHandler(const QString& selectionName) { (*handler)->initialize(selectionName); + // connect(this, &SelectionScriptingInterface::selectedItemsListChanged, handler.value(), &SelectionToSceneHandler::selectedItemsListChanged); } +void SelectionScriptingInterface::onSelectedItemsListChanged(const QString& listName) { + auto handler = _handlerMap.find(listName); + if (handler != _handlerMap.end()) { + (*handler)->updateSceneFromSelectedList(); + } +} + SelectionToSceneHandler::SelectionToSceneHandler() { } @@ -232,10 +246,8 @@ SelectionToSceneHandler::SelectionToSceneHandler() { void SelectionToSceneHandler::initialize(const QString& listName) { _listName = listName; - connect(&(*DependencyManager::get()), &SelectionScriptingInterface::selectedItemsListChanged, this, &SelectionToSceneHandler::selectedItemsListChanged); - // connect(&(*DependencyManager::get()), &SelectionScriptingInterface::highlightStyleChanged, this, &SelectionToSceneHandler::highlightStyleChanged); - // connect(&(*DependencyManager::get()), &SelectionScriptingInterface::highlightStyleRemoved, this, &SelectionToSceneHandler::highlightStyleRemoved); + updateSceneFromSelectedList(); } void SelectionToSceneHandler::selectedItemsListChanged(const QString& listName) { diff --git a/interface/src/scripting/SelectionScriptingInterface.h b/interface/src/scripting/SelectionScriptingInterface.h index 96cc71906f..7d84443085 100644 --- a/interface/src/scripting/SelectionScriptingInterface.h +++ b/interface/src/scripting/SelectionScriptingInterface.h @@ -138,6 +138,8 @@ public: render::HighlightStyle getHighlightStyle(const QString& listName) const; + void onSelectedItemsListChanged(const QString& listName); + signals: void selectedItemsListChanged(const QString& listName); // void highlightStyleChanged(const QString& listName); diff --git a/libraries/render-utils/src/HighlightEffect.cpp b/libraries/render-utils/src/HighlightEffect.cpp index 7c58e5ba66..79ae96c07c 100644 --- a/libraries/render-utils/src/HighlightEffect.cpp +++ b/libraries/render-utils/src/HighlightEffect.cpp @@ -432,6 +432,24 @@ void SelectionToHighlight::run(const render::RenderContextPointer& renderContext outputs.clear(); _sharedParameters->_highlightIds.fill(render::HighlightStage::INVALID_INDEX); + int numLayers = 0; + auto highlightList = highlightStage->getActiveHighlightIds(); + + for (auto styleId : highlightList) { + auto highlight = highlightStage->getHighlight(styleId); + + if (!scene->isSelectionEmpty(highlight._selectionName)) { + auto highlightId = highlightStage->getHighlightIdBySelection(highlight._selectionName); + _sharedParameters->_highlightIds[outputs.size()] = highlightId; + outputs.emplace_back(highlight._selectionName); + numLayers++; + + if (numLayers == HighlightSharedParameters::MAX_PASS_COUNT) { + break; + } + } + } + /* for (auto i = 0; i < HighlightSharedParameters::MAX_PASS_COUNT; i++) { std::ostringstream stream; if (i > 0) { @@ -447,7 +465,7 @@ void SelectionToHighlight::run(const render::RenderContextPointer& renderContext outputs.emplace_back(selectionName); } } - } + }*/ } void ExtractSelectionName::run(const render::RenderContextPointer& renderContext, const Inputs& inputs, Outputs& outputs) { diff --git a/libraries/render/src/render/HighlightStage.h b/libraries/render/src/render/HighlightStage.h index b35fff654c..94c6e3ca69 100644 --- a/libraries/render/src/render/HighlightStage.h +++ b/libraries/render/src/render/HighlightStage.h @@ -51,6 +51,7 @@ namespace render { HighlightIdList::iterator begin() { return _activeHighlightIds.begin(); } HighlightIdList::iterator end() { return _activeHighlightIds.end(); } + const HighlightIdList& getActiveHighlightIds() const { return _activeHighlightIds; } private: diff --git a/libraries/render/src/render/Scene.cpp b/libraries/render/src/render/Scene.cpp index 88e25b6d27..dc1c6a0e49 100644 --- a/libraries/render/src/render/Scene.cpp +++ b/libraries/render/src/render/Scene.cpp @@ -442,7 +442,7 @@ bool Scene::isSelectionEmpty(const Selection::Name& name) const { std::unique_lock lock(_selectionsMutex); auto found = _selections.find(name); if (found == _selections.end()) { - return false; + return true; } else { return (*found).second.isEmpty(); } From aa163db4e69aa761e136438b9c70cade8da6e8e0 Mon Sep 17 00:00:00 2001 From: samcake Date: Mon, 20 Nov 2017 17:21:15 -0800 Subject: [PATCH 09/29] Trying to make selection threadsafe --- .../src/scripting/SelectionScriptingInterface.cpp | 15 +++++++++++++-- .../src/scripting/SelectionScriptingInterface.h | 4 ++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/interface/src/scripting/SelectionScriptingInterface.cpp b/interface/src/scripting/SelectionScriptingInterface.cpp index 9af0ed8c82..4200a8e0dd 100644 --- a/interface/src/scripting/SelectionScriptingInterface.cpp +++ b/interface/src/scripting/SelectionScriptingInterface.cpp @@ -72,12 +72,14 @@ bool SelectionScriptingInterface::removeFromSelectedItemsList(const QString& lis } bool SelectionScriptingInterface::clearSelectedItemsList(const QString& listName) { + // QWriteLocker lock(&_selectionListsLock); _selectedItemsListMap.insert(listName, GameplayObjects()); onSelectedItemsListChanged(listName); return true; } bool SelectionScriptingInterface::enableListHighlight(const QString& listName, const QVariantMap& highlightStyleValues) { + // QWriteLocker lock(&_selectionListsLock); auto highlightStyle = _highlightedListMap.find(listName); if (highlightStyle == _highlightedListMap.end()) { @@ -111,6 +113,7 @@ bool SelectionScriptingInterface::enableListHighlight(const QString& listName, c } bool SelectionScriptingInterface::disableListHighlight(const QString& listName) { + // QWriteLocker lock(&_selectionListsLock); auto highlightStyle = _highlightedListMap.find(listName); if (highlightStyle != _highlightedListMap.end()) { // if ((*highlightStyle).isBoundToList()) { @@ -134,6 +137,7 @@ bool SelectionScriptingInterface::disableListHighlight(const QString& listName) } QVariantMap SelectionScriptingInterface::getListHighlightStyle(const QString& listName) const { + // QReadLocker lock(&_selectionListsLock); auto highlightStyle = _highlightedListMap.find(listName); if (highlightStyle == _highlightedListMap.end()) { return QVariantMap(); @@ -143,6 +147,7 @@ QVariantMap SelectionScriptingInterface::getListHighlightStyle(const QString& li } render::HighlightStyle SelectionScriptingInterface::getHighlightStyle(const QString& listName) const { + // QReadLocker lock(&_selectionListsLock); auto highlightStyle = _highlightedListMap.find(listName); if (highlightStyle == _highlightedListMap.end()) { return render::HighlightStyle(); @@ -152,6 +157,8 @@ render::HighlightStyle SelectionScriptingInterface::getHighlightStyle(const QStr } template bool SelectionScriptingInterface::addToGameplayObjects(const QString& listName, T idToAdd) { + // QWriteLocker lock(&_selectionListsLock); + GameplayObjects currentList = _selectedItemsListMap.value(listName); currentList.addToGameplayObjects(idToAdd); _selectedItemsListMap.insert(listName, currentList); @@ -160,6 +167,7 @@ template bool SelectionScriptingInterface::addToGameplayObjects(const return true; } template bool SelectionScriptingInterface::removeFromGameplayObjects(const QString& listName, T idToRemove) { + // QWriteLocker lock(&_selectionListsLock); GameplayObjects currentList = _selectedItemsListMap.value(listName); if (currentList.getContainsData()) { currentList.removeFromGameplayObjects(idToRemove); @@ -176,10 +184,12 @@ template bool SelectionScriptingInterface::removeFromGameplayObjects(c // GameplayObjects SelectionScriptingInterface::getList(const QString& listName) { + // QReadLocker lock(&_selectionListsLock); return _selectedItemsListMap.value(listName); } void SelectionScriptingInterface::printList(const QString& listName) { + // QReadLocker lock(&_selectionListsLock); auto currentList = _selectedItemsListMap.find(listName); if (currentList != _selectedItemsListMap.end()) { if ((*currentList).getContainsData()) { @@ -212,6 +222,7 @@ void SelectionScriptingInterface::printList(const QString& listName) { } bool SelectionScriptingInterface::removeListFromMap(const QString& listName) { + // QWriteLocker lock(&_selectionListsLock); if (_selectedItemsListMap.remove(listName)) { onSelectedItemsListChanged(listName); return true; @@ -221,6 +232,7 @@ bool SelectionScriptingInterface::removeListFromMap(const QString& listName) { } void SelectionScriptingInterface::setupHandler(const QString& selectionName) { + // QWriteLocker lock(&_selectionListsLock); auto handler = _handlerMap.find(selectionName); if (handler == _handlerMap.end()) { handler = _handlerMap.insert(selectionName, new SelectionToSceneHandler()); @@ -233,6 +245,7 @@ void SelectionScriptingInterface::setupHandler(const QString& selectionName) { } void SelectionScriptingInterface::onSelectedItemsListChanged(const QString& listName) { + // QWriteLocker lock(&_selectionListsLock); auto handler = _handlerMap.find(listName); if (handler != _handlerMap.end()) { (*handler)->updateSceneFromSelectedList(); @@ -245,8 +258,6 @@ SelectionToSceneHandler::SelectionToSceneHandler() { void SelectionToSceneHandler::initialize(const QString& listName) { _listName = listName; - - updateSceneFromSelectedList(); } diff --git a/interface/src/scripting/SelectionScriptingInterface.h b/interface/src/scripting/SelectionScriptingInterface.h index 7d84443085..d22df73218 100644 --- a/interface/src/scripting/SelectionScriptingInterface.h +++ b/interface/src/scripting/SelectionScriptingInterface.h @@ -142,10 +142,9 @@ public: signals: void selectedItemsListChanged(const QString& listName); - // void highlightStyleChanged(const QString& listName); - // void highlightStyleRemoved(const QString& listName); private: + mutable QReadWriteLock _selectionListsLock; QMap _selectedItemsListMap; QMap _highlightedListMap; @@ -156,6 +155,7 @@ private: void setupHandler(const QString& selectionName); + }; From 1514cdfb2f2bd91619d712b8effc3e98e30ddd89 Mon Sep 17 00:00:00 2001 From: samcake Date: Tue, 21 Nov 2017 17:59:45 -0800 Subject: [PATCH 10/29] extend the set of interface for multi highlight --- .../scripting/SelectionScriptingInterface.cpp | 237 +++++++++-------- .../scripting/SelectionScriptingInterface.h | 5 +- libraries/render-utils/src/Highlight.slh | 24 +- .../render-utils/src/HighlightEffect.cpp | 21 +- .../render-utils/src/Highlight_shared.slh | 19 +- .../render/src/render/HighlightStage.cpp | 16 +- libraries/render/src/render/HighlightStage.h | 16 +- libraries/render/src/render/HighlightStyle.h | 21 +- .../utilities/render/debugHighlight.js | 105 ++++++++ .../utilities/render/debugHighlight2.js | 251 ++++++++++++++++++ .../developer/utilities/render/highlight2.qml | 177 ++++++++++++ 11 files changed, 729 insertions(+), 163 deletions(-) create mode 100644 scripts/developer/utilities/render/debugHighlight2.js create mode 100644 scripts/developer/utilities/render/highlight2.qml diff --git a/interface/src/scripting/SelectionScriptingInterface.cpp b/interface/src/scripting/SelectionScriptingInterface.cpp index 4200a8e0dd..ba500ae010 100644 --- a/interface/src/scripting/SelectionScriptingInterface.cpp +++ b/interface/src/scripting/SelectionScriptingInterface.cpp @@ -72,28 +72,29 @@ bool SelectionScriptingInterface::removeFromSelectedItemsList(const QString& lis } bool SelectionScriptingInterface::clearSelectedItemsList(const QString& listName) { - // QWriteLocker lock(&_selectionListsLock); - _selectedItemsListMap.insert(listName, GameplayObjects()); + { + QWriteLocker lock(&_selectionListsLock); + _selectedItemsListMap.insert(listName, GameplayObjects()); + } onSelectedItemsListChanged(listName); return true; } bool SelectionScriptingInterface::enableListHighlight(const QString& listName, const QVariantMap& highlightStyleValues) { - // QWriteLocker lock(&_selectionListsLock); + QWriteLocker lock(&_highlightStylesLock); - auto highlightStyle = _highlightedListMap.find(listName); - if (highlightStyle == _highlightedListMap.end()) { - highlightStyle = _highlightedListMap.insert(listName, SelectionHighlightStyle()); + auto highlightStyle = _highlightStyleMap.find(listName); + if (highlightStyle == _highlightStyleMap.end()) { + highlightStyle = _highlightStyleMap.insert(listName, SelectionHighlightStyle()); } if (!(*highlightStyle).isBoundToList()) { - auto currentList = _selectedItemsListMap.find(listName); + /* auto currentList = _selectedItemsListMap.find(listName); if (currentList == _selectedItemsListMap.end()) { _selectedItemsListMap.insert(listName, GameplayObjects()); - } + }*/ setupHandler(listName); - (*highlightStyle).setBoundToList(true); } @@ -113,33 +114,32 @@ bool SelectionScriptingInterface::enableListHighlight(const QString& listName, c } bool SelectionScriptingInterface::disableListHighlight(const QString& listName) { - // QWriteLocker lock(&_selectionListsLock); - auto highlightStyle = _highlightedListMap.find(listName); - if (highlightStyle != _highlightedListMap.end()) { - // if ((*highlightStyle).isBoundToList()) { - _highlightedListMap.erase(highlightStyle); + QWriteLocker lock(&_highlightStylesLock); + auto highlightStyle = _highlightStyleMap.find(listName); + if (highlightStyle != _highlightStyleMap.end()) { + if ((*highlightStyle).isBoundToList()) { + } - auto mainScene = qApp->getMain3DScene(); - if (mainScene) { - render::Transaction transaction; - transaction.removeHighlightFromSelection(listName.toStdString()); - mainScene->enqueueTransaction(transaction); - } - else { - qWarning() << "SelectionToSceneHandler::highlightStyleChanged(), Unexpected null scene, possibly during application shutdown"; - } - // emit highlightStyleRemoved(listName); + _highlightStyleMap.erase(highlightStyle); - // } + auto mainScene = qApp->getMain3DScene(); + if (mainScene) { + render::Transaction transaction; + transaction.removeHighlightFromSelection(listName.toStdString()); + mainScene->enqueueTransaction(transaction); + } + else { + qWarning() << "SelectionToSceneHandler::highlightStyleChanged(), Unexpected null scene, possibly during application shutdown"; + } } return true; } QVariantMap SelectionScriptingInterface::getListHighlightStyle(const QString& listName) const { - // QReadLocker lock(&_selectionListsLock); - auto highlightStyle = _highlightedListMap.find(listName); - if (highlightStyle == _highlightedListMap.end()) { + QReadLocker lock(&_highlightStylesLock); + auto highlightStyle = _highlightStyleMap.find(listName); + if (highlightStyle == _highlightStyleMap.end()) { return QVariantMap(); } else { return (*highlightStyle).toVariantMap(); @@ -147,9 +147,9 @@ QVariantMap SelectionScriptingInterface::getListHighlightStyle(const QString& li } render::HighlightStyle SelectionScriptingInterface::getHighlightStyle(const QString& listName) const { - // QReadLocker lock(&_selectionListsLock); - auto highlightStyle = _highlightedListMap.find(listName); - if (highlightStyle == _highlightedListMap.end()) { + QReadLocker lock(&_highlightStylesLock); + auto highlightStyle = _highlightStyleMap.find(listName); + if (highlightStyle == _highlightStyleMap.end()) { return render::HighlightStyle(); } else { return (*highlightStyle).getStyle(); @@ -157,25 +157,30 @@ render::HighlightStyle SelectionScriptingInterface::getHighlightStyle(const QStr } template bool SelectionScriptingInterface::addToGameplayObjects(const QString& listName, T idToAdd) { - // QWriteLocker lock(&_selectionListsLock); - - GameplayObjects currentList = _selectedItemsListMap.value(listName); - currentList.addToGameplayObjects(idToAdd); - _selectedItemsListMap.insert(listName, currentList); - + { + QWriteLocker lock(&_selectionListsLock); + GameplayObjects currentList = _selectedItemsListMap.value(listName); + currentList.addToGameplayObjects(idToAdd); + _selectedItemsListMap.insert(listName, currentList); + } onSelectedItemsListChanged(listName); return true; } template bool SelectionScriptingInterface::removeFromGameplayObjects(const QString& listName, T idToRemove) { - // QWriteLocker lock(&_selectionListsLock); - GameplayObjects currentList = _selectedItemsListMap.value(listName); - if (currentList.getContainsData()) { - currentList.removeFromGameplayObjects(idToRemove); - _selectedItemsListMap.insert(listName, currentList); - + bool listExist = false; + { + QWriteLocker lock(&_selectionListsLock); + auto currentList = _selectedItemsListMap.find(listName); + if (currentList != _selectedItemsListMap.end()) { + listExist = true; + (*currentList).removeFromGameplayObjects(idToRemove); + } + } + if (listExist) { onSelectedItemsListChanged(listName); return true; - } else { + } + else { return false; } } @@ -184,12 +189,12 @@ template bool SelectionScriptingInterface::removeFromGameplayObjects(c // GameplayObjects SelectionScriptingInterface::getList(const QString& listName) { - // QReadLocker lock(&_selectionListsLock); + QReadLocker lock(&_selectionListsLock); return _selectedItemsListMap.value(listName); } void SelectionScriptingInterface::printList(const QString& listName) { - // QReadLocker lock(&_selectionListsLock); + QReadLocker lock(&_selectionListsLock); auto currentList = _selectedItemsListMap.find(listName); if (currentList != _selectedItemsListMap.end()) { if ((*currentList).getContainsData()) { @@ -222,8 +227,12 @@ void SelectionScriptingInterface::printList(const QString& listName) { } bool SelectionScriptingInterface::removeListFromMap(const QString& listName) { - // QWriteLocker lock(&_selectionListsLock); - if (_selectedItemsListMap.remove(listName)) { + bool removed = false; + { + QWriteLocker lock(&_selectionListsLock); + bool removed = _selectedItemsListMap.remove(listName); + } + if (removed) { onSelectedItemsListChanged(listName); return true; } else { @@ -232,24 +241,25 @@ bool SelectionScriptingInterface::removeListFromMap(const QString& listName) { } void SelectionScriptingInterface::setupHandler(const QString& selectionName) { - // QWriteLocker lock(&_selectionListsLock); + QWriteLocker lock(&_selectionHandlersLock); auto handler = _handlerMap.find(selectionName); if (handler == _handlerMap.end()) { handler = _handlerMap.insert(selectionName, new SelectionToSceneHandler()); } - (*handler)->initialize(selectionName); - // connect(this, &SelectionScriptingInterface::selectedItemsListChanged, handler.value(), &SelectionToSceneHandler::selectedItemsListChanged); - } void SelectionScriptingInterface::onSelectedItemsListChanged(const QString& listName) { - // QWriteLocker lock(&_selectionListsLock); - auto handler = _handlerMap.find(listName); - if (handler != _handlerMap.end()) { - (*handler)->updateSceneFromSelectedList(); + { + QWriteLocker lock(&_selectionHandlersLock); + auto handler = _handlerMap.find(listName); + if (handler != _handlerMap.end()) { + (*handler)->updateSceneFromSelectedList(); + } } + + emit selectedItemsListChanged(listName); } @@ -312,66 +322,65 @@ void SelectionToSceneHandler::updateSceneFromSelectedList() { qWarning() << "SelectionToSceneHandler::updateRendererSelectedList(), Unexpected null scene, possibly during application shutdown"; } } -/* -void SelectionToSceneHandler::highlightStyleChanged(const QString& listName) { - if (listName == _listName) { - auto mainScene = qApp->getMain3DScene(); - if (mainScene) { - auto thisStyle = DependencyManager::get()->getHighlightStyle(listName); - render::Transaction transaction; - transaction.resetSelectionHighlight(listName.toStdString(), thisStyle); - mainScene->enqueueTransaction(transaction); - } - else { - qWarning() << "SelectionToSceneHandler::highlightStyleChanged(), Unexpected null scene, possibly during application shutdown"; - } - } -} -void SelectionToSceneHandler::highlightStyleRemoved(const QString& listName) { - if (listName == _listName) { - auto mainScene = qApp->getMain3DScene(); - if (mainScene) { - render::Transaction transaction; - transaction.removeHighlightFromSelection(listName.toStdString()); - mainScene->enqueueTransaction(transaction); - } - else { - qWarning() << "SelectionToSceneHandler::highlightStyleRemoved(), Unexpected null scene, possibly during application shutdown"; - } - } -} -*/ bool SelectionHighlightStyle::fromVariantMap(const QVariantMap& properties) { - auto outlineColor = properties["outlineColor"]; - if (outlineColor.isValid()) { + auto colorVariant = properties["outlineUnoccludedColor"]; + if (colorVariant.isValid()) { bool isValid; - auto color = xColorFromVariant(properties["outlineColor"], isValid); + auto color = xColorFromVariant(colorVariant, isValid); if (isValid) { - _style.color = toGlm(color); + _style._outlineUnoccluded.color = toGlm(color); } } + colorVariant = properties["outlineOccludedColor"]; + if (colorVariant.isValid()) { + bool isValid; + auto color = xColorFromVariant(colorVariant, isValid); + if (isValid) { + _style._outlineOccluded.color = toGlm(color); + } + } + colorVariant = properties["fillUnoccludedColor"]; + if (colorVariant.isValid()) { + bool isValid; + auto color = xColorFromVariant(colorVariant, isValid); + if (isValid) { + _style._fillUnoccluded.color = toGlm(color); + } + } + colorVariant = properties["fillOccludedColor"]; + if (colorVariant.isValid()) { + bool isValid; + auto color = xColorFromVariant(colorVariant, isValid); + if (isValid) { + _style._fillOccluded.color = toGlm(color); + } + } + + auto intensityVariant = properties["outlineUnoccludedIntensity"]; + if (intensityVariant.isValid()) { + _style._outlineUnoccluded.alpha = intensityVariant.toFloat(); + } + intensityVariant = properties["outlineOccludedIntensity"]; + if (intensityVariant.isValid()) { + _style._outlineOccluded.alpha = intensityVariant.toFloat(); + } + intensityVariant = properties["fillUnoccludedIntensity"]; + if (intensityVariant.isValid()) { + _style._fillUnoccluded.alpha = intensityVariant.toFloat(); + } + intensityVariant = properties["fillOccludedIntensity"]; + if (intensityVariant.isValid()) { + _style._fillOccluded.alpha = intensityVariant.toFloat(); + } + auto outlineWidth = properties["outlineWidth"]; if (outlineWidth.isValid()) { - _style.outlineWidth = outlineWidth.toFloat(); + _style._outlineWidth = outlineWidth.toFloat(); } auto isOutlineSmooth = properties["isOutlineSmooth"]; if (isOutlineSmooth.isValid()) { - _style.isOutlineSmooth = isOutlineSmooth.toBool(); - } - - auto outlineIntensity = properties["outlineIntensity"]; - if (outlineIntensity.isValid()) { - _style.outlineIntensity = outlineIntensity.toFloat(); - } - - auto unoccludedFillOpacity = properties["unoccludedFillOpacity"]; - if (unoccludedFillOpacity.isValid()) { - _style.unoccludedFillOpacity = unoccludedFillOpacity.toFloat(); - } - auto occludedFillOpacity = properties["occludedFillOpacity"]; - if (occludedFillOpacity.isValid()) { - _style.occludedFillOpacity = occludedFillOpacity.toFloat(); + _style._isOutlineSmooth = isOutlineSmooth.toBool(); } return true; @@ -380,12 +389,18 @@ bool SelectionHighlightStyle::fromVariantMap(const QVariantMap& properties) { QVariantMap SelectionHighlightStyle::toVariantMap() const { QVariantMap properties; - properties["outlineColor"] = xColorToVariant(xColorFromGlm(_style.color)); - properties["outlineWidth"] = _style.outlineWidth; - properties["isOutlineSmooth"] = _style.isOutlineSmooth; - properties["outlineIntensity"] = _style.outlineIntensity; - properties["unoccludedFillOpacity"] = _style.unoccludedFillOpacity; - properties["occludedFillOpacity"] = _style.occludedFillOpacity; + properties["outlineUnoccludedColor"] = xColorToVariant(xColorFromGlm(_style._outlineUnoccluded.color)); + properties["outlineOccludedColor"] = xColorToVariant(xColorFromGlm(_style._outlineOccluded.color)); + properties["fillUnoccludedColor"] = xColorToVariant(xColorFromGlm(_style._fillUnoccluded.color)); + properties["fillOccludedColor"] = xColorToVariant(xColorFromGlm(_style._fillOccluded.color)); + + properties["outlineUnoccludedIntensity"] = _style._outlineUnoccluded.alpha; + properties["outlineOccludedIntensity"] = _style._outlineOccluded.alpha; + properties["fillUnoccludedIntensity"] = _style._fillUnoccluded.alpha; + properties["fillOccludedIntensity"] = _style._fillOccluded.alpha; + + properties["outlineWidth"] = _style._outlineWidth; + properties["isOutlineSmooth"] = _style._isOutlineSmooth; return properties; } \ No newline at end of file diff --git a/interface/src/scripting/SelectionScriptingInterface.h b/interface/src/scripting/SelectionScriptingInterface.h index d22df73218..6abf07537e 100644 --- a/interface/src/scripting/SelectionScriptingInterface.h +++ b/interface/src/scripting/SelectionScriptingInterface.h @@ -147,9 +147,12 @@ private: mutable QReadWriteLock _selectionListsLock; QMap _selectedItemsListMap; - QMap _highlightedListMap; + mutable QReadWriteLock _selectionHandlersLock; QMap _handlerMap; + mutable QReadWriteLock _highlightStylesLock; + QMap _highlightStyleMap; + template bool addToGameplayObjects(const QString& listName, T idToAdd); template bool removeFromGameplayObjects(const QString& listName, T idToRemove); diff --git a/libraries/render-utils/src/Highlight.slh b/libraries/render-utils/src/Highlight.slh index e6ebb25074..207276014c 100644 --- a/libraries/render-utils/src/Highlight.slh +++ b/libraries/render-utils/src/Highlight.slh @@ -36,8 +36,6 @@ void main(void) { // the blur will have a different width between the left / right sides and top / bottom // sides of the silhouette float highlightedDepth = texture(highlightedDepthMap, varTexCoord0).x; - float intensity = 0.0; - float isOccluded = 0.0; if (highlightedDepth < FAR_Z) { // We're not on the far plane so we are on the highlighted object, thus no outline to do! @@ -48,7 +46,11 @@ void main(void) { highlightedDepth = -evalZeyeFromZdb(highlightedDepth); sceneDepth = -evalZeyeFromZdb(sceneDepth); - intensity = sceneDepth < (highlightedDepth-LINEAR_DEPTH_BIAS) ? params._occludedFillOpacity : params._unoccludedFillOpacity; + if (sceneDepth < (highlightedDepth-LINEAR_DEPTH_BIAS)) { + outFragColor = vec4(params._fillOccludedColor, params._fillOccludedAlpha); + } else { + outFragColor = vec4(params._fillUnoccludedColor, params._fillUnoccludedAlpha); + } <@else@> discard; <@endif@> @@ -62,8 +64,9 @@ void main(void) { int x; int y; - float outlinedDepth = 0; - float sumOutlineDepth = 0; + float intensity = 0.0; + float outlinedDepth = 0.0; + float sumOutlineDepth = 0.0; for (y=0 ; y diff --git a/libraries/render-utils/src/HighlightEffect.cpp b/libraries/render-utils/src/HighlightEffect.cpp index 79ae96c07c..d1fcab67b6 100644 --- a/libraries/render-utils/src/HighlightEffect.cpp +++ b/libraries/render-utils/src/HighlightEffect.cpp @@ -88,7 +88,7 @@ HighlightSharedParameters::HighlightSharedParameters() { } float HighlightSharedParameters::getBlurPixelWidth(const render::HighlightStyle& style, int frameBufferHeight) { - return ceilf(style.outlineWidth * frameBufferHeight / 400.0f); + return ceilf(style._outlineWidth * frameBufferHeight / 400.0f); } PrepareDrawHighlight::PrepareDrawHighlight() { @@ -267,14 +267,19 @@ void DrawHighlight::run(const render::RenderContextPointer& renderContext, const { auto& shaderParameters = _configuration.edit(); - shaderParameters._color = highlight._style.color; - shaderParameters._intensity = highlight._style.outlineIntensity * (highlight._style.isOutlineSmooth ? 2.0f : 1.0f); - shaderParameters._unoccludedFillOpacity = highlight._style.unoccludedFillOpacity; - shaderParameters._occludedFillOpacity = highlight._style.occludedFillOpacity; - shaderParameters._threshold = highlight._style.isOutlineSmooth ? 1.0f : 1e-3f; - shaderParameters._blurKernelSize = std::min(7, std::max(2, (int)floorf(highlight._style.outlineWidth * 3 + 0.5f))); + shaderParameters._outlineUnoccludedColor = highlight._style._outlineUnoccluded.color; + shaderParameters._outlineUnoccludedAlpha = highlight._style._outlineUnoccluded.alpha * (highlight._style._isOutlineSmooth ? 2.0f : 1.0f); + shaderParameters._outlineOccludedColor = highlight._style._outlineOccluded.color; + shaderParameters._outlineOccludedAlpha = highlight._style._outlineOccluded.alpha * (highlight._style._isOutlineSmooth ? 2.0f : 1.0f); + shaderParameters._fillUnoccludedColor = highlight._style._fillUnoccluded.color; + shaderParameters._fillUnoccludedAlpha = highlight._style._fillUnoccluded.alpha; + shaderParameters._fillOccludedColor = highlight._style._fillOccluded.color; + shaderParameters._fillOccludedAlpha = highlight._style._fillOccluded.alpha; + + shaderParameters._threshold = highlight._style._isOutlineSmooth ? 1.0f : 1e-3f; + shaderParameters._blurKernelSize = std::min(7, std::max(2, (int)floorf(highlight._style._outlineWidth * 3 + 0.5f))); // Size is in normalized screen height. We decide that for highlight width = 1, this is equal to 1/400. - auto size = highlight._style.outlineWidth / 400.0f; + auto size = highlight._style._outlineWidth / 400.0f; shaderParameters._size.x = (size * framebufferSize.y) / framebufferSize.x; shaderParameters._size.y = size; } diff --git a/libraries/render-utils/src/Highlight_shared.slh b/libraries/render-utils/src/Highlight_shared.slh index 5efbde4d52..edc51e4ecb 100644 --- a/libraries/render-utils/src/Highlight_shared.slh +++ b/libraries/render-utils/src/Highlight_shared.slh @@ -11,17 +11,18 @@ struct HighlightParameters { - TVEC3 _color; - float _intensity; + TVEC3 _outlineUnoccludedColor; + float _outlineUnoccludedAlpha; + TVEC3 _outlineOccludedColor; + float _outlineOccludedAlpha; + TVEC3 _fillUnoccludedColor; + float _fillUnoccludedAlpha; + TVEC3 _fillOccludedColor; + float _fillOccludedAlpha; - TVEC2 _size; - float _unoccludedFillOpacity; - float _occludedFillOpacity; - - float _threshold; int _blurKernelSize; - float padding2; - float padding3; + float _threshold; + TVEC2 _size; }; // <@if 1@> diff --git a/libraries/render/src/render/HighlightStage.cpp b/libraries/render/src/render/HighlightStage.cpp index ade3844321..c9f097b387 100644 --- a/libraries/render/src/render/HighlightStage.cpp +++ b/libraries/render/src/render/HighlightStage.cpp @@ -61,42 +61,42 @@ void HighlightStageConfig::setSelectionName(const QString& name) { } void HighlightStageConfig::setOutlineSmooth(bool isSmooth) { - editStyle().isOutlineSmooth = isSmooth; + editStyle()._isOutlineSmooth = isSmooth; emit dirty(); } void HighlightStageConfig::setColorRed(float value) { - editStyle().color.r = value; + editStyle()._outlineUnoccluded.color.r = value; emit dirty(); } void HighlightStageConfig::setColorGreen(float value) { - editStyle().color.g = value; + editStyle()._outlineUnoccluded.color.g = value; emit dirty(); } void HighlightStageConfig::setColorBlue(float value) { - editStyle().color.b = value; + editStyle()._outlineUnoccluded.color.b = value; emit dirty(); } void HighlightStageConfig::setOutlineWidth(float value) { - editStyle().outlineWidth = value; + editStyle()._outlineWidth = value; emit dirty(); } void HighlightStageConfig::setOutlineIntensity(float value) { - editStyle().outlineIntensity = value; + editStyle()._outlineUnoccluded.alpha = value; emit dirty(); } void HighlightStageConfig::setUnoccludedFillOpacity(float value) { - editStyle().unoccludedFillOpacity = value; + editStyle()._fillUnoccluded.alpha = value; emit dirty(); } void HighlightStageConfig::setOccludedFillOpacity(float value) { - editStyle().occludedFillOpacity = value; + editStyle()._fillOccluded.alpha = value; emit dirty(); } diff --git a/libraries/render/src/render/HighlightStage.h b/libraries/render/src/render/HighlightStage.h index 94c6e3ca69..5e6574840f 100644 --- a/libraries/render/src/render/HighlightStage.h +++ b/libraries/render/src/render/HighlightStage.h @@ -83,28 +83,28 @@ namespace render { QString getSelectionName() const { return QString(_selectionName.c_str()); } void setSelectionName(const QString& name); - bool isOutlineSmooth() const { return getStyle().isOutlineSmooth; } + bool isOutlineSmooth() const { return getStyle()._isOutlineSmooth; } void setOutlineSmooth(bool isSmooth); - float getColorRed() const { return getStyle().color.r; } + float getColorRed() const { return getStyle()._outlineUnoccluded.color.r; } void setColorRed(float value); - float getColorGreen() const { return getStyle().color.g; } + float getColorGreen() const { return getStyle()._outlineUnoccluded.color.g; } void setColorGreen(float value); - float getColorBlue() const { return getStyle().color.b; } + float getColorBlue() const { return getStyle()._outlineUnoccluded.color.b; } void setColorBlue(float value); - float getOutlineWidth() const { return getStyle().outlineWidth; } + float getOutlineWidth() const { return getStyle()._outlineWidth; } void setOutlineWidth(float value); - float getOutlineIntensity() const { return getStyle().outlineIntensity; } + float getOutlineIntensity() const { return getStyle()._outlineUnoccluded.alpha; } void setOutlineIntensity(float value); - float getUnoccludedFillOpacity() const { return getStyle().unoccludedFillOpacity; } + float getUnoccludedFillOpacity() const { return getStyle()._fillUnoccluded.alpha; } void setUnoccludedFillOpacity(float value); - float getOccludedFillOpacity() const { return getStyle().occludedFillOpacity; } + float getOccludedFillOpacity() const { return getStyle()._fillOccluded.alpha; } void setOccludedFillOpacity(float value); std::string _selectionName{ "contextOverlayHighlightList" }; diff --git a/libraries/render/src/render/HighlightStyle.h b/libraries/render/src/render/HighlightStyle.h index 6e7373c78b..1243f5aa60 100644 --- a/libraries/render/src/render/HighlightStyle.h +++ b/libraries/render/src/render/HighlightStyle.h @@ -20,17 +20,22 @@ namespace render { // This holds the configuration for a particular outline style class HighlightStyle { public: + struct RGBA { + glm::vec3 color{ 1.f, 0.7f, 0.2f }; + float alpha{ 0.9f }; + }; + + RGBA _outlineUnoccluded{ { 1.f, 0.7f, 0.2f }, 0.9f }; + RGBA _outlineOccluded{ { 0.2f, 0.7f, 1.0f }, 0.9f }; + RGBA _fillUnoccluded{ { 1.f, 0.2f, 0.7f }, 0.0f }; + RGBA _fillOccluded{ { 0.7f, 1.f, 0.2f }, 0.0f }; + + float _outlineWidth{ 2.0f }; + bool _isOutlineSmooth{ false }; bool isFilled() const { - return unoccludedFillOpacity > 5e-3f || occludedFillOpacity > 5e-3f; + return _fillUnoccluded.alpha > 5e-3f || _fillOccluded.alpha > 5e-3f; } - - glm::vec3 color{ 1.f, 0.7f, 0.2f }; - float outlineWidth{ 2.0f }; - float outlineIntensity{ 0.9f }; - float unoccludedFillOpacity{ 0.0f }; - float occludedFillOpacity{ 0.0f }; - bool isOutlineSmooth{ false }; }; } diff --git a/scripts/developer/utilities/render/debugHighlight.js b/scripts/developer/utilities/render/debugHighlight.js index 5175761978..c647c601b9 100644 --- a/scripts/developer/utilities/render/debugHighlight.js +++ b/scripts/developer/utilities/render/debugHighlight.js @@ -9,6 +9,111 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +"use strict"; + +// +// Luci.js +// tablet-engine app +// +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +(function() { + var TABLET_BUTTON_NAME = "Highlight"; + var QMLAPP_URL = Script.resolvePath("./highlight.qml"); + var ICON_URL = Script.resolvePath("../../../system/assets/images/luci-i.svg"); + var ACTIVE_ICON_URL = Script.resolvePath("../../../system/assets/images/luci-a.svg"); + + + var onLuciScreen = false; + + function onClicked() { + if (onLuciScreen) { + tablet.gotoHomeScreen(); + } else { + tablet.loadQMLSource(QMLAPP_URL); + } + } + + var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); + var button = tablet.addButton({ + text: TABLET_BUTTON_NAME, + icon: ICON_URL, + activeIcon: ACTIVE_ICON_URL, + sortOrder: 1 + }); + + var hasEventBridge = false; + + function wireEventBridge(on) { + if (!tablet) { + print("Warning in wireEventBridge(): 'tablet' undefined!"); + return; + } + if (on) { + if (!hasEventBridge) { + tablet.fromQml.connect(fromQml); + hasEventBridge = true; + } + } else { + if (hasEventBridge) { + tablet.fromQml.disconnect(fromQml); + hasEventBridge = false; + } + } + } + + function onScreenChanged(type, url) { + if (url === QMLAPP_URL) { + onLuciScreen = true; + } else { + onLuciScreen = false; + } + + button.editProperties({isActive: onLuciScreen}); + wireEventBridge(onLuciScreen); + } + + function fromQml(message) { + } + + button.clicked.connect(onClicked); + tablet.screenChanged.connect(onScreenChanged); + + var moveDebugCursor = false; + Controller.mousePressEvent.connect(function (e) { + if (e.isMiddleButton) { + moveDebugCursor = true; + setDebugCursor(e.x, e.y); + } + }); + Controller.mouseReleaseEvent.connect(function() { moveDebugCursor = false; }); + Controller.mouseMoveEvent.connect(function (e) { if (moveDebugCursor) setDebugCursor(e.x, e.y); }); + + + Script.scriptEnding.connect(function () { + if (onLuciScreen) { + tablet.gotoHomeScreen(); + } + button.clicked.disconnect(onClicked); + tablet.screenChanged.disconnect(onScreenChanged); + tablet.removeButton(button); + }); + + function setDebugCursor(x, y) { + nx = (x / Window.innerWidth); + ny = 1.0 - ((y) / (Window.innerHeight - 32)); + + Render.getConfig("RenderMainView").getConfig("Antialiasing").debugCursorTexcoord = { x: nx, y: ny }; + } + +}()); + + + // Set up the qml ui var qml = Script.resolvePath('highlight.qml'); var window = new OverlayWindow({ diff --git a/scripts/developer/utilities/render/debugHighlight2.js b/scripts/developer/utilities/render/debugHighlight2.js new file mode 100644 index 0000000000..387d5bfe4a --- /dev/null +++ b/scripts/developer/utilities/render/debugHighlight2.js @@ -0,0 +1,251 @@ +// +// debugHighlight.js +// developer/utilities/render +// +// Olivier Prat, created on 08/08/2017. +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +"use strict"; + +// +// Luci.js +// tablet-engine app +// +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +(function() { + var TABLET_BUTTON_NAME = "Highlight"; + var QMLAPP_URL = Script.resolvePath("./highlight2.qml"); + var ICON_URL = Script.resolvePath("../../../system/assets/images/luci-i.svg"); + var ACTIVE_ICON_URL = Script.resolvePath("../../../system/assets/images/luci-a.svg"); + + + var onLuciScreen = false; + + function onClicked() { + if (onLuciScreen) { + tablet.gotoHomeScreen(); + } else { + tablet.loadQMLSource(QMLAPP_URL); + } + } + + var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); + var button = tablet.addButton({ + text: TABLET_BUTTON_NAME, + icon: ICON_URL, + activeIcon: ACTIVE_ICON_URL, + sortOrder: 1 + }); + + var hasEventBridge = false; + + function wireEventBridge(on) { + if (!tablet) { + print("Warning in wireEventBridge(): 'tablet' undefined!"); + return; + } + if (on) { + if (!hasEventBridge) { + tablet.fromQml.connect(fromQml); + hasEventBridge = true; + } + } else { + if (hasEventBridge) { + tablet.fromQml.disconnect(fromQml); + hasEventBridge = false; + } + } + } + + function onScreenChanged(type, url) { + if (url === QMLAPP_URL) { + onLuciScreen = true; + } else { + onLuciScreen = false; + } + + button.editProperties({isActive: onLuciScreen}); + wireEventBridge(onLuciScreen); + } + + function fromQml(message) { + } + + button.clicked.connect(onClicked); + tablet.screenChanged.connect(onScreenChanged); + + var moveDebugCursor = false; + Controller.mousePressEvent.connect(function (e) { + if (e.isMiddleButton) { + moveDebugCursor = true; + setDebugCursor(e.x, e.y); + } + }); + Controller.mouseReleaseEvent.connect(function() { moveDebugCursor = false; }); + Controller.mouseMoveEvent.connect(function (e) { if (moveDebugCursor) setDebugCursor(e.x, e.y); }); + + + Script.scriptEnding.connect(function () { + if (onLuciScreen) { + tablet.gotoHomeScreen(); + } + button.clicked.disconnect(onClicked); + tablet.screenChanged.disconnect(onScreenChanged); + tablet.removeButton(button); + }); + + function setDebugCursor(x, y) { + } + +}()); + + + +// Set up the qml ui + +// Created by Sam Gondelman on 9/7/2017 +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +/* +(function() { // BEGIN LOCAL_SCOPE + +var END_DIMENSIONS = { + x: 0.15, + y: 0.15, + z: 0.15 +}; +var COLOR = {red: 97, green: 247, blue: 255}; +var end = { + type: "sphere", + dimensions: END_DIMENSIONS, + color: COLOR, + ignoreRayIntersection: true, + alpha: 1.0, + visible: true +} + +var COLOR2 = {red: 247, green: 97, blue: 255}; +var end2 = { + type: "sphere", + dimensions: END_DIMENSIONS, + color: COLOR2, + ignoreRayIntersection: true, + alpha: 1.0, + visible: true +} + +var highlightGroupIndex = 0 +var isSelectionAddEnabled = false +var isSelectionEnabled = false +var renderStates = [{name: "test", end: end}]; +var defaultRenderStates = [{name: "test", distance: 20.0, end: end2}]; +var time = 0 + +var ray = LaserPointers.createLaserPointer({ + joint: "Mouse", + filter: RayPick.PICK_ENTITIES | RayPick.PICK_OVERLAYS | RayPick.PICK_AVATARS | RayPick.PICK_INVISIBLE | RayPick.PICK_NONCOLLIDABLE, + renderStates: renderStates, + defaultRenderStates: defaultRenderStates, + enabled: false +}); + +function getSelectionName() { + var selectionName = "contextOverlayHighlightList" + + if (highlightGroupIndex>0) { + selectionName += highlightGroupIndex + } + return selectionName +} + +function fromQml(message) { + tokens = message.split(' ') + print("Received '"+message+"' from hightlight.qml") + if (tokens[0]=="highlight") { + highlightGroupIndex = parseInt(tokens[1]) + print("Switching to highlight group "+highlightGroupIndex) + } else if (tokens[0]=="pick") { + isSelectionEnabled = tokens[1]=='true' + print("Ray picking set to "+isSelectionEnabled.toString()) + if (isSelectionEnabled) { + LaserPointers.enableLaserPointer(ray) + } else { + LaserPointers.disableLaserPointer(ray) + } + time = 0 + } else if (tokens[0]=="add") { + isSelectionAddEnabled = tokens[1]=='true' + print("Add to selection set to "+isSelectionAddEnabled.toString()) + if (!isSelectionAddEnabled) { + Selection.clearSelectedItemsList(getSelectionName()) + } + } +} + +window.fromQml.connect(fromQml); + +function cleanup() { + LaserPointers.removeLaserPointer(ray); +} +Script.scriptEnding.connect(cleanup); + +var prevID = 0 +var prevType = "" +var selectedID = 0 +var selectedType = "" +function update(deltaTime) { + + // you have to do this repeatedly because there's a bug but I'll fix it + LaserPointers.setRenderState(ray, "test"); + + var result = LaserPointers.getPrevRayPickResult(ray); + var selectionName = getSelectionName() + + if (isSelectionEnabled && result.type != RayPick.INTERSECTED_NONE) { + time += deltaTime + if (result.objectID != prevID) { + var typeName = "" + if (result.type == RayPick.INTERSECTED_ENTITY) { + typeName = "entity" + } else if (result.type == RayPick.INTERSECTED_OVERLAY) { + typeName = "overlay" + } else if (result.type == RayPick.INTERSECTED_AVATAR) { + typeName = "avatar" + } + + prevID = result.objectID; + prevType = typeName; + time = 0 + } else if (time>1.0 && prevID!=selectedID) { + if (prevID != 0 && !isSelectionAddEnabled) { + Selection.removeFromSelectedItemsList(selectionName, selectedType, selectedID) + } + selectedID = prevID + selectedType = prevType + Selection.addToSelectedItemsList(selectionName, selectedType, selectedID) + print("HIGHLIGHT " + highlightGroupIndex + " picked type: " + result.type + ", id: " + result.objectID); + } + } else { + if (prevID != 0 && !isSelectionAddEnabled) { + Selection.removeFromSelectedItemsList(selectionName, prevType, prevID) + } + prevID = 0 + selectedID = 0 + time = 0 + } +} + +Script.update.connect(update); + +}()); // END LOCAL_SCOPE*/ \ No newline at end of file diff --git a/scripts/developer/utilities/render/highlight2.qml b/scripts/developer/utilities/render/highlight2.qml new file mode 100644 index 0000000000..6be74fcf40 --- /dev/null +++ b/scripts/developer/utilities/render/highlight2.qml @@ -0,0 +1,177 @@ +// +// highlight.qml +// developer/utilities/render +// +// Olivier Prat, created on 08/08/2017. +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html +// +import QtQuick 2.7 +import QtQuick.Controls 1.4 +import QtQuick.Layouts 1.3 + +import "qrc:///qml/styles-uit" +import "qrc:///qml/controls-uit" as HifiControls +import "configSlider" + +Rectangle { + id: root + HifiConstants { id: hifi;} + color: hifi.colors.baseGray; + anchors.margins: hifi.dimensions.contentMargin.x + + property var debugConfig: Render.getConfig("RenderMainView.HighlightDebug") + property var highlightConfig: Render.getConfig("UpdateScene.HighlightStageSetup") + + signal sendToScript(var message); + + Column { + id: col + spacing: 10 + anchors.left: parent.left + anchors.right: parent.right + anchors.margins: hifi.dimensions.contentMargin.x + + Row { + spacing: 10 + anchors.left: parent.left + anchors.right: parent.right + + HifiControls.CheckBox { + id: debug + text: "View Mask" + checked: root.debugConfig["viewMask"] + onCheckedChanged: { + root.debugConfig["viewMask"] = checked; + } + } + HifiControls.CheckBox { + text: "Hover select" + checked: false + onCheckedChanged: { + sendToScript("pick "+checked.toString()) + } + } + HifiControls.CheckBox { + text: "Add to selection" + checked: false + onCheckedChanged: { + sendToScript("add "+checked.toString()) + } + } + } + + HifiControls.ComboBox { + id: box + width: 350 + z: 999 + editable: true + colorScheme: hifi.colorSchemes.dark + model: [ + "contextOverlayHighlightList", + "highlightList1", + "highlightList2", + "highlightList3", + "highlightList4"] + label: "" + + Timer { + id: postpone + interval: 100; running: false; repeat: false + onTriggered: { paramWidgetLoader.sourceComponent = paramWidgets } + } + onCurrentIndexChanged: { + root.highlightConfig["selectionName"] = model[currentIndex]; + sendToScript("highlight "+currentIndex) + // This is a hack to be sure the widgets below properly reflect the change of category: delete the Component + // by setting the loader source to Null and then recreate it 100ms later + paramWidgetLoader.sourceComponent = undefined; + postpone.interval = 100 + postpone.start() + } + } + + Loader { + id: paramWidgetLoader + sourceComponent: paramWidgets + width: 350 + } + + Component { + id: paramWidgets + + Column { + spacing: 10 + anchors.margins: hifi.dimensions.contentMargin.x + + HifiControls.Label { + text: "Outline" + } + Column { + spacing: 10 + anchors.left: parent.left + anchors.right: parent.right + HifiControls.CheckBox { + text: "Smooth" + checked: root.highlightConfig["isOutlineSmooth"] + onCheckedChanged: { + root.highlightConfig["isOutlineSmooth"] = checked; + } + } + Repeater { + model: ["Width:outlineWidth:5.0:0.0", + "Intensity:outlineIntensity:1.0:0.0" + ] + ConfigSlider { + label: qsTr(modelData.split(":")[0]) + integral: false + config: root.highlightConfig + property: modelData.split(":")[1] + max: modelData.split(":")[2] + min: modelData.split(":")[3] + } + } + } + + Separator {} + HifiControls.Label { + text: "Color" + } + Repeater { + model: ["Red:colorR:1.0:0.0", + "Green:colorG:1.0:0.0", + "Blue:colorB:1.0:0.0" + ] + ConfigSlider { + label: qsTr(modelData.split(":")[0]) + integral: false + config: root.highlightConfig + property: modelData.split(":")[1] + max: modelData.split(":")[2] + min: modelData.split(":")[3] + } + } + + Separator {} + HifiControls.Label { + text: "Fill Opacity" + } + Repeater { + model: ["Unoccluded:unoccludedFillOpacity:1.0:0.0", + "Occluded:occludedFillOpacity:1.0:0.0" + ] + ConfigSlider { + label: qsTr(modelData.split(":")[0]) + integral: false + config: root.highlightConfig + property: modelData.split(":")[1] + max: modelData.split(":")[2] + min: modelData.split(":")[3] + } + } + } + } + } +} From de410b683346cf516e579cbd3236bed1fcb25a5b Mon Sep 17 00:00:00 2001 From: samcake Date: Mon, 4 Dec 2017 17:29:01 -0800 Subject: [PATCH 11/29] I need a color editor --- .../scripting/SelectionScriptingInterface.h | 40 +++++++++++++ .../utilities/lib/plotperf/XColor.qml | 59 +++++++++++++++++++ .../developer/utilities/lib/plotperf/qmldir | 3 +- .../developer/utilities/render/highlight2.qml | 18 ++++-- 4 files changed, 115 insertions(+), 5 deletions(-) create mode 100644 scripts/developer/utilities/lib/plotperf/XColor.qml diff --git a/interface/src/scripting/SelectionScriptingInterface.h b/interface/src/scripting/SelectionScriptingInterface.h index 6abf07537e..2d9dc07661 100644 --- a/interface/src/scripting/SelectionScriptingInterface.h +++ b/interface/src/scripting/SelectionScriptingInterface.h @@ -132,8 +132,48 @@ public: */ Q_INVOKABLE bool clearSelectedItemsList(const QString& listName); + /**jsdoc + * Enable highlighting for the named selection. + * If the Selection doesn't exist, it will be created. + * All objects in the list will be displayed with the highlight effect as specified from the highlightStyle. + * The function can be called several times with different values in the style to modify it. + * + * @function Selection.enableListHighlight + * @param listName {string} name of the selection + * @param highlightStyle {jsObject} highlight style fields (see Selection.getListHighlightStyle for a detailed description of the highlightStyle). + * @returns {bool} true if the selection was successfully enabled for highlight. + */ Q_INVOKABLE bool enableListHighlight(const QString& listName, const QVariantMap& highlightStyle); + /**jsdoc + * Disable highlighting for the named selection. + * If the Selection doesn't exist or wasn't enabled for highliting then nothing happens simply returning false. + * + * @function Selection.disableListHighlight + * @param listName {string} name of the selection + * @returns {bool} true if the selection was successfully disabled for highlight, false otherwise. + */ Q_INVOKABLE bool disableListHighlight(const QString& listName); + /**jsdoc + * Query the highlight style values for the named selection. + * If the Selection doesn't exist or hasn't been highlight enabled yet, it will return an empty object. + * Otherwise, the jsObject describes the highlight style properties: + * - outlineUnoccludedColor: {xColor} Color of the specified highlight region + * - outlineOccludedColor: {xColor} " + * - fillUnoccludedColor: {xColor} " + * - fillOccludedColor: {xColor} " + * + * - outlineUnoccludedOpacity: {float} Opacity value ranging from 0.0 (not visible) to 1.0 (fully opaque) for the specified highlight region + * - outlineOccludedOpacity: {float} " + * - fillUnoccludedOpacity: {float} " + * - fillOccludedOpacity: {float} " + * + * - outlineWidth: {float} width of the outline expressed in pixels + * - isOutlineSmooth: {bool} true to enable oultine smooth falloff + * + * @function Selection.getListHighlightStyle + * @param listName {string} name of the selection + * @returns {jsObject} highlight style as described above + */ Q_INVOKABLE QVariantMap getListHighlightStyle(const QString& listName) const; render::HighlightStyle getHighlightStyle(const QString& listName) const; diff --git a/scripts/developer/utilities/lib/plotperf/XColor.qml b/scripts/developer/utilities/lib/plotperf/XColor.qml new file mode 100644 index 0000000000..1e1d28c059 --- /dev/null +++ b/scripts/developer/utilities/lib/plotperf/XColor.qml @@ -0,0 +1,59 @@ +// +// XColor.qml +// +// Created by Sam Gateau 12/4/2017 +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html +// + +import QtQuick 2.7 +import QtQuick.Controls 1.4 as Original +import QtQuick.Controls.Styles 1.4 + +import "qrc:///qml/styles-uit" +import "qrc:///qml/controls-uit" as HifiControls + + +Item { + HifiConstants { id: hifi } + id: root + + anchors.left: parent.left + anchors.right: parent.right + height: 24 + property var color + property alias label: labelControl.text + + function getColor() { + return Qt.rgba(color.red / 255.0, color.green / 255.0, color.blue / 255.0, 1.0 ); + } + + Rectangle { + id: current + HifiConstants { id: hifi;} + color: root.getColor(); + } + + Component.onCompleted: { + // Binding favors qml value, so set it first + bindingControl.when = true; + } + + HifiControls.Label { + id: labelControl + text: root.label + enabled: true + anchors.left: root.left + anchors.right: root.horizontalCenter + anchors.verticalCenter: root.verticalCenter + } + + Binding { + id: bindingControl + target: root.color + property: root.property + when: false + } +} diff --git a/scripts/developer/utilities/lib/plotperf/qmldir b/scripts/developer/utilities/lib/plotperf/qmldir index 5668f5034c..829592f87d 100644 --- a/scripts/developer/utilities/lib/plotperf/qmldir +++ b/scripts/developer/utilities/lib/plotperf/qmldir @@ -1 +1,2 @@ -PlotPerf 1.0 PlotPerf.qml \ No newline at end of file +PlotPerf 1.0 PlotPerf.qml +XColor 1.0 XColor.qml \ No newline at end of file diff --git a/scripts/developer/utilities/render/highlight2.qml b/scripts/developer/utilities/render/highlight2.qml index 6be74fcf40..b6dc49613e 100644 --- a/scripts/developer/utilities/render/highlight2.qml +++ b/scripts/developer/utilities/render/highlight2.qml @@ -15,6 +15,7 @@ import QtQuick.Layouts 1.3 import "qrc:///qml/styles-uit" import "qrc:///qml/controls-uit" as HifiControls import "configSlider" +import "../lib/plotperf" Rectangle { id: root @@ -22,8 +23,8 @@ Rectangle { color: hifi.colors.baseGray; anchors.margins: hifi.dimensions.contentMargin.x - property var debugConfig: Render.getConfig("RenderMainView.HighlightDebug") - property var highlightConfig: Render.getConfig("UpdateScene.HighlightStageSetup") + //property var debugConfig: Render.getConfig("RenderMainView.HighlightDebug") + //property var highlightConfig: Render.getConfig("UpdateScene.HighlightStageSetup") signal sendToScript(var message); @@ -60,9 +61,17 @@ Rectangle { onCheckedChanged: { sendToScript("add "+checked.toString()) } - } + } + } + Separator {} + + XColor { + color: { "red": 0, "green": 255, "blue": 0} } + Separator {} + +/* HifiControls.ComboBox { id: box width: 350 @@ -112,7 +121,7 @@ Rectangle { Column { spacing: 10 anchors.left: parent.left - anchors.right: parent.right + anchors.right: parent.right HifiControls.CheckBox { text: "Smooth" checked: root.highlightConfig["isOutlineSmooth"] @@ -173,5 +182,6 @@ Rectangle { } } } + */ } } From 1c5548b77b0a1c18ab43dd1bde32617416db0211 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Tue, 5 Dec 2017 01:25:30 -0800 Subject: [PATCH 12/29] Color picker in qml --- .../utilities/lib/plotperf/XColor.qml | 168 ++++++++++++++++-- .../developer/utilities/render/highlight2.qml | 55 +++--- 2 files changed, 174 insertions(+), 49 deletions(-) diff --git a/scripts/developer/utilities/lib/plotperf/XColor.qml b/scripts/developer/utilities/lib/plotperf/XColor.qml index 1e1d28c059..68600007d9 100644 --- a/scripts/developer/utilities/lib/plotperf/XColor.qml +++ b/scripts/developer/utilities/lib/plotperf/XColor.qml @@ -24,36 +24,176 @@ Item { anchors.right: parent.right height: 24 property var color - property alias label: labelControl.text + property var zoneWidth: width / 3; + property var hoveredOn: 0.0; + property var sliderHeight: height / 3; + signal newColor( color la_color) function getColor() { return Qt.rgba(color.red / 255.0, color.green / 255.0, color.blue / 255.0, 1.0 ); } + function repaint() { + current.color = getColor() + } + function setRed(r) { + color.red = r * 255; + repaint() + print("set red " + r) + } + function setGreen(g) { + color.green = g * 255; + repaint() + print("set green " + g) + } + function setBlue(b) { + color.blue = b * 255; + repaint() + print("set blue " + b) + } + + function resetSliders() { + redZone.set(color.red / 255) + greenZone.set(color.green / 255) + blueZone.set(color.blue / 255) + } + Rectangle { id: current - HifiConstants { id: hifi;} + anchors.fill: root color: root.getColor(); } + Rectangle { + id: sliderBack + height: root.sliderHeight + anchors.bottom: root.bottom + anchors.left: root.left + anchors.right: root.right + color: Qt.rgba(0.2, 0.2, 0.2, 1) + opacity: root.hoveredOn * 0.5 + } + + MouseArea { + id: all + anchors.fill: root + hoverEnabled: true + onEntered: { + root.hoveredOn = 1.0; + resetSliders(); + } + onExited: { + root.hoveredOn = 0.0; + } + } Component.onCompleted: { // Binding favors qml value, so set it first bindingControl.when = true; } - HifiControls.Label { - id: labelControl - text: root.label - enabled: true + Item { + id: redZone + anchors.top: root.top + anchors.bottom: root.bottom anchors.left: root.left - anchors.right: root.horizontalCenter - anchors.verticalCenter: root.verticalCenter - } + width: root.zoneWidth - Binding { - id: bindingControl - target: root.color - property: root.property - when: false + function set(r) { + if (r < 0.0) { + r = 0.0 + } else if (r > 1.0) { + r = 1.0 + } + root.setRed(r) + redRect.width = r * redZone.width + redRect.color = Qt.rgba(r, 0, 0, 1) + } + + Rectangle { + id: redRect + anchors.bottom: parent.bottom + anchors.left: parent.left + height: root.sliderHeight + opacity: root.hoveredOn + } + + MouseArea { + id: redArea + anchors.fill: parent + onPositionChanged: { + redZone.set(mouse.x / redArea.width) + } + } } + Item { + id: greenZone + anchors.top: root.top + anchors.bottom: root.bottom + anchors.left: redZone.right + + width: root.zoneWidth + + function set(g) { + if (g < 0.0) { + g = 0.0 + } else if (g > 1.0) { + g = 1.0 + } + root.setGreen(g) + greenRect.width = g * greenZone.width + greenRect.color = Qt.rgba(0, g, 0, 1) + } + + Rectangle { + id: greenRect + anchors.bottom: parent.bottom + anchors.left: parent.left + height: root.sliderHeight + opacity: root.hoveredOn + } + + MouseArea { + id: greenArea + anchors.fill: parent + onPositionChanged: { + greenZone.set(mouse.x / greenArea.width) + } + } + } + Item { + id: blueZone + anchors.top: root.top + anchors.bottom: root.bottom + anchors.right: root.right + // anchors.left: greenZone.right + + width: root.zoneWidth + + function set(b) { + if (b < 0.0) { + b = 0.0 + } else if (b > 1.0) { + b = 1.0 + } + root.setBlue(b) + blueRect.width = b * blueZone.width + blueRect.color = Qt.rgba(0, 0, b, 1) + } + + Rectangle { + id: blueRect + anchors.bottom: parent.bottom + anchors.left: parent.left + height: root.sliderHeight + opacity: root.hoveredOn + } + + MouseArea { + id: blueArea + anchors.fill: parent + onPositionChanged: { + blueZone.set(mouse.x / blueArea.width) + } + } + } } diff --git a/scripts/developer/utilities/render/highlight2.qml b/scripts/developer/utilities/render/highlight2.qml index b6dc49613e..39b6fc2825 100644 --- a/scripts/developer/utilities/render/highlight2.qml +++ b/scripts/developer/utilities/render/highlight2.qml @@ -23,9 +23,7 @@ Rectangle { color: hifi.colors.baseGray; anchors.margins: hifi.dimensions.contentMargin.x - //property var debugConfig: Render.getConfig("RenderMainView.HighlightDebug") - //property var highlightConfig: Render.getConfig("UpdateScene.HighlightStageSetup") - + signal sendToScript(var message); Column { @@ -35,40 +33,27 @@ Rectangle { anchors.right: parent.right anchors.margins: hifi.dimensions.contentMargin.x - Row { - spacing: 10 - anchors.left: parent.left - anchors.right: parent.right - - HifiControls.CheckBox { - id: debug - text: "View Mask" - checked: root.debugConfig["viewMask"] - onCheckedChanged: { - root.debugConfig["viewMask"] = checked; - } - } - HifiControls.CheckBox { - text: "Hover select" - checked: false - onCheckedChanged: { - sendToScript("pick "+checked.toString()) - } - } - HifiControls.CheckBox { - text: "Add to selection" - checked: false - onCheckedChanged: { - sendToScript("add "+checked.toString()) - } - } - } Separator {} - - XColor { - color: { "red": 0, "green": 255, "blue": 0} + Row { + height: 24 + anchors.left: parent.left + anchors.right: parent.right + HifiControls.Label { + height: 24 + width: parent.width / 2 + id: labelControl + text: "Color" + enabled: true + anchors.left: parent.left + anchors.right: parent.horizontalCenter + } + XColor { + // width: parent.width / 2 + anchors.left: parent.horizontalCenter + anchors.right: parent.right + color: { "red": 0, "green": 255, "blue": 0} + } } - Separator {} /* From 1483195285c3a47ccdb01f882ee60e35fd3c40ce Mon Sep 17 00:00:00 2001 From: samcake Date: Tue, 5 Dec 2017 18:27:53 -0800 Subject: [PATCH 13/29] almost complete setup working, yeah --- .../scripting/SelectionScriptingInterface.cpp | 8 + .../scripting/SelectionScriptingInterface.h | 2 + .../lib/plotperf/{XColor.qml => Color.qml} | 87 ++++--- .../developer/utilities/lib/plotperf/qmldir | 2 +- .../render/configSlider/ConfigSlider.qml | 4 + .../render/highlight/HighlightStyle.qml | 105 ++++++++ .../utilities/render/highlight/qmldir | 1 + .../developer/utilities/render/highlight2.qml | 226 +++++++----------- 8 files changed, 261 insertions(+), 174 deletions(-) rename scripts/developer/utilities/lib/plotperf/{XColor.qml => Color.qml} (74%) create mode 100644 scripts/developer/utilities/render/highlight/HighlightStyle.qml create mode 100644 scripts/developer/utilities/render/highlight/qmldir diff --git a/interface/src/scripting/SelectionScriptingInterface.cpp b/interface/src/scripting/SelectionScriptingInterface.cpp index ba500ae010..841e1738e3 100644 --- a/interface/src/scripting/SelectionScriptingInterface.cpp +++ b/interface/src/scripting/SelectionScriptingInterface.cpp @@ -146,6 +146,14 @@ QVariantMap SelectionScriptingInterface::getListHighlightStyle(const QString& li } } + +QStringList SelectionScriptingInterface::getHighlightStyles() const { + QStringList list; + QReadLocker lock(&_highlightStylesLock); + list = _highlightStyleMap.keys(); + return list; +} + render::HighlightStyle SelectionScriptingInterface::getHighlightStyle(const QString& listName) const { QReadLocker lock(&_highlightStylesLock); auto highlightStyle = _highlightStyleMap.find(listName); diff --git a/interface/src/scripting/SelectionScriptingInterface.h b/interface/src/scripting/SelectionScriptingInterface.h index 2d9dc07661..d0dcf8caec 100644 --- a/interface/src/scripting/SelectionScriptingInterface.h +++ b/interface/src/scripting/SelectionScriptingInterface.h @@ -176,6 +176,8 @@ public: */ Q_INVOKABLE QVariantMap getListHighlightStyle(const QString& listName) const; + Q_INVOKABLE QStringList getHighlightStyles() const; + render::HighlightStyle getHighlightStyle(const QString& listName) const; void onSelectedItemsListChanged(const QString& listName); diff --git a/scripts/developer/utilities/lib/plotperf/XColor.qml b/scripts/developer/utilities/lib/plotperf/Color.qml similarity index 74% rename from scripts/developer/utilities/lib/plotperf/XColor.qml rename to scripts/developer/utilities/lib/plotperf/Color.qml index 68600007d9..15d7f9fcc9 100644 --- a/scripts/developer/utilities/lib/plotperf/XColor.qml +++ b/scripts/developer/utilities/lib/plotperf/Color.qml @@ -1,5 +1,5 @@ // -// XColor.qml +// Color.qml // // Created by Sam Gateau 12/4/2017 // Copyright 2017 High Fidelity, Inc. @@ -20,48 +20,57 @@ Item { HifiConstants { id: hifi } id: root - anchors.left: parent.left - anchors.right: parent.right height: 24 - property var color + + property var _color: Qt.rgba(1.0, 1.0, 1.0, 1.0 ); property var zoneWidth: width / 3; property var hoveredOn: 0.0; - property var sliderHeight: height / 3; + property var sliderHeight: height / 2; - signal newColor( color la_color) - function getColor() { - return Qt.rgba(color.red / 255.0, color.green / 255.0, color.blue / 255.0, 1.0 ); - } + signal newColor(color __color) - function repaint() { - current.color = getColor() - } + function setColor(color) { + _color = Qt.rgba(color.r, color.g, color.b, 1.0) + updateColor() + } function setRed(r) { - color.red = r * 255; - repaint() - print("set red " + r) + _color.r = r; + updateColor() } function setGreen(g) { - color.green = g * 255; - repaint() - print("set green " + g) + _color.g = g; + updateColor() } function setBlue(b) { - color.blue = b * 255; + _color.b = b; + updateColor() + } + + function updateColor() { repaint() - print("set blue " + b) + newColor(_color) + } + function repaint() { + current.color = _color } function resetSliders() { - redZone.set(color.red / 255) - greenZone.set(color.green / 255) - blueZone.set(color.blue / 255) + redZone.set(_color.r) + greenZone.set(_color.g) + blueZone.set(_color.b) + } + + function setXColor(xcolor) { + setColor(Qt.rgba(xcolor.red/255, xcolor.green/255, color.blue/255, 1.0)) + } + function getXColor() { + return {red:_color.r * 255, green:_color.g * 255, blue:_color.b * 255} } Rectangle { id: current anchors.fill: root - color: root.getColor(); + color: root._color; } Rectangle { id: sliderBack @@ -87,8 +96,6 @@ Item { } Component.onCompleted: { - // Binding favors qml value, so set it first - bindingControl.when = true; } Item { @@ -98,13 +105,16 @@ Item { anchors.left: root.left width: root.zoneWidth - function set(r) { + function update(r) { if (r < 0.0) { r = 0.0 } else if (r > 1.0) { r = 1.0 } root.setRed(r) + set(r) + } + function set(r) { redRect.width = r * redZone.width redRect.color = Qt.rgba(r, 0, 0, 1) } @@ -121,7 +131,7 @@ Item { id: redArea anchors.fill: parent onPositionChanged: { - redZone.set(mouse.x / redArea.width) + redZone.update(mouse.x / redArea.width) } } } @@ -129,17 +139,19 @@ Item { id: greenZone anchors.top: root.top anchors.bottom: root.bottom - anchors.left: redZone.right - + anchors.horizontalCenter: root.horizontalCenter width: root.zoneWidth - function set(g) { + function update(g) { if (g < 0.0) { g = 0.0 } else if (g > 1.0) { g = 1.0 } root.setGreen(g) + set(g) + } + function set(g) { greenRect.width = g * greenZone.width greenRect.color = Qt.rgba(0, g, 0, 1) } @@ -156,7 +168,7 @@ Item { id: greenArea anchors.fill: parent onPositionChanged: { - greenZone.set(mouse.x / greenArea.width) + greenZone.update(mouse.x / greenArea.width) } } } @@ -164,18 +176,19 @@ Item { id: blueZone anchors.top: root.top anchors.bottom: root.bottom - anchors.right: root.right - // anchors.left: greenZone.right - + anchors.right: root.right width: root.zoneWidth - function set(b) { + function update(b) { if (b < 0.0) { b = 0.0 } else if (b > 1.0) { b = 1.0 } root.setBlue(b) + set(b) + } + function set(b) { blueRect.width = b * blueZone.width blueRect.color = Qt.rgba(0, 0, b, 1) } @@ -192,7 +205,7 @@ Item { id: blueArea anchors.fill: parent onPositionChanged: { - blueZone.set(mouse.x / blueArea.width) + blueZone.update(mouse.x / blueArea.width) } } } diff --git a/scripts/developer/utilities/lib/plotperf/qmldir b/scripts/developer/utilities/lib/plotperf/qmldir index 829592f87d..20b3fc9fcf 100644 --- a/scripts/developer/utilities/lib/plotperf/qmldir +++ b/scripts/developer/utilities/lib/plotperf/qmldir @@ -1,2 +1,2 @@ PlotPerf 1.0 PlotPerf.qml -XColor 1.0 XColor.qml \ No newline at end of file +Color 1.0 Color.qml diff --git a/scripts/developer/utilities/render/configSlider/ConfigSlider.qml b/scripts/developer/utilities/render/configSlider/ConfigSlider.qml index 830dc6de23..87e0e51726 100644 --- a/scripts/developer/utilities/render/configSlider/ConfigSlider.qml +++ b/scripts/developer/utilities/render/configSlider/ConfigSlider.qml @@ -30,6 +30,8 @@ Item { property alias min: sliderControl.minimumValue property alias max: sliderControl.maximumValue + signal valueChanged(real value) + Component.onCompleted: { // Binding favors qml value, so set it first sliderControl.value = root.config[root.property]; @@ -69,5 +71,7 @@ Item { anchors.rightMargin: 0 anchors.top: root.top anchors.topMargin: 0 + + onValueChanged: { root.valueChanged(value) } } } diff --git a/scripts/developer/utilities/render/highlight/HighlightStyle.qml b/scripts/developer/utilities/render/highlight/HighlightStyle.qml new file mode 100644 index 0000000000..189ac10b42 --- /dev/null +++ b/scripts/developer/utilities/render/highlight/HighlightStyle.qml @@ -0,0 +1,105 @@ +// +// highlightStyle.qml +// +// Created by Sam Gateau 12/4/2017 +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html +// +import QtQuick 2.7 +import QtQuick.Controls 1.4 +import QtQuick.Layouts 1.3 +import "../configSlider" +import "../../lib/plotperf" +import "qrc:///qml/styles-uit" +import "qrc:///qml/controls-uit" as HifiControls + +Item { + id: root + property var highlightStyle + height: 48 + + anchors.margins: 0 + + signal newStyle() + + function getStyle() { + return highlightStyle; + } + + Component.onCompleted: { + } + + Column { + spacing: 5 + anchors.left: root.left + anchors.right: root.right + anchors.margins: 0 + + + + ConfigSlider { + label: "Outline Width" + integral: false + config: root.highlightStyle + property: "outlineWidth" + max: 10 + min: 0 + + anchors.left: parent.left + anchors.right: parent.right + + onValueChanged: { root.highlightStyle["outlineWidth"] = value; newStyle() } + } + HifiControls.CheckBox { + id: isOutlineSmooth + text: "Smooth Outline" + checked: root.highlightStyle["isOutlineSmooth"] + onCheckedChanged: { + root.highlightStyle["isOutlineSmooth"] = checked; + newStyle(); + } + } + + Repeater { + model: [ + "Outline Unoccluded:outlineUnoccludedColor:outlineUnoccludedIntensity", + "Outline Occluded:outlineOccludedColor:outlineOccludedIntensity", + "Fill Unoccluded:fillUnoccludedColor:fillUnoccludedIntensity", + "Fill Occluded:fillOccludedColor:fillOccludedIntensity"] + Column { + anchors.left: parent.left + anchors.right: parent.right + anchors.margins: 0 + + Color { + height: 20 + anchors.right: parent.right + width: root.width / 2 + _color: Qt.rgba(root.highlightStyle[modelData.split(":")[1]].red / 255, root.highlightStyle[modelData.split(":")[1]].green / 255, root.highlightStyle[modelData.split(":")[1]].blue / 255, 1.0) + onNewColor: { + root.highlightStyle[modelData.split(":")[1]] = getXColor() + newStyle() + } + } + + ConfigSlider { + label: qsTr(modelData.split(":")[0]) + integral: false + config: root.highlightStyle + property: modelData.split(":")[2] + max: 1.0 + min: 0.0 + + anchors.left: parent.left + anchors.right: parent.right + + onValueChanged: { root.highlightStyle[modelData.split(":")[2]] = value; newStyle() } + } + + } + } + + } +} diff --git a/scripts/developer/utilities/render/highlight/qmldir b/scripts/developer/utilities/render/highlight/qmldir new file mode 100644 index 0000000000..31fc576bbe --- /dev/null +++ b/scripts/developer/utilities/render/highlight/qmldir @@ -0,0 +1 @@ +HighlightStyle 1.0 HighlightStyle.qml \ No newline at end of file diff --git a/scripts/developer/utilities/render/highlight2.qml b/scripts/developer/utilities/render/highlight2.qml index 39b6fc2825..583488c37d 100644 --- a/scripts/developer/utilities/render/highlight2.qml +++ b/scripts/developer/utilities/render/highlight2.qml @@ -16,157 +16,111 @@ import "qrc:///qml/styles-uit" import "qrc:///qml/controls-uit" as HifiControls import "configSlider" import "../lib/plotperf" +import "highlight" -Rectangle { +Item { id: root HifiConstants { id: hifi;} - color: hifi.colors.baseGray; - anchors.margins: hifi.dimensions.contentMargin.x + anchors.margins: 0 + property var listName: "contextOverlayHighlightList" + + property var styleList: Selection.getHighlightStyles() - signal sendToScript(var message); + Component.onCompleted: { + } + + Column { id: col - spacing: 10 - anchors.left: parent.left - anchors.right: parent.right + spacing: 5 + anchors.left: root.left + anchors.right: root.right anchors.margins: hifi.dimensions.contentMargin.x - Separator {} - Row { + Row { + id: controlbar + spacing: 10 + anchors.left: parent.left + anchors.right: parent.right height: 24 + + HifiControls.Button { + id: debug + text: "Refresh" + height: 24 + width: 128 + onClicked: { + print("list of highlight styles") + root.styleList = Selection.getHighlightStyles() + + print(root.styleList) + styleSelectorLoader.sourceComponent = undefined; + styleSelectorLoader.sourceComponent = selectorWidget; + } + } + + Loader { + id: styleSelectorLoader + sourceComponent: selectorWidget + width: 350 + anchors.right: parent.right + } + Component { + id: selectorWidget + HifiControls.ComboBox { + id: box + width: 350 + z: 999 + editable: true + colorScheme: hifi.colorSchemes.dark + model: root.styleList + label: "" + + Timer { + id: postpone + interval: 100; running: false; repeat: false + onTriggered: { styleWidgetLoader.sourceComponent = styleWidget } + } + onCurrentIndexChanged: { + root.listName = model[currentIndex]; + // sendToScript("highlight "+currentIndex) + // This is a hack to be sure the widgets below properly reflect the change of category: delete the Component + // by setting the loader source to Null and then recreate it 100ms later + styleWidgetLoader.sourceComponent = undefined; + postpone.interval = 100 + postpone.start() + } + } + + + } + } + + Separator {} + Loader { + id: styleWidgetLoader + sourceComponent: styleWidget + anchors.left: parent.left + anchors.right: parent.right + } + } + + Component { + id: styleWidget + + HighlightStyle { + id: highlightStyle anchors.left: parent.left anchors.right: parent.right - HifiControls.Label { - height: 24 - width: parent.width / 2 - id: labelControl - text: "Color" - enabled: true - anchors.left: parent.left - anchors.right: parent.horizontalCenter - } - XColor { - // width: parent.width / 2 - anchors.left: parent.horizontalCenter - anchors.right: parent.right - color: { "red": 0, "green": 255, "blue": 0} - } - } - Separator {} + highlightStyle: Selection.getListHighlightStyle(root.listName) -/* - HifiControls.ComboBox { - id: box - width: 350 - z: 999 - editable: true - colorScheme: hifi.colorSchemes.dark - model: [ - "contextOverlayHighlightList", - "highlightList1", - "highlightList2", - "highlightList3", - "highlightList4"] - label: "" - - Timer { - id: postpone - interval: 100; running: false; repeat: false - onTriggered: { paramWidgetLoader.sourceComponent = paramWidgets } - } - onCurrentIndexChanged: { - root.highlightConfig["selectionName"] = model[currentIndex]; - sendToScript("highlight "+currentIndex) - // This is a hack to be sure the widgets below properly reflect the change of category: delete the Component - // by setting the loader source to Null and then recreate it 100ms later - paramWidgetLoader.sourceComponent = undefined; - postpone.interval = 100 - postpone.start() + onNewStyle: { + var style = getStyle() + // print("new style " + JSON.stringify(style) ) + Selection.enableListHighlight(root.listName, style) } } - - Loader { - id: paramWidgetLoader - sourceComponent: paramWidgets - width: 350 - } - - Component { - id: paramWidgets - - Column { - spacing: 10 - anchors.margins: hifi.dimensions.contentMargin.x - - HifiControls.Label { - text: "Outline" - } - Column { - spacing: 10 - anchors.left: parent.left - anchors.right: parent.right - HifiControls.CheckBox { - text: "Smooth" - checked: root.highlightConfig["isOutlineSmooth"] - onCheckedChanged: { - root.highlightConfig["isOutlineSmooth"] = checked; - } - } - Repeater { - model: ["Width:outlineWidth:5.0:0.0", - "Intensity:outlineIntensity:1.0:0.0" - ] - ConfigSlider { - label: qsTr(modelData.split(":")[0]) - integral: false - config: root.highlightConfig - property: modelData.split(":")[1] - max: modelData.split(":")[2] - min: modelData.split(":")[3] - } - } - } - - Separator {} - HifiControls.Label { - text: "Color" - } - Repeater { - model: ["Red:colorR:1.0:0.0", - "Green:colorG:1.0:0.0", - "Blue:colorB:1.0:0.0" - ] - ConfigSlider { - label: qsTr(modelData.split(":")[0]) - integral: false - config: root.highlightConfig - property: modelData.split(":")[1] - max: modelData.split(":")[2] - min: modelData.split(":")[3] - } - } - - Separator {} - HifiControls.Label { - text: "Fill Opacity" - } - Repeater { - model: ["Unoccluded:unoccludedFillOpacity:1.0:0.0", - "Occluded:occludedFillOpacity:1.0:0.0" - ] - ConfigSlider { - label: qsTr(modelData.split(":")[0]) - integral: false - config: root.highlightConfig - property: modelData.split(":")[1] - max: modelData.split(":")[2] - min: modelData.split(":")[3] - } - } - } - } - */ } } From 5500a6d11cd9b8370e846968c823121f16d89f19 Mon Sep 17 00:00:00 2001 From: samcake Date: Wed, 6 Dec 2017 18:02:30 -0800 Subject: [PATCH 14/29] More to come --- .../scripting/SelectionScriptingInterface.cpp | 59 ++++++++++++++++--- .../scripting/SelectionScriptingInterface.h | 39 ++++++++---- .../developer/utilities/render/highlight2.qml | 6 +- 3 files changed, 80 insertions(+), 24 deletions(-) diff --git a/interface/src/scripting/SelectionScriptingInterface.cpp b/interface/src/scripting/SelectionScriptingInterface.cpp index 841e1738e3..195f1657e8 100644 --- a/interface/src/scripting/SelectionScriptingInterface.cpp +++ b/interface/src/scripting/SelectionScriptingInterface.cpp @@ -80,6 +80,20 @@ bool SelectionScriptingInterface::clearSelectedItemsList(const QString& listName return true; } +QStringList SelectionScriptingInterface::getListNames() const { + QStringList list; + QReadLocker lock(&_selectionListsLock); + list = _selectedItemsListMap.keys(); + return list; +} + +QStringList SelectionScriptingInterface::getHighlightedListNames() const { + QStringList list; + QReadLocker lock(&_highlightStylesLock); + list = _highlightStyleMap.keys(); + return list; +} + bool SelectionScriptingInterface::enableListHighlight(const QString& listName, const QVariantMap& highlightStyleValues) { QWriteLocker lock(&_highlightStylesLock); @@ -146,14 +160,6 @@ QVariantMap SelectionScriptingInterface::getListHighlightStyle(const QString& li } } - -QStringList SelectionScriptingInterface::getHighlightStyles() const { - QStringList list; - QReadLocker lock(&_highlightStylesLock); - list = _highlightStyleMap.keys(); - return list; -} - render::HighlightStyle SelectionScriptingInterface::getHighlightStyle(const QString& listName) const { QReadLocker lock(&_highlightStylesLock); auto highlightStyle = _highlightStyleMap.find(listName); @@ -234,6 +240,43 @@ void SelectionScriptingInterface::printList(const QString& listName) { } } +QVariantMap SelectionScriptingInterface::getSelectedItemsList(const QString& listName) const { + QReadLocker lock(&_selectionListsLock); + QVariantMap list; + auto currentList = _selectedItemsListMap.find(listName); + if (currentList != _selectedItemsListMap.end()) { + if ((*currentList).getContainsData()) { + + if (!(*currentList).getAvatarIDs().empty()) { + QList avatarIDs = QList::fromVector(QVector::fromStdVector((*currentList).getAvatarIDs())); + list["avatars"].fromValue( avatarIDs); + } + if (!(*currentList).getEntityIDs().empty()) { + // QList entityIDs = QList::fromVector(QVector::fromStdVector((*currentList).getEntityIDs())); + QList entityIDs; + for (auto j : (*currentList).getEntityIDs()) { + entityIDs.push_back( j ); + } + list["entities"] = (entityIDs); + } + if (!(*currentList).getOverlayIDs().empty()) { + QList overlayIDs = QList::fromVector(QVector::fromStdVector((*currentList).getOverlayIDs())); + list["overlays"].fromValue(overlayIDs); + } + + return list; + } + else { + //qDebug() << "List named " << listName << " empty"; + return list; + } + } + else { + // qDebug() << "List named " << listName << " doesn't exist."; + return list; + } +} + bool SelectionScriptingInterface::removeListFromMap(const QString& listName) { bool removed = false; { diff --git a/interface/src/scripting/SelectionScriptingInterface.h b/interface/src/scripting/SelectionScriptingInterface.h index d0dcf8caec..a05ddaa62c 100644 --- a/interface/src/scripting/SelectionScriptingInterface.h +++ b/interface/src/scripting/SelectionScriptingInterface.h @@ -27,17 +27,17 @@ class GameplayObjects { public: GameplayObjects(); - bool getContainsData() { return containsData; } + bool getContainsData() const { return containsData; } - std::vector getAvatarIDs() { return _avatarIDs; } + std::vector getAvatarIDs() const { return _avatarIDs; } bool addToGameplayObjects(const QUuid& avatarID); bool removeFromGameplayObjects(const QUuid& avatarID); - std::vector getEntityIDs() { return _entityIDs; } + std::vector getEntityIDs() const { return _entityIDs; } bool addToGameplayObjects(const EntityItemID& entityID); bool removeFromGameplayObjects(const EntityItemID& entityID); - std::vector getOverlayIDs() { return _overlayIDs; } + std::vector getOverlayIDs() const { return _overlayIDs; } bool addToGameplayObjects(const OverlayID& overlayID); bool removeFromGameplayObjects(const OverlayID& overlayID); @@ -90,14 +90,8 @@ class SelectionScriptingInterface : public QObject, public Dependency { public: SelectionScriptingInterface(); - GameplayObjects getList(const QString& listName); + Q_INVOKABLE QStringList getListNames() const; - /**jsdoc - * Prints out the list of avatars, entities and overlays stored in a particular selection. - * @function Selection.printList - * @param listName {string} name of the selection - */ - Q_INVOKABLE void printList(const QString& listName); /**jsdoc * Removes a named selection from the list of selections. * @function Selection.removeListFromMap @@ -132,6 +126,26 @@ public: */ Q_INVOKABLE bool clearSelectedItemsList(const QString& listName); + + + /**jsdoc + * Prints out the list of avatars, entities and overlays stored in a particular selection. + * @function Selection.printList + * @param listName {string} name of the selection + */ + Q_INVOKABLE void printList(const QString& listName); + + /**jsdoc + * Query the list of avatars, entities and overlays stored in a particular selection. + * @function Selection.getList + * @param listName {string} name of the selection + * @return + */ + Q_INVOKABLE QVariantMap getSelectedItemsList(const QString& listName) const; + + // + Q_INVOKABLE QStringList getHighlightedListNames() const; + /**jsdoc * Enable highlighting for the named selection. * If the Selection doesn't exist, it will be created. @@ -176,7 +190,8 @@ public: */ Q_INVOKABLE QVariantMap getListHighlightStyle(const QString& listName) const; - Q_INVOKABLE QStringList getHighlightStyles() const; + + GameplayObjects getList(const QString& listName); render::HighlightStyle getHighlightStyle(const QString& listName) const; diff --git a/scripts/developer/utilities/render/highlight2.qml b/scripts/developer/utilities/render/highlight2.qml index 583488c37d..b22cfd4033 100644 --- a/scripts/developer/utilities/render/highlight2.qml +++ b/scripts/developer/utilities/render/highlight2.qml @@ -24,7 +24,7 @@ Item { anchors.margins: 0 property var listName: "contextOverlayHighlightList" - property var styleList: Selection.getHighlightStyles() + property var styleList: Selection.getHighlightedListNames() signal sendToScript(var message); @@ -50,10 +50,9 @@ Item { id: debug text: "Refresh" height: 24 - width: 128 onClicked: { print("list of highlight styles") - root.styleList = Selection.getHighlightStyles() + root.styleList = Selection.getHighlightedListNames() print(root.styleList) styleSelectorLoader.sourceComponent = undefined; @@ -71,7 +70,6 @@ Item { id: selectorWidget HifiControls.ComboBox { id: box - width: 350 z: 999 editable: true colorScheme: hifi.colorSchemes.dark From 0245a7005daa126c9569c3fc78b4ad361fc12aea Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Wed, 6 Dec 2017 22:44:58 -0800 Subject: [PATCH 15/29] Adding the query of a particular selection content --- .../scripting/SelectionScriptingInterface.cpp | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/interface/src/scripting/SelectionScriptingInterface.cpp b/interface/src/scripting/SelectionScriptingInterface.cpp index 195f1657e8..4e28fb4702 100644 --- a/interface/src/scripting/SelectionScriptingInterface.cpp +++ b/interface/src/scripting/SelectionScriptingInterface.cpp @@ -104,10 +104,6 @@ bool SelectionScriptingInterface::enableListHighlight(const QString& listName, c } if (!(*highlightStyle).isBoundToList()) { - /* auto currentList = _selectedItemsListMap.find(listName); - if (currentList == _selectedItemsListMap.end()) { - _selectedItemsListMap.insert(listName, GameplayObjects()); - }*/ setupHandler(listName); (*highlightStyle).setBoundToList(true); } @@ -248,31 +244,34 @@ QVariantMap SelectionScriptingInterface::getSelectedItemsList(const QString& lis if ((*currentList).getContainsData()) { if (!(*currentList).getAvatarIDs().empty()) { - QList avatarIDs = QList::fromVector(QVector::fromStdVector((*currentList).getAvatarIDs())); - list["avatars"].fromValue( avatarIDs); + QList avatarIDs; + for (auto j : (*currentList).getAvatarIDs()) { + avatarIDs.push_back((QUuid)j); + } + list["avatars"] = (avatarIDs); } if (!(*currentList).getEntityIDs().empty()) { - // QList entityIDs = QList::fromVector(QVector::fromStdVector((*currentList).getEntityIDs())); QList entityIDs; for (auto j : (*currentList).getEntityIDs()) { - entityIDs.push_back( j ); + entityIDs.push_back((QUuid)j ); } list["entities"] = (entityIDs); } if (!(*currentList).getOverlayIDs().empty()) { - QList overlayIDs = QList::fromVector(QVector::fromStdVector((*currentList).getOverlayIDs())); - list["overlays"].fromValue(overlayIDs); + QList overlayIDs; + for (auto j : (*currentList).getOverlayIDs()) { + overlayIDs.push_back((QUuid)j); + } + list["overlays"] = (overlayIDs); } return list; } else { - //qDebug() << "List named " << listName << " empty"; return list; } } else { - // qDebug() << "List named " << listName << " doesn't exist."; return list; } } From 6148458aeb274f3247e8c2a39ae61e51231eb6b7 Mon Sep 17 00:00:00 2001 From: samcake Date: Thu, 7 Dec 2017 16:04:08 -0800 Subject: [PATCH 16/29] Workable state, need final clean up and testing --- .../scripting/SelectionScriptingInterface.h | 20 ++++-- libraries/render/src/render/HighlightStyle.h | 6 +- .../developer/utilities/render/highlight2.qml | 72 +++++++++++++++---- 3 files changed, 77 insertions(+), 21 deletions(-) diff --git a/interface/src/scripting/SelectionScriptingInterface.h b/interface/src/scripting/SelectionScriptingInterface.h index a05ddaa62c..75bddbe62d 100644 --- a/interface/src/scripting/SelectionScriptingInterface.h +++ b/interface/src/scripting/SelectionScriptingInterface.h @@ -59,8 +59,6 @@ public: public slots: void selectedItemsListChanged(const QString& listName); - // void highlightStyleChanged(const QString& listName); - // void highlightStyleRemoved(const QString& listName); private: QString _listName{ "" }; @@ -90,6 +88,11 @@ class SelectionScriptingInterface : public QObject, public Dependency { public: SelectionScriptingInterface(); + /**jsdoc + * Query the names of all the selection lists + * @function Selection.getListNames + * @return An array of names of all the selection lists + */ Q_INVOKABLE QStringList getListNames() const; /**jsdoc @@ -126,8 +129,6 @@ public: */ Q_INVOKABLE bool clearSelectedItemsList(const QString& listName); - - /**jsdoc * Prints out the list of avatars, entities and overlays stored in a particular selection. * @function Selection.printList @@ -139,11 +140,18 @@ public: * Query the list of avatars, entities and overlays stored in a particular selection. * @function Selection.getList * @param listName {string} name of the selection - * @return + * @return a js object containing the following properties (if the array of obkjects are not empty): + * - "entities": [ and array of the entityID of the entities in the selection] + * - "avatars": [ and array of the avatarID of the avatars in the selection] + * - "overlays": [ and array of the overlayID of the overlays in the selection] */ Q_INVOKABLE QVariantMap getSelectedItemsList(const QString& listName) const; - // + /**jsdoc + * Query the names of the highlighted selection lists + * @function Selection.getHighlightedListNames + * @return An array of names of the selection list currently highlight enabled + */ Q_INVOKABLE QStringList getHighlightedListNames() const; /**jsdoc diff --git a/libraries/render/src/render/HighlightStyle.h b/libraries/render/src/render/HighlightStyle.h index 1243f5aa60..981b43429a 100644 --- a/libraries/render/src/render/HighlightStyle.h +++ b/libraries/render/src/render/HighlightStyle.h @@ -26,9 +26,9 @@ namespace render { }; RGBA _outlineUnoccluded{ { 1.f, 0.7f, 0.2f }, 0.9f }; - RGBA _outlineOccluded{ { 0.2f, 0.7f, 1.0f }, 0.9f }; - RGBA _fillUnoccluded{ { 1.f, 0.2f, 0.7f }, 0.0f }; - RGBA _fillOccluded{ { 0.7f, 1.f, 0.2f }, 0.0f }; + RGBA _outlineOccluded{ { 1.f, 0.7f, 0.2f }, 0.9f }; + RGBA _fillUnoccluded{ { 0.2f, 0.7f, 1.0f }, 0.0f }; + RGBA _fillOccluded{ { 0.2f, 0.7f, 1.0f }, 0.0f }; float _outlineWidth{ 2.0f }; bool _isOutlineSmooth{ false }; diff --git a/scripts/developer/utilities/render/highlight2.qml b/scripts/developer/utilities/render/highlight2.qml index b22cfd4033..af478723fa 100644 --- a/scripts/developer/utilities/render/highlight2.qml +++ b/scripts/developer/utilities/render/highlight2.qml @@ -29,14 +29,18 @@ Item { signal sendToScript(var message); Component.onCompleted: { + // Connect the signal from Selection when any selection content change and use it to refresh the current selection view + Selection.selectedItemsListChanged.connect(resetSelectionView) + } + + function resetSelectionView() { + selectionView.resetSelectionView(); } - Column { id: col spacing: 5 - anchors.left: root.left - anchors.right: root.right + anchors.fill: root anchors.margins: hifi.dimensions.contentMargin.x Row { @@ -50,6 +54,7 @@ Item { id: debug text: "Refresh" height: 24 + width: 82 onClicked: { print("list of highlight styles") root.styleList = Selection.getHighlightedListNames() @@ -57,13 +62,14 @@ Item { print(root.styleList) styleSelectorLoader.sourceComponent = undefined; styleSelectorLoader.sourceComponent = selectorWidget; + resetSelectionView(); } } Loader { id: styleSelectorLoader sourceComponent: selectorWidget - width: 350 + width: 300 anchors.right: parent.right } Component { @@ -79,11 +85,12 @@ Item { Timer { id: postpone interval: 100; running: false; repeat: false - onTriggered: { styleWidgetLoader.sourceComponent = styleWidget } + onTriggered: { + styleWidgetLoader.sourceComponent = styleWidget + } } onCurrentIndexChanged: { root.listName = model[currentIndex]; - // sendToScript("highlight "+currentIndex) // This is a hack to be sure the widgets below properly reflect the change of category: delete the Component // by setting the loader source to Null and then recreate it 100ms later styleWidgetLoader.sourceComponent = undefined; @@ -91,8 +98,6 @@ Item { postpone.start() } } - - } } @@ -101,9 +106,52 @@ Item { id: styleWidgetLoader sourceComponent: styleWidget anchors.left: parent.left - anchors.right: parent.right - } - } + anchors.right: parent.right + height: 240 + } + + Separator {} + + Rectangle { + id: selectionView + anchors.left: parent.left + anchors.right: parent.right + height: 250 + color: hifi.colors.lightGray + + function resetSelectionView() { + // myModel.resetSelectionView(); + var entities = Selection.getSelectedItemsList(root.listName)["entities"] + //print("resetSelectionView" + JSON.stringify(entities)) + myModel.clear() + var fLen = entities.length; + for (var i = 0; i < fLen; i++) { + myModel.append({ "objectID": JSON.stringify(entities[i]) }) + // print("resetSelectionView" + JSON.stringify( entities[i])) + } + } + + ListModel { + id: myModel + } + + Component { + id: myDelegate + Row { + id: fruit + Text { text: JSON.stringify(objectID) } + } + } + + ListView { + id: selectionListView + anchors.fill: parent + anchors.topMargin: 30 + model: myModel + delegate: myDelegate + } + } + } Component { id: styleWidget @@ -116,7 +164,7 @@ Item { onNewStyle: { var style = getStyle() - // print("new style " + JSON.stringify(style) ) + // print("new style " + JSON.stringify(style) ) Selection.enableListHighlight(root.listName, style) } } From 65f22f498ac8be2b04bb29300f18c320835f7842 Mon Sep 17 00:00:00 2001 From: samcake Date: Thu, 7 Dec 2017 16:09:06 -0800 Subject: [PATCH 17/29] remove previous version of debug highlight --- .../utilities/render/debugHighlight.js | 265 ------------------ .../developer/utilities/render/highlight.qml | 177 ------------ 2 files changed, 442 deletions(-) delete mode 100644 scripts/developer/utilities/render/debugHighlight.js delete mode 100644 scripts/developer/utilities/render/highlight.qml diff --git a/scripts/developer/utilities/render/debugHighlight.js b/scripts/developer/utilities/render/debugHighlight.js deleted file mode 100644 index c647c601b9..0000000000 --- a/scripts/developer/utilities/render/debugHighlight.js +++ /dev/null @@ -1,265 +0,0 @@ -// -// debugHighlight.js -// developer/utilities/render -// -// Olivier Prat, created on 08/08/2017. -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -"use strict"; - -// -// Luci.js -// tablet-engine app -// -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -(function() { - var TABLET_BUTTON_NAME = "Highlight"; - var QMLAPP_URL = Script.resolvePath("./highlight.qml"); - var ICON_URL = Script.resolvePath("../../../system/assets/images/luci-i.svg"); - var ACTIVE_ICON_URL = Script.resolvePath("../../../system/assets/images/luci-a.svg"); - - - var onLuciScreen = false; - - function onClicked() { - if (onLuciScreen) { - tablet.gotoHomeScreen(); - } else { - tablet.loadQMLSource(QMLAPP_URL); - } - } - - var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); - var button = tablet.addButton({ - text: TABLET_BUTTON_NAME, - icon: ICON_URL, - activeIcon: ACTIVE_ICON_URL, - sortOrder: 1 - }); - - var hasEventBridge = false; - - function wireEventBridge(on) { - if (!tablet) { - print("Warning in wireEventBridge(): 'tablet' undefined!"); - return; - } - if (on) { - if (!hasEventBridge) { - tablet.fromQml.connect(fromQml); - hasEventBridge = true; - } - } else { - if (hasEventBridge) { - tablet.fromQml.disconnect(fromQml); - hasEventBridge = false; - } - } - } - - function onScreenChanged(type, url) { - if (url === QMLAPP_URL) { - onLuciScreen = true; - } else { - onLuciScreen = false; - } - - button.editProperties({isActive: onLuciScreen}); - wireEventBridge(onLuciScreen); - } - - function fromQml(message) { - } - - button.clicked.connect(onClicked); - tablet.screenChanged.connect(onScreenChanged); - - var moveDebugCursor = false; - Controller.mousePressEvent.connect(function (e) { - if (e.isMiddleButton) { - moveDebugCursor = true; - setDebugCursor(e.x, e.y); - } - }); - Controller.mouseReleaseEvent.connect(function() { moveDebugCursor = false; }); - Controller.mouseMoveEvent.connect(function (e) { if (moveDebugCursor) setDebugCursor(e.x, e.y); }); - - - Script.scriptEnding.connect(function () { - if (onLuciScreen) { - tablet.gotoHomeScreen(); - } - button.clicked.disconnect(onClicked); - tablet.screenChanged.disconnect(onScreenChanged); - tablet.removeButton(button); - }); - - function setDebugCursor(x, y) { - nx = (x / Window.innerWidth); - ny = 1.0 - ((y) / (Window.innerHeight - 32)); - - Render.getConfig("RenderMainView").getConfig("Antialiasing").debugCursorTexcoord = { x: nx, y: ny }; - } - -}()); - - - -// Set up the qml ui -var qml = Script.resolvePath('highlight.qml'); -var window = new OverlayWindow({ - title: 'Highlight', - source: qml, - width: 400, - height: 400, -}); -window.closed.connect(function() { Script.stop(); }); - -"use strict"; - -// Created by Sam Gondelman on 9/7/2017 -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html - -(function() { // BEGIN LOCAL_SCOPE - -var END_DIMENSIONS = { - x: 0.15, - y: 0.15, - z: 0.15 -}; -var COLOR = {red: 97, green: 247, blue: 255}; -var end = { - type: "sphere", - dimensions: END_DIMENSIONS, - color: COLOR, - ignoreRayIntersection: true, - alpha: 1.0, - visible: true -} - -var COLOR2 = {red: 247, green: 97, blue: 255}; -var end2 = { - type: "sphere", - dimensions: END_DIMENSIONS, - color: COLOR2, - ignoreRayIntersection: true, - alpha: 1.0, - visible: true -} - -var highlightGroupIndex = 0 -var isSelectionAddEnabled = false -var isSelectionEnabled = false -var renderStates = [{name: "test", end: end}]; -var defaultRenderStates = [{name: "test", distance: 20.0, end: end2}]; -var time = 0 - -var ray = LaserPointers.createLaserPointer({ - joint: "Mouse", - filter: RayPick.PICK_ENTITIES | RayPick.PICK_OVERLAYS | RayPick.PICK_AVATARS | RayPick.PICK_INVISIBLE | RayPick.PICK_NONCOLLIDABLE, - renderStates: renderStates, - defaultRenderStates: defaultRenderStates, - enabled: false -}); - -function getSelectionName() { - var selectionName = "contextOverlayHighlightList" - - if (highlightGroupIndex>0) { - selectionName += highlightGroupIndex - } - return selectionName -} - -function fromQml(message) { - tokens = message.split(' ') - print("Received '"+message+"' from hightlight.qml") - if (tokens[0]=="highlight") { - highlightGroupIndex = parseInt(tokens[1]) - print("Switching to highlight group "+highlightGroupIndex) - } else if (tokens[0]=="pick") { - isSelectionEnabled = tokens[1]=='true' - print("Ray picking set to "+isSelectionEnabled.toString()) - if (isSelectionEnabled) { - LaserPointers.enableLaserPointer(ray) - } else { - LaserPointers.disableLaserPointer(ray) - } - time = 0 - } else if (tokens[0]=="add") { - isSelectionAddEnabled = tokens[1]=='true' - print("Add to selection set to "+isSelectionAddEnabled.toString()) - if (!isSelectionAddEnabled) { - Selection.clearSelectedItemsList(getSelectionName()) - } - } -} - -window.fromQml.connect(fromQml); - -function cleanup() { - LaserPointers.removeLaserPointer(ray); -} -Script.scriptEnding.connect(cleanup); - -var prevID = 0 -var prevType = "" -var selectedID = 0 -var selectedType = "" -function update(deltaTime) { - - // you have to do this repeatedly because there's a bug but I'll fix it - LaserPointers.setRenderState(ray, "test"); - - var result = LaserPointers.getPrevRayPickResult(ray); - var selectionName = getSelectionName() - - if (isSelectionEnabled && result.type != RayPick.INTERSECTED_NONE) { - time += deltaTime - if (result.objectID != prevID) { - var typeName = "" - if (result.type == RayPick.INTERSECTED_ENTITY) { - typeName = "entity" - } else if (result.type == RayPick.INTERSECTED_OVERLAY) { - typeName = "overlay" - } else if (result.type == RayPick.INTERSECTED_AVATAR) { - typeName = "avatar" - } - - prevID = result.objectID; - prevType = typeName; - time = 0 - } else if (time>1.0 && prevID!=selectedID) { - if (prevID != 0 && !isSelectionAddEnabled) { - Selection.removeFromSelectedItemsList(selectionName, selectedType, selectedID) - } - selectedID = prevID - selectedType = prevType - Selection.addToSelectedItemsList(selectionName, selectedType, selectedID) - print("HIGHLIGHT " + highlightGroupIndex + " picked type: " + result.type + ", id: " + result.objectID); - } - } else { - if (prevID != 0 && !isSelectionAddEnabled) { - Selection.removeFromSelectedItemsList(selectionName, prevType, prevID) - } - prevID = 0 - selectedID = 0 - time = 0 - } -} - -Script.update.connect(update); - -}()); // END LOCAL_SCOPE \ No newline at end of file diff --git a/scripts/developer/utilities/render/highlight.qml b/scripts/developer/utilities/render/highlight.qml deleted file mode 100644 index 6be74fcf40..0000000000 --- a/scripts/developer/utilities/render/highlight.qml +++ /dev/null @@ -1,177 +0,0 @@ -// -// highlight.qml -// developer/utilities/render -// -// Olivier Prat, created on 08/08/2017. -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html -// -import QtQuick 2.7 -import QtQuick.Controls 1.4 -import QtQuick.Layouts 1.3 - -import "qrc:///qml/styles-uit" -import "qrc:///qml/controls-uit" as HifiControls -import "configSlider" - -Rectangle { - id: root - HifiConstants { id: hifi;} - color: hifi.colors.baseGray; - anchors.margins: hifi.dimensions.contentMargin.x - - property var debugConfig: Render.getConfig("RenderMainView.HighlightDebug") - property var highlightConfig: Render.getConfig("UpdateScene.HighlightStageSetup") - - signal sendToScript(var message); - - Column { - id: col - spacing: 10 - anchors.left: parent.left - anchors.right: parent.right - anchors.margins: hifi.dimensions.contentMargin.x - - Row { - spacing: 10 - anchors.left: parent.left - anchors.right: parent.right - - HifiControls.CheckBox { - id: debug - text: "View Mask" - checked: root.debugConfig["viewMask"] - onCheckedChanged: { - root.debugConfig["viewMask"] = checked; - } - } - HifiControls.CheckBox { - text: "Hover select" - checked: false - onCheckedChanged: { - sendToScript("pick "+checked.toString()) - } - } - HifiControls.CheckBox { - text: "Add to selection" - checked: false - onCheckedChanged: { - sendToScript("add "+checked.toString()) - } - } - } - - HifiControls.ComboBox { - id: box - width: 350 - z: 999 - editable: true - colorScheme: hifi.colorSchemes.dark - model: [ - "contextOverlayHighlightList", - "highlightList1", - "highlightList2", - "highlightList3", - "highlightList4"] - label: "" - - Timer { - id: postpone - interval: 100; running: false; repeat: false - onTriggered: { paramWidgetLoader.sourceComponent = paramWidgets } - } - onCurrentIndexChanged: { - root.highlightConfig["selectionName"] = model[currentIndex]; - sendToScript("highlight "+currentIndex) - // This is a hack to be sure the widgets below properly reflect the change of category: delete the Component - // by setting the loader source to Null and then recreate it 100ms later - paramWidgetLoader.sourceComponent = undefined; - postpone.interval = 100 - postpone.start() - } - } - - Loader { - id: paramWidgetLoader - sourceComponent: paramWidgets - width: 350 - } - - Component { - id: paramWidgets - - Column { - spacing: 10 - anchors.margins: hifi.dimensions.contentMargin.x - - HifiControls.Label { - text: "Outline" - } - Column { - spacing: 10 - anchors.left: parent.left - anchors.right: parent.right - HifiControls.CheckBox { - text: "Smooth" - checked: root.highlightConfig["isOutlineSmooth"] - onCheckedChanged: { - root.highlightConfig["isOutlineSmooth"] = checked; - } - } - Repeater { - model: ["Width:outlineWidth:5.0:0.0", - "Intensity:outlineIntensity:1.0:0.0" - ] - ConfigSlider { - label: qsTr(modelData.split(":")[0]) - integral: false - config: root.highlightConfig - property: modelData.split(":")[1] - max: modelData.split(":")[2] - min: modelData.split(":")[3] - } - } - } - - Separator {} - HifiControls.Label { - text: "Color" - } - Repeater { - model: ["Red:colorR:1.0:0.0", - "Green:colorG:1.0:0.0", - "Blue:colorB:1.0:0.0" - ] - ConfigSlider { - label: qsTr(modelData.split(":")[0]) - integral: false - config: root.highlightConfig - property: modelData.split(":")[1] - max: modelData.split(":")[2] - min: modelData.split(":")[3] - } - } - - Separator {} - HifiControls.Label { - text: "Fill Opacity" - } - Repeater { - model: ["Unoccluded:unoccludedFillOpacity:1.0:0.0", - "Occluded:occludedFillOpacity:1.0:0.0" - ] - ConfigSlider { - label: qsTr(modelData.split(":")[0]) - integral: false - config: root.highlightConfig - property: modelData.split(":")[1] - max: modelData.split(":")[2] - min: modelData.split(":")[3] - } - } - } - } - } -} From 298b9be0c2295f11ca29837be2ea0a94f6c3064e Mon Sep 17 00:00:00 2001 From: samcake Date: Thu, 7 Dec 2017 16:13:32 -0800 Subject: [PATCH 18/29] Reinstall highlight debug tool --- .../utilities/render/{debugHighlight2.js => debugHighlight.js} | 0 .../developer/utilities/render/{highlight2.qml => highlight.qml} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename scripts/developer/utilities/render/{debugHighlight2.js => debugHighlight.js} (100%) rename scripts/developer/utilities/render/{highlight2.qml => highlight.qml} (100%) diff --git a/scripts/developer/utilities/render/debugHighlight2.js b/scripts/developer/utilities/render/debugHighlight.js similarity index 100% rename from scripts/developer/utilities/render/debugHighlight2.js rename to scripts/developer/utilities/render/debugHighlight.js diff --git a/scripts/developer/utilities/render/highlight2.qml b/scripts/developer/utilities/render/highlight.qml similarity index 100% rename from scripts/developer/utilities/render/highlight2.qml rename to scripts/developer/utilities/render/highlight.qml From ace8e153c220e18148e806c786e9ad8c8c1cb348 Mon Sep 17 00:00:00 2001 From: samcake Date: Thu, 7 Dec 2017 17:45:40 -0800 Subject: [PATCH 19/29] making sure the ID of an object in the Selection list is unique and more refined debugging --- .../scripting/SelectionScriptingInterface.cpp | 12 +- .../scripting/SelectionScriptingInterface.h | 3 +- .../utilities/render/debugHighlight.js | 152 +----------------- .../developer/utilities/render/highlight.qml | 2 +- 4 files changed, 13 insertions(+), 156 deletions(-) diff --git a/interface/src/scripting/SelectionScriptingInterface.cpp b/interface/src/scripting/SelectionScriptingInterface.cpp index 4e28fb4702..6f2696f2f5 100644 --- a/interface/src/scripting/SelectionScriptingInterface.cpp +++ b/interface/src/scripting/SelectionScriptingInterface.cpp @@ -18,7 +18,9 @@ GameplayObjects::GameplayObjects() { bool GameplayObjects::addToGameplayObjects(const QUuid& avatarID) { containsData = true; - _avatarIDs.push_back(avatarID); + if (std::find(_avatarIDs.begin(), _avatarIDs.end(), avatarID) == _avatarIDs.end()) { + _avatarIDs.push_back(avatarID); + } return true; } bool GameplayObjects::removeFromGameplayObjects(const QUuid& avatarID) { @@ -28,7 +30,9 @@ bool GameplayObjects::removeFromGameplayObjects(const QUuid& avatarID) { bool GameplayObjects::addToGameplayObjects(const EntityItemID& entityID) { containsData = true; - _entityIDs.push_back(entityID); + if (std::find(_entityIDs.begin(), _entityIDs.end(), entityID) == _entityIDs.end()) { + _entityIDs.push_back(entityID); + } return true; } bool GameplayObjects::removeFromGameplayObjects(const EntityItemID& entityID) { @@ -38,7 +42,9 @@ bool GameplayObjects::removeFromGameplayObjects(const EntityItemID& entityID) { bool GameplayObjects::addToGameplayObjects(const OverlayID& overlayID) { containsData = true; - _overlayIDs.push_back(overlayID); + if (std::find(_overlayIDs.begin(), _overlayIDs.end(), overlayID) == _overlayIDs.end()) { + _overlayIDs.push_back(overlayID); + } return true; } bool GameplayObjects::removeFromGameplayObjects(const OverlayID& overlayID) { diff --git a/interface/src/scripting/SelectionScriptingInterface.h b/interface/src/scripting/SelectionScriptingInterface.h index 75bddbe62d..5c2bf2789f 100644 --- a/interface/src/scripting/SelectionScriptingInterface.h +++ b/interface/src/scripting/SelectionScriptingInterface.h @@ -140,10 +140,11 @@ public: * Query the list of avatars, entities and overlays stored in a particular selection. * @function Selection.getList * @param listName {string} name of the selection - * @return a js object containing the following properties (if the array of obkjects are not empty): + * @return a js object describing the content of a selection list with the following properties: * - "entities": [ and array of the entityID of the entities in the selection] * - "avatars": [ and array of the avatarID of the avatars in the selection] * - "overlays": [ and array of the overlayID of the overlays in the selection] + * If the list name doesn't exist, the function returns an empty js object with no properties. */ Q_INVOKABLE QVariantMap getSelectedItemsList(const QString& listName) const; diff --git a/scripts/developer/utilities/render/debugHighlight.js b/scripts/developer/utilities/render/debugHighlight.js index 387d5bfe4a..b1a91abdd7 100644 --- a/scripts/developer/utilities/render/debugHighlight.js +++ b/scripts/developer/utilities/render/debugHighlight.js @@ -11,19 +11,9 @@ "use strict"; -// -// Luci.js -// tablet-engine app -// -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - (function() { var TABLET_BUTTON_NAME = "Highlight"; - var QMLAPP_URL = Script.resolvePath("./highlight2.qml"); + var QMLAPP_URL = Script.resolvePath("./highlight.qml"); var ICON_URL = Script.resolvePath("../../../system/assets/images/luci-i.svg"); var ACTIVE_ICON_URL = Script.resolvePath("../../../system/assets/images/luci-a.svg"); @@ -109,143 +99,3 @@ }()); - -// Set up the qml ui - -// Created by Sam Gondelman on 9/7/2017 -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -/* -(function() { // BEGIN LOCAL_SCOPE - -var END_DIMENSIONS = { - x: 0.15, - y: 0.15, - z: 0.15 -}; -var COLOR = {red: 97, green: 247, blue: 255}; -var end = { - type: "sphere", - dimensions: END_DIMENSIONS, - color: COLOR, - ignoreRayIntersection: true, - alpha: 1.0, - visible: true -} - -var COLOR2 = {red: 247, green: 97, blue: 255}; -var end2 = { - type: "sphere", - dimensions: END_DIMENSIONS, - color: COLOR2, - ignoreRayIntersection: true, - alpha: 1.0, - visible: true -} - -var highlightGroupIndex = 0 -var isSelectionAddEnabled = false -var isSelectionEnabled = false -var renderStates = [{name: "test", end: end}]; -var defaultRenderStates = [{name: "test", distance: 20.0, end: end2}]; -var time = 0 - -var ray = LaserPointers.createLaserPointer({ - joint: "Mouse", - filter: RayPick.PICK_ENTITIES | RayPick.PICK_OVERLAYS | RayPick.PICK_AVATARS | RayPick.PICK_INVISIBLE | RayPick.PICK_NONCOLLIDABLE, - renderStates: renderStates, - defaultRenderStates: defaultRenderStates, - enabled: false -}); - -function getSelectionName() { - var selectionName = "contextOverlayHighlightList" - - if (highlightGroupIndex>0) { - selectionName += highlightGroupIndex - } - return selectionName -} - -function fromQml(message) { - tokens = message.split(' ') - print("Received '"+message+"' from hightlight.qml") - if (tokens[0]=="highlight") { - highlightGroupIndex = parseInt(tokens[1]) - print("Switching to highlight group "+highlightGroupIndex) - } else if (tokens[0]=="pick") { - isSelectionEnabled = tokens[1]=='true' - print("Ray picking set to "+isSelectionEnabled.toString()) - if (isSelectionEnabled) { - LaserPointers.enableLaserPointer(ray) - } else { - LaserPointers.disableLaserPointer(ray) - } - time = 0 - } else if (tokens[0]=="add") { - isSelectionAddEnabled = tokens[1]=='true' - print("Add to selection set to "+isSelectionAddEnabled.toString()) - if (!isSelectionAddEnabled) { - Selection.clearSelectedItemsList(getSelectionName()) - } - } -} - -window.fromQml.connect(fromQml); - -function cleanup() { - LaserPointers.removeLaserPointer(ray); -} -Script.scriptEnding.connect(cleanup); - -var prevID = 0 -var prevType = "" -var selectedID = 0 -var selectedType = "" -function update(deltaTime) { - - // you have to do this repeatedly because there's a bug but I'll fix it - LaserPointers.setRenderState(ray, "test"); - - var result = LaserPointers.getPrevRayPickResult(ray); - var selectionName = getSelectionName() - - if (isSelectionEnabled && result.type != RayPick.INTERSECTED_NONE) { - time += deltaTime - if (result.objectID != prevID) { - var typeName = "" - if (result.type == RayPick.INTERSECTED_ENTITY) { - typeName = "entity" - } else if (result.type == RayPick.INTERSECTED_OVERLAY) { - typeName = "overlay" - } else if (result.type == RayPick.INTERSECTED_AVATAR) { - typeName = "avatar" - } - - prevID = result.objectID; - prevType = typeName; - time = 0 - } else if (time>1.0 && prevID!=selectedID) { - if (prevID != 0 && !isSelectionAddEnabled) { - Selection.removeFromSelectedItemsList(selectionName, selectedType, selectedID) - } - selectedID = prevID - selectedType = prevType - Selection.addToSelectedItemsList(selectionName, selectedType, selectedID) - print("HIGHLIGHT " + highlightGroupIndex + " picked type: " + result.type + ", id: " + result.objectID); - } - } else { - if (prevID != 0 && !isSelectionAddEnabled) { - Selection.removeFromSelectedItemsList(selectionName, prevType, prevID) - } - prevID = 0 - selectedID = 0 - time = 0 - } -} - -Script.update.connect(update); - -}()); // END LOCAL_SCOPE*/ \ No newline at end of file diff --git a/scripts/developer/utilities/render/highlight.qml b/scripts/developer/utilities/render/highlight.qml index af478723fa..fed42a76c6 100644 --- a/scripts/developer/utilities/render/highlight.qml +++ b/scripts/developer/utilities/render/highlight.qml @@ -62,7 +62,6 @@ Item { print(root.styleList) styleSelectorLoader.sourceComponent = undefined; styleSelectorLoader.sourceComponent = selectorWidget; - resetSelectionView(); } } @@ -87,6 +86,7 @@ Item { interval: 100; running: false; repeat: false onTriggered: { styleWidgetLoader.sourceComponent = styleWidget + resetSelectionView(); } } onCurrentIndexChanged: { From 7a9d77fed49f4e7d90ff4e16833a70b54d0719a2 Mon Sep 17 00:00:00 2001 From: samcake Date: Thu, 7 Dec 2017 17:53:30 -0800 Subject: [PATCH 20/29] return a legit selectedItemsList js object as long as the list exist, only void if the list name is unknown --- .../scripting/SelectionScriptingInterface.cpp | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/interface/src/scripting/SelectionScriptingInterface.cpp b/interface/src/scripting/SelectionScriptingInterface.cpp index 6f2696f2f5..b7613cc3ae 100644 --- a/interface/src/scripting/SelectionScriptingInterface.cpp +++ b/interface/src/scripting/SelectionScriptingInterface.cpp @@ -247,35 +247,32 @@ QVariantMap SelectionScriptingInterface::getSelectedItemsList(const QString& lis QVariantMap list; auto currentList = _selectedItemsListMap.find(listName); if (currentList != _selectedItemsListMap.end()) { - if ((*currentList).getContainsData()) { + QList avatarIDs; + QList entityIDs; + QList overlayIDs; + if ((*currentList).getContainsData()) { if (!(*currentList).getAvatarIDs().empty()) { - QList avatarIDs; for (auto j : (*currentList).getAvatarIDs()) { avatarIDs.push_back((QUuid)j); } - list["avatars"] = (avatarIDs); } if (!(*currentList).getEntityIDs().empty()) { - QList entityIDs; for (auto j : (*currentList).getEntityIDs()) { entityIDs.push_back((QUuid)j ); } - list["entities"] = (entityIDs); } if (!(*currentList).getOverlayIDs().empty()) { - QList overlayIDs; for (auto j : (*currentList).getOverlayIDs()) { overlayIDs.push_back((QUuid)j); } - list["overlays"] = (overlayIDs); } + } + list["avatars"] = (avatarIDs); + list["entities"] = (entityIDs); + list["overlays"] = (overlayIDs); - return list; - } - else { - return list; - } + return list; } else { return list; From 4c1dea2b30f56a5454d2ffe95d1353923bb82398 Mon Sep 17 00:00:00 2001 From: samcake Date: Thu, 7 Dec 2017 17:54:14 -0800 Subject: [PATCH 21/29] Remove uneeded files --- .../render/highlightPage/HighlightPage.qml | 116 ------------------ .../utilities/render/highlightPage/qmldir | 1 - 2 files changed, 117 deletions(-) delete mode 100644 scripts/developer/utilities/render/highlightPage/HighlightPage.qml delete mode 100644 scripts/developer/utilities/render/highlightPage/qmldir diff --git a/scripts/developer/utilities/render/highlightPage/HighlightPage.qml b/scripts/developer/utilities/render/highlightPage/HighlightPage.qml deleted file mode 100644 index 5669f90628..0000000000 --- a/scripts/developer/utilities/render/highlightPage/HighlightPage.qml +++ /dev/null @@ -1,116 +0,0 @@ -// -// highlightPage.qml -// developer/utilities/render -// -// Olivier Prat, created on 08/08/2017. -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html -// -import QtQuick 2.7 -import QtQuick.Controls 1.4 -import QtQuick.Layouts 1.3 -import "../configSlider" -import "qrc:///qml/styles-uit" -import "qrc:///qml/controls-uit" as HifiControls - -Rectangle { - id: root - property var highlightIndex: 0 - property var drawConfig: Render.getConfig("RenderMainView.HighlightEffect"+highlightIndex) - - HifiConstants { id: hifi;} - anchors.margins: hifi.dimensions.contentMargin.x - - Column { - spacing: 5 - anchors.left: parent.left - anchors.right: parent.right - anchors.margins: hifi.dimensions.contentMargin.x - - HifiControls.CheckBox { - id: glow - text: "Glow" - checked: root.drawConfig["glow"] - onCheckedChanged: { - root.drawConfig["glow"] = checked; - } - } - Repeater { - model: ["Width:width:5.0:0.0", - "Intensity:intensity:1.0:0.0" - ] - ConfigSlider { - label: qsTr(modelData.split(":")[0]) - integral: false - config: root.drawConfig - property: modelData.split(":")[1] - max: modelData.split(":")[2] - min: modelData.split(":")[3] - - anchors.left: parent.left - anchors.right: parent.right - } - } - - GroupBox { - title: "Color" - anchors.left: parent.left - anchors.right: parent.right - Column { - spacing: 10 - anchors.left: parent.left - anchors.right: parent.right - anchors.margins: hifi.dimensions.contentMargin.x - - Repeater { - model: ["Red:colorR:1.0:0.0", - "Green:colorG:1.0:0.0", - "Blue:colorB:1.0:0.0" - ] - ConfigSlider { - label: qsTr(modelData.split(":")[0]) - integral: false - config: root.drawConfig - property: modelData.split(":")[1] - max: modelData.split(":")[2] - min: modelData.split(":")[3] - - anchors.left: parent.left - anchors.right: parent.right - } - } - } - } - - GroupBox { - title: "Fill Opacity" - anchors.left: parent.left - anchors.right: parent.right - Column { - spacing: 10 - anchors.left: parent.left - anchors.right: parent.right - anchors.margins: hifi.dimensions.contentMargin.x - - Repeater { - model: ["Unoccluded:unoccludedFillOpacity:1.0:0.0", - "Occluded:occludedFillOpacity:1.0:0.0" - ] - ConfigSlider { - label: qsTr(modelData.split(":")[0]) - integral: false - config: root.drawConfig - property: modelData.split(":")[1] - max: modelData.split(":")[2] - min: modelData.split(":")[3] - - anchors.left: parent.left - anchors.right: parent.right - } - } - } - } - } -} diff --git a/scripts/developer/utilities/render/highlightPage/qmldir b/scripts/developer/utilities/render/highlightPage/qmldir deleted file mode 100644 index bb3de24b84..0000000000 --- a/scripts/developer/utilities/render/highlightPage/qmldir +++ /dev/null @@ -1 +0,0 @@ -HighlightPage 1.0 HighlightPage.qml \ No newline at end of file From 013d2e808d8025bfac8df4e27fd714b64f29747c Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Fri, 8 Dec 2017 03:53:56 -0800 Subject: [PATCH 22/29] Adding the hovering from the mouse from the debugHighlight.js --- .../utilities/render/debugHighlight.js | 103 +++++++++++++++--- .../developer/utilities/render/highlight.qml | 28 +++-- 2 files changed, 107 insertions(+), 24 deletions(-) diff --git a/scripts/developer/utilities/render/debugHighlight.js b/scripts/developer/utilities/render/debugHighlight.js index b1a91abdd7..22fa54b9d2 100644 --- a/scripts/developer/utilities/render/debugHighlight.js +++ b/scripts/developer/utilities/render/debugHighlight.js @@ -66,24 +66,10 @@ button.editProperties({isActive: onLuciScreen}); wireEventBridge(onLuciScreen); } - - function fromQml(message) { - } - + button.clicked.connect(onClicked); tablet.screenChanged.connect(onScreenChanged); - var moveDebugCursor = false; - Controller.mousePressEvent.connect(function (e) { - if (e.isMiddleButton) { - moveDebugCursor = true; - setDebugCursor(e.x, e.y); - } - }); - Controller.mouseReleaseEvent.connect(function() { moveDebugCursor = false; }); - Controller.mouseMoveEvent.connect(function (e) { if (moveDebugCursor) setDebugCursor(e.x, e.y); }); - - Script.scriptEnding.connect(function () { if (onLuciScreen) { tablet.gotoHomeScreen(); @@ -92,10 +78,93 @@ tablet.screenChanged.disconnect(onScreenChanged); tablet.removeButton(button); }); - - function setDebugCursor(x, y) { + + // Create a Laser pointer used to pick and add objects to selections + var END_DIMENSIONS = { x: 0.05, y: 0.05, z: 0.05 }; + var COLOR1 = {red: 255, green: 0, blue: 0}; + var COLOR2 = {red: 0, green: 255, blue: 0}; + var end1 = { + type: "sphere", + dimensions: END_DIMENSIONS, + color: COLOR1, + ignoreRayIntersection: true } + var end2 = { + type: "sphere", + dimensions: END_DIMENSIONS, + color: COLOR2, + ignoreRayIntersection: true + } + var laser = Pointers.createPointer(PickType.Ray, { + joint: "Mouse", + filter: Picks.PICK_ENTITIES, + renderStates: [{name: "one", end: end1}], + defaultRenderStates: [{name: "one", end: end2, distance: 2.0}], + enabled: true + }); + Pointers.setRenderState(laser, "one"); + var HoveringList = "Hovering" + var hoveringStyle = { + isOutlineSmooth: true, + outlineWidth: 5, + outlineUnoccludedColor: {red: 255, green: 128, blue: 128}, + outlineUnoccludedIntensity: 0.88, + outlineOccludedColor: {red: 255, green: 128, blue: 128}, + outlineOccludedIntensity:0.5, + fillUnoccludedColor: {red: 26, green: 0, blue: 0}, + fillUnoccludedIntensity: 0.0, + fillOccludedColor: {red: 26, green: 0, blue: 0}, + fillOccludedIntensity: 0.0 + } + Selection.enableListHighlight(HoveringList, hoveringStyle) + + var currentSelectionName = "" + var isSelectionEnabled = false + Pointers.disablePointer(laser) + + function fromQml(message) { + tokens = message.split(' ') + print("Received '"+message+"' from hightlight.qml") + if (tokens[0]=="highlight") { + currentSelectionName = tokens[1]; + print("Switching to highlight name "+currentSelectionName) + } else if (tokens[0]=="pick") { + isSelectionEnabled = tokens[1]=='true' + print("Ray picking set to "+isSelectionEnabled.toString()) + if (isSelectionEnabled) { + Pointers.enablePointer(laser) + } else { + Pointers.disablePointer(laser) + Selection.clearSelectedItemsList(HoveringList) + } + time = 0 + } + } + + Entities.hoverEnterEntity.connect(function (id, event) { + // print("hoverEnterEntity"); + if (isSelectionEnabled) Selection.addToSelectedItemsList(HoveringList, "entity", id) + }) + + Entities.hoverOverEntity.connect(function (id, event) { + // print("hoverOverEntity"); + }) + + + Entities.hoverLeaveEntity.connect(function (id, event) { + if (isSelectionEnabled) Selection.removeFromSelectedItemsList(HoveringList, "entity", id) + // print("hoverLeaveEntity"); + }) + + function cleanup() { + Pointers.removePointer(ray); + Selection.disableListHighlight(HoveringList) + Selection.removeListFromMap(HoveringList) + + } + Script.scriptEnding.connect(cleanup); + }()); diff --git a/scripts/developer/utilities/render/highlight.qml b/scripts/developer/utilities/render/highlight.qml index fed42a76c6..a4e819937d 100644 --- a/scripts/developer/utilities/render/highlight.qml +++ b/scripts/developer/utilities/render/highlight.qml @@ -34,7 +34,9 @@ Item { } function resetSelectionView() { - selectionView.resetSelectionView(); + if (selectionView !== undefined) { + selectionView.resetSelectionView(); + } } Column { @@ -69,7 +71,7 @@ Item { id: styleSelectorLoader sourceComponent: selectorWidget width: 300 - anchors.right: parent.right + //anchors.right: parent.right } Component { id: selectorWidget @@ -112,6 +114,18 @@ Item { Separator {} + HifiControls.CheckBox { + text: "Highlight Hovered" + checked: false + onCheckedChanged: { + if (checked) { + root.sendToScript("pick true") + } else { + root.sendToScript("pick false") + } + } + } + Separator {} Rectangle { id: selectionView anchors.left: parent.left @@ -120,15 +134,15 @@ Item { color: hifi.colors.lightGray function resetSelectionView() { - // myModel.resetSelectionView(); - var entities = Selection.getSelectedItemsList(root.listName)["entities"] - //print("resetSelectionView" + JSON.stringify(entities)) myModel.clear() + var entities = Selection.getSelectedItemsList(root.listName)["entities"] + if (entities === undefined) { + return; + } var fLen = entities.length; for (var i = 0; i < fLen; i++) { myModel.append({ "objectID": JSON.stringify(entities[i]) }) - // print("resetSelectionView" + JSON.stringify( entities[i])) - } + } } ListModel { From eec4e966a75084d17cf684fda24a25f2246a7875 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Sun, 10 Dec 2017 10:13:49 -0800 Subject: [PATCH 23/29] Fix the linux build and correct the name of the property Intensity to Opacity --- .../scripting/SelectionScriptingInterface.cpp | 16 ++++++++-------- libraries/render/src/render/HighlightStyle.h | 2 ++ .../render/highlight/HighlightStyle.qml | 8 ++++---- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/interface/src/scripting/SelectionScriptingInterface.cpp b/interface/src/scripting/SelectionScriptingInterface.cpp index b7613cc3ae..a02d2c75f3 100644 --- a/interface/src/scripting/SelectionScriptingInterface.cpp +++ b/interface/src/scripting/SelectionScriptingInterface.cpp @@ -410,19 +410,19 @@ bool SelectionHighlightStyle::fromVariantMap(const QVariantMap& properties) { } } - auto intensityVariant = properties["outlineUnoccludedIntensity"]; + auto intensityVariant = properties["outlineUnoccludedOpacity"]; if (intensityVariant.isValid()) { _style._outlineUnoccluded.alpha = intensityVariant.toFloat(); } - intensityVariant = properties["outlineOccludedIntensity"]; + intensityVariant = properties["outlineOccludedOpacity"]; if (intensityVariant.isValid()) { _style._outlineOccluded.alpha = intensityVariant.toFloat(); } - intensityVariant = properties["fillUnoccludedIntensity"]; + intensityVariant = properties["fillUnoccludedOpacity"]; if (intensityVariant.isValid()) { _style._fillUnoccluded.alpha = intensityVariant.toFloat(); } - intensityVariant = properties["fillOccludedIntensity"]; + intensityVariant = properties["fillOccludedOpacity"]; if (intensityVariant.isValid()) { _style._fillOccluded.alpha = intensityVariant.toFloat(); } @@ -447,10 +447,10 @@ QVariantMap SelectionHighlightStyle::toVariantMap() const { properties["fillUnoccludedColor"] = xColorToVariant(xColorFromGlm(_style._fillUnoccluded.color)); properties["fillOccludedColor"] = xColorToVariant(xColorFromGlm(_style._fillOccluded.color)); - properties["outlineUnoccludedIntensity"] = _style._outlineUnoccluded.alpha; - properties["outlineOccludedIntensity"] = _style._outlineOccluded.alpha; - properties["fillUnoccludedIntensity"] = _style._fillUnoccluded.alpha; - properties["fillOccludedIntensity"] = _style._fillOccluded.alpha; + properties["outlineUnoccludedOpacity"] = _style._outlineUnoccluded.alpha; + properties["outlineOccludedOpacity"] = _style._outlineOccluded.alpha; + properties["fillUnoccludedOpacity"] = _style._fillUnoccluded.alpha; + properties["fillOccludedOpacity"] = _style._fillOccluded.alpha; properties["outlineWidth"] = _style._outlineWidth; properties["isOutlineSmooth"] = _style._isOutlineSmooth; diff --git a/libraries/render/src/render/HighlightStyle.h b/libraries/render/src/render/HighlightStyle.h index 981b43429a..4e6d43f911 100644 --- a/libraries/render/src/render/HighlightStyle.h +++ b/libraries/render/src/render/HighlightStyle.h @@ -23,6 +23,8 @@ namespace render { struct RGBA { glm::vec3 color{ 1.f, 0.7f, 0.2f }; float alpha{ 0.9f }; + + RGBA(const glm::vec3& c, float a) : color(c), alpha(a) {} }; RGBA _outlineUnoccluded{ { 1.f, 0.7f, 0.2f }, 0.9f }; diff --git a/scripts/developer/utilities/render/highlight/HighlightStyle.qml b/scripts/developer/utilities/render/highlight/HighlightStyle.qml index 189ac10b42..456c9bd7b6 100644 --- a/scripts/developer/utilities/render/highlight/HighlightStyle.qml +++ b/scripts/developer/utilities/render/highlight/HighlightStyle.qml @@ -64,10 +64,10 @@ Item { Repeater { model: [ - "Outline Unoccluded:outlineUnoccludedColor:outlineUnoccludedIntensity", - "Outline Occluded:outlineOccludedColor:outlineOccludedIntensity", - "Fill Unoccluded:fillUnoccludedColor:fillUnoccludedIntensity", - "Fill Occluded:fillOccludedColor:fillOccludedIntensity"] + "Outline Unoccluded:outlineUnoccludedColor:outlineUnoccludedOpacity", + "Outline Occluded:outlineOccludedColor:outlineOccludedOpacity", + "Fill Unoccluded:fillUnoccludedColor:fillUnoccludedOpacity", + "Fill Occluded:fillOccludedColor:fillOccludedOpacity"] Column { anchors.left: parent.left anchors.right: parent.right From bb888f2d4ce7cc6d7f271d48fb562851013602cd Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Sun, 10 Dec 2017 23:07:06 -0800 Subject: [PATCH 24/29] Replace the name opacity for alpha --- .../scripting/SelectionScriptingInterface.cpp | 16 ++++++++-------- .../src/scripting/SelectionScriptingInterface.h | 8 ++++---- .../developer/utilities/render/debugHighlight.js | 8 ++++---- .../render/highlight/HighlightStyle.qml | 8 ++++---- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/interface/src/scripting/SelectionScriptingInterface.cpp b/interface/src/scripting/SelectionScriptingInterface.cpp index a02d2c75f3..f534894145 100644 --- a/interface/src/scripting/SelectionScriptingInterface.cpp +++ b/interface/src/scripting/SelectionScriptingInterface.cpp @@ -410,19 +410,19 @@ bool SelectionHighlightStyle::fromVariantMap(const QVariantMap& properties) { } } - auto intensityVariant = properties["outlineUnoccludedOpacity"]; + auto intensityVariant = properties["outlineUnoccludedAlpha"]; if (intensityVariant.isValid()) { _style._outlineUnoccluded.alpha = intensityVariant.toFloat(); } - intensityVariant = properties["outlineOccludedOpacity"]; + intensityVariant = properties["outlineOccludedAlpha"]; if (intensityVariant.isValid()) { _style._outlineOccluded.alpha = intensityVariant.toFloat(); } - intensityVariant = properties["fillUnoccludedOpacity"]; + intensityVariant = properties["fillUnoccludedAlpha"]; if (intensityVariant.isValid()) { _style._fillUnoccluded.alpha = intensityVariant.toFloat(); } - intensityVariant = properties["fillOccludedOpacity"]; + intensityVariant = properties["fillOccludedAlpha"]; if (intensityVariant.isValid()) { _style._fillOccluded.alpha = intensityVariant.toFloat(); } @@ -447,10 +447,10 @@ QVariantMap SelectionHighlightStyle::toVariantMap() const { properties["fillUnoccludedColor"] = xColorToVariant(xColorFromGlm(_style._fillUnoccluded.color)); properties["fillOccludedColor"] = xColorToVariant(xColorFromGlm(_style._fillOccluded.color)); - properties["outlineUnoccludedOpacity"] = _style._outlineUnoccluded.alpha; - properties["outlineOccludedOpacity"] = _style._outlineOccluded.alpha; - properties["fillUnoccludedOpacity"] = _style._fillUnoccluded.alpha; - properties["fillOccludedOpacity"] = _style._fillOccluded.alpha; + properties["outlineUnoccludedAlpha"] = _style._outlineUnoccluded.alpha; + properties["outlineOccludedAlpha"] = _style._outlineOccluded.alpha; + properties["fillUnoccludedAlpha"] = _style._fillUnoccluded.alpha; + properties["fillOccludedAlpha"] = _style._fillOccluded.alpha; properties["outlineWidth"] = _style._outlineWidth; properties["isOutlineSmooth"] = _style._isOutlineSmooth; diff --git a/interface/src/scripting/SelectionScriptingInterface.h b/interface/src/scripting/SelectionScriptingInterface.h index 5c2bf2789f..8295375870 100644 --- a/interface/src/scripting/SelectionScriptingInterface.h +++ b/interface/src/scripting/SelectionScriptingInterface.h @@ -185,10 +185,10 @@ public: * - fillUnoccludedColor: {xColor} " * - fillOccludedColor: {xColor} " * - * - outlineUnoccludedOpacity: {float} Opacity value ranging from 0.0 (not visible) to 1.0 (fully opaque) for the specified highlight region - * - outlineOccludedOpacity: {float} " - * - fillUnoccludedOpacity: {float} " - * - fillOccludedOpacity: {float} " + * - outlineUnoccludedAlpha: {float} Alpha value ranging from 0.0 (not visible) to 1.0 (fully opaque) for the specified highlight region + * - outlineOccludedAlpha: {float} " + * - fillUnoccludedAlpha: {float} " + * - fillOccludedAlpha: {float} " * * - outlineWidth: {float} width of the outline expressed in pixels * - isOutlineSmooth: {bool} true to enable oultine smooth falloff diff --git a/scripts/developer/utilities/render/debugHighlight.js b/scripts/developer/utilities/render/debugHighlight.js index 22fa54b9d2..e70565cec2 100644 --- a/scripts/developer/utilities/render/debugHighlight.js +++ b/scripts/developer/utilities/render/debugHighlight.js @@ -109,13 +109,13 @@ isOutlineSmooth: true, outlineWidth: 5, outlineUnoccludedColor: {red: 255, green: 128, blue: 128}, - outlineUnoccludedIntensity: 0.88, + outlineUnoccludedAlpha: 0.88, outlineOccludedColor: {red: 255, green: 128, blue: 128}, - outlineOccludedIntensity:0.5, + outlineOccludedAlpha:0.5, fillUnoccludedColor: {red: 26, green: 0, blue: 0}, - fillUnoccludedIntensity: 0.0, + fillUnoccludedAlpha: 0.0, fillOccludedColor: {red: 26, green: 0, blue: 0}, - fillOccludedIntensity: 0.0 + fillOccludedAlpha: 0.0 } Selection.enableListHighlight(HoveringList, hoveringStyle) diff --git a/scripts/developer/utilities/render/highlight/HighlightStyle.qml b/scripts/developer/utilities/render/highlight/HighlightStyle.qml index 456c9bd7b6..371b7e81f7 100644 --- a/scripts/developer/utilities/render/highlight/HighlightStyle.qml +++ b/scripts/developer/utilities/render/highlight/HighlightStyle.qml @@ -64,10 +64,10 @@ Item { Repeater { model: [ - "Outline Unoccluded:outlineUnoccludedColor:outlineUnoccludedOpacity", - "Outline Occluded:outlineOccludedColor:outlineOccludedOpacity", - "Fill Unoccluded:fillUnoccludedColor:fillUnoccludedOpacity", - "Fill Occluded:fillOccludedColor:fillOccludedOpacity"] + "Outline Unoccluded:outlineUnoccludedColor:outlineUnoccludedAlpha", + "Outline Occluded:outlineOccludedColor:outlineOccludedAlpha", + "Fill Unoccluded:fillUnoccludedColor:fillUnoccludedAlpha", + "Fill Occluded:fillOccludedColor:fillOccludedAlpha"] Column { anchors.left: parent.left anchors.right: parent.right From cc4b2666478a9c63f6793efa1f2137cb1150132a Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Mon, 11 Dec 2017 00:31:54 -0800 Subject: [PATCH 25/29] Add names to objects of the selection, remove comments in shader and fix one more warning on linux --- .../scripting/SelectionScriptingInterface.cpp | 2 +- libraries/render-utils/src/Highlight.slh | 2 -- .../developer/utilities/render/highlight.qml | 27 ++++++++++++++----- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/interface/src/scripting/SelectionScriptingInterface.cpp b/interface/src/scripting/SelectionScriptingInterface.cpp index f534894145..233e61c8ae 100644 --- a/interface/src/scripting/SelectionScriptingInterface.cpp +++ b/interface/src/scripting/SelectionScriptingInterface.cpp @@ -283,7 +283,7 @@ bool SelectionScriptingInterface::removeListFromMap(const QString& listName) { bool removed = false; { QWriteLocker lock(&_selectionListsLock); - bool removed = _selectedItemsListMap.remove(listName); + removed = _selectedItemsListMap.remove(listName); } if (removed) { onSelectedItemsListChanged(listName); diff --git a/libraries/render-utils/src/Highlight.slh b/libraries/render-utils/src/Highlight.slh index 207276014c..e42ac6833c 100644 --- a/libraries/render-utils/src/Highlight.slh +++ b/libraries/render-utils/src/Highlight.slh @@ -78,9 +78,7 @@ void main(void) { { outlinedDepth = texture(highlightedDepthMap, uv).x; float touch = (outlinedDepth < FAR_Z) ? 1.0 : 0.0; - //sumOutlineDepth = min(outlinedDepth, sumOutlineDepth); sumOutlineDepth = max(outlinedDepth * touch, sumOutlineDepth); - // sumOutlineDepth += (outlinedDepth * touch); intensity += touch; weight += 1.f; } diff --git a/scripts/developer/utilities/render/highlight.qml b/scripts/developer/utilities/render/highlight.qml index a4e819937d..88d6a807ae 100644 --- a/scripts/developer/utilities/render/highlight.qml +++ b/scripts/developer/utilities/render/highlight.qml @@ -136,13 +136,26 @@ Item { function resetSelectionView() { myModel.clear() var entities = Selection.getSelectedItemsList(root.listName)["entities"] - if (entities === undefined) { - return; + if (entities !== undefined) { + myModel.append({ "objectID": "Entities" }) + for (var i = 0; i < entities.length; i++) { + myModel.append({ "objectID": JSON.stringify(entities[i]) }) + } + } + var overlays = Selection.getSelectedItemsList(root.listName)["overlays"] + if (overlays !== undefined) { + myModel.append({ "objectID": "Overlays" }) + for (var i = 0; i < overlays.length; i++) { + myModel.append({ "objectID": JSON.stringify(overlays[i]) }) + } + } + var avatars = Selection.getSelectedItemsList(root.listName)["avatars"] + if (avatars !== undefined) { + myModel.append({ "objectID": "Avatars" }) + for (var i = 0; i < avatars.length; i++) { + myModel.append({ "objectID": JSON.stringify(avatars[i]) }) + } } - var fLen = entities.length; - for (var i = 0; i < fLen; i++) { - myModel.append({ "objectID": JSON.stringify(entities[i]) }) - } } ListModel { @@ -153,7 +166,7 @@ Item { id: myDelegate Row { id: fruit - Text { text: JSON.stringify(objectID) } + Text { text: objectID } } } From d1cd9f5c6b1661e63c719b71263c4ab719492762 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Mon, 11 Dec 2017 02:21:09 -0800 Subject: [PATCH 26/29] adding correct support for the meta item fetch subItems for Overlays and specifically for ModelOverlay which fixes the highlight on Overlays --- interface/src/ui/overlays/Base3DOverlay.h | 2 ++ interface/src/ui/overlays/ModelOverlay.cpp | 26 +++++++++++++++++++ interface/src/ui/overlays/ModelOverlay.h | 8 ++++++ interface/src/ui/overlays/Overlay.h | 3 +++ interface/src/ui/overlays/Overlay2D.h | 2 ++ interface/src/ui/overlays/OverlaysPayload.cpp | 6 +++++ 6 files changed, 47 insertions(+) diff --git a/interface/src/ui/overlays/Base3DOverlay.h b/interface/src/ui/overlays/Base3DOverlay.h index 556399c741..6323ff9dc8 100644 --- a/interface/src/ui/overlays/Base3DOverlay.h +++ b/interface/src/ui/overlays/Base3DOverlay.h @@ -35,6 +35,8 @@ public: // getters virtual bool is3D() const override { return true; } + virtual uint32_t fetchMetaSubItems(render::ItemIDs& subItems) const override { subItems.push_back(getRenderItemID()); return (uint32_t) subItems.size(); } + // TODO: consider implementing registration points in this class glm::vec3 getCenter() const { return getWorldPosition(); } diff --git a/interface/src/ui/overlays/ModelOverlay.cpp b/interface/src/ui/overlays/ModelOverlay.cpp index f27e26280a..0846599728 100644 --- a/interface/src/ui/overlays/ModelOverlay.cpp +++ b/interface/src/ui/overlays/ModelOverlay.cpp @@ -79,6 +79,12 @@ void ModelOverlay::update(float deltatime) { if (_model->needsFixupInScene()) { _model->removeFromScene(scene, transaction); _model->addToScene(scene, transaction); + + auto newRenderItemIDs{ _model->fetchRenderItemIDs() }; + transaction.updateItem(getRenderItemID(), [newRenderItemIDs](Overlay& data) { + auto modelOverlay = static_cast(&data); + modelOverlay->setSubRenderItemIDs(newRenderItemIDs); + }); } if (_visibleDirty) { _visibleDirty = false; @@ -104,6 +110,10 @@ bool ModelOverlay::addToScene(Overlay::Pointer overlay, const render::ScenePoint void ModelOverlay::removeFromScene(Overlay::Pointer overlay, const render::ScenePointer& scene, render::Transaction& transaction) { Volume3DOverlay::removeFromScene(overlay, scene, transaction); _model->removeFromScene(scene, transaction); + transaction.updateItem(getRenderItemID(), [](Overlay& data) { + auto modelOverlay = static_cast(&data); + modelOverlay->clearSubRenderItemIDs(); + }); } void ModelOverlay::setVisible(bool visible) { @@ -529,3 +539,19 @@ void ModelOverlay::copyAnimationJointDataToModel(QVector jointsData) _updateModel = true; } +void ModelOverlay::clearSubRenderItemIDs() { + _subRenderItemIDs.clear(); +} + +void ModelOverlay::setSubRenderItemIDs(const render::ItemIDs& ids) { + _subRenderItemIDs = ids; +} + +uint32_t ModelOverlay::fetchMetaSubItems(render::ItemIDs& subItems) const { + if (_model) { + auto metaSubItems = _subRenderItemIDs; + subItems.insert(subItems.end(), metaSubItems.begin(), metaSubItems.end()); + return (uint32_t)metaSubItems.size(); + } + return 0; +} diff --git a/interface/src/ui/overlays/ModelOverlay.h b/interface/src/ui/overlays/ModelOverlay.h index c4506d9621..4f7f1e0cae 100644 --- a/interface/src/ui/overlays/ModelOverlay.h +++ b/interface/src/ui/overlays/ModelOverlay.h @@ -30,6 +30,12 @@ public: virtual void update(float deltatime) override; virtual void render(RenderArgs* args) override {}; + + virtual uint32_t fetchMetaSubItems(render::ItemIDs& subItems) const override; + + void clearSubRenderItemIDs(); + void setSubRenderItemIDs(const render::ItemIDs& ids); + void setProperties(const QVariantMap& properties) override; QVariant getProperty(const QString& property) override; virtual bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance, @@ -74,6 +80,8 @@ private: ModelPointer _model; QVariantMap _modelTextures; + render::ItemIDs _subRenderItemIDs; + QUrl _url; bool _updateModel { false }; bool _scaleToFit { false }; diff --git a/interface/src/ui/overlays/Overlay.h b/interface/src/ui/overlays/Overlay.h index 39208f01a0..806fc1aa14 100644 --- a/interface/src/ui/overlays/Overlay.h +++ b/interface/src/ui/overlays/Overlay.h @@ -53,6 +53,8 @@ public: virtual const render::ShapeKey getShapeKey() { return render::ShapeKey::Builder::ownPipeline(); } + virtual uint32_t fetchMetaSubItems(render::ItemIDs& subItems) const { return 0; } + // getters virtual QString getType() const = 0; virtual bool is3D() const = 0; @@ -130,6 +132,7 @@ namespace render { template <> int payloadGetLayer(const Overlay::Pointer& overlay); template <> void payloadRender(const Overlay::Pointer& overlay, RenderArgs* args); template <> const ShapeKey shapeGetShapeKey(const Overlay::Pointer& overlay); + template <> uint32_t metaFetchMetaSubItems(const Overlay::Pointer& overlay, ItemIDs& subItems); } Q_DECLARE_METATYPE(OverlayID); diff --git a/interface/src/ui/overlays/Overlay2D.h b/interface/src/ui/overlays/Overlay2D.h index a1efe8a6de..3175df92f1 100644 --- a/interface/src/ui/overlays/Overlay2D.h +++ b/interface/src/ui/overlays/Overlay2D.h @@ -26,6 +26,8 @@ public: virtual bool is3D() const override { return false; } + virtual uint32_t fetchMetaSubItems(render::ItemIDs& subItems) const override { subItems.push_back(getRenderItemID()); return 1; } + // getters int getX() const { return _bounds.x(); } int getY() const { return _bounds.y(); } diff --git a/interface/src/ui/overlays/OverlaysPayload.cpp b/interface/src/ui/overlays/OverlaysPayload.cpp index 8d3e514a0f..fceb261503 100644 --- a/interface/src/ui/overlays/OverlaysPayload.cpp +++ b/interface/src/ui/overlays/OverlaysPayload.cpp @@ -87,4 +87,10 @@ namespace render { template <> const ShapeKey shapeGetShapeKey(const Overlay::Pointer& overlay) { return overlay->getShapeKey(); } + + + template <> uint32_t metaFetchMetaSubItems(const Overlay::Pointer& overlay, ItemIDs& subItems) { + return overlay->fetchMetaSubItems(subItems); + } } + From b4f74330424d871234c2097738127e40dec8ac33 Mon Sep 17 00:00:00 2001 From: samcake Date: Mon, 11 Dec 2017 09:26:43 -0800 Subject: [PATCH 27/29] removing .f for a float in shader --- libraries/render-utils/src/Highlight.slh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/render-utils/src/Highlight.slh b/libraries/render-utils/src/Highlight.slh index e42ac6833c..f4d4ad0e04 100644 --- a/libraries/render-utils/src/Highlight.slh +++ b/libraries/render-utils/src/Highlight.slh @@ -80,7 +80,7 @@ void main(void) { float touch = (outlinedDepth < FAR_Z) ? 1.0 : 0.0; sumOutlineDepth = max(outlinedDepth * touch, sumOutlineDepth); intensity += touch; - weight += 1.f; + weight += 1.0; } uv.x += deltaUv.x; } From 1008175a923da1e03ec554c127797c2732b08733 Mon Sep 17 00:00:00 2001 From: samcake Date: Mon, 11 Dec 2017 09:28:33 -0800 Subject: [PATCH 28/29] Removing commented code --- libraries/render-utils/src/HighlightEffect.cpp | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/libraries/render-utils/src/HighlightEffect.cpp b/libraries/render-utils/src/HighlightEffect.cpp index d1fcab67b6..fee1f4a568 100644 --- a/libraries/render-utils/src/HighlightEffect.cpp +++ b/libraries/render-utils/src/HighlightEffect.cpp @@ -454,23 +454,6 @@ void SelectionToHighlight::run(const render::RenderContextPointer& renderContext } } } - /* - for (auto i = 0; i < HighlightSharedParameters::MAX_PASS_COUNT; i++) { - std::ostringstream stream; - if (i > 0) { - stream << "highlightList" << i; - } else { - stream << "contextOverlayHighlightList"; - } - auto selectionName = stream.str(); - if (!scene->isSelectionEmpty(selectionName)) { - auto highlightId = highlightStage->getHighlightIdBySelection(selectionName); - if (!render::HighlightStage::isIndexInvalid(highlightId)) { - _sharedParameters->_highlightIds[outputs.size()] = highlightId; - outputs.emplace_back(selectionName); - } - } - }*/ } void ExtractSelectionName::run(const render::RenderContextPointer& renderContext, const Inputs& inputs, Outputs& outputs) { From 63fb9b5503ff38e3ed4fcdd06a0080bf181a27e0 Mon Sep 17 00:00:00 2001 From: samcake Date: Mon, 11 Dec 2017 09:30:31 -0800 Subject: [PATCH 29/29] fix float literal syntax --- libraries/render/src/render/HighlightStyle.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/render/src/render/HighlightStyle.h b/libraries/render/src/render/HighlightStyle.h index 4e6d43f911..8bef5c33c3 100644 --- a/libraries/render/src/render/HighlightStyle.h +++ b/libraries/render/src/render/HighlightStyle.h @@ -21,14 +21,14 @@ namespace render { class HighlightStyle { public: struct RGBA { - glm::vec3 color{ 1.f, 0.7f, 0.2f }; + glm::vec3 color{ 1.0f, 0.7f, 0.2f }; float alpha{ 0.9f }; RGBA(const glm::vec3& c, float a) : color(c), alpha(a) {} }; - RGBA _outlineUnoccluded{ { 1.f, 0.7f, 0.2f }, 0.9f }; - RGBA _outlineOccluded{ { 1.f, 0.7f, 0.2f }, 0.9f }; + RGBA _outlineUnoccluded{ { 1.0f, 0.7f, 0.2f }, 0.9f }; + RGBA _outlineOccluded{ { 1.0f, 0.7f, 0.2f }, 0.9f }; RGBA _fillUnoccluded{ { 0.2f, 0.7f, 1.0f }, 0.0f }; RGBA _fillOccluded{ { 0.2f, 0.7f, 1.0f }, 0.0f };