阶段备份
This commit is contained in:
@@ -0,0 +1,188 @@
|
||||
#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>
|
||||
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 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);
|
||||
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);
|
||||
|
||||
resultSignLabel->setFont(font2);
|
||||
resultSignLabel->setPalette(palette);
|
||||
widget->titlelayout->addWidget(resultSignLabel);
|
||||
resultLabel->setFont(font2);
|
||||
resultLabel->setPalette(palette);
|
||||
widget->titlelayout->addWidget(resultLabel);
|
||||
|
||||
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);
|
||||
|
||||
totalCtBar =new FrequencyBar("totalCT");
|
||||
totalCtBar->setProgress(0.0);
|
||||
layout->addWidget(totalCtBar);
|
||||
|
||||
halconCtBar = new FrequencyBar("cc_ImageCT");
|
||||
halconCtBar->setProgress(0.0);
|
||||
layout->addWidget(halconCtBar);
|
||||
|
||||
aiCtBar = new FrequencyBar("ai_ImageCT");
|
||||
aiCtBar->setProgress(0.0);
|
||||
layout->addWidget(aiCtBar);
|
||||
connect(resetBtn, &QPushButton::clicked, this, &summaryDataManager::resetAllValue);
|
||||
}
|
||||
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
|
||||
Reference in New Issue
Block a user