WaferProgramPage.cpp 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. #include "WaferProgramPage.h"
  2. std::unordered_map<int, bool> WaferProgramPage::m_IdIsUsedMap;
  3. WaferProgramPage::WaferProgramPage(QWidget* parent)
  4. : QWidget(parent)
  5. {
  6. ui.setupUi(this);
  7. ui.pushButtonSave->setProperty("type", "save");
  8. ui.pushButtonAdd->setProperty("type", "add");
  9. setStyleSheet(
  10. "QWidget { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #F1F4FD, stop: 1 #E5E4F6); }"
  11. "QDoubleSpinBox { background: #FFFFFF; border: 1px solid #BABBDC; border-radius: 6px; padding: 2px 5px; }"
  12. "QSpinBox { background: #FFFFFF; border: 1px solid #BABBDC; border-radius: 6px; padding: 2px 5px; }"
  13. "QLineEdit { background: #FFFFFF; border: 1px solid #BABBDC; border-radius: 6px; padding: 2px 5px; }"
  14. "QCheckBox::indicator { width: 20px; height: 20px; }"
  15. "QCheckBox::indicator:unchecked { background-color: #FFFFFF; border-radius: 2px; }"
  16. "QComboBox { background: #FFFFFF; border: 1px solid #BABBDC; border-radius: 6px; padding: 2px 5px; }"
  17. "QComboBox::drop-down { width: 20px; }"
  18. "QPushButton { background: #D0D0E8; border: 1px solid #BABBDC; border-radius: 6px; padding: 2px 5px; }" // Button background color
  19. "QPushButton:hover { background-color: #B0B0D8; }" // Lighter color on hover
  20. "QPushButton:pressed { background-color: #A0A0C8; }" // Darker color on press
  21. );
  22. m_manageDB = CManageDB::GetInstance();
  23. if (m_manageDB == nullptr) return;
  24. m_pProduct = m_manageDB->GetCProduct();
  25. if (m_pProduct == nullptr) return;
  26. m_pProgramCViewInterface= ns_module::CViewInterface::GetInstance();
  27. connect(ui.pushButtonSave, &QPushButton::clicked, this, [=]() {
  28. m_pProduct->SetAllWaferMatrix(m_vecWaferMatrix);
  29. CProduct* _Product = m_manageDB->GetCProduct();
  30. });
  31. connect(ui.pushButtonAdd, &QPushButton::clicked, this, [=]() {
  32. PROGRAM_WAFER_MATRIX_STRUCT newMatrix;
  33. //排序
  34. std::sort(m_vecWaferMatrix.begin(), m_vecWaferMatrix.end(),
  35. [](const PROGRAM_WAFER_MATRIX_STRUCT& a, const PROGRAM_WAFER_MATRIX_STRUCT& b) {
  36. return a.MatrixId < b.MatrixId;
  37. });
  38. //找Id
  39. int newId = 1;
  40. for (const auto& matrix : m_vecWaferMatrix)
  41. {
  42. if (matrix.MatrixId == newId)
  43. {
  44. newId++;
  45. }
  46. else if (matrix.MatrixId > newId)
  47. {
  48. break;
  49. }
  50. }
  51. newMatrix.MatrixId = newId;
  52. newMatrix.MatrixRow = 0;
  53. newMatrix.MatrixCol = 0;
  54. int newVectorIndex = m_vecWaferMatrix.size();
  55. m_vecWaferMatrix.push_back(newMatrix);
  56. AddMatrixPage(newVectorIndex, newMatrix);
  57. });
  58. initPage();
  59. }
  60. void WaferProgramPage::initPage()
  61. {
  62. m_vecWaferMatrix = m_pProduct->GetWaferMatrix();
  63. for (int i = 0; i < m_vecWaferMatrix.size(); i++)
  64. {
  65. AddMatrixPage(i, m_vecWaferMatrix[i]);
  66. }
  67. }
  68. XY_DOUBLE_STRUCT WaferProgramPage::WaferGetAxisPosition(std::string ModuleType, XY_DOUBLE_STRUCT& pos)
  69. {
  70. /*CAxis* _Axis;
  71. CAxis::AXIS_TYPE eAxisType = _Axis->GetAxisType();*/
  72. if (m_pProgramCViewInterface == nullptr)
  73. {
  74. XY_DOUBLE_STRUCT errorPt = pos; // 可以根据需要返回一个错误状态
  75. // 弹出消息框显示位置
  76. QString positionString = QString("Unable to retrieve axis position for module type: %1").arg(QString::fromStdString(ModuleType));
  77. QMessageBox::information(this, "Axis Position Error", positionString);
  78. return errorPt;
  79. }
  80. m_pProgramCViewInterface->GetViewMotion()->GetAxisPosition(ModuleType, "X", pos.x);
  81. m_pProgramCViewInterface->GetViewMotion()->GetAxisPosition(ModuleType, "Y", pos.y);
  82. return pos;
  83. }
  84. void WaferProgramPage::AddMatrixPage(int vectorIndex, _PROGRAM_WAFER_MATRIX_STRUCT matrixData) {
  85. int matrixNum = m_vecWaferMatrix.size();
  86. int newMatrixID = ++matrixNum;
  87. QVector<QObject*> vecControls;
  88. QGroupBox* groupBox = new QGroupBox();
  89. QGridLayout* outMatrixGridLayout = new QGridLayout();
  90. outMatrixGridLayout->setSpacing(6);
  91. outMatrixGridLayout->setObjectName(QString::fromUtf8("subGridLayout"));
  92. groupBox->setLayout(outMatrixGridLayout);
  93. QGridLayout* subGridLayout = new QGridLayout();
  94. subGridLayout->setSpacing(6);
  95. subGridLayout->setObjectName(QString::fromUtf8("subGridLayout"));
  96. QLabel* labelTitle = new QLabel(this);
  97. labelTitle->setObjectName(QString::fromUtf8("labelTitle"));
  98. labelTitle->setText(tr("Matrix ") + QString::number(vectorIndex));
  99. subGridLayout->addWidget(labelTitle, 0, 0, 1, 1);
  100. vecControls.push_back(labelTitle);
  101. // 删除按钮
  102. QPushButton* pushButtonDelete = new QPushButton(this);
  103. pushButtonDelete->setObjectName(QString::fromUtf8("buttonDelete"));
  104. pushButtonDelete->setText(tr("Delete"));
  105. pushButtonDelete->setFixedWidth(62);
  106. subGridLayout->addWidget(pushButtonDelete, 0, 3, 1, 1); // 添加到标题右侧的第四列
  107. vecControls.push_back(pushButtonDelete);
  108. // 删除按钮点击事件
  109. connect(pushButtonDelete, &QPushButton::clicked, this, [=]() {
  110. // 删除当前矩阵页面及控件
  111. auto currentIt = m_mapWaferGroupBoxIndex.find(groupBox);
  112. if (currentIt != m_mapWaferGroupBoxIndex.end()) {
  113. int index = currentIt.value();
  114. m_mapWaferGroupBoxIndex.erase(currentIt);
  115. // 更新索引
  116. for (auto it = m_mapWaferGroupBoxIndex.begin(); it != m_mapWaferGroupBoxIndex.end(); it++) {
  117. if (it.value() > index) {
  118. int newIndex = it.value() - 1;
  119. m_mapWaferGroupBoxIndex.insert(it.key(), newIndex);
  120. }
  121. }
  122. // 删除矩阵数据
  123. m_vecWaferMatrix.erase(m_vecWaferMatrix.begin() + index);
  124. // 删除矩阵控件
  125. delete groupBox;
  126. }
  127. });
  128. QLabel* labelRow = new QLabel(this);
  129. labelRow->setObjectName(QString::fromUtf8("labelRow"));
  130. labelRow->setText(tr("Row & Cow "));
  131. subGridLayout->addWidget(labelRow, 1, 0, 1, 1);
  132. vecControls.push_back(labelRow);
  133. SpinBox* spinBoxRow = new SpinBox(this);
  134. spinBoxRow->setObjectName(QString::fromUtf8("spinBoxRow"));
  135. spinBoxRow->setValue(matrixData.MatrixRow);
  136. subGridLayout->addWidget(spinBoxRow, 1, 1, 1, 1);
  137. vecControls.push_back(spinBoxRow);
  138. /*QLabel* labelCol = new QLabel(this);
  139. labelCol->setObjectName(QString::fromUtf8("labelCol"));
  140. labelCol->setText(tr("Cow "));
  141. subGridLayout->addWidget(labelCol, 2, 0, 1, 1);
  142. vecControls.push_back(labelCol);*/
  143. SpinBox* spinBoxCol = new SpinBox(this);
  144. spinBoxCol->setObjectName(QString::fromUtf8("spinBoxCol"));
  145. spinBoxCol->setValue(matrixData.MatrixCol);
  146. subGridLayout->addWidget(spinBoxCol, 1, 2, 1, 1);
  147. vecControls.push_back(spinBoxCol);
  148. QLabel* labelLeftTop = new QLabel(this);
  149. labelLeftTop->setObjectName(QString::fromUtf8("labelLeftTop"));
  150. labelLeftTop->setText(tr("Left Top Pos "));
  151. subGridLayout->addWidget(labelLeftTop, 4, 0, 1, 1);
  152. vecControls.push_back(labelLeftTop);
  153. // Set all DoubleSpinBox width to 100
  154. DoubleSpinBox* doubleSpinBoxLeftTopX = new DoubleSpinBox(this);
  155. doubleSpinBoxLeftTopX->setObjectName(QString::fromUtf8("doubleSpinBoxLeftTopX"));
  156. doubleSpinBoxLeftTopX->setValue(matrixData.LeftTopPoint.x);
  157. doubleSpinBoxLeftTopX->setFixedWidth(100); // Set fixed width to 100
  158. subGridLayout->addWidget(doubleSpinBoxLeftTopX, 4, 1, 1, 1);
  159. vecControls.push_back(doubleSpinBoxLeftTopX);
  160. DoubleSpinBox* doubleSpinBoxLeftTopY = new DoubleSpinBox(this);
  161. doubleSpinBoxLeftTopY->setObjectName(QString::fromUtf8("doubleSpinBoxLeftTopY"));
  162. doubleSpinBoxLeftTopY->setValue(matrixData.LeftTopPoint.y);
  163. doubleSpinBoxLeftTopY->setFixedWidth(100); // Set fixed width to 100
  164. subGridLayout->addWidget(doubleSpinBoxLeftTopY, 4, 2, 1, 1);
  165. vecControls.push_back(doubleSpinBoxLeftTopY);
  166. // Adding button to get LeftTop position
  167. QPushButton* buttonLeftTop = new QPushButton("Get Pos", this);
  168. buttonLeftTop->setFixedWidth(62);
  169. subGridLayout->addWidget(buttonLeftTop, 4, 3, 1, 1); // Position the button next to LeftTopPos
  170. /*connect(buttonLeftTop, &QPushButton::clicked, this, [=]() {
  171. QString position = QString("X: %1, Y: %2").arg(doubleSpinBoxLeftTopX->value()).arg(doubleSpinBoxLeftTopY->value());
  172. QMessageBox::information(this, "Left Top Position", position);
  173. });*/
  174. connect(buttonLeftTop, &QPushButton::clicked, this, [=]() {
  175. // 获取+更新位置
  176. XY_DOUBLE_STRUCT position = WaferGetAxisPosition("WaferTable", m_vecWaferMatrix[vectorIndex].LeftTopPoint);
  177. // 更新 DoubleSpinBox 的值
  178. doubleSpinBoxLeftTopX->setValue(position.x); // 更新 X 轴
  179. doubleSpinBoxLeftTopY->setValue(position.y); // 更新 Y 轴
  180. });
  181. QLabel* labelRightTopPos = new QLabel(this);
  182. labelRightTopPos->setObjectName(QString::fromUtf8("labelRightTopPos"));
  183. labelRightTopPos->setText(tr("Right Top Pos "));
  184. subGridLayout->addWidget(labelRightTopPos, 5, 0, 1, 1);
  185. vecControls.push_back(labelRightTopPos);
  186. DoubleSpinBox* doubleSpinBoxRightTopX = new DoubleSpinBox(this);
  187. doubleSpinBoxRightTopX->setObjectName(QString::fromUtf8("doubleSpinBoxRightTopX"));
  188. doubleSpinBoxRightTopX->setValue(matrixData.RightTopPoint.x);
  189. doubleSpinBoxRightTopX->setFixedWidth(100); // Set fixed width to 100
  190. subGridLayout->addWidget(doubleSpinBoxRightTopX, 5, 1, 1, 1);
  191. vecControls.push_back(doubleSpinBoxRightTopX);
  192. DoubleSpinBox* doubleSpinBoxRightTopY = new DoubleSpinBox(this);
  193. doubleSpinBoxRightTopY->setObjectName(QString::fromUtf8("doubleSpinBoxRightTopY"));
  194. doubleSpinBoxRightTopY->setValue(matrixData.RightTopPoint.y);
  195. doubleSpinBoxRightTopY->setFixedWidth(100); // Set fixed width to 100
  196. subGridLayout->addWidget(doubleSpinBoxRightTopY, 5, 2, 1, 1);
  197. vecControls.push_back(doubleSpinBoxRightTopY);
  198. // Adding button to get RightTop position
  199. QPushButton* buttonRightTop = new QPushButton("Get Pos", this);
  200. buttonRightTop->setFixedWidth(62);
  201. subGridLayout->addWidget(buttonRightTop, 5, 3, 1, 1); // Position the button next to RightTopPos
  202. connect(buttonRightTop, &QPushButton::clicked, this, [=]() {
  203. // 获取+更新位置
  204. XY_DOUBLE_STRUCT position = WaferGetAxisPosition("WaferTable", m_vecWaferMatrix[vectorIndex].LeftTopPoint);
  205. // 更新 DoubleSpinBox 的值
  206. doubleSpinBoxRightTopX->setValue(position.x); // 更新 X 轴
  207. doubleSpinBoxRightTopY->setValue(position.y); // 更新 Y 轴
  208. });
  209. QLabel* labelRightButtomPos = new QLabel(this);
  210. labelRightButtomPos->setObjectName(QString::fromUtf8("labelRightButtomPos"));
  211. labelRightButtomPos->setText(tr("Right Buttom pos"));
  212. subGridLayout->addWidget(labelRightButtomPos, 6, 0, 1, 1);
  213. vecControls.push_back(labelRightButtomPos);
  214. DoubleSpinBox* doubleSpinBoxRightButtomX = new DoubleSpinBox(this);
  215. doubleSpinBoxRightButtomX->setObjectName(QString::fromUtf8("doubleSpinBoxRightButtomX"));
  216. doubleSpinBoxRightButtomX->setValue(matrixData.RightBottomPoint.x);
  217. doubleSpinBoxRightButtomX->setFixedWidth(100); // Set fixed width to 100
  218. subGridLayout->addWidget(doubleSpinBoxRightButtomX, 6, 1, 1, 1);
  219. vecControls.push_back(doubleSpinBoxRightButtomX);
  220. DoubleSpinBox* doubleSpinBoxRightButtomY = new DoubleSpinBox(this);
  221. doubleSpinBoxRightButtomY->setObjectName(QString::fromUtf8("doubleSpinBoxRightButtomY"));
  222. doubleSpinBoxRightButtomY->setValue(matrixData.RightBottomPoint.y);
  223. doubleSpinBoxRightButtomY->setFixedWidth(100); // Set fixed width to 100
  224. subGridLayout->addWidget(doubleSpinBoxRightButtomY, 6, 2, 1, 1);
  225. vecControls.push_back(doubleSpinBoxRightButtomY);
  226. // Adding button to get RightBottom position
  227. QPushButton* buttonRightButtom = new QPushButton("Get Pos", this);
  228. buttonRightButtom->setFixedWidth(62);
  229. subGridLayout->addWidget(buttonRightButtom, 6, 3, 1, 1); // Position the button next to RightBottomPos
  230. connect(buttonRightButtom, &QPushButton::clicked, this, [=]() {
  231. // 获取+更新位置
  232. XY_DOUBLE_STRUCT position = WaferGetAxisPosition("WaferTable", m_vecWaferMatrix[vectorIndex].LeftTopPoint);
  233. // 更新 DoubleSpinBox 的值
  234. doubleSpinBoxRightButtomX->setValue(position.x); // 更新 X 轴
  235. doubleSpinBoxRightButtomY->setValue(position.y); // 更新 Y 轴
  236. });
  237. QLabel* labelNoBondPts = new QLabel(this);
  238. labelNoBondPts->setObjectName(QString::fromUtf8("labelNoBondPts"));
  239. labelNoBondPts->setText(tr("No Bond Points"));
  240. subGridLayout->addWidget(labelNoBondPts, 7, 0, 1, 1);
  241. vecControls.push_back(labelNoBondPts);
  242. QLineEdit* lineEditNoBondPts = new QLineEdit(this);
  243. lineEditNoBondPts->setObjectName(QString::fromUtf8("lineEditNoBondPts"));
  244. lineEditNoBondPts->setReadOnly(true);
  245. lineEditNoBondPts->setCursor(Qt::PointingHandCursor);
  246. lineEditNoBondPts->setProperty("vectorIndex", vectorIndex); // Store the index
  247. lineEditNoBondPts->installEventFilter(this);
  248. subGridLayout->addWidget(lineEditNoBondPts, 7, 1, 1, 3);
  249. vecControls.push_back(lineEditNoBondPts);
  250. outMatrixGridLayout->addLayout(subGridLayout, 0, 0);
  251. QFrame* line = new QFrame();
  252. line->setFrameShape(QFrame::NoFrame);
  253. line->setFixedHeight(2);
  254. line->setStyleSheet("background-color: #C7CAEB;");
  255. outMatrixGridLayout->addWidget(line);
  256. ui.verticalLayout->addWidget(groupBox);
  257. m_mapWaferGroupBoxIndex.insert(groupBox, vectorIndex);
  258. // 连接信号和槽
  259. connect(spinBoxRow, &SpinBox::editDone, this, [=]() {
  260. m_vecWaferMatrix[vectorIndex].MatrixRow = spinBoxRow->value();
  261. });
  262. connect(spinBoxCol, &SpinBox::editDone, this, [=]() {
  263. m_vecWaferMatrix[vectorIndex].MatrixCol = spinBoxCol->value();
  264. });
  265. connect(doubleSpinBoxLeftTopX, &DoubleSpinBox::editDone, this, [=]() {
  266. m_vecWaferMatrix[vectorIndex].LeftTopPoint.x = doubleSpinBoxLeftTopX->value();
  267. });
  268. connect(doubleSpinBoxLeftTopY, &DoubleSpinBox::editDone, this, [=]() {
  269. m_vecWaferMatrix[vectorIndex].LeftTopPoint.y = doubleSpinBoxLeftTopY->value();
  270. });
  271. connect(doubleSpinBoxRightTopX, &DoubleSpinBox::editDone, this, [=]() {
  272. m_vecWaferMatrix[vectorIndex].RightTopPoint.x = doubleSpinBoxRightTopX->value();
  273. });
  274. connect(doubleSpinBoxRightTopY, &DoubleSpinBox::editDone, this, [=]() {
  275. m_vecWaferMatrix[vectorIndex].RightTopPoint.y = doubleSpinBoxRightTopY->value();
  276. });
  277. connect(doubleSpinBoxRightButtomX, &DoubleSpinBox::editDone, this, [=]() {
  278. m_vecWaferMatrix[vectorIndex].RightBottomPoint.x = doubleSpinBoxRightButtomX->value();
  279. });
  280. connect(doubleSpinBoxRightButtomY, &DoubleSpinBox::editDone, this, [=]() {
  281. m_vecWaferMatrix[vectorIndex].RightBottomPoint.y = doubleSpinBoxRightButtomY->value();
  282. });
  283. connect(lineEditNoBondPts, &QLineEdit::textChanged, this, [=]() {
  284. // Handle NoBondPts logic here
  285. });
  286. }
  287. bool WaferProgramPage::eventFilter(QObject* obj, QEvent* event) {
  288. if (event->type() == QEvent::MouseButtonPress) {
  289. auto* lineEdit = qobject_cast<QLineEdit*>(obj);
  290. if (lineEdit) {
  291. int index = lineEdit->property("vectorIndex").toInt();
  292. if (lineEdit->property("vectorIndex").isValid()) {
  293. // Handle WaffleMatrix
  294. onNoBondPtsClickedWafer(lineEdit, index);
  295. }
  296. return true; // Intercept the event
  297. }
  298. }
  299. return QWidget::eventFilter(obj, event);
  300. }
  301. void WaferProgramPage::onNoBondPtsClickedWafer(QLineEdit* lineEdit, int index) {
  302. if (index < 0 || index >= m_vecWaferMatrix.size()) return;
  303. const auto& wafer = m_vecWaferMatrix[index];
  304. NoBondPtEditDialog dlg(wafer.MatrixRow, wafer.MatrixCol, wafer.VecNoBondPt, this);
  305. if (dlg.exec() == QDialog::Accepted) {
  306. QVector<XY_LONG_STRUCT> selected = dlg.getSelectedPoints();
  307. m_vecWaferMatrix[index].VecNoBondPt = std::vector<XY_LONG_STRUCT>(selected.begin(), selected.end());
  308. QStringList ptList;
  309. for (const auto& pt : selected)
  310. ptList << QString("(%1,%2)").arg(pt.x).arg(pt.y);
  311. lineEdit->setText(ptList.join(" "));
  312. }
  313. }
  314. //QWidget* WaferProgramPage::CreateWaferProgramPage(const CONFIG_BASE_STRUCT& control) {
  315. // return new WaferProgramPage();
  316. //}
  317. //创建下拉列表
  318. //QComboBox* WaferProgramPage::createDieMatrixIdComboBox(int defaultId, int row) {
  319. // QComboBox* comboBox = new QComboBox(m_MergedTable);
  320. //
  321. // // 设置样式,确保在暗色模式下也是白底黑字
  322. // comboBox->setStyleSheet(R"(
  323. // QComboBox {
  324. // background-color: white;
  325. // color: black;
  326. // border: 1px solid #BABBDC;
  327. // border-radius: 4px;
  328. // padding: 2px 5px;
  329. // }
  330. // QComboBox QAbstractItemView {
  331. // background-color: white;
  332. // color: black;
  333. // selection-background-color: #E5E5FF;
  334. // selection-color: black;
  335. // }
  336. // )");
  337. // for (const auto& dieMatrix : m_vecDieMatrixt) {
  338. // /*comboBox->addItem(
  339. // QString("%1 - %2").arg(dieMatrix.MatrixId).arg(QString::fromStdString(dieMatrix.strModuleName)),
  340. // QVariant(dieMatrix.MatrixId)
  341. // );*/
  342. // comboBox->addItem(QString::number(dieMatrix.MatrixId), QVariant(dieMatrix.MatrixId));
  343. // }
  344. //
  345. // int index = comboBox->findData(defaultId);
  346. // if (index >= 0)
  347. // comboBox->setCurrentIndex(index);
  348. //
  349. // return comboBox;
  350. //}
  351. //
  352. //void WaferProgramPage::initMergedData() {
  353. // m_isInitializing = true;
  354. //
  355. // SqlOperation& sqlOp = SqlOperation::GetInstance();
  356. // QList<QJsonObject> directories;
  357. // int userPrivilege = 0;//?
  358. // sqlOp.GetDirectories("Dir_Programme", userPrivilege, directories); // 使用相应的表名和权限加载目录
  359. // m_vecWaferMatrix = m_pProduct->GetWaferMatrix();
  360. //
  361. // for (const PROGRAM_WAFER_MATRIX_STRUCT& wafer : m_vecWaferMatrix) {
  362. // int row = m_MergedTable->rowCount();
  363. // m_MergedTable->insertRow(row);
  364. // PROGRAM_DIE_MATRIX_STRUCT stDieMatrix;
  365. // m_pProduct->GetDieMatrix(wafer.MatrixId, stDieMatrix);
  366. // m_vecDieMatrixt.push_back(stDieMatrix);
  367. //
  368. // // 填充表格数据
  369. // m_MergedTable->setItem(row, 0, new QTableWidgetItem(QString::number(wafer.MatrixId))); // MatrixID
  370. // m_MergedTable->setItem(row, 1, new QTableWidgetItem(QString::number(wafer.MatrixRow))); // MatrixRow
  371. // m_MergedTable->setItem(row, 2, new QTableWidgetItem(QString::number(wafer.MatrixCol))); // MatrixCol
  372. // m_MergedTable->setItem(row, 3, new QTableWidgetItem(QString::number(wafer.LeftTopPoint.y))); // LeftTopPoint_Y
  373. // m_MergedTable->setItem(row, 4, new QTableWidgetItem(QString::number(wafer.LeftTopPoint.x))); // LeftTopPoint_X
  374. // m_MergedTable->setItem(row, 5, new QTableWidgetItem(QString::number(wafer.RightTopPoint.x))); // RightTopPoint_X
  375. // m_MergedTable->setItem(row, 6, new QTableWidgetItem(QString::number(wafer.RightTopPoint.y))); // RightTopPoint_Y
  376. // m_MergedTable->setItem(row, 7, new QTableWidgetItem(QString::number(wafer.RightBottomPoint.x))); // RightBottomPoint_X
  377. // m_MergedTable->setItem(row, 8, new QTableWidgetItem(QString::number(wafer.RightBottomPoint.y))); // RightBottomPoint_Y
  378. // m_MergedTable->setItem(row, 9, new QTableWidgetItem(QString::number(wafer.iDieMatrixId))); // DieMatrixId
  379. //
  380. // // 填充 NoBondPt 数据
  381. // QStringList noBondPts;
  382. // for (const XY_LONG_STRUCT& pt : wafer.VecNoBondPt) {
  383. // noBondPts.append(QString("(%1,%2)").arg(pt.x).arg(pt.y));
  384. // }
  385. // m_MergedTable->setItem(row, 10, new QTableWidgetItem(noBondPts.join(" "))); // NoBondPt
  386. // }
  387. //
  388. // // 调整列宽和行高
  389. // m_MergedTable->resizeColumnsToContents();
  390. // m_MergedTable->resizeRowsToContents();
  391. //
  392. // m_isInitializing = false;// 开启信号处理
  393. //}
  394. //
  395. //void WaferProgramPage::addRow() {
  396. // m_isInitializing = true;
  397. // m_IdIsUsedMap.clear();
  398. // for (const auto& wafer : m_vecWaferMatrix) {
  399. // m_IdIsUsedMap[wafer.MatrixId] = true;
  400. // }
  401. // int row = m_MergedTable->rowCount();
  402. // m_MergedTable->insertRow(row);
  403. //
  404. // int newId = 1;
  405. // bool idUsed = true;
  406. //
  407. // //// 检查当前 MatrixId 是否已存在
  408. // //while (idUsed) {
  409. // // idUsed = false; // 假设 ID 没有被使用
  410. //
  411. // // // 如果 ID 已存在于 map 中,则说明已被使用
  412. // // if (m_IdIsUsedMap.find(newId) != m_IdIsUsedMap.end()) {
  413. // // idUsed = true;
  414. // // }
  415. //
  416. // // if (idUsed) {
  417. // // ++newId; // 如果 ID 被使用,检查下一个 ID
  418. // // }
  419. // //}
  420. // //找出最大的ID值
  421. // UINT maxId = 0;
  422. // for (PROGRAM_WAFER_MATRIX_STRUCT& bondMatrix : m_vecWaferMatrix)
  423. // {
  424. // if (bondMatrix.MatrixId > maxId)
  425. // {
  426. // maxId = bondMatrix.MatrixId;
  427. // }
  428. // }
  429. // newId = ++maxId;
  430. //
  431. // // 为新行添加默认数据
  432. // m_MergedTable->setItem(row, 0, new QTableWidgetItem(QString::number(newId))); // MatrixID 默认值为 0
  433. // m_MergedTable->setItem(row, 1, new QTableWidgetItem("1")); // MatrixRow 默认值为 1
  434. // m_MergedTable->setItem(row, 2, new QTableWidgetItem("1")); // MatrixCol 默认值为 1
  435. // m_MergedTable->setItem(row, 3, new QTableWidgetItem("0")); // LeftTopPoint_Y 默认值为 0
  436. // m_MergedTable->setItem(row, 4, new QTableWidgetItem("0")); // LeftTopPoint_X 默认值为 0
  437. // m_MergedTable->setItem(row, 5, new QTableWidgetItem("0")); // RightTopPoint_X 默认值为 0
  438. // m_MergedTable->setItem(row, 6, new QTableWidgetItem("0")); // RightTopPoint_Y 默认值为 0
  439. // m_MergedTable->setItem(row, 7, new QTableWidgetItem("0")); // RightBottomPoint_X 默认值为 0
  440. // m_MergedTable->setItem(row, 8, new QTableWidgetItem("0")); // RightBottomPoint_Y 默认值为 0
  441. // m_MergedTable->setItem(row, 9, new QTableWidgetItem("0")); // DieMatrixId 默认值为 0
  442. // /*QComboBox* comboBox = createDieMatrixIdComboBox(0, row);
  443. // m_MergedTable->setCellWidget(row, 9, comboBox);*/
  444. //
  445. // m_MergedTable->setItem(row, 10, new QTableWidgetItem("")); // NoBondPt 默认值为空
  446. //
  447. // // 同时更新 PROGRAM_WAFER_MATRIX_STRUCT 数据
  448. // PROGRAM_WAFER_MATRIX_STRUCT newMatrix;
  449. // newMatrix.MatrixId = newId;
  450. // newMatrix.MatrixRow = 1;
  451. // newMatrix.MatrixCol = 1;
  452. // newMatrix.LeftTopPoint = { 0.0, 0.0 };
  453. // newMatrix.RightTopPoint = { 0.0, 0.0 };
  454. // newMatrix.RightBottomPoint = { 0.0, 0.0 };
  455. // newMatrix.iDieMatrixId = 0;
  456. // newMatrix.VecNoBondPt.clear(); // 默认值为空
  457. //
  458. // m_vecWaferMatrix.push_back(newMatrix);
  459. // // 将新矩阵添加到数据结构中
  460. // //m_pProduct->AddWaferMatrix(newMatrix, newId);
  461. // m_isInitializing = false;
  462. //}
  463. //
  464. //void WaferProgramPage::deleteRow() {
  465. // int currentRow = m_MergedTable->currentRow();
  466. //
  467. // if (currentRow >= 0 && currentRow < m_MergedTable->rowCount()) {
  468. // // 获取 MatrixID(假设第0列是 MatrixID)
  469. // QTableWidgetItem* idItem = m_MergedTable->item(currentRow, 0);
  470. // if (!idItem) return;
  471. //
  472. // int matrixID = idItem->text().toInt();
  473. //
  474. // // 从 m_MergedTable 删除行
  475. // m_MergedTable->removeRow(currentRow);
  476. //
  477. // // 从 m_vecWaferMatrix 中移除对应项
  478. // auto it = std::remove_if(m_vecWaferMatrix.begin(), m_vecWaferMatrix.end(),
  479. // [matrixID](const PROGRAM_WAFER_MATRIX_STRUCT& wafer) {
  480. // return wafer.MatrixId == matrixID;
  481. // });
  482. // if (it != m_vecWaferMatrix.end()) {
  483. // m_vecWaferMatrix.erase(it, m_vecWaferMatrix.end());
  484. // }
  485. //
  486. // // 同时通知数据管理类删除
  487. // //m_pProduct->DeleteWaferMatrix(matrixID);
  488. //
  489. // }
  490. // else {
  491. // //QMessageBox::warning(this, "No Row Selected", "Please select a row to delete.");
  492. // QMessageBox box(QMessageBox::Warning, "No Row Selected", "Please select a row to delete.");
  493. // box.setStyleSheet(R"(
  494. // QMessageBox {
  495. // background-color: #eeeeee;
  496. // color: black;
  497. // }
  498. // QPushButton {
  499. // background-color: #dddddd;
  500. // color: black;
  501. // }
  502. // )");
  503. // box.exec();
  504. // }
  505. // currentRow = -1;
  506. //}
  507. //
  508. //void WaferProgramPage::updateData() {
  509. // // 1. 清空原模型中的矩阵
  510. // auto originalData = m_pProduct->GetWaferMatrix();
  511. // for (const auto& matrix : originalData) {
  512. // m_pProduct->DeleteWaferMatrix(matrix.MatrixId);
  513. // }
  514. //
  515. // // 2. 添加当前表格中的数据
  516. // for (auto& matrix : m_vecWaferMatrix) {
  517. // int newId = matrix.MatrixId;
  518. // m_pProduct->AddWaferMatrix(matrix, newId);
  519. // auto originalData1 = m_pProduct->GetWaferMatrix();
  520. // }
  521. //
  522. // //qDebug() << "WaferMatrix 已同步到模型层,共同步:" << m_vecWaferMatrix.size() << "条记录。";
  523. //}
  524. //void WaferProgramPage::onCellChanged(int row, int column)
  525. //{
  526. // if (m_isInitializing) return; // 防止初始化时触发
  527. // if (row >= m_vecWaferMatrix.size()) return;
  528. //
  529. // QTableWidgetItem* item = m_MergedTable->item(row, column);
  530. // if (!item) return;
  531. //
  532. // QString value = item->text();
  533. // PROGRAM_WAFER_MATRIX_STRUCT& wafer = m_vecWaferMatrix[row];
  534. //
  535. // switch (column) {
  536. // case 0: wafer.MatrixId = value.toInt(); break;
  537. // case 1: wafer.MatrixRow = value.toInt(); break;
  538. // case 2: wafer.MatrixCol = value.toInt(); break;
  539. // case 3: wafer.LeftTopPoint.y = value.toDouble(); break;
  540. // case 4: wafer.LeftTopPoint.x = value.toDouble(); break;
  541. // case 5: wafer.RightTopPoint.x = value.toDouble(); break;
  542. // case 6: wafer.RightTopPoint.y = value.toDouble(); break;
  543. // case 7: wafer.RightBottomPoint.x = value.toDouble(); break;
  544. // case 8: wafer.RightBottomPoint.y = value.toDouble(); break;
  545. // ////case 9: wafer.iDieMatrixId = value.toInt(); break;
  546. //
  547. // case 10: {
  548. // wafer.VecNoBondPt.clear();
  549. // QRegularExpression regex(R"(\((\d+),(\d+)\))");
  550. // QRegularExpressionMatchIterator i = regex.globalMatch(value);
  551. // while (i.hasNext()) {
  552. // auto match = i.next();
  553. // XY_LONG_STRUCT pt;
  554. // pt.x = match.captured(1).toInt();
  555. // pt.y = match.captured(2).toInt();
  556. // wafer.VecNoBondPt.push_back(pt);
  557. // }
  558. // break;
  559. // }
  560. // default: break;
  561. // }
  562. //}