Skip to content

Commit

Permalink
try at robust subplot-to-subplot selections
Browse files Browse the repository at this point in the history
- clear selection outlines when mousing down on different subplot
  than last selection
- do not try to merge selection polygons from different subplots
- rm (now obsolete) splom-only clearSelect calls from cartesian/select.js
  • Loading branch information
etpinard committed Apr 11, 2018
1 parent 9aea0ba commit 71a0395
Showing 1 changed file with 17 additions and 26 deletions.
43 changes: 17 additions & 26 deletions src/plots/cartesian/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,35 +53,28 @@ function prepSelect(e, startX, startY, dragOptions, mode) {
var filterPoly, testPoly, mergedPolygons, currentPolygon;
var i, cd, trace, searchInfo, eventData;

// take over selection polygons from prev mode, if any
if((e.shiftKey || e.altKey) && (plotinfo.selection && plotinfo.selection.polygons) && !dragOptions.polygons) {
dragOptions.polygons = plotinfo.selection.polygons;
dragOptions.mergedPolygons = plotinfo.selection.mergedPolygons;
}
// create new polygons, if shift mode
else if((!e.shiftKey && !e.altKey) || ((e.shiftKey || e.altKey) && !plotinfo.selection)) {
plotinfo.selection = {};
plotinfo.selection.polygons = dragOptions.polygons = [];
plotinfo.selection.mergedPolygons = dragOptions.mergedPolygons = [];
if(fullLayout._lastSelectedSubplot && fullLayout._lastSelectedSubplot === plotinfo.id) {
// take over selection polygons from prev mode, if any
if((e.shiftKey || e.altKey) && (plotinfo.selection && plotinfo.selection.polygons) && !dragOptions.polygons) {
dragOptions.polygons = plotinfo.selection.polygons;
dragOptions.mergedPolygons = plotinfo.selection.mergedPolygons;
}
// create new polygons, if shift mode
else if((!e.shiftKey && !e.altKey) || ((e.shiftKey || e.altKey) && !plotinfo.selection)) {
plotinfo.selection = {};
plotinfo.selection.polygons = dragOptions.polygons = [];
plotinfo.selection.mergedPolygons = dragOptions.mergedPolygons = [];
}
} else {
// do not allow multi-selection across different subplots
clearSelect(zoomLayer);
fullLayout._lastSelectedSubplot = plotinfo.id;
}

if(mode === 'lasso') {
filterPoly = filteredPolygon([[x0, y0]], constants.BENDPX);
}

// FIXME: find a better way to clear selection outlines for splom
if(!e.shiftKey && !e.altKey) {
for(i = 0; i < gd.calcdata.length; i++) {
cd = gd.calcdata[i];
trace = cd[0].trace;

if(trace.type === 'splom') {
zoomLayer.selectAll('.select-outline').remove();
break;
}
}
}

var outlines = zoomLayer.selectAll('path.select-outline-' + plotinfo.id).data([1, 2]);

outlines.enter()
Expand Down Expand Up @@ -365,11 +358,9 @@ function updateSelectedState(gd, searchTraces, eventData) {
delete trace.selectedpoints;
delete trace._input.selectedpoints;
}

// FIXME: make sure there is no better way to clear selection for sploms
gd._fullLayout._zoomlayer.selectAll('.select-outline').remove();
}

// group searchInfo traces by trace modules
var lookup = {};

for(i = 0; i < searchTraces.length; i++) {
Expand Down

0 comments on commit 71a0395

Please sign in to comment.