|
| 1 | +# Classification Event Editor |
| 2 | + |
| 3 | +**Path:** `ui/classification/widgets/event_editor/` |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The **Event Editor** package is responsible for the **Right Panel** of the Classification Mode. It serves as the primary interface for manual data annotation. unlike the Localization mode which deals with timestamps, this editor focuses on assigning global attributes (labels) to entire video clips or actions. |
| 8 | + |
| 9 | +It features a **schema-driven UI**, meaning the widgets (Radio Buttons or Checkboxes) are dynamically rendered based on the loaded project JSON configuration. |
| 10 | + |
| 11 | +## Key Features |
| 12 | + |
| 13 | +* **Dynamic Rendering:** Automatically generates UI groups based on the label definition (Schema). |
| 14 | +* **Schema Management:** Allows users to add new Categories (Heads) and Labels dynamically during runtime. |
| 15 | +* **Annotation Input:** |
| 16 | + * **Single-choice:** Uses Radio Button groups. |
| 17 | + * **Multi-choice:** Uses Checkbox groups. |
| 18 | +* **Task Information:** Displays the current task name. |
| 19 | +* **History Control:** Hosts the Undo/Redo buttons for the classification workflow. |
| 20 | + |
| 21 | +## File Structure |
| 22 | + |
| 23 | +```text |
| 24 | +event_editor/ |
| 25 | +├── __init__.py # Package entry point; exports the main classes. |
| 26 | +├── editor.py # Defines the main container widget (ClassificationEventEditor). |
| 27 | +└── dynamic_widgets.py # Defines the atomic UI components (Label Groups). |
| 28 | +
|
| 29 | +``` |
| 30 | + |
| 31 | +## Module Descriptions |
| 32 | + |
| 33 | +### 1. `editor.py` |
| 34 | + |
| 35 | +Contains the `ClassificationEventEditor` class (formerly `ClassRightPanel`). |
| 36 | + |
| 37 | +**Responsibilities:** |
| 38 | + |
| 39 | +* Layout management (Vertical layout). |
| 40 | +* **Top Section:** Undo/Redo controls. |
| 41 | +* **Info Section:** Task name display. |
| 42 | +* **Schema Editor:** Input field and button to add new Label Heads. |
| 43 | +* **Scroll Area:** Holds the dynamic list of label groups. |
| 44 | +* **Bottom Section:** "Save Annotation" and "Clear Selection" buttons. |
| 45 | + |
| 46 | +**Key Signals:** |
| 47 | + |
| 48 | +* `add_head_clicked(str)`: Emitted when the user wants to add a new category. |
| 49 | +* `remove_head_clicked(str)`: Emitted when a category is deleted. |
| 50 | + |
| 51 | +### 2. `dynamic_widgets.py` |
| 52 | + |
| 53 | +Contains the reusable widgets that represent a single Label Head (Category). |
| 54 | + |
| 55 | +* **`DynamicSingleLabelGroup`**: |
| 56 | +* Used when the schema type is `single_label`. |
| 57 | +* Renders a `QButtonGroup` with `QRadioButton`s. |
| 58 | +* Allows adding/removing individual labels within the group. |
| 59 | + |
| 60 | + |
| 61 | +* **`DynamicMultiLabelGroup`**: |
| 62 | +* Used when the schema type is `multi_label`. |
| 63 | +* Renders a list of `QCheckBox`es. |
| 64 | +* Allows multiple selections simultaneously. |
| 65 | + |
| 66 | + |
| 67 | + |
| 68 | +### 3. `__init__.py` |
| 69 | + |
| 70 | +Exposes the classes to the rest of the application. |
| 71 | + |
| 72 | +```python |
| 73 | +from .editor import ClassificationEventEditor |
| 74 | +from .dynamic_widgets import DynamicSingleLabelGroup, DynamicMultiLabelGroup |
| 75 | + |
| 76 | +``` |
| 77 | + |
| 78 | +## Usage Example |
| 79 | + |
| 80 | +This module is typically instantiated by the `UnifiedTaskPanel` in the Main Window. |
| 81 | + |
| 82 | +```python |
| 83 | +# In ui/common/main_window.py |
| 84 | +from ui.classification.widgets.event_editor import ClassificationEventEditor |
| 85 | + |
| 86 | +self.right_panel = ClassificationEventEditor() |
| 87 | + |
| 88 | +# To populate the UI based on JSON schema: |
| 89 | +self.right_panel.setup_dynamic_labels(label_definitions_dict) |
| 90 | + |
| 91 | +# To get the user's current selection: |
| 92 | +user_data = self.right_panel.get_annotation() |
| 93 | + |
| 94 | +``` |
| 95 | + |
| 96 | +## Dependencies |
| 97 | + |
| 98 | +* **PyQt6**: Core UI framework. |
| 99 | +* **utils**: Uses `get_square_remove_btn_style` for the delete buttons. |
| 100 | + |
0 commit comments