159 lines
5.0 KiB
C++
159 lines
5.0 KiB
C++
#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>
|
|
#include <uiModule/uiModule_switchProduct.h>
|
|
#include <FrontendBackendBridge.h>
|
|
class dashBoradDataWidget : public QWidget
|
|
{
|
|
public:
|
|
QMutex mutex;
|
|
QLabel* OKLabel;
|
|
QLabel* NGLabel;
|
|
QLabel* totalLabel;
|
|
DashboardWidget* dashBoard;
|
|
int OKCount = 0, NGCount = 0;
|
|
dashBoradDataWidget(QString dataName)
|
|
{
|
|
QPalette palette;
|
|
palette.setColor(QPalette::WindowText, Qt::white);
|
|
QFont font("微软雅黑", 14, QFont::Bold);
|
|
|
|
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
|
|
dashBoard->setCurrentPercentage(((OKCount * 100) / ((OKCount + NGCount))));
|
|
}
|
|
};
|
|
|
|
class summaryDataManager : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
fancyWidget* widget;
|
|
std::vector< dashBoradDataWidget*> dashBoardWidgets;
|
|
summaryDataManager()
|
|
{
|
|
QPalette palette;
|
|
palette.setColor(QPalette::WindowText, Qt::white);
|
|
QFont font("微软雅黑", 14, QFont::Bold);
|
|
|
|
widget = new fancyWidget(u8"运行数据");
|
|
|
|
fancyButtonText* resetBtn = new fancyButtonText(80,40,u8"重置", u8"重置跑料数据");
|
|
QObject::connect(resetBtn, &QPushButton::clicked, this, &summaryDataManager::resetAllValue);
|
|
|
|
widget->titlelayout->addWidget(resetBtn);
|
|
widget->titlelayout->setAlignment(Qt::AlignLeft| Qt::AlignTop);
|
|
|
|
QVBoxLayout* layout = new QVBoxLayout();
|
|
widget->dataWidget.setLayout(layout);
|
|
|
|
dashBoradDataWidget* _dashBoradDataWidget = new dashBoradDataWidget(u8"测量");
|
|
dashBoradDataWidget* _dashBoradDataWidget2 = new dashBoradDataWidget(u8"检测");
|
|
dashBoardWidgets.push_back(_dashBoradDataWidget);
|
|
dashBoardWidgets.push_back(_dashBoradDataWidget2);
|
|
layout->addWidget(_dashBoradDataWidget);
|
|
layout->addWidget(_dashBoradDataWidget2);
|
|
|
|
FrequencyBar* progressBar=new FrequencyBar("totalCT");
|
|
progressBar->setProgress(0.5);
|
|
layout->addWidget(progressBar);
|
|
FrequencyBar* progressBar2 = new FrequencyBar("cc_ImageCT");
|
|
progressBar2->setProgress(0.3);
|
|
layout->addWidget(progressBar2);
|
|
FrequencyBar* progressBar3 = new FrequencyBar("ai_ImageCT");
|
|
progressBar3->setProgress(0.8);
|
|
layout->addWidget(progressBar3);
|
|
}
|
|
public slots:
|
|
void resetAllValue()
|
|
{
|
|
for (auto dashBoard : dashBoardWidgets)
|
|
dashBoard->reset();
|
|
}
|
|
};
|
|
|
|
#pragma once |