|
YODAU 1.0
YEAR OF THE DEPEND ADULT UNDERGARMENT
|
Frontend coordinator for streams, lines, templates, and events. More...
#include <frontend/include/helpers/controller.hpp>


Classes | |
| struct | tpl_line |
| Stored template geometry (percentage coordinates). More... | |
Public Slots | |
| void | handle_add_file (const QString &path, const QString &name, bool loop) |
| Handler for adding a file stream from UI. | |
| void | handle_add_local (const QString &source, const QString &name) |
| Handler for adding a local capture device from UI. | |
| void | handle_add_url (const QString &url, const QString &name) |
| Handler for adding a network URL stream from UI. | |
| void | handle_detect_local_sources () |
| Handler for detecting available local sources. | |
| void | handle_show_stream_changed (const QString &name, bool show) |
| Handler for stream visibility toggles in UI. | |
| void | handle_backend_event (const QString &text) |
| Append a textual message to the "active log" in settings. | |
| void | on_gui_frame (const QString &stream_name, const QImage &image) |
| Slot receiving GUI frames from stream tiles. | |
Public Member Functions | |
| controller (yodau::backend::stream_manager *mgr, settings_panel *panel, board *zone, QObject *parent=nullptr) | |
| Construct a controller. | |
| void | init_from_backend () |
| Populate settings UI from backend at startup. | |
Private Slots | |
| void | on_active_stream_selected (const QString &name) |
| Handler for selecting an active stream in settings. | |
| void | on_active_edit_mode_changed (bool drawing_new) |
| Handler for toggling active edit mode. | |
| void | on_active_line_params_changed (const QString &name, const QColor &color, bool closed) |
| Handler for changes to "new line" draft parameters. | |
| void | on_active_line_save_requested (const QString &name, bool closed) |
| Handler for saving a newly drawn draft line. | |
| void | on_active_template_selected (const QString &template_name) |
| Handler for selecting a template while in template mode. | |
| void | on_active_template_color_changed (const QColor &color) |
| Handler for changing template preview color. | |
| void | on_active_template_add_requested (const QString &template_name, const QColor &color) |
| Handler for adding the selected template to the active stream. | |
| void | on_active_line_undo_requested () |
| Handler for undoing last draft point. | |
| void | on_active_labels_enabled_changed (bool on) |
| Handler for toggling persistent label visibility in active view. | |
Private Member Functions | |
| void | setup_settings_connections () |
| Connect settings_panel signals to controller slots. | |
| void | setup_grid_connections () |
| Connect grid_view signals to controller handlers. | |
| void | handle_add_stream_common (const QString &source, const QString &name, const QString &type, bool loop) |
| shared implementation for add-stream commands. | |
| void | register_stream_in_ui (const QString &final_name, const QString &source_desc) |
| Add newly created backend stream into UI structures. | |
| void | handle_enlarge_requested (const QString &name) |
| Handle focus/enlarge requests from grid tiles. | |
| void | handle_back_to_grid () |
| Return to grid mode (clear active stream). | |
| void | handle_thumb_activate (const QString &name) |
| Convenience alias for activating a thumbnail stream. | |
| stream_cell * | active_cell_checked (const QString &fail_prefix) |
| Get active cell or log a failure. | |
| void | sync_active_persistent () |
| Sync persistent line overlays and template candidates for active stream. | |
| void | apply_template_preview (const QString &template_name) |
| Apply a template preview into the active cell draft. | |
| void | log_active (const QString &msg) const |
| Append a message to the active log (if settings exists). | |
| void | apply_added_line (stream_cell *cell, const QString &final_name, const std::vector< QPointF > &pts, bool closed) |
| Apply effects of a newly added line to UI and state. | |
| void | sync_active_cell_lines () const |
| Push per-stream persistent lines into the active UI cell. | |
| QSet< QString > | used_template_names_for_stream (const QString &stream) const |
| Collect template names already used by a stream. | |
| QStringList | template_candidates_excluding (const QSet< QString > &used) const |
| List templates not present in a given used set. | |
| void | update_repaint_caps () |
| Update repaint interval caps for all visible tiles. | |
| void | update_analysis_caps () |
| Update backend analysis interval based on visible tile count. | |
| void | on_backend_event (const yodau::backend::event &e) |
| Handle a single backend event (GUI-thread safe). | |
| void | on_backend_events (const std::vector< yodau::backend::event > &evs) |
| Handle a batch of backend events. | |
| stream_cell * | tile_for_stream_name (const QString &name) const |
| Resolve a tile widget for a given stream name. | |
| yodau::backend::frame | frame_from_image (const QImage &image) const |
| Convert a QImage into backend frame. | |
Static Private Member Functions | |
| static QString | now_ts () |
| Current wall-clock timestamp as human-readable string. | |
| static QString | points_str_from_pct (const std::vector< QPointF > &pts) |
| Convert draft points to backend format string. | |
| static int | repaint_interval_for_count (int n) |
| Choose repaint interval given number of visible streams. | |
Private Attributes | |
| yodau::backend::stream_manager * | stream_mgr { nullptr } |
| Backend stream manager (non-owning). | |
| settings_panel * | settings { nullptr } |
| Settings panel (non-owning). | |
| board * | main_zone { nullptr } |
| Main board/zone widget (non-owning). | |
| grid_view * | grid { nullptr } |
| Grid view extracted from board (non-owning). | |
| QString | active_name |
| Name of currently active stream (empty if none). | |
| bool | drawing_new_mode { true } |
| True if active edit mode is "draw new line". | |
| bool | active_labels_enabled { true } |
| Whether labels are enabled in active cell. | |
| QString | draft_line_name |
| Draft line name being edited. | |
| QColor | draft_line_color { Qt::red } |
| Draft line preview color. | |
| bool | draft_line_closed { false } |
| Draft line closed flag. | |
| QMap< QString, tpl_line > | templates |
| Template registry keyed by template name. | |
| QMap< QString, std::vector< stream_cell::line_instance > > | per_stream_lines |
| Per-stream persistent line instances keyed by stream name. | |
| QMap< QString, QUrl > | stream_sources |
| Remembered stream sources (as QUrl) keyed by stream name. | |
| QMap< QString, bool > | stream_loops |
| Remembered stream loop flags keyed by stream name. | |
| int | active_interval_ms { 33 } |
| Repaint interval for active (focused) stream in ms. | |
| int | idle_interval_ms { 66 } |
| Repaint interval for idle grid streams in ms. | |
Frontend coordinator for streams, lines, templates, and events.
Responsibilities:
Threading:
Definition at line 59 of file controller.hpp.
|
explicit |
Construct a controller.
The controller does not take ownership of passed pointers; they must stay alive for the lifetime of this object.
On construction it:
| mgr | Backend stream manager (may be null; controller becomes inert). |
| panel | Settings panel for stream/line/forms (may be null). |
| zone | Main board widget (may be null). |
| parent | QObject parent. |
Definition at line 25 of file controller.cpp.
References grid, board::grid_mode(), init_from_backend(), main_zone, settings, setup_grid_connections(), setup_settings_connections(), and stream_mgr.

|
private |
Get active cell or log a failure.
| fail_prefix | Prefix for log messages when lookup fails. |
Definition at line 613 of file controller.cpp.
References board::active_cell(), main_zone, and settings.

|
private |
Apply effects of a newly added line to UI and state.
Adds persistent line instance, registers as template, connects to backend, resets draft form, and refreshes template candidates.
| cell | Active cell. |
| final_name | Backend-resolved line name. |
| pts | Draft points. |
| closed | Closed flag. |
Definition at line 695 of file controller.cpp.
References stream_cell::clear_draft(), draft_line_closed, settings_panel::reset_active_line_form(), settings_panel::reset_active_template_form(), settings, and sync_active_persistent().

|
private |
Apply a template preview into the active cell draft.
Clears existing draft, loads template points, and applies preview color.
| template_name | Template to preview. |
Definition at line 654 of file controller.cpp.
References board::active_cell(), stream_cell::clear_draft(), main_zone, and settings.

|
private |
Convert a QImage into backend frame.
Ensures RGB888 format and fills yodau::backend::frame fields.
| image | GUI image. |
Definition at line 834 of file controller.cpp.
References yodau::backend::frame::format, yodau::backend::frame::height, yodau::backend::rgb24, yodau::backend::frame::stride, and yodau::backend::frame::width.
|
slot |
Handler for adding a file stream from UI.
Delegates to handle_add_stream_common with type "file".
| path | Local filesystem path to media. |
| name | Optional desired stream name. |
| loop | Whether playback should loop at end-of-file. |
Definition at line 106 of file controller.cpp.
|
slot |
Handler for adding a local capture device from UI.
Delegates to handle_add_stream_common with type "local".
| source | Device path/id (e.g., "/dev/video0"). |
| name | Optional desired stream name. |
Definition at line 112 of file controller.cpp.
|
private |
shared implementation for add-stream commands.
Performs validation (for urls), adds stream to backend, stores its source/loop flags, logs to UI, and registers in settings.
| source | Path/URL/device. |
| name | Optional desired name. |
| type | Type string passed to backend ("file","local","url"). |
| loop | Loop flag. |
Definition at line 507 of file controller.cpp.
References settings, and stream_mgr.
|
slot |
Handler for adding a network URL stream from UI.
Validates scheme and delegates to handle_add_stream_common with type "url".
| url | Stream URL (rtsp/http/https). |
| name | Optional desired stream name. |
Definition at line 116 of file controller.cpp.
|
private |
Return to grid mode (clear active stream).
Definition at line 601 of file controller.cpp.
References settings.
Referenced by handle_enlarge_requested().

|
slot |
Append a textual message to the "active log" in settings.
Used for general backend/UI status messages.
| text | Message to append. |
Definition at line 200 of file controller.cpp.
References settings.
|
slot |
Handler for detecting available local sources.
Invokes backend local discovery and updates the UI list of local sources.
Definition at line 120 of file controller.cpp.
References settings, and stream_mgr.
Referenced by main_window::main_window().

|
private |
Handle focus/enlarge requests from grid tiles.
Toggles active view for the given stream.
Definition at line 584 of file controller.cpp.
References handle_back_to_grid(), and settings.

|
slot |
Handler for stream visibility toggles in UI.
When show is true:
When false:
Updates repaint + analysis caps after change.
| name | Stream name. |
| show | Whether to show or hide it. |
Definition at line 148 of file controller.cpp.
References grid_view::add_stream(), yodau::backend::file, grid, yodau::backend::local, main_zone, grid_view::peek_stream_cell(), grid_view::remove_stream(), stream_cell::set_loop(), settings, stream_mgr, board::take_active_cell(), update_analysis_caps(), and update_repaint_caps().

|
private |
Convenience alias for activating a thumbnail stream.
Definition at line 609 of file controller.cpp.
| void controller::init_from_backend | ( | ) |
Populate settings UI from backend at startup.
Reads stream list from backend, adds them to settings panel, and registers them as existing names to prevent duplicates.
Safe to call multiple times; it will re-add current backend streams.
Definition at line 77 of file controller.cpp.
References settings, and stream_mgr.
Referenced by controller().

|
private |
Append a message to the active log (if settings exists).
Definition at line 680 of file controller.cpp.
References settings.
|
staticprivate |
Current wall-clock timestamp as human-readable string.
Used for log messages.
Definition at line 580 of file controller.cpp.
|
privateslot |
Handler for toggling active edit mode.
When drawing_new is true, user draws a new line. Otherwise user previews/templates existing lines.
| drawing_new | New edit mode flag. |
Definition at line 239 of file controller.cpp.
References board::active_cell(), stream_cell::clear_draft(), drawing_new_mode, main_zone, stream_cell::set_drawing_enabled(), and settings.
Referenced by setup_settings_connections().


|
privateslot |
Handler for toggling persistent label visibility in active view.
| on | True to enable labels. |
Definition at line 427 of file controller.cpp.
References board::active_cell(), active_labels_enabled, main_zone, and stream_cell::set_labels_enabled().
Referenced by setup_settings_connections().


|
privateslot |
Handler for changes to "new line" draft parameters.
Stores parameters locally and applies them to active cell draft.
| name | Draft line name. |
| color | Draft line color. |
| closed | Draft closed flag. |
Definition at line 267 of file controller.cpp.
References board::active_cell(), draft_line_closed, main_zone, and settings.

|
privateslot |
Handler for saving a newly drawn draft line.
Reads draft points from active cell, converts to string, adds line to backend, connects it to the active stream, and updates UI state.
| name | Desired line name (may be auto-resolved by backend). |
| closed | Whether line is closed. |
Definition at line 292 of file controller.cpp.
References stream_mgr.
|
privateslot |
Handler for undoing last draft point.
Removes last draft vertex from active cell.
Definition at line 408 of file controller.cpp.
References board::active_cell(), and main_zone.
Referenced by setup_settings_connections().


|
privateslot |
Handler for selecting an active stream in settings.
Moves the stream cell into the active container (or clears active view), applies edit mode settings, and refreshes persistent lines/templates.
| name | Stream name to activate, or empty to deactivate. |
Definition at line 206 of file controller.cpp.
References board::active_cell(), active_labels_enabled, board::clear_active(), stream_cell::clear_draft(), drawing_new_mode, main_zone, board::set_active_stream(), stream_cell::set_drawing_enabled(), stream_cell::set_labels_enabled(), settings, sync_active_persistent(), update_analysis_caps(), and update_repaint_caps().

|
privateslot |
Handler for adding the selected template to the active stream.
Connects backend line, adds a persistent line instance to UI, and resets template form.
| template_name | Template to add. |
| color | Color to render this instance in the active stream. |
Definition at line 351 of file controller.cpp.
References settings_panel::reset_active_template_form(), settings, and sync_active_persistent().

|
privateslot |
Handler for changing template preview color.
Reapplies template preview with new color (template mode only).
| color | New preview color. |
Definition at line 333 of file controller.cpp.
References drawing_new_mode, and settings.
|
privateslot |
Handler for selecting a template while in template mode.
Preview is applied to active cell draft.
| template_name | Template name. |
Definition at line 326 of file controller.cpp.
References drawing_new_mode.
|
private |
Handle a single backend event (GUI-thread safe).
Definition at line 866 of file controller.cpp.
References yodau::backend::event::kind, yodau::backend::event::line_name, and yodau::backend::tripwire.
|
private |
Handle a batch of backend events.
Definition at line 794 of file controller.cpp.
|
slot |
Slot receiving GUI frames from stream tiles.
Converts a QImage to backend yodau::backend::frame and pushes it to the backend for analysis.
| stream_name | Stream name. |
| image | Latest frame from GUI. |
Definition at line 857 of file controller.cpp.
References stream_mgr.
|
staticprivate |
Convert draft points to backend format string.
Output is parsable by backend yodau::backend::parse_points.
| pts | Percentage points. |
Definition at line 686 of file controller.cpp.
|
private |
Add newly created backend stream into UI structures.
Updates settings entries and refreshes repaint/analysis caps.
| final_name | Actual backend name used for stream. |
| source_desc | Human-readable source description. |
Definition at line 565 of file controller.cpp.
References settings_panel::clear_add_inputs(), settings, update_analysis_caps(), and update_repaint_caps().

|
staticprivate |
Choose repaint interval given number of visible streams.
| n | Visible stream count. |
Definition at line 802 of file controller.cpp.
Referenced by update_analysis_caps(), and update_repaint_caps().

|
private |
Connect grid_view signals to controller handlers.
Definition at line 490 of file controller.cpp.
References grid, grid_view::grid_view(), and grid_view::stream_enlarge().
Referenced by controller().


|
private |
Connect settings_panel signals to controller slots.
Definition at line 439 of file controller.cpp.
References settings_panel::active_edit_mode_changed(), settings_panel::active_labels_enabled_changed(), settings_panel::active_line_undo_requested(), main_zone, on_active_edit_mode_changed(), on_active_labels_enabled_changed(), on_active_line_undo_requested(), per_stream_lines, settings, and settings_panel::settings_panel().
Referenced by controller().


|
private |
Push per-stream persistent lines into the active UI cell.
Definition at line 732 of file controller.cpp.
References board::active_cell(), and main_zone.
Referenced by sync_active_persistent().


|
private |
Sync persistent line overlays and template candidates for active stream.
Definition at line 636 of file controller.cpp.
References settings, and sync_active_cell_lines().
Referenced by apply_added_line(), on_active_stream_selected(), and on_active_template_add_requested().


