添加切换标定模式,2d参数输入,额外存储NG结果图
This commit is contained in:
@@ -0,0 +1,164 @@
|
||||
#include <qwidget.h>
|
||||
#include <qlabel.h>
|
||||
#include <qpushbutton.h>
|
||||
#include <qobject.h>
|
||||
#include <uiModule/components/fancyButton.h>
|
||||
#include <qlayout.h>
|
||||
#include <qspinbox.h>
|
||||
#include <appCore.hpp>
|
||||
#include <appConfig/json/generalJsonParsing.hpp>
|
||||
class _952BiaoDingSwitch : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QLabel CurrentModeLabel;
|
||||
fancyButtonText NormalBtn, BiaoDingBtn;
|
||||
fancyButtonText SaveBtn,RestoreBtn;
|
||||
QGridLayout mainLayout;
|
||||
QLabel OutOffsetLabel, InnerOffsetLabel;
|
||||
QDoubleSpinBox* OutDoubleSpinBox,* InnerDoubleSpinBox;
|
||||
nlohmann::json JsonObj;
|
||||
QLabel _3dSignLabel, _2dSignLabel;
|
||||
_952BiaoDingSwitch()
|
||||
: NormalBtn(180, 30, "一般模式", "一般模式")
|
||||
, BiaoDingBtn(180, 30, "标定模式", "标定模式")
|
||||
, mainLayout(this)
|
||||
, SaveBtn(180, 30, "保存&应用", "保存&应用")
|
||||
, RestoreBtn(180, 30, "还原", "还原")
|
||||
{
|
||||
|
||||
QPalette palette;
|
||||
palette.setColor(QPalette::WindowText, Qt::white);
|
||||
QFont font("微软雅黑", 14, QFont::Bold);
|
||||
//
|
||||
_3dSignLabel.setText("3D参数设置");
|
||||
_3dSignLabel.setPalette(palette);
|
||||
_3dSignLabel.setFont(font);
|
||||
mainLayout.addWidget(&_3dSignLabel, 0, 0);
|
||||
//
|
||||
QHBoxLayout* btnLayout = new QHBoxLayout;
|
||||
btnLayout->setContentsMargins(0, 0, 0, 0);
|
||||
btnLayout->setAlignment(Qt::AlignLeft);
|
||||
btnLayout->addWidget(&NormalBtn);
|
||||
btnLayout->addWidget(&BiaoDingBtn);
|
||||
mainLayout.addLayout(btnLayout, 1, 0);
|
||||
//按钮互斥
|
||||
NormalBtn.toGreen();
|
||||
QObject::connect(&NormalBtn, &QPushButton::clicked, this, [=]()
|
||||
{
|
||||
NormalBtn.toGreen();
|
||||
BiaoDingBtn.toDefault();
|
||||
switchToNormal();
|
||||
});
|
||||
QObject::connect(&BiaoDingBtn, &QPushButton::clicked, this, [=]()
|
||||
{
|
||||
BiaoDingBtn.toGreen();
|
||||
NormalBtn.toDefault();
|
||||
switchToBiaoDing();
|
||||
});
|
||||
//
|
||||
_2dSignLabel.setText("2D参数设置");
|
||||
_2dSignLabel.setPalette(palette);
|
||||
_2dSignLabel.setFont(font);
|
||||
mainLayout.addWidget(&_2dSignLabel, 2, 0);
|
||||
//参数输入
|
||||
QHBoxLayout* OutOffsetLayout = new QHBoxLayout;
|
||||
OutDoubleSpinBox = new QDoubleSpinBox(this);
|
||||
OutDoubleSpinBox->setStyleSheet("QDoubleSpinBox::up-button, QDoubleSpinBox::down-button { width: 0; height: 0; border: none; }");
|
||||
OutDoubleSpinBox->setRange(0.0, 100.0); // 设置最小值和最大值
|
||||
OutDoubleSpinBox->setDecimals(2); // 设置小数点后的位数
|
||||
OutDoubleSpinBox->setFont(font);
|
||||
//OutDoubleSpinBox->setValue(1.5); // 设置初始值
|
||||
OutOffsetLabel.setText("外侧焊印直径(mm)");
|
||||
OutOffsetLabel.setPalette(palette);
|
||||
OutOffsetLabel.setFont(font);
|
||||
OutOffsetLayout->addWidget(&OutOffsetLabel);
|
||||
OutOffsetLayout->addWidget(OutDoubleSpinBox);
|
||||
mainLayout.addLayout(OutOffsetLayout, 3, 0);
|
||||
|
||||
QHBoxLayout* InnerOffsetLayout = new QHBoxLayout;
|
||||
InnerDoubleSpinBox = new QDoubleSpinBox(this);
|
||||
InnerDoubleSpinBox->setStyleSheet("QDoubleSpinBox::up-button, QDoubleSpinBox::down-button { width: 0; height: 0; border: none; }");
|
||||
InnerDoubleSpinBox->setRange(0.0, 100.0); // 设置最小值和最大值
|
||||
InnerDoubleSpinBox->setDecimals(2); // 设置小数点后的位数
|
||||
InnerDoubleSpinBox->setFont(font);
|
||||
InnerOffsetLabel.setText("内侧焊印直径(mm)");
|
||||
InnerOffsetLabel.setPalette(palette);
|
||||
InnerOffsetLabel.setFont(font);
|
||||
InnerOffsetLayout->addWidget(&InnerOffsetLabel);
|
||||
InnerOffsetLayout->addWidget(InnerDoubleSpinBox);
|
||||
mainLayout.addLayout(InnerOffsetLayout, 4, 0);
|
||||
//参数保存
|
||||
QHBoxLayout* btnLayout2 = new QHBoxLayout;
|
||||
btnLayout2->setContentsMargins(0, 0, 0, 0);
|
||||
btnLayout2->setAlignment(Qt::AlignLeft);
|
||||
btnLayout2->addWidget(&SaveBtn);
|
||||
QObject::connect(&SaveBtn, &QPushButton::clicked, this, [=]()
|
||||
{
|
||||
saveConfig();
|
||||
});
|
||||
connect(&SaveBtn, &QPushButton::clicked, this, [=]() mutable {
|
||||
// 设置按钮显示√
|
||||
SaveBtn.setText("√");
|
||||
SaveBtn.toGreen();
|
||||
// 创建一个定时器
|
||||
QTimer::singleShot(1000, [=]() mutable {
|
||||
// 一秒后还原文本
|
||||
SaveBtn.toDefault();
|
||||
SaveBtn.setText("保存&应用");
|
||||
});
|
||||
});
|
||||
btnLayout2->addWidget(&RestoreBtn);
|
||||
QObject::connect(&RestoreBtn, &QPushButton::clicked, this, [=]()
|
||||
{
|
||||
restore();
|
||||
});
|
||||
mainLayout.addLayout(btnLayout2, 5, 0);
|
||||
//加载json并设置默认值
|
||||
JsonObj = readJsonFromPath("./config/_952BiaoDingSwitchConfig.json");
|
||||
int JsonMode = JsonObj["mode"];
|
||||
double JsonOutOffset = JsonObj["in_OutOffset"];
|
||||
double JsonInnerOffset = JsonObj["in_InnerOffset"];
|
||||
if (JsonMode == 1)
|
||||
BiaoDingBtn.click();
|
||||
OutDoubleSpinBox->setValue(JsonOutOffset);
|
||||
InnerDoubleSpinBox->setValue(JsonInnerOffset);
|
||||
QMutexLocker locker(&_core._appConfig.__952BiaoDingSwitchData.mutex);
|
||||
_core._appConfig.__952BiaoDingSwitchData.modeIn = JsonMode;
|
||||
_core._appConfig.__952BiaoDingSwitchData.in_OutOffset = JsonOutOffset;
|
||||
_core._appConfig.__952BiaoDingSwitchData.in_InnerOffset = JsonInnerOffset;
|
||||
};
|
||||
void switchToBiaoDing()
|
||||
{
|
||||
QMutexLocker locker(&_core._appConfig.__952BiaoDingSwitchData.mutex);
|
||||
_core._appConfig.__952BiaoDingSwitchData.modeIn = 1;
|
||||
JsonObj["mode"] = 1;
|
||||
saveJsonFromPath("./config/_952BiaoDingSwitchConfig.json", JsonObj);
|
||||
}
|
||||
void switchToNormal()
|
||||
{
|
||||
QMutexLocker locker(&_core._appConfig.__952BiaoDingSwitchData.mutex);
|
||||
_core._appConfig.__952BiaoDingSwitchData.modeIn = 0;
|
||||
JsonObj["mode"] = 0;
|
||||
saveJsonFromPath("./config/_952BiaoDingSwitchConfig.json", JsonObj);
|
||||
}
|
||||
void saveConfig()
|
||||
{
|
||||
QMutexLocker locker(&_core._appConfig.__952BiaoDingSwitchData.mutex);
|
||||
_core._appConfig.__952BiaoDingSwitchData.in_OutOffset = OutDoubleSpinBox->value();
|
||||
_core._appConfig.__952BiaoDingSwitchData.in_InnerOffset = InnerDoubleSpinBox->value();
|
||||
JsonObj["in_OutOffset"] = _core._appConfig.__952BiaoDingSwitchData.in_OutOffset;
|
||||
JsonObj["in_InnerOffset"] = _core._appConfig.__952BiaoDingSwitchData.in_InnerOffset;
|
||||
saveJsonFromPath("./config/_952BiaoDingSwitchConfig.json", JsonObj);
|
||||
qDebug() << "_952BiaoDingSwitch-ValueChanged:in_OutOffset->" << _core._appConfig.__952BiaoDingSwitchData.in_OutOffset
|
||||
<< " | in_InnerOffset->" << _core._appConfig.__952BiaoDingSwitchData.in_InnerOffset;
|
||||
}
|
||||
void restore()
|
||||
{
|
||||
QMutexLocker locker(&_core._appConfig.__952BiaoDingSwitchData.mutex);
|
||||
OutDoubleSpinBox->setValue(_core._appConfig.__952BiaoDingSwitchData.in_OutOffset);
|
||||
InnerDoubleSpinBox->setValue(_core._appConfig.__952BiaoDingSwitchData.in_InnerOffset);
|
||||
}
|
||||
private:
|
||||
};
|
||||
#pragma once
|
||||
Reference in New Issue
Block a user