-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathprojector.cpp
More file actions
83 lines (73 loc) · 1.67 KB
/
projector.cpp
File metadata and controls
83 lines (73 loc) · 1.67 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
#include "projector.h"
#include <QLayout>
#include <QEvent>
#include <QPaintEvent>
int proj_w;
int proj_h;
Projector::Projector(QWidget *parent, int scanW, int scanH, int projW, int projH, int xos, int yos)
: QWidget(parent)
{
width = scanW;
height = scanH;
proj_w = projW;
proj_h = projH;
xoffset = xos;
yoffset = yos;
crossVisible = true;
label = new QLabel;
QHBoxLayout *lo = new QHBoxLayout;
lo->addWidget(label);
//setLayout(lo);
}
Projector::~Projector()
{
}
void Projector::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
if(crossVisible)//QEvent::User 1000
{
painter.setPen(QPen(Qt::yellow, 5));
//else
//painter.setPen(QPen(Qt::white, 5));
painter.drawLine(proj_w/2 - 60, proj_h/2, proj_w/2 + 60, proj_h/2);
painter.drawLine(proj_w/2, proj_h/2 - 60, proj_w/2, proj_h/2 + 60);
}
if(imageAva){
painter.drawImage(0,0,pshow);
}
}
void Projector::opencvWindow()
{
cv::namedWindow("w");
//cvResizeWindow("w",width,height);
cv::moveWindow("w", xoffset, yoffset);
}
void Projector::showMatImg(cv::Mat img)
{
cv::imshow("w", img);
}
void Projector::showImg(cv::Mat img)
{
pshow = QImage(img.data,img.cols,img.rows,QImage::Format_Indexed8);
imageAva = true;
this->update();
//QPixmap p = QPixmap::fromImage(pshow);
//label->setPixmap(p);
}
void Projector::destoryWindow()
{
cvDestroyWindow("w");
}
void Projector::displaySwitch(bool isWhite)
{
if(isWhite)
this->setPalette(Qt::white);
else
this->setPalette(Qt::black);
}
void Projector::setCrossVisable(bool flag)
{
crossVisible = flag;
this->update();
}