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
No related branches found
No related tags found
No related merge requests found
Pipeline #51984 passed
...@@ -169,6 +169,34 @@ export default class CollectTool extends Tool { ...@@ -169,6 +169,34 @@ export default class CollectTool extends Tool {
bottom = e.offsetY; bottom = e.offsetY;
} }
this.boxSelect.remove(); 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.
Finish editing this message first!
Please register or to comment