فهرست منبع

合并华夫盒界面

艳烨 邱 1 روز پیش
والد
کامیت
a44eb08a71
3فایلهای تغییر یافته به همراه418 افزوده شده و 135 حذف شده
  1. 344 131
      View/die-bonder-ui/Src/WaffleProgramPage.cpp
  2. 8 1
      View/die-bonder-ui/Src/WaffleProgramPage.h
  3. 66 3
      View/die-bonder-ui/Src/WaffleProgramPage.ui

+ 344 - 131
View/die-bonder-ui/Src/WaffleProgramPage.cpp

@@ -3,8 +3,12 @@
 #include <QLineEdit>
 #include "Src/RewriteControl/Controls/SpinBox.h"
 #include "Src/RewriteControl/Controls/DoubleSpinBox.h"
-#include <QLabel>
 #include <View/die-bonder-ui/Src/MatrixDialogs/NoBondPtEditDialog.h>
+#include <QLabel>
+#include <QPushButton>
+#include <QHBoxLayout>
+#include <QVBoxLayout>
+#include <algorithm>
 
 
 WaffleProgramPage::WaffleProgramPage(QWidget* parent)
@@ -12,15 +16,23 @@ WaffleProgramPage::WaffleProgramPage(QWidget* parent)
 {
 	ui.setupUi(this);
 
-	setStyleSheet(
-		"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;}"
-	);
+
+	ui.pushButtonSave->setProperty("type", "save");
+
+	setStyleSheet("QGroupBox { border: 2px solid #A9B4FF;border-radius: 10px;  }");
+
+	//setStyleSheet(
+	//	"QPushButton{background-color: #A9B4FF;border-radius: 5px;height: 30px;}"
+	//	"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;}"
+	//	"QGroupBox{ border: 2px solid red}"
+	//	//"QGroupBox::title { subcontrol-origin: margin; subcontrol-position: top center; padding: 0 3px; }"
+	//);
 
 	m_manageDB = CManageDB::GetInstance();
 	if (m_manageDB == nullptr) return;
@@ -29,6 +41,12 @@ WaffleProgramPage::WaffleProgramPage(QWidget* parent)
 
 	initPage();
 
+	connect(ui.pushButtonSave, &QPushButton::clicked, this, [=]() {
+		m_pProduct->SetAllWaffleMatrix(m_vecWaffleMatrix);
+		m_pProduct->SetAllWaffleDieMatrix(m_vecSubWaffleMatrix);
+
+		});
+
 }
 
 
