|
|
|
|
@ -0,0 +1,623 @@
|
|
|
|
|
#include "lpImageCaliUI4P.h"
|
|
|
|
|
#include "QFileDialog"
|
|
|
|
|
#include "lpGlobalConfig.h"
|
|
|
|
|
#include <QSettings>
|
|
|
|
|
#include <QApplication>
|
|
|
|
|
#pragma execution_character_set("utf-8")
|
|
|
|
|
lpImageCaliUI4P::lpImageCaliUI4P(QWidget *parent)
|
|
|
|
|
: QWidget(parent)
|
|
|
|
|
{
|
|
|
|
|
ui.setupUi(this);
|
|
|
|
|
{
|
|
|
|
|
m_srcImgView_1 = replaceWidget<AwesomeImgViewer>(ui.widget);
|
|
|
|
|
connect(m_srcImgView_1, SIGNAL(filterroiChanged(const AwesomeRoiInfo&, QString)), this, SLOT(onROIChange(const AwesomeRoiInfo&, QString)));
|
|
|
|
|
connect(m_srcImgView_1, SIGNAL(pixelClicked(QPoint)), this, SLOT(onPixelClicked(QPoint)));
|
|
|
|
|
connect(m_srcImgView_1, SIGNAL(roiLockIng(QString)), this, SLOT(onRoiLockIng(QString)));
|
|
|
|
|
connect(m_srcImgView_1, SIGNAL(sgImageScale(qreal)), this, SLOT(onImageScale(qreal)));
|
|
|
|
|
|
|
|
|
|
connect(ui.m_pbLoadImg, SIGNAL(clicked()), this, SLOT(onButtonClicked()));
|
|
|
|
|
connect(ui.m_pbApply, SIGNAL(clicked()), this, SLOT(onButtonClicked()));
|
|
|
|
|
//connect(ui.m_pbExit, SIGNAL(clicked()), this, SLOT(onButtonClicked()));
|
|
|
|
|
connect(ui.m_pbLock, SIGNAL(clicked()), this, SLOT(onButtonClicked()));
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
m_srcImgView_2 = replaceWidget<AwesomeImgViewer>(ui.widget_2);
|
|
|
|
|
connect(m_srcImgView_2, SIGNAL(filterroiChanged(const AwesomeRoiInfo&, QString)), this, SLOT(onROIChange(const AwesomeRoiInfo&, QString)));
|
|
|
|
|
connect(m_srcImgView_2, SIGNAL(pixelClicked(QPoint)), this, SLOT(onPixelClicked(QPoint)));
|
|
|
|
|
connect(m_srcImgView_2, SIGNAL(roiLockIng(QString)), this, SLOT(onRoiLockIng(QString)));
|
|
|
|
|
connect(m_srcImgView_2, SIGNAL(sgImageScale(qreal)), this, SLOT(onImageScale(qreal)));
|
|
|
|
|
|
|
|
|
|
connect(ui.m_pbLoadImg_2, SIGNAL(clicked()), this, SLOT(onButtonClicked()));
|
|
|
|
|
connect(ui.m_pbApply_2, SIGNAL(clicked()), this, SLOT(onButtonClicked()));
|
|
|
|
|
//connect(ui.m_pbExit, SIGNAL(clicked()), this, SLOT(onButtonClicked()));
|
|
|
|
|
connect(ui.m_pbLock_2, SIGNAL(clicked()), this, SLOT(onButtonClicked()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString strPath = QApplication::applicationDirPath() + "/showImg.ini";//图像展示比例的参数
|
|
|
|
|
QSettings setting(strPath, QSettings::IniFormat);
|
|
|
|
|
double nScale_1 = setting.value("ShowImg/Scale_Standard_1", 0.53).toDouble();
|
|
|
|
|
m_srcImgView_1->setInitScale(nScale_1);
|
|
|
|
|
double nScale_2 = setting.value("ShowImg/Scale_Standard_2", 0.53).toDouble();
|
|
|
|
|
m_srcImgView_2->setInitScale(nScale_2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lpImageCaliUI4P::~lpImageCaliUI4P()
|
|
|
|
|
{
|
|
|
|
|
if (m_srcImgView_1) {
|
|
|
|
|
delete m_srcImgView_1;
|
|
|
|
|
m_srcImgView_1 = nullptr;
|
|
|
|
|
}
|
|
|
|
|
if (m_srcImgView_2) {
|
|
|
|
|
delete m_srcImgView_2;
|
|
|
|
|
m_srcImgView_2 = nullptr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<typename _Widget>
|
|
|
|
|
_Widget* lpImageCaliUI4P::replaceWidget(QWidget* pSrcWidget)
|
|
|
|
|
{
|
|
|
|
|
if (!pSrcWidget) {
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
QWidget* pParent = qobject_cast<QWidget*>(pSrcWidget->parent());
|
|
|
|
|
if (!pParent) {
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
_Widget* pDstWidget = new _Widget;
|
|
|
|
|
auto *pFrom = pParent->layout()->replaceWidget(pSrcWidget, pDstWidget);
|
|
|
|
|
delete pFrom;
|
|
|
|
|
delete pSrcWidget;
|
|
|
|
|
return pDstWidget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void lpImageCaliUI4P::setStationFlags(bool bDouble)
|
|
|
|
|
{
|
|
|
|
|
if (bDouble == false)
|
|
|
|
|
{
|
|
|
|
|
ui.tabWidget->removeTab(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void lpImageCaliUI4P::showEvent(QShowEvent *event)
|
|
|
|
|
{
|
|
|
|
|
{//工位1 参数配置
|
|
|
|
|
ui.m_lineEdit_P1X->setText(QString("%1").arg(lpGlobalConfig::instance()->stationParam1.Pixpoint1.x()));
|
|
|
|
|
ui.m_lineEdit_P1Y->setText(QString("%1").arg(lpGlobalConfig::instance()->stationParam1.Pixpoint1.y()));
|
|
|
|
|
ui.m_lineEdit_P2X->setText(QString("%1").arg(lpGlobalConfig::instance()->stationParam1.Pixpoint2.x()));
|
|
|
|
|
ui.m_lineEdit_P2Y->setText(QString("%1").arg(lpGlobalConfig::instance()->stationParam1.Pixpoint2.y()));
|
|
|
|
|
ui.m_lineEdit_P3X->setText(QString("%1").arg(lpGlobalConfig::instance()->stationParam1.Pixpoint3.x()));
|
|
|
|
|
ui.m_lineEdit_P3Y->setText(QString("%1").arg(lpGlobalConfig::instance()->stationParam1.Pixpoint3.y()));
|
|
|
|
|
ui.m_lineEdit_P4X->setText(QString("%1").arg(lpGlobalConfig::instance()->stationParam1.Pixpoint4.x()));
|
|
|
|
|
ui.m_lineEdit_P4Y->setText(QString("%1").arg(lpGlobalConfig::instance()->stationParam1.Pixpoint4.y()));
|
|
|
|
|
|
|
|
|
|
ui.m_lineEdit_RealP1X->setText(QString("%1").arg(lpGlobalConfig::instance()->stationParam1.Realpoint1.x()));
|
|
|
|
|
ui.m_lineEdit_RealP1Y->setText(QString("%1").arg(lpGlobalConfig::instance()->stationParam1.Realpoint1.y()));
|
|
|
|
|
ui.m_lineEdit_RealP2X->setText(QString("%1").arg(lpGlobalConfig::instance()->stationParam1.Realpoint2.x()));
|
|
|
|
|
ui.m_lineEdit_RealP2Y->setText(QString("%1").arg(lpGlobalConfig::instance()->stationParam1.Realpoint2.y()));
|
|
|
|
|
ui.m_lineEdit_RealP3X->setText(QString("%1").arg(lpGlobalConfig::instance()->stationParam1.Realpoint3.x()));
|
|
|
|
|
ui.m_lineEdit_RealP3Y->setText(QString("%1").arg(lpGlobalConfig::instance()->stationParam1.Realpoint3.y()));
|
|
|
|
|
ui.m_lineEdit_RealP4X->setText(QString("%1").arg(lpGlobalConfig::instance()->stationParam1.Realpoint4.x()));
|
|
|
|
|
ui.m_lineEdit_RealP4Y->setText(QString("%1").arg(lpGlobalConfig::instance()->stationParam1.Realpoint4.y()));
|
|
|
|
|
|
|
|
|
|
ui.m_lineEdit_Xoffset->setText(QString("%1").arg(lpGlobalConfig::instance()->stationParam1.xPointOffset));
|
|
|
|
|
ui.m_lineEdit_Yoffset->setText(QString("%1").arg(lpGlobalConfig::instance()->stationParam1.yPointOffset));
|
|
|
|
|
|
|
|
|
|
ui.checkBox_XY_1->setChecked(lpGlobalConfig::instance()->stationParam1.bXYTrans);//输出坐标取反
|
|
|
|
|
m_point1_1 = lpGlobalConfig::instance()->stationParam1.Pixpoint1;
|
|
|
|
|
m_point2_1 = lpGlobalConfig::instance()->stationParam1.Pixpoint2;
|
|
|
|
|
m_point3_1 = lpGlobalConfig::instance()->stationParam1.Pixpoint3;
|
|
|
|
|
m_point4_1 = lpGlobalConfig::instance()->stationParam1.Pixpoint4;
|
|
|
|
|
m_testPoint_1 = lpGlobalConfig::instance()->stationParam1.testPoint;
|
|
|
|
|
|
|
|
|
|
QPointF temPoint = transWorldPoint(m_testPoint_1, lpGlobalConfig::instance()->stationParam1.matix);
|
|
|
|
|
ui.label_testPixPoint->setText(QString("(%1,%2)").arg(m_testPoint_1.x()).arg(m_testPoint_1.y()));
|
|
|
|
|
ui.label_testRealPoint->setText(QString("(%1,%2)").arg(temPoint.x()).arg(temPoint.y()));
|
|
|
|
|
if (m_srcImgView_1)
|
|
|
|
|
{
|
|
|
|
|
m_srcImgView_1->onClearAllROI();
|
|
|
|
|
QString DstPath = QApplication::applicationDirPath() + "\\user\\StandImage_1.jpg";
|
|
|
|
|
QImage img;
|
|
|
|
|
img.load(DstPath);
|
|
|
|
|
|
|
|
|
|
m_imageH_1 = img.height();
|
|
|
|
|
m_imageW_1 = img.width();
|
|
|
|
|
m_srcImgView_1->setImg(img);
|
|
|
|
|
|
|
|
|
|
AddPoint(m_point1_1, "P1");
|
|
|
|
|
AddPoint(m_point2_1, "P2");
|
|
|
|
|
AddPoint(m_point3_1, "P3");
|
|
|
|
|
AddPoint(m_point4_1, "P4");
|
|
|
|
|
AddPoint(m_testPoint_1, "Test",QColor(255,250,0));
|
|
|
|
|
m_srcImgView_1->setLabelVisible(true);
|
|
|
|
|
m_srcImgView_1->setLockAll(true);
|
|
|
|
|
}
|
|
|
|
|
ui.m_pbLock->setText(tr("解锁"));
|
|
|
|
|
ui.m_pbLock->setIcon(QIcon(":/Resource/lock.png"));
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
ui.m_lineEdit_P1X_2->setText(QString("%1").arg(lpGlobalConfig::instance()->stationParam2.Pixpoint1.x()));
|
|
|
|
|
ui.m_lineEdit_P1Y_2->setText(QString("%1").arg(lpGlobalConfig::instance()->stationParam2.Pixpoint1.y()));
|
|
|
|
|
ui.m_lineEdit_P2X_2->setText(QString("%1").arg(lpGlobalConfig::instance()->stationParam2.Pixpoint2.x()));
|
|
|
|
|
ui.m_lineEdit_P2Y_2->setText(QString("%1").arg(lpGlobalConfig::instance()->stationParam2.Pixpoint2.y()));
|
|
|
|
|
ui.m_lineEdit_P3X_2->setText(QString("%1").arg(lpGlobalConfig::instance()->stationParam2.Pixpoint3.x()));
|
|
|
|
|
ui.m_lineEdit_P3Y_2->setText(QString("%1").arg(lpGlobalConfig::instance()->stationParam2.Pixpoint3.y()));
|
|
|
|
|
ui.m_lineEdit_P4X_2->setText(QString("%1").arg(lpGlobalConfig::instance()->stationParam2.Pixpoint4.x()));
|
|
|
|
|
ui.m_lineEdit_P4Y_2->setText(QString("%1").arg(lpGlobalConfig::instance()->stationParam2.Pixpoint4.y()));
|
|
|
|
|
|
|
|
|
|
ui.m_lineEdit_RealP1X_2->setText(QString("%1").arg(lpGlobalConfig::instance()->stationParam2.Realpoint1.x()));
|
|
|
|
|
ui.m_lineEdit_RealP1Y_2->setText(QString("%1").arg(lpGlobalConfig::instance()->stationParam2.Realpoint1.y()));
|
|
|
|
|
ui.m_lineEdit_RealP2X_2->setText(QString("%1").arg(lpGlobalConfig::instance()->stationParam2.Realpoint2.x()));
|
|
|
|
|
ui.m_lineEdit_RealP2Y_2->setText(QString("%1").arg(lpGlobalConfig::instance()->stationParam2.Realpoint2.y()));
|
|
|
|
|
ui.m_lineEdit_RealP3X_2->setText(QString("%1").arg(lpGlobalConfig::instance()->stationParam2.Realpoint3.x()));
|
|
|
|
|
ui.m_lineEdit_RealP3Y_2->setText(QString("%1").arg(lpGlobalConfig::instance()->stationParam2.Realpoint3.y()));
|
|
|
|
|
ui.m_lineEdit_RealP4X_2->setText(QString("%1").arg(lpGlobalConfig::instance()->stationParam2.Realpoint4.x()));
|
|
|
|
|
ui.m_lineEdit_RealP4Y_2->setText(QString("%1").arg(lpGlobalConfig::instance()->stationParam2.Realpoint4.y()));
|
|
|
|
|
|
|
|
|
|
ui.m_lineEdit_Xoffset_2->setText(QString("%1").arg(lpGlobalConfig::instance()->stationParam2.xPointOffset));
|
|
|
|
|
ui.m_lineEdit_Yoffset_2->setText(QString("%1").arg(lpGlobalConfig::instance()->stationParam2.yPointOffset));
|
|
|
|
|
|
|
|
|
|
ui.checkBox_XY_2->setChecked(lpGlobalConfig::instance()->stationParam2.bXYTrans);//输出坐标取反
|
|
|
|
|
m_point1_2 = lpGlobalConfig::instance()->stationParam2.Pixpoint1;
|
|
|
|
|
m_point2_2 = lpGlobalConfig::instance()->stationParam2.Pixpoint2;
|
|
|
|
|
m_point3_2 = lpGlobalConfig::instance()->stationParam2.Pixpoint3;
|
|
|
|
|
m_point4_2 = lpGlobalConfig::instance()->stationParam2.Pixpoint4;
|
|
|
|
|
m_testPoint_2 = lpGlobalConfig::instance()->stationParam2.testPoint;
|
|
|
|
|
|
|
|
|
|
QPointF temPoint = transWorldPoint(m_testPoint_2, lpGlobalConfig::instance()->stationParam2.matix);
|
|
|
|
|
ui.label_testPixPoint_2->setText(QString("(%1,%2)").arg(m_testPoint_2.x()).arg(m_testPoint_2.y()));
|
|
|
|
|
ui.label_testRealPoint_2->setText(QString("(%1,%2)").arg(temPoint.x()).arg(temPoint.y()));
|
|
|
|
|
if (m_srcImgView_2)
|
|
|
|
|
{
|
|
|
|
|
m_srcImgView_2->onClearAllROI();
|
|
|
|
|
QString DstPath = QApplication::applicationDirPath() + "\\user\\StandImage_2.jpg";
|
|
|
|
|
QImage img;
|
|
|
|
|
img.load(DstPath);
|
|
|
|
|
|
|
|
|
|
m_imageH_2 = img.height();
|
|
|
|
|
m_imageW_2 = img.width();
|
|
|
|
|
m_srcImgView_2->setImg(img);
|
|
|
|
|
|
|
|
|
|
AddPoint_2(m_point1_2, "P1");
|
|
|
|
|
AddPoint_2(m_point2_2, "P2");
|
|
|
|
|
AddPoint_2(m_point3_2, "P3");
|
|
|
|
|
AddPoint_2(m_point4_2, "P4");
|
|
|
|
|
AddPoint_2(m_testPoint_2, "Test", QColor(255, 250, 0));
|
|
|
|
|
m_srcImgView_2->setLabelVisible(true);
|
|
|
|
|
m_srcImgView_2->setLockAll(true);
|
|
|
|
|
}
|
|
|
|
|
ui.m_pbLock_2->setText(tr("解锁"));
|
|
|
|
|
ui.m_pbLock_2->setIcon(QIcon(":/Resource/lock.png"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void lpImageCaliUI4P::changeEvent(QEvent *event)
|
|
|
|
|
{
|
|
|
|
|
if (event->type() == QEvent::LanguageChange)
|
|
|
|
|
{
|
|
|
|
|
ui.retranslateUi(this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Q_SLOT void lpImageCaliUI4P::onButtonClicked()
|
|
|
|
|
{
|
|
|
|
|
QString strObj = sender()->objectName();
|
|
|
|
|
if (strObj == "m_pbLoadImg")
|
|
|
|
|
{
|
|
|
|
|
QString fileName = QFileDialog::getOpenFileName(this, tr("选择标定图"), "/home/jana", tr("Image Files (*.png *.jpg *.bmp)"));
|
|
|
|
|
if (!fileName.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
QString DstPath = QApplication::applicationDirPath() + "\\user\\StandImage_1.jpg";
|
|
|
|
|
QString sourcePath = fileName;
|
|
|
|
|
DstPath.replace("\\", "/");
|
|
|
|
|
if (sourcePath == DstPath) {
|
|
|
|
|
}
|
|
|
|
|
if (!QFile::exists(sourcePath)) {
|
|
|
|
|
}
|
|
|
|
|
QDir *createfile = new QDir;
|
|
|
|
|
bool exist = createfile->exists(DstPath);
|
|
|
|
|
if (exist) {
|
|
|
|
|
createfile->remove(DstPath);
|
|
|
|
|
}
|
|
|
|
|
QImage img;
|
|
|
|
|
img.load(fileName);
|
|
|
|
|
img.save(DstPath);
|
|
|
|
|
if (m_srcImgView_1) {
|
|
|
|
|
m_imageH_1 = img.height();
|
|
|
|
|
m_imageW_1 = img.width();
|
|
|
|
|
m_srcImgView_1->setImg(img);
|
|
|
|
|
m_srcImgView_1->onClearAllROI();
|
|
|
|
|
AddPoint(m_point1_1, "P1");
|
|
|
|
|
AddPoint(m_point2_1, "P2");
|
|
|
|
|
AddPoint(m_point3_1, "P3");
|
|
|
|
|
AddPoint(m_point4_1, "P4");
|
|
|
|
|
AddPoint(m_testPoint_1, "Test", QColor(255, 250, 0));
|
|
|
|
|
m_srcImgView_1->setLabelVisible(true);
|
|
|
|
|
m_srcImgView_1->setLockAll(true);
|
|
|
|
|
ui.m_pbLock->setText(tr("解锁"));
|
|
|
|
|
ui.m_pbLock->setIcon(QIcon(":/Resource/lock.png"));
|
|
|
|
|
}
|
|
|
|
|
delete createfile;
|
|
|
|
|
createfile = nullptr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (strObj == "m_pbLoadImg_2")
|
|
|
|
|
{
|
|
|
|
|
QString fileName = QFileDialog::getOpenFileName(this, tr("选择标定图"), "/home/jana", tr("Image Files (*.png *.jpg *.bmp)"));
|
|
|
|
|
if (!fileName.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
QString DstPath = QApplication::applicationDirPath() + "\\user\\StandImage_2.jpg";
|
|
|
|
|
QString sourcePath = fileName;
|
|
|
|
|
DstPath.replace("\\", "/");
|
|
|
|
|
if (sourcePath == DstPath) {
|
|
|
|
|
}
|
|
|
|
|
if (!QFile::exists(sourcePath)) {
|
|
|
|
|
}
|
|
|
|
|
QDir *createfile = new QDir;
|
|
|
|
|
bool exist = createfile->exists(DstPath);
|
|
|
|
|
if (exist) {
|
|
|
|
|
createfile->remove(DstPath);
|
|
|
|
|
}
|
|
|
|
|
QImage img;
|
|
|
|
|
img.load(fileName);
|
|
|
|
|
img.save(DstPath);
|
|
|
|
|
if (m_srcImgView_2) {
|
|
|
|
|
m_imageH_2 = img.height();
|
|
|
|
|
m_imageW_2 = img.width();
|
|
|
|
|
m_srcImgView_2->setImg(img);
|
|
|
|
|
m_srcImgView_2->onClearAllROI();
|
|
|
|
|
AddPoint_2(m_point1_2, "P1");
|
|
|
|
|
AddPoint_2(m_point2_2, "P2");
|
|
|
|
|
AddPoint_2(m_point3_2, "P3");
|
|
|
|
|
AddPoint_2(m_point4_2, "P4");
|
|
|
|
|
AddPoint_2(m_testPoint_2, "Test", QColor(255, 250, 0));
|
|
|
|
|
m_srcImgView_2->setLabelVisible(true);
|
|
|
|
|
m_srcImgView_2->setLockAll(true);
|
|
|
|
|
ui.m_pbLock_2->setText(tr("解锁"));
|
|
|
|
|
ui.m_pbLock_2->setIcon(QIcon(":/Resource/lock.png"));
|
|
|
|
|
}
|
|
|
|
|
delete createfile;
|
|
|
|
|
createfile = nullptr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if ("m_pbApply" == strObj)
|
|
|
|
|
{
|
|
|
|
|
double realx1 = ui.m_lineEdit_RealP1X->text().toDouble();
|
|
|
|
|
double realy1 = ui.m_lineEdit_RealP1Y->text().toDouble();
|
|
|
|
|
double realx2 = ui.m_lineEdit_RealP2X->text().toDouble();
|
|
|
|
|
double realy2 = ui.m_lineEdit_RealP2Y->text().toDouble();
|
|
|
|
|
double realx3 = ui.m_lineEdit_RealP3X->text().toDouble();
|
|
|
|
|
double realy3 = ui.m_lineEdit_RealP3Y->text().toDouble();
|
|
|
|
|
double realx4 = ui.m_lineEdit_RealP4X->text().toDouble();
|
|
|
|
|
double realy4 = ui.m_lineEdit_RealP4Y->text().toDouble();
|
|
|
|
|
|
|
|
|
|
QPointF realPoint1 = QPointF(realx1, realy1);
|
|
|
|
|
QPointF realPoint2 = QPointF(realx2, realy2);
|
|
|
|
|
QPointF realPoint3 = QPointF(realx3, realy3);
|
|
|
|
|
QPointF realPoint4 = QPointF(realx4, realy4);
|
|
|
|
|
|
|
|
|
|
lpGlobalConfig::instance()->stationParam1.Realpoint1 = realPoint1;
|
|
|
|
|
lpGlobalConfig::instance()->stationParam1.Realpoint2 = realPoint2;
|
|
|
|
|
lpGlobalConfig::instance()->stationParam1.Realpoint3 = realPoint3;
|
|
|
|
|
lpGlobalConfig::instance()->stationParam1.Realpoint4 = realPoint4;
|
|
|
|
|
|
|
|
|
|
lpGlobalConfig::instance()->stationParam1.testPoint = m_testPoint_1;
|
|
|
|
|
QPolygonF srcPoly;
|
|
|
|
|
QPolygonF dstPoly;
|
|
|
|
|
srcPoly << m_point1_1 << m_point2_1 << m_point3_1 << m_point4_1;
|
|
|
|
|
dstPoly << realPoint1 << realPoint2 << realPoint3 << realPoint4;
|
|
|
|
|
lpGlobalConfig::instance()->stationParam1.matix = gentransform(srcPoly, dstPoly);
|
|
|
|
|
|
|
|
|
|
QPointF temPoint = transWorldPoint(m_testPoint_1, lpGlobalConfig::instance()->stationParam1.matix);
|
|
|
|
|
ui.label_testPixPoint->setText(QString("(%1,%2)").arg(m_testPoint_1.x()).arg(m_testPoint_1.y()));
|
|
|
|
|
ui.label_testRealPoint->setText(QString("(%1,%2)").arg(temPoint.x()).arg(temPoint.y()));
|
|
|
|
|
|
|
|
|
|
lpGlobalConfig::instance()->stationParam1.bXYTrans = ui.checkBox_XY_1->isChecked();//输出坐标取反
|
|
|
|
|
lpGlobalConfig::instance()->stationParam1.xPointOffset = ui.m_lineEdit_Xoffset->text().toDouble();
|
|
|
|
|
lpGlobalConfig::instance()->stationParam1.yPointOffset = ui.m_lineEdit_Yoffset->text().toDouble();
|
|
|
|
|
lpGlobalConfig::instance()->stationParam1.Pixpoint1 = m_point1_1;
|
|
|
|
|
lpGlobalConfig::instance()->stationParam1.Pixpoint2 = m_point2_1;
|
|
|
|
|
lpGlobalConfig::instance()->stationParam1.Pixpoint3 = m_point3_1;
|
|
|
|
|
lpGlobalConfig::instance()->stationParam1.Pixpoint4 = m_point4_1;
|
|
|
|
|
lpGlobalConfig::instance()->writeConfig();
|
|
|
|
|
ui.label_info->setText("参数已生效");
|
|
|
|
|
ui.label_info->setStyleSheet("background-color: rgb(255, 168, 55);");
|
|
|
|
|
if (m_timerID == 0)
|
|
|
|
|
{
|
|
|
|
|
m_timerID = startTimer(1000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if ("m_pbApply_2" == strObj)
|
|
|
|
|
{
|
|
|
|
|
double realx1 = ui.m_lineEdit_RealP1X_2->text().toDouble();
|
|
|
|
|
double realy1 = ui.m_lineEdit_RealP1Y_2->text().toDouble();
|
|
|
|
|
double realx2 = ui.m_lineEdit_RealP2X_2->text().toDouble();
|
|
|
|
|
double realy2 = ui.m_lineEdit_RealP2Y_2->text().toDouble();
|
|
|
|
|
double realx3 = ui.m_lineEdit_RealP3X_2->text().toDouble();
|
|
|
|
|
double realy3 = ui.m_lineEdit_RealP3Y_2->text().toDouble();
|
|
|
|
|
double realx4 = ui.m_lineEdit_RealP4X_2->text().toDouble();
|
|
|
|
|
double realy4 = ui.m_lineEdit_RealP4Y_2->text().toDouble();
|
|
|
|
|
|
|
|
|
|
QPointF realPoint1 = QPointF(realx1, realy1);
|
|
|
|
|
QPointF realPoint2 = QPointF(realx2, realy2);
|
|
|
|
|
QPointF realPoint3 = QPointF(realx3, realy3);
|
|
|
|
|
QPointF realPoint4 = QPointF(realx4, realy4);
|
|
|
|
|
|
|
|
|
|
lpGlobalConfig::instance()->stationParam2.Realpoint1 = realPoint1;
|
|
|
|
|
lpGlobalConfig::instance()->stationParam2.Realpoint2 = realPoint2;
|
|
|
|
|
lpGlobalConfig::instance()->stationParam2.Realpoint3 = realPoint3;
|
|
|
|
|
lpGlobalConfig::instance()->stationParam2.Realpoint4 = realPoint4;
|
|
|
|
|
|
|
|
|
|
lpGlobalConfig::instance()->stationParam2.testPoint = m_testPoint_2;
|
|
|
|
|
QPolygonF srcPoly;
|
|
|
|
|
QPolygonF dstPoly;
|
|
|
|
|
srcPoly << m_point1_2 << m_point2_2 << m_point3_2 << m_point4_2;
|
|
|
|
|
dstPoly << realPoint1 << realPoint2 << realPoint3 << realPoint4;
|
|
|
|
|
lpGlobalConfig::instance()->stationParam2.matix = gentransform(srcPoly, dstPoly);
|
|
|
|
|
|
|
|
|
|
QPointF temPoint = transWorldPoint(m_testPoint_2, lpGlobalConfig::instance()->stationParam2.matix);
|
|
|
|
|
ui.label_testPixPoint_2->setText(QString("(%1,%2)").arg(m_testPoint_2.x()).arg(m_testPoint_2.y()));
|
|
|
|
|
ui.label_testRealPoint_2->setText(QString("(%1,%2)").arg(temPoint.x()).arg(temPoint.y()));
|
|
|
|
|
|
|
|
|
|
lpGlobalConfig::instance()->stationParam2.bXYTrans = ui.checkBox_XY_2->isChecked();//输出坐标取反
|
|
|
|
|
lpGlobalConfig::instance()->stationParam2.xPointOffset = ui.m_lineEdit_Xoffset_2->text().toDouble();
|
|
|
|
|
lpGlobalConfig::instance()->stationParam2.yPointOffset = ui.m_lineEdit_Yoffset_2->text().toDouble();
|
|
|
|
|
lpGlobalConfig::instance()->stationParam2.Pixpoint1 = m_point1_2;
|
|
|
|
|
lpGlobalConfig::instance()->stationParam2.Pixpoint2 = m_point2_2;
|
|
|
|
|
lpGlobalConfig::instance()->stationParam2.Pixpoint3 = m_point3_2;
|
|
|
|
|
lpGlobalConfig::instance()->stationParam2.Pixpoint4 = m_point4_2;
|
|
|
|
|
lpGlobalConfig::instance()->writeConfig();
|
|
|
|
|
ui.label_info_2->setText("参数已生效");
|
|
|
|
|
ui.label_info_2->setStyleSheet("background-color: rgb(255, 168, 55);");
|
|
|
|
|
if (m_timerID == 0)
|
|
|
|
|
{
|
|
|
|
|
m_timerID = startTimer(1000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if ("m_pbExit" == strObj)
|
|
|
|
|
{
|
|
|
|
|
close();
|
|
|
|
|
}
|
|
|
|
|
else if ("m_pbLock" == strObj)
|
|
|
|
|
{
|
|
|
|
|
QString str = ui.m_pbLock->text();
|
|
|
|
|
if (str == tr("解锁")) {
|
|
|
|
|
ui.m_pbLock->setText(tr("上锁"));
|
|
|
|
|
ui.m_pbLock->setIcon(QIcon(":/Resource/lock-open.png"));
|
|
|
|
|
if (m_srcImgView_1)
|
|
|
|
|
{
|
|
|
|
|
m_srcImgView_1->setLockAll(false);
|
|
|
|
|
}
|
|
|
|
|
ui.label_info->setText("已解锁");
|
|
|
|
|
ui.label_info->setStyleSheet("background-color: rgb(255, 168, 55);");
|
|
|
|
|
if (m_timerID == 0)
|
|
|
|
|
{
|
|
|
|
|
m_timerID = startTimer(1000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (m_srcImgView_1)
|
|
|
|
|
{
|
|
|
|
|
m_srcImgView_1->setLockAll(true);
|
|
|
|
|
}
|
|
|
|
|
ui.m_pbLock->setText(tr("解锁"));
|
|
|
|
|
ui.m_pbLock->setIcon(QIcon(":/Resource/lock.png"));
|
|
|
|
|
ui.label_info->setText("已上锁");
|
|
|
|
|
ui.label_info->setStyleSheet("background-color: rgb(255, 168, 55);");
|
|
|
|
|
if (m_timerID == 0)
|
|
|
|
|
{
|
|
|
|
|
m_timerID = startTimer(1000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if ("m_pbLock_2" == strObj)
|
|
|
|
|
{
|
|
|
|
|
QString str = ui.m_pbLock_2->text();
|
|
|
|
|
if (str == tr("解锁")) {
|
|
|
|
|
ui.m_pbLock_2->setText(tr("上锁"));
|
|
|
|
|
ui.m_pbLock_2->setIcon(QIcon(":/Resource/lock-open.png"));
|
|
|
|
|
if (m_srcImgView_2)
|
|
|
|
|
{
|
|
|
|
|
m_srcImgView_2->setLockAll(false);
|
|
|
|
|
}
|
|
|
|
|
ui.label_info_2->setText("已解锁");
|
|
|
|
|
ui.label_info_2->setStyleSheet("background-color: rgb(255, 168, 55);");
|
|
|
|
|
if (m_timerID == 0)
|
|
|
|
|
{
|
|
|
|
|
m_timerID = startTimer(1000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (m_srcImgView_2)
|
|
|
|
|
{
|
|
|
|
|
m_srcImgView_2->setLockAll(true);
|
|
|
|
|
}
|
|
|
|
|
ui.m_pbLock_2->setText(tr("解锁"));
|
|
|
|
|
ui.m_pbLock_2->setIcon(QIcon(":/Resource/lock.png"));
|
|
|
|
|
|
|
|
|
|
ui.label_info_2->setText("已上锁");
|
|
|
|
|
ui.label_info_2->setStyleSheet("background-color: rgb(255, 168, 55);");
|
|
|
|
|
if (m_timerID == 0)
|
|
|
|
|
{
|
|
|
|
|
m_timerID = startTimer(1000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Q_SLOT void lpImageCaliUI4P::onROIChange(const AwesomeRoiInfo& roiInfo, QString strID)
|
|
|
|
|
{
|
|
|
|
|
if (sender() == m_srcImgView_1)
|
|
|
|
|
{
|
|
|
|
|
if (strID == "P1")
|
|
|
|
|
{
|
|
|
|
|
QPointF p = roiInfo.vertex.at(0);
|
|
|
|
|
m_point1_1.setX(p.x());
|
|
|
|
|
m_point1_1.setY(p.y());
|
|
|
|
|
ui.m_lineEdit_P1X->setText(QString("%1").arg(m_point1_1.x()));
|
|
|
|
|
ui.m_lineEdit_P1Y->setText(QString("%1").arg(m_point1_1.y()));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (strID == "P2")
|
|
|
|
|
{
|
|
|
|
|
QPointF p = roiInfo.vertex.at(0);
|
|
|
|
|
m_point2_1.setX(p.x());
|
|
|
|
|
m_point2_1.setY(p.y());
|
|
|
|
|
ui.m_lineEdit_P2X->setText(QString("%1").arg(m_point2_1.x()));
|
|
|
|
|
ui.m_lineEdit_P2Y->setText(QString("%1").arg(m_point2_1.y()));
|
|
|
|
|
}
|
|
|
|
|
else if (strID == "P3")
|
|
|
|
|
{
|
|
|
|
|
QPointF p = roiInfo.vertex.at(0);
|
|
|
|
|
m_point3_1.setX(p.x());
|
|
|
|
|
m_point3_1.setY(p.y());
|
|
|
|
|
ui.m_lineEdit_P3X->setText(QString("%1").arg(m_point3_1.x()));
|
|
|
|
|
ui.m_lineEdit_P3Y->setText(QString("%1").arg(m_point3_1.y()));
|
|
|
|
|
}
|
|
|
|
|
else if (strID == "P4")
|
|
|
|
|
{
|
|
|
|
|
QPointF p = roiInfo.vertex.at(0);
|
|
|
|
|
m_point4_1.setX(p.x());
|
|
|
|
|
m_point4_1.setY(p.y());
|
|
|
|
|
ui.m_lineEdit_P4X->setText(QString("%1").arg(m_point4_1.x()));
|
|
|
|
|
ui.m_lineEdit_P4Y->setText(QString("%1").arg(m_point4_1.y()));
|
|
|
|
|
}
|
|
|
|
|
else if (strID == "Test")
|
|
|
|
|
{
|
|
|
|
|
QPointF p = roiInfo.vertex.at(0);
|
|
|
|
|
m_testPoint_1.setX(p.x());
|
|
|
|
|
m_testPoint_1.setY(p.y());
|
|
|
|
|
QPointF temPoint = transWorldPoint(m_testPoint_1, lpGlobalConfig::instance()->stationParam1.matix);
|
|
|
|
|
ui.label_testPixPoint->setText(QString("(%1,%2)").arg(m_testPoint_1.x()).arg(m_testPoint_1.y()));
|
|
|
|
|
ui.label_testRealPoint->setText(QString("(%1,%2)").arg(temPoint.x()).arg(temPoint.y()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (sender() == m_srcImgView_2)
|
|
|
|
|
{
|
|
|
|
|
if (strID == "P1")
|
|
|
|
|
{
|
|
|
|
|
QPointF p = roiInfo.vertex.at(0);
|
|
|
|
|
m_point1_2.setX(p.x());
|
|
|
|
|
m_point1_2.setY(p.y());
|
|
|
|
|
ui.m_lineEdit_P1X_2->setText(QString("%1").arg(m_point1_2.x()));
|
|
|
|
|
ui.m_lineEdit_P1Y_2->setText(QString("%1").arg(m_point1_2.y()));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (strID == "P2")
|
|
|
|
|
{
|
|
|
|
|
QPointF p = roiInfo.vertex.at(0);
|
|
|
|
|
m_point2_2.setX(p.x());
|
|
|
|
|
m_point2_2.setY(p.y());
|
|
|
|
|
ui.m_lineEdit_P2X_2->setText(QString("%1").arg(m_point2_2.x()));
|
|
|
|
|
ui.m_lineEdit_P2Y_2->setText(QString("%1").arg(m_point2_2.y()));
|
|
|
|
|
}
|
|
|
|
|
else if (strID == "P3")
|
|
|
|
|
{
|
|
|
|
|
QPointF p = roiInfo.vertex.at(0);
|
|
|
|
|
m_point3_2.setX(p.x());
|
|
|
|
|
m_point3_2.setY(p.y());
|
|
|
|
|
ui.m_lineEdit_P3X_2->setText(QString("%1").arg(m_point3_2.x()));
|
|
|
|
|
ui.m_lineEdit_P3Y_2->setText(QString("%1").arg(m_point3_2.y()));
|
|
|
|
|
}
|
|
|
|
|
else if (strID == "P4")
|
|
|
|
|
{
|
|
|
|
|
QPointF p = roiInfo.vertex.at(0);
|
|
|
|
|
m_point4_2.setX(p.x());
|
|
|
|
|
m_point4_2.setY(p.y());
|
|
|
|
|
ui.m_lineEdit_P4X_2->setText(QString("%1").arg(m_point4_2.x()));
|
|
|
|
|
ui.m_lineEdit_P4Y_2->setText(QString("%1").arg(m_point4_2.y()));
|
|
|
|
|
}
|
|
|
|
|
else if (strID == "Test")
|
|
|
|
|
{
|
|
|
|
|
QPointF p = roiInfo.vertex.at(0);
|
|
|
|
|
m_testPoint_2.setX(p.x());
|
|
|
|
|
m_testPoint_2.setY(p.y());
|
|
|
|
|
QPointF temPoint = transWorldPoint(m_testPoint_2, lpGlobalConfig::instance()->stationParam2.matix);
|
|
|
|
|
ui.label_testPixPoint_2->setText(QString("(%1,%2)").arg(m_testPoint_2.x()).arg(m_testPoint_2.y()));
|
|
|
|
|
ui.label_testRealPoint_2->setText(QString("(%1,%2)").arg(temPoint.x()).arg(temPoint.y()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Q_SLOT void lpImageCaliUI4P::onPixelClicked(QPoint point)
|
|
|
|
|
{
|
|
|
|
|
int a = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Q_SLOT void lpImageCaliUI4P::onImageScale(qreal value)
|
|
|
|
|
{
|
|
|
|
|
if (sender() == m_srcImgView_1)
|
|
|
|
|
{
|
|
|
|
|
QString strPath = QApplication::applicationDirPath() + "/showImg.ini";
|
|
|
|
|
QSettings setting(strPath, QSettings::IniFormat);
|
|
|
|
|
QObject *obj = sender();
|
|
|
|
|
setting.setValue("ShowImg/Scale_Standard_1", value);
|
|
|
|
|
}
|
|
|
|
|
else if (sender() == m_srcImgView_2)
|
|
|
|
|
{
|
|
|
|
|
QString strPath = QApplication::applicationDirPath() + "/showImg.ini";
|
|
|
|
|
QSettings setting(strPath, QSettings::IniFormat);
|
|
|
|
|
QObject *obj = sender();
|
|
|
|
|
setting.setValue("ShowImg/Scale_Standard_2", value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void lpImageCaliUI4P::AddPoint(QPoint &p, QString strName,QColor color/* = QColor(0, 255, 0)*/)
|
|
|
|
|
{
|
|
|
|
|
if (m_srcImgView_1)
|
|
|
|
|
{
|
|
|
|
|
int x = p.x();
|
|
|
|
|
int y = p.y();
|
|
|
|
|
int xp = (x - m_imageW_1 / 2);
|
|
|
|
|
int yp = (y - m_imageH_1 / 2);
|
|
|
|
|
m_srcImgView_1->addPointRoi(QPointF(xp, yp), lpGlobalConfig::instance()->pointCircle, 0, strName, color, QColor(255, 0, 255));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void lpImageCaliUI4P::AddPoint_2(QPoint &p, QString strName, QColor color)
|
|
|
|
|
{
|
|
|
|
|
if (m_srcImgView_2)
|
|
|
|
|
{
|
|
|
|
|
int x = p.x();
|
|
|
|
|
int y = p.y();
|
|
|
|
|
int xp = (x - m_imageW_2 / 2);
|
|
|
|
|
int yp = (y - m_imageH_2 / 2);
|
|
|
|
|
m_srcImgView_2->addPointRoi(QPointF(xp, yp), lpGlobalConfig::instance()->pointCircle, 0, strName, color, QColor(255, 0, 255));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Q_SLOT void lpImageCaliUI4P::onRoiLockIng(QString strName)
|
|
|
|
|
{
|
|
|
|
|
if (sender() == m_srcImgView_1)
|
|
|
|
|
{
|
|
|
|
|
ui.label_info->setText("不能操作,请解锁");
|
|
|
|
|
ui.label_info->setStyleSheet("background-color: rgb(200, 68, 55);");
|
|
|
|
|
if (m_timerID == 0)
|
|
|
|
|
{
|
|
|
|
|
m_timerID = startTimer(1000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (sender() == m_srcImgView_2)
|
|
|
|
|
{
|
|
|
|
|
ui.label_info_2->setText("不能操作,请解锁");
|
|
|
|
|
ui.label_info_2->setStyleSheet("background-color: rgb(200, 68, 55);");
|
|
|
|
|
if (m_timerID == 0)
|
|
|
|
|
{
|
|
|
|
|
m_timerID = startTimer(1000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void lpImageCaliUI4P::timerEvent(QTimerEvent *event)
|
|
|
|
|
{
|
|
|
|
|
if (m_timerID == event->timerId())
|
|
|
|
|
{
|
|
|
|
|
killTimer(m_timerID);
|
|
|
|
|
m_timerID = 0;
|
|
|
|
|
ui.label_info->setText("");
|
|
|
|
|
ui.label_info->setStyleSheet("");
|
|
|
|
|
ui.label_info_2->setText("");
|
|
|
|
|
ui.label_info_2->setStyleSheet("");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|