From afdc8632422f900a6ad6dad2fc4c9e1633efb41e Mon Sep 17 00:00:00 2001 From: mgfcf <m.giller@tu-braunschweig.de> Date: Thu, 16 Dec 2021 09:08:22 +0100 Subject: [PATCH] First working implementation of box select --- editor/js/tools/collecttool.js | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/editor/js/tools/collecttool.js b/editor/js/tools/collecttool.js index 3ff246f..c39c87f 100644 --- a/editor/js/tools/collecttool.js +++ b/editor/js/tools/collecttool.js @@ -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); } } -- GitLab