ledset增加走点保存
This commit is contained in:
parent
0cb51c6e2a
commit
898fcb8133
|
@ -18,7 +18,7 @@ BaseWinBase::BaseWinBase(QWidget *that) : that(that) {
|
||||||
center->installEventFilter(that);
|
center->installEventFilter(that);
|
||||||
}
|
}
|
||||||
|
|
||||||
QHBoxLayout *BaseWinBase::addBtns(QHBoxLayout *hBox) {
|
QBoxLayout *BaseWinBase::addBtns(QBoxLayout *hBox) {
|
||||||
if(hBox->count()==0) hBox->addStretch();
|
if(hBox->count()==0) hBox->addStretch();
|
||||||
auto btn = new QPushButton("--");
|
auto btn = new QPushButton("--");
|
||||||
btn->setProperty("ss", "min");
|
btn->setProperty("ss", "min");
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
class BaseWinBase {
|
class BaseWinBase {
|
||||||
public:
|
public:
|
||||||
explicit BaseWinBase(QWidget *that);
|
explicit BaseWinBase(QWidget *that);
|
||||||
QHBoxLayout *addBtns(QHBoxLayout *);
|
QBoxLayout *addBtns(QBoxLayout *);
|
||||||
QWidget *center{0};
|
QWidget *center{0};
|
||||||
QPen borderPenAct{QColor{0x0077cc}};
|
QPen borderPenAct{QColor{0x0077cc}};
|
||||||
QPen borderPenUnact{Qt::gray};
|
QPen borderPenUnact{Qt::gray};
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "expertsmartpointsetwin.h"
|
#include "expertsmartpointsetwin.h"
|
||||||
|
#include "gqt.h"
|
||||||
#include <QStackedLayout>
|
#include <QStackedLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QRadioButton>
|
#include <QRadioButton>
|
||||||
|
@ -6,7 +7,11 @@
|
||||||
#include <QButtonGroup>
|
#include <QButtonGroup>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QDebug>
|
#include <QMessageBox>
|
||||||
|
#include <QLineEdit>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QFileDialog>
|
||||||
|
|
||||||
ExpertSmartPointSetWin::ExpertSmartPointSetWin(QWidget *parent) : BaseWin{parent} {
|
ExpertSmartPointSetWin::ExpertSmartPointSetWin(QWidget *parent) : BaseWin{parent} {
|
||||||
setWindowModality(Qt::WindowModal);
|
setWindowModality(Qt::WindowModal);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
@ -46,7 +51,7 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(QWidget *parent) : BaseWin{parent
|
||||||
|
|
||||||
fdModuleWidth = new QSpinBox;
|
fdModuleWidth = new QSpinBox;
|
||||||
fdModuleWidth->setRange(0, 9999);
|
fdModuleWidth->setRange(0, 9999);
|
||||||
fdModuleWidth->setValue(128);
|
fdModuleWidth->setValue(moduleWidth);
|
||||||
hhhh->addWidget(fdModuleWidth);
|
hhhh->addWidget(fdModuleWidth);
|
||||||
|
|
||||||
vvv->addLayout(hhhh);
|
vvv->addLayout(hhhh);
|
||||||
|
@ -58,7 +63,7 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(QWidget *parent) : BaseWin{parent
|
||||||
|
|
||||||
fdModuleHeight = new QSpinBox;
|
fdModuleHeight = new QSpinBox;
|
||||||
fdModuleHeight->setRange(0, 9999);
|
fdModuleHeight->setRange(0, 9999);
|
||||||
fdModuleHeight->setValue(64);
|
fdModuleHeight->setValue(moduleHeight);
|
||||||
hhhh->addWidget(fdModuleHeight);
|
hhhh->addWidget(fdModuleHeight);
|
||||||
|
|
||||||
vvv->addLayout(hhhh);
|
vvv->addLayout(hhhh);
|
||||||
|
@ -68,9 +73,9 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(QWidget *parent) : BaseWin{parent
|
||||||
lb = new QLabel("数据组数: ");
|
lb = new QLabel("数据组数: ");
|
||||||
hhhh->addWidget(lb);
|
hhhh->addWidget(lb);
|
||||||
|
|
||||||
auto fdGrpCnt = new QSpinBox;
|
fdGrpCnt = new QSpinBox;
|
||||||
fdGrpCnt->setRange(0, 9999);
|
fdGrpCnt->setRange(0, 9999);
|
||||||
fdGrpCnt->setValue(1);
|
fdGrpCnt->setValue(grpCnt);
|
||||||
hhhh->addWidget(fdGrpCnt);
|
hhhh->addWidget(fdGrpCnt);
|
||||||
|
|
||||||
vvv->addLayout(hhhh);
|
vvv->addLayout(hhhh);
|
||||||
|
@ -362,6 +367,11 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(QWidget *parent) : BaseWin{parent
|
||||||
});
|
});
|
||||||
hhh->addWidget(btnReset);
|
hhh->addWidget(btnReset);
|
||||||
|
|
||||||
|
auto btnOK = new QPushButton("完成");
|
||||||
|
btnOK->setMinimumSize(90, 30);
|
||||||
|
connect(btnOK, &QPushButton::clicked, this, &ExpertSmartPointSetWin::save);
|
||||||
|
hhh->addWidget(btnOK);
|
||||||
|
|
||||||
hhh->addStretch();
|
hhh->addStretch();
|
||||||
vBox->addLayout(hhh);
|
vBox->addLayout(hhh);
|
||||||
|
|
||||||
|
@ -376,14 +386,30 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(QWidget *parent) : BaseWin{parent
|
||||||
if(row < 0) return;
|
if(row < 0) return;
|
||||||
auto item = table->item(row, col);
|
auto item = table->item(row, col);
|
||||||
if(item) return;
|
if(item) return;
|
||||||
auto cnt = tableRow->columnCount() + 1;
|
if(lines.isEmpty()) {
|
||||||
tableRow->setColumnCount(cnt);
|
auto cnt = tableRow->columnCount() + 1;
|
||||||
tableRow->setItem(0, cnt-1, new QTableWidgetItem(QString::number(cnt)));
|
tableRow->setColumnCount(cnt);
|
||||||
item = new QTableWidgetItem("√");
|
tableRow->setItem(0, cnt-1, new QTableWidgetItem(QString::number(cnt)));
|
||||||
item->setData(Qt::UserRole, QPoint{col, row});
|
item = new QTableWidgetItem("√");
|
||||||
tableRow->setItem(1, cnt-1, item);
|
item->setData(Qt::UserRole, QPoint{col, row});
|
||||||
item = new QTableWidgetItem(QString::number(cnt - virtualCnt));
|
tableRow->setItem(1, cnt-1, item);
|
||||||
table->setItem(row, col, item);
|
auto realCnt = cnt - virtualCnt;
|
||||||
|
item = new QTableWidgetItem(QString::number(realCnt));
|
||||||
|
table->setItem(row, col, item);
|
||||||
|
if(realCnt==moduleWidth) {
|
||||||
|
lines.append({col, row});
|
||||||
|
QMessageBox::information(this, "提示", "列走完");
|
||||||
|
}
|
||||||
|
} else if(lines.size() < scanCnt) {
|
||||||
|
lines.append({col, row});
|
||||||
|
auto size = lines.size();
|
||||||
|
item = new QTableWidgetItem("S"+QString::number(size));
|
||||||
|
table->setItem(row, col, item);
|
||||||
|
if(size==scanCnt) {
|
||||||
|
QMessageBox::information(this, "提示", "行走完");
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
vBox->addWidget(table);
|
vBox->addWidget(table);
|
||||||
|
|
||||||
|
@ -420,21 +446,23 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(QWidget *parent) : BaseWin{parent
|
||||||
connect(btnPrev, &QPushButton::clicked, this, [stack, btnPrev, btnNext] {
|
connect(btnPrev, &QPushButton::clicked, this, [stack, btnPrev, btnNext] {
|
||||||
auto idx = stack->currentIndex();
|
auto idx = stack->currentIndex();
|
||||||
stack->setCurrentIndex(--idx);
|
stack->setCurrentIndex(--idx);
|
||||||
btnPrev->setVisible(idx > 0);
|
btnPrev->setEnabled(idx > 0);
|
||||||
btnNext->setVisible(idx < stack->count()-1);
|
btnNext->setEnabled(idx < stack->count()-1);
|
||||||
});
|
});
|
||||||
connect(btnNext, &QPushButton::clicked, this, [this, stack, btnPrev, btnNext] {
|
connect(btnNext, &QPushButton::clicked, this, [this, stack, btnPrev, btnNext] {
|
||||||
auto idx = stack->currentIndex();
|
auto idx = stack->currentIndex();
|
||||||
if(idx==0) {
|
if(idx==0) {
|
||||||
moduleWidth = fdModuleWidth->value();
|
moduleWidth = fdModuleWidth->value();
|
||||||
moduleHeight = fdModuleHeight->value();
|
moduleHeight = fdModuleHeight->value();
|
||||||
|
grpCnt = fdGrpCnt->value();
|
||||||
|
scanCnt = (moduleHeight + 1) / grpCnt;
|
||||||
} else if(idx==2) {
|
} else if(idx==2) {
|
||||||
table->setColumnCount(moduleWidth);
|
table->setColumnCount(moduleWidth);
|
||||||
table->setRowCount(moduleHeight);
|
table->setRowCount(moduleHeight);
|
||||||
}
|
}
|
||||||
stack->setCurrentIndex(++idx);
|
stack->setCurrentIndex(++idx);
|
||||||
btnPrev->setVisible(idx > 0);
|
btnPrev->setEnabled(idx > 0);
|
||||||
btnNext->setVisible(idx < stack->count()-1);
|
btnNext->setEnabled(idx < stack->count()-1);
|
||||||
});
|
});
|
||||||
|
|
||||||
auto btnCcl = new QPushButton("取消");
|
auto btnCcl = new QPushButton("取消");
|
||||||
|
@ -443,3 +471,47 @@ ExpertSmartPointSetWin::ExpertSmartPointSetWin(QWidget *parent) : BaseWin{parent
|
||||||
|
|
||||||
hBox->addSpacing(30);
|
hBox->addSpacing(30);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ExpertSmartPointSetWin::save() {
|
||||||
|
auto dlg = new BaseDlg(this);
|
||||||
|
dlg->setWindowTitle("保存设置");
|
||||||
|
|
||||||
|
auto vBox = new VBox(dlg->center);
|
||||||
|
vBox->setContentsMargins(0,0,0,0);
|
||||||
|
|
||||||
|
auto hBox = new HBox(vBox);
|
||||||
|
dlg->addBtns(hBox);
|
||||||
|
|
||||||
|
vBox->addSpacing(20);
|
||||||
|
hBox = new HBox(vBox);
|
||||||
|
hBox->addWidget(new QLabel("文件名称: "));
|
||||||
|
hBox->addWidget(new QLineEdit(QString("1X2_3扫").arg(moduleWidth).arg(moduleHeight).arg(scanCnt)));
|
||||||
|
|
||||||
|
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 btnChoose = new QPushButton("选择路径");
|
||||||
|
connect(btnChoose, &QPushButton::clicked, this, [this, fdPath] {
|
||||||
|
auto dir = QFileDialog::getExistingDirectory(this, "选择存储文件的目录", fdPath->text());
|
||||||
|
});
|
||||||
|
hBox->addWidget(btnChoose);
|
||||||
|
|
||||||
|
vBox->addSpacing(20);
|
||||||
|
hBox = new HBox(vBox);
|
||||||
|
hBox->addStretch();
|
||||||
|
|
||||||
|
auto btnOK = new QPushButton("完成");
|
||||||
|
btnOK->setMinimumSize(90, 30);
|
||||||
|
connect(btnOK, &QPushButton::clicked, dlg, &BaseDlg::accept);
|
||||||
|
hBox->addWidget(btnOK);
|
||||||
|
|
||||||
|
auto btnBack = new QPushButton("返回");
|
||||||
|
btnBack->setMinimumSize(90, 30);
|
||||||
|
connect(btnBack, &QPushButton::clicked, dlg, &BaseDlg::reject);
|
||||||
|
hBox->addWidget(btnBack);
|
||||||
|
|
||||||
|
dlg->exec();
|
||||||
|
}
|
||||||
|
|
|
@ -14,21 +14,18 @@ public:
|
||||||
QTableWidget::setItem(row, column, item);
|
QTableWidget::setItem(row, column, item);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
struct Point {
|
|
||||||
int x;
|
|
||||||
int y;
|
|
||||||
int c{0};
|
|
||||||
};
|
|
||||||
|
|
||||||
class ExpertSmartPointSetWin : public BaseWin {
|
class ExpertSmartPointSetWin : public BaseWin {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ExpertSmartPointSetWin(QWidget *parent = nullptr);
|
explicit ExpertSmartPointSetWin(QWidget *parent = nullptr);
|
||||||
|
void save();
|
||||||
|
|
||||||
QSpinBox *fdModuleWidth, *fdModuleHeight;
|
QSpinBox *fdModuleWidth, *fdModuleHeight, *fdGrpCnt;
|
||||||
PointTable *table, *tableRow;
|
PointTable *table, *tableRow;
|
||||||
int virtualCnt = 0;
|
int virtualCnt = 0;
|
||||||
int moduleWidth{0}, moduleHeight{0};
|
QList<QPoint> lines;
|
||||||
|
int moduleWidth{16}, moduleHeight{8}, grpCnt{2}, scanCnt{4};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // EXPERTSMARTPOINTSETWIN_H
|
#endif // EXPERTSMARTPOINTSETWIN_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user