@@ -44,130 +62,244 @@ void WaffleProgramPage::AddMatrixPage(int vectorIndex, PROGRAM_WAFFLE_MATRIX_STR
 	int newMatrixID = ++matrixNum;
 	QVector<QObject*> vecControls;
 
-	QGroupBox* groupBox = new QGroupBox();
-
-
+	QWidget* outWidget = new QWidget();
 
 	QGridLayout* outMatrixGridLayout = new QGridLayout();
 	outMatrixGridLayout->setSpacing(6);
-	outMatrixGridLayout->setObjectName(QString::fromUtf8("subGridLayout"));
-	groupBox->setLayout(outMatrixGridLayout);
+	outMatrixGridLayout->setObjectName(QString::fromUtf8("Out GridLayout"));
+
+	QGridLayout* boxGridLayout = new QGridLayout();
+	boxGridLayout->setSpacing(6);
+	boxGridLayout->setObjectName(QString::fromUtf8("Box GridLayout"));
+
+	QHBoxLayout* buttonLayout = new QHBoxLayout();
+	QSpacerItem* item = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
+	buttonLayout->addSpacerItem(item);
+
+	QPushButton* pushButtonAddOutMatrix = new QPushButton();
+	pushButtonAddOutMatrix->setObjectName(QString::fromUtf8("button Add"));
+	pushButtonAddOutMatrix->setText(tr("add out Matrix"));
+	buttonLayout->addWidget(pushButtonAddOutMatrix);
+
+	connect(pushButtonAddOutMatrix, &QPushButton::clicked, this, [=]() {
+		PROGRAM_WAFFLE_MATRIX_STRUCT newMatrix;
+		//排序
+		std::sort(m_vecWaffleMatrix.begin(), m_vecWaffleMatrix.end(),
+			[](const PROGRAM_WAFFLE_MATRIX_STRUCT& a, const PROGRAM_WAFFLE_MATRIX_STRUCT& b) {
+				return a.MatrixId < b.MatrixId;
+			});
+		//找Id
+		int newId = 1;
+		for (const auto& matrix : m_vecWaffleMatrix)
+		{
+			if (matrix.MatrixId == newId)
+			{
+				newId++;
+			} else if (matrix.MatrixId > newId)
+			{
+				break;
+			}
+		}
 
+		newMatrix.MatrixId = newId;
+		int newVectorIndex = m_vecWaffleMatrix.size();
+		std::vector<PROGRAM_DIE_MATRIX_STRUCT> newVecSubMatrix;
+		m_vecWaffleMatrix.push_back(newMatrix);
+		AddMatrixPage(newVectorIndex, newMatrix, newVecSubMatrix);
 
-	QGridLayout* subGridLayout = new QGridLayout();
-	subGridLayout->setSpacing(6);
-	subGridLayout->setObjectName(QString::fromUtf8("subGridLayout"));
-	//groupBox->setLayout(subGridLayout);
+		});
 
+	//ui.verticalLayout->addLayout(buttonLayout);
 
-	QLabel* labelTitle = new QLabel(this);
+	QGroupBox* groupBox = new QGroupBox(outWidget);
+	groupBox->setLayout(boxGridLayout);
+
+	QGridLayout* matrixGridLayout = new QGridLayout();
+	matrixGridLayout->setSpacing(6);
+	matrixGridLayout->setObjectName(QString::fromUtf8("matrixGridLayout"));
+
+	QLabel* labelTitle = new QLabel(outWidget);
 	labelTitle->setObjectName(QString::fromUtf8("labelTitle"));
-	labelTitle->setText(tr("Sub Matrix ") + QString::number(vectorIndex));
-	subGridLayout->addWidget(labelTitle, 0, 0, 1, 1);
+	labelTitle->setText(tr("Matrix ") + QString::number(vectorIndex));
+	labelTitle->setStyleSheet("color: #6A78FF;height: 30px");
+	matrixGridLayout->addWidget(labelTitle, 0, 1, 1, 3);
 	vecControls.push_back(labelTitle);
 
-	QLabel* labelRow = new QLabel(this);
+
+	QPushButton* pushButtonAdd = new QPushButton(outWidget);
+	pushButtonAdd->setObjectName(QString::fromUtf8("button Add"));
+	pushButtonAdd->setText(tr("add sub Matrix"));
+	matrixGridLayout->addWidget(pushButtonAdd, 1, 1, 1, 1);
+	pushButtonAdd->setProperty("type", "default");
+
+	connect(pushButtonAdd, &QPushButton::clicked, this, [=]() {
+		int newIndex = m_vecSubWaffleMatrix.size();
+		PROGRAM_DIE_MATRIX_STRUCT dieMatrix;
+		//排序
+		std::sort(m_vecSubWaffleMatrix.begin(), m_vecSubWaffleMatrix.end(),
+			[](const PROGRAM_DIE_MATRIX_STRUCT& a, const PROGRAM_DIE_MATRIX_STRUCT& b) {
+				return a.MatrixId < b.MatrixId;
+			});
+		//找Id
+		int newId = 1;
+		for (const auto& matrix : m_vecSubWaffleMatrix)
+		{
+			if (matrix.MatrixId == newId)
+			{
+				newId++;
+			} else if (matrix.MatrixId > newId)
+			{
+				break;
+			}
+		}
+
+		dieMatrix.MatrixId = newId;
+		dieMatrix.strModuleName = "WaffleHead";
+		dieMatrix.iModuleId = MODULE_LIST::WaffleHead;
+		m_vecSubWaffleMatrix.push_back(dieMatrix);
+
+		//找大矩阵ID/Index
+		auto currentIt = m_mapOutWidgetIndex.find(outWidget);
+		int index = currentIt.value(); //迭代器 erase后currentIt被删除了
+		m_vecWaffleMatrix[index].VecDieMatrixId.push_back(newId);
+
+		AddSubMatrixPage(newIndex, dieMatrix, boxGridLayout);
+		});
+
+
+	QPushButton* pushButtonDelete = new QPushButton(outWidget);
+	pushButtonDelete->setObjectName(QString::fromUtf8("button delete"));
+	pushButtonDelete->setText(tr("delete Matrix"));
+	matrixGridLayout->addWidget(pushButtonDelete, 1, 2, 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_vecWaffleMatrix.erase(m_vecWaffleMatrix.begin() + index);
+
+		delete outWidget;
+		});
+
+
+	QLabel* labelRow = new QLabel(outWidget);
 	labelRow->setObjectName(QString::fromUtf8("labelRow"));
 	labelRow->setText(tr("Row "));
-	subGridLayout->addWidget(labelRow, 1, 0, 1, 1);
+	matrixGridLayout->addWidget(labelRow, 2, 0, 1, 1);
 	vecControls.push_back(labelRow);
 
-	SpinBox* spinBoxRow = new SpinBox(this);
+	SpinBox* spinBoxRow = new SpinBox(outWidget);
 	spinBoxRow->setObjectName(QString::fromUtf8("spinBoxRow"));
