WaffleProgramPage.cpp 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  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 <QLabel>
  7. WaffleProgramPage::WaffleProgramPage(QWidget* parent)
  8. :QWidget(parent)
  9. {
  10. ui.setupUi(this);
  11. setStyleSheet(
  12. "QDoubleSpinBox{background: #FFFFFF;border: 1px solid #BABBDC;border - radius: 6px;padding: 2px 5px;}"
  13. "QSpinBox{background: #FFFFFF;border: 1px solid #BABBDC;border - radius: 6px;padding: 2px 5px;}"
  14. "QLineEdit{background: #FFFFFF;border: 1px solid #BABBDC;border - radius: 6px;padding: 2px 5px;}"
  15. "QCheckBox::indicator{width: 20px;height: 20px;}"
  16. "QCheckBox::indicator:unchecked{background - color: #FFFFFF;border-radius: 2px;}"
  17. "QComboBox{background: #FFFFFF;border: 1px solid #BABBDC;border - radius: 6px;padding: 2px 5px;}"
  18. "QComboBox::drop - down{width: 20px;}"
  19. );
  20. m_manageDB = CManageDB::GetInstance();
  21. if (m_manageDB == nullptr) return;
  22. m_pProduct = m_manageDB->GetCProduct();
  23. if (m_pProduct == nullptr) return;
  24. initPage();
  25. }
  26. WaffleProgramPage::~WaffleProgramPage()
  27. {
  28. }
  29. void WaffleProgramPage::AddMatrixPage(int vectorIndex, PROGRAM_WAFFLE_MATRIX_STRUCT matrixData, std::vector<PROGRAM_DIE_MATRIX_STRUCT> vecSubMatrix)
  30. {
  31. int matrixNum = m_mapSubMatrixControls.size();
  32. int newMatrixID = ++matrixNum;
  33. QVector<QObject*> vecControls;
  34. QGroupBox* groupBox = new QGroupBox();
  35. QGridLayout* outMatrixGridLayout = new QGridLayout();
  36. outMatrixGridLayout->setSpacing(6);
  37. outMatrixGridLayout->setObjectName(QString::fromUtf8("subGridLayout"));
  38. groupBox->setLayout(outMatrixGridLayout);
  39. QGridLayout* subGridLayout = new QGridLayout();
  40. subGridLayout->setSpacing(6);
  41. subGridLayout->setObjectName(QString::fromUtf8("subGridLayout"));
  42. //groupBox->setLayout(subGridLayout);
  43. QLabel* labelTitle = new QLabel(this);
  44. labelTitle->setObjectName(QString::fromUtf8("labelTitle"));
  45. labelTitle->setText(tr("Sub Matrix ") + QString::number(vectorIndex));
  46. subGridLayout->addWidget(labelTitle, 0, 0, 1, 1);
  47. vecControls.push_back(labelTitle);
  48. QLabel* labelRow = new QLabel(this);
  49. labelRow->setObjectName(QString::fromUtf8("labelRow"));
  50. labelRow->setText(tr("Row "));
  51. subGridLayout->addWidget(labelRow, 1, 0, 1, 1);
  52. vecControls.push_back(labelRow);
  53. SpinBox* spinBoxRow = new SpinBox(this);
  54. spinBoxRow->setObjectName(QString::fromUtf8("spinBoxRow"));
  55. subGridLayout->addWidget(spinBoxRow, 1, 1, 1, 1);
  56. vecControls.push_back(spinBoxRow);
  57. QLabel* labelCol = new QLabel(this);
  58. labelCol->setObjectName(QString::fromUtf8("labelCol"));
  59. labelCol->setText(tr("Cow "));
  60. subGridLayout->addWidget(labelCol, 2, 0, 1, 1);
  61. vecControls.push_back(labelCol);
  62. SpinBox* spinBoxCol = new SpinBox(this);
  63. spinBoxCol->setObjectName(QString::fromUtf8("spinBoxCol"));
  64. subGridLayout->addWidget(spinBoxCol, 2, 1, 1, 1);
  65. vecControls.push_back(spinBoxCol);
  66. QLabel* labelLeftTop = new QLabel(this);
  67. labelLeftTop->setObjectName(QString::fromUtf8("labelLeftTop"));
  68. labelLeftTop->setText(tr("Left Top Pos "));
  69. subGridLayout->addWidget(labelLeftTop, 4, 0, 1, 1);
  70. vecControls.push_back(labelLeftTop);
  71. DoubleSpinBox* doubleSpinBoxLeftTopX = new DoubleSpinBox(this);
  72. doubleSpinBoxLeftTopX->setObjectName(QString::fromUtf8("doubleSpinBoxLeftTopX"));
  73. subGridLayout->addWidget(doubleSpinBoxLeftTopX, 4, 1, 1, 1);
  74. vecControls.push_back(doubleSpinBoxLeftTopX);
  75. DoubleSpinBox* doubleSpinBoxLeftTopY = new DoubleSpinBox(this);
  76. doubleSpinBoxLeftTopY->setObjectName(QString::fromUtf8("doubleSpinBoxLeftTopY"));
  77. subGridLayout->addWidget(doubleSpinBoxLeftTopY, 4, 2, 1, 1);
  78. vecControls.push_back(doubleSpinBoxLeftTopY);
  79. QLabel* labelRightTopPos = new QLabel(this);
  80. labelRightTopPos->setObjectName(QString::fromUtf8("labelRightTopPos"));
  81. labelRightTopPos->setText(tr("Right Top Pos "));
  82. subGridLayout->addWidget(labelRightTopPos, 5, 0, 1, 1);
  83. vecControls.push_back(labelRightTopPos);
  84. DoubleSpinBox* doubleSpinBoxRightTopX = new DoubleSpinBox(this);
  85. doubleSpinBoxRightTopX->setObjectName(QString::fromUtf8("doubleSpinBoxRightTopX"));
  86. subGridLayout->addWidget(doubleSpinBoxRightTopX, 5, 1, 1, 1);
  87. vecControls.push_back(doubleSpinBoxRightTopX);
  88. DoubleSpinBox* doubleSpinBoxRightTopY = new DoubleSpinBox(this);
  89. doubleSpinBoxRightTopY->setObjectName(QString::fromUtf8("doubleSpinBoxRightTopY"));
  90. subGridLayout->addWidget(doubleSpinBoxRightTopY, 5, 2, 1, 1);
  91. vecControls.push_back(doubleSpinBoxRightTopY);
  92. QLabel* labelRightButtomPos = new QLabel(this);
  93. labelRightButtomPos->setObjectName(QString::fromUtf8("labelRightButtomPos"));
  94. labelRightButtomPos->setText(tr("Right Buttom pos"));
  95. subGridLayout->addWidget(labelRightButtomPos, 6, 0, 1, 1);
  96. vecControls.push_back(labelRightButtomPos);
  97. DoubleSpinBox* doubleSpinBoxRightButtomX = new DoubleSpinBox(this);
  98. doubleSpinBoxRightButtomX->setObjectName(QString::fromUtf8("doubleSpinBoxRightButtomX"));
  99. subGridLayout->addWidget(doubleSpinBoxRightButtomX, 6, 1, 1, 1);
  100. vecControls.push_back(doubleSpinBoxRightButtomX);
  101. DoubleSpinBox* doubleSpinBoxRightButtomY = new DoubleSpinBox(this);
  102. doubleSpinBoxRightButtomY->setObjectName(QString::fromUtf8("doubleSpinBoxRightButtomY"));
  103. subGridLayout->addWidget(doubleSpinBoxRightButtomY, 6, 2, 1, 1);
  104. vecControls.push_back(doubleSpinBoxRightTopX);
  105. QLabel* labelNoBondPts = new QLabel(this);
  106. labelNoBondPts->setObjectName(QString::fromUtf8("labelNoBondPts"));
  107. labelNoBondPts->setText(tr("No Bond Points"));
  108. subGridLayout->addWidget(labelNoBondPts, 7, 0, 1, 1);
  109. vecControls.push_back(labelNoBondPts);
  110. QLineEdit* lineEditNoBondPts = new QLineEdit(this);
  111. lineEditNoBondPts->setObjectName(QString::fromUtf8("lineEditNoBondPts"));
  112. subGridLayout->addWidget(lineEditNoBondPts, 7, 1, 1, 2);
  113. vecControls.push_back(lineEditNoBondPts);
  114. outMatrixGridLayout->addLayout(subGridLayout, 0, 0);
  115. QFrame* line = new QFrame();
  116. line->setFrameShape(QFrame::NoFrame); // 移除默认框架
  117. line->setFixedHeight(2); // 设置固定高度
  118. line->setStyleSheet("background-color: #C7CAEB;");
  119. outMatrixGridLayout->addWidget(line);
  120. ui.verticalLayout->addWidget(groupBox);
  121. for (int j = 0; j < matrixData.VecDieMatrixId.size(); j++)
  122. {
  123. for (int i = 0; i < m_vecSubWaffleMatrix.size(); i++)
  124. {
  125. if (matrixData.VecDieMatrixId[j] == m_vecSubWaffleMatrix[i].MatrixId)
  126. {
  127. AddSubMatrixPage(i, m_vecSubWaffleMatrix[i], outMatrixGridLayout);
  128. }
  129. }
  130. }
  131. //for (int i = 0; i = vecSubMatrix.size(); i++)
  132. //{
  133. // AddSubMatrixPage(i, vecSubMatrix[i], outMatrixGridLayout);
  134. //}
  135. connect(spinBoxRow, &SpinBox::editDone, this, [=]() {
  136. m_vecWaffleMatrix[vectorIndex].PackRow = spinBoxRow->value();
  137. });
  138. connect(spinBoxCol, &SpinBox::editDone, this, [=]() {
  139. m_vecWaffleMatrix[vectorIndex].PackCol = spinBoxCol->value();
  140. });
  141. connect(doubleSpinBoxLeftTopX, &DoubleSpinBox::editDone, this, [=]() {
  142. m_vecWaffleMatrix[vectorIndex].LeftTopPoint.x = doubleSpinBoxLeftTopX->value();
  143. });
  144. connect(doubleSpinBoxLeftTopY, &DoubleSpinBox::editDone, this, [=]() {
  145. m_vecWaffleMatrix[vectorIndex].LeftTopPoint.y = doubleSpinBoxLeftTopY->value();
  146. });
  147. connect(doubleSpinBoxRightTopX, &DoubleSpinBox::editDone, this, [=]() {
  148. m_vecWaffleMatrix[vectorIndex].RightTopPoint.x = doubleSpinBoxRightTopX->value();
  149. });
  150. connect(doubleSpinBoxRightTopY, &DoubleSpinBox::editDone, this, [=]() {
  151. m_vecWaffleMatrix[vectorIndex].RightTopPoint.y = doubleSpinBoxRightTopY->value();
  152. });
  153. connect(doubleSpinBoxRightButtomX, &DoubleSpinBox::editDone, this, [=]() {
  154. m_vecWaffleMatrix[vectorIndex].RightBottomPoint.x = doubleSpinBoxRightButtomX->value();
  155. });
  156. connect(doubleSpinBoxRightButtomY, &DoubleSpinBox::editDone, this, [=]() {
  157. m_vecWaffleMatrix[vectorIndex].RightBottomPoint.y = doubleSpinBoxRightButtomY->value();
  158. });
  159. connect(lineEditNoBondPts, &QLineEdit::textChanged, this, [=]() {
  160. });
  161. }
  162. void WaffleProgramPage::AddSubMatrixPage(int subVectorIndex, PROGRAM_DIE_MATRIX_STRUCT subMatrix, QGridLayout* layout)
  163. {
  164. QVector<QObject*> vecControls;
  165. QGridLayout* subGridLayout = new QGridLayout();
  166. subGridLayout->setSpacing(6);
  167. subGridLayout->setObjectName(QString::fromUtf8("subGridLayout"));
  168. //groupBox->setLayout(subGridLayout);
  169. QLabel* labelTitle = new QLabel(this);
  170. labelTitle->setObjectName(QString::fromUtf8("labelTitle"));
  171. labelTitle->setText(tr("Sub Matrix ") + QString::number(subVectorIndex));
  172. subGridLayout->addWidget(labelTitle, 0, 0, 1, 1);
  173. vecControls.push_back(labelTitle);
  174. labelTitle->setStyleSheet("background-color: #F0F0F0;");
  175. QLabel* labelRow = new QLabel(this);
  176. labelRow->setObjectName(QString::fromUtf8("labelRow"));
  177. labelRow->setText(tr("Row "));
  178. subGridLayout->addWidget(labelRow, 1, 0, 1, 1);
  179. vecControls.push_back(labelRow);
  180. SpinBox* spinBoxRow = new SpinBox(this);
  181. spinBoxRow->setObjectName(QString::fromUtf8("spinBoxRow"));
  182. subGridLayout->addWidget(spinBoxRow, 1, 1, 1, 1);
  183. vecControls.push_back(spinBoxRow);
  184. QLabel* labelCol = new QLabel(this);
  185. labelCol->setObjectName(QString::fromUtf8("labelCol"));
  186. labelCol->setText(tr("Cow "));
  187. subGridLayout->addWidget(labelCol, 2, 0, 1, 1);
  188. vecControls.push_back(labelCol);
  189. SpinBox* spinBoxCol = new SpinBox(this);
  190. spinBoxCol->setObjectName(QString::fromUtf8("spinBoxCol"));
  191. subGridLayout->addWidget(spinBoxCol, 2, 1, 1, 1);
  192. vecControls.push_back(spinBoxCol);
  193. QLabel* labelLeftTop = new QLabel(this);
  194. labelLeftTop->setObjectName(QString::fromUtf8("labelLeftTop"));
  195. labelLeftTop->setText(tr("Left Top Pos "));
  196. subGridLayout->addWidget(labelLeftTop, 4, 0, 1, 1);
  197. vecControls.push_back(labelLeftTop);
  198. DoubleSpinBox* doubleSpinBoxLeftTopX = new DoubleSpinBox(this);
  199. doubleSpinBoxLeftTopX->setObjectName(QString::fromUtf8("doubleSpinBoxLeftTopX"));
  200. subGridLayout->addWidget(doubleSpinBoxLeftTopX, 4, 1, 1, 1);
  201. vecControls.push_back(doubleSpinBoxLeftTopX);
  202. DoubleSpinBox* doubleSpinBoxLeftTopY = new DoubleSpinBox(this);
  203. doubleSpinBoxLeftTopY->setObjectName(QString::fromUtf8("doubleSpinBoxLeftTopY"));
  204. subGridLayout->addWidget(doubleSpinBoxLeftTopY, 4, 2, 1, 1);
  205. vecControls.push_back(doubleSpinBoxLeftTopY);
  206. QLabel* labelRightTopPos = new QLabel(this);
  207. labelRightTopPos->setObjectName(QString::fromUtf8("labelRightTopPos"));
  208. labelRightTopPos->setText(tr("Right Top Pos "));
  209. subGridLayout->addWidget(labelRightTopPos, 5, 0, 1, 1);
  210. vecControls.push_back(labelRightTopPos);
  211. DoubleSpinBox* doubleSpinBoxRightTopX = new DoubleSpinBox(this);
  212. doubleSpinBoxRightTopX->setObjectName(QString::fromUtf8("doubleSpinBoxRightTopX"));
  213. subGridLayout->addWidget(doubleSpinBoxRightTopX, 5, 1, 1, 1);
  214. vecControls.push_back(doubleSpinBoxRightTopX);
  215. DoubleSpinBox* doubleSpinBoxRightTopY = new DoubleSpinBox(this);
  216. doubleSpinBoxRightTopY->setObjectName(QString::fromUtf8("doubleSpinBoxRightTopY"));
  217. subGridLayout->addWidget(doubleSpinBoxRightTopY, 5, 2, 1, 1);
  218. vecControls.push_back(doubleSpinBoxRightTopY);
  219. QLabel* labelRightButtomPos = new QLabel(this);
  220. labelRightButtomPos->setObjectName(QString::fromUtf8("labelRightButtomPos"));
  221. labelRightButtomPos->setText(tr("Right Buttom pos"));
  222. subGridLayout->addWidget(labelRightButtomPos, 6, 0, 1, 1);
  223. vecControls.push_back(labelRightButtomPos);
  224. DoubleSpinBox* doubleSpinBoxRightButtomX = new DoubleSpinBox(this);
  225. doubleSpinBoxRightButtomX->setObjectName(QString::fromUtf8("doubleSpinBoxRightButtomX"));
  226. subGridLayout->addWidget(doubleSpinBoxRightButtomX, 6, 1, 1, 1);
  227. vecControls.push_back(doubleSpinBoxRightButtomX);
  228. DoubleSpinBox* doubleSpinBoxRightButtomY = new DoubleSpinBox(this);
  229. doubleSpinBoxRightButtomY->setObjectName(QString::fromUtf8("doubleSpinBoxRightButtomY"));
  230. subGridLayout->addWidget(doubleSpinBoxRightButtomY, 6, 2, 1, 1);
  231. vecControls.push_back(doubleSpinBoxRightTopX);
  232. QLabel* labelNoBondPts = new QLabel(this);
  233. labelNoBondPts->setObjectName(QString::fromUtf8("labelNoBondPts"));
  234. labelNoBondPts->setText(tr("No Bond Points"));
  235. subGridLayout->addWidget(labelNoBondPts, 7, 0, 1, 1);
  236. vecControls.push_back(labelNoBondPts);
  237. QLineEdit* lineEditNoBondPts = new QLineEdit(this);
  238. lineEditNoBondPts->setObjectName(QString::fromUtf8("lineEditNoBondPts"));
  239. subGridLayout->addWidget(lineEditNoBondPts, 7, 1, 1, 2);
  240. vecControls.push_back(lineEditNoBondPts);
  241. layout->addLayout(subGridLayout, 11, 0);
  242. QFrame* line = new QFrame();
  243. line->setFrameShape(QFrame::NoFrame); // 移除默认框架
  244. line->setFixedHeight(2); // 设置固定高度
  245. line->setStyleSheet("background-color: #C7CAEB;");
  246. ui.verticalLayout->addWidget(line);
  247. connect(spinBoxRow, &SpinBox::editDone, this, [=]() {
  248. m_vecSubWaffleMatrix[subVectorIndex].MatrixRow = spinBoxRow->value();
  249. });
  250. connect(spinBoxCol, &SpinBox::editDone, this, [=]() {
  251. m_vecSubWaffleMatrix[subVectorIndex].MatrixCol = spinBoxCol->value();
  252. });
  253. connect(doubleSpinBoxLeftTopX, &DoubleSpinBox::editDone, this, [=]() {
  254. m_vecSubWaffleMatrix[subVectorIndex].LeftTopPoint.x = doubleSpinBoxLeftTopX->value();
  255. });
  256. connect(doubleSpinBoxLeftTopY, &DoubleSpinBox::editDone, this, [=]() {
  257. m_vecSubWaffleMatrix[subVectorIndex].LeftTopPoint.y = doubleSpinBoxLeftTopY->value();
  258. });
  259. connect(doubleSpinBoxRightTopX, &DoubleSpinBox::editDone, this, [=]() {
  260. m_vecSubWaffleMatrix[subVectorIndex].RightTopPoint.x = doubleSpinBoxRightTopX->value();
  261. });
  262. connect(doubleSpinBoxRightTopY, &DoubleSpinBox::editDone, this, [=]() {
  263. m_vecSubWaffleMatrix[subVectorIndex].RightTopPoint.y = doubleSpinBoxRightTopY->value();
  264. });
  265. connect(doubleSpinBoxRightButtomX, &DoubleSpinBox::editDone, this, [=]() {
  266. m_vecSubWaffleMatrix[subVectorIndex].RightBottomPoint.x = doubleSpinBoxRightButtomX->value();
  267. });
  268. connect(doubleSpinBoxRightButtomY, &DoubleSpinBox::editDone, this, [=]() {
  269. m_vecSubWaffleMatrix[subVectorIndex].RightBottomPoint.y = doubleSpinBoxRightButtomY->value();
  270. });
  271. connect(lineEditNoBondPts, &QLineEdit::textChanged, this, [=]() {
  272. });
  273. }
  274. void WaffleProgramPage::SaveAllParam()
  275. {
  276. }
  277. void WaffleProgramPage::MatrixChangeEvent()
  278. {
  279. for (PROGRAM_WAFFLE_MATRIX_STRUCT& waffleMatrix : m_vecWaffleMatrix)
  280. {
  281. m_pProduct->SetWaffleMatrix(waffleMatrix.MatrixId, waffleMatrix);
  282. }
  283. m_pProduct->SetDieMatrix(m_vecSubWaffleMatrix, true);
  284. //for (PROGRAM_BOND_MATRIX_STRUCT& bondMatrix : m_vecWaffleMatrix)
  285. //{
  286. // m_manageDB->GetCProduct()->SetBondMatrix(bondMatrix.BondMatrixId, bondMatrix);
  287. //}
  288. //for (PROGRAM_POINT_MATRIX_STRUCT& pointMatrix : m_vecSubMatrixs)
  289. //{
  290. // m_manageDB->GetCProduct()->SetPointMatrix(pointMatrix.MatrixId, pointMatrix);
  291. //}
  292. }
  293. void WaffleProgramPage::initPage()
  294. {
  295. m_vecWaffleMatrix = m_pProduct->GetWaffleMatrix();
  296. for (int i = 0; i < m_vecWaffleMatrix.size(); i++)
  297. {
  298. for (int j = 0; j < m_vecWaffleMatrix[i].VecDieMatrixId.size(); j++)
  299. {
  300. PROGRAM_DIE_MATRIX_STRUCT subMatrix;
  301. m_pProduct->GetDieMatrix(m_vecWaffleMatrix[i].VecDieMatrixId[j], subMatrix);
  302. m_vecSubWaffleMatrix.push_back(subMatrix);
  303. //AddMatrixPage(i, j, subMatrix);
  304. }
  305. AddMatrixPage(i, m_vecWaffleMatrix[i], m_vecSubWaffleMatrix);
  306. //for (int j = 0; j < m_vecWaffleMatrix[i].VecDieMatrixId.size(); j++)
  307. //{
  308. // for (int k = 0; k < m_vecSubWaffleMatrix.size(); k++)
  309. // {
  310. // if (m_vecWaffleMatrix[i].VecDieMatrixId[j] == m_vecSubWaffleMatrix[k].MatrixId)
  311. // {
  312. // AddSubMatrixPage(i, m_vecSubWaffleMatrix[k],nullptr);
  313. // }
  314. // }
  315. //}
  316. }
  317. }