From b5076faee3873aeb8feedc6f6e0c6e36cff31242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoshiki=20V=C3=A1zquez=20Baeza?= Date: Wed, 16 Sep 2020 12:49:47 -0700 Subject: [PATCH] ENH: Link emperor double-click event and add timer cancelation (#370) * ENH: Link emperor double-click event and add timer cancelation Fixes #197 * BUG: Fix issue with biplot and emissive selection Thanks @fedarko * STY: Make it prettier --- .../support_files/js/node-click-callback.js | 38 +++++++++++++++++++ .../support_files/js/selection-callback.js | 7 +++- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/empress/support_files/js/node-click-callback.js b/empress/support_files/js/node-click-callback.js index 6a2462d15..d525aea0e 100644 --- a/empress/support_files/js/node-click-callback.js +++ b/empress/support_files/js/node-click-callback.js @@ -22,3 +22,41 @@ ec.sceneViews[0].on("click", function (name, object) { empress.showNodeMenuForName(name); }); + +ec.controllers.color.addEventListener("value-double-clicked", function ( + payload +) { + // when dealing with a biplot ignore arrow-emitted events + if (payload.target.decompositionName() !== "scatter") { + return; + } + + // cancel any ongoing timers + clearTimeout(empress.timer); + + // reset emissive settings for all markers since an ongoing timer may have + // been cancelled + ec.decViews.scatter.setEmissive(0x000000); + plotView.needsUpdate = true; + + // if there's any coloring setup remove it, and re-enable the update button + sPanel.sUpdateBtn.classList.remove("hidden"); + sPanel.fUpdateBtn.classList.remove("hidden"); + legend.clear(); + empress.resetTree(); + + var names = _.map(payload.message.group, function (item) { + return item.name; + }); + var container = {}; + container[payload.message.attribute] = names; + empress.colorSampleGroups(container); + + // 4 seconds before resetting + empress.timer = setTimeout(function () { + empress.resetTree(); + empress.drawTree(); + + plotView.needsUpdate = true; + }, 4000); +}); diff --git a/empress/support_files/js/selection-callback.js b/empress/support_files/js/selection-callback.js index 331c76e2d..ac7af94d9 100644 --- a/empress/support_files/js/selection-callback.js +++ b/empress/support_files/js/selection-callback.js @@ -4,6 +4,9 @@ * */ +// cancel any ongoing timers +clearTimeout(empress.timer); + // if there's any coloring setup remove it, and re-enable the update button sPanel.sUpdateBtn.classList.remove("hidden"); sPanel.fUpdateBtn.classList.remove("hidden"); @@ -22,8 +25,8 @@ for (var key in groups) { } empress.colorSampleGroups(namesOnly); -// 3 seconds before resetting -setTimeout(function () { +// 4 seconds before resetting +empress.timer = setTimeout(function () { empress.resetTree(); empress.drawTree();