Files
handleaiuinew/HanddleAI/HandleAiUi-new/uiModule/uiModule_summaryDataManager.h
T

188 lines
6.1 KiB
C++
Raw Normal View History

2024-05-18 23:53:26 +08:00
#include <qmutex.h>
#include <qlabel.h>
#include <uiModule/components/fancyButton.h>
#include <uiModule/components/fancyWidget.h>
#include <uiModule/components/dashBoard.h>
#include <uiModule/components/fancyProcessBar.h>
#include <uiModule/components/fancyLogWindow.h>
2024-05-28 10:41:18 +08:00
#include <uiModule/uiModule_switchProduct.h>
2024-08-07 09:16:35 +00:00
class dashBoradDataWidget : public QWidget
2024-05-18 23:53:26 +08:00
{
public:
2024-08-07 09:16:35 +00:00
QMutex mutex;
2024-05-18 23:53:26 +08:00
QLabel* OKLabel;
QLabel* NGLabel;
QLabel* totalLabel;
2024-08-07 09:16:35 +00:00
DashboardWidget* dashBoard;
int OKCount = 0, NGCount = 0;
dashBoradDataWidget(QString dataName)
2024-05-18 23:53:26 +08:00
{
QPalette palette;
palette.setColor(QPalette::WindowText, Qt::white);
QFont font("微软雅黑", 14, QFont::Bold);
2024-08-07 09:16:35 +00:00
QHBoxLayout* layout = new QHBoxLayout();
this->setLayout(layout);
QVBoxLayout* vlayout1 = new QVBoxLayout();
QVBoxLayout* vlayout2 = new QVBoxLayout();
layout->addLayout(vlayout1);
layout->addLayout(vlayout2);
dashBoard = new DashboardWidget();
vlayout1->addWidget(dashBoard);
vlayout1->setContentsMargins(0, 0, 0, 0);
{
QHBoxLayout* tempLayout = new QHBoxLayout();
QLabel* tempLabel = new QLabel(dataName + u8"OK数量:");
tempLabel->setFont(font);
tempLabel->setPalette(palette);
OKLabel = new QLabel("0");
OKLabel->setFont(font);
OKLabel->setPalette(palette);
tempLayout->addWidget(tempLabel);
tempLayout->addWidget(OKLabel);
vlayout2->addLayout(tempLayout);
}
{
QHBoxLayout* tempLayout = new QHBoxLayout();
QLabel* tempLabel = new QLabel(dataName + u8"NG数量:");
tempLabel->setFont(font);
tempLabel->setPalette(palette);
NGLabel = new QLabel("0");
NGLabel->setFont(font);
NGLabel->setPalette(palette);
tempLayout->addWidget(tempLabel);
tempLayout->addWidget(NGLabel);
vlayout2->addLayout(tempLayout);
}
{
QHBoxLayout* tempLayout = new QHBoxLayout();
QLabel* tempLabel = new QLabel(dataName + u8"总数量:");
tempLabel->setFont(font);
tempLabel->setPalette(palette);
totalLabel = new QLabel("0");
totalLabel->setFont(font);
totalLabel->setPalette(palette);
tempLayout->addWidget(tempLabel);
tempLayout->addWidget(totalLabel);
vlayout2->addLayout(tempLayout);
}
}
void addOk()
{
mutex.lock();
OKCount += 1;
valueChanged();
mutex.unlock();
}
void addNG()
{
mutex.lock();
NGCount += 1;
valueChanged();
mutex.unlock();
}
void reset()
{
mutex.lock();
OKCount = 0;
NGCount = 0;
valueChanged();
mutex.unlock();
}
void valueChanged()
{
OKLabel->setText(QString::number(OKCount));
NGLabel->setText(QString::number(NGCount));
totalLabel->setText(QString::number(OKCount + NGCount));
if(OKCount + NGCount == 0)
dashBoard->setCurrentPercentage(0);
else if (NGCount == 0 && OKCount > 0)
dashBoard->setCurrentPercentage(0);
else if (OKCount == 0 && NGCount > 0)
dashBoard->setCurrentPercentage(100);
else
dashBoard->setCurrentPercentage(((NGCount * 100) / ((OKCount + NGCount))));
}
};
class summaryDataManager : public QObject
{
Q_OBJECT
public:
QLabel* resultSignLabel = new QLabel("总结果:");//总结果label
QLabel* resultLabel = new QLabel("待读取");//总结果label
fancyWidget* widget;
std::vector< dashBoradDataWidget*> dashBoardWidgets;
FrequencyBar* totalCtBar;
FrequencyBar* halconCtBar;
FrequencyBar* aiCtBar;
summaryDataManager()
{
QPalette palette;
palette.setColor(QPalette::WindowText, Qt::white);
QFont font("微软雅黑", 14, QFont::Bold);
QFont font2("微软雅黑", 20, QFont::Bold);
2024-05-18 23:53:26 +08:00
widget = new fancyWidget(u8"运行数据");
fancyButtonText* resetBtn = new fancyButtonText(80,40,u8"重置", u8"重置跑料数据");
2024-08-07 09:16:35 +00:00
QObject::connect(resetBtn, &QPushButton::clicked, this, &summaryDataManager::resetAllValue);
2024-05-18 23:53:26 +08:00
widget->titlelayout->addWidget(resetBtn);
widget->titlelayout->setAlignment(Qt::AlignLeft| Qt::AlignTop);
2024-08-07 09:16:35 +00:00
resultSignLabel->setFont(font2);
resultSignLabel->setPalette(palette);
widget->titlelayout->addWidget(resultSignLabel);
resultLabel->setFont(font2);
resultLabel->setPalette(palette);
widget->titlelayout->addWidget(resultLabel);
2024-05-18 23:53:26 +08:00
QVBoxLayout* layout = new QVBoxLayout();
widget->dataWidget.setLayout(layout);
2024-08-07 09:16:35 +00:00
dashBoradDataWidget* _dashBoradDataWidget = new dashBoradDataWidget(u8"测量");
dashBoradDataWidget* _dashBoradDataWidget2 = new dashBoradDataWidget(u8"检测");
dashBoardWidgets.push_back(_dashBoradDataWidget);
dashBoardWidgets.push_back(_dashBoradDataWidget2);
layout->addWidget(_dashBoradDataWidget);
layout->addWidget(_dashBoradDataWidget2);
2024-05-18 23:53:26 +08:00
2024-08-07 09:16:35 +00:00
totalCtBar =new FrequencyBar("totalCT");
totalCtBar->setProgress(0.0);
layout->addWidget(totalCtBar);
2024-05-18 23:53:26 +08:00
2024-08-07 09:16:35 +00:00
halconCtBar = new FrequencyBar("cc_ImageCT");
halconCtBar->setProgress(0.0);
layout->addWidget(halconCtBar);
2024-05-18 23:53:26 +08:00
2024-08-07 09:16:35 +00:00
aiCtBar = new FrequencyBar("ai_ImageCT");
aiCtBar->setProgress(0.0);
layout->addWidget(aiCtBar);
connect(resetBtn, &QPushButton::clicked, this, &summaryDataManager::resetAllValue);
2024-05-18 23:53:26 +08:00
}
2024-08-07 09:16:35 +00:00
public slots:
void resetAllValue()
{
resultLabel->setText("待读取");
QPalette palette;
palette.setColor(QPalette::WindowText, Qt::white);
resultLabel->setPalette(palette);
for (auto dashBoard : dashBoardWidgets)
dashBoard->reset();
}
void setSummaryResult(QString text, Qt::GlobalColor color)
{
QPalette palette;
palette.setColor(QPalette::WindowText, color);
resultLabel->setText(text);
resultLabel->setPalette(palette);
}
};
#pragma once