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.
122 lines
2.9 KiB
C++
122 lines
2.9 KiB
C++
#include "QDebugDlg.h"
|
|
#include "IWheelModel.h"
|
|
#include "QFile"
|
|
#include "QTextStream"
|
|
/*调试窗口*/
|
|
QDebugDlg::QDebugDlg(QWidget *parent)
|
|
: QWidget(parent)
|
|
{
|
|
ui.setupUi(this);
|
|
setWindowIcon(QIcon(":/image/leaper"));
|
|
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("开始模拟检测")) {
|
|
ui.Dlp_StartDetect_button->setText(tr("停止"));
|
|
m_simuliter.start(2000);
|
|
}
|
|
else {
|
|
ui.Dlp_StartDetect_button->setText(tr("开始模拟检测"));
|
|
m_simuliter.stop();
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
Q_SLOT void QDebugDlg::onTimeOut()
|
|
{
|
|
emit sgTriggerCam();
|
|
}
|
|
|
|
void QDebugDlg::changeEvent(QEvent *event)
|
|
{
|
|
if (event->type() == QEvent::LanguageChange)
|
|
{
|
|
ui.retranslateUi(this);
|
|
}
|
|
}
|