Skip to content
Snippets Groups Projects
Commit afdc8632 authored by Maximilian Giller's avatar Maximilian Giller
Browse files

First working implementation of box select

parent 1a970d2a
Branches
Tags
No related merge requests found
Pipeline #51984 passed
......@@ -169,6 +169,34 @@ export default class CollectTool extends Tool {
bottom = e.offsetY;
}
this.boxSelect.remove();
this.onBoxSelect(left, bottom, top, right);
// this.onBoxSelect(left, bottom, top, right);
const tl = renderer.screen2GraphCoords(left, top);
const br = renderer.screen2GraphCoords(right, bottom);
const hitNodes = [];
graph.data[Graph.GRAPH_NODES].forEach((node) => {
if (
tl.x < node.x &&
node.x < br.x &&
br.y > node.y &&
node.y > tl.y
) {
hitNodes.push(node);
}
});
// run code to select your nodes here
// return selectGraphObjects(hitNodes);
console.log(hitNodes);
if (state.itemsContext !== CONTEXT.node) {
state.clearSelectedItems();
state.itemsContext = CONTEXT.node;
}
state.addSelectedItems(hitNodes);
// TODO Should be shown in menu
// this.menu.value(COLLECTION_KEY, state.selectedItems);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment