1#ifndef YODAU_FRONTEND_HELPERS_CONTROLLER_HPP
2#define YODAU_FRONTEND_HELPERS_CONTROLLER_HPP
9#include <QRandomGenerator>
19#include "widgets/stream_cell.hpp"
26
27
28
29
30
31
32
33
34
35
36
37
38
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
87
88
89
90
91
92
93
100
101
102
103
104
105
106
107
111
112
113
114
115
116
117
121
122
123
124
125
126
127
128
132
133
134
135
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
163
164
165
166
167
168
172
173
174
175
176
177
178
179
180 void on_gui_frame(
const QString& stream_name,
const QImage& image);
186
187
188
189
190
191
192
196
197
198
199
200
201
202
206
207
208
209
210
211
212
213
215 const QString& name,
const QColor& color,
bool closed
219
220
221
222
223
224
225
226
230
231
232
233
234
235
239
240
241
242
243
244
248
249
250
251
252
253
254
255
257 const QString& template_name,
const QColor& color
261
262
263
264
268
269
270
271
286
287
288
289
290
291
292
293
294
295
297 const QString& source,
const QString& name,
const QString& type,
302
303
304
305
306
307
308
310 const QString& final_name,
const QString& source_desc
314
315
316
317
318
319
325
326
327
328
338
339
340
341
342
346
347
348
352
353
354
355
356
357
361
362
366
367
368
369
370
371
372
376
377
378
379
380
381
382
383
384
385
388 const std::vector<QPointF>& pts,
bool closed
395
396
397
398
399
403
404
405
406
407
411
412
416
417
421
422
426
427
431
432
433
434
435
439
440
441
442
443
444
445
449
450
451
452
453
454
455
494
495
496
497
498
510
511
512
513
void clear_active()
Clear active mode and return the active cell to the grid.
board(QWidget *parent=nullptr)
Construct the board widget.
void set_active_stream(const QString &name)
Make a stream active by name.
stream_cell * active_cell() const
Get the currently active (focused) stream cell, if any.
grid_view * grid_mode() const
Access the grid view (thumbnail mode).
stream_cell * take_active_cell()
Detach and return the active cell without putting it back to grid.
bool drawing_new_mode
True if active edit mode is "draw new line".
void on_active_template_selected(const QString &template_name)
Handler for selecting a template while in template mode.
static QString points_str_from_pct(const std::vector< QPointF > &pts)
Convert draft points to backend format string.
void on_active_line_undo_requested()
Handler for undoing last draft point.
void update_analysis_caps()
Update backend analysis interval based on visible tile count.
void update_repaint_caps()
Update repaint interval caps for all visible tiles.
void on_backend_event(const yodau::backend::event &e)
Handle a single backend event (GUI-thread safe).
QColor draft_line_color
Draft line preview color.
void on_active_template_color_changed(const QColor &color)
Handler for changing template preview color.
QMap< QString, std::vector< stream_cell::line_instance > > per_stream_lines
Per-stream persistent line instances keyed by stream name.
QMap< QString, bool > stream_loops
Remembered stream loop flags keyed by stream name.
stream_cell * active_cell_checked(const QString &fail_prefix)
Get active cell or log a failure.
void on_active_template_add_requested(const QString &template_name, const QColor &color)
Handler for adding the selected template to the active stream.
QMap< QString, QUrl > stream_sources
Remembered stream sources (as QUrl) keyed by stream name.
void on_active_edit_mode_changed(bool drawing_new)
Handler for toggling active edit mode.
static QString now_ts()
Current wall-clock timestamp as human-readable string.
void on_backend_events(const std::vector< yodau::backend::event > &evs)
Handle a batch of backend events.
yodau::backend::stream_manager * stream_mgr
Backend stream manager (non-owning).
void handle_add_url(const QString &url, const QString &name)
Handler for adding a network URL stream from UI.
void on_active_line_params_changed(const QString &name, const QColor &color, bool closed)
Handler for changes to "new line" draft parameters.
QSet< QString > used_template_names_for_stream(const QString &stream) const
Collect template names already used by a stream.
void register_stream_in_ui(const QString &final_name, const QString &source_desc)
Add newly created backend stream into UI structures.
void handle_backend_event(const QString &text)
Append a textual message to the "active log" in settings.
void setup_grid_connections()
Connect grid_view signals to controller handlers.
void handle_show_stream_changed(const QString &name, bool show)
Handler for stream visibility toggles in UI.
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 log_active(const QString &msg) const
Append a message to the active log (if settings exists).
void handle_detect_local_sources()
Handler for detecting available local sources.
stream_cell * tile_for_stream_name(const QString &name) const
Resolve a tile widget for a given stream name.
QStringList template_candidates_excluding(const QSet< QString > &used) const
List templates not present in a given used set.
void handle_back_to_grid()
Return to grid mode (clear active stream).
QMap< QString, tpl_line > templates
Template registry keyed by template name.
void on_active_line_save_requested(const QString &name, bool closed)
Handler for saving a newly drawn draft line.
void handle_thumb_activate(const QString &name)
Convenience alias for activating a thumbnail stream.
void on_active_labels_enabled_changed(bool on)
Handler for toggling persistent label visibility in active view.
void sync_active_cell_lines() const
Push per-stream persistent lines into the active UI cell.
void handle_add_local(const QString &source, const QString &name)
Handler for adding a local capture device from UI.
void sync_active_persistent()
Sync persistent line overlays and template candidates for active stream.
int active_interval_ms
Repaint interval for active (focused) stream in ms.
grid_view * grid
Grid view extracted from board (non-owning).
yodau::backend::frame frame_from_image(const QImage &image) const
Convert a QImage into backend frame.
void setup_settings_connections()
Connect settings_panel signals to controller slots.
void handle_enlarge_requested(const QString &name)
Handle focus/enlarge requests from grid tiles.
void apply_template_preview(const QString &template_name)
Apply a template preview into the active cell draft.
settings_panel * settings
Settings panel (non-owning).
void handle_add_stream_common(const QString &source, const QString &name, const QString &type, bool loop)
shared implementation for add-stream commands.
bool active_labels_enabled
Whether labels are enabled in active cell.
static int repaint_interval_for_count(int n)
Choose repaint interval given number of visible streams.
board * main_zone
Main board/zone widget (non-owning).
QString active_name
Name of currently active stream (empty if none).
void init_from_backend()
Populate settings UI from backend at startup.
QString draft_line_name
Draft line name being edited.
int idle_interval_ms
Repaint interval for idle grid streams in ms.
bool draft_line_closed
Draft line closed flag.
void on_gui_frame(const QString &stream_name, const QImage &image)
Slot receiving GUI frames from stream tiles.
grid_view(QWidget *parent=nullptr)
Construct an empty grid view.
void remove_stream(const QString &name)
Remove a stream cell from the grid.
void add_stream(const QString &name)
Add a new stream cell to the grid.
stream_cell * peek_stream_cell(const QString &name) const
Get a pointer to a cell without removing it.
void stream_enlarge(const QString &name)
Emitted when a stream cell requests focus/enlargement.
void active_line_undo_requested()
Emitted when user requests undo of the last draft point.
settings_panel(QWidget *parent=nullptr)
Construct the settings panel.
void clear_add_inputs() const
Clear all add-tab input fields and reset validation.
void reset_active_template_form()
Reset the templates form to "none" selection.
void reset_active_line_form()
Reset the "new line" form in the active tab.
void active_edit_mode_changed(bool drawing_new)
Emitted when edit mode changes.
void active_labels_enabled_changed(bool on)
Emitted when label visibility toggle changes.
void set_loop(bool on)
Enable or disable looping for file-based playback.
void set_labels_enabled(bool on)
Enable or disable rendering of persistent line labels.
void clear_draft()
Clear all draft data (points, hover point, preview flag).
void set_drawing_enabled(bool on)
Enable or disable interactive drawing on this cell.
Central coordinator for streams, geometry, frame processing and events.
Represents a single video stream and its analytic connections.
event_kind
High-level classification of backend events.
pixel_format
Pixel format of a frame buffer.
stream_type
Source/transport type of a video stream.
#define str_label(text)
Create a user-visible localized label.
Stored template geometry (percentage coordinates).
std::vector< QPointF > pts_pct
Template vertices in percentage coordinates.
bool closed
Whether template is closed.
Instance of a persistent (saved) line to be rendered on the stream.
Generic event produced by the backend.
event_kind kind
Type of the event.
std::string line_name
Name of the line / ROI / rule responsible for this event.
int width
Frame width in pixels.
int stride
Number of bytes per row.
int height
Frame height in pixels.
pixel_format format
Pixel format of the buffer.