-	subGridLayout->addWidget(spinBoxRow, 1, 1, 1, 1);
+	matrixGridLayout->addWidget(spinBoxRow, 2, 1, 1, 1);
 	vecControls.push_back(spinBoxRow);
 
-	QLabel* labelCol = new QLabel(this);
+	QLabel* labelCol = new QLabel(outWidget);
 	labelCol->setObjectName(QString::fromUtf8("labelCol"));
 	labelCol->setText(tr("Cow "));
-	subGridLayout->addWidget(labelCol, 2, 0, 1, 1);
+	matrixGridLayout->addWidget(labelCol, 3, 0, 1, 1);
 	vecControls.push_back(labelCol);
 
-	SpinBox* spinBoxCol = new SpinBox(this);
+	SpinBox* spinBoxCol = new SpinBox(outWidget);
 	spinBoxCol->setObjectName(QString::fromUtf8("spinBoxCol"));
-	subGridLayout->addWidget(spinBoxCol, 2, 1, 1, 1);
+	matrixGridLayout->addWidget(spinBoxCol, 3, 1, 1, 1);
 	vecControls.push_back(spinBoxCol);
 
-	QLabel* labelLeftTop = new QLabel(this);
+	QLabel* labelLeftTop = new QLabel(outWidget);
 	labelLeftTop->setObjectName(QString::fromUtf8("labelLeftTop"));
 	labelLeftTop->setText(tr("Left Top Pos "));
-	subGridLayout->addWidget(labelLeftTop, 4, 0, 1, 1);
+	matrixGridLayout->addWidget(labelLeftTop, 4, 0, 1, 1);
 	vecControls.push_back(labelLeftTop);
 
-	DoubleSpinBox* doubleSpinBoxLeftTopX = new DoubleSpinBox(this);
+	DoubleSpinBox* doubleSpinBoxLeftTopX = new DoubleSpinBox(outWidget);
 	doubleSpinBoxLeftTopX->setObjectName(QString::fromUtf8("doubleSpinBoxLeftTopX"));
-	subGridLayout->addWidget(doubleSpinBoxLeftTopX, 4, 1, 1, 1);
+	matrixGridLayout->addWidget(doubleSpinBoxLeftTopX, 4, 1, 1, 1);
 	vecControls.push_back(doubleSpinBoxLeftTopX);
 
-	DoubleSpinBox* doubleSpinBoxLeftTopY = new DoubleSpinBox(this);
+	DoubleSpinBox* doubleSpinBoxLeftTopY = new DoubleSpinBox(outWidget);
 	doubleSpinBoxLeftTopY->setObjectName(QString::fromUtf8("doubleSpinBoxLeftTopY"));
-	subGridLayout->addWidget(doubleSpinBoxLeftTopY, 4, 2, 1, 1);
+	matrixGridLayout->addWidget(doubleSpinBoxLeftTopY, 4, 2, 1, 1);
 	vecControls.push_back(doubleSpinBoxLeftTopY);
 
-	QLabel* labelRightTopPos = new QLabel(this);
+	QLabel* labelRightTopPos = new QLabel(outWidget);
 	labelRightTopPos->setObjectName(QString::fromUtf8("labelRightTopPos"));
 	labelRightTopPos->setText(tr("Right Top Pos "));
-	subGridLayout->addWidget(labelRightTopPos, 5, 0, 1, 1);
+	matrixGridLayout->addWidget(labelRightTopPos, 5, 0, 1, 1);
 	vecControls.push_back(labelRightTopPos);
 
-	DoubleSpinBox* doubleSpinBoxRightTopX = new DoubleSpinBox(this);
+	DoubleSpinBox* doubleSpinBoxRightTopX = new DoubleSpinBox(outWidget);
 	doubleSpinBoxRightTopX->setObjectName(QString::fromUtf8("doubleSpinBoxRightTopX"));
-	subGridLayout->addWidget(doubleSpinBoxRightTopX, 5, 1, 1, 1);
+	matrixGridLayout->addWidget(doubleSpinBoxRightTopX, 5, 1, 1, 1);
 	vecControls.push_back(doubleSpinBoxRightTopX);
 
-	DoubleSpinBox* doubleSpinBoxRightTopY = new DoubleSpinBox(this);
+	DoubleSpinBox* doubleSpinBoxRightTopY = new DoubleSpinBox(outWidget);
 	doubleSpinBoxRightTopY->setObjectName(QString::fromUtf8("doubleSpinBoxRightTopY"));
-	subGridLayout->addWidget(doubleSpinBoxRightTopY, 5, 2, 1, 1);
+	matrixGridLayout->addWidget(doubleSpinBoxRightTopY, 5, 2, 1, 1);
 	vecControls.push_back(doubleSpinBoxRightTopY);
 
