|
|
|
|
@ -74,6 +74,7 @@ static cv::Mat QImageToMat(QImage image) {
|
|
|
|
|
mat = cv::Mat(image.height(), image.width(), CV_8UC3, (void*)image.constBits(), image.bytesPerLine());
|
|
|
|
|
cv::cvtColor(mat, mat, CV_BGR2RGB);
|
|
|
|
|
break;
|
|
|
|
|
case QImage::Format_Grayscale8:
|
|
|
|
|
case QImage::Format_Indexed8:
|
|
|
|
|
mat = cv::Mat(image.height(), image.width(), CV_8UC1, (void*)image.constBits(), image.bytesPerLine());
|
|
|
|
|
break;
|
|
|
|
|
@ -124,12 +125,11 @@ lpMainWin::lpMainWin(QWidget *parent)
|
|
|
|
|
|
|
|
|
|
connect(ui.actionSystemSeting, SIGNAL(triggered()), this, SLOT(onActionClicked()));
|
|
|
|
|
connect(ui.actioncamSetting, SIGNAL(triggered()), this, SLOT(onActionClicked()));
|
|
|
|
|
|
|
|
|
|
connect(ui.btn_start_detect, SIGNAL(clicked()), this, SLOT(onButtonClicked()));
|
|
|
|
|
|
|
|
|
|
ui.action_userManager->setVisible(false);
|
|
|
|
|
QMenu *pToolMenu = new QMenu(this);
|
|
|
|
|
|
|
|
|
|
QMenu *pToolMenu = new QMenu(this);
|
|
|
|
|
pToolMenu->addAction(ui.action_ImageCali);//图像标定
|
|
|
|
|
pToolMenu->addAction(ui.action_debug);
|
|
|
|
|
pToolMenu->addAction(ui.actionSystemSeting);
|
|
|
|
|
@ -163,10 +163,10 @@ lpMainWin::lpMainWin(QWidget *parent)
|
|
|
|
|
ui.mainToolBar->addWidget(m_pLabelInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
{//系统状态栏展示UI初始化
|
|
|
|
|
m_pLbCurrentTime = new QLabel(tr("系统时间"));
|
|
|
|
|
m_pLbDetectState = new QLabel(tr("检测状态"));
|
|
|
|
|
m_pLbUser = new QLabel(tr("用户:"));
|
|
|
|
|
m_pLbUser = new QLabel(tr("用户:"));
|
|
|
|
|
|
|
|
|
|
QFont m_font;
|
|
|
|
|
m_font.setBold(true);
|
|
|
|
|
@ -192,36 +192,38 @@ lpMainWin::lpMainWin(QWidget *parent)
|
|
|
|
|
//加载用户管理模块
|
|
|
|
|
loadUserModel();
|
|
|
|
|
//初始化模型管理模块
|
|
|
|
|
{
|
|
|
|
|
{//模板库核心管理模块 wheelctrl
|
|
|
|
|
m_pCtrl = new WheelCtrl(QCoreApplication::applicationDirPath(), nullptr);
|
|
|
|
|
m_pWorkCtrl = new QWorkMgrCtrl(m_pCtrl);
|
|
|
|
|
m_pWorkCtrl = new QWorkMgrCtrl(m_pCtrl);//工单管理模块
|
|
|
|
|
m_pWorkCtrl->readManageFile();
|
|
|
|
|
m_pWorkUI = new QWorkMgrUI(m_pWorkCtrl, m_pCtrl);
|
|
|
|
|
m_pWorkUI = new QWorkMgrUI(m_pWorkCtrl, m_pCtrl);//工单管理UI
|
|
|
|
|
m_pWorkUI->InitUI();
|
|
|
|
|
connect(m_pWorkUI, SIGNAL(sgUpdatedefect()), this, SLOT(onUpdateDefect()));
|
|
|
|
|
|
|
|
|
|
m_pModelMgrDlg = new QModelMgrDlg(m_pCtrl);//模板管理
|
|
|
|
|
//当某个模板加入训练或者不加入训练时修改原来工作单中的模板信息
|
|
|
|
|
connect(m_pModelMgrDlg, SIGNAL(sgModifyModel(QString)), this, SLOT(modWorkMgr(QString)));
|
|
|
|
|
connect(m_pModelMgrDlg, SIGNAL(sgUpdatedefect()), this, SLOT(onUpdateDefect()));
|
|
|
|
|
|
|
|
|
|
connect(m_pModelMgrDlg, SIGNAL(sgModifyModel(QString)), this, SLOT(modWorkMgr(QString)));//修改模板名
|
|
|
|
|
connect(m_pModelMgrDlg, SIGNAL(sgUpdatedefect()), this, SLOT(onUpdateDefect()));//更新检测列表
|
|
|
|
|
connect(m_pModelMgrDlg, SIGNAL(sgAddNewModel(QString)), this, SLOT(onSlotAddNewModel(QString)));//新建模板型号
|
|
|
|
|
connect(m_pModelMgrDlg, SIGNAL(sgDelOldModel(QString)), this, SLOT(onSlotDelOldModel(QString)));//删除模板型号
|
|
|
|
|
|
|
|
|
|
m_pDebugDlg = new QDebugDlg();//调试界面
|
|
|
|
|
connect(m_pDebugDlg, SIGNAL(sgTriggerCam()), this, SLOT(onTriggerCam()));
|
|
|
|
|
m_pDebugDlg->onSetCtrl(m_pCtrl);
|
|
|
|
|
m_pSystemConfigUI = new lpSystemConfigUI();
|
|
|
|
|
m_CamSettingDlg = new QCamSettingDlg();
|
|
|
|
|
connect(m_pDebugDlg, SIGNAL(sgTriggerCam()), this, SLOT(onTriggerCam()));
|
|
|
|
|
|
|
|
|
|
m_pSystemConfigUI = new lpSystemConfigUI();//系统参数配置页面
|
|
|
|
|
m_CamSettingDlg = new QCamSettingDlg();//相机设置页面
|
|
|
|
|
m_CamSettingDlg->setCoreCtrlPtr(m_pCoreCtrl);
|
|
|
|
|
|
|
|
|
|
//检测结果预览图UI初始化
|
|
|
|
|
m_pixMapList = new QPixmapListBar(ui.tp_main_tabWidget);
|
|
|
|
|
ui.tp_main_tabWidget->insertTab(0, m_pixMapList, tr("历史"));
|
|
|
|
|
ui.tp_main_tabWidget->setCurrentIndex(0);
|
|
|
|
|
|
|
|
|
|
m_pImageCaliUI = new lpImageCaliUI();
|
|
|
|
|
m_pAlgParamDlg = new QAlgParamDlg();
|
|
|
|
|
m_pImageCaliUI = new lpImageCaliUI();//图像标定页面
|
|
|
|
|
m_pAlgParamDlg = new QAlgParamDlg();//算法参数调试页面
|
|
|
|
|
|
|
|
|
|
connect(m_pSystemConfigUI, SIGNAL(sgUpdateInfo()), this, SLOT(setWindowTitleInfo()));
|
|
|
|
|
connect(m_pSystemConfigUI, SIGNAL(sgUpdateInfo()), this, SLOT(setWindowTitleInfo()));//系统标题
|
|
|
|
|
}
|
|
|
|
|
onSetModel();
|
|
|
|
|
{
|
|
|
|
|
@ -230,12 +232,12 @@ lpMainWin::lpMainWin(QWidget *parent)
|
|
|
|
|
connect(this, SIGNAL(sgGetImg()), this, SLOT(onGetImg()));
|
|
|
|
|
connect(this, SIGNAL(sgShowMsgdlg(QString)), this, SLOT(onShowMsg(QString)));
|
|
|
|
|
}
|
|
|
|
|
{//PLC tcp 通讯
|
|
|
|
|
m_pPlcDevice = new QPLCDevice();
|
|
|
|
|
m_pPlcDevice->onInitDevice();
|
|
|
|
|
m_pPlcDevice->onStartServer(lpGlobalConfig::instance()->tcpServerPort);
|
|
|
|
|
connect(m_pPlcDevice, SIGNAL(sgTrigerCam(int)), this, SLOT(onPLCTrigerCam(int)));
|
|
|
|
|
}
|
|
|
|
|
//{//PLC tcp 通讯
|
|
|
|
|
// m_pPlcDevice = new QPLCDevice();
|
|
|
|
|
// m_pPlcDevice->onInitDevice();
|
|
|
|
|
// m_pPlcDevice->onStartServer(lpGlobalConfig::instance()->tcpServerPort);
|
|
|
|
|
// connect(m_pPlcDevice, SIGNAL(sgTrigerCam(int)), this, SLOT(onPLCTrigerCam(int)));
|
|
|
|
|
//}
|
|
|
|
|
{
|
|
|
|
|
QTimer::singleShot(3000, [&]() {
|
|
|
|
|
ui.btn_start_detect->setText(tr("停止检测"));
|
|
|
|
|
@ -371,11 +373,11 @@ lpMainWin::~lpMainWin()
|
|
|
|
|
delete m_pDesigner;
|
|
|
|
|
m_pDesigner = nullptr;
|
|
|
|
|
}
|
|
|
|
|
if (m_pPlcDevice)
|
|
|
|
|
{
|
|
|
|
|
delete m_pPlcDevice;
|
|
|
|
|
m_pPlcDevice = nullptr;
|
|
|
|
|
}
|
|
|
|
|
//if (m_pPlcDevice)
|
|
|
|
|
//{
|
|
|
|
|
// delete m_pPlcDevice;
|
|
|
|
|
// m_pPlcDevice = nullptr;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
if (m_pDllCoreCtrl)
|
|
|
|
|
{
|
|
|
|
|
@ -405,7 +407,14 @@ bool lpMainWin::onInitCoreCtrl()
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
m_pCoreCtrl = m_pDllCoreCtrl->m_pCoreCtrl;
|
|
|
|
|
|
|
|
|
|
if (m_pCoreCtrl == nullptr)//corectrl 加载失败
|
|
|
|
|
{
|
|
|
|
|
QMessageBox infobox(QMessageBox::Critical, tr("提示"), tr("Corectrl模块加载失败,请检查!"), QMessageBox::Yes, this);
|
|
|
|
|
infobox.setWindowIcon(QIcon(":/image/leaper"));
|
|
|
|
|
infobox.setButtonText(QMessageBox::Yes, tr("确认"));
|
|
|
|
|
infobox.exec();
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
FuncCallBack_VarInt getVarfunc = std::bind(&lpMainWin::IGetVariantById, this, std::placeholders::_1);
|
|
|
|
|
m_pCoreCtrl->IRegisterGetVariant(getVarfunc);
|
|
|
|
|
|
|
|
|
|
@ -438,6 +447,14 @@ bool lpMainWin::onInitEngineCtrl()
|
|
|
|
|
if (m_pDllEngineCtrl != nullptr)
|
|
|
|
|
{
|
|
|
|
|
m_pEngineCtrl = m_pDllEngineCtrl->m_pDE;
|
|
|
|
|
if (m_pEngineCtrl == nullptr)
|
|
|
|
|
{
|
|
|
|
|
QMessageBox infobox(QMessageBox::Critical, tr("提示"), tr("lpbengine模块加载失败,请检查!"), QMessageBox::Yes, this);
|
|
|
|
|
infobox.setWindowIcon(QIcon(":/image/leaper"));
|
|
|
|
|
infobox.setButtonText(QMessageBox::Yes, tr("确认"));
|
|
|
|
|
infobox.exec();
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -451,6 +468,13 @@ bool lpMainWin::onInitEngineCtrl()
|
|
|
|
|
{
|
|
|
|
|
m_pDesigner->Initialize(m_pEngineCtrl);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
QMessageBox infobox(QMessageBox::Critical, tr("提示"), tr("lpdesigner模块加载失败,请检查!"), QMessageBox::Yes, this);
|
|
|
|
|
infobox.setWindowIcon(QIcon(":/image/leaper"));
|
|
|
|
|
infobox.setButtonText(QMessageBox::Yes, tr("确认"));
|
|
|
|
|
infobox.exec();
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
@ -1630,10 +1654,10 @@ void lpMainWin::onSaveValveResult(ValueResult &rlt)
|
|
|
|
|
pDB->InsertValueRlt(rlt);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (m_pPlcDevice)
|
|
|
|
|
{
|
|
|
|
|
m_pPlcDevice->onSendValueRlt(rlt);
|
|
|
|
|
}
|
|
|
|
|
//if (m_pPlcDevice)
|
|
|
|
|
//{
|
|
|
|
|
// m_pPlcDevice->onSendValueRlt(rlt);
|
|
|
|
|
//}
|
|
|
|
|
sendWebAlgRlt(rlt);
|
|
|
|
|
|
|
|
|
|
QString strMsg = QString("%1 识别结果:%2 定位角度:%3").arg(QDateTime::currentDateTime().toString("hh:mm:ss")).arg(rlt.strModel).arg(rlt.angle);
|
|
|
|
|
@ -1774,6 +1798,7 @@ void lpMainWin::setMainWindowVisibility(bool state)
|
|
|
|
|
else {
|
|
|
|
|
m_restoreAction->setText(tr("显示界面"));
|
|
|
|
|
hide();
|
|
|
|
|
/*防止子窗口没有关闭的情况下,主窗口关闭了,再关闭子窗口时整个应用被退出*/
|
|
|
|
|
if (m_pAlgParamDlg)
|
|
|
|
|
{
|
|
|
|
|
if (!m_pAlgParamDlg->isHidden())
|
|
|
|
|
@ -1857,7 +1882,7 @@ Q_SLOT void lpMainWin::setWindowTitleInfo()
|
|
|
|
|
m_trayIcon->setToolTip(lpGlobalConfig::instance()->strSysTitle);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//展示检测日志记录
|
|
|
|
|
Q_SLOT void lpMainWin::onShowDetectLog(QString strMsg)
|
|
|
|
|
{
|
|
|
|
|
int size = ui.main_textBrowser->toPlainText().size();
|
|
|
|
|
@ -1865,7 +1890,7 @@ Q_SLOT void lpMainWin::onShowDetectLog(QString strMsg)
|
|
|
|
|
ui.main_textBrowser->clear();
|
|
|
|
|
ui.main_textBrowser->append(strMsg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//根据注册状态启用相关功能
|
|
|
|
|
Q_SLOT void lpMainWin::onLineseCheck(bool bFlag)
|
|
|
|
|
{
|
|
|
|
|
ui.action_modelmgr->setDisabled(!bFlag);
|
|
|
|
|
@ -1901,7 +1926,7 @@ void lpMainWin::onStrongButton()
|
|
|
|
|
|
|
|
|
|
void lpMainWin::tcpServerInit()
|
|
|
|
|
{
|
|
|
|
|
int port = lpGlobalConfig::instance()->webSocketPort;
|
|
|
|
|
int port = lpGlobalConfig::instance()->tcpServerPort;
|
|
|
|
|
TP_TCP_SERVER_PARAM init_param;
|
|
|
|
|
init_param.host_ip_ = "*";
|
|
|
|
|
init_param.port_ = port;
|
|
|
|
|
@ -1958,7 +1983,7 @@ void lpMainWin::paraJson(const QJsonObject& json)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (strcmd == "showWidget")
|
|
|
|
|
else if (strcmd == "showWidget")//接收到显示窗口的命令
|
|
|
|
|
{
|
|
|
|
|
onShowMainWindow();
|
|
|
|
|
}
|
|
|
|
|
@ -1975,7 +2000,7 @@ void lpMainWin::paraJson(const QJsonObject& json)
|
|
|
|
|
|
|
|
|
|
void lpMainWin::onShowMainWindow()
|
|
|
|
|
{
|
|
|
|
|
if (this->isMinimized() == true)
|
|
|
|
|
if (this->isMinimized() == true)//如果窗口是最小化 还原展示
|
|
|
|
|
{
|
|
|
|
|
Qt::WindowStates winStatus = Qt::WindowNoState;
|
|
|
|
|
if (this->windowState() & Qt::WindowMaximized)
|
|
|
|
|
@ -1987,7 +2012,7 @@ void lpMainWin::onShowMainWindow()
|
|
|
|
|
this->activateWindow();
|
|
|
|
|
this->showNormal();
|
|
|
|
|
}
|
|
|
|
|
if (this->isHidden())
|
|
|
|
|
if (this->isHidden())//如果窗口是隐藏 在后台运行的,展示为活动窗口
|
|
|
|
|
{
|
|
|
|
|
Qt::WindowStates winStatus = Qt::WindowNoState;
|
|
|
|
|
if (this->windowState() & Qt::WindowMaximized)
|
|
|
|
|
@ -2000,7 +2025,7 @@ void lpMainWin::onShowMainWindow()
|
|
|
|
|
this->raise();
|
|
|
|
|
this->show();
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
else {//如果窗口已经展示,在其他程序后面,则把窗口重新展示到桌面的最顶层
|
|
|
|
|
QRect curGemRect = this->geometry();
|
|
|
|
|
|
|
|
|
|
//激活mpWindow窗体为桌面的顶层窗体
|
|
|
|
|
@ -2018,7 +2043,7 @@ void lpMainWin::onShowMainWindow()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void lpMainWin::AckTriggerCam()
|
|
|
|
|
{
|
|
|
|
|
{//相机触发应答数据 应答数据发给valueMain应用程序 tcp发送
|
|
|
|
|
if (tcp_server_ptr_)
|
|
|
|
|
{
|
|
|
|
|
QJsonObject ackObj;
|
|
|
|
|
|