diff --git a/src/tpMain/ModelMgrUi.cpp b/src/tpMain/ModelMgrUi.cpp index 628e8a8..1699098 100644 --- a/src/tpMain/ModelMgrUi.cpp +++ b/src/tpMain/ModelMgrUi.cpp @@ -1,4 +1,4 @@ -#include "ModelMgrUi.h" +/*#include "ModelMgrUi.h" #include "qlistwidget.h" #include "ModelTableView.h" #include "ModelManager.h" @@ -388,7 +388,7 @@ Q_SLOT void ModelMgrUi::onModifyModel() templatepath += strModel; templatepath += "\\model.yml"; std::string strS = templatepath.toLocal8Bit().toStdString(); - pModel->getImageComModel()->save2file(strS/*string((const char *)templatepath.toLocal8Bit())*/); + pModel->getImageComModel()->save2file(strS); m_pModelMgr->modModel(strModel); m_pModelMgr->saveModel(strModel); QString str = m_pCtrl->getUserName() + ":" + QString("%1:%2 %3").arg(tr("修改了模板")).arg(strModel).arg(tr("的参数")); @@ -592,9 +592,6 @@ void ModelMgrUi::updateWidget(QString str) m_pListWgtImages->setViewMode(QListView::IconMode); m_pListWgtImages->clear(); m_pListWgtImages->setProperty("model", str); - /* - 这里可能存在内存泄露 暂时未找到解决的办法 - */ m_pListWgtImages->setIconSize(QSize(WS_PICSIZELIST_ITEM, WS_PICSIZELIST_ITEM)); m_pListWgtImages->setAcceptDrops(false); std::vector imgTemplateLib = m_pModelMgr->getTmpImage(str)->getVectors(); @@ -864,17 +861,17 @@ void ModelMgrUi::TrainAllTskFunc() m_compareModel->setIsEnableCache(true); if (m_trainAllTsk->getStopFlag()) break; - /*if (pModel->getDiameter() && pModel->getThickness()) - { - m_compareModel->setRealWidth(pModel->getDiameter()); - m_compareModel->setRealHeight(pModel->getThickness()); - }*/ + //if (pModel->getDiameter() && pModel->getThickness()) + //{ + // m_compareModel->setRealWidth(pModel->getDiameter()); + // m_compareModel->setRealHeight(pModel->getThickness()); + //} //for (int h = 0; h < m_modelInfo.size(); h++) //{ //const vector& vectorMats = m_modelInfo[h].mpAllImage; - /*double md_diameter = m_modelInfo[h].md_diameter; - double md_height = m_modelInfo[h].md_height;*/ + //double md_diameter = m_modelInfo[h].md_diameter; + //double md_height = m_modelInfo[h].md_height; m_compareModel->computeDisThre(falseSamples, NULL); //} @@ -882,13 +879,13 @@ void ModelMgrUi::TrainAllTskFunc() break; double m_double = m_compareModel->getDisThre(); qWarning() << m_modelName << ":" << "disthre" << m_double; - /******************************************************************/ + QString templatepath = m_pCtrl->appRoot() + "\\pattern\\template\\"; templatepath += m_modelName; templatepath += "\\model.yml"; std::string strS = templatepath.toLocal8Bit().toStdString(); - m_compareModel->save2file(strS/*string((const char *)templatepath.toLocal8Bit())*/); + m_compareModel->save2file(strS); cv::Mat dst = m_compareModel->getM8uMaskImg(); QImage img(dst.data, dst.cols, dst.rows, dst.cols, QImage::Format_Indexed8); QPixmap pix = QPixmap::fromImage(img); @@ -988,7 +985,6 @@ void ModelMgrUi::TrainOneTskFunc() } if (m_trainOneTsk->getStopFlag()) return; - /*这里需要加载提示 说明模板正在训练*/ emit sgPrograssShow(tr("模板训练进度"), str, 1, emPross_SetValue); ImageCompareModel *m_compareModel = pModel->getImageComModel(); @@ -1044,7 +1040,7 @@ void ModelMgrUi::TrainOneTskFunc() templatepath += "\\model.yml"; m_compareModel->setName(m_strTrainModel.toLatin1().data()); std::string strS = templatepath.toLocal8Bit().toStdString(); - m_compareModel->save2file(strS/*string((const char *)templatepath.toLocal8Bit())*/);//////////////////////////////save params + m_compareModel->save2file(strS);//////////////////////////////save params if (pModel->getPicPath().isEmpty()) { QString modelName = pModel->getModelID(); @@ -1071,12 +1067,10 @@ void ModelMgrUi::TrainOneTskFunc() //for (int h = 0; h < m_modelInfo.size(); h++) //{ //const vector& vectorMats = m_modelInfo[h].mpAllImage; - /*double md_diameter = m_modelInfo[h].md_diameter; - double md_height = m_modelInfo[h].md_height;*/ m_compareModel->computeDisThre(falseSamples, NULL); //} strS = templatepath.toLocal8Bit().toStdString(); - m_compareModel->save2file(strS/*string((const char *)templatepath.toLocal8Bit())*/); + m_compareModel->save2file(strS); if (m_trainOneTsk->getStopFlag()) return; emit sgPrograssShow(tr("模板训练进度"), str, 6, emPross_SetValue); @@ -1187,3 +1181,4 @@ bool ModelMgrUi::onMessageBox(QMessageBox::Icon ntype, QString strTitle, QString return (infobox.exec() == QMessageBox::Ok); } +*/ \ No newline at end of file diff --git a/src/tpMain/ModelMgrUi.h b/src/tpMain/ModelMgrUi.h index 1239af5..e1c82e4 100644 --- a/src/tpMain/ModelMgrUi.h +++ b/src/tpMain/ModelMgrUi.h @@ -1,4 +1,4 @@ -#pragma once +/*#pragma once #include "qlistwidget.h" #include "IWheelUi.h" #include "QObjectCleanupHandler" @@ -93,3 +93,4 @@ private: bool m_modLib; }; +*/ \ No newline at end of file diff --git a/src/tpMain/ProgressView.cpp b/src/tpMain/ProgressView.cpp index 441452f..e91d94f 100644 --- a/src/tpMain/ProgressView.cpp +++ b/src/tpMain/ProgressView.cpp @@ -5,13 +5,16 @@ #include "qcoreapplication.h" #pragma execution_character_set("utf-8") -ProgressView::ProgressView() +ProgressView::ProgressView(QWidget* parent) { nCancel = false; - m_pProgressDialog = new QProgressDialog; - m_pProgressDialog->setWindowFlags(Qt::Dialog); - m_pProgressDialog->setWindowFlags(Qt::WindowCloseButtonHint); + m_pProgressDialog = new QProgressDialog(parent); connect(m_pProgressDialog, SIGNAL(canceled()), this, SIGNAL(cancel())); + + m_pProgressDialog->setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint); + m_pProgressDialog->setWindowIcon(QIcon(":/resource/logo-8.png")); + m_pProgressDialog->setWindowModality(Qt::ApplicationModal); + m_pProgressDialog->setAttribute(Qt::WA_ShowModal, true); } ProgressView::ProgressView(QString strTitle, QString strLabel, int nMax, QString strIcon) @@ -20,6 +23,7 @@ ProgressView::ProgressView(QString strTitle, QString strLabel, int nMax, QString m_pProgressDialog = new QProgressDialog; m_pProgressDialog->setWindowFlags(Qt::Dialog); connect(m_pProgressDialog, SIGNAL(canceled()), this, SIGNAL(cancel())); + m_pProgressDialog->hide(); show(strTitle, strLabel, nMax, strIcon); } @@ -40,6 +44,8 @@ ProgressView::~ProgressView() bool ProgressView::show(QString strTitle, QString strLabel, int nMax, QString strIcon) { + + m_pProgressDialog->setWindowTitle(strTitle); m_pProgressDialog->setWindowIcon(QIcon(strIcon)); m_pProgressDialog->setLabelText(strLabel); @@ -47,7 +53,6 @@ bool ProgressView::show(QString strTitle, QString strLabel, int nMax, QString st if (nCancel==false) m_pProgressDialog->setCancelButton(0); m_pProgressDialog->setCancelButtonText(tr("取消")); - m_pProgressDialog->setWindowModality(Qt::ApplicationModal); m_pProgressDialog->show(); return true; } @@ -70,7 +75,7 @@ bool ProgressView::finish() // m_pProgressDialog->deleteLater(); // m_pProgressDialog = NULL; } - qApp->processEvents(); + //qApp->processEvents(); return true; } @@ -96,6 +101,13 @@ void ProgressView::setRange(int nMax, int nMin /*= 0*/) } } +void ProgressView::hide() +{ + if (m_pProgressDialog) { + m_pProgressDialog->hide(); + } +} + QStringList FileOper::selectFiles(QString strTitle, QString strFilter, QString strDir) { QFileDialog fileDialog; diff --git a/src/tpMain/ProgressView.h b/src/tpMain/ProgressView.h index 7a79c68..6b65fb4 100644 --- a/src/tpMain/ProgressView.h +++ b/src/tpMain/ProgressView.h @@ -6,7 +6,7 @@ class ProgressView:public QObject { Q_OBJECT public: - ProgressView(); + ProgressView(QWidget* parent); ProgressView(QString strTitle, QString strLabel, int nMax, QString strIcon); ~ProgressView(); @@ -17,6 +17,7 @@ public: void setLabel(QString strText); void setRange(int nMax, int nMin = 0); void setUseCancel(bool m_cancel){ nCancel = m_cancel; }; + void hide(); signals: void cancel(); private: diff --git a/src/tpMain/WheelUis.cpp b/src/tpMain/WheelUis.cpp index 96e689c..a929b05 100644 --- a/src/tpMain/WheelUis.cpp +++ b/src/tpMain/WheelUis.cpp @@ -20,7 +20,7 @@ WheelUis::WheelUis(IWheelCtrl *pCtrl) { m_mpUis.insert(WHEEL_UI_DEVELOP, new DevelopUi(WHEEL_UI_DEVELOP, m_pCtrl)); m_mpUis.insert(WHEEL_UI_CHANNEL, new CHannelUI(WHEEL_UI_CHANNEL, m_pCtrl)); - m_mpUis.insert(WHEEL_UI_MODELMGR, new ModelMgrUi(WHEEL_UI_MODELMGR, m_pCtrl)); +// m_mpUis.insert(WHEEL_UI_MODELMGR, new ModelMgrUi(WHEEL_UI_MODELMGR, m_pCtrl)); m_mpUis.insert(WHEEL_UI_CONMODE, new ConnectModeUi(WHEEL_UI_CONMODE, m_pCtrl)); m_mpUis.insert(WHEEL_UI_MAINWINDOW, new MainUi(WHEEL_UI_MAINWINDOW, m_pCtrl)); m_mpUis.insert(WHEEL_UI_TIMEMGR, new TimeMgrUi(WHEEL_UI_TIMEMGR, m_pCtrl)); diff --git a/tpvs17/tpMain/QModelMgrDlg.cpp b/tpvs17/tpMain/QModelMgrDlg.cpp index a2a9fc6..03175df 100644 --- a/tpvs17/tpMain/QModelMgrDlg.cpp +++ b/tpvs17/tpMain/QModelMgrDlg.cpp @@ -17,10 +17,20 @@ #define MODEL_UI_ICON_NONE ":/image/none.jpg" #define MODEL_UI_ICON_LEAPER ":/image/leaper" +enum EM_TYPE_PROCESSMODEL +{ + emPross_Init = 0, + emPross_SetValue, + emPross_SetLable, + emPross_Finish, + emPross_enable, + emPross_Disable +}; + #pragma execution_character_set("utf-8") using namespace std; -//QTime m_ticktimer; +QTime m_ticktimer; QModelMgrDlg::QModelMgrDlg(IWheelCtrl *ptr, QWidget *parent) : QWidget(parent),m_pCtrl(ptr) { @@ -34,6 +44,7 @@ QModelMgrDlg::QModelMgrDlg(IWheelCtrl *ptr, QWidget *parent) connect(ui.m_pbAddPic, SIGNAL(clicked()), this, SLOT(onButtonClicked())); connect(ui.m_pbDelAll, SIGNAL(clicked()), this, SLOT(onButtonClicked())); + m_pShowImgList = ui.listWidget; m_pModelMgr = m_pCtrl->getModelMgr(); // m_pState = m_pCtrl->getDetectState(); @@ -47,19 +58,20 @@ QModelMgrDlg::QModelMgrDlg(IWheelCtrl *ptr, QWidget *parent) m_trainOneTsk->loadfunc(this, &QModelMgrDlg::TrainOneTskFunc); - m_pProgressView = new ProgressView(); - Qt::WindowFlags flags = Qt::Dialog; + m_pProgressView = new ProgressView(this); m_pProgressView->setUseCancel(true); connect(m_pProgressView, SIGNAL(cancel()), this, SLOT(onProgassCancel())); - + //m_pProgressView->finish(); + connect(this, SIGNAL(sgPrograssShow(QString, QString, int, int)), this, SLOT(onPrograssShow(QString, QString, int, int))); + connect(this, SIGNAL(sgShowMsg(QString)), this, SLOT(onShowMessage(QString))); { m_pModelLists = new ModelsView(ui.ModelMgr_Models_tableView, m_pModelMgr->getAllModelMapPtr()); m_pModelLists->setHideItems(QStringList() << "NG"); connect(m_pModelLists, SIGNAL(sgSelectModel(QString)), this, SLOT(onShowModelInfo(QString))); - connect(m_pModelLists, SIGNAL(sgSelectModel(QString)), this, SLOT(onShowModelPic(QString))); + //connect(m_pModelLists, SIGNAL(sgSelectModel(QString)), this, SLOT(onShowModelPic(QString))); connect(this, SIGNAL(sgTrainShowInfo(QString)), this, SLOT(onShowModelInfo(QString))); - connect(ui.ModelMgr_showPic_listWidget_tab1, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(onItemDoubleClicked(QListWidgetItem*))); + connect(m_pShowImgList, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(onItemDoubleClicked(QListWidgetItem*))); QString strApp = QApplication::applicationDirPath(); QSettings setting(strApp + "\\user\\systemfile.ini", QSettings::IniFormat); @@ -77,6 +89,11 @@ QModelMgrDlg::QModelMgrDlg(IWheelCtrl *ptr, QWidget *parent) QModelMgrDlg::~QModelMgrDlg() { + for (int nIndex = (m_pShowImgList->count() - 1); nIndex >= 0; nIndex--) { + QListWidgetItem *pItem = m_pShowImgList->takeItem(nIndex); + delete pItem; + } + ui.ModelMgr_find_lineEdit->clear(); if (m_trainAllTsk) { if (m_trainAllTsk->isRunning()) { @@ -112,7 +129,7 @@ void QModelMgrDlg::onSetCtrl(IWheelCtrl* ptr) Q_SLOT void QModelMgrDlg::onAddPic2Model() { - QString strModel = ui.ModelMgr_showPic_listWidget_tab1->property("model").toString(); + QString strModel = m_pShowImgList->property("model").toString(); if (strModel.isEmpty()) { onMessageBox(QMessageBox::Information, tr("ʾ"), tr("ѡһҪ׷ͼͺţ"), 0); return; @@ -162,7 +179,7 @@ Q_SLOT void QModelMgrDlg::onAddPic2Model() Q_SLOT void QModelMgrDlg::onModifyModel() { - QString strModel = ui.ModelMgr_showPic_listWidget_tab1->property("model").toString(); + QString strModel = m_pShowImgList->property("model").toString(); if (strModel.isEmpty()) { onMessageBox(QMessageBox::Information, tr("ʾ"), tr("ѡһҪ޸ĵͺţ"), 0); return; @@ -201,7 +218,7 @@ Q_SLOT void QModelMgrDlg::onModifyModel() Q_SLOT void QModelMgrDlg::onDelModel() { - QString strModel = ui.ModelMgr_showPic_listWidget_tab1->property("model").toString(); + QString strModel = m_pShowImgList->property("model").toString(); if (strModel.isEmpty()) { onMessageBox(QMessageBox::Information, tr("ʾ"), tr("ѡһҪɾͺ"), 0); return; @@ -274,13 +291,13 @@ Q_SLOT void QModelMgrDlg::onTrainModel() { if (m_trainOneTsk) { if (!m_trainOneTsk->isRunning()) { - QString strModel = ui.ModelMgr_showPic_listWidget_tab1->property("model").toString(); + QString strModel = m_pShowImgList->property("model").toString(); if (strModel.isEmpty()) { onMessageBox(QMessageBox::Information, tr("ʾ"), tr("ѡһҪѵͺţ"), 0); return; } m_strTrainModel = strModel; - //m_ticktimer.start(); + m_ticktimer.start(); m_trainOneTsk->InitStopFlag(); m_trainOneTsk->start(); } @@ -298,7 +315,7 @@ Q_SLOT void QModelMgrDlg::onTrainAllModels() if (!m_trainAllTsk->isRunning()) { if (onMessageBox(QMessageBox::Warning, tr("ʾ"), tr("ͺģѵڼϵͳļ⹦ֱܽģѵɣȫѵģ彫Ҫܳʱ䣬ڼ佫ܽǷִУ"), 1) == false) return; - //m_ticktimer.start(); + m_ticktimer.start(); m_trainAllTsk->InitStopFlag(); m_trainAllTsk->start(); } @@ -314,12 +331,12 @@ Q_SLOT void QModelMgrDlg::onItemDoubleClicked(QListWidgetItem * item) { QObject *obj = sender(); QString objName = obj->objectName(); - if ("ModelMgr_showPic_listWidget_tab1" == objName) + //if ("ModelMgr_showPic_listWidget_tab1" == objName) { // if (m_pCtrl->getDetectState()->m_Debug != 100) // if (m_pCtrl->getUserLevel() <= 0) // return; - QString strModel = ui.ModelMgr_showPic_listWidget_tab1->property("model").toString(); + QString strModel = m_pShowImgList->property("model").toString(); QString itemText = item->text(); QString strWarning = tr("ȷɾͼ?"); if (onMessageBox(QMessageBox::Warning, tr("ģͼƬɾ"), strWarning, 1) == false) @@ -329,19 +346,18 @@ Q_SLOT void QModelMgrDlg::onItemDoubleClicked(QListWidgetItem * item) pImg->remove(itemText); } delete item; - QString m_str = QString("%1 %2 %3").arg(tr("")).arg(ui.ModelMgr_showPic_listWidget_tab1->count()).arg(tr("ͼ")); - //if (m_pLbListWidgetNum) - ui.ModelMgr_label_Pic_Number->setText(m_str); - } - else if ("ModelMgr_listWidget_tab2" == objName) - { - int a = 0; + QString m_str = QString("%1 %2 %3").arg(tr("")).arg(m_pShowImgList->count()).arg(tr("ͼ")); + ui.label_imgNum->setText(m_str); } +// else if ("ModelMgr_listWidget_tab2" == objName) +// { +// int a = 0; +// } } Q_SLOT void QModelMgrDlg::onPrograssShow(QString title, QString strValue, int size, int model) { -/* switch (model) + switch (model) { case emPross_Init: { @@ -366,7 +382,7 @@ Q_SLOT void QModelMgrDlg::onPrograssShow(QString title, QString strValue, int si break; case emPross_Disable: break; - }*/ + } } Q_SLOT void QModelMgrDlg::setValue(int value) @@ -401,7 +417,7 @@ Q_SLOT void QModelMgrDlg::onDelAllModels() Q_SLOT void QModelMgrDlg::onChangeModelName() { - QString strModel = ui.ModelMgr_showPic_listWidget_tab1->property("model").toString(); + QString strModel = m_pShowImgList->property("model").toString(); if (strModel.isEmpty()) { onMessageBox(QMessageBox::Information, tr("ʾ"), tr("ѡһҪ޸ĵͺţ"), 0); @@ -439,7 +455,7 @@ Q_SLOT void QModelMgrDlg::onProgassCancel() m_trainOneTsk->stop(); m_trainOneTsk->quit(); } - //m_ticktimer.elapsed(); + m_ticktimer.elapsed(); } Q_SLOT void QModelMgrDlg::onTableWidget(int nIndex) @@ -476,10 +492,7 @@ Q_SLOT void QModelMgrDlg::onShowModelInfo(QString str) double FalseMinDis = m_pModelMgr->getModel(str)->getImageComModel()->getFalseSampleMinDis(); double disMax = m_pModelMgr->getModel(str)->getImageComModel()->getDisMax(); - //if (m_RepetBox) - { - ui.ModelMgr_model_Repet_spinBox->setValue(m_pModelMgr->getModel(str)->getRepeatNum()); - } + ui.ModelMgr_model_Repet_spinBox->setValue(m_pModelMgr->getModel(str)->getRepeatNum()); if (disThred >= 1.7976931348623157e+308) { disThred = FalseMinDis; @@ -501,14 +514,13 @@ Q_SLOT void QModelMgrDlg::onShowModelInfo(QString str) ui.ModelMgr_horizontalSlider->setValue(vvv); ui.ModelMgr_Num->setText(QString::number(vvv) + "%"); updateWidget(str); - //if (m_pLbListWidgetNum) - { - int IImgNum = ui.ModelMgr_showPic_listWidget_tab1->count(); - QString strShow = QString("%1 %2 %3").arg(tr("")).arg(IImgNum).arg(tr("ͼ")); - if (IImgNum > 0 && IImgNum < nGlobalMinImgs) - strShow += QString(",%1 %2 %3.").arg(tr("ͼ")).arg(nGlobalMinImgs).arg(tr(",뼰ʱѵ")); - ui.ModelMgr_label_Pic_Number->setText(strShow); - } + + int IImgNum = m_pShowImgList->count(); + QString strShow = QString("%1 %2 %3").arg(tr("")).arg(IImgNum).arg(tr("ͼ")); + if (IImgNum > 0 && IImgNum < nGlobalMinImgs) + strShow += QString(",%1 %2 %3.").arg(tr("ͼ")).arg(nGlobalMinImgs).arg(tr(",뼰ʱѵ")); + ui.label_imgNum->setText(strShow); + /* if (m_WarningMsg) { int nTypeModel = m_pModelMgr->getModel(str)->getImageModel(); @@ -570,25 +582,25 @@ void QModelMgrDlg::onClearShow() QPixmap pix(MODEL_UI_ICON_NONE); ui.ModelMgr_modelpic_lable->setPixmap(pix.scaled(WS_PICSIZE, WS_PICSIZE)); ui.ModelMgr_horizontalSlider->setValue(0); - ui.ModelMgr_showPic_listWidget_tab1->setProperty("model", ""); - ui.ModelMgr_showPic_listWidget_tab1->clear(); + m_pShowImgList->setProperty("model", ""); + m_pShowImgList->clear(); } void QModelMgrDlg::TrainAllTskFunc() { QStringList lstAll = m_pModelMgr->getAllModelName(); QMap> mpAllImage = m_pModelMgr->getAllModelImage(); -// emit sgPrograssShow(tr("ģ½"), tr("ڳʼģ Ҫѵ%1ģ,Ժ.....").arg(lstAll.size()), lstAll.size(), emPross_Init); + emit sgPrograssShow(tr("ģ½"), tr("ڳʼģ Ҫѵ%1ģ,Ժ.....").arg(lstAll.size()), lstAll.size(), emPross_Init); int nIndex = 0; for (; nIndex < lstAll.size() && (!m_trainAllTsk->getStopFlag()); nIndex++) { -// emit sgPrograssShow(tr("ģ½"), "", nIndex, emPross_SetValue); + emit sgPrograssShow(tr("ģ½"), "", nIndex, emPross_SetValue); QString m_modelName = lstAll.at(nIndex); TempImage *pImg = m_pModelMgr->getTmpImage(m_modelName); if (!pImg) { continue; } QString str = tr("ѵ%1ģ %2/%3,Ժ.....").arg(m_modelName).arg(nIndex + 1).arg(m_pModelMgr->getAllModelName().size()); -// emit sgPrograssShow(tr("ģ½"), str, lstAll.size(), emPross_SetLable); + emit sgPrograssShow(tr("ģ½"), str, lstAll.size(), emPross_SetLable); IWheelModel *pModel = m_pModelMgr->getModel(m_modelName); std::vector mMat = pImg->getImgVector(); ImageCompareModel *m_compareModel = pModel->getImageComModel(); @@ -644,7 +656,7 @@ void QModelMgrDlg::TrainAllTskFunc() m_pModelMgr->modModel(m_modelName); } str = tr("%1ģȡ %2/%3,Ժ.....").arg(m_modelName).arg(nIndex + 1).arg(m_pModelMgr->getAllModelName().size()); -// emit sgPrograssShow(tr("ģ½"), str, lstAll.size(), emPross_SetLable); + emit sgPrograssShow(tr("ģ½"), str, lstAll.size(), emPross_SetLable); m_compareModel->setIsEnableCache(true); if (m_trainAllTsk->getStopFlag()) @@ -681,12 +693,12 @@ void QModelMgrDlg::TrainAllTskFunc() emit sgTrainShowInfo(m_modelName); str = tr("%1ģѵ %2/%3,Ժ.....").arg(m_modelName).arg(nIndex + 1).arg(m_pModelMgr->getAllModelName().size()); -// emit sgPrograssShow(tr("ģ½"), "", nIndex, emPross_SetValue); + emit sgPrograssShow(tr("ģ½"), "", nIndex, emPross_SetValue); } if (!m_trainAllTsk->getStopFlag()) { -// emit sgPrograssShow(tr("ģ½"), "", nIndex, emPross_Finish); -// emit sgPrograssShow(tr("ģ½"), tr("ȫģɣ%1s").arg(m_ticktimer.elapsed() / 1000.0), nIndex, emPross_enable); + emit sgPrograssShow(tr("ģ½"), "", nIndex, emPross_Finish); + emit sgPrograssShow(tr("ģ½"), tr("ȫģɣ%1s").arg(m_ticktimer.elapsed() / 1000.0), nIndex, emPross_enable); QString str = m_pCtrl->getUserName() + ":" + tr("ȫģѵ%1ģ").arg(lstAll.size()); m_pCtrl->addLog(str, emTypeUseState); } @@ -698,28 +710,28 @@ void QModelMgrDlg::TrainOneTskFunc() return; int m_step = 5; QString str = tr("ģ׼Ժ....."); -// emit sgPrograssShow(tr("ģѵ"), str, m_step, emPross_Init); + emit sgPrograssShow(tr("ģѵ"), str, m_step, emPross_Init); IWheelModel*pModel = m_pModelMgr->getModel(m_strTrainModel); if (!pModel) { return; } -// emit sgPrograssShow(tr("ģѵ"), str, 0, emPross_SetValue); + emit sgPrograssShow(tr("ģѵ"), str, 0, emPross_SetValue); if (m_trainOneTsk->getStopFlag()) return; TempImage *pTempImg = pModel->getTempImage(); std::vector m_MatVec = pTempImg->getImgVector(); if (m_MatVec.size() <= 0) { -// emit sgPrograssShow(tr("ģѵ"), tr("%1ͺûͼƬѵ").arg(m_strTrainModel), 6, emPross_enable); -// emit sgPrograssShow(tr("ģѵ"), tr("%1ͺûͼƬѵ").arg(m_strTrainModel), 6, emPross_Finish); + emit sgPrograssShow(tr("ģѵ"), tr("%1ͺûͼƬѵ").arg(m_strTrainModel), 6, emPross_enable); + emit sgPrograssShow(tr("ģѵ"), tr("%1ͺûͼƬѵ").arg(m_strTrainModel), 6, emPross_Finish); return; } if (m_trainOneTsk->getStopFlag()) return; /*Ҫʾ ˵ģѵ*/ -// emit sgPrograssShow(tr("ģѵ"), str, 1, emPross_SetValue); + emit sgPrograssShow(tr("ģѵ"), str, 1, emPross_SetValue); ImageCompareModel *m_compareModel = pModel->getImageComModel(); //std::vector firstFalseSample = m_pModelMgr->getFirstImgFromFalse(pModel->getModelID()); @@ -766,7 +778,7 @@ void QModelMgrDlg::TrainOneTskFunc() m_compareModel->calculateAllParams(m_MatVec); if (m_trainOneTsk->getStopFlag()) return; -// emit sgPrograssShow(tr("ģѵ"), str, 2, emPross_SetValue); + emit sgPrograssShow(tr("ģѵ"), str, 2, emPross_SetValue); hubBase::mkdir(m_pCtrl->appRoot() + "\\pattern"); QString templatepath = m_pCtrl->appRoot() + "\\pattern\\template\\"; hubBase::mkdir(templatepath); @@ -788,9 +800,9 @@ void QModelMgrDlg::TrainOneTskFunc() } if (m_trainOneTsk->getStopFlag()) return; -// emit sgPrograssShow(tr("ģѵ"), str, 3, emPross_SetValue); -// emit sgPrograssShow(tr("ģѵ"), str, 4, emPross_SetValue); -// emit sgPrograssShow(tr("ģѵ"), tr("%1ģ ڻȡֵ,Ժ....").arg(m_strTrainModel), 4, emPross_SetLable); + emit sgPrograssShow(tr("ģѵ"), str, 3, emPross_SetValue); + emit sgPrograssShow(tr("ģѵ"), str, 4, emPross_SetValue); + emit sgPrograssShow(tr("ģѵ"), tr("%1ģ ڻȡֵ,Ժ....").arg(m_strTrainModel), 4, emPross_SetLable); m_compareModel->setIsEnableCache(false); //if (pModel->getDiameter() && pModel->getThickness()) @@ -809,9 +821,9 @@ void QModelMgrDlg::TrainOneTskFunc() m_compareModel->save2file(strS/*string((const char *)templatepath.toLocal8Bit())*/); if (m_trainOneTsk->getStopFlag()) return; -// emit sgPrograssShow(tr("ģѵ"), str, 6, emPross_SetValue); -// emit sgPrograssShow(tr("ģѵ"), str, 6, emPross_Finish); -// emit sgPrograssShow(tr("ģѵ"), tr("ѵɣ%1s").arg(m_ticktimer.elapsed() / 1000.0), 6, emPross_enable); + emit sgPrograssShow(tr("ģѵ"), str, 6, emPross_SetValue); + emit sgPrograssShow(tr("ģѵ"), str, 6, emPross_Finish); + emit sgPrograssShow(tr("ģѵ"), tr("ѵɣ%1s").arg(m_ticktimer.elapsed() / 1000.0), 6, emPross_enable); emit sgTrainShowInfo(m_strTrainModel); str = m_pCtrl->getUserName() + ":" + tr("ѵģ:%1").arg(m_strTrainModel); m_pCtrl->addLog(str, emTypeUseState); @@ -821,18 +833,18 @@ void QModelMgrDlg::TrainOneTskFunc() void QModelMgrDlg::updateWidget(QString str) { // update images - for (int nIndex = (ui.ModelMgr_showPic_listWidget_tab1->count() - 1); nIndex >= 0; nIndex--) { - QListWidgetItem *pItem = ui.ModelMgr_showPic_listWidget_tab1->takeItem(nIndex); + for (int nIndex = (m_pShowImgList->count() - 1); nIndex >= 0; nIndex--) { + QListWidgetItem *pItem = m_pShowImgList->takeItem(nIndex); delete pItem; } - ui.ModelMgr_showPic_listWidget_tab1->setViewMode(QListView::IconMode); - ui.ModelMgr_showPic_listWidget_tab1->clear(); - ui.ModelMgr_showPic_listWidget_tab1->setProperty("model", str); + m_pShowImgList->setViewMode(QListView::IconMode); + m_pShowImgList->clear(); + m_pShowImgList->setProperty("model", str); /* ܴڴй¶ ʱδҵİ취 */ - ui.ModelMgr_showPic_listWidget_tab1->setIconSize(QSize(WS_PICSIZELIST_ITEM, WS_PICSIZELIST_ITEM)); - ui.ModelMgr_showPic_listWidget_tab1->setAcceptDrops(false); + m_pShowImgList->setIconSize(QSize(WS_PICSIZELIST_ITEM, WS_PICSIZELIST_ITEM)); + m_pShowImgList->setAcceptDrops(false); std::vector imgTemplateLib = m_pModelMgr->getTmpImage(str)->getVectors(); for (int j = 0; j < imgTemplateLib.size(); j++) { @@ -842,17 +854,15 @@ void QModelMgrDlg::updateWidget(QString str) QImage img(dst.data, dst.cols, dst.rows, QImage::Format_Indexed8); QPixmap pix = QPixmap::fromImage(img); QIcon icon(pix.scaled(QSize(WS_PICSIZELIST_ITEM, WS_PICSIZELIST_ITEM))); - QListWidgetItem* pItem = new QListWidgetItem(icon, imgTemplateLib.at(j)->m_strFileName); - ui.ModelMgr_showPic_listWidget_tab1->addItem(pItem); + QListWidgetItem* pItem = new QListWidgetItem(icon, imgTemplateLib.at(j)->m_strFileName, m_pShowImgList); + m_pShowImgList->addItem(pItem); } } bool QModelMgrDlg::appImage2Widget(QString strPath, QString strModel) { //ͼ+ -//cv::Mat dst = ModelTrain::findCircleObject(strPath); cv::Mat dst = imread(string((const char *)strPath.toLocal8Bit()), 0); - //cv::Mat dst = imread(strPath.toLatin1().data(), 0); if (dst.empty()) { return false; } @@ -868,13 +878,12 @@ bool QModelMgrDlg::appImage2Widget(QString strPath, QString strModel) QFileInfo fi; fi = QFileInfo(strPath); QListWidgetItem *pItem = new QListWidgetItem(icon, strFileName); -// if (m_pListWgtImages != NULL) - { - ui.ModelMgr_showPic_listWidget_tab1->insertItem(ui.ModelMgr_showPic_listWidget_tab1->count(), pItem); - ui.ModelMgr_showPic_listWidget_tab1->setViewMode(QListView::IconMode); - ui.ModelMgr_showPic_listWidget_tab1->setIconSize(QSize(WS_PICSIZELIST_ITEM, WS_PICSIZELIST_ITEM)); - ui.ModelMgr_showPic_listWidget_tab1->setAcceptDrops(false); - } + + m_pShowImgList->insertItem(m_pShowImgList->count(), pItem); + m_pShowImgList->setViewMode(QListView::IconMode); + m_pShowImgList->setIconSize(QSize(WS_PICSIZELIST_ITEM, WS_PICSIZELIST_ITEM)); + m_pShowImgList->setAcceptDrops(false); + //add 2 lib IWheelModel *pModel = m_pModelMgr->getModel(strModel); QString strPath2 = m_pCtrl->appRoot() + "\\pattern\\template\\"; @@ -885,9 +894,8 @@ bool QModelMgrDlg::appImage2Widget(QString strPath, QString strModel) cv::imwrite(string((const char *)strPath2.toLocal8Bit()), dst); //cv::imwrite(strPath2.toLatin1().data(), dst); pModel->getTempImage()->add(dst, strFileName, strPath2); - QString m_str = QString("%1 %2 %3").arg(tr("")).arg(ui.ModelMgr_showPic_listWidget_tab1->count()).arg(tr("ͼ")); - //if (m_pLbListWidgetNum) - ui.ModelMgr_label_Pic_Number->setText(m_str); + QString m_str = QString("%1 %2 %3").arg(tr("")).arg(m_pShowImgList->count()).arg(tr("ͼ")); + ui.label_imgNum->setText(m_str); return true; } diff --git a/tpvs17/tpMain/QModelMgrDlg.h b/tpvs17/tpMain/QModelMgrDlg.h index 73b10f4..bb9530f 100644 --- a/tpvs17/tpMain/QModelMgrDlg.h +++ b/tpvs17/tpMain/QModelMgrDlg.h @@ -64,6 +64,7 @@ private: class QMyThread *m_trainOneTsk{ nullptr }; class ModelManager *m_pModelMgr{ nullptr }; class ModelsView *m_pModelLists{ nullptr }; + QListWidget *m_pShowImgList{ nullptr }; int nGlobalMinImgs{5}; QString m_strTrainModel; diff --git a/tpvs17/tpMain/QModelMgrDlg.ui b/tpvs17/tpMain/QModelMgrDlg.ui index 75b140d..fcf0dcb 100644 --- a/tpvs17/tpMain/QModelMgrDlg.ui +++ b/tpvs17/tpMain/QModelMgrDlg.ui @@ -444,25 +444,17 @@ 图片显示: - - - - - Arial - - - - true - - - false - - - QAbstractItemView::DragDrop + + + + TextLabel - + + + + @@ -529,25 +521,6 @@ - - - - - Consolas - 11 - 50 - false - false - - - - - - - - - - diff --git a/tpvs17/tpMain/tpMain.vcxproj b/tpvs17/tpMain/tpMain.vcxproj index 5f92396..b59bb8a 100644 --- a/tpvs17/tpMain/tpMain.vcxproj +++ b/tpvs17/tpMain/tpMain.vcxproj @@ -116,9 +116,6 @@ true - - true - true @@ -281,9 +278,6 @@ true - - true - true @@ -896,14 +890,18 @@ "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DTPMAIN_LIB -DTPMAIN_EXPORTS -DQT_GUI_LIB -DQT_WIDGETS_LIB -DQT_SQL_LIB -DQT_PRINTSUPPORT_LIB -DQT_NETWORK_LIB -DQT_SERIALPORT_LIB -D%(PreprocessorDefinitions) "-I." "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\ActiveQt" "-I$(QTDIR)\include\QtSerialPort" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtPrintSupport" "-I$(QTDIR)\include\QtSql" "-I$(QTDIR)\include\QtNetwork" "-I.\..\..\..\spider\libZK" "-I.\..\..\..\tadpole\include" "-I.\..\..\..\tadpole\src\SubFilters" "-I.\..\..\..\tadpole\src\SubFilters\tpSubFilterDemo" "-I.\..\..\..\tadpole\src\tpGui" "-I.\..\..\..\tadpole\src\tpBase" "-I.\..\..\..\tadpole\src\lpbengine" "-I.\..\..\..\tadpole\src\tpNet" "-I.\..\..\..\tadpole\src\lpdesigner" "-I.\..\..\..\tadpole\src\tpMain" "-I.\..\..\..\tadpole\src\tpSubFilter" "-I.\..\..\..\tadpole\src\libzkq" "-I.\..\..\..\tadpole\src\tpAssister" "-I.\..\..\include\tpMain" "-I.\..\..\include\tpMain\SubFilters" "-I.\..\include" "-I.\..\..\..\lpOpenCV\opencv2.4.9\build\include" "-I.\..\..\..\lpOpenCV\opencv2.4.9\build\include\opencv2" "-I.\..\..\..\lpOpenCV\opencv2.4.9\build\include\opencv" "-I.\..\..\..\Cyclops\include" "-I.\..\..\src\algorithm" "-I.\..\..\include" "-I.\..\..\.\src\tpMain" "-I.\..\..\.\src\tpMain\thread" "-I.\..\..\.\src\tpMain\splashScreen" "-I.\..\..\.\src\tpMain\LightBoxwidget" "-I.\..\..\.\src\tpMain\QDiskCleanThread" "-I.\..\..\.\src\tpMain\QPixmapListBar" "-I.\..\..\.\src\userCtrl" "-I.\..\..\.\src\NetWheel" "-I.\..\..\.\src\RasterSDG20" "-I.\..\..\.\src\ReportModel" - $(QTDIR)\bin\moc.exe;%(FullPath) - Moc%27ing ModelMgrUi.h... - .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp - "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DWIN64 -DQT_CORE_LIB -DTPMAIN_LIB -DTPMAIN_EXPORTS -DQT_GUI_LIB -DQT_WIDGETS_LIB -DQT_SQL_LIB -DQT_PRINTSUPPORT_LIB -DQT_NETWORK_LIB -DQT_SERIALPORT_LIB -D_WINDOWS -D%(PreprocessorDefinitions) "-I." "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\ActiveQt" "-I$(QTDIR)\include\QtSerialPort" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtPrintSupport" "-I$(QTDIR)\include\QtSql" "-I$(QTDIR)\include\QtNetwork" "-I.\..\..\src\algorithm" "-I.\..\..\src\tpMain" "-I.\..\..\src\tpMain\thread" "-I.\..\..\src\tpMain\splashScreen" "-I.\..\..\src\tpMain\LightBoxwidget" "-I.\..\..\src\tpMain\QDiskCleanThread" "-I.\..\..\src\tpMain\QPixmapListBar" "-I.\..\..\src\userCtrl" "-I.\..\..\src\NetWheel" "-I.\..\..\src\RasterSDG20" "-I.\..\..\src\ReportModel" "-I.\..\..\3part\libzkq\include" "-I.\..\..\3part\tadpole\include\tpBase" "-I.\..\..\3part\opencv3.4.1\include" "-I.\..\..\3part\opencv3.4.1\include\opencv" "-I.\..\..\3part\opencv3.4.1\include\opencv2" "-I.\..\..\3part\Cyclops\include" "-I.\..\..\3part\lpCoreCtrl\include" "-I.\..\..\src\tpMain\algela" - $(QTDIR)\bin\moc.exe;%(FullPath) - Moc%27ing ModelMgrUi.h... - .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp - "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DWIN64 -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DTPMAIN_LIB -DTPMAIN_EXPORTS -DQT_GUI_LIB -DQT_WIDGETS_LIB -DQT_SQL_LIB -DQT_PRINTSUPPORT_LIB -DQT_NETWORK_LIB -DQT_SERIALPORT_LIB -D%(PreprocessorDefinitions) "-I." "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(ConfigurationName)" "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\ActiveQt" "-I$(QTDIR)\include\QtSerialPort" "-I$(QTDIR)\include\QtANGLE" "-I$(QTDIR)\include\QtPrintSupport" "-I$(QTDIR)\include\QtSql" "-I$(QTDIR)\include\QtNetwork" "-I.\..\..\..\spider\libZK" "-I.\..\..\..\tadpole\include" "-I.\..\..\..\tadpole\src\SubFilters" "-I.\..\..\..\tadpole\src\SubFilters\tpSubFilterDemo" "-I.\..\..\..\tadpole\src\tpGui" "-I.\..\..\..\tadpole\src\tpBase" "-I.\..\..\..\tadpole\src\lpbengine" "-I.\..\..\..\tadpole\src\tpNet" "-I.\..\..\..\tadpole\src\lpdesigner" "-I.\..\..\..\tadpole\src\tpMain" "-I.\..\..\..\tadpole\src\tpSubFilter" "-I.\..\..\..\tadpole\src\libzkq" "-I.\..\..\..\tadpole\src\tpAssister" "-I.\..\..\include\tpMain" "-I.\..\..\include\tpMain\SubFilters" "-I.\..\include" "-I.\..\..\..\lpOpenCV\opencv2.4.9\build\include" "-I.\..\..\..\lpOpenCV\opencv2.4.9\build\include\opencv2" "-I.\..\..\..\lpOpenCV\opencv2.4.9\build\include\opencv" "-I.\..\..\..\Cyclops\include" "-I.\..\..\src\algorithm" "-I.\..\..\include" "-I.\..\..\.\src\tpMain" "-I.\..\..\.\src\tpMain\thread" "-I.\..\..\.\src\tpMain\splashScreen" "-I.\..\..\.\src\tpMain\LightBoxwidget" "-I.\..\..\.\src\tpMain\QDiskCleanThread" "-I.\..\..\.\src\tpMain\QPixmapListBar" "-I.\..\..\.\src\userCtrl" "-I.\..\..\.\src\NetWheel" "-I.\..\..\.\src\RasterSDG20" "-I.\..\..\.\src\ReportModel" + + + + + + + + + + + +