-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathVideoView.h
More file actions
122 lines (95 loc) · 2.78 KB
/
Copy pathVideoView.h
File metadata and controls
122 lines (95 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#pragma once
#include <memory>
#include <boost/optional.hpp>
#include <opencv2/opencv.hpp>
#include <QOpenGLWidget>
#include <QOpenGLFunctions>
#include <QOpenGLTexture>
#include "biotracker/core/TextureObject.h"
#include "biotracker/core/BioTrackerApp.h"
#include "biotracker/util/stdext.h"
class QOpenGLContext;
namespace BioTracker {
namespace Gui {
class VideoView : public QOpenGLWidget, protected QOpenGLFunctions {
Q_OBJECT
public:
enum class Mode : uint8_t {
INTERACTION = 0,
PANZOOM
};
VideoView(QWidget *parent, Core::BioTrackerApp &facade);
Mode getMode() const {
return m_currentMode;
}
Core::TextureObject &getTexture() {
return m_texture;
}
public Q_SLOTS:
void setMode(const Mode mode);
void fitToWindow();
private:
/**
* @brief Used to store mouse cursor offsets while panning.
*/
struct CurrentPanState {
QPointF lastPos;
CurrentPanState(const QPointF lastPos)
: lastPos(lastPos) {
}
};
/**
* @brief Stores the current zoom and pan offsets. While panning, panState stores the last mouse cursor position.
*/
struct PanZoomState {
float zoomFactor = 0.f;
float panX = 0.f;
float panY = 0.f;
boost::optional<CurrentPanState> panState;
};
/**
* @brief Current State of the VideoWidget. In Interaction mode, mouse and keyboard event will be forwarded to
* the currently active tracking algorithm.
*/
Mode m_currentMode;
/**
* @brief Pan/Zoom state variables.
*/
PanZoomState m_panZoomState;
/**
* @brief Ratio of widget size and image size
*/
float m_screenPicRatio;
/**
* @brief Wrapper for the OpenGL texture. Also contains the original image as opencv matrix.
*/
Core::TextureObject m_texture;
Core::BioTrackerApp &m_biotracker;
/**
* @brief m_painter
*/
QPainter m_painter;
void initializeGL() override;
void resizeGL(int w, int h) override;
void resizeEvent(QResizeEvent *event) override;
void paintEvent(QPaintEvent *event) override;
/**
* @brief unprojectScreenPos
* @param mouseCoords coordinates relative to window
* @return coordinates relative to image
*/
QPoint unprojectScreenPos(QPoint mouseCoords);
/**
* @brief projectPicturePos
* @param imageCoords coordinates relative to image
* @return coordinates relative to window
*/
QPoint projectPicturePos(QPoint imageCoords);
void keyPressEvent(QKeyEvent *e) override;
void mouseMoveEvent(QMouseEvent *e) override;
void mousePressEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override;
void wheelEvent(QWheelEvent *e) override;
};
}
}