-	QLabel* labelRightButtomPos = new QLabel(this);
+	QLabel* labelRightButtomPos = new QLabel(outWidget);
 	labelRightButtomPos->setObjectName(QString::fromUtf8("labelRightButtomPos"));
 	labelRightButtomPos->setText(tr("Right Buttom pos"));
-	subGridLayout->addWidget(labelRightButtomPos, 6, 0, 1, 1);
+	matrixGridLayout->addWidget(labelRightButtomPos, 6, 0, 1, 1);
 	vecControls.push_back(labelRightButtomPos);
 
-	DoubleSpinBox* doubleSpinBoxRightButtomX = new DoubleSpinBox(this);
+	DoubleSpinBox* doubleSpinBoxRightButtomX = new DoubleSpinBox(outWidget);
 	doubleSpinBoxRightButtomX->setObjectName(QString::fromUtf8("doubleSpinBoxRightButtomX"));
-	subGridLayout->addWidget(doubleSpinBoxRightButtomX, 6, 1, 1, 1);
+	matrixGridLayout->addWidget(doubleSpinBoxRightButtomX, 6, 1, 1, 1);
 	vecControls.push_back(doubleSpinBoxRightButtomX);
 
-	DoubleSpinBox* doubleSpinBoxRightButtomY = new DoubleSpinBox(this);
+	DoubleSpinBox* doubleSpinBoxRightButtomY = new DoubleSpinBox(outWidget);
 	doubleSpinBoxRightButtomY->setObjectName(QString::fromUtf8("doubleSpinBoxRightButtomY"));
-	subGridLayout->addWidget(doubleSpinBoxRightButtomY, 6, 2, 1, 1);
+	matrixGridLayout->addWidget(doubleSpinBoxRightButtomY, 6, 2, 1, 1);
 	vecControls.push_back(doubleSpinBoxRightTopX);
 
-	QLabel* labelNoBondPts = new QLabel(this);
+	QLabel* labelNoBondPts = new QLabel(outWidget);
 	labelNoBondPts->setObjectName(QString::fromUtf8("labelNoBondPts"));
 	labelNoBondPts->setText(tr("No Bond Points"));
-	subGridLayout->addWidget(labelNoBondPts, 7, 0, 1, 1);
+	matrixGridLayout->addWidget(labelNoBondPts, 7, 0, 1, 1);
 	vecControls.push_back(labelNoBondPts);
 
-	QLineEdit* lineEditNoBondPts = new QLineEdit(this);
+	QLineEdit* lineEditNoBondPts = new QLineEdit(outWidget);
 	lineEditNoBondPts->setObjectName(QString::fromUtf8("lineEditNoBondPts"));
-
+	matrixGridLayout->addWidget(lineEditNoBondPts, 7, 1, 1, 2);
+	vecControls.push_back(lineEditNoBondPts);
 
 	lineEditNoBondPts->setReadOnly(true);
 	lineEditNoBondPts->setCursor(Qt::PointingHandCursor);
-	lineEditNoBondPts->setProperty("vectorIndex", vectorIndex);  // 存储索引
+	lineEditNoBondPts->setProperty("subVectorIndex", vectorIndex);  // 存储索引
 	lineEditNoBondPts->installEventFilter(this);
 
+	QFrame* line = new QFrame(outWidget);
+	line->setFrameShape(QFrame::NoFrame); // 移除默认框架
+	line->setFixedHeight(2);         // 设置固定高度
+	line->setStyleSheet("background-color: #C7CAEB;");
 
-	/*connect(lineEditNoBondPts, &QLineEdit::selectionChanged, this, [=]() {
-		this->onNoBondPtsClicked(lineEditNoBondPts, vectorIndex);
+	boxGridLayout->addLayout(matrixGridLayout, 2, 0);
+	boxGridLayout->addWidget(line);
 
-		});*/
-	subGridLayout->addWidget(lineEditNoBondPts, 7, 1, 1, 2);
-	vecControls.push_back(lineEditNoBondPts);
+	outMatrixGridLayout->addLayout(buttonLayout, 1, 0);	
+	outMatrixGridLayout->addWidget(groupBox);
 
-	outMatrixGridLayout->addLayout(subGridLayout, 0, 0);
 
-	QFrame* line = new QFrame();
-	line->setFrameShape(QFrame::NoFrame); // 移除默认框架
-	line->setFixedHeight(2);         // 设置固定高度
-	line->setStyleSheet("background-color: #C7CAEB;");
-	outMatrixGridLayout->addWidget(line);
+	outWidget->setLayout(outMatrixGridLayout);
+
+	ui.verticalLayout->addWidget(outWidget);
 
