From 445bce29d4f95fb6d4a8e3986ee0f975c83b85f9 Mon Sep 17 00:00:00 2001 From: Stanislav Mishchenko Date: Sat, 25 May 2024 13:46:44 +0300 Subject: [PATCH] fix selection order bug --- .../solve/rendering/canvas/SceneCanvas.kt | 65 +++++++++++-------- 1 file changed, 38 insertions(+), 27 deletions(-) diff --git a/src/main/kotlin/solve/rendering/canvas/SceneCanvas.kt b/src/main/kotlin/solve/rendering/canvas/SceneCanvas.kt index 74e7ae4f..07f7c82a 100644 --- a/src/main/kotlin/solve/rendering/canvas/SceneCanvas.kt +++ b/src/main/kotlin/solve/rendering/canvas/SceneCanvas.kt @@ -209,39 +209,50 @@ class SceneCanvas : OpenGLCanvas() { var clickedLandmarkLayerState: LayerState? = null var clickedLandmarkUID = 0L - interactingVisualizationFrame.layers.forEach { layer -> - if (!layer.settings.enabled) { - return@forEach - } - - when (layer) { - is Layer.PointLayer -> { - val clickedLandmark = getClickedPointLandmark(layer, frameInteractionPixel) ?: return@forEach - clickedLandmarkLayerState = clickedLandmark.layerState - clickedLandmarkUID = clickedLandmark.uid - } - is Layer.LineLayer -> { - val clickedLandmark = getClickedLineLandmark(layer, frameInteractionPixel) ?: return@forEach - clickedLandmarkLayerState = clickedLandmark.layerState - clickedLandmarkUID = clickedLandmark.uid + run clickHandler@{ + interactingVisualizationFrame.layers.forEach { layer -> + if (!layer.settings.enabled) { + return@forEach } - is Layer.PlanesLayer -> { - clickedLandmarkUID = - getClickedPlaneUID(layer, frameInteractionPixel, true) ?: return@forEach - clickedLandmarkLayerState = layer.layerState + + when (layer) { + is Layer.PointLayer -> { + val clickedLandmark = getClickedPointLandmark(layer, frameInteractionPixel) ?: return@forEach + clickedLandmarkLayerState = clickedLandmark.layerState + clickedLandmarkUID = clickedLandmark.uid + return@clickHandler + } + + is Layer.LineLayer -> { + val clickedLandmark = getClickedLineLandmark(layer, frameInteractionPixel) ?: return@forEach + clickedLandmarkLayerState = clickedLandmark.layerState + clickedLandmarkUID = clickedLandmark.uid + return@clickHandler + } + + is Layer.PlanesLayer -> { + clickedLandmarkUID = + getClickedPlaneUID(layer, frameInteractionPixel, true) ?: return@forEach + clickedLandmarkLayerState = layer.layerState + return@clickHandler + } } } } if (clickedLandmarkLayerState == null) { - interactingVisualizationFrame.layers.filterIsInstance().asReversed().forEach { layer -> - if (!layer.settings.enabled) { - return@forEach - } - - clickedLandmarkUID = - getClickedPlaneUID(layer, frameInteractionPixel, false) ?: return@forEach - clickedLandmarkLayerState = layer.layerState + run clickHandler@{ + interactingVisualizationFrame.layers.filterIsInstance().asReversed() + .forEach { layer -> + if (!layer.settings.enabled) { + return@forEach + } + + clickedLandmarkUID = + getClickedPlaneUID(layer, frameInteractionPixel, false) ?: return@forEach + clickedLandmarkLayerState = layer.layerState + return@clickHandler + } } }