ledset增加走点保存

This commit is contained in:
gangphon 2022-09-09 23:25:49 +08:00
parent 898fcb8133
commit 1c61ae8216
4 changed files with 134 additions and 72 deletions

View File

@ -5,12 +5,14 @@
#include <QRadioButton>
#include <QPushButton>
#include <QButtonGroup>
#include <QComboBox>
#include <QHeaderView>
#include <QMessageBox>
#include <QLineEdit>
#include <QApplication>
#include <QFileDialog>
#include <QJsonObject>
#include <QJsonArray>
#include <QJsonDocument>
ExpertSmartPointSetWin::ExpertSmartPointSetWin(QWidget *parent) : BaseWin{parent} {
setWindowModality(Qt::WindowModal);
@ -51,7 +53,7 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(QWidget *parent) : BaseWin{parent
fdModuleWidth = new QSpinBox;
fdModuleWidth->setRange(0, 9999);
fdModuleWidth->setValue(moduleWidth);
fdModuleWidth->setValue(ModuleWidth);
hhhh->addWidget(fdModuleWidth);
vvv->addLayout(hhhh);
@ -63,7 +65,7 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(QWidget *parent) : BaseWin{parent
fdModuleHeight = new QSpinBox;
fdModuleHeight->setRange(0, 9999);
fdModuleHeight->setValue(moduleHeight);
fdModuleHeight->setValue(ModuleHeight);
hhhh->addWidget(fdModuleHeight);
vvv->addLayout(hhhh);
@ -73,10 +75,10 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(QWidget *parent) : BaseWin{parent
lb = new QLabel("数据组数: ");
hhhh->addWidget(lb);
fdGrpCnt = new QSpinBox;
fdGrpCnt->setRange(0, 9999);
fdGrpCnt->setValue(grpCnt);
hhhh->addWidget(fdGrpCnt);
fdGroupNum = new QSpinBox;
fdGroupNum->setRange(0, 9999);
fdGroupNum->setValue(GroupNum);
hhhh->addWidget(fdGroupNum);
vvv->addLayout(hhhh);
vvv->addStretch();
@ -91,9 +93,9 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(QWidget *parent) : BaseWin{parent
lb = new QLabel("驱动芯片: ");
hhhh->addWidget(lb);
auto fdChip = new QComboBox;
fdChip->addItem("ICND2153");
hhhh->addWidget(fdChip);
fdChipType = new QComboBox;
fdChipType->addItem("ICND2153");
hhhh->addWidget(fdChipType);
vvv->addLayout(hhhh);
vvv->addSpacing(30);
@ -102,7 +104,7 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(QWidget *parent) : BaseWin{parent
lb = new QLabel("译码方式: ");
hhhh->addWidget(lb);
auto fdDecodeMode = new QComboBox;
fdDecodeMode = new QComboBox;
fdDecodeMode->addItem("138译码");
hhhh->addWidget(fdDecodeMode);
@ -113,12 +115,12 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(QWidget *parent) : BaseWin{parent
lb = new QLabel("分组方式: ");
hhhh->addWidget(lb);
auto fdGrping = new QComboBox;
fdGrping->addItem("三线并行");
fdGrping->addItem("三色1点串");
fdGrping->addItem("三色8点串");
fdGrping->addItem("三色16点串");
hhhh->addWidget(fdGrping);
fdGroupMode = new QComboBox;
fdGroupMode->addItem("三线并行");
fdGroupMode->addItem("三色1点串");
fdGroupMode->addItem("三色8点串");
fdGroupMode->addItem("三色16点串");
hhhh->addWidget(fdGroupMode);
vvv->addLayout(hhhh);
vvv->addStretch();
@ -386,7 +388,7 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(QWidget *parent) : BaseWin{parent
if(row < 0) return;
auto item = table->item(row, col);
if(item) return;
if(lines.isEmpty()) {
if(scans.isEmpty()) {
auto cnt = tableRow->columnCount() + 1;
tableRow->setColumnCount(cnt);
tableRow->setItem(0, cnt-1, new QTableWidgetItem(QString::number(cnt)));
@ -396,16 +398,16 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(QWidget *parent) : BaseWin{parent
auto realCnt = cnt - virtualCnt;
item = new QTableWidgetItem(QString::number(realCnt));
table->setItem(row, col, item);
if(realCnt==moduleWidth) {
lines.append({col, row});
if(realCnt==ModuleWidth) {
scans.append({col, row});
QMessageBox::information(this, "提示", "列走完");
}
} else if(lines.size() < scanCnt) {
lines.append({col, row});
auto size = lines.size();
} else if(scans.size() < ScanNum) {
scans.append({col, row});
auto size = scans.size();
item = new QTableWidgetItem("S"+QString::number(size));
table->setItem(row, col, item);
if(size==scanCnt) {
if(size==ScanNum) {
QMessageBox::information(this, "提示", "行走完");
save();
}
@ -452,13 +454,16 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(QWidget *parent) : BaseWin{parent
connect(btnNext, &QPushButton::clicked, this, [this, stack, btnPrev, btnNext] {
auto idx = stack->currentIndex();
if(idx==0) {
moduleWidth = fdModuleWidth->value();
moduleHeight = fdModuleHeight->value();
grpCnt = fdGrpCnt->value();
scanCnt = (moduleHeight + 1) / grpCnt;
ModuleWidth = fdModuleWidth->value();
ModuleHeight = fdModuleHeight->value();
GroupNum = fdGroupNum->value();
ScanNum = (ModuleHeight + 1) / GroupNum;
ChipType = fdChipType->currentText();
DecodeMode = fdDecodeMode->currentText();
GroupMode = fdGroupMode->currentText();
} else if(idx==2) {
table->setColumnCount(moduleWidth);
table->setRowCount(moduleHeight);
table->setColumnCount(ModuleWidth);
table->setRowCount(ModuleHeight);
}
stack->setCurrentIndex(++idx);
btnPrev->setEnabled(idx > 0);
@ -473,6 +478,34 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(QWidget *parent) : BaseWin{parent
}
void ExpertSmartPointSetWin::save() {
auto file = QFileDialog::getSaveFileName(this, "保存文件", QApplication::applicationDirPath()+QString("/ModuleFiles/1X2_3扫.module").arg(ModuleWidth).arg(ModuleHeight).arg(ScanNum));
if(file.isEmpty()) return;
QFile qFile(file);
if(! qFile.open(QFile::WriteOnly)) return;
QJsonObject obj;
obj.insert("ModuleWidth", ModuleWidth);
obj.insert("ModuleHeight", ModuleHeight);
obj.insert("GroupNum", GroupNum);
obj.insert("ScanNum", ScanNum);
obj.insert("ChipType", ChipType);
obj.insert("DecodeMode", DecodeMode);
obj.insert("GroupMode", GroupMode);
QJsonArray Points;
for(int i=0; i<tableRow->columnCount(); i++) {
auto data = tableRow->item(1, i)->data(Qt::UserRole);
if(! data.isValid()) Points.append(-1);
Points.append(data.toPoint().x());
}
obj.insert("Points", Points);
QJsonArray Scans;
foreach(QPoint scan, scans) Scans.append(scan.y());
obj.insert("Scans", Scans);
qFile.write(QJsonDocument(obj).toJson(QJsonDocument::Indented));
qFile.close();
QMessageBox::information(this, "保存成功", "保存成功");
}
void ExpertSmartPointSetWin::save2() {
auto dlg = new BaseDlg(this);
dlg->setWindowTitle("保存设置");
@ -485,17 +518,33 @@ void ExpertSmartPointSetWin::save() {
vBox->addSpacing(20);
hBox = new HBox(vBox);
hBox->addWidget(new QLabel("文件名称: "));
hBox->addWidget(new QLineEdit(QString("1X2_3扫").arg(moduleWidth).arg(moduleHeight).arg(scanCnt)));
hBox->addWidget(new QLineEdit(QString("1X2_3扫").arg(ModuleWidth).arg(ModuleHeight).arg(ScanNum)));
vBox->addSpacing(20);
hBox = new HBox(vBox);
hBox->addWidget(new QLabel("保存路径: "));
auto fdPath = new QLineEdit(QApplication::applicationDirPath()+"/ModuleFiles");
fdPath->setMinimumWidth(400);
hBox->addWidget(fdPath);
auto dir = QApplication::applicationDirPath()+"/ModuleFiles";
QDir(dir).mkpath(".");
auto fdDir = new QLineEdit(dir);
fdDir->setMinimumWidth(400);
hBox->addWidget(fdDir);
auto btnChoose = new QPushButton("选择路径");
connect(btnChoose, &QPushButton::clicked, this, [this, fdPath] {
auto dir = QFileDialog::getExistingDirectory(this, "选择存储文件的目录", fdPath->text());
connect(btnChoose, &QPushButton::clicked, this, [this, fdDir] {
QFileInfo info(fdDir->text());
QFileDialog dlg(this, "选择存储文件的目录", info.path());
auto font = dlg.font();
font.setPixelSize(12);
dlg.setFont(font);
dlg.setFileMode(QFileDialog::Directory);
dlg.setOptions(QFileDialog::ShowDirsOnly);
dlg.selectFile(info.fileName());
dlg.exec();
auto dir = dlg.selectedFiles();
if(! dir.isEmpty()) fdDir->setText(dir[0]);
//auto dir = QFileDialog::getExistingDirectory(this, "选择存储文件的目录", fdDir->text());
//if(! dir.isEmpty()) fdDir->setText(dir);
});
hBox->addWidget(btnChoose);

View File

@ -4,6 +4,7 @@
#include "basewin.h"
#include <QSpinBox>
#include <QTableWidget>
#include <QComboBox>
class PointTable : public QTableWidget {
public:
@ -20,12 +21,17 @@ class ExpertSmartPointSetWin : public BaseWin {
public:
explicit ExpertSmartPointSetWin(QWidget *parent = nullptr);
void save();
void save2();
QSpinBox *fdModuleWidth, *fdModuleHeight, *fdGrpCnt;
PointTable *table, *tableRow;
int virtualCnt = 0;
QList<QPoint> lines;
int moduleWidth{16}, moduleHeight{8}, grpCnt{2}, scanCnt{4};
QList<QPoint> scans;
QSpinBox *fdModuleWidth, *fdModuleHeight, *fdGroupNum;
QComboBox *fdChipType, *fdDecodeMode, *fdGroupMode;
int ModuleWidth{16}, ModuleHeight{8}, GroupNum{2}, ScanNum{4};
QString ChipType, DecodeMode, GroupMode;
};
#endif // EXPERTSMARTPOINTSETWIN_H

View File

@ -133,13 +133,10 @@ QTabBar::tab:selected {margin-top: 0; border-bottom: none; color: #acf; backgrou
{
auto vBox = new QVBoxLayout(receivePanel);
auto gBox = new QGroupBox("模组信息");
gBox->setForegroundRole(QPalette::Text);
vBox->addWidget(gBox);
auto hhh = new QHBoxLayout(gBox);
auto vvv = new QVBoxLayout();
hhh->addLayout(vvv);
auto vvv = new VBox(hhh);
auto lb = new QLabel("驱动芯片: ");
vvv->addWidget(lb);
@ -147,8 +144,7 @@ QTabBar::tab:selected {margin-top: 0; border-bottom: none; color: #acf; backgrou
lb = new QLabel("译码方式: ");
vvv->addWidget(lb);
vvv = new QVBoxLayout();
hhh->addLayout(vvv);
vvv = new VBox(hhh);
lb = new QLabel("驱动芯片");
vvv->addWidget(lb);
@ -157,8 +153,7 @@ QTabBar::tab:selected {margin-top: 0; border-bottom: none; color: #acf; backgrou
vvv->addWidget(lb);
hhh->addSpacing(20);
vvv = new QVBoxLayout();
hhh->addLayout(vvv);
vvv = new VBox(hhh);
lb = new QLabel("模组宽度: ");
vvv->addWidget(lb);
@ -166,8 +161,7 @@ QTabBar::tab:selected {margin-top: 0; border-bottom: none; color: #acf; backgrou
lb = new QLabel("模组高度: ");
vvv->addWidget(lb);
vvv = new QVBoxLayout();
hhh->addLayout(vvv);
vvv = new VBox(hhh);
lb = new QLabel("模组宽度");
vvv->addWidget(lb);
@ -176,8 +170,7 @@ QTabBar::tab:selected {margin-top: 0; border-bottom: none; color: #acf; backgrou
vvv->addWidget(lb);
hhh->addSpacing(20);
vvv = new QVBoxLayout();
hhh->addLayout(vvv);
vvv = new VBox(hhh);
lb = new QLabel("扫描数: ");
vvv->addWidget(lb);
@ -185,8 +178,7 @@ QTabBar::tab:selected {margin-top: 0; border-bottom: none; color: #acf; backgrou
lb = new QLabel("数据数组: ");
vvv->addWidget(lb);
vvv = new QVBoxLayout();
hhh->addLayout(vvv);
vvv = new VBox(hhh);
lb = new QLabel("扫描数");
vvv->addWidget(lb);
@ -195,8 +187,7 @@ QTabBar::tab:selected {margin-top: 0; border-bottom: none; color: #acf; backgrou
vvv->addWidget(lb);
hhh->addSpacing(20);
vvv = new QVBoxLayout();
hhh->addLayout(vvv);
vvv = new VBox(hhh);
lb = new QLabel("数据线颜色: ");
vvv->addWidget(lb);
@ -204,15 +195,13 @@ QTabBar::tab:selected {margin-top: 0; border-bottom: none; color: #acf; backgrou
lb = new QLabel("模组抽行设置");
vvv->addWidget(lb);
vvv = new QVBoxLayout();
hhh->addLayout(vvv);
vvv = new VBox(hhh);
lb = new QLabel("数据线颜色");
vvv->addWidget(lb);
hhh->addStretch();
vvv = new QVBoxLayout();
hhh->addLayout(vvv);
vvv = new VBox(hhh);
auto btn = new QPushButton("模组选择");
vvv->addWidget(btn);
@ -223,6 +212,21 @@ QTabBar::tab:selected {margin-top: 0; border-bottom: none; color: #acf; backgrou
});
vvv->addWidget(btn);
gBox = new QGroupBox("单卡带载");
vBox->addWidget(gBox);
auto tab = new QTabWidget;
tab->setTabPosition(QTabWidget::West);
vBox->addWidget(tab);
auto normalPanel = new QWidget;
tab->addTab(normalPanel, "常规设计");
auto advancedPanel = new QWidget;
tab->addTab(advancedPanel, "高级设计");
vBox->addStretch();
}

View File

@ -43,33 +43,36 @@ int main(int argc, char *argv[]) {
QPalette plt = a.palette();
plt.setBrush(QPalette::Window, QColor(0x333333));
plt.setBrush(QPalette::WindowText, QColor(0xffffff));
plt.setBrush(QPalette::Base, QColor(0x444444));
plt.setBrush(QPalette::AlternateBase, QColor(0x555555));
plt.setBrush(QPalette::Base, QColor(0x222222));
plt.setBrush(QPalette::AlternateBase, QColor(0x333333));
plt.setBrush(QPalette::Text, QColor(0xffffff));
plt.setBrush(QPalette::Button, QColor(0x222222));
plt.setBrush(QPalette::Button, QColor(0x444444));
plt.setBrush(QPalette::ButtonText, QColor(0xffffff));
plt.setBrush(QPalette::ToolTipBase, QColor(0x444466));
plt.setBrush(QPalette::ToolTipText, QColor(0xffffff));
plt.setBrush(QPalette::Light, QColor(0x444444));
plt.setBrush(QPalette::Midlight, QColor(0x666666));
plt.setBrush(QPalette::Mid, QColor(0x888888));
plt.setBrush(QPalette::Dark, QColor(0xaaaaaa));
plt.setBrush(QPalette::Midlight, QColor(0x555555));
plt.setBrush(QPalette::Mid, QColor(0x666666));
plt.setBrush(QPalette::Dark, QColor(0x777777));
plt.setBrush(QPalette::BrightText, QColor(0,0,0));
plt.setBrush(QPalette::Shadow, QColor(0xaaaaaa));
a.setPalette(plt);
a.setWindowIcon(QIcon(":/128.ico"));
a.setStyleSheet(R"rrr(
QMessageBox {background: #444;}
QGroupBox::title {color: #fff;}
QMessageBox {background: #333;}
QGroupBox {border: 1px solid #777; border-radius: 3px; margin-top: 1.2ex; padding-top: 1ex;}
QGroupBox::title {color: #fff; subcontrol-origin: margin; position: relative; left: 1.4ex;}
QLineEdit, QComboBox, QSpinBox, QPushButton, QAbstractScrollArea {border: 1px solid #888;}
QLineEdit, QComboBox, QSpinBox {border-radius: 2px; padding: 2px; background: #222;}
QPushButton{border-radius: 4px; padding: 2px 6px; background: #222;}
QPushButton:hover {background: #444;}
QPushButton{border-radius: 4px; padding: 2px 6px; background: #444;}
QPushButton:hover {background: #555;}
QPushButton:pressed {background: #666;}
QPushButton:checked {background: #026; border-color: #06f;}
QPushButton:!enabled {background: #666; color: #777;}
QPushButton[ss="min"]{border-radius: 4px; padding: 0; width: 30px; height: 25px; background: #07c;}
QPushButton[ss="close"]{border-radius: 4px; padding: 0; width: 30px; height: 25px; background: #e22;}
@ -77,10 +80,10 @@ QPushButton[ss="close"]{border-radius: 4px; padding: 0; width: 30px; height: 25p
QRadioButton::indicator {border-image: url(:/imgs/radio-un.png); width: 14px; height: 14px;}
QRadioButton::indicator:checked {border-image: url(:/imgs/radio-check.png);}
QAbstractScrollArea QScrollBar {background: #555;}
QAbstractScrollArea QScrollBar {background: #222;}
QTableView {gridline-color:#888;}
QHeaderView::section, QTableCornerButton:section {background: #555;}
QTableView {gridline-color:#777;}
QHeaderView::section, QTableCornerButton:section {background: #444;}
QSlider::horizontal {height: 16px;}
QSlider::groove {background: transparent;}