From eceda165409c4b35d5a36a19f4a51091c1d46b4d Mon Sep 17 00:00:00 2001 From: Clea Aumont Date: Tue, 19 Dec 2023 15:08:05 -0500 Subject: [PATCH 1/2] disable shape editing during pan/zoom mode --- callbacks/control_bar.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/callbacks/control_bar.py b/callbacks/control_bar.py index 5e26b32..2598a9c 100644 --- a/callbacks/control_bar.py +++ b/callbacks/control_bar.py @@ -163,6 +163,7 @@ def update_selected_class_style(selected_class, all_annotation_classes): State("annotation-store", "data"), State("generate-annotation-class-modal", "opened"), State({"type": "edit-annotation-class-modal", "index": ALL}, "opened"), + State("image-viewer", "figure"), prevent_initial_call=True, ) def annotation_mode( @@ -174,6 +175,7 @@ def annotation_mode( annotation_store, generate_modal_opened, edit_modal_opened, + fig, ): """ This callback is responsible for changing the annotation mode and the style of the buttons. @@ -235,6 +237,10 @@ def annotation_mode( annotation_store["dragmode"] = "pan" styles[trigger] = active + # disable shape editing when in pan/zoom mode + for shape in fig["layout"]["shapes"]: + shape["editable"] = trigger != "pan-and-zoom" and pan_and_zoom > 0 + patched_figure["layout"]["shapes"] = fig["layout"]["shapes"] return ( patched_figure, styles["closed-freeform"], From 175c450ecbcda9c284c01a8390588f7b91d67eeb Mon Sep 17 00:00:00 2001 From: Clea Aumont Date: Wed, 27 Dec 2023 13:50:40 -0500 Subject: [PATCH 2/2] run isort --- components/control_bar.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/control_bar.py b/components/control_bar.py index 4249a19..bb36d8f 100644 --- a/components/control_bar.py +++ b/components/control_bar.py @@ -1,9 +1,10 @@ import dash_bootstrap_components as dbc +import dash_core_components as dcc import dash_mantine_components as dmc from dash import dcc, html from dash_extensions import EventListener from dash_iconify import DashIconify -import dash_core_components as dcc + from components.annotation_class import annotation_class_item from constants import ANNOT_ICONS, KEYBINDS from utils import data_utils