YODAU 1.0
YEAR OF THE DEPEND ADULT UNDERGARMENT
Loading...
Searching...
No Matches
stream_cell.hpp
Go to the documentation of this file.
1#ifndef YODAU_FRONTEND_WIDGETS_STREAM_CELL_HPP
2#define YODAU_FRONTEND_WIDGETS_STREAM_CELL_HPP
3
4#include <QCamera>
5#include <QCameraDevice>
6#include <QColor>
7#include <QDateTime>
8#include <QElapsedTimer>
9#include <QHash>
10#include <QImage>
11#include <QMediaCaptureSession>
12#include <QMediaDevices>
13#include <QMediaPlayer>
14#include <QPointF>
15#include <QString>
16#include <QUrl>
17#include <QVector>
18#include <QVideoFrame>
19#include <QVideoSink>
20#include <QWidget>
21
22#include <optional>
23#include <vector>
24
25/**
26 * @file stream_cell.hpp
27 * @brief Declarative UI widget for visualizing a single stream with overlays.
28 *
29 * This header declares @ref stream_cell, a Qt widget that:
30 * - displays video frames (from a media player or camera),
31 * - supports interactive drawing of "draft" lines in percentage coordinates,
32 * - renders persistent (saved) lines on top of the video,
33 * - shows transient event markers (e.g. motion/tripwire hits),
34 * - emits signals for user actions (close/focus) and frame availability.
35 *
36 * The implementation lives in stream_cell.cpp.
37 */
38
39class QLabel;
40class QPushButton;
41class QEvent;
42class QKeyEvent;
43class QMouseEvent;
44class QPaintEvent;
45class QPainter;
46
47/**
48 * @brief Widget representing one video stream cell in the frontend.
49 *
50 * A stream cell is a self-contained view of a video source that can be:
51 * - inactive (thumbnail in a grid),
52 * - active (focused/enlarged and optionally editable).
53 *
54 * Coordinate system:
55 * - All geometry overlays (draft and persistent lines, events) are stored
56 * in **percentage coordinates**:
57 * - x,y in range [0.0; 100.0]
58 * - (0,0) is top-left of the widget
59 * - (100,100) is bottom-right of the widget
60 *
61 * Interaction:
62 * - When drawing is enabled and the cell is active:
63 * - Left click adds a draft point at cursor position.
64 * - Mouse move updates hover position (preview segment).
65 * - Backspace / Ctrl+Z removes last draft point.
66 *
67 * Rendering:
68 * - Video frame fills the widget area.
69 * - Persistent lines are drawn solid, with optional labels.
70 * - Draft line is drawn dashed.
71 * - Hover point/coords and preview segments are shown while drawing.
72 * - Recent events are drawn as fading circles.
73 * - Line highlights (by name and optional hit point) animate for a short TTL.
74 */
75class stream_cell final : public QWidget {
77
78public:
79 /**
80 * @brief Instance of a persistent (saved) line to be rendered on the
81 * stream.
82 *
83 * Line is described in percentage coordinates.
84 */
86 /** @brief Name of the underlying template/definition in backend. */
88 /** @brief Line color used for rendering (default: red). */
90 /** @brief Whether the polyline should be treated as closed polygon. */
91 bool closed { false };
92 /** @brief Polyline points in percentage coordinates. */
94 };
95
96 /**
97 * @brief Construct a stream cell.
98 *
99 * @param name Logical stream name displayed in the widget.
100 * @param parent Optional parent widget.
101 */
102 explicit stream_cell(const QString& name, QWidget* parent = nullptr);
103
104 /**
105 * @brief Get logical name of this stream cell.
106 * @return Reference to stored name.
107 */
108 [[nodiscard]] const QString& get_name() const;
109
110 /**
111 * @brief Check whether this cell is currently active (focused).
112 * @return true if active.
113 */
114 bool is_active() const;
115
116 /**
117 * @brief Get current draft polyline points (percentage coordinates).
118 * @return Copy of draft points.
119 */
121
122 /**
123 * @brief Get whether current draft line is closed.
124 * @return true if draft is closed.
125 */
126 [[nodiscard]] bool draft_closed() const;
127
128 /**
129 * @brief Get current draft line name.
130 * @return Draft name, may be empty.
131 */
132 [[nodiscard]] QString draft_name() const;
133
134 /**
135 * @brief Get current draft line color.
136 * @return Draft color.
137 */
138 [[nodiscard]] QColor draft_color() const;
139
140 /**
141 * @brief Check whether the draft is in preview-only mode.
142 *
143 * Preview mode means draft is shown but not necessarily editable.
144 */
145 bool is_draft_preview() const;
146
147 /**
148 * @brief Set active (focused) state.
149 *
150 * Deactivating a cell automatically disables drawing and clears draft.
151 *
152 * @param val New active state.
153 */
154 void set_active(bool val);
155
156 /**
157 * @brief Enable or disable interactive drawing on this cell.
158 *
159 * Enabling drawing also enables mouse tracking to receive hover updates.
160 *
161 * @param on True to enable drawing.
162 */
163 void set_drawing_enabled(bool on);
164
165 /**
166 * @brief Set draft line parameters (name, color, closed flag).
167 *
168 * Does not modify draft points.
169 *
170 * @param name Draft line name.
171 * @param color Draft line color.
172 * @param closed Draft line closed flag.
173 */
174 void
175 set_draft_params(const QString& name, const QColor& color, bool closed);
176
177 /**
178 * @brief Replace current draft points (percentage coordinates).
179 *
180 * @param pts New draft points.
181 */
182 void set_draft_points_pct(const std::vector<QPointF>& pts);
183
184 /**
185 * @brief Clear all draft data (points, hover point, preview flag).
186 */
187 void clear_draft();
188
189 /**
190 * @brief Replace all persistent lines.
191 *
192 * @param lines New list of persistent line instances.
193 */
194 void set_persistent_lines(const std::vector<line_instance>& lines);
195
196 /**
197 * @brief Append a persistent line to the list.
198 *
199 * @param line Line instance to add.
200 */
201 void add_persistent_line(const line_instance& line);
202
203 /**
204 * @brief Remove all persistent lines.
205 */
207
208 /**
209 * @brief Enable or disable draft preview mode.
210 *
211 * @param on True to enable preview.
212 */
213 void set_draft_preview(bool on);
214
215 /**
216 * @brief Enable or disable rendering of persistent line labels.
217 *
218 * Labels are only shown when the cell is active.
219 *
220 * @param on True to enable labels.
221 */
222 void set_labels_enabled(bool on);
223
224 /**
225 * @brief Set media player source.
226 *
227 * If a media player is available, switches it to @p source and starts
228 * playback.
229 *
230 * @param source URL of local file or network stream.
231 */
232 void set_source(const QUrl& source);
233
234 /**
235 * @brief Enable or disable looping for file-based playback.
236 *
237 * @param on True to loop on end-of-media.
238 */
239 void set_loop(bool on);
240
241 /**
242 * @brief Switch to camera input by device id.
243 *
244 * Stops any previous player/camera, creates capture session if needed,
245 * finds a matching camera device by @p id, and starts capture.
246 *
247 * @param id Camera device id returned by Qt multimedia.
248 */
249 void set_camera_id(const QByteArray& id);
250
251 /**
252 * @brief Instance of a transient visual event marker.
253 *
254 * Events are maintained in percentage coordinates and rendered as fading
255 * circles for a fixed TTL.
256 */
258 /** @brief Event position in percentage coordinates. */
260 /** @brief Event color. */
262 /** @brief Timestamp when event was added. */
264 };
265
266 /**
267 * @brief Add a transient event marker.
268 *
269 * @param pos_pct Event position in percentage coordinates.
270 * @param color Event color.
271 */
272 void add_event(const QPointF& pos_pct, const QColor& color);
273
274 /**
275 * @brief Set minimum repaint interval for video frame updates.
276 *
277 * Frames arriving faster than this interval will be coalesced.
278 *
279 * @param ms Interval in milliseconds (> 0).
280 */
281 void set_repaint_interval_ms(int ms);
282
283 /**
284 * @brief Highlight a persistent line by name.
285 *
286 * Triggers a temporal highlight animation (thicker/alpha pulse).
287 *
288 * @param line_name Name of the line to highlight.
289 */
290 void highlight_line(const QString& line_name);
291
292 /**
293 * @brief Highlight a line and record a hit position for spatial falloff.
294 *
295 * The highlight animation will concentrate around @p pos_pct if the line
296 * supports segment-wise highlighting.
297 *
298 * @param line_name Name of the line to highlight.
299 * @param pos_pct Hit position in percentage coordinates.
300 */
301 void highlight_line_at(const QString& line_name, const QPointF& pos_pct);
302
303signals:
304 /**
305 * @brief Emitted when the user requests closing this stream cell.
306 *
307 * Typically triggered by clicking the close button.
308 *
309 * @param name Stream cell name.
310 */
312
313 /**
314 * @brief Emitted when the user requests focusing/enlarging this cell.
315 *
316 * Typically triggered by clicking the focus button.
317 *
318 * @param name Stream cell name.
319 */
320 void request_focus(const QString& name);
321
322 /**
323 * @brief Emitted whenever a new frame image becomes available.
324 *
325 * Useful for forwarding frames to backend processing or snapshots.
326 *
327 * @param stream_name Name of the stream.
328 * @param image Converted QImage representing the latest frame.
329 */
330 void frame_ready(const QString& stream_name, const QImage& image);
331
332protected:
333 /**
334 * @brief Paint handler.
335 *
336 * Draws:
337 * - widget background,
338 * - last video frame or "no signal" message,
339 * - stream name,
340 * - events, lines, draft and hover overlays.
341 */
342 void paintEvent(QPaintEvent* event) override;
343
344 /**
345 * @brief Mouse press handler for drawing draft points.
346 */
347 void mousePressEvent(QMouseEvent* event) override;
348
349 /**
350 * @brief Mouse move handler for hover updates while drawing.
351 */
352 void mouseMoveEvent(QMouseEvent* event) override;
353
354 /**
355 * @brief Leave handler to clear hover state.
356 */
357 void leaveEvent(QEvent* event) override;
358
359 /**
360 * @brief Key press handler for draft undo.
361 */
362 void keyPressEvent(QKeyEvent* event) override;
363
364private:
365 /** @brief Build child UI widgets (buttons, sink/player connections). */
366 void build_ui();
367 /** @brief Update focus button icon/tooltip based on active state. */
368 void update_icon();
369
370 /**
371 * @brief Draw a polyline/polygon with point markers.
372 *
373 * Points are given in percentage coordinates and projected to widget space.
374 *
375 * @param p Painter to draw with.
376 * @param pts_pct Points in percentage coordinates.
377 * @param color Stroke color.
378 * @param closed Whether to draw polygon instead of polyline.
379 * @param style Pen style.
380 * @param width Pen width in pixels.
381 */
383 QPainter& p, const std::vector<QPointF>& pts_pct, const QColor& color,
384 bool closed, Qt::PenStyle style, qreal width
385 ) const;
386
387 /** @brief Draw all persistent lines and their labels/highlights. */
388 void draw_persistent(QPainter& p) const;
389 /** @brief Draw the draft line (if any). */
390 void draw_draft(QPainter& p) const;
391 /** @brief Draw hover point indicator (if any). */
392 void draw_hover_point(QPainter& p) const;
393 /** @brief Draw hover coordinate text (if enabled). */
394 void draw_hover_coords(QPainter& p) const;
395 /** @brief Draw preview segment from last draft point to hover point. */
396 void draw_preview_segment(QPainter& p) const;
397 /** @brief Draw stream name overlay at top-left. */
398 void draw_stream_name(QPainter& p) const;
399
400 /**
401 * @brief Compute label anchor position for a line in pixel coordinates.
402 *
403 * Uses first or last point depending on closed flag.
404 */
405 QPointF label_pos_px(const line_instance& l) const;
406
407 /**
408 * @brief Convert pixel position to percentage coordinates.
409 */
410 QPointF to_pct(const QPointF& pos_px) const;
411
412 /**
413 * @brief Convert percentage coordinates to pixel position.
414 */
415 QPointF to_px(const QPointF& pos_pct) const;
416
417 /**
418 * @brief Draw transient events and prune expired ones.
419 */
420 void draw_events(QPainter& p);
421
422private slots:
423 /**
424 * @brief Slot called when the video sink receives a new frame.
425 *
426 * Converts the frame to QImage, emits @ref frame_ready,
427 * and schedules repaint respecting @ref repaint_interval_ms.
428 */
430
431 /**
432 * @brief Slot called on media status changes.
433 *
434 * Used to implement looping on end-of-media when enabled.
435 */
436 void on_media_status_changed(QMediaPlayer::MediaStatus status);
437
438 /**
439 * @brief Slot called when media player errors occur.
440 *
441 * Stores the error string and triggers a repaint.
442 */
443 void
444 on_player_error(QMediaPlayer::Error error, const QString& error_string);
445
446 /**
447 * @brief Slot called on camera errors.
448 *
449 * Stores camera error string and triggers a repaint.
450 */
451 void on_camera_error(QCamera::Error error);
452
453private:
454 /** @brief Logical stream name. */
456
457 /** @brief UI close button (top-right). */
458 QPushButton* close_btn { nullptr };
459 /** @brief UI focus/enlarge button (top-right). */
460 QPushButton* focus_btn { nullptr };
461 /** @brief Optional name label (unused in current implementation). */
462 QLabel* name_label { nullptr };
463
464 /** @brief Whether the cell is focused/active. */
465 bool active { false };
466
467 /** @brief Whether interactive drawing is enabled. */
468 bool drawing_enabled { false };
469 /** @brief Whether draft line is shown in preview mode. */
470 bool draft_preview { false };
471 /** @brief Whether persistent line labels are shown when active. */
472 bool labels_enabled { true };
473
474 /** @brief Draft line name. */
476 /** @brief Draft line color. */
478 /** @brief Draft line closed flag. */
479 bool draft_line_closed { false };
480 /** @brief Draft polyline points in percentage coordinates. */
482 /** @brief Current hover position in percentage coordinates. */
484
485 /** @brief Persisted lines to render. */
487
488 /** @brief Media player for file/URL sources. */
489 QMediaPlayer* player { nullptr };
490 /** @brief Video sink feeding decoded frames into the widget. */
491 QVideoSink* sink { nullptr };
492 /** @brief Most recent received frame as an image. */
494 /** @brief Whether playback looping is enabled. */
495 bool loop_enabled { true };
496 /** @brief Last error string to display when no frame is available. */
498
499 /** @brief Active camera (if using live input). */
500 QCamera* camera { nullptr };
501 /** @brief Capture session binding camera to sink. */
503 /** @brief Selected camera id. */
505
506 /** @brief Transient events currently displayed. */
508
509 /** @brief Timer throttling repaint frequency. */
511 /** @brief Minimum repaint interval in ms. */
513
514 /**
515 * @brief Line highlight timestamps by line name.
516 *
517 * Used to animate highlight effects for a fixed TTL.
518 */
520
521 /** @brief Highlight time-to-live in ms. */
523
524 /**
525 * @brief Hit info attached to a line highlight.
526 *
527 * Allows spatially localized highlight (falloff from hit position).
528 */
529 struct hit_info {
530 /** @brief Hit position in percentage coordinates. */
532 /** @brief Hit timestamp. */
534 };
535
536 /** @brief Optional hit positions per line name. */
538};
539
540#endif // YODAU_FRONTEND_WIDGETS_STREAM_CELL_HPP
void clear_active()
Clear active mode and return the active cell to the grid.
Definition board.cpp:66
board(QWidget *parent=nullptr)
Construct the board widget.
Definition board.cpp:8
void set_active_stream(const QString &name)
Make a stream active by name.
Definition board.cpp:34
stream_cell * active_cell() const
Get the currently active (focused) stream cell, if any.
Definition board.cpp:32
grid_view * grid_mode() const
Access the grid view (thumbnail mode).
Definition board.cpp:30
stream_cell * take_active_cell()
Detach and return the active cell without putting it back to grid.
Definition board.cpp:80
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.
Definition grid_view.cpp:13
void remove_stream(const QString &name)
Remove a stream cell from the grid.
Definition grid_view.cpp:60
void add_stream(const QString &name)
Add a new stream cell to the grid.
Definition grid_view.cpp:40
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 add_event(const QPointF &pos_pct, const QColor &color)
Add a transient event marker.
QImage last_frame
Most recent received frame as an image.
void mousePressEvent(QMouseEvent *event) override
Mouse press handler for drawing draft points.
int repaint_interval_ms
Minimum repaint interval in ms.
QHash< QString, QDateTime > line_highlights
Line highlight timestamps by line name.
std::vector< QPointF > draft_line_points_pct
Draft polyline points in percentage coordinates.
void set_loop(bool on)
Enable or disable looping for file-based playback.
void mouseMoveEvent(QMouseEvent *event) override
Mouse move handler for hover updates while drawing.
QMediaPlayer * player
Media player for file/URL sources.
void update_icon()
Update focus button icon/tooltip based on active state.
QPushButton * close_btn
UI close button (top-right).
void draw_hover_point(QPainter &p) const
Draw hover point indicator (if any).
bool is_active() const
Check whether this cell is currently active (focused).
bool active
Whether the cell is focused/active.
bool drawing_enabled
Whether interactive drawing is enabled.
QString draft_line_name
Draft line name.
std::vector< line_instance > persistent_lines
Persisted lines to render.
bool labels_enabled
Whether persistent line labels are shown when active.
void set_active(bool val)
Set active (focused) state.
void set_repaint_interval_ms(int ms)
Set minimum repaint interval for video frame updates.
QHash< QString, hit_info > line_hits
Optional hit positions per line name.
void draw_stream_name(QPainter &p) const
Draw stream name overlay at top-left.
void set_source(const QUrl &source)
Set media player source.
void set_persistent_lines(const std::vector< line_instance > &lines)
Replace all persistent lines.
bool draft_closed() const
Get whether current draft line is closed.
void set_camera_id(const QByteArray &id)
Switch to camera input by device id.
void paintEvent(QPaintEvent *event) override
Paint handler.
void draw_preview_segment(QPainter &p) const
Draw preview segment from last draft point to hover point.
QCamera * camera
Active camera (if using live input).
QColor draft_line_color
Draft line color.
void set_labels_enabled(bool on)
Enable or disable rendering of persistent line labels.
void draw_draft(QPainter &p) const
Draw the draft line (if any).
QVideoSink * sink
Video sink feeding decoded frames into the widget.
QByteArray camera_id
Selected camera id.
int line_highlight_ttl_ms
Highlight time-to-live in ms.
void clear_draft()
Clear all draft data (points, hover point, preview flag).
void clear_persistent_lines()
Remove all persistent lines.
QMediaCaptureSession * session
Capture session binding camera to sink.
QLabel * name_label
Optional name label (unused in current implementation).
void leaveEvent(QEvent *event) override
Leave handler to clear hover state.
void draw_persistent(QPainter &p) const
Draw all persistent lines and their labels/highlights.
void on_camera_error(QCamera::Error error)
Slot called on camera errors.
QElapsedTimer repaint_timer
Timer throttling repaint frequency.
void draw_events(QPainter &p)
Draw transient events and prune expired ones.
void set_draft_preview(bool on)
Enable or disable draft preview mode.
QPointF to_px(const QPointF &pos_pct) const
Convert percentage coordinates to pixel position.
void set_draft_points_pct(const std::vector< QPointF > &pts)
Replace current draft points (percentage coordinates).
const QString & get_name() const
Get logical name of this stream cell.
bool loop_enabled
Whether playback looping is enabled.
QPushButton * focus_btn
UI focus/enlarge button (top-right).
QString name
Logical stream name.
void draw_poly_with_points(QPainter &p, const std::vector< QPointF > &pts_pct, const QColor &color, bool closed, Qt::PenStyle style, qreal width) const
Draw a polyline/polygon with point markers.
void add_persistent_line(const line_instance &line)
Append a persistent line to the list.
void draw_hover_coords(QPainter &p) const
Draw hover coordinate text (if enabled).
QColor draft_color() const
Get current draft line color.
QPointF label_pos_px(const line_instance &l) const
Compute label anchor position for a line in pixel coordinates.
void set_drawing_enabled(bool on)
Enable or disable interactive drawing on this cell.
bool draft_line_closed
Draft line closed flag.
QString draft_name() const
Get current draft line name.
QString last_error
Last error string to display when no frame is available.
QVector< event_instance > events
Transient events currently displayed.
void keyPressEvent(QKeyEvent *event) override
Key press handler for draft undo.
void build_ui()
Build child UI widgets (buttons, sink/player connections).
std::vector< QPointF > draft_points_pct() const
Get current draft polyline points (percentage coordinates).
void on_media_status_changed(QMediaPlayer::MediaStatus status)
Slot called on media status changes.
bool draft_preview
Whether draft line is shown in preview mode.
QPointF to_pct(const QPointF &pos_px) const
Convert pixel position to percentage coordinates.
bool is_draft_preview() const
Check whether the draft is in preview-only mode.
std::optional< QPointF > hover_point_pct
Current hover position in percentage coordinates.
Central coordinator for streams, geometry, frame processing and events.
Represents a single video stream and its analytic connections.
Definition stream.hpp:64
event_kind
High-level classification of backend events.
Definition event.hpp:19
pixel_format
Pixel format of a frame buffer.
Definition frame.hpp:16
stream_type
Source/transport type of a video stream.
Definition stream.hpp:23
#define str_label(text)
Create a user-visible localized label.
Definition str_label.hpp:29
Stored template geometry (percentage coordinates).
std::vector< QPointF > pts_pct
Template vertices in percentage coordinates.
bool closed
Whether template is closed.
Instance of a transient visual event marker.
QPointF pos_pct
Event position in percentage coordinates.
QDateTime ts
Timestamp when event was added.
Hit info attached to a line highlight.
QDateTime ts
Hit timestamp.
QPointF pos_pct
Hit position in percentage coordinates.
Instance of a persistent (saved) line to be rendered on the stream.
Generic event produced by the backend.
Definition event.hpp:44
event_kind kind
Type of the event.
Definition event.hpp:50
std::string line_name
Name of the line / ROI / rule responsible for this event.
Definition event.hpp:86
Video frame container.
Definition frame.hpp:44
int width
Frame width in pixels.
Definition frame.hpp:48
int stride
Number of bytes per row.
Definition frame.hpp:60
int height
Frame height in pixels.
Definition frame.hpp:53
pixel_format format
Pixel format of the buffer.
Definition frame.hpp:67