You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
wheeldetect/tpvs17/tpMain/QDebugDlg.cpp

113 lines
2.7 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include "QDebugDlg.h"
#include "IWheelModel.h"
#include "QFile"
#include "QTextStream"
QDebugDlg::QDebugDlg(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
connect(ui.Dlp_Next_button_2, SIGNAL(clicked()), this, SLOT(onButtonClicked()));
connect(ui.Dlp_StartDetect_button, SIGNAL(clicked()), this, SLOT(onButtonClicked()));
connect(&m_simuliter, SIGNAL(timeout()), this, SLOT(onTimeOut()));
}
QDebugDlg::~QDebugDlg()
{
if (m_simuliter.isActive())
{
m_simuliter.stop();
}
}
void QDebugDlg::onShowResult(Result2Ui* pRlt)
{
ui.Dlp_Result_Img;
ui.Dlp_model_id_label;
ui.Dlp_model_rota_label;
ui.Dlp_height_label;
ui.Dlp_diamer_label;
// show result
if (!pRlt) {
return;
}
if (m_pCtrl) {
IWheelModel *pModel = m_pCtrl->getModel(pRlt->m_strModel);
if (pModel) {
ui.Dlp_diamer_label->setText(QString::number(pModel->getDiameter()));
ui.Dlp_height_label->setText(QString::number(pModel->getThickness()));
ui.Dlp_model_id_label->setText(pModel->getModelID());
ui.Dlp_model_rota_label->setText(QString::number(pRlt->m_dMinDis));
/* if (m_pState->m_SaveD2HCsv == 1)
{
QString strPath = m_pCtrl->appRoot() + "//user//diameter2thickness.csv";
QFile qFile(strPath);
qFile.open(QIODevice::Append | QIODevice::WriteOnly | QIODevice::Text);
QTextStream st(&qFile);
st << pRlt->m_strModel << "," << pRlt->m_dThickness << "," << pRlt->m_dDiameter << "," << pModel->getDiameter() << "\n";
qFile.close();
}
*/
}
else {
ui.Dlp_diamer_label->setText("0");
ui.Dlp_height_label->setText("0");
ui.Dlp_model_id_label->setText("");
}
if (pRlt->m_strModel.isEmpty())
pRlt->m_strModel = "NG";
if (pRlt->m_pixResult.isNull())
{
int dhight = pRlt->m_pixSrc.height();
int dwidth = pRlt->m_pixSrc.width();
double nRate = pRlt->m_pixSrc.width()*1.0 / pRlt->m_pixSrc.height();
int scarew = 300;
int scareh = 300 * 1.0 / nRate;
if (scareh > 300)
{
scarew = 300;
scareh = 300 * 1.0 / nRate;
}
ui.Dlp_Result_Img->setPixmap(pRlt->m_pixSrc.scaled(scarew, scareh));
}
else
ui.Dlp_Result_Img->setPixmap(pRlt->m_pixResult.scaled(300, 300));
//saveImage(pResult);
}
}
void QDebugDlg::onSetCtrl(IWheelCtrl* ptr)
{
m_pCtrl = ptr;
}
Q_SLOT void QDebugDlg::onButtonClicked()
{
QString strObj = sender()->objectName();
if ("Dlp_Next_button_2" == strObj) {
emit sgTriggerCam();
}
else if ("Dlp_StartDetect_button" == strObj) {
if (ui.Dlp_StartDetect_button->text() == tr("<EFBFBD><EFBFBD>ʼģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")) {
ui.Dlp_StartDetect_button->setText(tr("ֹͣ"));
m_simuliter.start(2000);
}
else {
ui.Dlp_StartDetect_button->setText(tr("<EFBFBD><EFBFBD>ʼģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"));
m_simuliter.stop();
}
}
}
Q_SLOT void QDebugDlg::onTimeOut()
{
emit sgTriggerCam();
}