完善历史图片检索以及显示
This commit is contained in:
@@ -48,7 +48,7 @@ signals:
|
||||
void sendPixmapImageWidget(showImgPack*);
|
||||
void sendInitFinished(int);
|
||||
void sendInitString(QString);//初始化日志
|
||||
|
||||
void addHistoryDataSignal(bool isOK, QString path, QPixmap img);
|
||||
void addDashBoardData(int index, bool value);//增加一个OK/NG数据到dashboard
|
||||
void resetDashBoard();//reset dashBoard
|
||||
|
||||
|
||||
@@ -265,7 +265,9 @@ public:
|
||||
}
|
||||
static std::string getFileName(std::string path)
|
||||
{
|
||||
return path.substr(path.find_last_of("\\") + 1, path.find_last_of(".") - path.find_last_of("\\") - 1);
|
||||
if (path.find("\\") != std::string::npos)
|
||||
return path.substr(path.find_last_of("\\") + 1, path.find_last_of(".") - path.find_last_of("\\") - 1);
|
||||
return path.substr(path.find_last_of("/") + 1, path.find_last_of(".") - path.find_last_of("/") - 1);
|
||||
}
|
||||
static QString getFileName(const QString& path) {
|
||||
int lastSlashIndex = path.lastIndexOf('/');
|
||||
|
||||
@@ -131,6 +131,7 @@ void threadManager::resultHandle(std::shared_ptr <detData> data)
|
||||
pack->type = imgWidgetRes;
|
||||
pack->index = data->resShowIndex+ cnt;
|
||||
emit _backEndManager->sendPixmapImageWidget(pack);
|
||||
emit _backEndManager->addHistoryDataSignal((data->aiDetOK == true && data->halconOK == true), "", pixmap);
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <uiModule/uiModule_historyListWidget.h>
|
||||
class displayWidget :public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QGridLayout* Layout;
|
||||
QLabel* icon, * Title;
|
||||
@@ -17,7 +18,6 @@ public:
|
||||
ImageWidgetManager _ImageWidgetManager;
|
||||
summaryDataManager* _summaryDataManager;
|
||||
historyShowListWidget* historyImgs = new historyShowListWidget();
|
||||
//ImageWidget* imgWidget;
|
||||
displayWidget()
|
||||
{
|
||||
this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
@@ -40,6 +40,8 @@ public:
|
||||
Layout->setColumnStretch(2, 1);
|
||||
leftItemInit();
|
||||
rightItemInit();
|
||||
QObject::connect(historyImgs, &historyShowListWidget::itemClickSignal, this, &displayWidget::historyClick);
|
||||
//historyImgs->addData(true, "D:/CCD/yuantu/2024-06-04/23H/TEST/1 (1).bmp", QPixmap("D:/CCD/yuantu/2024-06-04/23H/TEST/1 (1).bmp"));
|
||||
}
|
||||
void rightItemInit()
|
||||
{
|
||||
@@ -72,5 +74,14 @@ public:
|
||||
//leftWidget->setMaximumWidth(width / 1.2);
|
||||
//rightWidget->setMaximumWidth(width / 2);
|
||||
}
|
||||
private slots:
|
||||
void historyClick(QString path)
|
||||
{
|
||||
emit historyClickSignal(path);
|
||||
emit changeStackWidget(3);
|
||||
}
|
||||
signals:
|
||||
void historyClickSignal(QString);
|
||||
void changeStackWidget(int);
|
||||
};
|
||||
#pragma once
|
||||
@@ -70,5 +70,11 @@ public:
|
||||
dirListWidget.setStyleSheet("background: transparent;");
|
||||
QObject::connect(&dirListWidget, &menuListWidget::switchPathSignal, &_historyShowListWidget, &historyShowListWidget::addImgFromPath);
|
||||
}
|
||||
public slots:
|
||||
void widgetJumpWithPath(QString path)
|
||||
{
|
||||
dirListWidget.jumpWithPath(path);
|
||||
_historyShowListWidget._historyShowListSubThread.asyncReadImg(path.toStdString());
|
||||
}
|
||||
};
|
||||
#pragma once
|
||||
@@ -21,6 +21,7 @@ void connectSignalAndSlots(MainWindow* front, backEndManager* back)
|
||||
QObject::connect(back, &backEndManager::sendInitString, front, &MainWindow::recvInitString);
|
||||
QObject::connect(back, &backEndManager::sendInitFinished, front, &MainWindow::recvInitFinished);
|
||||
QObject::connect(back, &backEndManager::addDashBoardData, front, &MainWindow::addDashBoardData);
|
||||
QObject::connect(back, &backEndManager::addHistoryDataSignal, front, &MainWindow::addDetHistoryData);
|
||||
|
||||
QObject::connect(front, &MainWindow::reInitSignal, back, &backEndManager::initialization);
|
||||
QObject::connect(front->_loadingWidget.retryBtn, &QPushButton::clicked, back, &backEndManager::initialization);
|
||||
|
||||
@@ -254,16 +254,10 @@ void MainWindow::leftBarInit()
|
||||
layout->addWidget(pageBtns[index]);
|
||||
connect(pageBtns[index], &QPushButton::clicked, [=]()
|
||||
{
|
||||
for (int index2 = 0; index2 < pageBtns.size(); index2++)
|
||||
{
|
||||
if (index2 != index)
|
||||
pageBtns[index2]->toDefault();
|
||||
}
|
||||
pageBtns[index]->pressed();
|
||||
pageWidgets.setCurrentIndex(index);
|
||||
//qInfo() << "switch Page to Index:" << index;
|
||||
qDebug() << "switch Page to Index:" << index;
|
||||
switchStackWidget(index);
|
||||
});
|
||||
}
|
||||
toMainBtn->click();
|
||||
QObject::connect(_displayWidget, &displayWidget::changeStackWidget, this, &MainWindow::switchStackWidget);
|
||||
QObject::connect(_displayWidget, &displayWidget::historyClickSignal, _historyWidget, &historyWidget::widgetJumpWithPath);
|
||||
}
|
||||
@@ -99,7 +99,17 @@ public slots:
|
||||
{
|
||||
showMinimized();
|
||||
}
|
||||
|
||||
void switchStackWidget(int index)
|
||||
{
|
||||
for (int index2 = 0; index2 < pageBtns.size(); index2++)
|
||||
{
|
||||
if (index2 != index)
|
||||
pageBtns[index2]->toDefault();
|
||||
}
|
||||
pageBtns[index]->pressed();
|
||||
pageWidgets.setCurrentIndex(index);
|
||||
qDebug() << "switch Page to Index:" << index;
|
||||
}
|
||||
void toggleMaximize(toggleMaximizeEnum toggleMaximizeEnumIn = reverse)
|
||||
{
|
||||
switch (toggleMaximizeEnumIn)
|
||||
@@ -210,7 +220,10 @@ public slots:
|
||||
_loadingWidget.initLog->append(strIn);
|
||||
}
|
||||
}
|
||||
|
||||
void addDetHistoryData(bool isOK, QString path, QPixmap img)
|
||||
{
|
||||
_displayWidget->historyImgs->addData(isOK, path, img);
|
||||
}
|
||||
void addDashBoardData(int index, bool value)//增加一个OK/NG数据到dashboard
|
||||
{
|
||||
if (_displayWidget->_summaryDataManager->dashBoardWidgets.size() - 1 < index)
|
||||
|
||||
@@ -52,7 +52,8 @@ class historyShowListSubThread : public QThread
|
||||
public:
|
||||
QMutex queueMutex;
|
||||
QQueue<std::pair<int, std::string>> queue;
|
||||
void run()
|
||||
private:
|
||||
void run() override
|
||||
{
|
||||
while (queue.size() > 0)
|
||||
{
|
||||
@@ -66,7 +67,7 @@ public:
|
||||
continue;
|
||||
QPixmap map;
|
||||
cvMatToQPixMap(mat, map);
|
||||
addDataSignal((data.second.find("OK") != std::string::npos), data.second, map);
|
||||
addDataSignal((data.second.find("OK") != std::string::npos), QString::fromStdString(data.second), map);
|
||||
}
|
||||
else if (data.first == 1)
|
||||
{
|
||||
@@ -99,7 +100,7 @@ public slots:
|
||||
this->start();
|
||||
}
|
||||
signals:
|
||||
void addDataSignal(bool isOk, std::string filePath, QPixmap img);
|
||||
void addDataSignal(bool isOk,QString, QPixmap img);
|
||||
void readImgSignal(QPixmap img);
|
||||
};
|
||||
class historyShowListWidget : public QWidget
|
||||
@@ -127,9 +128,8 @@ public:
|
||||
|
||||
QObject::connect(this, &historyShowListWidget::asyncReadImgSignal, &_historyShowListSubThread, &historyShowListSubThread::asyncReadImg);
|
||||
QObject::connect(this, &historyShowListWidget::asyncReadIconsSignal, &_historyShowListSubThread, &historyShowListSubThread::asyncReadIcons);
|
||||
QObject::connect(&_historyShowListSubThread, &historyShowListSubThread::addDataSignal, this, &historyShowListWidget::addData);
|
||||
QObject::connect(showDataListWidget, &QListWidget::itemClicked, this, &historyShowListWidget::itemClick);
|
||||
|
||||
QObject::connect(&_historyShowListSubThread, &historyShowListSubThread::addDataSignal, this, &historyShowListWidget::addData);
|
||||
}
|
||||
public slots:
|
||||
void addImgFromPath(QString path)
|
||||
@@ -142,14 +142,14 @@ public slots:
|
||||
emit asyncReadIconsSignal(files);
|
||||
|
||||
}
|
||||
void addData(bool isOk, std::string filePath, QPixmap img)
|
||||
void addData(bool isOk, QString path, QPixmap img)
|
||||
{
|
||||
QString title;
|
||||
if (isOk == true)
|
||||
title = "OK";
|
||||
else
|
||||
title = "NG";
|
||||
QWidget* widget = new historyItemWidget(title, filePath, img, size());
|
||||
QWidget* widget = new historyItemWidget(title, path.toStdString(), img, size());
|
||||
QListWidgetItem* item = new QListWidgetItem();
|
||||
showDataListWidget->addItem(item);
|
||||
showDataListWidget->setItemWidget(item, widget);
|
||||
@@ -171,6 +171,7 @@ private slots:
|
||||
{
|
||||
QString path = label->text();
|
||||
emit asyncReadImgSignal(path.toStdString());
|
||||
emit itemClickSignal(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,11 +108,13 @@ public:
|
||||
return;
|
||||
|
||||
//写入
|
||||
std::string fileName = fileManager::getFileName(path.toStdString());
|
||||
pathList.clear();
|
||||
depth = list.size() - 1;
|
||||
for (auto str : list)
|
||||
pathList.append(str);
|
||||
if (str.contains(QString::fromStdString(fileName)) == false)
|
||||
pathList.append(str);
|
||||
|
||||
depth = pathList.size() - 1;
|
||||
refreshListWidget();
|
||||
}
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user