-	ui.verticalLayout->addWidget(groupBox);
+	m_mapOutWidgetIndex.insert(outWidget, vectorIndex);
 
 	for (int j = 0; j < matrixData.VecDieMatrixId.size(); j++)
 	{
@@ -175,16 +307,28 @@ void WaffleProgramPage::AddMatrixPage(int vectorIndex, PROGRAM_WAFFLE_MATRIX_STR
 		{
 			if (matrixData.VecDieMatrixId[j] == m_vecSubWaffleMatrix[i].MatrixId)
 			{
-				AddSubMatrixPage(i, m_vecSubWaffleMatrix[i], outMatrixGridLayout);
+				AddSubMatrixPage(i, m_vecSubWaffleMatrix[i], boxGridLayout);
 			}
 		}
 	}
 
+	QSpacerItem* vSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
+	ui.verticalLayout->addItem(vSpacer);
+
 	//for (int i = 0; i = vecSubMatrix.size(); i++)
 	//{
 	//	AddSubMatrixPage(i, vecSubMatrix[i], outMatrixGridLayout);
 	//}
 
+	spinBoxRow->setValue(matrixData.PackRow);
+	spinBoxCol->setValue(matrixData.PackCol);
+	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_vecWaffleMatrix[vectorIndex].PackRow = spinBoxRow->value();
@@ -224,188 +368,257 @@ void WaffleProgramPage::AddMatrixPage(int vectorIndex, PROGRAM_WAFFLE_MATRIX_STR
 
 }
 
-bool WaffleProgramPage::eventFilter(QObject* obj, QEvent* event) {
-	if (event->type() == QEvent::MouseButtonPress) {
-		auto* lineEdit = qobject_cast<QLineEdit*>(obj);
-		if (lineEdit) {
-			int index = lineEdit->property("vectorIndex").toInt();
-			onNoBondPtsClicked(lineEdit, index);
-			return true; // 拦截事件
-		}
-	}
-	return QWidget::eventFilter(obj, event);
-}
-
-void WaffleProgramPage::onNoBondPtsClicked(QLineEdit* lineEdit, int index) {
-	if (index < 0 || index >= m_vecWaffleMatrix.size()) return;
-
-	const auto& waffle = m_vecWaffleMatrix[index];
-	NoBondPtEditDialog dlg(waffle.PackRow, waffle.PackCol, waffle.VecNoBondDie, this);
-
-	if (dlg.exec() == QDialog::Accepted) {
-		QVector<XY_LONG_STRUCT> selected = dlg.getSelectedPoints();
-		m_vecWaffleMatrix[index].VecNoBondDie = 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(" "));
-	}
-}
-
 void WaffleProgramPage::AddSubMatrixPage(int subVectorIndex, PROGRAM_DIE_MATRIX_STRUCT subMatrix, QGridLayout* layout)
 {
 	QVector<QObject*> vecControls;
 
-	QGridLayout* subGridLayout = new QGridLayout();
+	QWidget* subWidget = new QWidget();
+
+	QGridLayout* subGridLayout = new QGridLayout(subWidget);
 	subGridLayout->setSpacing(6);
 	subGridLayout->setObjectName(QString::fromUtf8("subGridLayout"));
 	//groupBox->setLayout(subGridLayout);
 
 
-	QLabel* labelTitle = new QLabel(this);
+	QLabel* labelTitle = new QLabel(subWidget);
 	labelTitle->setObjectName(QString::fromUtf8("labelTitle"));
 	labelTitle->setText(tr("Sub Matrix ") + QString::number(subVectorIndex));
-	subGridLayout->addWidget(labelTitle, 0, 0, 1, 1);
+	labelTitle->setStyleSheet("color: #808BFF;height: 30px");
+	subGridLayout->addWidget(labelTitle, 0, 1, 1, 3);
 	vecControls.push_back(labelTitle);
-	labelTitle->setStyleSheet("background-color: #F0F0F0;");
 
-	QLabel* labelRow = new QLabel(this);
+
+	QPushButton* pushButtonDelete = new QPushButton(subWidget);
+	pushButtonDelete->setObjectName(QString::fromUtf8("button delete"));
+	pushButtonDelete->setText(tr("delete Matrix"));
+	subGridLayout->addWidget(pushButtonDelete, 1, 2, 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_vecSubWaffleMatrix[index].MatrixId;
+
+
+		//删除缓存
+		m_vecSubWaffleMatrix.erase(m_vecSubWaffleMatrix.begin() + index);
+
+		//删除大矩阵子ID数据(遍历删除)
+		for (PROGRAM_WAFFLE_MATRIX_STRUCT& matrix : m_vecWaffleMatrix)
+		{
+			auto it = std::find(matrix.VecDieMatrixId.begin(), matrix.VecDieMatrixId.end(), subMatrixId);
+			if (it != matrix.VecDieMatrixId.end())
+			{
+				matrix.VecDieMatrixId.erase(it);				
+			} 
+		}
+
+		delete subWidget;
+		});
+
+	QLabel* labelRow = new QLabel(subWidget);
 	labelRow->setObjectName(QString::fromUtf8("labelRow"));
 	labelRow->setText(tr("Row "));
