Skip to content

Commit

Permalink
Merge pull request #157 from mlexchange/disable-shape-editing
Browse files Browse the repository at this point in the history
disable shape editing during pan/zoom mode
  • Loading branch information
hannahker committed Jan 9, 2024
2 parents bcaeeb0 + 175c450 commit 979d6e5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions callbacks/control_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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.
Expand Down Expand Up @@ -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"],
Expand Down
3 changes: 2 additions & 1 deletion components/control_bar.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 979d6e5

Please sign in to comment.