CuteLogger
Fast and simple logging solution for Qt based applications
videozoomwidget.h
1/*
2 * Copyright (c) 2019 Meltytech, LLC
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef VIDEOZOOMWIDGET_H
19#define VIDEOZOOMWIDGET_H
20
21#include "sharedframe.h"
22
23#include <QMutex>
24#include <QWidget>
25
26class VideoZoomWidget : public QWidget
27{
28 Q_OBJECT
29
30public:
31 struct PixelValues
32 {
33 uint8_t y;
34 uint8_t u;
35 uint8_t v;
36 uint8_t r;
37 uint8_t g;
38 uint8_t b;
39 };
40
41 explicit VideoZoomWidget();
42
43 // May be called from a worker thread.
44 void putFrame(SharedFrame frame);
45
46 QPoint getSelectedPixel();
47 void setSelectedPixel(QPoint pixel);
48 QRect getPixelRect();
49 int getZoom();
50 PixelValues getPixelValues(const QPoint &pixel);
51 void setOffset(QPoint offset);
52
53signals:
54 void pixelSelected(const QPoint &);
55 void zoomChanged(int zoom);
56
57public slots:
58 void lock(bool locked);
59
60private:
61 virtual QSize sizeHint() const Q_DECL_OVERRIDE;
62
63 void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
64 void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
65 void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
66 void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
67
68 QPoint pixelToPos(const QPoint &pixel);
69 QPoint posToPixel(const QPoint &pos);
70 PixelValues pixelToValues(const QPoint &pixel);
71
72 bool m_locked;
73 bool m_selectionInProgress;
74 int m_zoom;
75 QPoint m_imageOffset;
76 QPoint m_mouseGrabPixel;
77 QPoint m_selectedPixel;
78
79 // Variables accessed from multiple threads (mutex protected)
80 QMutex m_mutex;
81 SharedFrame m_frame;
82};
83
84#endif // VIDEOZOOMWIDGET_H
The SharedFrame provides thread safe access to Mlt::Frame data.
Definition sharedframe.h:50