WaferProgramPage.cpp 26 KB

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