-	subGridLayout->addWidget(labelRow, 1, 0, 1, 1);
+	subGridLayout->addWidget(labelRow, 2, 0, 1, 1);
 	vecControls.push_back(labelRow);
 
-	SpinBox* spinBoxRow = new SpinBox(this);
+	SpinBox* spinBoxRow = new SpinBox(subWidget);
 	spinBoxRow->setObjectName(QString::fromUtf8("spinBoxRow"));
-	subGridLayout->addWidget(spinBoxRow, 1, 1, 1, 1);
+	subGridLayout->addWidget(spinBoxRow, 2, 1, 1, 1);
 	vecControls.push_back(spinBoxRow);
 
-	QLabel* labelCol = new QLabel(this);
+	QLabel* labelCol = new QLabel(subWidget);
 	labelCol->setObjectName(QString::fromUtf8("labelCol"));
 	labelCol->setText(tr("Cow "));
-	subGridLayout->addWidget(labelCol, 2, 0, 1, 1);
+	subGridLayout->addWidget(labelCol, 3, 0, 1, 1);
 	vecControls.push_back(labelCol);
 
-	SpinBox* spinBoxCol = new SpinBox(this);
+	SpinBox* spinBoxCol = new SpinBox(subWidget);
 	spinBoxCol->setObjectName(QString::fromUtf8("spinBoxCol"));
-	subGridLayout->addWidget(spinBoxCol, 2, 1, 1, 1);
+	subGridLayout->addWidget(spinBoxCol, 3, 1, 1, 1);
 	vecControls.push_back(spinBoxCol);
 
-	QLabel* labelLeftTop = new QLabel(this);
+	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(this);
+	DoubleSpinBox* doubleSpinBoxLeftTopX = new DoubleSpinBox(subWidget);
 	doubleSpinBoxLeftTopX->setObjectName(QString::fromUtf8("doubleSpinBoxLeftTopX"));
 	subGridLayout->addWidget(doubleSpinBoxLeftTopX, 4, 1, 1, 1);
 	vecControls.push_back(doubleSpinBoxLeftTopX);
 
-	DoubleSpinBox* doubleSpinBoxLeftTopY = new DoubleSpinBox(this);
+	DoubleSpinBox* doubleSpinBoxLeftTopY = new DoubleSpinBox(subWidget);
 	doubleSpinBoxLeftTopY->setObjectName(QString::fromUtf8("doubleSpinBoxLeftTopY"));
 	subGridLayout->addWidget(doubleSpinBoxLeftTopY, 4, 2, 1, 1);
 	vecControls.push_back(doubleSpinBoxLeftTopY);
 
-	QLabel* labelRightTopPos = new QLabel(this);
+	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(this);
+	DoubleSpinBox* doubleSpinBoxRightTopX = new DoubleSpinBox(subWidget);
 	doubleSpinBoxRightTopX->setObjectName(QString::fromUtf8("doubleSpinBoxRightTopX"));
 	subGridLayout->addWidget(doubleSpinBoxRightTopX, 5, 1, 1, 1);
 	vecControls.push_back(doubleSpinBoxRightTopX);
 
-	DoubleSpinBox* doubleSpinBoxRightTopY = new DoubleSpinBox(this);
+	DoubleSpinBox* doubleSpinBoxRightTopY = new DoubleSpinBox(subWidget);
 	doubleSpinBoxRightTopY->setObjectName(QString::fromUtf8("doubleSpinBoxRightTopY"));
 	subGridLayout->addWidget(doubleSpinBoxRightTopY, 5, 2, 1, 1);
 	vecControls.push_back(doubleSpinBoxRightTopY);
 
-	QLabel* labelRightButtomPos = new QLabel(this);
+	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(this);
+	DoubleSpinBox* doubleSpinBoxRightButtomX = new DoubleSpinBox(subWidget);
 	doubleSpinBoxRightButtomX->setObjectName(QString::fromUtf8("doubleSpinBoxRightButtomX"));
 	subGridLayout->addWidget(doubleSpinBoxRightButtomX, 6, 1, 1, 1);
 	vecControls.push_back(doubleSpinBoxRightButtomX);
 
-	DoubleSpinBox* doubleSpinBoxRightButtomY = new DoubleSpinBox(this);
+	DoubleSpinBox* doubleSpinBoxRightButtomY = new DoubleSpinBox(subWidget);
 	doubleSpinBoxRightButtomY->setObjectName(QString::fromUtf8("doubleSpinBoxRightButtomY"));
 	subGridLayout->addWidget(doubleSpinBoxRightButtomY, 6, 2, 1, 1);
 	vecControls.push_back(doubleSpinBoxRightTopX);
 
