WaffleProgramPage.cpp 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937
  1. #include "WaffleProgramPage.h"
  2. #include <QGroupBox>
  3. #include <QLineEdit>
  4. #include "Src/RewriteControl/Controls/SpinBox.h"
  5. #include "Src/RewriteControl/Controls/DoubleSpinBox.h"
  6. #include <View/die-bonder-ui/Src/MatrixDialogs/NoBondPtEditDialog.h>
  7. #include <QLabel>
  8. #include <QPushButton>
  9. #include <QHBoxLayout>
  10. #include <QVBoxLayout>
  11. #include <algorithm>
  12. WaffleProgramPage::WaffleProgramPage(QWidget* parent)
  13. :QWidget(parent)
  14. {
  15. ui.setupUi(this);
  16. ui.pushButtonSave->setProperty("type", "save");
  17. ui.pushButtonAddOutMatrix->setProperty("type", "addOutMatrix");
  18. setStyleSheet(
  19. "QWidget { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #F1F4FD, stop: 1 #E5E4F6); }"
  20. "QDoubleSpinBox { background: #FFFFFF; border: 1px solid #BABBDC; border-radius: 6px; padding: 2px 5px; }"
  21. "QSpinBox { background: #FFFFFF; border: 1px solid #BABBDC; border-radius: 6px; padding: 2px 5px; }"
  22. "QLineEdit { background: #FFFFFF; border: 1px solid #BABBDC; border-radius: 6px; padding: 2px 5px; }"
  23. "QCheckBox::indicator { width: 20px; height: 20px; }"
  24. "QCheckBox::indicator:unchecked { background-color: #FFFFFF; border-radius: 2px; }"
  25. "QComboBox { background: #FFFFFF; border: 1px solid #BABBDC; border-radius: 6px; padding: 2px 5px; }"
  26. "QComboBox::drop-down { width: 20px; }"
  27. "QPushButton { background: #D0D0E8; border: 1px solid #BABBDC; border-radius: 6px; padding: 2px 5px; }" // Button background color
  28. "QPushButton:hover { background-color: #B0B0D8; }" // Lighter color on hover
  29. "QPushButton:pressed { background-color: #A0A0C8; }" // Darker color on press
  30. );
  31. m_manageDB = CManageDB::GetInstance();
  32. if (m_manageDB == nullptr) return;
  33. m_pProduct = m_manageDB->GetCProduct();
  34. if (m_pProduct == nullptr) return;
  35. m_pProgramCViewInterface = ns_module::CViewInterface::GetInstance();
  36. ui.pushButtonAddOutMatrix->setIcon(QIcon(":/images/Program/addMatrix.png"));
  37. ui.pushButtonSave->setIcon(QIcon(":/images/Program/saveMatrix.png"));
  38. initPage();
  39. connect(ui.pushButtonSave, &QPushButton::clicked, this, [=]() {
  40. m_pProduct->SetAllWaffleMatrix(m_vecWaffleMatrix);
  41. m_pProduct->SetAllWaffleDieMatrix(m_vecSubWaffleMatrix);
  42. CWafflePackMatrix* pMatrix = CResources::GetInstance()->GetWafflePackMatrix();
  43. pMatrix->LoadMatrix(MATRIX_SEARCH_DIR::DIR_S);
  44. CProduct* _Product = m_manageDB->GetCProduct();
  45. });
  46. connect(ui.pushButtonAddOutMatrix, &QPushButton::clicked, this, [=]() {
  47. PROGRAM_WAFFLE_MATRIX_STRUCT newMatrix;
  48. //排序
  49. std::sort(m_vecWaffleMatrix.begin(), m_vecWaffleMatrix.end(),
  50. [](const PROGRAM_WAFFLE_MATRIX_STRUCT& a, const PROGRAM_WAFFLE_MATRIX_STRUCT& b) {
  51. return a.MatrixId < b.MatrixId;
  52. });
  53. int newId = 0;
  54. UINT maxID = 0;
  55. // 查找最大 MatrixId
  56. for (PROGRAM_WAFFLE_MATRIX_STRUCT& waffleMatrix : m_vecWaffleMatrix)
  57. {
  58. if (waffleMatrix.MatrixId > maxID)
  59. {
  60. maxID = waffleMatrix.MatrixId;
  61. }
  62. }
  63. // 生成新的子矩阵 ID,确保唯一性
  64. newId = ++maxID;
  65. while (std::any_of(m_vecWaffleMatrix.begin(), m_vecWaffleMatrix.end(),
  66. [newId](const PROGRAM_WAFFLE_MATRIX_STRUCT& waffleMatrix) {
  67. return waffleMatrix.MatrixId == newId;
  68. }))
  69. {
  70. newId++; // 如果生成的 ID 已经存在,递增直到找到唯一的 ID
  71. }
  72. newMatrix.MatrixId = newId;
  73. /*newMatrix.PackRow = 0;
  74. newMatrix.PackCol = 0;*/
  75. int newVectorIndex = m_vecWaffleMatrix.size();
  76. //std::vector<PROGRAM_DIE_MATRIX_STRUCT> newVecSubMatrix;
  77. m_vecWaffleMatrix.push_back(newMatrix);
  78. AddMatrixPage(newVectorIndex, newMatrix, m_vecSubWaffleMatrix);
  79. });
  80. }
  81. WaffleProgramPage::~WaffleProgramPage()
  82. {
  83. }
  84. XY_DOUBLE_STRUCT WaffleProgramPage::WaffleGetAxisPosition(std::string ModuleType, XY_DOUBLE_STRUCT& pos)
  85. {
  86. /*CAxis* _Axis;
  87. CAxis::AXIS_TYPE eAxisType = _Axis->GetAxisType();*/
  88. if (m_pProgramCViewInterface == nullptr)
  89. {
  90. XY_DOUBLE_STRUCT errorPt = pos; // 可以根据需要返回一个错误状态
  91. // 弹出消息框显示位置
  92. QString positionString = QString("Unable to retrieve axis position for module type: %1").arg(QString::fromStdString(ModuleType));
  93. QMessageBox::information(this, "Axis Position Error", positionString);
  94. return errorPt;
  95. }
  96. m_pProgramCViewInterface->GetViewMotion()->GetAxisPosition(ModuleType, "X", pos.x);
  97. m_pProgramCViewInterface->GetViewMotion()->GetAxisPosition(ModuleType, "Y", pos.y);
  98. m_pProgramCViewInterface->GetViewMotion()->ModuleMoveTo(ModuleType, "X", pos.x);
  99. m_pProgramCViewInterface->GetViewMotion()->ModuleMoveTo(ModuleType, "Y", pos.y);
  100. return pos;
  101. }
  102. XY_DOUBLE_STRUCT WaffleProgramPage::WaffleMoveToXYAxisPosition(std::string ModuleType, XY_DOUBLE_STRUCT& pos)
  103. {
  104. if (m_pProgramCViewInterface == nullptr)
  105. {
  106. XY_DOUBLE_STRUCT errorPt = pos; // 可以根据需要返回一个错误状态
  107. // 弹出消息框显示位置
  108. QString positionString = QString("Unable to retrieve axis position for module type: %1").arg(QString::fromStdString(ModuleType));
  109. QMessageBox::information(this, "Axis Position Error", positionString);
  110. return errorPt;
  111. }
  112. m_pProgramCViewInterface->GetViewMotion()->ModuleMoveTo(ModuleType, "X", pos.x);
  113. m_pProgramCViewInterface->GetViewMotion()->ModuleMoveTo(ModuleType, "Y", pos.y);
  114. return pos;
  115. }
  116. void WaffleProgramPage::AddMatrixPage(int vectorIndex, PROGRAM_WAFFLE_MATRIX_STRUCT matrixData, std::vector<PROGRAM_DIE_MATRIX_STRUCT> vecSubMatrix)
  117. {
  118. int matrixNum = m_mapSubMatrixControls.size();
  119. int newMatrixID = ++matrixNum;
  120. QVector<QObject*> vecControls;
  121. QWidget* outWidget = new QWidget();
  122. QGridLayout* outMatrixGridLayout = new QGridLayout();
  123. outMatrixGridLayout->setSpacing(4);
  124. outMatrixGridLayout->setObjectName(QString::fromUtf8("Out GridLayout"));
  125. outMatrixGridLayout->setContentsMargins(0, 0, 0, 0); // 设置布局的边距为0
  126. QGridLayout* boxGridLayout = new QGridLayout();
  127. boxGridLayout->setSpacing(6);
  128. boxGridLayout->setObjectName(QString::fromUtf8("Box GridLayout"));
  129. QHBoxLayout* buttonLayout = new QHBoxLayout();
  130. /*QSpacerItem* item = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
  131. buttonLayout->addSpacerItem(item);*/
  132. //QPushButton* pushButtonAddOutMatrix = new QPushButton();
  133. //pushButtonAddOutMatrix->setObjectName(QString::fromUtf8("button Add"));
  134. //pushButtonAddOutMatrix->setText(tr("add out Matrix"));
  135. //buttonLayout->addWidget(pushButtonAddOutMatrix);
  136. //ui.verticalLayout->addLayout(buttonLayout);
  137. QGroupBox* groupBox = new QGroupBox(outWidget);
  138. groupBox->setLayout(boxGridLayout);
  139. QGridLayout* matrixGridLayout = new QGridLayout();
  140. matrixGridLayout->setSpacing(6);
  141. matrixGridLayout->setObjectName(QString::fromUtf8("matrixGridLayout"));
  142. QLabel* labelTitle = new QLabel(outWidget);
  143. labelTitle->setObjectName(QString::fromUtf8("labelTitle"));
  144. labelTitle->setText(tr("Matrix","矩阵") + QString::number(vectorIndex + 1));
  145. labelTitle->setStyleSheet("color: #6A78FF;height: 30px");
  146. matrixGridLayout->addWidget(labelTitle, 0, 0, 1, 1);
  147. vecControls.push_back(labelTitle);
  148. QPushButton* pushButtonAdd = new QPushButton(outWidget);
  149. pushButtonAdd->setObjectName(QString::fromUtf8("button Add"));
  150. pushButtonAdd->setToolTip(tr("AddSubMatrix", "添加子矩阵")); // 设置鼠标悬停时显示的文字提示
  151. pushButtonAdd->setIcon(QIcon(":/images/Program/addSubMatrix.png"));
  152. matrixGridLayout->addWidget(pushButtonAdd, 0, 3, 1, 1);
  153. pushButtonAdd->setProperty("type", "default");
  154. connect(pushButtonAdd, &QPushButton::clicked, this, [=]() {
  155. int newIndex = m_vecSubWaffleMatrix.size();
  156. PROGRAM_DIE_MATRIX_STRUCT dieMatrix;
  157. //排序
  158. std::sort(m_vecSubWaffleMatrix.begin(), m_vecSubWaffleMatrix.end(),
  159. [](const PROGRAM_DIE_MATRIX_STRUCT& a, const PROGRAM_DIE_MATRIX_STRUCT& b) {
  160. return a.MatrixId < b.MatrixId;
  161. });
  162. int newSubMatrixID = 0;
  163. UINT maxID = 0;
  164. // 查找最大 MatrixId
  165. for (PROGRAM_DIE_MATRIX_STRUCT& subMatrix : m_vecSubWaffleMatrix)
  166. {
  167. if (subMatrix.MatrixId > maxID)
  168. {
  169. maxID = subMatrix.MatrixId;
  170. }
  171. }
  172. // 生成新的子矩阵 ID,确保唯一性
  173. newSubMatrixID = ++maxID;
  174. while (std::any_of(m_vecSubWaffleMatrix.begin(), m_vecSubWaffleMatrix.end(),
  175. [newSubMatrixID](const PROGRAM_DIE_MATRIX_STRUCT& subMatrix) {
  176. return subMatrix.MatrixId == newSubMatrixID;
  177. }))
  178. {
  179. newSubMatrixID++; // 如果生成的 ID 已经存在,递增直到找到唯一的 ID
  180. }
  181. dieMatrix.MatrixId = newSubMatrixID;
  182. /*dieMatrix.strModuleName = "WaffleHead";
  183. dieMatrix.iModuleId = MODULE_LIST::WaffleHead;
  184. dieMatrix.MatrixRow = 0;
  185. dieMatrix.MatrixCol = 0;*/
  186. m_vecSubWaffleMatrix.push_back(dieMatrix);
  187. //找大矩阵ID/Index
  188. auto currentIt = m_mapOutWidgetIndex.find(outWidget);
  189. int index = currentIt.value(); //迭代器 erase后currentIt被删除了
  190. m_vecWaffleMatrix[index].VecDieMatrixId.push_back(newSubMatrixID);
  191. AddSubMatrixPage(vectorIndex,newIndex, dieMatrix, boxGridLayout);
  192. });
  193. QPushButton* pushButtonDelete = new QPushButton(outWidget);
  194. pushButtonDelete->setObjectName(QString::fromUtf8("button delete"));
  195. pushButtonDelete->setToolTip(tr("DeleteOutMatrix", "删除大矩阵")); // 设置鼠标悬停时显示的文字提示
  196. pushButtonDelete->setIcon(QIcon(":/images/Program/deleteInner.png"));
  197. matrixGridLayout->addWidget(pushButtonDelete, 0, 4, 1, 1);
  198. connect(pushButtonDelete, &QPushButton::clicked, this, [=]() {
  199. //处理index
  200. auto currentIt = m_mapOutWidgetIndex.find(outWidget);
  201. int index = currentIt.value(); //迭代器 erase后currentIt被删除了
  202. m_mapOutWidgetIndex.erase(currentIt);
  203. for (auto it = m_mapOutWidgetIndex.begin(); it != m_mapOutWidgetIndex.end(); it++)
  204. {
  205. if (it.value() > index)
  206. {
  207. int newIndex = it.value() - 1;
  208. m_mapOutWidgetIndex.insert(it.key(), newIndex);
  209. }
  210. }
  211. //删除缓存数据
  212. m_vecWaffleMatrix.erase(m_vecWaffleMatrix.begin() + index);
  213. delete outWidget;
  214. });
  215. QLabel* labelRow = new QLabel(outWidget);
  216. labelRow->setObjectName(QString::fromUtf8("labelRow"));
  217. labelRow->setText(tr("Row & Cow","行 & 列"));
  218. matrixGridLayout->addWidget(labelRow, 2, 0, 1, 1);
  219. vecControls.push_back(labelRow);
  220. SpinBox* spinBoxRow = new SpinBox(outWidget);
  221. spinBoxRow->setObjectName(QString::fromUtf8("spinBoxRow"));
  222. spinBoxRow->setFixedWidth(95); // Set fixed width to 95
  223. matrixGridLayout->addWidget(spinBoxRow, 2, 1, 1, 1);
  224. vecControls.push_back(spinBoxRow);
  225. /*QLabel* labelCol = new QLabel(outWidget);
  226. labelCol->setObjectName(QString::fromUtf8("labelCol"));
  227. labelCol->setText(tr("Cow "));
  228. matrixGridLayout->addWidget(labelCol, 3, 0, 1, 1);
  229. vecControls.push_back(labelCol);*/
  230. SpinBox* spinBoxCol = new SpinBox(outWidget);
  231. spinBoxCol->setObjectName(QString::fromUtf8("spinBoxCol"));
  232. spinBoxCol->setFixedWidth(95); // Set fixed width to 95
  233. matrixGridLayout->addWidget(spinBoxCol, 2, 2, 1, 1);
  234. vecControls.push_back(spinBoxCol);
  235. QLabel* labelLeftTop = new QLabel(outWidget);
  236. labelLeftTop->setObjectName(QString::fromUtf8("labelLeftTop"));
  237. labelLeftTop->setText(tr("Left Top Pos","左上角"));
  238. matrixGridLayout->addWidget(labelLeftTop, 4, 0, 1, 1);
  239. vecControls.push_back(labelLeftTop);
  240. DoubleSpinBox* doubleSpinBoxLeftTopX = new DoubleSpinBox(outWidget);
  241. doubleSpinBoxLeftTopX->setObjectName(QString::fromUtf8("doubleSpinBoxLeftTopX"));
  242. doubleSpinBoxLeftTopX->setFixedWidth(95); // Set fixed width to 95
  243. matrixGridLayout->addWidget(doubleSpinBoxLeftTopX, 4, 1, 1, 1);
  244. vecControls.push_back(doubleSpinBoxLeftTopX);
  245. DoubleSpinBox* doubleSpinBoxLeftTopY = new DoubleSpinBox(outWidget);
  246. doubleSpinBoxLeftTopY->setObjectName(QString::fromUtf8("doubleSpinBoxLeftTopY"));
  247. doubleSpinBoxLeftTopY->setFixedWidth(95); // Set fixed width to 95
  248. matrixGridLayout->addWidget(doubleSpinBoxLeftTopY, 4, 2, 1, 1);
  249. vecControls.push_back(doubleSpinBoxLeftTopY);
  250. QPushButton* buttonLeftTop = new QPushButton(this);
  251. buttonLeftTop->setFixedWidth(30); // Set the same width for the button
  252. matrixGridLayout->addWidget(buttonLeftTop, 4, 3, 1, 1); // Position the button next to LeftTopPos
  253. connect(buttonLeftTop, &QPushButton::clicked, this, [=]() {
  254. XY_DOUBLE_STRUCT position = WaffleGetAxisPosition("WaffleHead", m_vecWaffleMatrix[vectorIndex].LeftTopPoint);
  255. doubleSpinBoxLeftTopX->setValue(position.x); // Update X axis
  256. doubleSpinBoxLeftTopY->setValue(position.y); // Update Y axis
  257. });
  258. //MoveTo
  259. QPushButton* buttonMoveToLeftTop = new QPushButton(this);
  260. buttonMoveToLeftTop->setFixedWidth(30); // Set the same width for the button
  261. matrixGridLayout->addWidget(buttonMoveToLeftTop, 4, 4, 1, 1); // Position the button next to LeftTopPos
  262. connect(buttonMoveToLeftTop, &QPushButton::clicked, this, [=]() {
  263. XY_DOUBLE_STRUCT position = WaffleMoveToXYAxisPosition("WaffleHead", m_vecWaffleMatrix[vectorIndex].LeftTopPoint);
  264. //doubleSpinBoxLeftTopX->setValue(position.x); // Update X axis
  265. //doubleSpinBoxLeftTopY->setValue(position.y); // Update Y axis
  266. });
  267. QLabel* labelRightTopPos = new QLabel(outWidget);
  268. labelRightTopPos->setObjectName(QString::fromUtf8("labelRightTopPos"));
  269. labelRightTopPos->setText(tr("Right Top Pos","右上角"));
  270. matrixGridLayout->addWidget(labelRightTopPos, 5, 0, 1, 1);
  271. vecControls.push_back(labelRightTopPos);
  272. DoubleSpinBox* doubleSpinBoxRightTopX = new DoubleSpinBox(outWidget);
  273. doubleSpinBoxRightTopX->setObjectName(QString::fromUtf8("doubleSpinBoxRightTopX"));
  274. doubleSpinBoxRightTopX->setFixedWidth(95); // Set fixed width to 95
  275. matrixGridLayout->addWidget(doubleSpinBoxRightTopX, 5, 1, 1, 1);
  276. vecControls.push_back(doubleSpinBoxRightTopX);
  277. DoubleSpinBox* doubleSpinBoxRightTopY = new DoubleSpinBox(outWidget);
  278. doubleSpinBoxRightTopY->setObjectName(QString::fromUtf8("doubleSpinBoxRightTopY"));
  279. doubleSpinBoxRightTopY->setFixedWidth(95); // Set fixed width to 95
  280. matrixGridLayout->addWidget(doubleSpinBoxRightTopY, 5, 2, 1, 1);
  281. vecControls.push_back(doubleSpinBoxRightTopY);
  282. QPushButton* buttonRightTop = new QPushButton(this);
  283. buttonRightTop->setFixedWidth(30); // Set the same width for the button
  284. matrixGridLayout->addWidget(buttonRightTop, 5, 3, 1, 1); // Position the button next to RightTopPos
  285. connect(buttonRightTop, &QPushButton::clicked, this, [=]() {
  286. XY_DOUBLE_STRUCT position = WaffleGetAxisPosition("WaffleHead", m_vecWaffleMatrix[vectorIndex].RightTopPoint);
  287. doubleSpinBoxRightTopX->setValue(position.x); // Update X axis
  288. doubleSpinBoxRightTopY->setValue(position.y); // Update Y axis
  289. });
  290. //MoveTo
  291. QPushButton* buttonMoveToRightTop = new QPushButton(this);
  292. buttonMoveToRightTop->setFixedWidth(30); // Set the same width for the button
  293. matrixGridLayout->addWidget(buttonMoveToRightTop, 5, 4, 1, 1); // Position the button next to LeftTopPos
  294. connect(buttonMoveToRightTop, &QPushButton::clicked, this, [=]() {
  295. XY_DOUBLE_STRUCT position = WaffleMoveToXYAxisPosition("WaffleHead", m_vecWaffleMatrix[vectorIndex].RightTopPoint);
  296. });
  297. QLabel* labelRightButtomPos = new QLabel(outWidget);
  298. labelRightButtomPos->setObjectName(QString::fromUtf8("labelRightButtomPos"));
  299. labelRightButtomPos->setText(tr("Right Buttom pos","点击右下角点"));
  300. matrixGridLayout->addWidget(labelRightButtomPos, 6, 0, 1, 1);
  301. vecControls.push_back(labelRightButtomPos);
  302. DoubleSpinBox* doubleSpinBoxRightButtomX = new DoubleSpinBox(outWidget);
  303. doubleSpinBoxRightButtomX->setObjectName(QString::fromUtf8("doubleSpinBoxRightButtomX"));
  304. doubleSpinBoxRightButtomX->setFixedWidth(95); // Set fixed width to 95
  305. matrixGridLayout->addWidget(doubleSpinBoxRightButtomX, 6, 1, 1, 1);
  306. vecControls.push_back(doubleSpinBoxRightButtomX);
  307. DoubleSpinBox* doubleSpinBoxRightButtomY = new DoubleSpinBox(outWidget);
  308. doubleSpinBoxRightButtomY->setObjectName(QString::fromUtf8("doubleSpinBoxRightButtomY"));
  309. doubleSpinBoxRightButtomY->setFixedWidth(95); // Set fixed width to 95
  310. matrixGridLayout->addWidget(doubleSpinBoxRightButtomY, 6, 2, 1, 1);
  311. vecControls.push_back(doubleSpinBoxRightTopX);
  312. QPushButton* buttonRightButtom = new QPushButton(this);
  313. buttonRightButtom->setFixedWidth(30); // Set the same width for the button
  314. matrixGridLayout->addWidget(buttonRightButtom, 6, 3, 1, 1); // Position the button next to RightBottomPos
  315. connect(buttonRightButtom, &QPushButton::clicked, this, [=]() {
  316. XY_DOUBLE_STRUCT position = WaffleGetAxisPosition("WaffleHead", m_vecWaffleMatrix[vectorIndex].RightBottomPoint);
  317. doubleSpinBoxRightButtomX->setValue(position.x); // Update X axis
  318. doubleSpinBoxRightButtomY->setValue(position.y); // Update Y axis
  319. });
  320. //MoveTo
  321. QPushButton* buttonMoveToRightButtom = new QPushButton(this);
  322. buttonMoveToRightButtom->setFixedWidth(30); // Set the same width for the button
  323. matrixGridLayout->addWidget(buttonMoveToRightButtom, 6, 4, 1, 1); // Position the button next to LeftTopPos
  324. connect(buttonMoveToRightButtom, &QPushButton::clicked, this, [=]() {
  325. XY_DOUBLE_STRUCT position = WaffleMoveToXYAxisPosition("WaffleHead", m_vecWaffleMatrix[vectorIndex].RightBottomPoint);
  326. });
  327. QLabel* labelNoBondPts = new QLabel(outWidget);
  328. labelNoBondPts->setObjectName(QString::fromUtf8("labelNoBondPts"));
  329. labelNoBondPts->setText(tr("No Bond Points","不固晶点"));
  330. matrixGridLayout->addWidget(labelNoBondPts, 7, 0, 1, 1);
  331. vecControls.push_back(labelNoBondPts);
  332. QLineEdit* lineEditNoBondPts = new QLineEdit(outWidget);
  333. lineEditNoBondPts->setObjectName(QString::fromUtf8("lineEditNoBondPts"));
  334. matrixGridLayout->addWidget(lineEditNoBondPts, 7, 1, 1, 4);
  335. vecControls.push_back(lineEditNoBondPts);
  336. lineEditNoBondPts->setReadOnly(true);
  337. lineEditNoBondPts->setCursor(Qt::PointingHandCursor);
  338. lineEditNoBondPts->setProperty("vectorIndex", vectorIndex); // 存储索引
  339. lineEditNoBondPts->setProperty("parentMatrixIndex", -1); // 存储大矩阵的索引(即父矩阵)
  340. lineEditNoBondPts->installEventFilter(this);
  341. QFrame* line = new QFrame(outWidget);
  342. line->setFrameShape(QFrame::NoFrame); // 移除默认框架
  343. line->setFixedHeight(2); // 设置固定高度
  344. line->setStyleSheet("background-color: #C7CAEB;");
  345. boxGridLayout->addLayout(matrixGridLayout, 2, 0);
  346. boxGridLayout->addWidget(line);
  347. outMatrixGridLayout->addLayout(buttonLayout, 1, 0);
  348. outMatrixGridLayout->addWidget(groupBox);
  349. outWidget->setLayout(outMatrixGridLayout);
  350. QSpacerItem* spacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
  351. // 移除弹簧
  352. for (int i = 0; i < ui.verticalLayout->count(); ++i) {
  353. if (ui.verticalLayout->itemAt(i)->spacerItem()) {
  354. // 找到并移除弹簧
  355. ui.verticalLayout->removeItem(ui.verticalLayout->itemAt(i));
  356. break;
  357. }
  358. }
  359. ui.verticalLayout->addWidget(outWidget);
  360. // 重新添加弹簧到布局的最下方
  361. ui.verticalLayout->addItem(spacer);
  362. m_mapOutWidgetIndex.insert(outWidget, vectorIndex);
  363. for (int j = 0; j < matrixData.VecDieMatrixId.size(); j++)
  364. {
  365. for (int i = 0; i < m_vecSubWaffleMatrix.size(); i++)
  366. {
  367. if (matrixData.VecDieMatrixId[j] == m_vecSubWaffleMatrix[i].MatrixId)
  368. {
  369. AddSubMatrixPage(j,i, m_vecSubWaffleMatrix[i], boxGridLayout);
  370. }
  371. }
  372. }
  373. //for (int i = 0; i = vecSubMatrix.size(); i++)
  374. //{
  375. // AddSubMatrixPage(i, vecSubMatrix[i], outMatrixGridLayout);
  376. //}
  377. spinBoxRow->setValue(matrixData.PackRow);
  378. spinBoxCol->setValue(matrixData.PackCol);
  379. doubleSpinBoxLeftTopX->setValue(matrixData.LeftTopPoint.x);
  380. doubleSpinBoxLeftTopY->setValue(matrixData.LeftTopPoint.y);
  381. doubleSpinBoxRightTopX->setValue(matrixData.RightTopPoint.x);
  382. doubleSpinBoxRightTopY->setValue(matrixData.RightTopPoint.y);
  383. doubleSpinBoxRightButtomX->setValue(matrixData.RightBottomPoint.x);
  384. doubleSpinBoxRightButtomY->setValue(matrixData.RightBottomPoint.y);
  385. buttonLeftTop->setToolTip(tr("GetBondAxisPosition", "设置左上点为当前坐标"));
  386. buttonRightTop->setToolTip(tr("GetBondAxisPosition", "设置右上点为当前坐标"));
  387. buttonRightButtom->setToolTip(tr("GetBondAxisPosition", "设置右下点为当前坐标"));
  388. buttonMoveToLeftTop->setToolTip(tr("MoveToPosition", "移动到左上点"));
  389. buttonMoveToRightTop->setToolTip(tr("MoveToRightTop", "移动到右上点"));
  390. buttonMoveToRightButtom->setToolTip(tr("MoveToRightTop", "移动到右下点"));
  391. buttonLeftTop->setIcon(QIcon(":/images/Program/getPos.png"));
  392. buttonMoveToLeftTop->setIcon(QIcon(":/images/Program/moveTo.png"));
  393. buttonRightTop->setIcon(QIcon(":/images/Program/getPos.png"));
  394. buttonMoveToRightTop->setIcon(QIcon(":/images/Program/moveTo.png"));
  395. buttonRightButtom->setIcon(QIcon(":/images/Program/getPos.png"));
  396. buttonMoveToRightButtom->setIcon(QIcon(":/images/Program/moveTo.png"));
  397. connect(spinBoxRow, &SpinBox::editDone, this, [=]() {
  398. m_vecWaffleMatrix[vectorIndex].PackRow = spinBoxRow->value();
  399. });
  400. connect(spinBoxCol, &SpinBox::editDone, this, [=]() {
  401. m_vecWaffleMatrix[vectorIndex].PackCol = spinBoxCol->value();
  402. });
  403. connect(doubleSpinBoxLeftTopX, &DoubleSpinBox::editDone, this, [=]() {
  404. m_vecWaffleMatrix[vectorIndex].LeftTopPoint.x = doubleSpinBoxLeftTopX->value();
  405. });
  406. connect(doubleSpinBoxLeftTopY, &DoubleSpinBox::editDone, this, [=]() {
  407. m_vecWaffleMatrix[vectorIndex].LeftTopPoint.y = doubleSpinBoxLeftTopY->value();
  408. });
  409. connect(doubleSpinBoxRightTopX, &DoubleSpinBox::editDone, this, [=]() {
  410. m_vecWaffleMatrix[vectorIndex].RightTopPoint.x = doubleSpinBoxRightTopX->value();
  411. });
  412. connect(doubleSpinBoxRightTopY, &DoubleSpinBox::editDone, this, [=]() {
  413. m_vecWaffleMatrix[vectorIndex].RightTopPoint.y = doubleSpinBoxRightTopY->value();
  414. });
  415. connect(doubleSpinBoxRightButtomX, &DoubleSpinBox::editDone, this, [=]() {
  416. m_vecWaffleMatrix[vectorIndex].RightBottomPoint.x = doubleSpinBoxRightButtomX->value();
  417. });
  418. connect(doubleSpinBoxRightButtomY, &DoubleSpinBox::editDone, this, [=]() {
  419. m_vecWaffleMatrix[vectorIndex].RightBottomPoint.y = doubleSpinBoxRightButtomY->value();
  420. });
  421. connect(lineEditNoBondPts, &QLineEdit::textChanged, this, [=]() {
  422. });
  423. }
  424. void WaffleProgramPage::AddSubMatrixPage(int vectorIndex, int subVectorIndex, PROGRAM_DIE_MATRIX_STRUCT subMatrix, QGridLayout* layout)
  425. {
  426. QVector<QObject*> vecControls;
  427. QWidget* subWidget = new QWidget();
  428. QGridLayout* subGridLayout = new QGridLayout(subWidget);
  429. subGridLayout->setSpacing(4);
  430. subGridLayout->setObjectName(QString::fromUtf8("subGridLayout"));
  431. //groupBox->setLayout(subGridLayout);
  432. subGridLayout->setContentsMargins(0, 0, 0, 0); // 设置布局的边距为0
  433. subGridLayout->setAlignment(Qt::AlignCenter);
  434. QLabel* labelTitle = new QLabel(subWidget);
  435. labelTitle->setObjectName(QString::fromUtf8("labelTitle"));
  436. labelTitle->setText(tr("Sub Matrix ","子矩阵") + QString::number(subVectorIndex));
  437. labelTitle->setStyleSheet("color: #808BFF;height: 30px");
  438. subGridLayout->addWidget(labelTitle, 0, 1, 1, 1);
  439. vecControls.push_back(labelTitle);
  440. QPushButton* pushButtonDelete = new QPushButton(subWidget);
  441. pushButtonDelete->setObjectName(QString::fromUtf8("button delete"));
  442. pushButtonDelete->setToolTip(tr("DeleteSubMatrix", "删除子矩阵"));
  443. pushButtonDelete->setIcon(QIcon(":/images/Program/deleteInner.png"));
  444. subGridLayout->addWidget(pushButtonDelete, 0, 4, 1, 1);
  445. connect(pushButtonDelete, &QPushButton::clicked, this, [=]() {
  446. //处理index
  447. auto currentIt = m_mapSubWidgetIndex.find(subWidget);
  448. int index = currentIt.value(); //迭代器 erase后currentIt被删除了
  449. m_mapSubWidgetIndex.erase(currentIt);
  450. for (auto it = m_mapSubWidgetIndex.begin(); it != m_mapSubWidgetIndex.end(); ++it)
  451. {
  452. if (it.value() > index)
  453. {
  454. //value() 返回的是副本不是引用
  455. int newIndex = it.value() - 1;
  456. m_mapSubWidgetIndex.insert(it.key(), newIndex);
  457. }
  458. }
  459. // 子矩阵ID
  460. int subMatrixId = m_vecSubWaffleMatrix[index].MatrixId;
  461. //删除缓存
  462. m_vecSubWaffleMatrix.erase(m_vecSubWaffleMatrix.begin() + index);
  463. //删除大矩阵子ID数据(遍历删除)
  464. for (PROGRAM_WAFFLE_MATRIX_STRUCT& matrix : m_vecWaffleMatrix)
  465. {
  466. auto it = std::find(matrix.VecDieMatrixId.begin(), matrix.VecDieMatrixId.end(), subMatrixId);
  467. if (it != matrix.VecDieMatrixId.end())
  468. {
  469. matrix.VecDieMatrixId.erase(it);
  470. }
  471. }
  472. delete subWidget;
  473. });
  474. QLabel* labelRow = new QLabel(subWidget);
  475. labelRow->setObjectName(QString::fromUtf8("labelRow"));
  476. labelRow->setText(tr("Row & Cow","行&列"));
  477. subGridLayout->addWidget(labelRow, 2, 0, 1, 1);
  478. vecControls.push_back(labelRow);
  479. SpinBox* spinBoxRow = new SpinBox(subWidget);
  480. spinBoxRow->setObjectName(QString::fromUtf8("spinBoxRow"));
  481. subGridLayout->addWidget(spinBoxRow, 2, 1, 1, 1);
  482. vecControls.push_back(spinBoxRow);
  483. /*QLabel* labelCol = new QLabel(subWidget);
  484. labelCol->setObjectName(QString::fromUtf8("labelCol"));
  485. labelCol->setText(tr("Cow "));
  486. subGridLayout->addWidget(labelCol, 3, 0, 1, 1);
  487. vecControls.push_back(labelCol);*/
  488. SpinBox* spinBoxCol = new SpinBox(subWidget);
  489. spinBoxCol->setObjectName(QString::fromUtf8("spinBoxCol"));
  490. subGridLayout->addWidget(spinBoxCol, 2, 2, 1, 1);
  491. vecControls.push_back(spinBoxCol);
  492. QLabel* labelLeftTop = new QLabel(subWidget);
  493. labelLeftTop->setObjectName(QString::fromUtf8("labelLeftTop"));
  494. labelLeftTop->setText(tr("Left Top Pos","左上点"));
  495. subGridLayout->addWidget(labelLeftTop, 4, 0, 1, 1);
  496. vecControls.push_back(labelLeftTop);
  497. DoubleSpinBox* doubleSpinBoxLeftTopX = new DoubleSpinBox(subWidget);
  498. doubleSpinBoxLeftTopX->setObjectName(QString::fromUtf8("doubleSpinBoxLeftTopX"));
  499. doubleSpinBoxLeftTopX->setFixedWidth(95); // Set fixed width to 95
  500. doubleSpinBoxLeftTopX->setFixedWidth(95); // Set fixed width to 95
  501. subGridLayout->addWidget(doubleSpinBoxLeftTopX, 4, 1, 1, 1);
  502. vecControls.push_back(doubleSpinBoxLeftTopX);
  503. DoubleSpinBox* doubleSpinBoxLeftTopY = new DoubleSpinBox(subWidget);
  504. doubleSpinBoxLeftTopY->setObjectName(QString::fromUtf8("doubleSpinBoxLeftTopY"));
  505. doubleSpinBoxLeftTopY->setFixedWidth(95); // Set fixed width to 95
  506. doubleSpinBoxLeftTopY->setFixedWidth(95); // Set fixed width to 95
  507. subGridLayout->addWidget(doubleSpinBoxLeftTopY, 4, 2, 1, 1);
  508. vecControls.push_back(doubleSpinBoxLeftTopY);
  509. QLabel* labelRightTopPos = new QLabel(subWidget);
  510. labelRightTopPos->setObjectName(QString::fromUtf8("labelRightTopPos"));
  511. labelRightTopPos->setText(tr("Right Top Pos","右上点"));
  512. subGridLayout->addWidget(labelRightTopPos, 5, 0, 1, 1);
  513. vecControls.push_back(labelRightTopPos);
  514. DoubleSpinBox* doubleSpinBoxRightTopX = new DoubleSpinBox(subWidget);
  515. doubleSpinBoxRightTopX->setObjectName(QString::fromUtf8("doubleSpinBoxRightTopX"));
  516. doubleSpinBoxRightTopX->setFixedWidth(95); // Set fixed width to 95
  517. subGridLayout->addWidget(doubleSpinBoxRightTopX, 5, 1, 1, 1);
  518. vecControls.push_back(doubleSpinBoxRightTopX);
  519. DoubleSpinBox* doubleSpinBoxRightTopY = new DoubleSpinBox(subWidget);
  520. doubleSpinBoxRightTopY->setObjectName(QString::fromUtf8("doubleSpinBoxRightTopY"));
  521. doubleSpinBoxRightTopY->setFixedWidth(95); // Set fixed width to 95
  522. subGridLayout->addWidget(doubleSpinBoxRightTopY, 5, 2, 1, 1);
  523. vecControls.push_back(doubleSpinBoxRightTopY);
  524. QLabel* labelRightButtomPos = new QLabel(subWidget);
  525. labelRightButtomPos->setObjectName(QString::fromUtf8("labelRightButtomPos"));
  526. labelRightButtomPos->setText(tr("Right Buttom pos","右下点"));
  527. subGridLayout->addWidget(labelRightButtomPos, 6, 0, 1, 1);
  528. vecControls.push_back(labelRightButtomPos);
  529. DoubleSpinBox* doubleSpinBoxRightButtomX = new DoubleSpinBox(subWidget);
  530. doubleSpinBoxRightButtomX->setObjectName(QString::fromUtf8("doubleSpinBoxRightButtomX"));
  531. doubleSpinBoxRightButtomX->setFixedWidth(95); // Set fixed width to 95
  532. subGridLayout->addWidget(doubleSpinBoxRightButtomX, 6, 1, 1, 1);
  533. vecControls.push_back(doubleSpinBoxRightButtomX);
  534. DoubleSpinBox* doubleSpinBoxRightButtomY = new DoubleSpinBox(subWidget);
  535. doubleSpinBoxRightButtomY->setObjectName(QString::fromUtf8("doubleSpinBoxRightButtomY"));
  536. doubleSpinBoxRightButtomY->setFixedWidth(95); // Set fixed width to 95
  537. subGridLayout->addWidget(doubleSpinBoxRightButtomY, 6, 2, 1, 1);
  538. vecControls.push_back(doubleSpinBoxRightTopX);
  539. QLabel* labelNoBondPts = new QLabel(subWidget);
  540. labelNoBondPts->setObjectName(QString::fromUtf8("labelNoBondPts"));
  541. labelNoBondPts->setText(tr("No Bond Points","不固晶点"));
  542. subGridLayout->addWidget(labelNoBondPts, 7, 0, 1, 1);
  543. vecControls.push_back(labelNoBondPts);
  544. QLineEdit* lineEditNoBondPts = new QLineEdit(subWidget);
  545. lineEditNoBondPts->setObjectName(QString::fromUtf8("lineEditNoBondPts"));
  546. lineEditNoBondPts->setReadOnly(true);
  547. lineEditNoBondPts->setCursor(Qt::PointingHandCursor);
  548. //lineEditNoBondPts->setProperty("matrixType", "SubMatrix"); // 设置为子矩阵
  549. lineEditNoBondPts->setProperty("vectorIndex", subVectorIndex); // 子矩阵索引
  550. lineEditNoBondPts->setProperty("parentMatrixIndex", vectorIndex); // 设置父矩阵的索引
  551. lineEditNoBondPts->installEventFilter(this);
  552. subGridLayout->addWidget(lineEditNoBondPts, 7, 1, 1, 3);
  553. vecControls.push_back(lineEditNoBondPts);
  554. // Left Top Position X and Y
  555. QPushButton* buttonLeftTop = new QPushButton(subWidget);
  556. buttonLeftTop->setFixedWidth(30); // 设置固定宽度
  557. subGridLayout->addWidget(buttonLeftTop, 4, 3, 1, 1); // 添加按钮到4行3列
  558. connect(buttonLeftTop, &QPushButton::clicked, this, [=]() {
  559. XY_DOUBLE_STRUCT position = WaffleGetAxisPosition("WaffleHead", m_vecSubWaffleMatrix[subVectorIndex].LeftTopPoint);
  560. doubleSpinBoxLeftTopX->setValue(position.x); // 更新 X 轴
  561. doubleSpinBoxLeftTopY->setValue(position.y); // 更新 Y 轴
  562. });
  563. //MoveTo
  564. QPushButton* buttonMoveToLeftTop = new QPushButton(subWidget);
  565. buttonMoveToLeftTop->setFixedWidth(30); // Set the same width for the button
  566. subGridLayout->addWidget(buttonMoveToLeftTop, 4, 4, 1, 1); // Position the button next to LeftTopPos
  567. connect(buttonMoveToLeftTop, &QPushButton::clicked, this, [=]() {
  568. XY_DOUBLE_STRUCT position = WaffleMoveToXYAxisPosition("WaffleHead", m_vecWaffleMatrix[subVectorIndex].LeftTopPoint);
  569. });
  570. // Right Top Position X and Y
  571. QPushButton* buttonRightTop = new QPushButton(subWidget);
  572. buttonRightTop->setFixedWidth(30); // 设置固定宽度
  573. subGridLayout->addWidget(buttonRightTop, 5, 3, 1, 1); // 添加按钮到5行3列
  574. connect(buttonRightTop, &QPushButton::clicked, this, [=]() {
  575. XY_DOUBLE_STRUCT position = WaffleGetAxisPosition("WaffleHead", m_vecSubWaffleMatrix[subVectorIndex].RightTopPoint);
  576. doubleSpinBoxRightTopX->setValue(position.x); // 更新 X 轴
  577. doubleSpinBoxRightTopY->setValue(position.y); // 更新 Y 轴
  578. });
  579. //MoveTo
  580. QPushButton* buttonMoveToRightTop = new QPushButton(subWidget);
  581. buttonMoveToRightTop->setFixedWidth(30); // Set the same width for the button
  582. subGridLayout->addWidget(buttonMoveToRightTop, 5, 4, 1, 1); // Position the button next to LeftTopPos
  583. connect(buttonMoveToRightTop, &QPushButton::clicked, this, [=]() {
  584. XY_DOUBLE_STRUCT position = WaffleMoveToXYAxisPosition("WaffleHead", m_vecWaffleMatrix[subVectorIndex].RightTopPoint);
  585. });
  586. // Right Bottom Position X and Y
  587. QPushButton* buttonRightButtom = new QPushButton(subWidget);
  588. buttonRightButtom->setFixedWidth(30); // 设置固定宽度
  589. subGridLayout->addWidget(buttonRightButtom, 6, 3, 1, 1); // 添加按钮到6行3列
  590. connect(buttonRightButtom, &QPushButton::clicked, this, [=]() {
  591. XY_DOUBLE_STRUCT position = WaffleGetAxisPosition("WaffleHead", m_vecSubWaffleMatrix[subVectorIndex].RightBottomPoint);
  592. doubleSpinBoxRightButtomX->setValue(position.x); // 更新 X 轴
  593. doubleSpinBoxRightButtomY->setValue(position.y); // 更新 Y 轴
  594. });
  595. //MoveTo
  596. QPushButton* buttonMoveToRightButtom = new QPushButton(subWidget);
  597. buttonMoveToRightButtom->setFixedWidth(30); // Set the same width for the button
  598. subGridLayout->addWidget(buttonMoveToRightButtom, 6, 4, 1, 1); // Position the button next to LeftTopPos
  599. connect(buttonMoveToRightButtom, &QPushButton::clicked, this, [=]() {
  600. XY_DOUBLE_STRUCT position = WaffleMoveToXYAxisPosition("WaffleHead", m_vecWaffleMatrix[subVectorIndex].RightBottomPoint);
  601. });
  602. //layout->addLayout(subGridLayout, 11, 0);
  603. buttonLeftTop->setToolTip(tr("GetBondAxisPosition", "设置左上点为当前坐标"));
  604. buttonRightTop->setToolTip(tr("GetBondAxisPosition", "设置右上点为当前坐标"));
  605. buttonRightButtom->setToolTip(tr("GetBondAxisPosition", "设置右下点为当前坐标"));
  606. buttonMoveToLeftTop->setToolTip(tr("MoveToPosition", "移动到左上点"));
  607. buttonMoveToRightTop->setToolTip(tr("MoveToRightTop", "移动到右上点"));
  608. buttonMoveToRightButtom->setToolTip(tr("MoveToRightTop", "移动到右下点"));
  609. buttonLeftTop->setIcon(QIcon(":/images/Program/getPos.png"));
  610. buttonMoveToLeftTop->setIcon(QIcon(":/images/Program/moveTo.png"));
  611. buttonRightTop->setIcon(QIcon(":/images/Program/getPos.png"));
  612. buttonMoveToRightTop->setIcon(QIcon(":/images/Program/moveTo.png"));
  613. buttonRightButtom->setIcon(QIcon(":/images/Program/getPos.png"));
  614. buttonMoveToRightButtom->setIcon(QIcon(":/images/Program/moveTo.png"));
  615. QFrame* line = new QFrame(subWidget);
  616. line->setFrameShape(QFrame::NoFrame); // 移除默认框架
  617. line->setFixedHeight(2); // 设置固定高度
  618. line->setStyleSheet("background-color: #C7CAEB;");
  619. subGridLayout->addWidget(line, 10, 0, 1, 3);
  620. layout->addWidget(subWidget);
  621. m_mapSubWidgetIndex.insert(subWidget, subVectorIndex);
  622. spinBoxRow->setValue(subMatrix.MatrixRow);
  623. spinBoxCol->setValue(subMatrix.MatrixCol);
  624. doubleSpinBoxLeftTopX->setValue(subMatrix.LeftTopPoint.x);
  625. doubleSpinBoxLeftTopY->setValue(subMatrix.LeftTopPoint.y);
  626. doubleSpinBoxRightTopX->setValue(subMatrix.RightTopPoint.x);
  627. doubleSpinBoxRightTopY->setValue(subMatrix.RightTopPoint.y);
  628. doubleSpinBoxRightButtomX->setValue(subMatrix.RightBottomPoint.x);
  629. doubleSpinBoxRightButtomY->setValue(subMatrix.RightBottomPoint.y);
  630. connect(spinBoxRow, &SpinBox::editDone, this, [=]() {
  631. auto it = m_mapSubWidgetIndex.find(subWidget);
  632. m_vecSubWaffleMatrix[it.value()].MatrixRow = spinBoxRow->value();
  633. });
  634. connect(spinBoxCol, &SpinBox::editDone, this, [=]() {
  635. auto it = m_mapSubWidgetIndex.find(subWidget);
  636. m_vecSubWaffleMatrix[it.value()].MatrixCol = spinBoxCol->value();
  637. });
  638. connect(doubleSpinBoxLeftTopX, &DoubleSpinBox::editDone, this, [=]() {
  639. auto it = m_mapSubWidgetIndex.find(subWidget);
  640. m_vecSubWaffleMatrix[it.value()].LeftTopPoint.x = doubleSpinBoxLeftTopX->value();
  641. });
  642. connect(doubleSpinBoxLeftTopY, &DoubleSpinBox::editDone, this, [=]() {
  643. auto it = m_mapSubWidgetIndex.find(subWidget);
  644. m_vecSubWaffleMatrix[it.value()].LeftTopPoint.y = doubleSpinBoxLeftTopY->value();
  645. });
  646. connect(doubleSpinBoxRightTopX, &DoubleSpinBox::editDone, this, [=]() {
  647. auto it = m_mapSubWidgetIndex.find(subWidget);
  648. m_vecSubWaffleMatrix[it.value()].RightTopPoint.x = doubleSpinBoxRightTopX->value();
  649. });
  650. connect(doubleSpinBoxRightTopY, &DoubleSpinBox::editDone, this, [=]() {
  651. auto it = m_mapSubWidgetIndex.find(subWidget);
  652. m_vecSubWaffleMatrix[it.value()].RightTopPoint.y = doubleSpinBoxRightTopY->value();
  653. });
  654. connect(doubleSpinBoxRightButtomX, &DoubleSpinBox::editDone, this, [=]() {
  655. auto it = m_mapSubWidgetIndex.find(subWidget);
  656. m_vecSubWaffleMatrix[it.value()].RightBottomPoint.x = doubleSpinBoxRightButtomX->value();
  657. });
  658. connect(doubleSpinBoxRightButtomY, &DoubleSpinBox::editDone, this, [=]() {
  659. auto it = m_mapSubWidgetIndex.find(subWidget);
  660. m_vecSubWaffleMatrix[it.value()].RightBottomPoint.y = doubleSpinBoxRightButtomY->value();
  661. });
  662. connect(lineEditNoBondPts, &QLineEdit::textChanged, this, [=]() {
  663. auto it = m_mapSubWidgetIndex.find(subWidget);
  664. });
  665. }
  666. bool WaffleProgramPage::eventFilter(QObject* obj, QEvent* event) {
  667. if (event->type() == QEvent::MouseButtonPress)
  668. {
  669. auto* lineEdit = qobject_cast<QLineEdit*>(obj);
  670. if (lineEdit)
  671. {
  672. int index = lineEdit->property("vectorIndex").toInt(); // 当前矩阵索引
  673. int parentIndex = lineEdit->property("parentMatrixIndex").toInt(); // 父矩阵索引
  674. onNoBondPtsClicked(lineEdit, index, parentIndex); // 传递父矩阵索引
  675. return true; // 拦截事件
  676. }
  677. }
  678. return QWidget::eventFilter(obj, event);
  679. }
  680. void WaffleProgramPage::onNoBondPtsClicked(QLineEdit* lineEdit, int index, int parentIndex) {
  681. if (parentIndex != -1)
  682. {
  683. // 处理子矩阵的操作
  684. if (index < 0 || index >= m_vecSubWaffleMatrix.size()) return;
  685. const auto& subMatrix = m_vecSubWaffleMatrix[index];
  686. NoBondPtEditDialog dlg(subMatrix.MatrixRow, subMatrix.MatrixCol, subMatrix.VecNoBondPt, this);
  687. if (dlg.exec() == QDialog::Accepted)
  688. {
  689. QVector<XY_LONG_STRUCT> selected = dlg.getSelectedPoints();
  690. m_vecSubWaffleMatrix[index].VecNoBondPt = std::vector<XY_LONG_STRUCT>(selected.begin(), selected.end());
  691. QStringList ptList;
  692. for (const auto& pt : selected)
  693. ptList << QString("(%1,%2)").arg(pt.x).arg(pt.y);
  694. lineEdit->setText(ptList.join(" "));
  695. }
  696. // 这里可以用 parentIndex 来关联父矩阵(即大矩阵)做相应的操作
  697. }
  698. else
  699. {
  700. // 处理大矩阵的操作
  701. if (index < 0 || index >= m_vecWaffleMatrix.size()) return;
  702. const auto& waffleMatrix = m_vecWaffleMatrix[index];
  703. NoBondPtEditDialog dlg(waffleMatrix.PackRow, waffleMatrix.PackCol, waffleMatrix.VecNoBondDie, this);
  704. if (dlg.exec() == QDialog::Accepted)
  705. {
  706. QVector<XY_LONG_STRUCT> selected = dlg.getSelectedPoints();
  707. m_vecWaffleMatrix[index].VecNoBondDie = std::vector<XY_LONG_STRUCT>(selected.begin(), selected.end());
  708. QStringList ptList;
  709. for (const auto& pt : selected)
  710. ptList << QString("(%1,%2)").arg(pt.x).arg(pt.y);
  711. lineEdit->setText(ptList.join(" "));
  712. }
  713. // 这里也可以用 parentIndex 来关联父矩阵(即大矩阵)做相应的操作
  714. }
  715. }
  716. void WaffleProgramPage::SaveAllParam()
  717. {
  718. }
  719. void WaffleProgramPage::MatrixChangeEvent()
  720. {
  721. for (PROGRAM_WAFFLE_MATRIX_STRUCT& waffleMatrix : m_vecWaffleMatrix)
  722. {
  723. m_pProduct->SetWaffleMatrix(waffleMatrix.MatrixId, waffleMatrix);
  724. }
  725. m_pProduct->SetDieMatrix(m_vecSubWaffleMatrix, true);
  726. //for (PROGRAM_BOND_MATRIX_STRUCT& bondMatrix : m_vecWaffleMatrix)
  727. //{
  728. // m_manageDB->GetCProduct()->SetBondMatrix(bondMatrix.BondMatrixId, bondMatrix);
  729. //}
  730. //for (PROGRAM_POINT_MATRIX_STRUCT& pointMatrix : m_vecSubMatrixs)
  731. //{
  732. // m_manageDB->GetCProduct()->SetPointMatrix(pointMatrix.MatrixId, pointMatrix);
  733. //}
  734. }
  735. void WaffleProgramPage::initPage()
  736. {
  737. m_vecWaffleMatrix = m_pProduct->GetWaffleMatrix();
  738. m_pProduct->GetAllDieMatrix(m_vecSubWaffleMatrix);
  739. for (int i = 0; i < m_vecWaffleMatrix.size(); i++)
  740. {
  741. //for (int j = 0; j < m_vecWaffleMatrix[i].VecDieMatrixId.size(); j++)
  742. //{
  743. // PROGRAM_DIE_MATRIX_STRUCT subMatrix;
  744. // m_pProduct->GetDieMatrix(m_vecWaffleMatrix[i].VecDieMatrixId[j], subMatrix);
  745. // m_vecSubWaffleMatrix.push_back(subMatrix);
  746. // //AddMatrixPage(i, j, subMatrix);
  747. //}
  748. AddMatrixPage(i, m_vecWaffleMatrix[i], m_vecSubWaffleMatrix);
  749. }
  750. }