123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642 |
- #include "WaferProgramPage.h"
- std::unordered_map<int, bool> WaferProgramPage::m_IdIsUsedMap;
- WaferProgramPage::WaferProgramPage(QWidget* parent)
- : QWidget(parent)
- {
- ui.setupUi(this);
- ui.pushButtonSave->setProperty("type", "save");
- ui.pushButtonAdd->setProperty("type", "add");
- setStyleSheet(
- "QWidget { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #F1F4FD, stop: 1 #E5E4F6); }"
- "QDoubleSpinBox { background: #FFFFFF; border: 1px solid #BABBDC; border-radius: 6px; padding: 2px 5px; }"
- "QSpinBox { background: #FFFFFF; border: 1px solid #BABBDC; border-radius: 6px; padding: 2px 5px; }"
- "QLineEdit { background: #FFFFFF; border: 1px solid #BABBDC; border-radius: 6px; padding: 2px 5px; }"
- "QCheckBox::indicator { width: 20px; height: 20px; }"
- "QCheckBox::indicator:unchecked { background-color: #FFFFFF; border-radius: 2px; }"
- "QComboBox { background: #FFFFFF; border: 1px solid #BABBDC; border-radius: 6px; padding: 2px 5px; }"
- "QComboBox::drop-down { width: 20px; }"
- "QPushButton { background: #D0D0E8; border: 1px solid #BABBDC; border-radius: 6px; padding: 2px 5px; }" // Button background color
- "QPushButton:hover { background-color: #B0B0D8; }" // Lighter color on hover
- "QPushButton:pressed { background-color: #A0A0C8; }" // Darker color on press
- );
- m_manageDB = CManageDB::GetInstance();
- if (m_manageDB == nullptr) return;
- m_pProduct = m_manageDB->GetCProduct();
- if (m_pProduct == nullptr) return;
- m_pProgramCViewInterface= ns_module::CViewInterface::GetInstance();
- connect(ui.pushButtonSave, &QPushButton::clicked, this, [=]() {
- m_pProduct->SetAllWaferMatrix(m_vecWaferMatrix);
- CProduct* _Product = m_manageDB->GetCProduct();
- });
- connect(ui.pushButtonAdd, &QPushButton::clicked, this, [=]() {
- PROGRAM_WAFER_MATRIX_STRUCT newMatrix;
- //排序
- std::sort(m_vecWaferMatrix.begin(), m_vecWaferMatrix.end(),
- [](const PROGRAM_WAFER_MATRIX_STRUCT& a, const PROGRAM_WAFER_MATRIX_STRUCT& b) {
- return a.MatrixId < b.MatrixId;
- });
- int newId = 0;
- UINT maxID = 0;
- // 查找最大 MatrixId
- for (PROGRAM_WAFER_MATRIX_STRUCT& matrix : m_vecWaferMatrix)
- {
- if (matrix.MatrixId > maxID)
- {
- maxID = matrix.MatrixId;
- }
- }
- // 生成新的子矩阵 ID,确保唯一性
- newId = ++maxID;
- newMatrix.MatrixId = newId;
- newMatrix.MatrixRow = 1;
- newMatrix.MatrixCol = 1;
- int newVectorIndex = m_vecWaferMatrix.size();
- m_vecWaferMatrix.push_back(newMatrix);
- AddMatrixPage(newVectorIndex, newMatrix);
- });
- initPage();
- }
- void WaferProgramPage::initPage()
- {
- m_vecWaferMatrix = m_pProduct->GetWaferMatrix();
- for (int i = 0; i < m_vecWaferMatrix.size(); i++)
- {
- AddMatrixPage(i, m_vecWaferMatrix[i]);
- }
- }
- XY_DOUBLE_STRUCT WaferProgramPage::WaferGetAxisPosition(std::string ModuleType, XY_DOUBLE_STRUCT& pos)
- {
- /*CAxis* _Axis;
- CAxis::AXIS_TYPE eAxisType = _Axis->GetAxisType();*/
- if (m_pProgramCViewInterface == nullptr)
- {
- XY_DOUBLE_STRUCT errorPt = pos; // 可以根据需要返回一个错误状态
- // 弹出消息框显示位置
- QString positionString = QString("Unable to retrieve axis position for module type: %1").arg(QString::fromStdString(ModuleType));
- QMessageBox::information(this, "Axis Position Error", positionString);
- return errorPt;
- }
- m_pProgramCViewInterface->GetViewMotion()->GetAxisPosition(ModuleType, "X", pos.x);
- m_pProgramCViewInterface->GetViewMotion()->GetAxisPosition(ModuleType, "Y", pos.y);
- return pos;
- }
- void WaferProgramPage::AddMatrixPage(int vectorIndex, _PROGRAM_WAFER_MATRIX_STRUCT matrixData) {
- int matrixNum = m_vecWaferMatrix.size();
- int newMatrixID = ++matrixNum;
- QVector<QObject*> vecControls;
- QGroupBox* groupBox = new QGroupBox();
- QGridLayout* outMatrixGridLayout = new QGridLayout();
- outMatrixGridLayout->setSpacing(6);
- outMatrixGridLayout->setObjectName(QString::fromUtf8("subGridLayout"));
- groupBox->setLayout(outMatrixGridLayout);
- QGridLayout* subGridLayout = new QGridLayout();
- subGridLayout->setSpacing(6);
- subGridLayout->setObjectName(QString::fromUtf8("subGridLayout"));
- QLabel* labelTitle = new QLabel(this);
- labelTitle->setObjectName(QString::fromUtf8("labelTitle"));
- labelTitle->setText(tr("Matrix ") + QString::number(vectorIndex));
- subGridLayout->addWidget(labelTitle, 0, 0, 1, 1);
- vecControls.push_back(labelTitle);
- // 删除按钮
- QPushButton* pushButtonDelete = new QPushButton(this);
- pushButtonDelete->setObjectName(QString::fromUtf8("buttonDelete"));
- pushButtonDelete->setText(tr("Delete"));
- pushButtonDelete->setFixedWidth(62);
- subGridLayout->addWidget(pushButtonDelete, 0, 3, 1, 1); // 添加到标题右侧的第四列
- vecControls.push_back(pushButtonDelete);
- // 删除按钮点击事件
- connect(pushButtonDelete, &QPushButton::clicked, this, [=]() {
- // 删除当前矩阵页面及控件
- auto currentIt = m_mapWaferGroupBoxIndex.find(groupBox);
- if (currentIt != m_mapWaferGroupBoxIndex.end()) {
- int index = currentIt.value();
- m_mapWaferGroupBoxIndex.erase(currentIt);
- // 更新索引
- for (auto it = m_mapWaferGroupBoxIndex.begin(); it != m_mapWaferGroupBoxIndex.end(); it++) {
- if (it.value() > index) {
- int newIndex = it.value() - 1;
- m_mapWaferGroupBoxIndex.insert(it.key(), newIndex);
- }
- }
- // 删除矩阵数据
- m_vecWaferMatrix.erase(m_vecWaferMatrix.begin() + index);
- // 删除矩阵控件
- delete groupBox;
- }
- });
- QLabel* labelRow = new QLabel(this);
- labelRow->setObjectName(QString::fromUtf8("labelRow"));
- labelRow->setText(tr("Row & Cow "));
- subGridLayout->addWidget(labelRow, 1, 0, 1, 1);
- vecControls.push_back(labelRow);
- SpinBox* spinBoxRow = new SpinBox(this);
- spinBoxRow->setObjectName(QString::fromUtf8("spinBoxRow"));
- spinBoxRow->setValue(matrixData.MatrixRow);
- subGridLayout->addWidget(spinBoxRow, 1, 1, 1, 1);
- vecControls.push_back(spinBoxRow);
- /*QLabel* labelCol = new QLabel(this);
- labelCol->setObjectName(QString::fromUtf8("labelCol"));
- labelCol->setText(tr("Cow "));
- subGridLayout->addWidget(labelCol, 2, 0, 1, 1);
- vecControls.push_back(labelCol);*/
- SpinBox* spinBoxCol = new SpinBox(this);
- spinBoxCol->setObjectName(QString::fromUtf8("spinBoxCol"));
- spinBoxCol->setValue(matrixData.MatrixCol);
- subGridLayout->addWidget(spinBoxCol, 1, 2, 1, 1);
- vecControls.push_back(spinBoxCol);
- QLabel* labelLeftTop = new QLabel(this);
- labelLeftTop->setObjectName(QString::fromUtf8("labelLeftTop"));
- labelLeftTop->setText(tr("Left Top Pos "));
- subGridLayout->addWidget(labelLeftTop, 4, 0, 1, 1);
- vecControls.push_back(labelLeftTop);
- // Set all DoubleSpinBox width to 100
- DoubleSpinBox* doubleSpinBoxLeftTopX = new DoubleSpinBox(this);
- doubleSpinBoxLeftTopX->setObjectName(QString::fromUtf8("doubleSpinBoxLeftTopX"));
- doubleSpinBoxLeftTopX->setValue(matrixData.LeftTopPoint.x);
- doubleSpinBoxLeftTopX->setFixedWidth(100); // Set fixed width to 100
- subGridLayout->addWidget(doubleSpinBoxLeftTopX, 4, 1, 1, 1);
- vecControls.push_back(doubleSpinBoxLeftTopX);
- DoubleSpinBox* doubleSpinBoxLeftTopY = new DoubleSpinBox(this);
- doubleSpinBoxLeftTopY->setObjectName(QString::fromUtf8("doubleSpinBoxLeftTopY"));
- doubleSpinBoxLeftTopY->setValue(matrixData.LeftTopPoint.y);
- doubleSpinBoxLeftTopY->setFixedWidth(100); // Set fixed width to 100
- subGridLayout->addWidget(doubleSpinBoxLeftTopY, 4, 2, 1, 1);
- vecControls.push_back(doubleSpinBoxLeftTopY);
- // Adding button to get LeftTop position
- QPushButton* buttonLeftTop = new QPushButton("Get Pos", this);
- buttonLeftTop->setFixedWidth(62);
- subGridLayout->addWidget(buttonLeftTop, 4, 3, 1, 1); // Position the button next to LeftTopPos
- /*connect(buttonLeftTop, &QPushButton::clicked, this, [=]() {
- QString position = QString("X: %1, Y: %2").arg(doubleSpinBoxLeftTopX->value()).arg(doubleSpinBoxLeftTopY->value());
- QMessageBox::information(this, "Left Top Position", position);
- });*/
- connect(buttonLeftTop, &QPushButton::clicked, this, [=]() {
- // 获取+更新位置
- XY_DOUBLE_STRUCT position = WaferGetAxisPosition("WaferTable", m_vecWaferMatrix[vectorIndex].LeftTopPoint);
- // 更新 DoubleSpinBox 的值
- doubleSpinBoxLeftTopX->setValue(position.x); // 更新 X 轴
- doubleSpinBoxLeftTopY->setValue(position.y); // 更新 Y 轴
- });
- QLabel* labelRightTopPos = new QLabel(this);
- labelRightTopPos->setObjectName(QString::fromUtf8("labelRightTopPos"));
- labelRightTopPos->setText(tr("Right Top Pos "));
- subGridLayout->addWidget(labelRightTopPos, 5, 0, 1, 1);
- vecControls.push_back(labelRightTopPos);
- DoubleSpinBox* doubleSpinBoxRightTopX = new DoubleSpinBox(this);
- doubleSpinBoxRightTopX->setObjectName(QString::fromUtf8("doubleSpinBoxRightTopX"));
- doubleSpinBoxRightTopX->setValue(matrixData.RightTopPoint.x);
- doubleSpinBoxRightTopX->setFixedWidth(100); // Set fixed width to 100
- subGridLayout->addWidget(doubleSpinBoxRightTopX, 5, 1, 1, 1);
- vecControls.push_back(doubleSpinBoxRightTopX);
- DoubleSpinBox* doubleSpinBoxRightTopY = new DoubleSpinBox(this);
- doubleSpinBoxRightTopY->setObjectName(QString::fromUtf8("doubleSpinBoxRightTopY"));
- doubleSpinBoxRightTopY->setValue(matrixData.RightTopPoint.y);
- doubleSpinBoxRightTopY->setFixedWidth(100); // Set fixed width to 100
- subGridLayout->addWidget(doubleSpinBoxRightTopY, 5, 2, 1, 1);
- vecControls.push_back(doubleSpinBoxRightTopY);
- // Adding button to get RightTop position
- QPushButton* buttonRightTop = new QPushButton("Get Pos", this);
- buttonRightTop->setFixedWidth(62);
- subGridLayout->addWidget(buttonRightTop, 5, 3, 1, 1); // Position the button next to RightTopPos
- connect(buttonRightTop, &QPushButton::clicked, this, [=]() {
- // 获取+更新位置
- XY_DOUBLE_STRUCT position = WaferGetAxisPosition("WaferTable", m_vecWaferMatrix[vectorIndex].LeftTopPoint);
- // 更新 DoubleSpinBox 的值
- doubleSpinBoxRightTopX->setValue(position.x); // 更新 X 轴
- doubleSpinBoxRightTopY->setValue(position.y); // 更新 Y 轴
- });
- QLabel* labelRightButtomPos = new QLabel(this);
- labelRightButtomPos->setObjectName(QString::fromUtf8("labelRightButtomPos"));
- labelRightButtomPos->setText(tr("Right Buttom pos"));
- subGridLayout->addWidget(labelRightButtomPos, 6, 0, 1, 1);
- vecControls.push_back(labelRightButtomPos);
- DoubleSpinBox* doubleSpinBoxRightButtomX = new DoubleSpinBox(this);
- doubleSpinBoxRightButtomX->setObjectName(QString::fromUtf8("doubleSpinBoxRightButtomX"));
- doubleSpinBoxRightButtomX->setValue(matrixData.RightBottomPoint.x);
- doubleSpinBoxRightButtomX->setFixedWidth(100); // Set fixed width to 100
- subGridLayout->addWidget(doubleSpinBoxRightButtomX, 6, 1, 1, 1);
- vecControls.push_back(doubleSpinBoxRightButtomX);
- DoubleSpinBox* doubleSpinBoxRightButtomY = new DoubleSpinBox(this);
- doubleSpinBoxRightButtomY->setObjectName(QString::fromUtf8("doubleSpinBoxRightButtomY"));
- doubleSpinBoxRightButtomY->setValue(matrixData.RightBottomPoint.y);
- doubleSpinBoxRightButtomY->setFixedWidth(100); // Set fixed width to 100
- subGridLayout->addWidget(doubleSpinBoxRightButtomY, 6, 2, 1, 1);
- vecControls.push_back(doubleSpinBoxRightButtomY);
- // Adding button to get RightBottom position
- QPushButton* buttonRightButtom = new QPushButton("Get Pos", this);
- buttonRightButtom->setFixedWidth(62);
- subGridLayout->addWidget(buttonRightButtom, 6, 3, 1, 1); // Position the button next to RightBottomPos
- connect(buttonRightButtom, &QPushButton::clicked, this, [=]() {
- // 获取+更新位置
- XY_DOUBLE_STRUCT position = WaferGetAxisPosition("WaferTable", m_vecWaferMatrix[vectorIndex].LeftTopPoint);
- // 更新 DoubleSpinBox 的值
- doubleSpinBoxRightButtomX->setValue(position.x); // 更新 X 轴
- doubleSpinBoxRightButtomY->setValue(position.y); // 更新 Y 轴
- });
- QLabel* labelNoBondPts = new QLabel(this);
- labelNoBondPts->setObjectName(QString::fromUtf8("labelNoBondPts"));
- labelNoBondPts->setText(tr("No Bond Points"));
- subGridLayout->addWidget(labelNoBondPts, 7, 0, 1, 1);
- vecControls.push_back(labelNoBondPts);
- QLineEdit* lineEditNoBondPts = new QLineEdit(this);
- lineEditNoBondPts->setObjectName(QString::fromUtf8("lineEditNoBondPts"));
- lineEditNoBondPts->setReadOnly(true);
- lineEditNoBondPts->setCursor(Qt::PointingHandCursor);
- lineEditNoBondPts->setProperty("vectorIndex", vectorIndex); // Store the index
- lineEditNoBondPts->installEventFilter(this);
- subGridLayout->addWidget(lineEditNoBondPts, 7, 1, 1, 3);
- vecControls.push_back(lineEditNoBondPts);
- outMatrixGridLayout->addLayout(subGridLayout, 0, 0);
- QFrame* line = new QFrame();
- line->setFrameShape(QFrame::NoFrame);
- line->setFixedHeight(2);
- line->setStyleSheet("background-color: #C7CAEB;");
- outMatrixGridLayout->addWidget(line);
- ui.verticalLayout->addWidget(groupBox);
- m_mapWaferGroupBoxIndex.insert(groupBox, vectorIndex);
- // 连接信号和槽
- connect(spinBoxRow, &SpinBox::editDone, this, [=]() {
- m_vecWaferMatrix[vectorIndex].MatrixRow = spinBoxRow->value();
- });
- connect(spinBoxCol, &SpinBox::editDone, this, [=]() {
- m_vecWaferMatrix[vectorIndex].MatrixCol = spinBoxCol->value();
- });
- connect(doubleSpinBoxLeftTopX, &DoubleSpinBox::editDone, this, [=]() {
- m_vecWaferMatrix[vectorIndex].LeftTopPoint.x = doubleSpinBoxLeftTopX->value();
- });
- connect(doubleSpinBoxLeftTopY, &DoubleSpinBox::editDone, this, [=]() {
- m_vecWaferMatrix[vectorIndex].LeftTopPoint.y = doubleSpinBoxLeftTopY->value();
- });
- connect(doubleSpinBoxRightTopX, &DoubleSpinBox::editDone, this, [=]() {
- m_vecWaferMatrix[vectorIndex].RightTopPoint.x = doubleSpinBoxRightTopX->value();
- });
- connect(doubleSpinBoxRightTopY, &DoubleSpinBox::editDone, this, [=]() {
- m_vecWaferMatrix[vectorIndex].RightTopPoint.y = doubleSpinBoxRightTopY->value();
- });
- connect(doubleSpinBoxRightButtomX, &DoubleSpinBox::editDone, this, [=]() {
- m_vecWaferMatrix[vectorIndex].RightBottomPoint.x = doubleSpinBoxRightButtomX->value();
- });
- connect(doubleSpinBoxRightButtomY, &DoubleSpinBox::editDone, this, [=]() {
- m_vecWaferMatrix[vectorIndex].RightBottomPoint.y = doubleSpinBoxRightButtomY->value();
- });
- connect(lineEditNoBondPts, &QLineEdit::textChanged, this, [=]() {
- // Handle NoBondPts logic here
- });
- }
- bool WaferProgramPage::eventFilter(QObject* obj, QEvent* event) {
- if (event->type() == QEvent::MouseButtonPress) {
- auto* lineEdit = qobject_cast<QLineEdit*>(obj);
- if (lineEdit) {
- int index = lineEdit->property("vectorIndex").toInt();
- if (lineEdit->property("vectorIndex").isValid()) {
- // Handle WaffleMatrix
- onNoBondPtsClickedWafer(lineEdit, index);
- }
- return true; // Intercept the event
- }
- }
- return QWidget::eventFilter(obj, event);
- }
- void WaferProgramPage::onNoBondPtsClickedWafer(QLineEdit* lineEdit, int index) {
- if (index < 0 || index >= m_vecWaferMatrix.size()) return;
- const auto& wafer = m_vecWaferMatrix[index];
- NoBondPtEditDialog dlg(wafer.MatrixRow, wafer.MatrixCol, wafer.VecNoBondPt, this);
- if (dlg.exec() == QDialog::Accepted) {
- QVector<XY_LONG_STRUCT> selected = dlg.getSelectedPoints();
- m_vecWaferMatrix[index].VecNoBondPt = std::vector<XY_LONG_STRUCT>(selected.begin(), selected.end());
- QStringList ptList;
- for (const auto& pt : selected)
- ptList << QString("(%1,%2)").arg(pt.x).arg(pt.y);
- lineEdit->setText(ptList.join(" "));
- }
- }
- //QWidget* WaferProgramPage::CreateWaferProgramPage(const CONFIG_BASE_STRUCT& control) {
- // return new WaferProgramPage();
- //}
- //创建下拉列表
- //QComboBox* WaferProgramPage::createDieMatrixIdComboBox(int defaultId, int row) {
- // QComboBox* comboBox = new QComboBox(m_MergedTable);
- //
- // // 设置样式,确保在暗色模式下也是白底黑字
- // comboBox->setStyleSheet(R"(
- // QComboBox {
- // background-color: white;
- // color: black;
- // border: 1px solid #BABBDC;
- // border-radius: 4px;
- // padding: 2px 5px;
- // }
- // QComboBox QAbstractItemView {
- // background-color: white;
- // color: black;
- // selection-background-color: #E5E5FF;
- // selection-color: black;
- // }
- // )");
- // for (const auto& dieMatrix : m_vecDieMatrixt) {
- // /*comboBox->addItem(
- // QString("%1 - %2").arg(dieMatrix.MatrixId).arg(QString::fromStdString(dieMatrix.strModuleName)),
- // QVariant(dieMatrix.MatrixId)
- // );*/
- // comboBox->addItem(QString::number(dieMatrix.MatrixId), QVariant(dieMatrix.MatrixId));
- // }
- //
- // int index = comboBox->findData(defaultId);
- // if (index >= 0)
- // comboBox->setCurrentIndex(index);
- //
- // return comboBox;
- //}
- //
- //void WaferProgramPage::initMergedData() {
- // m_isInitializing = true;
- //
- // SqlOperation& sqlOp = SqlOperation::GetInstance();
- // QList<QJsonObject> directories;
- // int userPrivilege = 0;//?
- // sqlOp.GetDirectories("Dir_Programme", userPrivilege, directories); // 使用相应的表名和权限加载目录
- // m_vecWaferMatrix = m_pProduct->GetWaferMatrix();
- //
- // for (const PROGRAM_WAFER_MATRIX_STRUCT& wafer : m_vecWaferMatrix) {
- // int row = m_MergedTable->rowCount();
- // m_MergedTable->insertRow(row);
- // PROGRAM_DIE_MATRIX_STRUCT stDieMatrix;
- // m_pProduct->GetDieMatrix(wafer.MatrixId, stDieMatrix);
- // m_vecDieMatrixt.push_back(stDieMatrix);
- //
- // // 填充表格数据
- // m_MergedTable->setItem(row, 0, new QTableWidgetItem(QString::number(wafer.MatrixId))); // MatrixID
- // m_MergedTable->setItem(row, 1, new QTableWidgetItem(QString::number(wafer.MatrixRow))); // MatrixRow
- // m_MergedTable->setItem(row, 2, new QTableWidgetItem(QString::number(wafer.MatrixCol))); // MatrixCol
- // m_MergedTable->setItem(row, 3, new QTableWidgetItem(QString::number(wafer.LeftTopPoint.y))); // LeftTopPoint_Y
- // m_MergedTable->setItem(row, 4, new QTableWidgetItem(QString::number(wafer.LeftTopPoint.x))); // LeftTopPoint_X
- // m_MergedTable->setItem(row, 5, new QTableWidgetItem(QString::number(wafer.RightTopPoint.x))); // RightTopPoint_X
- // m_MergedTable->setItem(row, 6, new QTableWidgetItem(QString::number(wafer.RightTopPoint.y))); // RightTopPoint_Y
- // m_MergedTable->setItem(row, 7, new QTableWidgetItem(QString::number(wafer.RightBottomPoint.x))); // RightBottomPoint_X
- // m_MergedTable->setItem(row, 8, new QTableWidgetItem(QString::number(wafer.RightBottomPoint.y))); // RightBottomPoint_Y
- // m_MergedTable->setItem(row, 9, new QTableWidgetItem(QString::number(wafer.iDieMatrixId))); // DieMatrixId
- //
- // // 填充 NoBondPt 数据
- // QStringList noBondPts;
- // for (const XY_LONG_STRUCT& pt : wafer.VecNoBondPt) {
- // noBondPts.append(QString("(%1,%2)").arg(pt.x).arg(pt.y));
- // }
- // m_MergedTable->setItem(row, 10, new QTableWidgetItem(noBondPts.join(" "))); // NoBondPt
- // }
- //
- // // 调整列宽和行高
- // m_MergedTable->resizeColumnsToContents();
- // m_MergedTable->resizeRowsToContents();
- //
- // m_isInitializing = false;// 开启信号处理
- //}
- //
- //void WaferProgramPage::addRow() {
- // m_isInitializing = true;
- // m_IdIsUsedMap.clear();
- // for (const auto& wafer : m_vecWaferMatrix) {
- // m_IdIsUsedMap[wafer.MatrixId] = true;
- // }
- // int row = m_MergedTable->rowCount();
- // m_MergedTable->insertRow(row);
- //
- // int newId = 1;
- // bool idUsed = true;
- //
- // //// 检查当前 MatrixId 是否已存在
- // //while (idUsed) {
- // // idUsed = false; // 假设 ID 没有被使用
- //
- // // // 如果 ID 已存在于 map 中,则说明已被使用
- // // if (m_IdIsUsedMap.find(newId) != m_IdIsUsedMap.end()) {
- // // idUsed = true;
- // // }
- //
- // // if (idUsed) {
- // // ++newId; // 如果 ID 被使用,检查下一个 ID
- // // }
- // //}
- // //找出最大的ID值
- // UINT maxId = 0;
- // for (PROGRAM_WAFER_MATRIX_STRUCT& bondMatrix : m_vecWaferMatrix)
- // {
- // if (bondMatrix.MatrixId > maxId)
- // {
- // maxId = bondMatrix.MatrixId;
- // }
- // }
- // newId = ++maxId;
- //
- // // 为新行添加默认数据
- // m_MergedTable->setItem(row, 0, new QTableWidgetItem(QString::number(newId))); // MatrixID 默认值为 0
- // m_MergedTable->setItem(row, 1, new QTableWidgetItem("1")); // MatrixRow 默认值为 1
- // m_MergedTable->setItem(row, 2, new QTableWidgetItem("1")); // MatrixCol 默认值为 1
- // m_MergedTable->setItem(row, 3, new QTableWidgetItem("0")); // LeftTopPoint_Y 默认值为 0
- // m_MergedTable->setItem(row, 4, new QTableWidgetItem("0")); // LeftTopPoint_X 默认值为 0
- // m_MergedTable->setItem(row, 5, new QTableWidgetItem("0")); // RightTopPoint_X 默认值为 0
- // m_MergedTable->setItem(row, 6, new QTableWidgetItem("0")); // RightTopPoint_Y 默认值为 0
- // m_MergedTable->setItem(row, 7, new QTableWidgetItem("0")); // RightBottomPoint_X 默认值为 0
- // m_MergedTable->setItem(row, 8, new QTableWidgetItem("0")); // RightBottomPoint_Y 默认值为 0
- // m_MergedTable->setItem(row, 9, new QTableWidgetItem("0")); // DieMatrixId 默认值为 0
- // /*QComboBox* comboBox = createDieMatrixIdComboBox(0, row);
- // m_MergedTable->setCellWidget(row, 9, comboBox);*/
- //
- // m_MergedTable->setItem(row, 10, new QTableWidgetItem("")); // NoBondPt 默认值为空
- //
- // // 同时更新 PROGRAM_WAFER_MATRIX_STRUCT 数据
- // PROGRAM_WAFER_MATRIX_STRUCT newMatrix;
- // newMatrix.MatrixId = newId;
- // newMatrix.MatrixRow = 1;
- // newMatrix.MatrixCol = 1;
- // newMatrix.LeftTopPoint = { 0.0, 0.0 };
- // newMatrix.RightTopPoint = { 0.0, 0.0 };
- // newMatrix.RightBottomPoint = { 0.0, 0.0 };
- // newMatrix.iDieMatrixId = 0;
- // newMatrix.VecNoBondPt.clear(); // 默认值为空
- //
- // m_vecWaferMatrix.push_back(newMatrix);
- // // 将新矩阵添加到数据结构中
- // //m_pProduct->AddWaferMatrix(newMatrix, newId);
- // m_isInitializing = false;
- //}
- //
- //void WaferProgramPage::deleteRow() {
- // int currentRow = m_MergedTable->currentRow();
- //
- // if (currentRow >= 0 && currentRow < m_MergedTable->rowCount()) {
- // // 获取 MatrixID(假设第0列是 MatrixID)
- // QTableWidgetItem* idItem = m_MergedTable->item(currentRow, 0);
- // if (!idItem) return;
- //
- // int matrixID = idItem->text().toInt();
- //
- // // 从 m_MergedTable 删除行
- // m_MergedTable->removeRow(currentRow);
- //
- // // 从 m_vecWaferMatrix 中移除对应项
- // auto it = std::remove_if(m_vecWaferMatrix.begin(), m_vecWaferMatrix.end(),
- // [matrixID](const PROGRAM_WAFER_MATRIX_STRUCT& wafer) {
- // return wafer.MatrixId == matrixID;
- // });
- // if (it != m_vecWaferMatrix.end()) {
- // m_vecWaferMatrix.erase(it, m_vecWaferMatrix.end());
- // }
- //
- // // 同时通知数据管理类删除
- // //m_pProduct->DeleteWaferMatrix(matrixID);
- //
- // }
- // else {
- // //QMessageBox::warning(this, "No Row Selected", "Please select a row to delete.");
- // QMessageBox box(QMessageBox::Warning, "No Row Selected", "Please select a row to delete.");
- // box.setStyleSheet(R"(
- // QMessageBox {
- // background-color: #eeeeee;
- // color: black;
- // }
- // QPushButton {
- // background-color: #dddddd;
- // color: black;
- // }
- // )");
- // box.exec();
- // }
- // currentRow = -1;
- //}
- //
- //void WaferProgramPage::updateData() {
- // // 1. 清空原模型中的矩阵
- // auto originalData = m_pProduct->GetWaferMatrix();
- // for (const auto& matrix : originalData) {
- // m_pProduct->DeleteWaferMatrix(matrix.MatrixId);
- // }
- //
- // // 2. 添加当前表格中的数据
- // for (auto& matrix : m_vecWaferMatrix) {
- // int newId = matrix.MatrixId;
- // m_pProduct->AddWaferMatrix(matrix, newId);
- // auto originalData1 = m_pProduct->GetWaferMatrix();
- // }
- //
- // //qDebug() << "WaferMatrix 已同步到模型层,共同步:" << m_vecWaferMatrix.size() << "条记录。";
- //}
- //void WaferProgramPage::onCellChanged(int row, int column)
- //{
- // if (m_isInitializing) return; // 防止初始化时触发
- // if (row >= m_vecWaferMatrix.size()) return;
- //
- // QTableWidgetItem* item = m_MergedTable->item(row, column);
- // if (!item) return;
- //
- // QString value = item->text();
- // PROGRAM_WAFER_MATRIX_STRUCT& wafer = m_vecWaferMatrix[row];
- //
- // switch (column) {
- // case 0: wafer.MatrixId = value.toInt(); break;
- // case 1: wafer.MatrixRow = value.toInt(); break;
- // case 2: wafer.MatrixCol = value.toInt(); break;
- // case 3: wafer.LeftTopPoint.y = value.toDouble(); break;
- // case 4: wafer.LeftTopPoint.x = value.toDouble(); break;
- // case 5: wafer.RightTopPoint.x = value.toDouble(); break;
- // case 6: wafer.RightTopPoint.y = value.toDouble(); break;
- // case 7: wafer.RightBottomPoint.x = value.toDouble(); break;
- // case 8: wafer.RightBottomPoint.y = value.toDouble(); break;
- // ////case 9: wafer.iDieMatrixId = value.toInt(); break;
- //
- // case 10: {
- // wafer.VecNoBondPt.clear();
- // QRegularExpression regex(R"(\((\d+),(\d+)\))");
- // QRegularExpressionMatchIterator i = regex.globalMatch(value);
- // while (i.hasNext()) {
- // auto match = i.next();
- // XY_LONG_STRUCT pt;
- // pt.x = match.captured(1).toInt();
- // pt.y = match.captured(2).toInt();
- // wafer.VecNoBondPt.push_back(pt);
- // }
- // break;
- // }
- // default: break;
- // }
- //}
|