-
Notifications
You must be signed in to change notification settings - Fork 1
/
qframedisplay.cpp
89 lines (76 loc) · 3 KB
/
qframedisplay.cpp
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
#include "qframedisplay.h"
#include <QDebug>
QFrameDisplay::QFrameDisplay(int type)
{
mType = type;
if(type == PAN_DISPLAY)
{
this->setWindowTitle("Panoramic View");
this->setFixedHeight(PAN_HEIGHT);
this->setFixedWidth(PAN_WIDTH);
this->setMouseTracking(true);
this->setCursor(Qt::CrossCursor);
}
else if (type == FOVEAL_DISPLAY)
{
this->setWindowTitle("Foveal View");
this->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
this->setFixedHeight(FOVEAL_HEIGHT);
this->setFixedWidth(FOVEAL_WIDTH);
// probably we should keep this resizable for the foveal display
}
}
////////////////////////////////////////////////////////////////////////////////////////////////
void QFrameDisplay::mouseMoveEvent(QMouseEvent *ev){
if(mType == PAN_DISPLAY) // only the pan view will be able to do this
{
QPoint currentMousePos = ev->pos();
if (ev->x() <= this->width() && ev->x() >= 0)
{
if (ev->y() <= this->height() && ev->y() >= 0)
{
emit sendMousePosition(currentMousePos);
}
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////
void QFrameDisplay::mousePressEvent(QMouseEvent *ev){
if(mType == PAN_DISPLAY) // only the pan view will be able to do this
{
QPoint currentMousePos = ev->pos();
if (ev->x() <= this->width() && ev->x() >= 0)
{
if (ev->y() <= this->height() && ev->y() >= 0)
{
emit sendClickedMousePosition(currentMousePos);
}
}
}
}
////////////////////////////////////////////////////////////////////////////////////////////////
void QFrameDisplay::receiveFrameCaptured(cv::Mat *frm){
//qDebug() << "Here";
if(this->isVisible())
{
if(frm != NULL && frm->data)
{
//cv::cvtColor(*frm,*frm, CV_BGR2RGB); // convert to rgb
//if(mType == PAN_DISPLAY)
//{
// mPixMap = QPixmap::fromImage(QImage(frm->data, frm->cols, frm->rows,frm->step, QImage::Format_RGB888));
// this->setPixmap(mPixMap);
//}
//else if(mType == FOVEAL_DISPLAY)
//{
// mPixMap = QPixmap::fromImage(QImage(frm->data, frm->cols, frm->rows,frm->step, QImage::Format_RGB888));
// //this->setPixmap(mPixMap.scaled(this->width(), this->height())); // use Qt::KeepAspectRatio to maintain aspect ratio
//}
mPixMap = QPixmap::fromImage(QImage(frm->data, frm->cols, frm->rows,frm->step, QImage::Format_RGB888));
this->setPixmap(mPixMap);
emit sendFrameDisplayed();
}
}
// qDebug() << "Receiving Frame "<<mType << " num:" << mNum++;
}
////////////////////////////////////////////////////////////////////////////////////////////////