|
private |
List templates not present in a given used set.
| used | Already used names. |
Definition at line 758 of file controller.cpp.
|
private |
Resolve a tile widget for a given stream name.
Prefers active cell if it matches name, otherwise looks in grid.
| name | Stream name. |
Definition at line 818 of file controller.cpp.
References board::active_cell(), grid, main_zone, and grid_view::peek_stream_cell().

|
private |
Update backend analysis interval based on visible tile count.
Definition at line 67 of file controller.cpp.
References grid, repaint_interval_for_count(), and stream_mgr.
Referenced by handle_show_stream_changed(), on_active_stream_selected(), and register_stream_in_ui().


|
private |
Update repaint interval caps for all visible tiles.
Definition at line 772 of file controller.cpp.
References active_interval_ms, grid, and repaint_interval_for_count().
Referenced by handle_show_stream_changed(), on_active_stream_selected(), and register_stream_in_ui().


|
private |
Collect template names already used by a stream.
| stream | Stream name. |
Definition at line 743 of file controller.cpp.
|
private |
Repaint interval for active (focused) stream in ms.
Definition at line 523 of file controller.hpp.
Referenced by update_repaint_caps().
|
private |
Whether labels are enabled in active cell.
Definition at line 482 of file controller.hpp.
Referenced by on_active_labels_enabled_changed(), and on_active_stream_selected().
|
private |
Name of currently active stream (empty if none).
Definition at line 476 of file controller.hpp.
|
private |
Draft line closed flag.
Definition at line 491 of file controller.hpp.
Referenced by apply_added_line(), and on_active_line_params_changed().
|
private |
|
private |
Draft line name being edited.
Definition at line 485 of file controller.hpp.
|
private |
True if active edit mode is "draw new line".
Definition at line 479 of file controller.hpp.
Referenced by on_active_edit_mode_changed(), on_active_stream_selected(), on_active_template_color_changed(), and on_active_template_selected().
|
private |
Grid view extracted from board (non-owning).
Definition at line 471 of file controller.hpp.
Referenced by controller(), handle_show_stream_changed(), setup_grid_connections(), tile_for_stream_name(), update_analysis_caps(), and update_repaint_caps().
|
private |
Repaint interval for idle grid streams in ms.
Definition at line 526 of file controller.hpp.
|
private |
Main board/zone widget (non-owning).
Definition at line 468 of file controller.hpp.
Referenced by active_cell_checked(), apply_template_preview(), controller(), handle_show_stream_changed(), on_active_edit_mode_changed(), on_active_labels_enabled_changed(), on_active_line_params_changed(), on_active_line_undo_requested(), on_active_stream_selected(), setup_settings_connections(), sync_active_cell_lines(), and tile_for_stream_name().
|
private |
Per-stream persistent line instances keyed by stream name.
Each instance carries its own color and closed flag for rendering.
Definition at line 514 of file controller.hpp.
Referenced by main_window::main_window(), and setup_settings_connections().
|
private |
Settings panel (non-owning).
Definition at line 465 of file controller.hpp.
Referenced by active_cell_checked(), apply_added_line(), apply_template_preview(), controller(), handle_add_stream_common(), handle_back_to_grid(), handle_backend_event(), handle_detect_local_sources(), handle_enlarge_requested(), handle_show_stream_changed(), init_from_backend(), log_active(), on_active_edit_mode_changed(), on_active_line_params_changed(), on_active_stream_selected(), on_active_template_add_requested(), on_active_template_color_changed(), register_stream_in_ui(), setup_settings_connections(), and sync_active_persistent().
|
private |
Remembered stream loop flags keyed by stream name.
Definition at line 520 of file controller.hpp.
|
private |
Backend stream manager (non-owning).
Definition at line 462 of file controller.hpp.
Referenced by controller(), handle_add_stream_common(), handle_detect_local_sources(), handle_show_stream_changed(), init_from_backend(), on_active_line_save_requested(), on_gui_frame(), and update_analysis_caps().
|
private |
Remembered stream sources (as QUrl) keyed by stream name.
Definition at line 517 of file controller.hpp.
|
private |
Template registry keyed by template name.
Definition at line 507 of file controller.hpp.