BondMatrixProgramPage.cpp 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529
  1. #include "BondMatrixProgramPage.h"
  2. #include "Src/RewriteControl/Controls/SpinBox.h"
  3. #include "Src/RewriteControl/Controls/DoubleSpinBox.h"
  4. #include <QPushButton>
  5. #include <QtWidgets/qmessagebox.h>
  6. #include <View/die-bonder-ui/Src/MatrixDialogs/NoBondPtEditDialog.h>
  7. BondMatrixProgramPage::BondMatrixProgramPage(QWidget* parent) :
  8. QWidget(parent)
  9. {
  10. ui.setupUi(this);
  11. ui.pushButtonSave->setProperty("type", "save");
  12. ui.pushButtonAddOutMatrix->setProperty("type", "addOutMatrix");
  13. ui.pushButtonSaveParaAs->setProperty("type", "saveParaAs");
  14. ui.pushButtonSavePara->setProperty("type", "savePara");
  15. setStyleSheet(
  16. "QWidget { background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #F1F4FD, stop: 1 #E5E4F6); }"
  17. "QDoubleSpinBox { background: #FFFFFF; border: 1px solid #BABBDC; border-radius: 6px; padding: 2px 5px; }"
  18. "QSpinBox { background: #FFFFFF; border: 1px solid #BABBDC; border-radius: 6px; padding: 2px 5px; }"
  19. "QLineEdit { background: #FFFFFF; border: 1px solid #BABBDC; border-radius: 6px; padding: 2px 5px; }"
  20. "QCheckBox::indicator { width: 20px; height: 20px; }"
  21. "QCheckBox::indicator:unchecked { background-color: #FFFFFF; border-radius: 2px; }"
  22. "QComboBox { background: #FFFFFF; border: 1px solid #BABBDC; border-radius: 6px; padding: 2px 5px; }"
  23. "QComboBox::drop-down { width: 20px; }"
  24. "QPushButton { background: #D0D0E8; border: 1px solid #BABBDC; border-radius: 6px; padding: 2px 5px; }" // Button background color
  25. "QPushButton:hover { background-color: #B0B0D8; }" // Lighter color on hover
  26. "QPushButton:pressed { background-color: #A0A0C8; }" // Darker color on press
  27. );
  28. m_manageDB = CManageDB::GetInstance();
  29. if (m_manageDB == nullptr) return;
  30. m_pProduct = m_manageDB->GetCProduct();
  31. if (m_pProduct == nullptr) return;
  32. m_pProgramCViewInterface = ns_module::CViewInterface::GetInstance();
  33. ui.frame->setFrameShape(QFrame::NoFrame); // 移除默认框架
  34. ui.frame->setFixedHeight(2); // 设置固定高度
  35. ui.frame->setStyleSheet("background-color: #C7CAEB;");
  36. //ui.tab->setStyleSheet("background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #F1F4FD, stop: 1 #E5E4F6)");
  37. //从后端获取数据
  38. m_vectBondMatrixs = m_manageDB->GetCProduct()->GetBondMatrix();
  39. m_manageDB->GetCProduct()->GetAllPointMatrix(m_vecSubMatrixs);
  40. m_vecBondInfoData = m_manageDB->GetCProduct()->GetAllBondInfoData();
  41. if (m_vectBondMatrixs.size() == 0)
  42. {
  43. return;
  44. }
  45. initPage();
  46. connect(ui.pushButtonSave, &QPushButton::clicked, this, [=] {
  47. MatrixChangeEvent();
  48. CBondMatrix* pBondMatrix = CResources::GetInstance()->GetBondMatrix();
  49. pBondMatrix->LoadMatrix(BOND_DIR::OrderAndS);
  50. });
  51. connect(ui.pushButtonAddOutMatrix, &QPushButton::clicked, this, [=]() {
  52. PROGRAM_BOND_MATRIX_STRUCT newMatrix;
  53. //排序
  54. std::sort(m_vectBondMatrixs.begin(), m_vectBondMatrixs.end(),
  55. [](const PROGRAM_BOND_MATRIX_STRUCT& a, const PROGRAM_BOND_MATRIX_STRUCT& b) {
  56. return a.BondMatrixId < b.BondMatrixId;
  57. });
  58. int newBondMatrixID = 0;
  59. UINT maxID = 0;
  60. // 查找最大 MatrixId
  61. for (PROGRAM_BOND_MATRIX_STRUCT& bondMatrix : m_vectBondMatrixs)
  62. {
  63. if (bondMatrix.BondMatrixId > maxID)
  64. {
  65. maxID = bondMatrix.BondMatrixId;
  66. }
  67. }
  68. newBondMatrixID = ++maxID;
  69. while (std::any_of(m_vectBondMatrixs.begin(), m_vectBondMatrixs.end(),
  70. [newBondMatrixID](const PROGRAM_BOND_MATRIX_STRUCT& bondMatrix) {
  71. return bondMatrix.BondMatrixId == newBondMatrixID;
  72. }))
  73. {
  74. newBondMatrixID++; // 如果生成的 ID 已经存在,递增直到找到唯一的 ID
  75. }
  76. newMatrix.BondMatrixId = newBondMatrixID;
  77. newMatrix.BondMatrixRow = 0;
  78. newMatrix.BondMatrixCol = 0;
  79. newMatrix.strModuleName = "BondHead";
  80. newMatrix.iModuleId = MODULE_LIST::BondHead;
  81. int newVectorIndex = m_vectBondMatrixs.size();
  82. newMatrix.BondInfoId = 1;
  83. //std::vector<PROGRAM_POINT_MATRIX_STRUCT> newVecSubMatrix;
  84. m_vectBondMatrixs.push_back(newMatrix);
  85. AddOutMatrixPage(newVectorIndex, newMatrix, m_vecSubMatrixs);
  86. });
  87. connect(ui.pushButtonSavePara, &QPushButton::clicked, this, [=] {
  88. MatrixChangeEvent();
  89. ParamChangeEvent();
  90. CBondMatrix* pBondMatrix = CResources::GetInstance()->GetBondMatrix();
  91. pBondMatrix->LoadMatrix(BOND_DIR::OrderAndS);
  92. });
  93. connect(ui.pushButtonSaveParaAs, &QPushButton::clicked, this, [=] {
  94. ParamSaveAsEvent();
  95. CBondMatrix* pBondMatrix = CResources::GetInstance()->GetBondMatrix();
  96. pBondMatrix->LoadMatrix(BOND_DIR::OrderAndS);
  97. });
  98. connect(ui.comboBoxCurrentPara, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboBoxIndexChanged(int)));
  99. //connect(ui.comboBoxCurrentPara, SIGNAL(showPopup()), this, SLOT(onComboBoxPopup()));
  100. //connect(ui.comboBoxCurrentPara, &QComboBox::showPopup, this, &BondMatrixProgramPage::onComboBoxPopup);
  101. ui.comboBoxCurrentPara->installEventFilter(this);
  102. //参数
  103. connect(ui.comboBoxDieSource, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [=](int index) {
  104. if (index == 0)
  105. {
  106. m_curBondInfo.eDieSource = DIE_SOURCE::BY_WAFFLE;
  107. }
  108. else if (index == 1)
  109. {
  110. m_curBondInfo.eDieSource = DIE_SOURCE::BY_WAFER;
  111. }
  112. //ParamChangeEvent();
  113. });
  114. connect(ui.checkBoxIsCalib, &QCheckBox::clicked, this, [=](bool isChecked) {
  115. });
  116. connect(ui.spinBoxPickTempID, &SpinBox::editDone, this, [=]() {
  117. m_curBondInfo.iPickPRStrategyId = ui.spinBoxPickTempID->value();
  118. //ParamChangeEvent();
  119. });
  120. connect(ui.spinBoxPickNozzleID, &SpinBox::editDone, this, [=]() {
  121. m_curBondInfo.iPickHeadId = ui.spinBoxPickNozzleID->value();
  122. //ParamChangeEvent();
  123. });
  124. connect(ui.spinBoxPreBondTemp, &SpinBox::editDone, this, [=]() {
  125. m_curBondInfo.iBondFrontPRStrategyId = ui.spinBoxPreBondTemp->value();
  126. //ParamChangeEvent();
  127. });
  128. connect(ui.spinBoxPostBondTemp, &SpinBox::editDone, this, [=]() {
  129. m_curBondInfo.iBondBackPRStrategyId = ui.spinBoxPostBondTemp->value();
  130. //ParamChangeEvent();
  131. });
  132. connect(ui.spinBoxBondTemp, &SpinBox::editDone, this, [=]() {
  133. m_curBondInfo.iBondPRStrategyId = ui.spinBoxBondTemp->value();
  134. //ParamChangeEvent();
  135. });
  136. connect(ui.spinBoxLookUpTemp, &SpinBox::editDone, this, [=]() {
  137. m_curBondInfo.iLookUpPRStrategyId = ui.spinBoxLookUpTemp->value();
  138. //ParamChangeEvent();
  139. });
  140. connect(ui.spinBoxCalibPickTemp, &SpinBox::editDone, this, [=]() {
  141. m_curBondInfo.iCalibPRStrategyId = ui.spinBoxCalibPickTemp->value();
  142. //ParamChangeEvent();
  143. });
  144. connect(ui.spinBoxBondNozzleID, &SpinBox::editDone, this, [=]() {
  145. m_curBondInfo.iBondHeadId = ui.spinBoxBondNozzleID->value();
  146. //ParamChangeEvent();
  147. });
  148. connect(ui.doubleSpinBoxBondOffsetX, &DoubleSpinBox::editDone, this, [=]() {
  149. m_curBondInfo.stOffset.x = ui.doubleSpinBoxBondOffsetX->value();
  150. //ParamChangeEvent();
  151. });
  152. connect(ui.doubleSpinBoxBondOffsetY, &DoubleSpinBox::editDone, this, [=]() {
  153. m_curBondInfo.stOffset.y = ui.doubleSpinBoxBondOffsetY->value();
  154. //ParamChangeEvent();
  155. });
  156. connect(ui.doubleSpinBoxBondOffsetAngle, &DoubleSpinBox::editDone, this, [=]() {
  157. m_curBondInfo.stOffset.a = ui.doubleSpinBoxBondOffsetAngle->value();
  158. //ParamChangeEvent();
  159. });
  160. connect(ui.comboBoxPickParamType, &QComboBox::currentTextChanged, this, [=]() {
  161. //UpdatePagePickParam();
  162. });
  163. connect(ui.checkBoxPickBlockCheck, &QCheckBox::clicked, this, [=](bool isChecked) {
  164. if (ui.comboBoxPickParamType->currentIndex() == 0)//华夫盒
  165. {
  166. m_curWaferPickParam.bCheckBlock = ui.checkBoxPickBlockCheck->isChecked();
  167. }
  168. else if (ui.comboBoxPickParamType->currentIndex() == 1)//晶圆台
  169. {
  170. m_curCalibPickParam.bCheckBlock = ui.checkBoxPickBlockCheck->isChecked();
  171. }
  172. //ParamChangeEvent();
  173. });
  174. connect(ui.checkBoxPickLoseCheck, &QCheckBox::clicked, this, [=](bool isChecked) {
  175. if (ui.comboBoxPickParamType->currentIndex() == 0)//华夫盒
  176. {
  177. m_curWaferPickParam.bCheckLose = ui.checkBoxPickLoseCheck->isChecked();
  178. }
  179. else if (ui.comboBoxPickParamType->currentIndex() == 1)//晶圆台
  180. {
  181. m_curCalibPickParam.bCheckLose = ui.checkBoxPickLoseCheck->isChecked();
  182. }
  183. //ParamChangeEvent();
  184. });
  185. connect(ui.checkBoxPickFindForceCheck, &QCheckBox::clicked, this, [=](bool isChecked) {
  186. if (ui.comboBoxPickParamType->currentIndex() == 0)//华夫盒
  187. {
  188. m_curWaferPickParam.bFindForce = ui.checkBoxPickFindForceCheck->isChecked();
  189. }
  190. else if (ui.comboBoxPickParamType->currentIndex() == 1)//晶圆台
  191. {
  192. m_curCalibPickParam.bFindForce = ui.checkBoxPickFindForceCheck->isChecked();
  193. }
  194. //ParamChangeEvent();
  195. });
  196. connect(ui.doubleSpinBoxPrePickZ, &DoubleSpinBox::editDone, this, [=]() {
  197. if (ui.comboBoxPickParamType->currentIndex() == 0)//华夫盒
  198. {
  199. m_curWaferPickParam.dPreLev = ui.doubleSpinBoxPrePickZ->value();
  200. }
  201. else if (ui.comboBoxPickParamType->currentIndex() == 1)//晶圆台
  202. {
  203. m_curCalibPickParam.dPreLev = ui.doubleSpinBoxPrePickZ->value();
  204. }
  205. //ParamChangeEvent();
  206. });
  207. connect(ui.doubleSpinBoxPickForce, &DoubleSpinBox::editDone, this, [=]() {
  208. if (ui.comboBoxPickParamType->currentIndex() == 0)//华夫盒
  209. {
  210. m_curWaferPickParam.dForce = ui.doubleSpinBoxPickForce->value();
  211. }
  212. else if (ui.comboBoxPickParamType->currentIndex() == 1)//晶圆台
  213. {
  214. m_curCalibPickParam.dForce = ui.doubleSpinBoxPickForce->value();
  215. }
  216. //ParamChangeEvent();
  217. });
  218. connect(ui.doubleSpinBoxPickPosZ, &DoubleSpinBox::editDone, this, [=]() {
  219. if (ui.comboBoxPickParamType->currentIndex() == 0)//华夫盒
  220. {
  221. m_curWaferPickParam.dWorkLev = ui.doubleSpinBoxPickPosZ->value();
  222. }
  223. else if (ui.comboBoxPickParamType->currentIndex() == 1)//晶圆台
  224. {
  225. m_curCalibPickParam.dWorkLev = ui.doubleSpinBoxPickPosZ->value();
  226. }
  227. //ParamChangeEvent();
  228. });
  229. connect(ui.spinBoxPickGrabDelay, &SpinBox::editDone, this, [=]() {
  230. if (ui.comboBoxPickParamType->currentIndex() == 0)//华夫盒
  231. {
  232. m_curWaferPickParam.iGrabDelay = ui.spinBoxPickGrabDelay->value();
  233. }
  234. else if (ui.comboBoxPickParamType->currentIndex() == 1)//晶圆台
  235. {
  236. m_curCalibPickParam.iGrabDelay = ui.spinBoxPickGrabDelay->value();
  237. }
  238. //ParamChangeEvent();
  239. });
  240. connect(ui.spinBox_PickDelay, &SpinBox::editDone, this, [=]() {
  241. if (ui.comboBoxPickParamType->currentIndex() == 0)//华夫盒
  242. {
  243. m_curWaferPickParam.iPickOrBondDelay = ui.spinBox_PickDelay->value();
  244. }
  245. else if (ui.comboBoxPickParamType->currentIndex() == 1)//晶圆台
  246. {
  247. m_curCalibPickParam.iPickOrBondDelay = ui.spinBox_PickDelay->value();
  248. }
  249. //ParamChangeEvent();
  250. });
  251. connect(ui.spinBoxPickBlockCheckDelay, &SpinBox::editDone, this, [=]() {
  252. if (ui.comboBoxPickParamType->currentIndex() == 0)//华夫盒
  253. {
  254. m_curWaferPickParam.iBlockOrLoseDelay = ui.spinBoxPickBlockCheckDelay->value();
  255. }
  256. else if (ui.comboBoxPickParamType->currentIndex() == 1)//晶圆台
  257. {
  258. m_curCalibPickParam.iBlockOrLoseDelay = ui.spinBoxPickBlockCheckDelay->value();
  259. }
  260. //ParamChangeEvent();
  261. });
  262. connect(ui.spinBoxPickVacDelay, &SpinBox::editDone, this, [=]() {
  263. if (ui.comboBoxPickParamType->currentIndex() == 0)//华夫盒
  264. {
  265. m_curWaferPickParam.iVacuumDelay = ui.spinBoxPickVacDelay->value();
  266. }
  267. else if (ui.comboBoxPickParamType->currentIndex() == 1)//晶圆台
  268. {
  269. m_curCalibPickParam.iVacuumDelay = ui.spinBoxPickVacDelay->value();
  270. }
  271. //ParamChangeEvent();
  272. });
  273. connect(ui.spinBoxPickBlowDelay, &SpinBox::editDone, this, [=]() {
  274. if (ui.comboBoxPickParamType->currentIndex() == 0)//华夫盒
  275. {
  276. m_curWaferPickParam.iBlowDelay = ui.spinBoxPickBlowDelay->value();
  277. }
  278. else if (ui.comboBoxPickParamType->currentIndex() == 1)//晶圆台
  279. {
  280. m_curCalibPickParam.iBlowDelay = ui.spinBoxPickBlowDelay->value();
  281. }
  282. //ParamChangeEvent();
  283. });
  284. connect(ui.comboBoxBondParamType, &QComboBox::currentTextChanged, this, [=]() {
  285. UpdatePageBondParam();
  286. });
  287. connect(ui.checkBoxBondBlockCheck, &QCheckBox::clicked, this, [=](bool isChecked) {
  288. if (ui.comboBoxBondParamType->currentIndex() == 0)//中转台放晶
  289. {
  290. m_curCalibPlaceParam.bCheckBlock = ui.checkBoxBondBlockCheck->isChecked();
  291. }
  292. else if (ui.comboBoxBondParamType->currentIndex() == 1)//固晶台固晶
  293. {
  294. m_curBondParam.bCheckBlock = ui.checkBoxBondBlockCheck->isChecked();
  295. }
  296. //ParamChangeEvent();
  297. });
  298. connect(ui.checkBoxBondLoseCheck, &QCheckBox::clicked, this, [=](bool isChecked) {
  299. if (ui.comboBoxBondParamType->currentIndex() == 0)//中转台放晶
  300. {
  301. m_curCalibPlaceParam.bCheckLose = ui.checkBoxBondLoseCheck->isChecked();
  302. }
  303. else if (ui.comboBoxBondParamType->currentIndex() == 1)//固晶台固晶
  304. {
  305. m_curBondParam.bCheckLose = ui.checkBoxBondLoseCheck->isChecked();
  306. }
  307. //ParamChangeEvent();
  308. });
  309. connect(ui.checkBoxBondFindForce, &QCheckBox::clicked, this, [=](bool isChecked) {
  310. if (ui.comboBoxBondParamType->currentIndex() == 0)//中转台放晶
  311. {
  312. m_curCalibPlaceParam.bFindForce = ui.checkBoxBondFindForce->isChecked();
  313. }
  314. else if (ui.comboBoxBondParamType->currentIndex() == 1)//固晶台固晶
  315. {
  316. m_curBondParam.bFindForce = ui.checkBoxBondFindForce->isChecked();
  317. }
  318. //ParamChangeEvent();
  319. });
  320. connect(ui.doubleSpinBoxPreBondPosZ, &DoubleSpinBox::editDone, this, [=]() {
  321. if (ui.comboBoxBondParamType->currentIndex() == 0)//中转台放晶
  322. {
  323. m_curCalibPlaceParam.dPreLev = ui.doubleSpinBoxPreBondPosZ->value();
  324. }
  325. else if (ui.comboBoxBondParamType->currentIndex() == 1)//固晶台固晶
  326. {
  327. m_curBondParam.dPreLev = ui.doubleSpinBoxPreBondPosZ->value();
  328. }
  329. //ParamChangeEvent();
  330. });
  331. connect(ui.doubleSpinBoxBondForce, &DoubleSpinBox::editDone, this, [=]() {
  332. if (ui.comboBoxBondParamType->currentIndex() == 0)//中转台放晶
  333. {
  334. m_curCalibPlaceParam.dForce = ui.doubleSpinBoxBondForce->value();
  335. }
  336. else if (ui.comboBoxBondParamType->currentIndex() == 1)//固晶台固晶
  337. {
  338. m_curBondParam.dForce = ui.doubleSpinBoxBondForce->value();
  339. }
  340. //ParamChangeEvent();
  341. });
  342. connect(ui.doubleSpinBoxBondPosZ, &DoubleSpinBox::editDone, this, [=]() {
  343. if (ui.comboBoxBondParamType->currentIndex() == 0)//中转台放晶
  344. {
  345. m_curCalibPlaceParam.dWorkLev = ui.doubleSpinBoxBondPosZ->value();
  346. }
  347. else if (ui.comboBoxBondParamType->currentIndex() == 1)//固晶台固晶
  348. {
  349. m_curBondParam.dWorkLev = ui.doubleSpinBoxBondPosZ->value();
  350. }
  351. //ParamChangeEvent();
  352. });
  353. connect(ui.spinBoxBondGrabDelay, &SpinBox::editDone, this, [=]() {
  354. if (ui.comboBoxBondParamType->currentIndex() == 0)//中转台放晶
  355. {
  356. m_curCalibPlaceParam.iGrabDelay = ui.spinBoxBondGrabDelay->value();
  357. }
  358. else if (ui.comboBoxBondParamType->currentIndex() == 1)//固晶台固晶
  359. {
  360. m_curBondParam.iGrabDelay = ui.spinBoxBondGrabDelay->value();
  361. }
  362. //ParamChangeEvent();
  363. });
  364. connect(ui.spinBoxBondBlockCheckDelay, &SpinBox::editDone, this, [=]() {
  365. if (ui.comboBoxBondParamType->currentIndex() == 0)//中转台放晶
  366. {
  367. m_curCalibPlaceParam.iBlockOrLoseDelay = ui.spinBoxBondBlockCheckDelay->value();
  368. }
  369. else if (ui.comboBoxBondParamType->currentIndex() == 1)//固晶台固晶
  370. {
  371. m_curBondParam.iBlockOrLoseDelay = ui.spinBoxBondBlockCheckDelay->value();
  372. }
  373. //ParamChangeEvent();
  374. });
  375. connect(ui.spinBoxBondDelay, &SpinBox::editDone, this, [=]() {
  376. if (ui.comboBoxBondParamType->currentIndex() == 0)//中转台放晶
  377. {
  378. m_curCalibPlaceParam.iPickOrBondDelay = ui.spinBoxBondDelay->value();
  379. }
  380. else if (ui.comboBoxBondParamType->currentIndex() == 1)//固晶台固晶
  381. {
  382. m_curBondParam.iPickOrBondDelay = ui.spinBoxBondDelay->value();
  383. }
  384. //ParamChangeEvent();
  385. });
  386. connect(ui.spinBoxBondVacDelay, &SpinBox::editDone, this, [=]() {
  387. if (ui.comboBoxBondParamType->currentIndex() == 0)//中转台放晶
  388. {
  389. m_curCalibPlaceParam.iVacuumDelay = ui.spinBoxBondVacDelay->value();
  390. }
  391. else if (ui.comboBoxBondParamType->currentIndex() == 1)//固晶台固晶
  392. {
  393. m_curBondParam.iVacuumDelay = ui.spinBoxBondVacDelay->value();
  394. }
  395. //ParamChangeEvent();
  396. });
  397. connect(ui.spinBoxBondBlowDelay, &SpinBox::editDone, this, [=]() {
  398. if (ui.comboBoxBondParamType->currentIndex() == 0)//中转台放晶
  399. {
  400. m_curCalibPlaceParam.iBlowDelay = ui.spinBoxBondBlowDelay->value();
  401. }
  402. else if (ui.comboBoxBondParamType->currentIndex() == 1)//固晶台固晶
  403. {
  404. m_curBondParam.iBlowDelay = ui.spinBoxBondBlowDelay->value();
  405. }
  406. //ParamChangeEvent();
  407. });
  408. }
  409. BondMatrixProgramPage::~BondMatrixProgramPage()
  410. {
  411. }
  412. XY_DOUBLE_STRUCT BondMatrixProgramPage::BondGetAxisPosition(std::string ModuleType, XY_DOUBLE_STRUCT& pos)
  413. {
  414. /*CAxis* _Axis;
  415. CAxis::AXIS_TYPE eAxisType = _Axis->GetAxisType();*/
  416. if (m_pProgramCViewInterface == nullptr)
  417. {
  418. XY_DOUBLE_STRUCT errorPt = pos; // 可以根据需要返回一个错误状态
  419. // 弹出消息框显示位置
  420. QString positionString = QString("Unable to retrieve axis position for module type: %1").arg(QString::fromStdString(ModuleType));
  421. QMessageBox::information(this, "Axis Position Error", positionString);
  422. return errorPt;
  423. }
  424. m_pProgramCViewInterface->GetViewMotion()->GetAxisPosition(ModuleType, "X", pos.x);
  425. m_pProgramCViewInterface->GetViewMotion()->GetAxisPosition(ModuleType, "Y", pos.y);
  426. return pos;
  427. }
  428. void BondMatrixProgramPage::AddOutMatrixPage(int vectorIndex, PROGRAM_BOND_MATRIX_STRUCT matrixData, std::vector<PROGRAM_POINT_MATRIX_STRUCT> vecSubMatrix)
  429. {
  430. int matrixNum = m_mapSubMatrixControls.size();
  431. int newMatrixID = ++matrixNum;
  432. QVector<QObject*> vecControls;
  433. QWidget* outWidget = new QWidget();
  434. QGridLayout* outMatrixGridLayout = new QGridLayout();
  435. outMatrixGridLayout->setSpacing(4);
  436. outMatrixGridLayout->setObjectName(QString::fromUtf8("Out GridLayout"));
  437. outMatrixGridLayout->setContentsMargins(0, 0, 0, 0); // 设置布局的边距为0
  438. QGridLayout* boxGridLayout = new QGridLayout();
  439. boxGridLayout->setSpacing(4);
  440. boxGridLayout->setObjectName(QString::fromUtf8("Box GridLayout"));
  441. boxGridLayout->setContentsMargins(0, 0, 0, 0); // 设置布局的边距为0
  442. QHBoxLayout* buttonLayout = new QHBoxLayout();
  443. QSpacerItem* item = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
  444. buttonLayout->addSpacerItem(item);
  445. QGroupBox* groupBox = new QGroupBox(outWidget);
  446. groupBox->setLayout(boxGridLayout);
  447. QGridLayout* matrixGridLayout = new QGridLayout();
  448. matrixGridLayout->setSpacing(4);
  449. matrixGridLayout->setObjectName(QString::fromUtf8("matrixGridLayout"));
  450. matrixGridLayout->setContentsMargins(0, 0, 0, 0); // 设置布局的边距为0
  451. //// Add line for separation
  452. //QFrame* line = new QFrame();
  453. //line->setFrameShape(QFrame::NoFrame); // Remove default frame
  454. //line->setFixedHeight(2); // Set fixed height for line
  455. //line->setStyleSheet("background-color: #C7CAEB;");
  456. //outMatrixGridLayout->addWidget(line, 0, 0, 1, 4);
  457. // Add matrix title
  458. QLabel* labelTitle = new QLabel(outWidget);
  459. labelTitle->setObjectName(QString::fromUtf8("labelTitle"));
  460. labelTitle->setText(tr("Bond Matrix ") + QString::number(vectorIndex+1));
  461. labelTitle->setStyleSheet("color: #6A78FF;height: 30px");
  462. matrixGridLayout->addWidget(labelTitle, 0, 0, 1, 1);
  463. vecControls.push_back(labelTitle);
  464. //// Add Delete Out Matrix button
  465. //QPushButton* buttonDeleteOutMatrix = new QPushButton("Delete Matrix", outWidget);
  466. //outMatrixGridLayout->addWidget(buttonDeleteOutMatrix, 8, 0, 1, 3);
  467. //connect(buttonDeleteOutMatrix, &QPushButton::clicked, this, [=]() {
  468. // m_vectBondMatrixs.erase(m_vectBondMatrixs.begin() + vectorIndex);
  469. // delete outWidget;
  470. // });
  471. // Add "Add Sub Matrix" button
  472. QPushButton* pushButtonAdd = new QPushButton(outWidget);
  473. pushButtonAdd->setObjectName(QString::fromUtf8("button Add"));
  474. pushButtonAdd->setText(tr("Add sub Matrix"));
  475. matrixGridLayout->addWidget(pushButtonAdd, 0, 2, 1, 2);
  476. pushButtonAdd->setProperty("type", "default");
  477. connect(pushButtonAdd, &QPushButton::clicked, this, [=]() {
  478. int newSubMatrixIndex = m_vecSubMatrixs.size();
  479. PROGRAM_POINT_MATRIX_STRUCT subMatrix;
  480. std::sort(m_vecSubMatrixs.begin(), m_vecSubMatrixs.end(),
  481. [](const PROGRAM_POINT_MATRIX_STRUCT& a, const PROGRAM_POINT_MATRIX_STRUCT& b) {
  482. return a.MatrixId < b.MatrixId;
  483. });
  484. int newSubMatrixID = 0;
  485. UINT maxID = 0;
  486. // 查找最大 MatrixId
  487. for (PROGRAM_POINT_MATRIX_STRUCT& subMatrix : m_vecSubMatrixs)
  488. {
  489. if (subMatrix.MatrixId > maxID)
  490. {
  491. maxID = subMatrix.MatrixId;
  492. }
  493. }
  494. newSubMatrixID = ++maxID;
  495. while (std::any_of(m_vecSubMatrixs.begin(), m_vecSubMatrixs.end(),
  496. [newSubMatrixID](const PROGRAM_POINT_MATRIX_STRUCT& subMatrix) {
  497. return subMatrix.MatrixId == newSubMatrixID;
  498. }))
  499. {
  500. newSubMatrixID++; // 如果生成的 ID 已经存在,递增直到找到唯一的 ID
  501. }
  502. subMatrix.MatrixId = newSubMatrixID;
  503. subMatrix.strModuleName = "BondHead";
  504. subMatrix.iModuleId = MODULE_LIST::BondHead;
  505. subMatrix.MatrixRow = 0;
  506. subMatrix.MatrixCol = 0;
  507. m_vecSubMatrixs.push_back(subMatrix);
  508. // Add the submatrix to the bond matrix's VecPointMatrixId
  509. //找大矩阵ID/Index
  510. auto currentIt = m_mapOutWidgetIndex.find(outWidget);
  511. int index = currentIt.value(); //迭代器 erase后currentIt被删除了
  512. m_vectBondMatrixs[index].VecPointMatrixId.push_back(newSubMatrixID);
  513. AddMatrixPage(index, newSubMatrixIndex, subMatrix, outMatrixGridLayout);
  514. });
  515. // Add Delete Out Matrix button
  516. QPushButton* pushButtonDelete = new QPushButton(outWidget);
  517. pushButtonDelete->setObjectName(QString::fromUtf8("button delete"));
  518. pushButtonDelete->setText(tr("Delete"));
  519. matrixGridLayout->addWidget(pushButtonDelete, 0, 1, 1, 1);
  520. connect(pushButtonDelete, &QPushButton::clicked, this, [=]() {
  521. //处理index
  522. auto currentIt = m_mapOutWidgetIndex.find(outWidget);
  523. int index = currentIt.value(); //迭代器 erase后currentIt被删除了
  524. m_mapOutWidgetIndex.erase(currentIt);
  525. for (auto it = m_mapOutWidgetIndex.begin(); it != m_mapOutWidgetIndex.end(); it++)
  526. {
  527. if (it.value() > index)
  528. {
  529. int newIndex = it.value() - 1;
  530. m_mapOutWidgetIndex.insert(it.key(), newIndex);
  531. }
  532. }
  533. //删除缓存数据
  534. m_vectBondMatrixs.erase(m_vectBondMatrixs.begin() + index);
  535. //m_mapBondMatrixToSubMatrices.remove(vectorIndex); // Remove mapping between BondMatrix and its SubMatrices
  536. delete outWidget;
  537. });
  538. // Add Row and Column controls
  539. QLabel* labelRow = new QLabel(outWidget);
  540. labelRow->setObjectName(QString::fromUtf8("labelRow"));
  541. labelRow->setText(tr("Row & Cow"));
  542. matrixGridLayout->addWidget(labelRow, 2, 0, 1, 1);
  543. vecControls.push_back(labelRow);
  544. SpinBox* spinBoxRow = new SpinBox(outWidget);
  545. spinBoxRow->setObjectName(QString::fromUtf8("spinBoxRow"));
  546. spinBoxRow->setFixedWidth(100); // Set fixed width to 100
  547. matrixGridLayout->addWidget(spinBoxRow, 2, 1, 1, 1);
  548. vecControls.push_back(spinBoxRow);
  549. /*QLabel* labelCol = new QLabel(outWidget);
  550. labelCol->setObjectName(QString::fromUtf8("labelCol"));
  551. labelCol->setText(tr("Column "));
  552. outMatrixGridLayout->addWidget(labelCol, 3, 0, 1, 1);
  553. vecControls.push_back(labelCol);*/
  554. SpinBox* spinBoxCol = new SpinBox(outWidget);
  555. spinBoxCol->setObjectName(QString::fromUtf8("spinBoxCol"));
  556. spinBoxCol->setFixedWidth(100); // Set fixed width to 100
  557. matrixGridLayout->addWidget(spinBoxCol, 2, 2, 1, 1);
  558. vecControls.push_back(spinBoxCol);
  559. // Add Left Top Position controls
  560. QLabel* labelLeftTop = new QLabel(outWidget);
  561. labelLeftTop->setObjectName(QString::fromUtf8("labelLeftTop"));
  562. labelLeftTop->setText(tr("Left Top Pos "));
  563. matrixGridLayout->addWidget(labelLeftTop, 4, 0, 1, 1);
  564. vecControls.push_back(labelLeftTop);
  565. DoubleSpinBox* doubleSpinBoxLeftTopX = new DoubleSpinBox(outWidget);
  566. doubleSpinBoxLeftTopX->setObjectName(QString::fromUtf8("doubleSpinBoxLeftTopX"));
  567. doubleSpinBoxLeftTopX->setFixedWidth(100); // Set fixed width to 100
  568. matrixGridLayout->addWidget(doubleSpinBoxLeftTopX, 4, 1, 1, 1);
  569. vecControls.push_back(doubleSpinBoxLeftTopX);
  570. DoubleSpinBox* doubleSpinBoxLeftTopY = new DoubleSpinBox(outWidget);
  571. doubleSpinBoxLeftTopY->setObjectName(QString::fromUtf8("doubleSpinBoxLeftTopY"));
  572. doubleSpinBoxLeftTopY->setFixedWidth(100); // Set fixed width to 100
  573. matrixGridLayout->addWidget(doubleSpinBoxLeftTopY, 4, 2, 1, 1);
  574. vecControls.push_back(doubleSpinBoxLeftTopY);
  575. // Add Get Pos button for Left Top
  576. QPushButton* buttonLeftTop = new QPushButton("Get Pos", this);
  577. buttonLeftTop->setFixedWidth(62); // Set the same width for the button
  578. matrixGridLayout->addWidget(buttonLeftTop, 4, 3, 1, 1); // Position the button next to LeftTopPos
  579. connect(buttonLeftTop, &QPushButton::clicked, this, [=]() {
  580. XY_DOUBLE_STRUCT position = BondGetAxisPosition("BondHead", m_vectBondMatrixs[vectorIndex].LeftTopPoint);
  581. doubleSpinBoxLeftTopX->setValue(position.x);
  582. doubleSpinBoxLeftTopY->setValue(position.y);
  583. });
  584. // Add Right Top Position controls
  585. QLabel* labelRightTopPos = new QLabel(outWidget);
  586. labelRightTopPos->setObjectName(QString::fromUtf8("labelRightTopPos"));
  587. labelRightTopPos->setText(tr("Right Top Pos "));
  588. matrixGridLayout->addWidget(labelRightTopPos, 5, 0, 1, 1);
  589. vecControls.push_back(labelRightTopPos);
  590. DoubleSpinBox* doubleSpinBoxRightTopX = new DoubleSpinBox(outWidget);
  591. doubleSpinBoxRightTopX->setObjectName(QString::fromUtf8("doubleSpinBoxRightTopX"));
  592. doubleSpinBoxRightTopX->setFixedWidth(100); // Set fixed width to 100
  593. matrixGridLayout->addWidget(doubleSpinBoxRightTopX, 5, 1, 1, 1);
  594. vecControls.push_back(doubleSpinBoxRightTopX);
  595. DoubleSpinBox* doubleSpinBoxRightTopY = new DoubleSpinBox(outWidget);
  596. doubleSpinBoxRightTopY->setObjectName(QString::fromUtf8("doubleSpinBoxRightTopY"));
  597. doubleSpinBoxRightTopY->setFixedWidth(100); // Set fixed width to 100
  598. matrixGridLayout->addWidget(doubleSpinBoxRightTopY, 5, 2, 1, 1);
  599. vecControls.push_back(doubleSpinBoxRightTopY);
  600. QPushButton* buttonRightTop = new QPushButton("Get Pos", this);
  601. buttonRightTop->setFixedWidth(62); // Set the same width for the button
  602. matrixGridLayout->addWidget(buttonRightTop, 5, 3, 1, 1); // Position the button next to RightTopPos
  603. connect(buttonRightTop, &QPushButton::clicked, this, [=]() {
  604. XY_DOUBLE_STRUCT position = BondGetAxisPosition("BondHead", m_vectBondMatrixs[vectorIndex].RightTopPoint);
  605. doubleSpinBoxRightTopX->setValue(position.x);
  606. doubleSpinBoxRightTopY->setValue(position.y);
  607. });
  608. // Add Right Bottom Position controls
  609. QLabel* labelRightButtomPos = new QLabel(outWidget);
  610. labelRightButtomPos->setObjectName(QString::fromUtf8("labelRightButtomPos"));
  611. labelRightButtomPos->setText(tr("Right Buttom pos"));
  612. matrixGridLayout->addWidget(labelRightButtomPos, 6, 0, 1, 1);
  613. vecControls.push_back(labelRightButtomPos);
  614. DoubleSpinBox* doubleSpinBoxRightButtomX = new DoubleSpinBox(outWidget);
  615. doubleSpinBoxRightButtomX->setObjectName(QString::fromUtf8("doubleSpinBoxRightButtomX"));
  616. doubleSpinBoxRightButtomX->setFixedWidth(100); // Set fixed width to 100
  617. matrixGridLayout->addWidget(doubleSpinBoxRightButtomX, 6, 1, 1, 1);
  618. vecControls.push_back(doubleSpinBoxRightButtomX);
  619. DoubleSpinBox* doubleSpinBoxRightButtomY = new DoubleSpinBox(outWidget);
  620. doubleSpinBoxRightButtomY->setObjectName(QString::fromUtf8("doubleSpinBoxRightButtomY"));
  621. doubleSpinBoxRightButtomY->setFixedWidth(100); // Set fixed width to 100
  622. matrixGridLayout->addWidget(doubleSpinBoxRightButtomY, 6, 2, 1, 1);
  623. vecControls.push_back(doubleSpinBoxRightTopX);
  624. QPushButton* buttonRightButtom = new QPushButton("Get Pos", this);
  625. buttonRightButtom->setFixedWidth(62); // Set the same width for the button
  626. matrixGridLayout->addWidget(buttonRightButtom, 6, 3, 1, 1); // Position the button next to RightBottomPos
  627. connect(buttonRightButtom, &QPushButton::clicked, this, [=]() {
  628. XY_DOUBLE_STRUCT position = BondGetAxisPosition("BondHead", m_vectBondMatrixs[vectorIndex].RightBottomPoint);
  629. doubleSpinBoxRightButtomX->setValue(position.x);
  630. doubleSpinBoxRightButtomY->setValue(position.y);
  631. });
  632. // Add No Bond Points line edit
  633. QLabel* labelNoBondPts = new QLabel(outWidget);
  634. labelNoBondPts->setObjectName(QString::fromUtf8("labelNoBondPts"));
  635. labelNoBondPts->setText(tr("No Bond Points"));
  636. matrixGridLayout->addWidget(labelNoBondPts, 7, 0, 1, 1);
  637. vecControls.push_back(labelNoBondPts);
  638. QLineEdit* lineEditNoBondPts = new QLineEdit(outWidget);
  639. lineEditNoBondPts->setObjectName(QString::fromUtf8("lineEditNoBondPts"));
  640. matrixGridLayout->addWidget(lineEditNoBondPts, 7, 1, 1, 3);
  641. vecControls.push_back(lineEditNoBondPts);
  642. lineEditNoBondPts->setReadOnly(true);
  643. lineEditNoBondPts->setCursor(Qt::PointingHandCursor);
  644. lineEditNoBondPts->setProperty("vectorIndex", vectorIndex); // 存储索引
  645. lineEditNoBondPts->setProperty("parentMatrixIndex", -1); // 设置父矩阵的索引
  646. lineEditNoBondPts->installEventFilter(this);
  647. /*QLineEdit* lineEditNoBondPts = new QLineEdit(outWidget);
  648. lineEditNoBondPts->setObjectName(QString::fromUtf8("lineEditNoBondPts"));
  649. matrixGridLayout->addWidget(lineEditNoBondPts, 7, 1, 1, 3);
  650. vecControls.push_back(lineEditNoBondPts);*/
  651. // Paragram line edit
  652. QLabel* labelParagram = new QLabel(outWidget);
  653. labelParagram->setObjectName(QString::fromUtf8("labelParagram"));
  654. labelParagram->setText(tr("ParagramSet"));
  655. matrixGridLayout->addWidget(labelParagram, 8, 0, 1, 1);
  656. vecControls.push_back(labelParagram);
  657. QComboBox* comboBoxParagramSet = new QComboBox(outWidget);
  658. comboBoxParagramSet->setObjectName(QString::fromUtf8("comboBoxNoBondPts"));
  659. m_mapParagramSetComboBox.insert(comboBoxParagramSet, vectorIndex);
  660. // 添加选项到下拉框并关联 iInfoId
  661. for (const auto& bondMatrix : m_vecBondInfoData) {
  662. // 将 iInfoId 作为显示项添加到下拉框
  663. QString itemText = QString::number(bondMatrix.iInfoId); // 显示编号 iInfoId
  664. // 添加项并使用 setData 存储 iInfoId 作为附加数据
  665. comboBoxParagramSet->addItem(itemText, bondMatrix.iInfoId);
  666. }
  667. comboBoxParagramSet->setCurrentIndex(m_vectBondMatrixs[vectorIndex].BondInfoId-1);
  668. // 将下拉框添加到布局中
  669. matrixGridLayout->addWidget(comboBoxParagramSet, 8, 1, 1, 1);
  670. // 将控件保存到 vecControls 中
  671. vecControls.push_back(comboBoxParagramSet);
  672. // 连接 QComboBox 的信号和槽
  673. connect(comboBoxParagramSet, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboBoxIndexChanged(int)));
  674. //connect(, SIGNAL(showPopup()), this, SLOT(onComboBoxPopup()));
  675. //connect(comboBoxParagramSet, &QComboBox::showPopup, this, &BondMatrixProgramPage::onComboBoxPopup);
  676. comboBoxParagramSet->installEventFilter(this);
  677. QPushButton* buttonParagram = new QPushButton("ShowParagram", this);
  678. //buttonParagram->setFixedWidth(62); // Set the same width for the button
  679. matrixGridLayout->addWidget(buttonParagram, 8, 2, 1, 2); // Position the button next to RightBottomPos
  680. connect(buttonParagram, &QPushButton::clicked, this, [=]() {
  681. UpdateShowBondInfoData(m_vectBondMatrixs[vectorIndex].BondInfoId);
  682. });
  683. QFrame* line = new QFrame(outWidget);
  684. line->setFrameShape(QFrame::NoFrame); // 移除默认框架
  685. line->setFixedHeight(2); // 设置固定高度
  686. line->setStyleSheet("background-color: #C7CAEB;");
  687. boxGridLayout->addLayout(matrixGridLayout, 2, 0);
  688. boxGridLayout->addWidget(line);
  689. //outMatrixGridLayout->addLayout(buttonLayout, 1, 0);
  690. outMatrixGridLayout->addWidget(groupBox);
  691. outWidget->setLayout(outMatrixGridLayout);
  692. ui.verticalLayout_3->addWidget(outWidget);
  693. ui.verticalLayout_3->setContentsMargins(0, 0, 0, 0); // Adjust margins if necessary
  694. ui.verticalLayout_3->setAlignment(Qt::AlignTop | Qt::AlignLeft); // Align the layout to the top-left
  695. m_mapOutWidgetIndex.insert(outWidget, vectorIndex);
  696. // Add Sub Matrices
  697. for (int j = 0; j < matrixData.VecPointMatrixId.size(); j++)
  698. {
  699. for (int i = 0; i < m_vecSubMatrixs.size(); i++)
  700. {
  701. if (matrixData.VecPointMatrixId[j] == m_vecSubMatrixs[i].MatrixId)
  702. {
  703. AddMatrixPage(j, i, m_vecSubMatrixs[i], outMatrixGridLayout);
  704. }
  705. }
  706. }
  707. QSpacerItem* vSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
  708. ui.verticalLayout_3->addItem(vSpacer);
  709. // Add all controls and finalize layout
  710. /*outWidget->setLayout(outMatrixGridLayout);
  711. ui.scrollArea_2->setLayout(outMatrixGridLayout);*/
  712. spinBoxRow->setValue(matrixData.BondMatrixRow);
  713. spinBoxCol->setValue(matrixData.BondMatrixCol);
  714. doubleSpinBoxLeftTopX->setValue(matrixData.LeftTopPoint.x);
  715. doubleSpinBoxLeftTopY->setValue(matrixData.LeftTopPoint.y);
  716. doubleSpinBoxRightTopX->setValue(matrixData.RightTopPoint.x);
  717. doubleSpinBoxRightTopY->setValue(matrixData.RightTopPoint.y);
  718. doubleSpinBoxRightButtomX->setValue(matrixData.RightBottomPoint.x);
  719. doubleSpinBoxRightButtomY->setValue(matrixData.RightBottomPoint.y);
  720. connect(spinBoxRow, &SpinBox::editDone, this, [=]() {
  721. m_vectBondMatrixs[vectorIndex].BondMatrixRow = spinBoxRow->value();
  722. });
  723. connect(spinBoxCol, &SpinBox::editDone, this, [=]() {
  724. m_vectBondMatrixs[vectorIndex].BondMatrixCol = spinBoxCol->value();
  725. });
  726. connect(doubleSpinBoxLeftTopX, &DoubleSpinBox::editDone, this, [=]() {
  727. m_vectBondMatrixs[vectorIndex].LeftTopPoint.x = doubleSpinBoxLeftTopX->value();
  728. });
  729. connect(doubleSpinBoxLeftTopY, &DoubleSpinBox::editDone, this, [=]() {
  730. m_vectBondMatrixs[vectorIndex].LeftTopPoint.y = doubleSpinBoxLeftTopY->value();
  731. });
  732. connect(doubleSpinBoxRightTopX, &DoubleSpinBox::editDone, this, [=]() {
  733. m_vectBondMatrixs[vectorIndex].RightTopPoint.x = doubleSpinBoxRightTopX->value();
  734. });
  735. connect(doubleSpinBoxRightTopY, &DoubleSpinBox::editDone, this, [=]() {
  736. m_vectBondMatrixs[vectorIndex].RightTopPoint.y = doubleSpinBoxRightTopY->value();
  737. });
  738. connect(doubleSpinBoxRightButtomX, &DoubleSpinBox::editDone, this, [=]() {
  739. m_vectBondMatrixs[vectorIndex].RightBottomPoint.x = doubleSpinBoxRightButtomX->value();
  740. });
  741. connect(doubleSpinBoxRightButtomY, &DoubleSpinBox::editDone, this, [=]() {
  742. m_vectBondMatrixs[vectorIndex].RightBottomPoint.y = doubleSpinBoxRightButtomY->value();
  743. });
  744. connect(lineEditNoBondPts, &QLineEdit::textChanged, this, [=]() {
  745. });
  746. }
  747. void BondMatrixProgramPage::onComboBoxPopup(QComboBox* comboBox) {
  748. // 获取当前的 QComboBox
  749. //QComboBox* comboBox = qobject_cast<QComboBox*>(sender());
  750. if (!comboBox) {
  751. return;
  752. }
  753. int currentIndex = comboBox->currentIndex(); // 获取当前选中的索引
  754. QVariant currentData = comboBox->currentData(); // 获取当前选中的附加数据(例如 iInfoId)
  755. // 清空下拉框中的所有项
  756. comboBox->clear();
  757. // 重新填充下拉框选项,并更新 QMap 中的绑定关系
  758. for (const auto& bondMatrix : m_vecBondInfoData) {
  759. // 显示编号 iInfoId
  760. QString itemText = QString::number(bondMatrix.iInfoId);
  761. // 将 iInfoId 添加到下拉框
  762. comboBox->addItem(itemText, bondMatrix.iInfoId);
  763. }
  764. // 恢复原来的选中项
  765. // 通过 index 恢复选中项
  766. if (currentIndex >= 0 && currentIndex < comboBox->count()) {
  767. comboBox->setCurrentIndex(currentIndex);
  768. }
  769. }
  770. //// 槽函数:每次下拉框弹出时刷新内容
  771. //void BondMatrixProgramPage::onComboBoxPopup() {
  772. // // 清空下拉框中的所有项
  773. // comboBoxParagramSet->clear();
  774. //
  775. // // 重新填充下拉框选项
  776. // for (const auto& bondMatrix : m_vecBondInfoData) {
  777. // // 显示编号 iInfoId
  778. // QString itemText = QString::number(bondMatrix.iInfoId);
  779. //
  780. // // 将 iInfoId 添加到下拉框
  781. // comboBoxParagramSet->addItem(itemText, bondMatrix.iInfoId);
  782. // }
  783. //}
  784. void BondMatrixProgramPage::onComboBoxIndexChanged(int index) {
  785. // 获取当前选中的 QComboBox
  786. QComboBox* comboBox = qobject_cast<QComboBox*>(sender());
  787. if (!comboBox) {
  788. return;
  789. }
  790. // 获取当前选中的 BondInfoId
  791. UINT selectedBondInfoId = comboBox->currentData().toUInt();
  792. // 获取当前 QComboBox 对应的 vectorIndex
  793. int vectorIndex = m_mapParagramSetComboBox.value(comboBox, -1); // 从 QMap 中获取 vectorIndex
  794. if (vectorIndex != -1) {
  795. // 更新 m_vectBondMatrixs[vectorIndex].BondInfoId
  796. m_vectBondMatrixs[vectorIndex].BondInfoId = selectedBondInfoId;
  797. //qDebug() << "Updated BondInfoId for vectorIndex: " << vectorIndex;
  798. }
  799. else {
  800. //qDebug() << "No vectorIndex found for the combo box!";
  801. }
  802. // 调用 UpdateShowBondInfoData 更新数据
  803. UpdateShowBondInfoData(selectedBondInfoId);
  804. }
  805. void BondMatrixProgramPage::AddMatrixPage(int vectorIndex, int subVectorIndex, PROGRAM_POINT_MATRIX_STRUCT subMatrix, QGridLayout* layout)
  806. {
  807. QVector<QObject*> vecControls;
  808. QWidget* subWidget = new QWidget();
  809. QGridLayout* subGridLayout = new QGridLayout(subWidget);
  810. subGridLayout->setSpacing(4);
  811. subGridLayout->setObjectName(QString::fromUtf8("subGridLayout"));
  812. //groupBox->setLayout(subGridLayout);
  813. subGridLayout->setContentsMargins(0, 0, 0, 0); // 设置布局的边距为0
  814. subGridLayout->setAlignment(Qt::AlignCenter);
  815. QLabel* labelTitle = new QLabel(subWidget);
  816. labelTitle->setObjectName(QString::fromUtf8("labelTitle"));
  817. labelTitle->setText(tr("Sub Matrix ") + QString::number(subVectorIndex));
  818. labelTitle->setStyleSheet("color: #808BFF;height: 30px");
  819. subGridLayout->addWidget(labelTitle, 0, 1, 1, 1);
  820. vecControls.push_back(labelTitle);
  821. QPushButton* pushButtonDelete = new QPushButton(subWidget);
  822. pushButtonDelete->setObjectName(QString::fromUtf8("button delete"));
  823. pushButtonDelete->setText(tr("Delete"));
  824. subGridLayout->addWidget(pushButtonDelete, 0, 3, 1, 1);
  825. connect(pushButtonDelete, &QPushButton::clicked, this, [=]() {
  826. //处理index
  827. auto currentIt = m_mapSubWidgetIndex.find(subWidget);
  828. int index = currentIt.value(); //迭代器 erase后currentIt被删除了
  829. m_mapSubWidgetIndex.erase(currentIt);
  830. for (auto it = m_mapSubWidgetIndex.begin(); it != m_mapSubWidgetIndex.end(); ++it)
  831. {
  832. if (it.value() > index)
  833. {
  834. //value() 返回的是副本不是引用
  835. int newIndex = it.value() - 1;
  836. m_mapSubWidgetIndex.insert(it.key(), newIndex);
  837. }
  838. }
  839. // 子矩阵ID
  840. int subMatrixId = m_vecSubMatrixs[index].MatrixId;
  841. //删除缓存
  842. m_vecSubMatrixs.erase(m_vecSubMatrixs.begin() + index);
  843. //删除大矩阵子ID数据(遍历删除)
  844. for (PROGRAM_BOND_MATRIX_STRUCT& matrix : m_vectBondMatrixs)
  845. {
  846. auto it = std::find(matrix.VecPointMatrixId.begin(), matrix.VecPointMatrixId.end(), subMatrixId);
  847. if (it != matrix.VecPointMatrixId.end())
  848. {
  849. matrix.VecPointMatrixId.erase(it);
  850. }
  851. }
  852. delete subWidget;
  853. });
  854. QLabel* labelRow = new QLabel(subWidget);
  855. labelRow->setObjectName(QString::fromUtf8("labelRow"));
  856. labelRow->setText(tr("Row & Cow"));
  857. subGridLayout->addWidget(labelRow, 2, 0, 1, 1);
  858. vecControls.push_back(labelRow);
  859. SpinBox* spinBoxRow = new SpinBox(subWidget);
  860. spinBoxRow->setObjectName(QString::fromUtf8("spinBoxRow"));
  861. subGridLayout->addWidget(spinBoxRow, 2, 1, 1, 1);
  862. vecControls.push_back(spinBoxRow);
  863. /*QLabel* labelCol = new QLabel(subWidget);
  864. labelCol->setObjectName(QString::fromUtf8("labelCol"));
  865. labelCol->setText(tr("Cow "));
  866. subGridLayout->addWidget(labelCol, 3, 0, 1, 1);
  867. vecControls.push_back(labelCol);*/
  868. SpinBox* spinBoxCol = new SpinBox(subWidget);
  869. spinBoxCol->setObjectName(QString::fromUtf8("spinBoxCol"));
  870. subGridLayout->addWidget(spinBoxCol, 2, 2, 1, 1);
  871. vecControls.push_back(spinBoxCol);
  872. QLabel* labelLeftTop = new QLabel(subWidget);
  873. labelLeftTop->setObjectName(QString::fromUtf8("labelLeftTop"));
  874. labelLeftTop->setText(tr("Left Top Pos "));
  875. subGridLayout->addWidget(labelLeftTop, 4, 0, 1, 1);
  876. vecControls.push_back(labelLeftTop);
  877. DoubleSpinBox* doubleSpinBoxLeftTopX = new DoubleSpinBox(subWidget);
  878. doubleSpinBoxLeftTopX->setObjectName(QString::fromUtf8("doubleSpinBoxLeftTopX"));
  879. doubleSpinBoxLeftTopX->setFixedWidth(100); // Set fixed width to 100
  880. doubleSpinBoxLeftTopX->setFixedWidth(100); // Set fixed width to 100
  881. subGridLayout->addWidget(doubleSpinBoxLeftTopX, 4, 1, 1, 1);
  882. vecControls.push_back(doubleSpinBoxLeftTopX);
  883. DoubleSpinBox* doubleSpinBoxLeftTopY = new DoubleSpinBox(subWidget);
  884. doubleSpinBoxLeftTopY->setObjectName(QString::fromUtf8("doubleSpinBoxLeftTopY"));
  885. doubleSpinBoxLeftTopY->setFixedWidth(100); // Set fixed width to 100
  886. doubleSpinBoxLeftTopY->setFixedWidth(100); // Set fixed width to 100
  887. subGridLayout->addWidget(doubleSpinBoxLeftTopY, 4, 2, 1, 1);
  888. vecControls.push_back(doubleSpinBoxLeftTopY);
  889. QLabel* labelRightTopPos = new QLabel(subWidget);
  890. labelRightTopPos->setObjectName(QString::fromUtf8("labelRightTopPos"));
  891. labelRightTopPos->setText(tr("Right Top Pos "));
  892. subGridLayout->addWidget(labelRightTopPos, 5, 0, 1, 1);
  893. vecControls.push_back(labelRightTopPos);
  894. DoubleSpinBox* doubleSpinBoxRightTopX = new DoubleSpinBox(subWidget);
  895. doubleSpinBoxRightTopX->setObjectName(QString::fromUtf8("doubleSpinBoxRightTopX"));
  896. doubleSpinBoxRightTopX->setFixedWidth(100); // Set fixed width to 100
  897. subGridLayout->addWidget(doubleSpinBoxRightTopX, 5, 1, 1, 1);
  898. vecControls.push_back(doubleSpinBoxRightTopX);
  899. DoubleSpinBox* doubleSpinBoxRightTopY = new DoubleSpinBox(subWidget);
  900. doubleSpinBoxRightTopY->setObjectName(QString::fromUtf8("doubleSpinBoxRightTopY"));
  901. doubleSpinBoxRightTopY->setFixedWidth(100); // Set fixed width to 100
  902. subGridLayout->addWidget(doubleSpinBoxRightTopY, 5, 2, 1, 1);
  903. vecControls.push_back(doubleSpinBoxRightTopY);
  904. QLabel* labelRightButtomPos = new QLabel(subWidget);
  905. labelRightButtomPos->setObjectName(QString::fromUtf8("labelRightButtomPos"));
  906. labelRightButtomPos->setText(tr("Right Buttom pos"));
  907. subGridLayout->addWidget(labelRightButtomPos, 6, 0, 1, 1);
  908. vecControls.push_back(labelRightButtomPos);
  909. DoubleSpinBox* doubleSpinBoxRightButtomX = new DoubleSpinBox(subWidget);
  910. doubleSpinBoxRightButtomX->setObjectName(QString::fromUtf8("doubleSpinBoxRightButtomX"));
  911. doubleSpinBoxRightButtomX->setFixedWidth(100); // Set fixed width to 100
  912. subGridLayout->addWidget(doubleSpinBoxRightButtomX, 6, 1, 1, 1);
  913. vecControls.push_back(doubleSpinBoxRightButtomX);
  914. DoubleSpinBox* doubleSpinBoxRightButtomY = new DoubleSpinBox(subWidget);
  915. doubleSpinBoxRightButtomY->setObjectName(QString::fromUtf8("doubleSpinBoxRightButtomY"));
  916. doubleSpinBoxRightButtomY->setFixedWidth(100); // Set fixed width to 100
  917. subGridLayout->addWidget(doubleSpinBoxRightButtomY, 6, 2, 1, 1);
  918. vecControls.push_back(doubleSpinBoxRightTopX);
  919. QLabel* labelNoBondPts = new QLabel(subWidget);
  920. labelNoBondPts->setObjectName(QString::fromUtf8("labelNoBondPts"));
  921. labelNoBondPts->setText(tr("No Bond Points"));
  922. subGridLayout->addWidget(labelNoBondPts, 7, 0, 1, 1);
  923. vecControls.push_back(labelNoBondPts);
  924. QLineEdit* lineEditNoBondPts = new QLineEdit(subWidget);
  925. lineEditNoBondPts->setObjectName(QString::fromUtf8("lineEditNoBondPts"));
  926. lineEditNoBondPts->setReadOnly(true);
  927. lineEditNoBondPts->setCursor(Qt::PointingHandCursor);
  928. lineEditNoBondPts->setProperty("vectorIndex", subVectorIndex); // 存储索引
  929. lineEditNoBondPts->setProperty("parentMatrixIndex", vectorIndex); // 设置父矩阵的索引
  930. lineEditNoBondPts->installEventFilter(this);
  931. subGridLayout->addWidget(lineEditNoBondPts, 7, 1, 1, 3);
  932. vecControls.push_back(lineEditNoBondPts);
  933. // Left Top Position X and Y
  934. QPushButton* buttonLeftTop = new QPushButton("Get Pos", subWidget);
  935. buttonLeftTop->setFixedWidth(62); // 设置固定宽度
  936. subGridLayout->addWidget(buttonLeftTop, 4, 3, 1, 1); // 添加按钮到4行3列
  937. connect(buttonLeftTop, &QPushButton::clicked, this, [=]() {
  938. XY_DOUBLE_STRUCT position = BondGetAxisPosition("BondHead", m_vecSubMatrixs[subVectorIndex].LeftTopPoint);
  939. doubleSpinBoxLeftTopX->setValue(position.x); // 更新 X 轴
  940. doubleSpinBoxLeftTopY->setValue(position.y); // 更新 Y 轴
  941. });
  942. // Right Top Position X and Y
  943. QPushButton* buttonRightTop = new QPushButton("Get Pos", subWidget);
  944. buttonRightTop->setFixedWidth(62); // 设置固定宽度
  945. subGridLayout->addWidget(buttonRightTop, 5, 3, 1, 1); // 添加按钮到5行3列
  946. connect(buttonRightTop, &QPushButton::clicked, this, [=]() {
  947. XY_DOUBLE_STRUCT position = BondGetAxisPosition("BondHead", m_vecSubMatrixs[subVectorIndex].RightTopPoint);
  948. doubleSpinBoxRightTopX->setValue(position.x); // 更新 X 轴
  949. doubleSpinBoxRightTopY->setValue(position.y); // 更新 Y 轴
  950. });
  951. // Right Bottom Position X and Y
  952. QPushButton* buttonRightButtom = new QPushButton("Get Pos", subWidget);
  953. buttonRightButtom->setFixedWidth(62); // 设置固定宽度
  954. subGridLayout->addWidget(buttonRightButtom, 6, 3, 1, 1); // 添加按钮到6行3列
  955. connect(buttonRightButtom, &QPushButton::clicked, this, [=]() {
  956. XY_DOUBLE_STRUCT position = BondGetAxisPosition("BondHead", m_vecSubMatrixs[subVectorIndex].RightBottomPoint);
  957. doubleSpinBoxRightButtomX->setValue(position.x); // 更新 X 轴
  958. doubleSpinBoxRightButtomY->setValue(position.y); // 更新 Y 轴
  959. });
  960. //layout->addLayout(subGridLayout, 11, 0);
  961. QFrame* line = new QFrame(subWidget);
  962. line->setFrameShape(QFrame::NoFrame); // 移除默认框架
  963. line->setFixedHeight(2); // 设置固定高度
  964. line->setStyleSheet("background-color: #C7CAEB;");
  965. subGridLayout->addWidget(line, 10, 0, 1, 4);
  966. layout->addWidget(subWidget);
  967. m_mapSubWidgetIndex.insert(subWidget, subVectorIndex);
  968. spinBoxRow->setValue(subMatrix.MatrixRow);
  969. spinBoxCol->setValue(subMatrix.MatrixCol);
  970. doubleSpinBoxLeftTopX->setValue(subMatrix.LeftTopPoint.x);
  971. doubleSpinBoxLeftTopY->setValue(subMatrix.LeftTopPoint.y);
  972. doubleSpinBoxRightTopX->setValue(subMatrix.RightTopPoint.x);
  973. doubleSpinBoxRightTopY->setValue(subMatrix.RightTopPoint.y);
  974. doubleSpinBoxRightButtomX->setValue(subMatrix.RightBottomPoint.x);
  975. doubleSpinBoxRightButtomY->setValue(subMatrix.RightBottomPoint.y);
  976. connect(spinBoxRow, &SpinBox::editDone, this, [=]() {
  977. auto it = m_mapSubWidgetIndex.find(subWidget);
  978. m_vecSubMatrixs[it.value()].MatrixRow = spinBoxRow->value();
  979. });
  980. connect(spinBoxCol, &SpinBox::editDone, this, [=]() {
  981. auto it = m_mapSubWidgetIndex.find(subWidget);
  982. m_vecSubMatrixs[it.value()].MatrixCol = spinBoxCol->value();
  983. });
  984. connect(doubleSpinBoxLeftTopX, &DoubleSpinBox::editDone, this, [=]() {
  985. auto it = m_mapSubWidgetIndex.find(subWidget);
  986. m_vecSubMatrixs[it.value()].LeftTopPoint.x = doubleSpinBoxLeftTopX->value();
  987. });
  988. connect(doubleSpinBoxLeftTopY, &DoubleSpinBox::editDone, this, [=]() {
  989. auto it = m_mapSubWidgetIndex.find(subWidget);
  990. m_vecSubMatrixs[it.value()].LeftTopPoint.y = doubleSpinBoxLeftTopY->value();
  991. });
  992. connect(doubleSpinBoxRightTopX, &DoubleSpinBox::editDone, this, [=]() {
  993. auto it = m_mapSubWidgetIndex.find(subWidget);
  994. m_vecSubMatrixs[it.value()].RightTopPoint.x = doubleSpinBoxRightTopX->value();
  995. });
  996. connect(doubleSpinBoxRightTopY, &DoubleSpinBox::editDone, this, [=]() {
  997. auto it = m_mapSubWidgetIndex.find(subWidget);
  998. m_vecSubMatrixs[it.value()].RightTopPoint.y = doubleSpinBoxRightTopY->value();
  999. });
  1000. connect(doubleSpinBoxRightButtomX, &DoubleSpinBox::editDone, this, [=]() {
  1001. auto it = m_mapSubWidgetIndex.find(subWidget);
  1002. m_vecSubMatrixs[it.value()].RightBottomPoint.x = doubleSpinBoxRightButtomX->value();
  1003. });
  1004. connect(doubleSpinBoxRightButtomY, &DoubleSpinBox::editDone, this, [=]() {
  1005. auto it = m_mapSubWidgetIndex.find(subWidget);
  1006. m_vecSubMatrixs[it.value()].RightBottomPoint.y = doubleSpinBoxRightButtomY->value();
  1007. });
  1008. connect(lineEditNoBondPts, &QLineEdit::textChanged, this, [=]() {
  1009. auto it = m_mapSubWidgetIndex.find(subWidget);
  1010. });
  1011. }
  1012. bool BondMatrixProgramPage::eventFilter(QObject* obj, QEvent* event) {
  1013. // 捕获鼠标点击事件(QEvent::MouseButtonPress)
  1014. if (event->type() == QEvent::MouseButtonPress) {
  1015. auto* comboBox = qobject_cast<QComboBox*>(obj);
  1016. if (comboBox) {
  1017. // 当 QComboBox 被点击时执行 onComboBoxPopup()
  1018. onComboBoxPopup(comboBox);
  1019. return false; // 拦截事件,防止进一步传播
  1020. }
  1021. // 处理 QLineEdit 的点击事件
  1022. auto* lineEdit = qobject_cast<QLineEdit*>(obj);
  1023. if (lineEdit) {
  1024. int index = lineEdit->property("vectorIndex").toInt(); // 当前矩阵索引
  1025. int parentIndex = lineEdit->property("parentMatrixIndex").toInt(); // 父矩阵索引
  1026. onNoBondPtsClicked(lineEdit, index, parentIndex); // 传递父矩阵索引
  1027. return true; // 拦截事件
  1028. }
  1029. }
  1030. return QWidget::eventFilter(obj, event);
  1031. }
  1032. void BondMatrixProgramPage::onNoBondPtsClicked(QLineEdit* lineEdit, int index, int parentIndex) {
  1033. if (parentIndex != -1)
  1034. {
  1035. // 处理子矩阵的操作
  1036. if (index < 0 || index >= m_vecSubMatrixs.size()) return;
  1037. const auto& subMatrix = m_vecSubMatrixs[index];
  1038. NoBondPtEditDialog dlg(subMatrix.MatrixRow, subMatrix.MatrixCol, subMatrix.VecNoBondPt, this);
  1039. if (dlg.exec() == QDialog::Accepted)
  1040. {
  1041. QVector<XY_LONG_STRUCT> selected = dlg.getSelectedPoints();
  1042. m_vecSubMatrixs[index].VecNoBondPt = std::vector<XY_LONG_STRUCT>(selected.begin(), selected.end());
  1043. QStringList ptList;
  1044. for (const auto& pt : selected)
  1045. ptList << QString("(%1,%2)").arg(pt.x).arg(pt.y);
  1046. lineEdit->setText(ptList.join(" "));
  1047. }
  1048. // 这里可以用 parentIndex 来关联父矩阵(即大矩阵)做相应的操作
  1049. }
  1050. else
  1051. {
  1052. // 处理大矩阵的操作
  1053. if (index < 0 || index >= m_vectBondMatrixs.size()) return;
  1054. const auto& bondMatrix = m_vectBondMatrixs[index];
  1055. NoBondPtEditDialog dlg(bondMatrix.BondMatrixRow, bondMatrix.BondMatrixCol, bondMatrix.VecNoBondPt, this);
  1056. if (dlg.exec() == QDialog::Accepted)
  1057. {
  1058. QVector<XY_LONG_STRUCT> selected = dlg.getSelectedPoints();
  1059. m_vectBondMatrixs[index].VecNoBondPt = std::vector<XY_LONG_STRUCT>(selected.begin(), selected.end());
  1060. QStringList ptList;
  1061. for (const auto& pt : selected)
  1062. ptList << QString("(%1,%2)").arg(pt.x).arg(pt.y);
  1063. lineEdit->setText(ptList.join(" "));
  1064. }
  1065. // 这里也可以用 parentIndex 来关联父矩阵(即大矩阵)做相应的操作
  1066. }
  1067. }
  1068. void BondMatrixProgramPage::AddMatrixParam()
  1069. {
  1070. }
  1071. void BondMatrixProgramPage::UpdatePageParam()
  1072. {
  1073. int dieSourceIndex = 0;
  1074. if (m_curBondInfo.eDieSource == DIE_SOURCE::BY_WAFER)
  1075. {
  1076. dieSourceIndex = 1;
  1077. }
  1078. else if (m_curBondInfo.eDieSource == DIE_SOURCE::BY_WAFFLE)
  1079. {
  1080. dieSourceIndex = 0;
  1081. }
  1082. ui.comboBoxDieSource->setCurrentIndex(dieSourceIndex);
  1083. ui.spinBoxPickTempID->setValue(m_curBondInfo.iPickPRStrategyId);
  1084. ui.spinBoxPickNozzleID->setValue(m_curBondInfo.iPickHeadId);
  1085. ui.spinBoxPreBondTemp->setValue(m_curBondInfo.iBondFrontPRStrategyId);
  1086. ui.spinBoxPostBondTemp->setValue(m_curBondInfo.iBondBackPRStrategyId);
  1087. ui.spinBoxBondTemp->setValue(m_curBondInfo.iBondPRStrategyId);
  1088. ui.spinBoxLookUpTemp->setValue(m_curBondInfo.iLookUpPRStrategyId);
  1089. ui.spinBoxCalibPickTemp->setValue(m_curBondInfo.iCalibPRStrategyId);
  1090. ui.doubleSpinBoxBondOffsetX->setValue(m_curBondInfo.stOffset.x);
  1091. ui.doubleSpinBoxBondOffsetY->setValue(m_curBondInfo.stOffset.y);
  1092. ui.doubleSpinBoxBondOffsetAngle->setValue(m_curBondInfo.stOffset.a);
  1093. UpdatePagePickParam();
  1094. UpdatePageBondParam();
  1095. }
  1096. int BondMatrixProgramPage::ParamSaveAsEvent()
  1097. {
  1098. int iWaferPickParamId,iCalibPlaceParamId,iCalibPickParamId,iBondParamId;
  1099. m_manageDB->GetCProduct()->AddBondParam(m_curWaferPickParam, iWaferPickParamId); //SetBondParam(m_curWaferPickParam.iId, m_curWaferPickParam);
  1100. m_manageDB->GetCProduct()->AddBondParam(m_curCalibPlaceParam, iCalibPlaceParamId);
  1101. m_manageDB->GetCProduct()->AddBondParam(m_curCalibPickParam, iCalibPickParamId);
  1102. m_manageDB->GetCProduct()->AddBondParam(m_curBondParam, iBondParamId);
  1103. int iInfoId;
  1104. m_manageDB->GetCProduct()->AddBondInfoData(m_curBondInfo, iInfoId);
  1105. ns_db::BOND_INFO_STRUCT newBondInfo;
  1106. m_manageDB->GetCProduct()->GetBondInfoData(iInfoId, newBondInfo);
  1107. m_vecBondInfoData.push_back(newBondInfo);// = m_manageDB->GetCProduct()->GetAllBondInfoData();
  1108. // 填充 QComboBox
  1109. ui.comboBoxCurrentPara->clear();
  1110. for (const auto& bondMatrix : m_vecBondInfoData) {
  1111. QString itemText = QString::number(bondMatrix.iInfoId);
  1112. ui.comboBoxCurrentPara->addItem(itemText, bondMatrix.iInfoId);
  1113. }
  1114. ui.comboBoxCurrentPara->setCurrentIndex(iInfoId-1);
  1115. return iInfoId;
  1116. }
  1117. void BondMatrixProgramPage::ParamChangeEvent()
  1118. {
  1119. m_manageDB->GetCProduct()->SetBondInfoData(m_curBondInfo.iInfoId, m_curBondInfo);
  1120. m_manageDB->GetCProduct()->SetBondParam(m_curWaferPickParam.iId, m_curWaferPickParam);
  1121. m_manageDB->GetCProduct()->SetBondParam(m_curCalibPlaceParam.iId, m_curCalibPlaceParam);
  1122. m_manageDB->GetCProduct()->SetBondParam(m_curCalibPickParam.iId, m_curCalibPickParam);
  1123. m_manageDB->GetCProduct()->SetBondParam(m_curBondParam.iId, m_curBondParam);
  1124. CProduct* _Product = m_manageDB->GetCProduct();
  1125. }
  1126. void BondMatrixProgramPage::MatrixChangeEvent()
  1127. {
  1128. m_manageDB->GetCProduct()->SetAllBondMatrix(m_vectBondMatrixs, true);
  1129. m_manageDB->GetCProduct()->SetAllPointMatrix(m_vecSubMatrixs, true);
  1130. /*for (PROGRAM_BOND_MATRIX_STRUCT& bondMatrix : m_vectBondMatrixs)
  1131. {
  1132. m_manageDB->GetCProduct()->SetBondMatrix(bondMatrix.BondMatrixId, bondMatrix);
  1133. }*/
  1134. /*for (PROGRAM_POINT_MATRIX_STRUCT& pointMatrix : m_vecSubMatrixs)
  1135. {
  1136. m_manageDB->GetCProduct()->SetPointMatrix(pointMatrix.MatrixId, pointMatrix);
  1137. }*/
  1138. CProduct* _Product = m_manageDB->GetCProduct();
  1139. }
  1140. void BondMatrixProgramPage::UpdatePagePickParam()
  1141. {
  1142. //"取晶头取晶"
  1143. if (ui.comboBoxPickParamType->currentIndex() == 0)
  1144. {
  1145. ui.checkBoxPickBlockCheck->setChecked(m_curWaferPickParam.bCheckBlock);
  1146. ui.checkBoxPickLoseCheck->setChecked(m_curWaferPickParam.bCheckLose);
  1147. ui.checkBoxPickFindForceCheck->setChecked(m_curWaferPickParam.bFindForce);
  1148. ui.doubleSpinBoxPrePickZ->setValue(m_curWaferPickParam.dPreLev);
  1149. ui.doubleSpinBoxPickForce->setValue(m_curWaferPickParam.dForce);
  1150. ui.doubleSpinBoxPickPosZ->setValue(m_curWaferPickParam.dWorkLev);
  1151. ui.spinBoxPickGrabDelay->setValue(m_curWaferPickParam.iGrabDelay);
  1152. ui.spinBox_PickDelay->setValue(m_curWaferPickParam.iPickOrBondDelay);
  1153. ui.spinBoxPickBlockCheckDelay->setValue(m_curWaferPickParam.iBlockOrLoseDelay);
  1154. ui.spinBoxPickVacDelay->setValue(m_curWaferPickParam.iVacuumDelay);
  1155. ui.spinBoxPickBlowDelay->setValue(m_curWaferPickParam.iBlowDelay);
  1156. }
  1157. //"中转台取晶"
  1158. else if (ui.comboBoxPickParamType->currentIndex() == 1)
  1159. {
  1160. ui.checkBoxPickBlockCheck->setChecked(m_curCalibPickParam.bCheckBlock);
  1161. ui.checkBoxPickLoseCheck->setChecked(m_curCalibPickParam.bCheckLose);
  1162. ui.checkBoxPickFindForceCheck->setChecked(m_curCalibPickParam.bFindForce);
  1163. ui.doubleSpinBoxPrePickZ->setValue(m_curCalibPickParam.dPreLev);
  1164. ui.doubleSpinBoxPickForce->setValue(m_curCalibPickParam.dForce);
  1165. ui.doubleSpinBoxPickPosZ->setValue(m_curCalibPickParam.dWorkLev);
  1166. ui.spinBoxPickGrabDelay->setValue(m_curCalibPickParam.iGrabDelay);
  1167. ui.spinBox_PickDelay->setValue(m_curCalibPickParam.iPickOrBondDelay);
  1168. ui.spinBoxPickBlockCheckDelay->setValue(m_curCalibPickParam.iBlockOrLoseDelay);
  1169. ui.spinBoxPickVacDelay->setValue(m_curCalibPickParam.iVacuumDelay);
  1170. ui.spinBoxPickBlowDelay->setValue(m_curCalibPickParam.iBlowDelay);
  1171. }
  1172. }
  1173. void BondMatrixProgramPage::UpdatePageBondParam()
  1174. {
  1175. //"中转台放晶"
  1176. if (ui.comboBoxBondParamType->currentIndex() == 0)
  1177. {
  1178. ui.checkBoxBondBlockCheck->setChecked(m_curCalibPlaceParam.bCheckBlock);
  1179. ui.checkBoxBondLoseCheck->setChecked(m_curCalibPlaceParam.bCheckLose);
  1180. ui.checkBoxBondFindForce->setChecked(m_curCalibPlaceParam.bFindForce);
  1181. ui.doubleSpinBoxPreBondPosZ->setValue(m_curCalibPlaceParam.dPreLev);
  1182. ui.doubleSpinBoxBondForce->setValue(m_curCalibPlaceParam.dForce);
  1183. ui.doubleSpinBoxBondPosZ->setValue(m_curCalibPlaceParam.dWorkLev);
  1184. ui.spinBoxBondGrabDelay->setValue(m_curCalibPlaceParam.iGrabDelay);
  1185. ui.spinBoxBondDelay->setValue(m_curCalibPlaceParam.iPickOrBondDelay);
  1186. ui.spinBoxBondBlockCheckDelay->setValue(m_curCalibPlaceParam.iBlockOrLoseDelay);
  1187. ui.spinBoxBondVacDelay->setValue(m_curCalibPlaceParam.iVacuumDelay);
  1188. ui.spinBoxBondBlowDelay->setValue(m_curCalibPlaceParam.iBlowDelay);
  1189. }
  1190. //"固晶台固晶"
  1191. else if (ui.comboBoxBondParamType->currentIndex() == 1)
  1192. {
  1193. ui.checkBoxBondBlockCheck->setChecked(m_curBondParam.bCheckBlock);
  1194. ui.checkBoxBondLoseCheck->setChecked(m_curBondParam.bCheckLose);
  1195. ui.checkBoxBondFindForce->setChecked(m_curBondParam.bFindForce);
  1196. ui.doubleSpinBoxPreBondPosZ->setValue(m_curBondParam.dPreLev);
  1197. ui.doubleSpinBoxBondForce->setValue(m_curBondParam.dForce);
  1198. ui.doubleSpinBoxBondPosZ->setValue(m_curBondParam.dWorkLev);
  1199. ui.spinBoxBondGrabDelay->setValue(m_curBondParam.iGrabDelay);
  1200. ui.spinBoxBondDelay->setValue(m_curBondParam.iPickOrBondDelay);
  1201. ui.spinBoxBondBlockCheckDelay->setValue(m_curBondParam.iBlockOrLoseDelay);
  1202. ui.spinBoxBondVacDelay->setValue(m_curBondParam.iVacuumDelay);
  1203. ui.spinBoxBondBlowDelay->setValue(m_curBondParam.iBlowDelay);
  1204. }
  1205. }
  1206. void BondMatrixProgramPage::initPage()
  1207. {
  1208. //for (int i = 0; i < m_vectBondMatrixs.size(); i++)
  1209. //{
  1210. // for (int j = 0; j < m_vectBondMatrixs[i].VecPointMatrixId.size(); j++)
  1211. // {
  1212. // PROGRAM_POINT_MATRIX_STRUCT subMatrix;
  1213. // m_manageDB->GetCProduct()->GetPointMatrix(m_vectBondMatrixs[i].VecPointMatrixId[j], subMatrix);
  1214. // m_vecSubMatrixs.push_back(subMatrix);
  1215. // //AddMatrixPage(i, j, subMatrix);
  1216. // }
  1217. // AddOutMatrixPage(i, m_vectBondMatrixs[i], m_vecSubMatrixs);
  1218. //}
  1219. for (int i = 0; i < m_vectBondMatrixs.size(); i++)
  1220. {
  1221. AddOutMatrixPage(i, m_vectBondMatrixs[i], m_vecSubMatrixs);
  1222. }
  1223. //for (int i = 0; i < m_vectBondMatrixs[0].VecPointMatrixId.size(); ++i)
  1224. //{
  1225. // PROGRAM_POINT_MATRIX_STRUCT subMatrix;
  1226. // m_manageDB->GetCProduct()->GetPointMatrix(m_vectBondMatrixs[0].VecPointMatrixId[i], subMatrix);
  1227. // m_vecSubMatrixs.push_back(subMatrix);
  1228. //}
  1229. //m_manageDB->GetCProduct()->GetDieMatrix(m_vectBondMatrixs[0].VecPointMatrixId[0], m_vecSubMatrixs);
  1230. //显示矩阵数据
  1231. /*ui.spinBoxRow->setValue(m_vectBondMatrixs[0].BondMatrixRow);
  1232. ui.spinBoxCol->setValue(m_vectBondMatrixs[0].BondMatrixCol);
  1233. ui.doubleSpinBoxLeftTopX->setValue(m_vectBondMatrixs[0].LeftTopPoint.x);
  1234. ui.doubleSpinBoxLeftTopY->setValue(m_vectBondMatrixs[0].LeftTopPoint.y);
  1235. ui.doubleSpinBoxRightTopX->setValue(m_vectBondMatrixs[0].RightTopPoint.x);
  1236. ui.doubleSpinBoxRightTopY->setValue(m_vectBondMatrixs[0].RightTopPoint.y);
  1237. ui.doubleSpinBoxRightButtomX->setValue(m_vectBondMatrixs[0].RightBottomPoint.x);
  1238. ui.doubleSpinBoxRightButtomY->setValue(m_vectBondMatrixs[0].RightBottomPoint.y);
  1239. QString noBondPts = "";
  1240. bool firstTime = false;
  1241. for (XY_LONG_STRUCT& pt : m_vectBondMatrixs[0].VecNoBondPt)
  1242. {
  1243. if (firstTime)
  1244. {
  1245. noBondPts += "(" + QString::number(pt.x) + "," + QString::number(pt.y) + ")";
  1246. firstTime = true;
  1247. }
  1248. noBondPts += ";(" + QString::number(pt.x) + "," + QString::number(pt.y) + ")";
  1249. }
  1250. ui.lineEditNoBondPts->setText(noBondPts);*/
  1251. //显示子矩阵及数据
  1252. //for (PROGRAM_POINT_MATRIX_STRUCT& subMatrix : m_vecSubMatrixs)
  1253. //{
  1254. // AddMatrixPage(subMatrix);
  1255. //}
  1256. //从后端获取参数, 一套数据
  1257. CResources* pResources = CResources::GetInstance();
  1258. if (pResources == nullptr)
  1259. {
  1260. return;
  1261. }
  1262. CBondMatrix* pBondMatrix = pResources->GetBondMatrix();
  1263. if (pBondMatrix == nullptr)
  1264. {
  1265. return;
  1266. }
  1267. // 清空下拉框中的所有项
  1268. ui.comboBoxCurrentPara->clear();
  1269. // 重新填充下拉框选项,并更新 QMap 中的绑定关系
  1270. for (const auto& bondMatrix : m_vecBondInfoData) {
  1271. // 显示编号 iInfoId
  1272. QString itemText = QString::number(bondMatrix.iInfoId);
  1273. // 将 iInfoId 添加到下拉框
  1274. ui.comboBoxCurrentPara->addItem(itemText, bondMatrix.iInfoId);
  1275. }
  1276. UpdateShowBondInfoData(m_vectBondMatrixs[0].BondInfoId);
  1277. ////pBondMatrix->GetPintInfoByIndex(0, m_curPointInfo);
  1278. //m_manageDB->GetCProduct()->GetBondInfoData(m_vectBondMatrixs[0].BondInfoId, m_curBondInfo);
  1279. //m_manageDB->GetCProduct()->GetBondParam(m_curBondInfo.iPickParamId, m_curWaferPickParam);
  1280. //m_manageDB->GetCProduct()->GetBondParam(m_curBondInfo.iCalibBondParamId, m_curCalibPlaceParam);
  1281. //m_manageDB->GetCProduct()->GetBondParam(m_curBondInfo.iCalibPickParamId, m_curCalibPickParam);
  1282. //m_manageDB->GetCProduct()->GetBondParam(m_curBondInfo.iBondParamId, m_curBondParam);
  1283. ////显示界面参数
  1284. //UpdatePageParam();
  1285. }
  1286. void BondMatrixProgramPage::UpdateShowBondInfoData(UINT iInfoId) {
  1287. //pBondMatrix->GetPintInfoByIndex(0, m_curPointInfo);
  1288. m_manageDB->GetCProduct()->GetBondInfoData(iInfoId, m_curBondInfo);
  1289. m_manageDB->GetCProduct()->GetBondParam(m_curBondInfo.iPickParamId, m_curWaferPickParam);
  1290. m_manageDB->GetCProduct()->GetBondParam(m_curBondInfo.iCalibBondParamId, m_curCalibPlaceParam);
  1291. m_manageDB->GetCProduct()->GetBondParam(m_curBondInfo.iCalibPickParamId, m_curCalibPickParam);
  1292. m_manageDB->GetCProduct()->GetBondParam(m_curBondInfo.iBondParamId, m_curBondParam);
  1293. ui.comboBoxCurrentPara->setCurrentIndex(iInfoId-1);
  1294. //显示界面参数
  1295. UpdatePageParam();
  1296. }