-	QLabel* labelNoBondPts = new QLabel(this);
+	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(this);
+	QLineEdit* lineEditNoBondPts = new QLineEdit(subWidget);
 	lineEditNoBondPts->setObjectName(QString::fromUtf8("lineEditNoBondPts"));
 
-
 	lineEditNoBondPts->setReadOnly(true);
 	lineEditNoBondPts->setCursor(Qt::PointingHandCursor);
-	lineEditNoBondPts->setProperty("subVectorIndex", subVectorIndex);  // 存储索引
+	lineEditNoBondPts->setProperty("vectorIndex", subVectorIndex);  // 存储索引
 	lineEditNoBondPts->installEventFilter(this);
 
 	subGridLayout->addWidget(lineEditNoBondPts, 7, 1, 1, 2);
 	vecControls.push_back(lineEditNoBondPts);
 
-	layout->addLayout(subGridLayout, 11, 0);
 
-	QFrame* line = new QFrame();
+	//layout->addLayout(subGridLayout, 11, 0);
+
+	QFrame* line = new QFrame(subWidget);
 	line->setFrameShape(QFrame::NoFrame); // 移除默认框架
 	line->setFixedHeight(2);         // 设置固定高度
 	line->setStyleSheet("background-color: #C7CAEB;");
-	ui.verticalLayout->addWidget(line);
+	subGridLayout->addWidget(line, 10, 0, 1, 3);
+
+
+	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, [=]() {
-		m_vecSubWaffleMatrix[subVectorIndex].MatrixRow = spinBoxRow->value();
+		auto it = m_mapSubWidgetIndex.find(subWidget);
+		m_vecSubWaffleMatrix[it.value()].MatrixRow = spinBoxRow->value();
 		});
 
 	connect(spinBoxCol, &SpinBox::editDone, this, [=]() {
-		m_vecSubWaffleMatrix[subVectorIndex].MatrixCol = spinBoxCol->value();
+		auto it = m_mapSubWidgetIndex.find(subWidget);
+		m_vecSubWaffleMatrix[it.value()].MatrixCol = spinBoxCol->value();
 		});
 
 	connect(doubleSpinBoxLeftTopX, &DoubleSpinBox::editDone, this, [=]() {
-		m_vecSubWaffleMatrix[subVectorIndex].LeftTopPoint.x = doubleSpinBoxLeftTopX->value();
+		auto it = m_mapSubWidgetIndex.find(subWidget);
+		m_vecSubWaffleMatrix[it.value()].LeftTopPoint.x = doubleSpinBoxLeftTopX->value();
 		});
 
 	connect(doubleSpinBoxLeftTopY, &DoubleSpinBox::editDone, this, [=]() {
-		m_vecSubWaffleMatrix[subVectorIndex].LeftTopPoint.y = doubleSpinBoxLeftTopY->value();
+		auto it = m_mapSubWidgetIndex.find(subWidget);
+		m_vecSubWaffleMatrix[it.value()].LeftTopPoint.y = doubleSpinBoxLeftTopY->value();
 		});
 
 	connect(doubleSpinBoxRightTopX, &DoubleSpinBox::editDone, this, [=]() {
-		m_vecSubWaffleMatrix[subVectorIndex].RightTopPoint.x = doubleSpinBoxRightTopX->value();
+		auto it = m_mapSubWidgetIndex.find(subWidget);
+		m_vecSubWaffleMatrix[it.value()].RightTopPoint.x = doubleSpinBoxRightTopX->value();
 		});
 
 	connect(doubleSpinBoxRightTopY, &DoubleSpinBox::editDone, this, [=]() {
-		m_vecSubWaffleMatrix[subVectorIndex].RightTopPoint.y = doubleSpinBoxRightTopY->value();
+		auto it = m_mapSubWidgetIndex.find(subWidget);
+		m_vecSubWaffleMatrix[it.value()].RightTopPoint.y = doubleSpinBoxRightTopY->value();
 		});
 
 	connect(doubleSpinBoxRightButtomX, &DoubleSpinBox::editDone, this, [=]() {
-		m_vecSubWaffleMatrix[subVectorIndex].RightBottomPoint.x = doubleSpinBoxRightButtomX->value();
+		auto it = m_mapSubWidgetIndex.find(subWidget);
+		m_vecSubWaffleMatrix[it.value()].RightBottomPoint.x = doubleSpinBoxRightButtomX->value();
 		});
 
 	connect(doubleSpinBoxRightButtomY, &DoubleSpinBox::editDone, this, [=]() {
-		m_vecSubWaffleMatrix[subVectorIndex].RightBottomPoint.y = doubleSpinBoxRightButtomY->value();
+		auto it = m_mapSubWidgetIndex.find(subWidget);
+		m_vecSubWaffleMatrix[it.value()].RightBottomPoint.y = doubleSpinBoxRightButtomY->value();
 		});
 
 	connect(lineEditNoBondPts, &QLineEdit::textChanged, this, [=]() {
+		auto it = m_mapSubWidgetIndex.find(subWidget);
 		});
 
