Skip to content

Commit

Permalink
ENH: Link emperor double-click event and add timer cancelation (#370)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ElDeveloper authored Sep 16, 2020
1 parent 5d19f0d commit b5076fa
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
38 changes: 38 additions & 0 deletions empress/support_files/js/node-click-callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
7 changes: 5 additions & 2 deletions empress/support_files/js/selection-callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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();

Expand Down

0 comments on commit b5076fa

Please sign in to comment.