#include "BondMatrixProgramPage.h" #include "Src/RewriteControl/Controls/SpinBox.h" #include "Src/RewriteControl/Controls/DoubleSpinBox.h" #include #include #include BondMatrixProgramPage::BondMatrixProgramPage(QWidget* parent) : QWidget(parent) { ui.setupUi(this); ui.pushButtonSave->setProperty("type", "save"); ui.pushButtonAddOutMatrix->setProperty("type", "addOutMatrix"); ui.pushButtonSaveParaAs->setProperty("type", "saveParaAs"); ui.pushButtonSavePara->setProperty("type", "savePara"); 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(); ui.frame->setFrameShape(QFrame::NoFrame); // 移除默认框架 ui.frame->setFixedHeight(2); // 设置固定高度 ui.frame->setStyleSheet("background-color: #C7CAEB;"); //ui.tab->setStyleSheet("background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #F1F4FD, stop: 1 #E5E4F6)"); //从后端获取数据 m_vectBondMatrixs = m_manageDB->GetCProduct()->GetBondMatrix(); m_manageDB->GetCProduct()->GetAllPointMatrix(m_vecSubMatrixs); m_vecBondInfoData = m_manageDB->GetCProduct()->GetAllBondInfoData(); if (m_vectBondMatrixs.size() == 0) { return; } initPage(); connect(ui.pushButtonSave, &QPushButton::clicked, this, [=] { MatrixChangeEvent(); }); connect(ui.pushButtonAddOutMatrix, &QPushButton::clicked, this, [=]() { PROGRAM_BOND_MATRIX_STRUCT newMatrix; //排序 std::sort(m_vectBondMatrixs.begin(), m_vectBondMatrixs.end(), [](const PROGRAM_BOND_MATRIX_STRUCT& a, const PROGRAM_BOND_MATRIX_STRUCT& b) { return a.BondMatrixId < b.BondMatrixId; }); int newBondMatrixID = 0; UINT maxID = 0; // 查找最大 MatrixId for (PROGRAM_BOND_MATRIX_STRUCT& bondMatrix : m_vectBondMatrixs) { if (bondMatrix.BondMatrixId > maxID) { maxID = bondMatrix.BondMatrixId; } } newBondMatrixID = ++maxID; while (std::any_of(m_vectBondMatrixs.begin(), m_vectBondMatrixs.end(), [newBondMatrixID](const PROGRAM_BOND_MATRIX_STRUCT& bondMatrix) { return bondMatrix.BondMatrixId == newBondMatrixID; })) { newBondMatrixID++; // 如果生成的 ID 已经存在,递增直到找到唯一的 ID } newMatrix.BondMatrixId = newBondMatrixID; newMatrix.BondMatrixRow = 0; newMatrix.BondMatrixCol = 0; newMatrix.strModuleName = "UltraHead"; newMatrix.iModuleId = MODULE_LIST::BondHead; int newVectorIndex = m_vectBondMatrixs.size(); newMatrix.BondInfoId = 1; //std::vector newVecSubMatrix; m_vectBondMatrixs.push_back(newMatrix); AddOutMatrixPage(newVectorIndex, newMatrix, m_vecSubMatrixs); }); connect(ui.pushButtonSavePara, &QPushButton::clicked, this, [=] { MatrixChangeEvent(); ParamChangeEvent(); }); connect(ui.pushButtonSaveParaAs, &QPushButton::clicked, this, [=] { ParamSaveAsEvent(); }); //参数 connect(ui.comboBoxDieSource, QOverload::of(&QComboBox::currentIndexChanged), this, [=](int index) { if (index == 0) { m_curBondInfo.eDieSource = DIE_SOURCE::BY_WAFFLE; } else if (index == 1) { m_curBondInfo.eDieSource = DIE_SOURCE::BY_WAFER; } //ParamChangeEvent(); }); connect(ui.checkBoxIsCalib, &QCheckBox::clicked, this, [=](bool isChecked) { }); connect(ui.spinBoxPickTempID, &SpinBox::editDone, this, [=]() { m_curBondInfo.iPickPRStrategyId = ui.spinBoxPickTempID->value(); //ParamChangeEvent(); }); connect(ui.spinBoxPickNozzleID, &SpinBox::editDone, this, [=]() { m_curBondInfo.iPickHeadId = ui.spinBoxPickNozzleID->value(); //ParamChangeEvent(); }); connect(ui.spinBoxPreBondTemp, &SpinBox::editDone, this, [=]() { m_curBondInfo.iBondFrontPRStrategyId = ui.spinBoxPreBondTemp->value(); //ParamChangeEvent(); }); connect(ui.spinBoxPostBondTemp, &SpinBox::editDone, this, [=]() { m_curBondInfo.iBondBackPRStrategyId = ui.spinBoxPostBondTemp->value(); //ParamChangeEvent(); }); connect(ui.spinBoxBondTemp, &SpinBox::editDone, this, [=]() { m_curBondInfo.iBondPRStrategyId = ui.spinBoxBondTemp->value(); //ParamChangeEvent(); }); connect(ui.spinBoxLookUpTemp, &SpinBox::editDone, this, [=]() { m_curBondInfo.iLookUpPRStrategyId = ui.spinBoxLookUpTemp->value(); //ParamChangeEvent(); }); connect(ui.spinBoxCalibPickTemp, &SpinBox::editDone, this, [=]() { m_curBondInfo.iCalibPRStrategyId = ui.spinBoxCalibPickTemp->value(); //ParamChangeEvent(); }); connect(ui.spinBoxBondNozzleID, &SpinBox::editDone, this, [=]() { m_curBondInfo.iBondHeadId = ui.spinBoxBondNozzleID->value(); //ParamChangeEvent(); }); connect(ui.doubleSpinBoxBondOffsetX, &DoubleSpinBox::editDone, this, [=]() { m_curBondInfo.stOffset.x = ui.doubleSpinBoxBondOffsetX->value(); //ParamChangeEvent(); }); connect(ui.doubleSpinBoxBondOffsetY, &DoubleSpinBox::editDone, this, [=]() { m_curBondInfo.stOffset.y = ui.doubleSpinBoxBondOffsetY->value(); //ParamChangeEvent(); }); connect(ui.doubleSpinBoxBondOffsetAngle, &DoubleSpinBox::editDone, this, [=]() { m_curBondInfo.stOffset.a = ui.doubleSpinBoxBondOffsetAngle->value(); //ParamChangeEvent(); }); connect(ui.comboBoxPickParamType, &QComboBox::currentTextChanged, this, [=]() { //UpdatePagePickParam(); }); connect(ui.checkBoxPickBlockCheck, &QCheckBox::clicked, this, [=](bool isChecked) { if (ui.comboBoxPickParamType->currentIndex() == 0)//华夫盒 { m_curWaferPickParam.bCheckBlock = ui.checkBoxPickBlockCheck->isChecked(); } else if (ui.comboBoxPickParamType->currentIndex() == 1)//晶圆台 { m_curCalibPickParam.bCheckBlock = ui.checkBoxPickBlockCheck->isChecked(); } //ParamChangeEvent(); }); connect(ui.checkBoxPickLoseCheck, &QCheckBox::clicked, this, [=](bool isChecked) { if (ui.comboBoxPickParamType->currentIndex() == 0)//华夫盒 { m_curWaferPickParam.bCheckLose = ui.checkBoxPickLoseCheck->isChecked(); } else if (ui.comboBoxPickParamType->currentIndex() == 1)//晶圆台 { m_curCalibPickParam.bCheckLose = ui.checkBoxPickLoseCheck->isChecked(); } //ParamChangeEvent(); }); connect(ui.checkBoxPickFindForceCheck, &QCheckBox::clicked, this, [=](bool isChecked) { if (ui.comboBoxPickParamType->currentIndex() == 0)//华夫盒 { m_curWaferPickParam.bFindForce = ui.checkBoxPickFindForceCheck->isChecked(); } else if (ui.comboBoxPickParamType->currentIndex() == 1)//晶圆台 { m_curCalibPickParam.bFindForce = ui.checkBoxPickFindForceCheck->isChecked(); } //ParamChangeEvent(); }); connect(ui.doubleSpinBoxPrePickZ, &DoubleSpinBox::editDone, this, [=]() { if (ui.comboBoxPickParamType->currentIndex() == 0)//华夫盒 { m_curWaferPickParam.dPreLev = ui.doubleSpinBoxPrePickZ->value(); } else if (ui.comboBoxPickParamType->currentIndex() == 1)//晶圆台 { m_curCalibPickParam.dPreLev = ui.doubleSpinBoxPrePickZ->value(); } //ParamChangeEvent(); }); connect(ui.doubleSpinBoxPickForce, &DoubleSpinBox::editDone, this, [=]() { if (ui.comboBoxPickParamType->currentIndex() == 0)//华夫盒 { m_curWaferPickParam.dForce = ui.doubleSpinBoxPickForce->value(); } else if (ui.comboBoxPickParamType->currentIndex() == 1)//晶圆台 { m_curCalibPickParam.dForce = ui.doubleSpinBoxPickForce->value(); } //ParamChangeEvent(); }); connect(ui.doubleSpinBoxPickPosZ, &DoubleSpinBox::editDone, this, [=]() { if (ui.comboBoxPickParamType->currentIndex() == 0)//华夫盒 { m_curWaferPickParam.dWorkLev = ui.doubleSpinBoxPickPosZ->value(); } else if (ui.comboBoxPickParamType->currentIndex() == 1)//晶圆台 { m_curCalibPickParam.dWorkLev = ui.doubleSpinBoxPickPosZ->value(); } //ParamChangeEvent(); }); connect(ui.spinBoxPickGrabDelay, &SpinBox::editDone, this, [=]() { if (ui.comboBoxPickParamType->currentIndex() == 0)//华夫盒 { m_curWaferPickParam.iGrabDelay = ui.spinBoxPickGrabDelay->value(); } else if (ui.comboBoxPickParamType->currentIndex() == 1)//晶圆台 { m_curCalibPickParam.iGrabDelay = ui.spinBoxPickGrabDelay->value(); } //ParamChangeEvent(); }); connect(ui.spinBox_PickDelay, &SpinBox::editDone, this, [=]() { if (ui.comboBoxPickParamType->currentIndex() == 0)//华夫盒 { m_curWaferPickParam.iPickOrBondDelay = ui.spinBox_PickDelay->value(); } else if (ui.comboBoxPickParamType->currentIndex() == 1)//晶圆台 { m_curCalibPickParam.iPickOrBondDelay = ui.spinBox_PickDelay->value(); } //ParamChangeEvent(); }); connect(ui.spinBoxPickBlockCheckDelay, &SpinBox::editDone, this, [=]() { if (ui.comboBoxPickParamType->currentIndex() == 0)//华夫盒 { m_curWaferPickParam.iBlockOrLoseDelay = ui.spinBoxPickBlockCheckDelay->value(); } else if (ui.comboBoxPickParamType->currentIndex() == 1)//晶圆台 { m_curCalibPickParam.iBlockOrLoseDelay = ui.spinBoxPickBlockCheckDelay->value(); } //ParamChangeEvent(); }); connect(ui.spinBoxPickVacDelay, &SpinBox::editDone, this, [=]() { if (ui.comboBoxPickParamType->currentIndex() == 0)//华夫盒 { m_curWaferPickParam.iVacuumDelay = ui.spinBoxPickVacDelay->value(); } else if (ui.comboBoxPickParamType->currentIndex() == 1)//晶圆台 { m_curCalibPickParam.iVacuumDelay = ui.spinBoxPickVacDelay->value(); } //ParamChangeEvent(); }); connect(ui.spinBoxPickBlowDelay, &SpinBox::editDone, this, [=]() { if (ui.comboBoxPickParamType->currentIndex() == 0)//华夫盒 { m_curWaferPickParam.iBlowDelay = ui.spinBoxPickBlowDelay->value(); } else if (ui.comboBoxPickParamType->currentIndex() == 1)//晶圆台 { m_curCalibPickParam.iBlowDelay = ui.spinBoxPickBlowDelay->value(); } //ParamChangeEvent(); }); connect(ui.comboBoxBondParamType, &QComboBox::currentTextChanged, this, [=]() { UpdatePageBondParam(); }); connect(ui.checkBoxBondBlockCheck, &QCheckBox::clicked, this, [=](bool isChecked) { if (ui.comboBoxBondParamType->currentIndex() == 0)//中转台放晶 { m_curCalibPlaceParam.bCheckBlock = ui.checkBoxBondBlockCheck->isChecked(); } else if (ui.comboBoxBondParamType->currentIndex() == 1)//固晶台固晶 { m_curBondParam.bCheckBlock = ui.checkBoxBondBlockCheck->isChecked(); } //ParamChangeEvent(); }); connect(ui.checkBoxBondLoseCheck, &QCheckBox::clicked, this, [=](bool isChecked) { if (ui.comboBoxBondParamType->currentIndex() == 0)//中转台放晶 { m_curCalibPlaceParam.bCheckLose = ui.checkBoxBondLoseCheck->isChecked(); } else if (ui.comboBoxBondParamType->currentIndex() == 1)//固晶台固晶 { m_curBondParam.bCheckLose = ui.checkBoxBondLoseCheck->isChecked(); } //ParamChangeEvent(); }); connect(ui.checkBoxBondFindForce, &QCheckBox::clicked, this, [=](bool isChecked) { if (ui.comboBoxBondParamType->currentIndex() == 0)//中转台放晶 { m_curCalibPlaceParam.bFindForce = ui.checkBoxBondFindForce->isChecked(); } else if (ui.comboBoxBondParamType->currentIndex() == 1)//固晶台固晶 { m_curBondParam.bFindForce = ui.checkBoxBondFindForce->isChecked(); } //ParamChangeEvent(); }); connect(ui.doubleSpinBoxPreBondPosZ, &DoubleSpinBox::editDone, this, [=]() { if (ui.comboBoxBondParamType->currentIndex() == 0)//中转台放晶 { m_curCalibPlaceParam.dPreLev = ui.doubleSpinBoxPreBondPosZ->value(); } else if (ui.comboBoxBondParamType->currentIndex() == 1)//固晶台固晶 { m_curBondParam.dPreLev = ui.doubleSpinBoxPreBondPosZ->value(); } //ParamChangeEvent(); }); connect(ui.doubleSpinBoxBondForce, &DoubleSpinBox::editDone, this, [=]() { if (ui.comboBoxBondParamType->currentIndex() == 0)//中转台放晶 { m_curCalibPlaceParam.dForce = ui.doubleSpinBoxBondForce->value(); } else if (ui.comboBoxBondParamType->currentIndex() == 1)//固晶台固晶 { m_curBondParam.dForce = ui.doubleSpinBoxBondForce->value(); } //ParamChangeEvent(); }); connect(ui.doubleSpinBoxBondPosZ, &DoubleSpinBox::editDone, this, [=]() { if (ui.comboBoxBondParamType->currentIndex() == 0)//中转台放晶 { m_curCalibPlaceParam.dWorkLev = ui.doubleSpinBoxBondPosZ->value(); } else if (ui.comboBoxBondParamType->currentIndex() == 1)//固晶台固晶 { m_curBondParam.dWorkLev = ui.doubleSpinBoxBondPosZ->value(); } //ParamChangeEvent(); }); connect(ui.spinBoxBondGrabDelay, &SpinBox::editDone, this, [=]() { if (ui.comboBoxBondParamType->currentIndex() == 0)//中转台放晶 { m_curCalibPlaceParam.iGrabDelay = ui.spinBoxBondGrabDelay->value(); } else if (ui.comboBoxBondParamType->currentIndex() == 1)//固晶台固晶 { m_curBondParam.iGrabDelay = ui.spinBoxBondGrabDelay->value(); } //ParamChangeEvent(); }); connect(ui.spinBoxBondBlockCheckDelay, &SpinBox::editDone, this, [=]() { if (ui.comboBoxBondParamType->currentIndex() == 0)//中转台放晶 { m_curCalibPlaceParam.iBlockOrLoseDelay = ui.spinBoxBondBlockCheckDelay->value(); } else if (ui.comboBoxBondParamType->currentIndex() == 1)//固晶台固晶 { m_curBondParam.iBlockOrLoseDelay = ui.spinBoxBondBlockCheckDelay->value(); } //ParamChangeEvent(); }); connect(ui.spinBoxBondDelay, &SpinBox::editDone, this, [=]() { if (ui.comboBoxBondParamType->currentIndex() == 0)//中转台放晶 { m_curCalibPlaceParam.iPickOrBondDelay = ui.spinBoxBondDelay->value(); } else if (ui.comboBoxBondParamType->currentIndex() == 1)//固晶台固晶 { m_curBondParam.iPickOrBondDelay = ui.spinBoxBondDelay->value(); } //ParamChangeEvent(); }); connect(ui.spinBoxBondVacDelay, &SpinBox::editDone, this, [=]() { if (ui.comboBoxBondParamType->currentIndex() == 0)//中转台放晶 { m_curCalibPlaceParam.iVacuumDelay = ui.spinBoxBondVacDelay->value(); } else if (ui.comboBoxBondParamType->currentIndex() == 1)//固晶台固晶 { m_curBondParam.iVacuumDelay = ui.spinBoxBondVacDelay->value(); } //ParamChangeEvent(); }); connect(ui.spinBoxBondBlowDelay, &SpinBox::editDone, this, [=]() { if (ui.comboBoxBondParamType->currentIndex() == 0)//中转台放晶 { m_curCalibPlaceParam.iBlowDelay = ui.spinBoxBondBlowDelay->value(); } else if (ui.comboBoxBondParamType->currentIndex() == 1)//固晶台固晶 { m_curBondParam.iBlowDelay = ui.spinBoxBondBlowDelay->value(); } //ParamChangeEvent(); }); } BondMatrixProgramPage::~BondMatrixProgramPage() { } XY_DOUBLE_STRUCT BondMatrixProgramPage::BondGetAxisPosition(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 BondMatrixProgramPage::AddOutMatrixPage(int vectorIndex, PROGRAM_BOND_MATRIX_STRUCT matrixData, std::vector vecSubMatrix) { int matrixNum = m_mapSubMatrixControls.size(); int newMatrixID = ++matrixNum; QVector vecControls; QWidget* outWidget = new QWidget(); QGridLayout* outMatrixGridLayout = new QGridLayout(); outMatrixGridLayout->setSpacing(4); outMatrixGridLayout->setObjectName(QString::fromUtf8("Out GridLayout")); outMatrixGridLayout->setContentsMargins(0, 0, 0, 0); // 设置布局的边距为0 QGridLayout* boxGridLayout = new QGridLayout(); boxGridLayout->setSpacing(4); boxGridLayout->setObjectName(QString::fromUtf8("Box GridLayout")); boxGridLayout->setContentsMargins(0, 0, 0, 0); // 设置布局的边距为0 QHBoxLayout* buttonLayout = new QHBoxLayout(); QSpacerItem* item = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); buttonLayout->addSpacerItem(item); QGroupBox* groupBox = new QGroupBox(outWidget); groupBox->setLayout(boxGridLayout); QGridLayout* matrixGridLayout = new QGridLayout(); matrixGridLayout->setSpacing(4); matrixGridLayout->setObjectName(QString::fromUtf8("matrixGridLayout")); matrixGridLayout->setContentsMargins(0, 0, 0, 0); // 设置布局的边距为0 //// Add line for separation //QFrame* line = new QFrame(); //line->setFrameShape(QFrame::NoFrame); // Remove default frame //line->setFixedHeight(2); // Set fixed height for line //line->setStyleSheet("background-color: #C7CAEB;"); //outMatrixGridLayout->addWidget(line, 0, 0, 1, 4); // Add matrix title QLabel* labelTitle = new QLabel(outWidget); labelTitle->setObjectName(QString::fromUtf8("labelTitle")); labelTitle->setText(tr("Bond Matrix ") + QString::number(vectorIndex)); labelTitle->setStyleSheet("color: #6A78FF;height: 30px"); matrixGridLayout->addWidget(labelTitle, 0, 0, 1, 1); vecControls.push_back(labelTitle); //// Add Delete Out Matrix button //QPushButton* buttonDeleteOutMatrix = new QPushButton("Delete Matrix", outWidget); //outMatrixGridLayout->addWidget(buttonDeleteOutMatrix, 8, 0, 1, 3); //connect(buttonDeleteOutMatrix, &QPushButton::clicked, this, [=]() { // m_vectBondMatrixs.erase(m_vectBondMatrixs.begin() + vectorIndex); // delete outWidget; // }); // Add "Add Sub Matrix" button QPushButton* pushButtonAdd = new QPushButton(outWidget); pushButtonAdd->setObjectName(QString::fromUtf8("button Add")); pushButtonAdd->setText(tr("Add sub Matrix")); matrixGridLayout->addWidget(pushButtonAdd, 0, 2, 1, 2); pushButtonAdd->setProperty("type", "default"); connect(pushButtonAdd, &QPushButton::clicked, this, [=]() { int newSubMatrixIndex = m_vecSubMatrixs.size(); PROGRAM_POINT_MATRIX_STRUCT subMatrix; std::sort(m_vecSubMatrixs.begin(), m_vecSubMatrixs.end(), [](const PROGRAM_POINT_MATRIX_STRUCT& a, const PROGRAM_POINT_MATRIX_STRUCT& b) { return a.MatrixId < b.MatrixId; }); int newSubMatrixID = 0; UINT maxID = 0; // 查找最大 MatrixId for (PROGRAM_POINT_MATRIX_STRUCT& subMatrix : m_vecSubMatrixs) { if (subMatrix.MatrixId > maxID) { maxID = subMatrix.MatrixId; } } newSubMatrixID = ++maxID; while (std::any_of(m_vecSubMatrixs.begin(), m_vecSubMatrixs.end(), [newSubMatrixID](const PROGRAM_POINT_MATRIX_STRUCT& subMatrix) { return subMatrix.MatrixId == newSubMatrixID; })) { newSubMatrixID++; // 如果生成的 ID 已经存在,递增直到找到唯一的 ID } subMatrix.MatrixId = newSubMatrixID; subMatrix.strModuleName = "UltraHead"; subMatrix.iModuleId = MODULE_LIST::BondHead; subMatrix.MatrixRow = 0; subMatrix.MatrixCol = 0; m_vecSubMatrixs.push_back(subMatrix); // Add the submatrix to the bond matrix's VecPointMatrixId //找大矩阵ID/Index auto currentIt = m_mapOutWidgetIndex.find(outWidget); int index = currentIt.value(); //迭代器 erase后currentIt被删除了 m_vectBondMatrixs[index].VecPointMatrixId.push_back(newSubMatrixID); AddMatrixPage(index, newSubMatrixIndex, subMatrix, outMatrixGridLayout); }); // Add Delete Out Matrix button QPushButton* pushButtonDelete = new QPushButton(outWidget); pushButtonDelete->setObjectName(QString::fromUtf8("button delete")); pushButtonDelete->setText(tr("Delete")); matrixGridLayout->addWidget(pushButtonDelete, 0, 1, 1, 1); connect(pushButtonDelete, &QPushButton::clicked, this, [=]() { //处理index auto currentIt = m_mapOutWidgetIndex.find(outWidget); int index = currentIt.value(); //迭代器 erase后currentIt被删除了 m_mapOutWidgetIndex.erase(currentIt); for (auto it = m_mapOutWidgetIndex.begin(); it != m_mapOutWidgetIndex.end(); it++) { if (it.value() > index) { int newIndex = it.value() - 1; m_mapOutWidgetIndex.insert(it.key(), newIndex); } } //删除缓存数据 m_vectBondMatrixs.erase(m_vectBondMatrixs.begin() + vectorIndex); //m_mapBondMatrixToSubMatrices.remove(vectorIndex); // Remove mapping between BondMatrix and its SubMatrices delete outWidget; }); // Add Row and Column controls QLabel* labelRow = new QLabel(outWidget); labelRow->setObjectName(QString::fromUtf8("labelRow")); labelRow->setText(tr("Row & Cow")); matrixGridLayout->addWidget(labelRow, 2, 0, 1, 1); vecControls.push_back(labelRow); SpinBox* spinBoxRow = new SpinBox(outWidget); spinBoxRow->setObjectName(QString::fromUtf8("spinBoxRow")); spinBoxRow->setFixedWidth(100); // Set fixed width to 100 matrixGridLayout->addWidget(spinBoxRow, 2, 1, 1, 1); vecControls.push_back(spinBoxRow); /*QLabel* labelCol = new QLabel(outWidget); labelCol->setObjectName(QString::fromUtf8("labelCol")); labelCol->setText(tr("Column ")); outMatrixGridLayout->addWidget(labelCol, 3, 0, 1, 1); vecControls.push_back(labelCol);*/ SpinBox* spinBoxCol = new SpinBox(outWidget); spinBoxCol->setObjectName(QString::fromUtf8("spinBoxCol")); spinBoxCol->setFixedWidth(100); // Set fixed width to 100 matrixGridLayout->addWidget(spinBoxCol, 2, 2, 1, 1); vecControls.push_back(spinBoxCol); // Add Left Top Position controls QLabel* labelLeftTop = new QLabel(outWidget); labelLeftTop->setObjectName(QString::fromUtf8("labelLeftTop")); labelLeftTop->setText(tr("Left Top Pos ")); matrixGridLayout->addWidget(labelLeftTop, 4, 0, 1, 1); vecControls.push_back(labelLeftTop); DoubleSpinBox* doubleSpinBoxLeftTopX = new DoubleSpinBox(outWidget); doubleSpinBoxLeftTopX->setObjectName(QString::fromUtf8("doubleSpinBoxLeftTopX")); doubleSpinBoxLeftTopX->setFixedWidth(100); // Set fixed width to 100 matrixGridLayout->addWidget(doubleSpinBoxLeftTopX, 4, 1, 1, 1); vecControls.push_back(doubleSpinBoxLeftTopX); DoubleSpinBox* doubleSpinBoxLeftTopY = new DoubleSpinBox(outWidget); doubleSpinBoxLeftTopY->setObjectName(QString::fromUtf8("doubleSpinBoxLeftTopY")); doubleSpinBoxLeftTopY->setFixedWidth(100); // Set fixed width to 100 matrixGridLayout->addWidget(doubleSpinBoxLeftTopY, 4, 2, 1, 1); vecControls.push_back(doubleSpinBoxLeftTopY); // Add Get Pos button for Left Top QPushButton* buttonLeftTop = new QPushButton("Get Pos", this); buttonLeftTop->setFixedWidth(62); // Set the same width for the button matrixGridLayout->addWidget(buttonLeftTop, 4, 3, 1, 1); // Position the button next to LeftTopPos connect(buttonLeftTop, &QPushButton::clicked, this, [=]() { XY_DOUBLE_STRUCT position = BondGetAxisPosition("BondMatrix", m_vectBondMatrixs[vectorIndex].LeftTopPoint); doubleSpinBoxLeftTopX->setValue(position.x); doubleSpinBoxLeftTopY->setValue(position.y); }); // Add Right Top Position controls QLabel* labelRightTopPos = new QLabel(outWidget); labelRightTopPos->setObjectName(QString::fromUtf8("labelRightTopPos")); labelRightTopPos->setText(tr("Right Top Pos ")); matrixGridLayout->addWidget(labelRightTopPos, 5, 0, 1, 1); vecControls.push_back(labelRightTopPos); DoubleSpinBox* doubleSpinBoxRightTopX = new DoubleSpinBox(outWidget); doubleSpinBoxRightTopX->setObjectName(QString::fromUtf8("doubleSpinBoxRightTopX")); doubleSpinBoxRightTopX->setFixedWidth(100); // Set fixed width to 100 matrixGridLayout->addWidget(doubleSpinBoxRightTopX, 5, 1, 1, 1); vecControls.push_back(doubleSpinBoxRightTopX); DoubleSpinBox* doubleSpinBoxRightTopY = new DoubleSpinBox(outWidget); doubleSpinBoxRightTopY->setObjectName(QString::fromUtf8("doubleSpinBoxRightTopY")); doubleSpinBoxRightTopY->setFixedWidth(100); // Set fixed width to 100 matrixGridLayout->addWidget(doubleSpinBoxRightTopY, 5, 2, 1, 1); vecControls.push_back(doubleSpinBoxRightTopY); QPushButton* buttonRightTop = new QPushButton("Get Pos", this); buttonRightTop->setFixedWidth(62); // Set the same width for the button matrixGridLayout->addWidget(buttonRightTop, 5, 3, 1, 1); // Position the button next to RightTopPos connect(buttonRightTop, &QPushButton::clicked, this, [=]() { XY_DOUBLE_STRUCT position = BondGetAxisPosition("BondMatrix", m_vectBondMatrixs[vectorIndex].RightTopPoint); doubleSpinBoxRightTopX->setValue(position.x); doubleSpinBoxRightTopY->setValue(position.y); }); // Add Right Bottom Position controls QLabel* labelRightButtomPos = new QLabel(outWidget); labelRightButtomPos->setObjectName(QString::fromUtf8("labelRightButtomPos")); labelRightButtomPos->setText(tr("Right Buttom pos")); matrixGridLayout->addWidget(labelRightButtomPos, 6, 0, 1, 1); vecControls.push_back(labelRightButtomPos); DoubleSpinBox* doubleSpinBoxRightButtomX = new DoubleSpinBox(outWidget); doubleSpinBoxRightButtomX->setObjectName(QString::fromUtf8("doubleSpinBoxRightButtomX")); doubleSpinBoxRightButtomX->setFixedWidth(100); // Set fixed width to 100 matrixGridLayout->addWidget(doubleSpinBoxRightButtomX, 6, 1, 1, 1); vecControls.push_back(doubleSpinBoxRightButtomX); DoubleSpinBox* doubleSpinBoxRightButtomY = new DoubleSpinBox(outWidget); doubleSpinBoxRightButtomY->setObjectName(QString::fromUtf8("doubleSpinBoxRightButtomY")); doubleSpinBoxRightButtomY->setFixedWidth(100); // Set fixed width to 100 matrixGridLayout->addWidget(doubleSpinBoxRightButtomY, 6, 2, 1, 1); vecControls.push_back(doubleSpinBoxRightTopX); QPushButton* buttonRightButtom = new QPushButton("Get Pos", this); buttonRightButtom->setFixedWidth(62); // Set the same width for the button matrixGridLayout->addWidget(buttonRightButtom, 6, 3, 1, 1); // Position the button next to RightBottomPos connect(buttonRightButtom, &QPushButton::clicked, this, [=]() { XY_DOUBLE_STRUCT position = BondGetAxisPosition("BondMatrix", m_vectBondMatrixs[vectorIndex].RightBottomPoint); doubleSpinBoxRightButtomX->setValue(position.x); doubleSpinBoxRightButtomY->setValue(position.y); }); // Add No Bond Points line edit QLabel* labelNoBondPts = new QLabel(outWidget); labelNoBondPts->setObjectName(QString::fromUtf8("labelNoBondPts")); labelNoBondPts->setText(tr("No Bond Points")); matrixGridLayout->addWidget(labelNoBondPts, 7, 0, 1, 1); vecControls.push_back(labelNoBondPts); QLineEdit* lineEditNoBondPts = new QLineEdit(outWidget); lineEditNoBondPts->setObjectName(QString::fromUtf8("lineEditNoBondPts")); matrixGridLayout->addWidget(lineEditNoBondPts, 7, 1, 1, 3); vecControls.push_back(lineEditNoBondPts); lineEditNoBondPts->setReadOnly(true); lineEditNoBondPts->setCursor(Qt::PointingHandCursor); lineEditNoBondPts->setProperty("vectorIndex", vectorIndex); // 存储索引 lineEditNoBondPts->setProperty("parentMatrixIndex", -1); // 设置父矩阵的索引 lineEditNoBondPts->installEventFilter(this); /*QLineEdit* lineEditNoBondPts = new QLineEdit(outWidget); lineEditNoBondPts->setObjectName(QString::fromUtf8("lineEditNoBondPts")); matrixGridLayout->addWidget(lineEditNoBondPts, 7, 1, 1, 3); vecControls.push_back(lineEditNoBondPts);*/ // Paragram line edit QLabel* labelParagram = new QLabel(outWidget); labelParagram->setObjectName(QString::fromUtf8("labelParagram")); labelParagram->setText(tr("ParagramSet")); matrixGridLayout->addWidget(labelParagram, 8, 0, 1, 1); vecControls.push_back(labelParagram); QComboBox* comboBoxParagramSet = new QComboBox(outWidget); comboBoxParagramSet->setObjectName(QString::fromUtf8("comboBoxNoBondPts")); m_mapParagramSetComboBox.insert(comboBoxParagramSet, vectorIndex); // 添加选项到下拉框并关联 iInfoId for (const auto& bondMatrix : m_vecBondInfoData) { // 将 iInfoId 作为显示项添加到下拉框 QString itemText = QString::number(bondMatrix.iInfoId); // 显示编号 iInfoId // 添加项并使用 setData 存储 iInfoId 作为附加数据 comboBoxParagramSet->addItem(itemText, bondMatrix.iInfoId); } // 将下拉框添加到布局中 matrixGridLayout->addWidget(comboBoxParagramSet, 8, 1, 1, 1); // 将控件保存到 vecControls 中 vecControls.push_back(comboBoxParagramSet); // 连接 QComboBox 的信号和槽 connect(comboBoxParagramSet, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboBoxIndexChanged(int))); connect(comboBoxParagramSet, SIGNAL(showPopup()), this, SLOT(onComboBoxPopup())); QPushButton* buttonParagram = new QPushButton("ShowParagram", this); //buttonParagram->setFixedWidth(62); // Set the same width for the button matrixGridLayout->addWidget(buttonParagram, 8, 2, 1, 2); // Position the button next to RightBottomPos connect(buttonParagram, &QPushButton::clicked, this, [=]() { UpdateShowBondInfoData(m_vectBondMatrixs[vectorIndex].BondInfoId); }); QFrame* line = new QFrame(outWidget); line->setFrameShape(QFrame::NoFrame); // 移除默认框架 line->setFixedHeight(2); // 设置固定高度 line->setStyleSheet("background-color: #C7CAEB;"); boxGridLayout->addLayout(matrixGridLayout, 2, 0); boxGridLayout->addWidget(line); //outMatrixGridLayout->addLayout(buttonLayout, 1, 0); outMatrixGridLayout->addWidget(groupBox); outWidget->setLayout(outMatrixGridLayout); ui.verticalLayout_3->addWidget(outWidget); ui.verticalLayout_3->setContentsMargins(0, 0, 0, 0); // Adjust margins if necessary ui.verticalLayout_3->setAlignment(Qt::AlignTop | Qt::AlignLeft); // Align the layout to the top-left m_mapOutWidgetIndex.insert(outWidget, vectorIndex); // Add Sub Matrices for (int j = 0; j < matrixData.VecPointMatrixId.size(); j++) { for (int i = 0; i < m_vecSubMatrixs.size(); i++) { if (matrixData.VecPointMatrixId[j] == m_vecSubMatrixs[i].MatrixId) { AddMatrixPage(j, i, m_vecSubMatrixs[i], outMatrixGridLayout); } } } QSpacerItem* vSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding); ui.verticalLayout_3->addItem(vSpacer); // Add all controls and finalize layout /*outWidget->setLayout(outMatrixGridLayout); ui.scrollArea_2->setLayout(outMatrixGridLayout);*/ spinBoxRow->setValue(matrixData.BondMatrixRow); spinBoxCol->setValue(matrixData.BondMatrixCol); doubleSpinBoxLeftTopX->setValue(matrixData.LeftTopPoint.x); doubleSpinBoxLeftTopY->setValue(matrixData.LeftTopPoint.y); doubleSpinBoxRightTopX->setValue(matrixData.RightTopPoint.x); doubleSpinBoxRightTopY->setValue(matrixData.RightTopPoint.y); doubleSpinBoxRightButtomX->setValue(matrixData.RightBottomPoint.x); doubleSpinBoxRightButtomY->setValue(matrixData.RightBottomPoint.y); connect(spinBoxRow, &SpinBox::editDone, this, [=]() { m_vectBondMatrixs[vectorIndex].BondMatrixRow = spinBoxRow->value(); }); connect(spinBoxCol, &SpinBox::editDone, this, [=]() { m_vectBondMatrixs[vectorIndex].BondMatrixCol = spinBoxCol->value(); }); connect(doubleSpinBoxLeftTopX, &DoubleSpinBox::editDone, this, [=]() { m_vectBondMatrixs[vectorIndex].LeftTopPoint.x = doubleSpinBoxLeftTopX->value(); }); connect(doubleSpinBoxLeftTopY, &DoubleSpinBox::editDone, this, [=]() { m_vectBondMatrixs[vectorIndex].LeftTopPoint.y = doubleSpinBoxLeftTopY->value(); }); connect(doubleSpinBoxRightTopX, &DoubleSpinBox::editDone, this, [=]() { m_vectBondMatrixs[vectorIndex].RightTopPoint.x = doubleSpinBoxRightTopX->value(); }); connect(doubleSpinBoxRightTopY, &DoubleSpinBox::editDone, this, [=]() { m_vectBondMatrixs[vectorIndex].RightTopPoint.y = doubleSpinBoxRightTopY->value(); }); connect(doubleSpinBoxRightButtomX, &DoubleSpinBox::editDone, this, [=]() { m_vectBondMatrixs[vectorIndex].RightBottomPoint.x = doubleSpinBoxRightButtomX->value(); }); connect(doubleSpinBoxRightButtomY, &DoubleSpinBox::editDone, this, [=]() { m_vectBondMatrixs[vectorIndex].RightBottomPoint.y = doubleSpinBoxRightButtomY->value(); }); connect(lineEditNoBondPts, &QLineEdit::textChanged, this, [=]() { }); } void BondMatrixProgramPage::onComboBoxPopup() { // 获取当前的 QComboBox QComboBox* comboBox = qobject_cast(sender()); if (!comboBox) { return; } // 清空下拉框中的所有项 comboBox->clear(); // 重新填充下拉框选项,并更新 QMap 中的绑定关系 for (const auto& bondMatrix : m_vecBondInfoData) { // 显示编号 iInfoId QString itemText = QString::number(bondMatrix.iInfoId); // 将 iInfoId 添加到下拉框 comboBox->addItem(itemText, bondMatrix.iInfoId); } } //// 槽函数:每次下拉框弹出时刷新内容 //void BondMatrixProgramPage::onComboBoxPopup() { // // 清空下拉框中的所有项 // comboBoxParagramSet->clear(); // // // 重新填充下拉框选项 // for (const auto& bondMatrix : m_vecBondInfoData) { // // 显示编号 iInfoId // QString itemText = QString::number(bondMatrix.iInfoId); // // // 将 iInfoId 添加到下拉框 // comboBoxParagramSet->addItem(itemText, bondMatrix.iInfoId); // } //} void BondMatrixProgramPage::onComboBoxIndexChanged(int index) { // 获取当前选中的 QComboBox QComboBox* comboBox = qobject_cast(sender()); if (!comboBox) { return; } // 获取当前选中的 BondInfoId UINT selectedBondInfoId = comboBox->currentData().toUInt(); // 获取当前 QComboBox 对应的 vectorIndex int vectorIndex = m_mapParagramSetComboBox.value(comboBox, -1); // 从 QMap 中获取 vectorIndex if (vectorIndex != -1) { // 更新 m_vectBondMatrixs[vectorIndex].BondInfoId m_vectBondMatrixs[vectorIndex].BondInfoId = selectedBondInfoId; //qDebug() << "Updated BondInfoId for vectorIndex: " << vectorIndex; } else { //qDebug() << "No vectorIndex found for the combo box!"; } // 调用 UpdateShowBondInfoData 更新数据 UpdateShowBondInfoData(selectedBondInfoId); } void BondMatrixProgramPage::AddMatrixPage(int vectorIndex, int subVectorIndex, PROGRAM_POINT_MATRIX_STRUCT subMatrix, QGridLayout* layout) { QVector vecControls; QWidget* subWidget = new QWidget(); QGridLayout* subGridLayout = new QGridLayout(subWidget); subGridLayout->setSpacing(4); subGridLayout->setObjectName(QString::fromUtf8("subGridLayout")); //groupBox->setLayout(subGridLayout); subGridLayout->setContentsMargins(0, 0, 0, 0); // 设置布局的边距为0 subGridLayout->setAlignment(Qt::AlignCenter); QLabel* labelTitle = new QLabel(subWidget); labelTitle->setObjectName(QString::fromUtf8("labelTitle")); labelTitle->setText(tr("Sub Matrix ") + QString::number(subVectorIndex)); labelTitle->setStyleSheet("color: #808BFF;height: 30px"); subGridLayout->addWidget(labelTitle, 0, 1, 1, 1); vecControls.push_back(labelTitle); QPushButton* pushButtonDelete = new QPushButton(subWidget); pushButtonDelete->setObjectName(QString::fromUtf8("button delete")); pushButtonDelete->setText(tr("Delete")); subGridLayout->addWidget(pushButtonDelete, 0, 3, 1, 1); connect(pushButtonDelete, &QPushButton::clicked, this, [=]() { //处理index auto currentIt = m_mapSubWidgetIndex.find(subWidget); int index = currentIt.value(); //迭代器 erase后currentIt被删除了 m_mapSubWidgetIndex.erase(currentIt); for (auto it = m_mapSubWidgetIndex.begin(); it != m_mapSubWidgetIndex.end(); ++it) { if (it.value() > index) { //value() 返回的是副本不是引用 int newIndex = it.value() - 1; m_mapSubWidgetIndex.insert(it.key(), newIndex); } } // 子矩阵ID int subMatrixId = m_vecSubMatrixs[index].MatrixId; //删除缓存 m_vecSubMatrixs.erase(m_vecSubMatrixs.begin() + index); //删除大矩阵子ID数据(遍历删除) for (PROGRAM_BOND_MATRIX_STRUCT& matrix : m_vectBondMatrixs) { auto it = std::find(matrix.VecPointMatrixId.begin(), matrix.VecPointMatrixId.end(), subMatrixId); if (it != matrix.VecPointMatrixId.end()) { matrix.VecPointMatrixId.erase(it); } } delete subWidget; }); QLabel* labelRow = new QLabel(subWidget); labelRow->setObjectName(QString::fromUtf8("labelRow")); labelRow->setText(tr("Row & Cow")); subGridLayout->addWidget(labelRow, 2, 0, 1, 1); vecControls.push_back(labelRow); SpinBox* spinBoxRow = new SpinBox(subWidget); spinBoxRow->setObjectName(QString::fromUtf8("spinBoxRow")); subGridLayout->addWidget(spinBoxRow, 2, 1, 1, 1); vecControls.push_back(spinBoxRow); /*QLabel* labelCol = new QLabel(subWidget); labelCol->setObjectName(QString::fromUtf8("labelCol")); labelCol->setText(tr("Cow ")); subGridLayout->addWidget(labelCol, 3, 0, 1, 1); vecControls.push_back(labelCol);*/ SpinBox* spinBoxCol = new SpinBox(subWidget); spinBoxCol->setObjectName(QString::fromUtf8("spinBoxCol")); subGridLayout->addWidget(spinBoxCol, 2, 2, 1, 1); vecControls.push_back(spinBoxCol); QLabel* labelLeftTop = new QLabel(subWidget); labelLeftTop->setObjectName(QString::fromUtf8("labelLeftTop")); labelLeftTop->setText(tr("Left Top Pos ")); subGridLayout->addWidget(labelLeftTop, 4, 0, 1, 1); vecControls.push_back(labelLeftTop); DoubleSpinBox* doubleSpinBoxLeftTopX = new DoubleSpinBox(subWidget); doubleSpinBoxLeftTopX->setObjectName(QString::fromUtf8("doubleSpinBoxLeftTopX")); doubleSpinBoxLeftTopX->setFixedWidth(100); // Set fixed width to 100 doubleSpinBoxLeftTopX->setFixedWidth(100); // Set fixed width to 100 subGridLayout->addWidget(doubleSpinBoxLeftTopX, 4, 1, 1, 1); vecControls.push_back(doubleSpinBoxLeftTopX); DoubleSpinBox* doubleSpinBoxLeftTopY = new DoubleSpinBox(subWidget); doubleSpinBoxLeftTopY->setObjectName(QString::fromUtf8("doubleSpinBoxLeftTopY")); doubleSpinBoxLeftTopY->setFixedWidth(100); // Set fixed width to 100 doubleSpinBoxLeftTopY->setFixedWidth(100); // Set fixed width to 100 subGridLayout->addWidget(doubleSpinBoxLeftTopY, 4, 2, 1, 1); vecControls.push_back(doubleSpinBoxLeftTopY); QLabel* labelRightTopPos = new QLabel(subWidget); 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(subWidget); doubleSpinBoxRightTopX->setObjectName(QString::fromUtf8("doubleSpinBoxRightTopX")); doubleSpinBoxRightTopX->setFixedWidth(100); // Set fixed width to 100 subGridLayout->addWidget(doubleSpinBoxRightTopX, 5, 1, 1, 1); vecControls.push_back(doubleSpinBoxRightTopX); DoubleSpinBox* doubleSpinBoxRightTopY = new DoubleSpinBox(subWidget); doubleSpinBoxRightTopY->setObjectName(QString::fromUtf8("doubleSpinBoxRightTopY")); doubleSpinBoxRightTopY->setFixedWidth(100); // Set fixed width to 100 subGridLayout->addWidget(doubleSpinBoxRightTopY, 5, 2, 1, 1); vecControls.push_back(doubleSpinBoxRightTopY); QLabel* labelRightButtomPos = new QLabel(subWidget); 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(subWidget); doubleSpinBoxRightButtomX->setObjectName(QString::fromUtf8("doubleSpinBoxRightButtomX")); doubleSpinBoxRightButtomX->setFixedWidth(100); // Set fixed width to 100 subGridLayout->addWidget(doubleSpinBoxRightButtomX, 6, 1, 1, 1); vecControls.push_back(doubleSpinBoxRightButtomX); DoubleSpinBox* doubleSpinBoxRightButtomY = new DoubleSpinBox(subWidget); doubleSpinBoxRightButtomY->setObjectName(QString::fromUtf8("doubleSpinBoxRightButtomY")); doubleSpinBoxRightButtomY->setFixedWidth(100); // Set fixed width to 100 subGridLayout->addWidget(doubleSpinBoxRightButtomY, 6, 2, 1, 1); vecControls.push_back(doubleSpinBoxRightTopX); QLabel* labelNoBondPts = new QLabel(subWidget); 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(subWidget); lineEditNoBondPts->setObjectName(QString::fromUtf8("lineEditNoBondPts")); lineEditNoBondPts->setReadOnly(true); lineEditNoBondPts->setCursor(Qt::PointingHandCursor); lineEditNoBondPts->setProperty("vectorIndex", subVectorIndex); // 存储索引 lineEditNoBondPts->setProperty("parentMatrixIndex", vectorIndex); // 设置父矩阵的索引 lineEditNoBondPts->installEventFilter(this); subGridLayout->addWidget(lineEditNoBondPts, 7, 1, 1, 3); vecControls.push_back(lineEditNoBondPts); // Left Top Position X and Y QPushButton* buttonLeftTop = new QPushButton("Get Pos", subWidget); buttonLeftTop->setFixedWidth(62); // 设置固定宽度 subGridLayout->addWidget(buttonLeftTop, 4, 3, 1, 1); // 添加按钮到4行3列 connect(buttonLeftTop, &QPushButton::clicked, this, [=]() { XY_DOUBLE_STRUCT position = BondGetAxisPosition("UltraHead", m_vectBondMatrixs[subVectorIndex].LeftTopPoint); doubleSpinBoxLeftTopX->setValue(position.x); // 更新 X 轴 doubleSpinBoxLeftTopY->setValue(position.y); // 更新 Y 轴 }); // Right Top Position X and Y QPushButton* buttonRightTop = new QPushButton("Get Pos", subWidget); buttonRightTop->setFixedWidth(62); // 设置固定宽度 subGridLayout->addWidget(buttonRightTop, 5, 3, 1, 1); // 添加按钮到5行3列 connect(buttonRightTop, &QPushButton::clicked, this, [=]() { XY_DOUBLE_STRUCT position = BondGetAxisPosition("UltraHead", m_vectBondMatrixs[subVectorIndex].RightTopPoint); doubleSpinBoxRightTopX->setValue(position.x); // 更新 X 轴 doubleSpinBoxRightTopY->setValue(position.y); // 更新 Y 轴 }); // Right Bottom Position X and Y QPushButton* buttonRightButtom = new QPushButton("Get Pos", subWidget); buttonRightButtom->setFixedWidth(62); // 设置固定宽度 subGridLayout->addWidget(buttonRightButtom, 6, 3, 1, 1); // 添加按钮到6行3列 connect(buttonRightButtom, &QPushButton::clicked, this, [=]() { XY_DOUBLE_STRUCT position = BondGetAxisPosition("UltraHead", m_vectBondMatrixs[subVectorIndex].RightBottomPoint); doubleSpinBoxRightButtomX->setValue(position.x); // 更新 X 轴 doubleSpinBoxRightButtomY->setValue(position.y); // 更新 Y 轴 }); //layout->addLayout(subGridLayout, 11, 0); QFrame* line = new QFrame(subWidget); line->setFrameShape(QFrame::NoFrame); // 移除默认框架 line->setFixedHeight(2); // 设置固定高度 line->setStyleSheet("background-color: #C7CAEB;"); subGridLayout->addWidget(line, 10, 0, 1, 4); layout->addWidget(subWidget); m_mapSubWidgetIndex.insert(subWidget, subVectorIndex); spinBoxRow->setValue(subMatrix.MatrixRow); spinBoxCol->setValue(subMatrix.MatrixCol); doubleSpinBoxLeftTopX->setValue(subMatrix.LeftTopPoint.x); doubleSpinBoxLeftTopY->setValue(subMatrix.LeftTopPoint.y); doubleSpinBoxRightTopX->setValue(subMatrix.RightTopPoint.x); doubleSpinBoxRightTopY->setValue(subMatrix.RightTopPoint.y); doubleSpinBoxRightButtomX->setValue(subMatrix.RightBottomPoint.x); doubleSpinBoxRightButtomY->setValue(subMatrix.RightBottomPoint.y); connect(spinBoxRow, &SpinBox::editDone, this, [=]() { auto it = m_mapSubWidgetIndex.find(subWidget); m_vecSubMatrixs[it.value()].MatrixRow = spinBoxRow->value(); }); connect(spinBoxCol, &SpinBox::editDone, this, [=]() { auto it = m_mapSubWidgetIndex.find(subWidget); m_vecSubMatrixs[it.value()].MatrixCol = spinBoxCol->value(); }); connect(doubleSpinBoxLeftTopX, &DoubleSpinBox::editDone, this, [=]() { auto it = m_mapSubWidgetIndex.find(subWidget); m_vecSubMatrixs[it.value()].LeftTopPoint.x = doubleSpinBoxLeftTopX->value(); }); connect(doubleSpinBoxLeftTopY, &DoubleSpinBox::editDone, this, [=]() { auto it = m_mapSubWidgetIndex.find(subWidget); m_vecSubMatrixs[it.value()].LeftTopPoint.y = doubleSpinBoxLeftTopY->value(); }); connect(doubleSpinBoxRightTopX, &DoubleSpinBox::editDone, this, [=]() { auto it = m_mapSubWidgetIndex.find(subWidget); m_vecSubMatrixs[it.value()].RightTopPoint.x = doubleSpinBoxRightTopX->value(); }); connect(doubleSpinBoxRightTopY, &DoubleSpinBox::editDone, this, [=]() { auto it = m_mapSubWidgetIndex.find(subWidget); m_vecSubMatrixs[it.value()].RightTopPoint.y = doubleSpinBoxRightTopY->value(); }); connect(doubleSpinBoxRightButtomX, &DoubleSpinBox::editDone, this, [=]() { auto it = m_mapSubWidgetIndex.find(subWidget); m_vecSubMatrixs[it.value()].RightBottomPoint.x = doubleSpinBoxRightButtomX->value(); }); connect(doubleSpinBoxRightButtomY, &DoubleSpinBox::editDone, this, [=]() { auto it = m_mapSubWidgetIndex.find(subWidget); m_vecSubMatrixs[it.value()].RightBottomPoint.y = doubleSpinBoxRightButtomY->value(); }); connect(lineEditNoBondPts, &QLineEdit::textChanged, this, [=]() { auto it = m_mapSubWidgetIndex.find(subWidget); }); } bool BondMatrixProgramPage::eventFilter(QObject* obj, QEvent* event) { if (event->type() == QEvent::MouseButtonPress) { auto* lineEdit = qobject_cast(obj); if (lineEdit) { int index = lineEdit->property("vectorIndex").toInt(); // 当前矩阵索引 int parentIndex = lineEdit->property("parentMatrixIndex").toInt(); // 父矩阵索引 onNoBondPtsClicked(lineEdit, index, parentIndex); // 传递父矩阵索引 return true; // 拦截事件 } } return QWidget::eventFilter(obj, event); } void BondMatrixProgramPage::onNoBondPtsClicked(QLineEdit* lineEdit, int index, int parentIndex) { if (parentIndex != -1) { // 处理子矩阵的操作 if (index < 0 || index >= m_vecSubMatrixs.size()) return; const auto& subMatrix = m_vecSubMatrixs[index]; NoBondPtEditDialog dlg(subMatrix.MatrixRow, subMatrix.MatrixCol, subMatrix.VecNoBondPt, this); if (dlg.exec() == QDialog::Accepted) { QVector selected = dlg.getSelectedPoints(); m_vecSubMatrixs[index].VecNoBondPt = std::vector(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(" ")); } // 这里可以用 parentIndex 来关联父矩阵(即大矩阵)做相应的操作 } else { // 处理大矩阵的操作 if (index < 0 || index >= m_vectBondMatrixs.size()) return; const auto& bondMatrix = m_vectBondMatrixs[index]; NoBondPtEditDialog dlg(bondMatrix.BondMatrixRow, bondMatrix.BondMatrixCol, bondMatrix.VecNoBondPt, this); if (dlg.exec() == QDialog::Accepted) { QVector selected = dlg.getSelectedPoints(); m_vectBondMatrixs[index].VecNoBondPt = std::vector(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(" ")); } // 这里也可以用 parentIndex 来关联父矩阵(即大矩阵)做相应的操作 } } void BondMatrixProgramPage::AddMatrixParam() { } void BondMatrixProgramPage::UpdatePageParam() { int dieSourceIndex = 0; if (m_curBondInfo.eDieSource == DIE_SOURCE::BY_WAFER) { dieSourceIndex = 1; } else if (m_curBondInfo.eDieSource == DIE_SOURCE::BY_WAFFLE) { dieSourceIndex = 0; } ui.comboBoxDieSource->setCurrentIndex(dieSourceIndex); ui.spinBoxPickTempID->setValue(m_curBondInfo.iPickPRStrategyId); ui.spinBoxPickNozzleID->setValue(m_curBondInfo.iPickHeadId); ui.spinBoxPreBondTemp->setValue(m_curBondInfo.iBondFrontPRStrategyId); ui.spinBoxPostBondTemp->setValue(m_curBondInfo.iBondBackPRStrategyId); ui.spinBoxBondTemp->setValue(m_curBondInfo.iBondPRStrategyId); ui.spinBoxLookUpTemp->setValue(m_curBondInfo.iLookUpPRStrategyId); ui.spinBoxCalibPickTemp->setValue(m_curBondInfo.iCalibPRStrategyId); ui.doubleSpinBoxBondOffsetX->setValue(m_curBondInfo.stOffset.x); ui.doubleSpinBoxBondOffsetY->setValue(m_curBondInfo.stOffset.y); ui.doubleSpinBoxBondOffsetAngle->setValue(m_curBondInfo.stOffset.a); UpdatePagePickParam(); UpdatePageBondParam(); } int BondMatrixProgramPage::ParamSaveAsEvent() { int iWaferPickParamId,iCalibPlaceParamId,iCalibPickParamId,iBondParamId; m_manageDB->GetCProduct()->AddBondParam(m_curWaferPickParam, iWaferPickParamId); //SetBondParam(m_curWaferPickParam.iId, m_curWaferPickParam); m_manageDB->GetCProduct()->AddBondParam(m_curCalibPlaceParam, iCalibPlaceParamId); m_manageDB->GetCProduct()->AddBondParam(m_curCalibPickParam, iCalibPickParamId); m_manageDB->GetCProduct()->AddBondParam(m_curBondParam, iBondParamId); int iInfoId; m_manageDB->GetCProduct()->AddBondInfoData(m_curBondInfo, iInfoId); return iInfoId; } void BondMatrixProgramPage::ParamChangeEvent() { m_manageDB->GetCProduct()->SetBondInfoData(m_curBondInfo.iInfoId, m_curBondInfo); m_manageDB->GetCProduct()->SetBondParam(m_curWaferPickParam.iId, m_curWaferPickParam); m_manageDB->GetCProduct()->SetBondParam(m_curCalibPlaceParam.iId, m_curCalibPlaceParam); m_manageDB->GetCProduct()->SetBondParam(m_curCalibPickParam.iId, m_curCalibPickParam); m_manageDB->GetCProduct()->SetBondParam(m_curBondParam.iId, m_curBondParam); CProduct* _Product = m_manageDB->GetCProduct(); } void BondMatrixProgramPage::MatrixChangeEvent() { m_manageDB->GetCProduct()->SetAllBondMatrix(m_vectBondMatrixs, true); m_manageDB->GetCProduct()->SetAllPointMatrix(m_vecSubMatrixs, true); /*for (PROGRAM_BOND_MATRIX_STRUCT& bondMatrix : m_vectBondMatrixs) { m_manageDB->GetCProduct()->SetBondMatrix(bondMatrix.BondMatrixId, bondMatrix); }*/ /*for (PROGRAM_POINT_MATRIX_STRUCT& pointMatrix : m_vecSubMatrixs) { m_manageDB->GetCProduct()->SetPointMatrix(pointMatrix.MatrixId, pointMatrix); }*/ CProduct* _Product = m_manageDB->GetCProduct(); } void BondMatrixProgramPage::UpdatePagePickParam() { //"取晶头取晶" if (ui.comboBoxPickParamType->currentIndex() == 0) { ui.checkBoxPickBlockCheck->setChecked(m_curWaferPickParam.bCheckBlock); ui.checkBoxPickLoseCheck->setChecked(m_curWaferPickParam.bCheckLose); ui.checkBoxPickFindForceCheck->setChecked(m_curWaferPickParam.bFindForce); ui.doubleSpinBoxPrePickZ->setValue(m_curWaferPickParam.dPreLev); ui.doubleSpinBoxPickForce->setValue(m_curWaferPickParam.dForce); ui.doubleSpinBoxPickPosZ->setValue(m_curWaferPickParam.dWorkLev); ui.spinBoxPickGrabDelay->setValue(m_curWaferPickParam.iGrabDelay); ui.spinBox_PickDelay->setValue(m_curWaferPickParam.iPickOrBondDelay); ui.spinBoxPickBlockCheckDelay->setValue(m_curWaferPickParam.iBlockOrLoseDelay); ui.spinBoxPickVacDelay->setValue(m_curWaferPickParam.iVacuumDelay); ui.spinBoxPickBlowDelay->setValue(m_curWaferPickParam.iBlowDelay); } //"中转台取晶" else if (ui.comboBoxPickParamType->currentIndex() == 1) { ui.checkBoxPickBlockCheck->setChecked(m_curCalibPickParam.bCheckBlock); ui.checkBoxPickLoseCheck->setChecked(m_curCalibPickParam.bCheckLose); ui.checkBoxPickFindForceCheck->setChecked(m_curCalibPickParam.bFindForce); ui.doubleSpinBoxPrePickZ->setValue(m_curCalibPickParam.dPreLev); ui.doubleSpinBoxPickForce->setValue(m_curCalibPickParam.dForce); ui.doubleSpinBoxPickPosZ->setValue(m_curCalibPickParam.dWorkLev); ui.spinBoxPickGrabDelay->setValue(m_curCalibPickParam.iGrabDelay); ui.spinBox_PickDelay->setValue(m_curCalibPickParam.iPickOrBondDelay); ui.spinBoxPickBlockCheckDelay->setValue(m_curCalibPickParam.iBlockOrLoseDelay); ui.spinBoxPickVacDelay->setValue(m_curCalibPickParam.iVacuumDelay); ui.spinBoxPickBlowDelay->setValue(m_curCalibPickParam.iBlowDelay); } } void BondMatrixProgramPage::UpdatePageBondParam() { //"中转台放晶" if (ui.comboBoxBondParamType->currentIndex() == 0) { ui.checkBoxBondBlockCheck->setChecked(m_curCalibPlaceParam.bCheckBlock); ui.checkBoxBondLoseCheck->setChecked(m_curCalibPlaceParam.bCheckLose); ui.checkBoxBondFindForce->setChecked(m_curCalibPlaceParam.bFindForce); ui.doubleSpinBoxPreBondPosZ->setValue(m_curCalibPlaceParam.dPreLev); ui.doubleSpinBoxBondForce->setValue(m_curCalibPlaceParam.dForce); ui.doubleSpinBoxBondPosZ->setValue(m_curCalibPlaceParam.dWorkLev); ui.spinBoxBondGrabDelay->setValue(m_curCalibPlaceParam.iGrabDelay); ui.spinBoxBondDelay->setValue(m_curCalibPlaceParam.iPickOrBondDelay); ui.spinBoxBondBlockCheckDelay->setValue(m_curCalibPlaceParam.iBlockOrLoseDelay); ui.spinBoxBondVacDelay->setValue(m_curCalibPlaceParam.iVacuumDelay); ui.spinBoxBondBlowDelay->setValue(m_curCalibPlaceParam.iBlowDelay); } //"固晶台固晶" else if (ui.comboBoxBondParamType->currentIndex() == 1) { ui.checkBoxBondBlockCheck->setChecked(m_curBondParam.bCheckBlock); ui.checkBoxBondLoseCheck->setChecked(m_curBondParam.bCheckLose); ui.checkBoxBondFindForce->setChecked(m_curBondParam.bFindForce); ui.doubleSpinBoxPreBondPosZ->setValue(m_curBondParam.dPreLev); ui.doubleSpinBoxBondForce->setValue(m_curBondParam.dForce); ui.doubleSpinBoxBondPosZ->setValue(m_curBondParam.dWorkLev); ui.spinBoxBondGrabDelay->setValue(m_curBondParam.iGrabDelay); ui.spinBoxBondDelay->setValue(m_curBondParam.iPickOrBondDelay); ui.spinBoxBondBlockCheckDelay->setValue(m_curBondParam.iBlockOrLoseDelay); ui.spinBoxBondVacDelay->setValue(m_curBondParam.iVacuumDelay); ui.spinBoxBondBlowDelay->setValue(m_curBondParam.iBlowDelay); } } void BondMatrixProgramPage::initPage() { //for (int i = 0; i < m_vectBondMatrixs.size(); i++) //{ // for (int j = 0; j < m_vectBondMatrixs[i].VecPointMatrixId.size(); j++) // { // PROGRAM_POINT_MATRIX_STRUCT subMatrix; // m_manageDB->GetCProduct()->GetPointMatrix(m_vectBondMatrixs[i].VecPointMatrixId[j], subMatrix); // m_vecSubMatrixs.push_back(subMatrix); // //AddMatrixPage(i, j, subMatrix); // } // AddOutMatrixPage(i, m_vectBondMatrixs[i], m_vecSubMatrixs); //} for (int i = 0; i < m_vectBondMatrixs.size(); i++) { AddOutMatrixPage(i, m_vectBondMatrixs[i], m_vecSubMatrixs); } //for (int i = 0; i < m_vectBondMatrixs[0].VecPointMatrixId.size(); ++i) //{ // PROGRAM_POINT_MATRIX_STRUCT subMatrix; // m_manageDB->GetCProduct()->GetPointMatrix(m_vectBondMatrixs[0].VecPointMatrixId[i], subMatrix); // m_vecSubMatrixs.push_back(subMatrix); //} //m_manageDB->GetCProduct()->GetDieMatrix(m_vectBondMatrixs[0].VecPointMatrixId[0], m_vecSubMatrixs); //显示矩阵数据 /*ui.spinBoxRow->setValue(m_vectBondMatrixs[0].BondMatrixRow); ui.spinBoxCol->setValue(m_vectBondMatrixs[0].BondMatrixCol); ui.doubleSpinBoxLeftTopX->setValue(m_vectBondMatrixs[0].LeftTopPoint.x); ui.doubleSpinBoxLeftTopY->setValue(m_vectBondMatrixs[0].LeftTopPoint.y); ui.doubleSpinBoxRightTopX->setValue(m_vectBondMatrixs[0].RightTopPoint.x); ui.doubleSpinBoxRightTopY->setValue(m_vectBondMatrixs[0].RightTopPoint.y); ui.doubleSpinBoxRightButtomX->setValue(m_vectBondMatrixs[0].RightBottomPoint.x); ui.doubleSpinBoxRightButtomY->setValue(m_vectBondMatrixs[0].RightBottomPoint.y); QString noBondPts = ""; bool firstTime = false; for (XY_LONG_STRUCT& pt : m_vectBondMatrixs[0].VecNoBondPt) { if (firstTime) { noBondPts += "(" + QString::number(pt.x) + "," + QString::number(pt.y) + ")"; firstTime = true; } noBondPts += ";(" + QString::number(pt.x) + "," + QString::number(pt.y) + ")"; } ui.lineEditNoBondPts->setText(noBondPts);*/ //显示子矩阵及数据 //for (PROGRAM_POINT_MATRIX_STRUCT& subMatrix : m_vecSubMatrixs) //{ // AddMatrixPage(subMatrix); //} //从后端获取参数, 一套数据 CResources* pResources = CResources::GetInstance(); if (pResources == nullptr) { return; } CBondMatrix* pBondMatrix = pResources->GetBondMatrix(); if (pBondMatrix == nullptr) { return; } UpdateShowBondInfoData(m_vectBondMatrixs[0].BondInfoId); ////pBondMatrix->GetPintInfoByIndex(0, m_curPointInfo); //m_manageDB->GetCProduct()->GetBondInfoData(m_vectBondMatrixs[0].BondInfoId, m_curBondInfo); //m_manageDB->GetCProduct()->GetBondParam(m_curBondInfo.iPickParamId, m_curWaferPickParam); //m_manageDB->GetCProduct()->GetBondParam(m_curBondInfo.iCalibBondParamId, m_curCalibPlaceParam); //m_manageDB->GetCProduct()->GetBondParam(m_curBondInfo.iCalibPickParamId, m_curCalibPickParam); //m_manageDB->GetCProduct()->GetBondParam(m_curBondInfo.iBondParamId, m_curBondParam); ////显示界面参数 //UpdatePageParam(); } void BondMatrixProgramPage::UpdateShowBondInfoData(UINT iInfoId) { //pBondMatrix->GetPintInfoByIndex(0, m_curPointInfo); m_manageDB->GetCProduct()->GetBondInfoData(iInfoId, m_curBondInfo); m_manageDB->GetCProduct()->GetBondParam(m_curBondInfo.iPickParamId, m_curWaferPickParam); m_manageDB->GetCProduct()->GetBondParam(m_curBondInfo.iCalibBondParamId, m_curCalibPlaceParam); m_manageDB->GetCProduct()->GetBondParam(m_curBondInfo.iCalibPickParamId, m_curCalibPickParam); m_manageDB->GetCProduct()->GetBondParam(m_curBondInfo.iBondParamId, m_curBondParam); //显示界面参数 UpdatePageParam(); }