Selection History State
app.ui.view_state.selection_history_stateModule for selection history state; stores transient interaction state.
See Also
BBoxViewModel— snapshots box data for undo and redoAnnotationHandler— applies recorded selection mutations
Layer: Presentation. Context: Stores transient interaction state at this architectural boundary.
SelectionHistoryEntry
dataclass
Store the selected box keys before and after one selection change.
| ATTRIBUTE | DESCRIPTION |
|---|---|
before_keys |
Selection to restore when undoing the change.
TYPE:
|
after_keys |
Selection to restore when redoing the change.
TYPE:
|
Layer: Presentation. Context: Supports user interaction and delegates application work through presentation contracts.
after_keys: list[str]
instance-attribute
before_keys: list[str]
instance-attribute
__init__(before_keys: list[str], after_keys: list[str]) -> None
BoxMutationEntry
dataclass
Store one frame's box and selection snapshots for undo or redo.
| ATTRIBUTE | DESCRIPTION |
|---|---|
frame_index |
Frame whose boxes were mutated.
TYPE:
|
before_boxes |
Boxes captured before the mutation.
TYPE:
|
after_boxes |
Boxes captured after the mutation.
TYPE:
|
before_selection |
Selected keys captured before the mutation.
TYPE:
|
after_selection |
Selected keys captured after the mutation.
TYPE:
|
Layer: Presentation. Context: Supports user interaction and delegates application work through presentation contracts.
after_boxes: list
instance-attribute
after_selection: list[str]
instance-attribute
before_boxes: list
instance-attribute
before_selection: list[str]
instance-attribute
frame_index: int
instance-attribute
__init__(frame_index: int, before_boxes: list, after_boxes: list, before_selection: list[str], after_selection: list[str]) -> None
CopiedBBoxSnapshot
dataclass
Store the box fields needed to paste a copied annotation.
| ATTRIBUTE | DESCRIPTION |
|---|---|
label |
Classification label to copy.
TYPE:
|
bbox_xyxy |
Image-space
TYPE:
|
color_hex |
Display color to apply to the pasted box.
TYPE:
|
Layer: Presentation. Context: Supports user interaction and delegates application work through presentation contracts.
bbox_xyxy: tuple[int, int, int, int]
instance-attribute
color_hex: str
instance-attribute
label: str
instance-attribute
__init__(label: str, bbox_xyxy: tuple[int, int, int, int], color_hex: str) -> None
SelectionHistoryState
Represent selection history state.
Layer: Presentation. Context: Supports user interaction and delegates application work through presentation contracts.
has_clipboard_boxes: bool
property
Return whether the clipboard contains any copied boxes.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
|
__init__() -> None
get_clipboard_boxes() -> list[CopiedBBoxSnapshot]
Return a shallow copy of the copied-box clipboard.
| RETURNS | DESCRIPTION |
|---|---|
list[CopiedBBoxSnapshot]
|
List of clipboard snapshots; the list is copied, but its entries are shared. |
record_box_mutation(*, session_id: str, tab_index: int, frame_index: int, before_boxes: list, after_boxes: list, before_selection: list[str], after_selection: list[str]) -> None
Record before/after box and selection snapshots for undo.
| PARAMETER | DESCRIPTION |
|---|---|
session_id
|
Session whose boxes changed.
TYPE:
|
tab_index
|
Data tab where the mutation occurred.
TYPE:
|
frame_index
|
Zero-based index of the edited frame.
TYPE:
|
before_boxes
|
Box list captured before the edit.
TYPE:
|
after_boxes
|
Box list captured after the edit.
TYPE:
|
before_selection
|
Selected keys before the edit.
TYPE:
|
after_selection
|
Selected keys after the edit.
TYPE:
|
Side Effects
Appends an undo entry and clears redo history for this session and tab.
record_selection_change(*, session_id: str, tab_index: int, before_keys: list[str], after_keys: list[str]) -> None
Push a selection change onto the undo stack for one session and tab.
| PARAMETER | DESCRIPTION |
|---|---|
session_id
|
Session whose selection changed.
TYPE:
|
tab_index
|
Data tab whose selection changed.
TYPE:
|
before_keys
|
Selected box keys before the change.
TYPE:
|
after_keys
|
Selected box keys after the change.
TYPE:
|
Side Effects
Does nothing for equal selections; otherwise records the change and clears redo history.
redo_box_mutation(*, session_id: str, tab_index: int) -> BoxMutationEntry | None
Move the latest undone box mutation back to undo history.
| PARAMETER | DESCRIPTION |
|---|---|
session_id
|
Session whose mutation history is traversed.
TYPE:
|
tab_index
|
Data tab whose mutation history is traversed.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
BoxMutationEntry | None
|
Mutation snapshot to reapply, or |
redo_selection(*, session_id: str, tab_index: int) -> list[str] | None
Move the latest undone selection change back to undo history.
| PARAMETER | DESCRIPTION |
|---|---|
session_id
|
Session whose selection history is traversed.
TYPE:
|
tab_index
|
Data tab whose selection history is traversed.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[str] | None
|
Copy of the restored selected keys, or |
set_clipboard_boxes(*, boxes: list[CopiedBBoxSnapshot], tab_index: int) -> None
Replace the copied-box clipboard with snapshots from one data tab.
| PARAMETER | DESCRIPTION |
|---|---|
boxes
|
Box snapshots available for pasting.
TYPE:
|
tab_index
|
Tab index from which the boxes were copied.
TYPE:
|
undo_box_mutation(*, session_id: str, tab_index: int) -> BoxMutationEntry | None
Move the latest box mutation to redo history and return its snapshots.
| PARAMETER | DESCRIPTION |
|---|---|
session_id
|
Session whose mutation history is traversed.
TYPE:
|
tab_index
|
Data tab whose mutation history is traversed.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
BoxMutationEntry | None
|
Mutation snapshot to restore, or |
undo_selection(*, session_id: str, tab_index: int) -> list[str] | None
Move the latest selection change to redo history and return its prior selection.
| PARAMETER | DESCRIPTION |
|---|---|
session_id
|
Session whose selection history is traversed.
TYPE:
|
tab_index
|
Data tab whose selection history is traversed.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[str] | None
|
Copy of the prior selected keys, or |