+}
+
+bool WaffleProgramPage::eventFilter(QObject* obj, QEvent* event) {
+	if (event->type() == QEvent::MouseButtonPress)
+	{
+		auto* lineEdit = qobject_cast<QLineEdit*>(obj);
+		if (lineEdit)
+		{
+			int index = lineEdit->property("vectorIndex").toInt();
+			onNoBondPtsClicked(lineEdit, index);
+			return true; // 拦截事件
+		}
+	}
+	return QWidget::eventFilter(obj, event);
+}
+
+void WaffleProgramPage::onNoBondPtsClicked(QLineEdit* lineEdit, int index) {
+	if (index < 0 || index >= m_vecWaffleMatrix.size()) return;
 
+	const auto& waffle = m_vecWaffleMatrix[index];
+	NoBondPtEditDialog dlg(waffle.PackRow, waffle.PackCol, waffle.VecNoBondDie, this);
 
+	if (dlg.exec() == QDialog::Accepted)
+	{
+		QVector<XY_LONG_STRUCT> selected = dlg.getSelectedPoints();
+		m_vecWaffleMatrix[index].VecNoBondDie = 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(" "));
+	}
 }
 
+
 void WaffleProgramPage::SaveAllParam()
 {
 }

+ 8 - 1
View/die-bonder-ui/Src/WaffleProgramPage.h

@@ -3,6 +3,7 @@
 #include <QWidget>
 #include "ui_WaffleProgramPage.h"
 #include "CViewInterface.h"
+#include <QMap>
 
 class WaffleProgramPage : public QWidget
 {
@@ -34,7 +35,9 @@ private:
 
 	void initPage();
 
-	bool eventFilter(QObject* obj, QEvent* event) override;
+protected:
+	bool eventFilter(QObject* watched, QEvent* event) override;
+
 
 private slots:
 	void onNoBondPtsClicked(QLineEdit* lineEdit, int waffleIndex);
@@ -57,5 +60,9 @@ private:
 
 	int m_curPtIndex = 0;
 
+	QMap<QWidget*, int> m_mapSubWidgetIndex;
+
+	QMap<QWidget*, int> m_mapOutWidgetIndex;
+
 
 };

+ 66 - 3
View/die-bonder-ui/Src/WaffleProgramPage.ui

@@ -6,7 +6,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>621</width>
+    <width>1079</width>
     <height>864</height>
    </rect>
   </property>
@@ -14,6 +14,18 @@
    <string>WaffleProgramPage</string>
   </property>
   <layout class="QVBoxLayout" name="verticalLayout_2">
+   <property name="leftMargin">
+    <number>0</number>
+   </property>
+   <property name="topMargin">
+    <number>0</number>
+   </property>
+   <property name="rightMargin">
+    <number>0</number>
+   </property>
+   <property name="bottomMargin">
+    <number>0</number>
+   </property>
    <item>
     <widget class="QScrollArea" name="scrollArea">
      <property name="widgetResizable">
@@ -24,11 +36,62 @@
        <rect>
         <x>0</x>
         <y>0</y>
-        <width>597</width>
-        <height>840</height>
+        <width>1077</width>
+        <height>862</height>
        </rect>
       </property>
       <layout class="QVBoxLayout" name="verticalLayout_3">
+       <property name="leftMargin">
+        <number>6</number>
+       </property>
+       <property name="topMargin">
+        <number>6</number>
+       </property>
+       <property name="rightMargin">
+        <number>6</number>
+       </property>
+       <property name="bottomMargin">
+        <number>6</number>
+       </property>
+       <item>
+        <layout class="QHBoxLayout" name="horizontalLayout">
+         <item>
+          <spacer name="horizontalSpacer">
+           <property name="orientation">
+            <enum>Qt::Horizontal</enum>
+           </property>
+           <property name="sizeType">
+            <enum>QSizePolicy::Expanding</enum>
+           </property>
+           <property name="sizeHint" stdset="0">
+            <size>
+             <width>40</width>
+             <height>20</height>
+            </size>
+           </property>
+          </spacer>
+         </item>
+         <item>
+          <widget class="QPushButton" name="pushButtonSave">
+           <property name="sizePolicy">
+            <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+             <horstretch>0</horstretch>
+             <verstretch>0</verstretch>
+            </sizepolicy>
+           </property>
+           <property name="minimumSize">
+            <size>
+             <width>150</width>
+             <height>0</height>
+            </size>
+           </property>
+           <property name="text">
+            <string>Save</string>
+           </property>
+          </widget>
+         </item>
+        </layout>
+       </item>
        <item>
         <layout class="QVBoxLayout" name="verticalLayout"/>
        </item>