-
Notifications
You must be signed in to change notification settings - Fork 0
/
ImageWindow.cpp
113 lines (93 loc) · 3.08 KB
/
ImageWindow.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include "ImageWindow.h"
ImageWindow::ImageWindow(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
}
ImageWindow::~ImageWindow()
{
}
void ImageWindow::setSize(int width, int height, QGraphicsScene* originalScene)
{
if (width > 1300) {
ui.ShowImage->setGeometry(0, 0, 1280 + 2, 720 + 2); //重置图片容器大小
this->resize(QSize(1280 + 2, 720 + 20)); //重置窗口大小
ui.poslabel->setGeometry(0, 720 + 5, 100, 10); //配置坐标显示label位置
ui.picvalue->setGeometry(1280 - 110, 720 + 5, 100, 10);
ui.ShowImage->setSceneRect(QRectF(-(1280 / 2), -(720 / 2), 1280, 720)); //设置scenRect大小
}
else {
ui.ShowImage->setGeometry(0, 0, width + 2, height + 2); //重置图片容器大小
this->resize(QSize(width + 2, height + 20)); //重置窗口大小
ui.poslabel->setGeometry(0, height + 5, 100, 10); //配置坐标显示label位置
ui.picvalue->setGeometry(width - 110, height + 5, 100, 10);
ui.ShowImage->setSceneRect(QRectF(-(width / 2), -(height / 2), width, height)); //设置scenRect大小
}
ui.ShowImage->setScene(originalScene); //为graphyview配置 Scene
}
//在图片下方显示坐标点
void ImageWindow::setCor(QPointF ptsf)
{
QPointF pts = ptsf;
float x = pts.x();
float y = pts.y();
stringstream strd;
strd << (int)x;
string sstr = strd.str();
QString qstr = QString::fromStdString(sstr) + ",";
strd.clear();
strd.str("");
strd << (int)y;
sstr = strd.str();
qstr += QString::fromStdString(sstr);
ui.poslabel->setText(qstr);
}
//在窗口右下方显示RGB颜色值
void ImageWindow::setCorValue(int R, int G, int B)
{
stringstream strd;
strd << R;
string sstr = strd.str();
QString qstr = QString::fromStdString(sstr) + ",";
strd.clear();
strd.str("");
strd << G;
sstr = strd.str();
qstr += QString::fromStdString(sstr) + ",";
strd.clear();
strd.str("");
strd << B;
sstr = strd.str();
qstr += QString::fromStdString(sstr);
ui.picvalue->setText(qstr);
}
//void ImageWindow::setQimage(QImage qimage, ImageWidget* m_Image,QGraphicsScene* originalScene)
//{
// int width = qimage.width();
// int height = qimage.height();
// this->img = qimage;
// tempPixmap = QPixmap::fromImage(img); //转换为pixmap
// originalScene = new QGraphicsScene(this); //new一个scene
// this->resize(QSize(qimage.width()+2, qimage.height()+20)); //重置窗口大小 底部预留位置显示坐标
// m_Image = new ImageWidget(&tempPixmap); //自定义图片控制类
// m_Image->setQGraphicsViewWH(qimage.width() + 2, qimage.height() + 2);
// ui.ShowImage->setGeometry(0, 0, qimage.width()+2, qimage.height()+2); //重置图片容器大小
// ui.ShowImage->setSceneRect(QRectF(-(width / 2), -(height / 2), width, height));
// //ui.ShowImage->setAttribute(Qt::WA_TransparentForMouseEvents); //设置鼠标事件穿透,即在窗口上点击可以触发父窗口的鼠标事件
// ui.poslabel->setGeometry(0, height + 5, 20, 10);
// originalScene->addItem(m_Image);
// ui.ShowImage->setScene(originalScene);
//
// /*QPointF pts = m_Image->getRecordPoint();
// float x = pts.x();
// float y = pts.y();
// stringstream strd;
// strd << (int)x;
// string sstr = strd.str();
// QString qstr = QString::fromStdString(sstr);;
// ui.poslabel->setText(qstr);*/
//
//
//
//
//}