SingleCameraOperationWnd.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. #include "SingleCameraOperationWnd.h"
  2. #include "ui_SingleCameraOperationWnd.h"
  3. #include <QSettings>
  4. #include <QCloseEvent>
  5. #include <QVBoxLayout>
  6. #include <QDebug>
  7. #include <QTimer>
  8. #include "CameraMaterialGroupWnd/CameraImage/CameraImageHandler.h"
  9. SingleCameraOperationWnd::SingleCameraOperationWnd(QWidget* parent)
  10. : JOriginalMainWnd(parent)
  11. , ui(new Ui::SingleCameraOperationWnd), scaleFactor(1.0)
  12. {
  13. ui->setupUi(this);
  14. ui->viewwidgetgroup->resizeSingleUI(true);
  15. ui->lightJoystickSwitchPage->resizeSingleUI();
  16. isShow = true;
  17. connect(ui->viewwidgetgroup, &ControlOperationPage::send_ComboBox_singal, this, &SingleCameraOperationWnd::HandleComboxchange);
  18. initFrom();
  19. m_timerMaterial = new QTimer(this);
  20. connect(m_timerMaterial, &QTimer::timeout, this, &SingleCameraOperationWnd::UpdateMaterialByTimer);
  21. m_pCViewInterface = ns_module::CViewInterface::GetInstance();
  22. }
  23. SingleCameraOperationWnd::~SingleCameraOperationWnd()
  24. {
  25. UnCameraBind();
  26. delete ui;
  27. }
  28. void SingleCameraOperationWnd::initFrom()
  29. {
  30. // 设置右上部分
  31. QWidget* viewport = ui->scrollArea->viewport();
  32. QWidget* container = new QWidget(viewport);
  33. QVBoxLayout* layout = new QVBoxLayout(container);
  34. layout->setSpacing(16); // 设置Group之间的间隔距离
  35. layout->setMargin(0);
  36. int nSize = 0;
  37. if (m_pMainCameraBind != nullptr)
  38. {
  39. //QList<int> numbers = { 1, 2, 3, 4, 5, 6, 7, 8 };
  40. nSize = m_pMainCameraBind->m_vecCamera.size();
  41. if (nSize == 0) // 针对获取不到的情况
  42. {
  43. nSize = 5;
  44. //JMessageTip::Message_warning("a");
  45. }
  46. QList<int> numbers;
  47. for (int i = 1; i <= nSize; i++)
  48. {
  49. numbers.push_back(i);
  50. }
  51. for (int i = 0; i < numbers.size(); ++i)
  52. {
  53. int num = numbers[i];
  54. CameraImageHandler* manager = nullptr;
  55. if (nSize == 5) // 测试数据
  56. {
  57. CameraInfo test;
  58. test.iCameraId = i;
  59. test.name = ("camera" + QString::number(i)).toStdString();
  60. test.eType = MATERIAL_WAFFLE;
  61. manager = new CameraImageHandler(num, test);
  62. }
  63. else
  64. {
  65. m_pMainCameraBind->m_vecCamera[i].eType = MATERIAL_BOX;
  66. manager = new CameraImageHandler(num, m_pMainCameraBind->m_vecCamera[i]);
  67. }
  68. Group* widget = manager->getGroup();
  69. if (m_pMainCameraBind->m_vecCamera.size() > 0)
  70. {
  71. widget->SetCameaInfo(m_pMainCameraBind->m_vecCamera[i]);
  72. }
  73. if (widget != nullptr)
  74. {
  75. CameraConnectUpdateImageFun(i, widget);
  76. connect(widget, &Group::sendUpdateGroupState,
  77. this, &SingleCameraOperationWnd::checkSettings);
  78. connect(widget, &Group::send_ComboBox_singal,
  79. this, &SingleCameraOperationWnd::GetGroupComboxChanged);
  80. layout->addWidget(widget);
  81. m_allGroup.append(widget);
  82. groupMap[num] = widget;
  83. }
  84. if (manager->getWafer())
  85. {
  86. waferMap.insert(num, manager->getWafer());
  87. ui->viewwidgetgroup->setWafer(waferMap.value(i + 1));
  88. m_allGroup[i]->setWaferWidget(ui->viewwidgetgroup->getWafer()->getGlobalPixmap());
  89. }
  90. if (manager->getWaffle())
  91. {
  92. waffleMap.insert(num, manager->getWaffle());
  93. ui->viewwidgetgroup->setWaffle(waffleMap.value(i + 1));
  94. m_allGroup[i]->setWaffleWidget(ui->viewwidgetgroup->getWaffle()->getGlobalPixmap());
  95. }
  96. if (manager->getMaterialBox())
  97. {
  98. materialBoxMap.insert(num, manager->getMaterialBox());
  99. }
  100. if (manager->getBond())
  101. {
  102. bondMap.insert(num, manager->getBond());
  103. ui->viewwidgetgroup->setBond(bondMap.value(i + 1));
  104. m_allGroup[i]->setBondWidget(ui->viewwidgetgroup->getBond()->getGlobalPixmap());
  105. }
  106. if (!manager->getFileList().isEmpty())
  107. {
  108. m_mapFileListMap.insert(num, manager->getFileList());
  109. }
  110. delete manager;
  111. }
  112. //清理ui->viewwidgetgroup
  113. int width = ui->viewwidgetgroup->width();
  114. int height = ui->viewwidgetgroup->height();
  115. QPixmap pixmap(width, height);
  116. pixmap.fill(Qt::white); // 白色背景
  117. GetGroupImageShowSignals(pixmap);
  118. // 设置控件的最小高度和最大宽度
  119. int minHeight = 162;
  120. int maxWidth = 244;
  121. for (Group* w : m_allGroup) {
  122. w->setMinimumHeight(minHeight);
  123. w->setMaximumWidth(maxWidth);
  124. }
  125. container->setLayout(layout);
  126. ui->scrollArea->setWidget(container);
  127. ui->scrollArea->resize(261, 700);
  128. initWidget();
  129. }
  130. }
  131. void SingleCameraOperationWnd::closeEvent(QCloseEvent* event) {
  132. // 保存滑块状态
  133. // saveSliderStates();
  134. // 确保调用基类的 closeEvent 处理其他关闭逻辑
  135. QMainWindow::closeEvent(event);
  136. }
  137. void SingleCameraOperationWnd::checkSettings(int groupId, int index) {
  138. if (groupId != lastGroupId || index != lastIndex) {
  139. GetCurrentSelectSlots(groupId, index);
  140. lastGroupId = groupId;
  141. lastIndex = index;
  142. saveInfoOfLast();
  143. }
  144. }
  145. void SingleCameraOperationWnd::updateMaterialWidget(int materialWndType, int groupId)
  146. {
  147. switch (materialWndType)
  148. {
  149. case 1: ui->viewwidgetgroup->setWafer(waferMap.value(groupId)); break;
  150. case 2: ui->viewwidgetgroup->setWaffle(waffleMap.value(groupId)); break;
  151. case 3: ui->viewwidgetgroup->setMaterialBox(materialBoxMap.value(groupId)); break;
  152. case 4: ui->viewwidgetgroup->setBond(bondMap.value(groupId)); break;
  153. }
  154. }
  155. void SingleCameraOperationWnd::InitMainCameraBind(CameraBind* pCameraBind)
  156. {
  157. m_pMainCameraBind = pCameraBind;
  158. initFrom();
  159. }
  160. void SingleCameraOperationWnd::UnCameraBind()
  161. {
  162. for (size_t i = 0; i < m_allGroup.size(); i++)
  163. {
  164. CameraConnectUpdateImageFun(i, m_allGroup[i], true);
  165. }
  166. //判断退出前的窗口是否是绑定相机
  167. if (m_veCurrentSelectGroup.isBond == true) {
  168. //解绑
  169. disconnect(m_veCurrentSelectGroup.pSelectGroup, &Group::SetUpDataImageShowSig,
  170. this, &SingleCameraOperationWnd::GetGroupImageShowSignals);
  171. }
  172. }
  173. void SingleCameraOperationWnd::CameraConnectUpdateImageFun(int nIndex, Group* widget, bool isUnCameraBind /*= false*/)
  174. {
  175. auto BinCamerasImage = [&](void (SingleCameraOperationWnd::* pCamerasImage)(const QPixmap& imageData))
  176. {
  177. if (isUnCameraBind)
  178. {
  179. // disconnect(widget, &Group::SetCurrentSelectSig, this, &SingleCameraOperationWnd::checkSettings);
  180. disconnect(this, pCamerasImage, widget, &Group::UpDataImageShowSlots);
  181. }
  182. else
  183. {
  184. //共用函数
  185. //connect(widget, &Group::sendUpdateGroupState, this, &SingleCameraOperationWnd::checkSettings);
  186. connect(this, pCamerasImage, widget, &Group::UpDataImageShowSlots);
  187. }
  188. };
  189. if (nIndex == 0)
  190. {
  191. BinCamerasImage(&SingleCameraOperationWnd::UpDataImageShowSignals0);
  192. }
  193. else if (nIndex == 1)
  194. {
  195. BinCamerasImage(&SingleCameraOperationWnd::UpDataImageShowSignals1);
  196. }
  197. else if (nIndex == 2)
  198. {
  199. BinCamerasImage(&SingleCameraOperationWnd::UpDataImageShowSignals2);
  200. }
  201. else if (nIndex == 3)
  202. {
  203. BinCamerasImage(&SingleCameraOperationWnd::UpDataImageShowSignals3);
  204. }
  205. else if (nIndex == 4)
  206. {
  207. BinCamerasImage(&SingleCameraOperationWnd::UpDataImageShowSignals4);
  208. }
  209. }
  210. void SingleCameraOperationWnd::UpdateCameraDisplay0(int iCameraId, JVision::ImageInfo imageData)
  211. {
  212. QImage image(imageData.data, imageData.width, imageData.height, QImage::Format_Indexed8);
  213. emit UpDataImageShowSignals0(QPixmap::fromImage(image));
  214. }
  215. void SingleCameraOperationWnd::UpdateCameraDisplay1(int iCameraId, JVision::ImageInfo imageData)
  216. {
  217. QImage image(imageData.data, imageData.width, imageData.height, QImage::Format_Indexed8);
  218. emit UpDataImageShowSignals1(QPixmap::fromImage(image));
  219. }
  220. void SingleCameraOperationWnd::UpdateCameraDisplay2(int iCameraId, JVision::ImageInfo imageData)
  221. {
  222. QImage image(imageData.data, imageData.width, imageData.height, QImage::Format_Indexed8);
  223. emit UpDataImageShowSignals2(QPixmap::fromImage(image));
  224. }
  225. void SingleCameraOperationWnd::UpdateCameraDisplay3(int iCameraId, JVision::ImageInfo imageData)
  226. {
  227. QImage image(imageData.data, imageData.width, imageData.height, QImage::Format_Indexed8);
  228. emit UpDataImageShowSignals3(QPixmap::fromImage(image));
  229. }
  230. void SingleCameraOperationWnd::UpdateCameraDisplay4(int iCameraId, JVision::ImageInfo imageData)
  231. {
  232. QImage image(imageData.data, imageData.width, imageData.height, QImage::Format_Indexed8);
  233. emit UpDataImageShowSignals4(QPixmap::fromImage(image));
  234. }
  235. void SingleCameraOperationWnd::wheelEvent(QWheelEvent* event)
  236. {
  237. //mousePos = ui->viewwidgetgroup->getOperatewidget()->mapFromGlobal(event->globalPos());
  238. //if (ui->viewwidgetgroup->getOperatewidget()->rect().contains(ui->viewwidgetgroup->getOperatewidget()->mapFromGlobal(event->globalPos()))) {
  239. // if (event->angleDelta().y() > 0) {
  240. // ui->viewwidgetgroup->updateScale(scaleFactor * 1.1); // 放大
  241. // } else {
  242. // ui->viewwidgetgroup->updateScale(scaleFactor * 0.9); // 缩小
  243. // }
  244. //}
  245. //if (ui->scrollArea->rect().contains(ui->scrollArea->mapFromGlobal(event->globalPos()))) {
  246. // // 获取 QScrollArea 的横向滚动条
  247. // QScrollBar *scrollBar = ui->scrollArea->horizontalScrollBar();
  248. // // 根据滚轮滚动方向改变滚动条的值
  249. // if (event->angleDelta().y() > 0) {
  250. // scrollBar->setValue(scrollBar->value() - 50);
  251. // } else {
  252. // scrollBar->setValue(scrollBar->value() + 50);
  253. // }
  254. //}
  255. QMainWindow::wheelEvent(event);
  256. }
  257. QString SingleCameraOperationWnd::getImagePathFromIndex(int index) {
  258. QStringList imagePaths = {
  259. ":/images/test_image/image.png",
  260. ":/images/test_image/image_2.png",
  261. };
  262. if (index >= 0 && index < imagePaths.size()) {
  263. return imagePaths[index];
  264. }
  265. return ":/images/test_image/image.png";
  266. }
  267. void SingleCameraOperationWnd::showEvent(QShowEvent* event) {
  268. QMainWindow::showEvent(event);
  269. }
  270. void SingleCameraOperationWnd::hideEvent(QHideEvent* event) {
  271. QMainWindow::hideEvent(event);
  272. }
  273. #if 0
  274. void SingleCameraOperationWnd::on_DatacomboBox_currentIndexChanged(int index) {
  275. QSettings settings("YourCompany", "YourApplication_");
  276. int groupId = settings.value("GroupId", 0).toInt();
  277. if (groupMap.contains(groupId)) {
  278. Group* group = groupMap[groupId];
  279. // 修改属性
  280. group->setDatacomboBox(index);
  281. }
  282. else {
  283. qDebug() << "Group with id" << groupId << "not found.";
  284. }
  285. }
  286. #endif
  287. void SingleCameraOperationWnd::updateImage(const QImage& image) {
  288. QPixmap pixmap = QPixmap::fromImage(image);
  289. QSize size = ui->viewwidgetgroup->getOperatewidget()->size();
  290. // QPixmap scaledPixmap = pixmap.scaled(size, Qt::KeepAspectRatio, Qt::SmoothTransformation);
  291. QPixmap scaledPixmap = pixmap.scaled(size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
  292. ui->viewwidgetgroup->getOperatewidget()->setPixmap(scaledPixmap);
  293. }
  294. void SingleCameraOperationWnd::GetGroupImageShowSignals(const QPixmap& imageData) {
  295. QSize size = ui->viewwidgetgroup->getOperatewidget()->size();
  296. QPixmap scaledPixmap = imageData.scaled(size, Qt::KeepAspectRatio, Qt::SmoothTransformation);
  297. ui->viewwidgetgroup->setScaleFactorSize(scaledPixmap);
  298. // m_lastRightPixmap = imageData;
  299. }
  300. void SingleCameraOperationWnd::BindImageOrMaterial(int index) {
  301. if (index == m_nImageIndex) {
  302. m_veCurrentSelectGroup.isBond = true;
  303. connect(m_veCurrentSelectGroup.pSelectGroup, &Group::SetUpDataImageShowSig,
  304. this, &SingleCameraOperationWnd::GetGroupImageShowSignals);
  305. UpdataLightJoystickSwitchPage(m_veCurrentSelectGroup.pSelectGroup->m_nGroupId, true);
  306. }
  307. else {
  308. QSettings settings("YourOrganization", "YourApplication");
  309. settings.beginGroup(QString::number(m_veCurrentSelectGroup.pSelectGroup->m_nGroupId));
  310. int materialWndType = settings.value("MaterialWndType").toInt();
  311. settings.endGroup();
  312. m_veCurrentSelectGroup.isBond = false;
  313. UpdataLightJoystickSwitchPage(m_veCurrentSelectGroup.pSelectGroup->m_nGroupId, false);
  314. updateMaterialWidget(materialWndType, m_veCurrentSelectGroup.pSelectGroup->m_nGroupId);
  315. }
  316. }
  317. void SingleCameraOperationWnd::initWidget() {
  318. //初始化当前页面的信息
  319. QSettings settings("YourOrganization", "YourApplication");
  320. lastIndex = settings.value("SingleLastIndex", 1).toInt();
  321. lastGroupId = settings.value("SingleLastGroupId", 1).toInt();
  322. //处理各种情况的初始化
  323. if (m_pMainCameraBind == nullptr || m_allGroup.size() == 0)
  324. {
  325. return;
  326. }
  327. //当lastGroupId大于m_allGroup.size()时,初始化lastGroupId为1
  328. if (m_allGroup.size() < lastGroupId) {
  329. lastGroupId = 1;
  330. lastIndex = 1;
  331. m_veCurrentSelectGroup.isInitialed = true;
  332. m_veCurrentSelectGroup.pSelectGroup = m_allGroup.at(lastGroupId - 1);
  333. m_veCurrentSelectGroup.pSelectGroup->initBorderStyle(lastIndex, 1);
  334. //初始化下拉框内容同步小窗口索引
  335. int currentComboBoxIndex = m_veCurrentSelectGroup.pSelectGroup->getCurrentComboBoxIndex();
  336. ui->viewwidgetgroup->setEnableControls(true);
  337. ui->viewwidgetgroup->setComboBox(m_mapFileListMap[m_veCurrentSelectGroup.pSelectGroup->m_nGroupId], currentComboBoxIndex);
  338. BindImageOrMaterial(m_nImageIndex);
  339. }
  340. else {
  341. }
  342. m_veCurrentSelectGroup.isInitialed = true;
  343. m_veCurrentSelectGroup.pSelectGroup = m_allGroup.at(lastGroupId - 1);
  344. m_veCurrentSelectGroup.pSelectGroup->initBorderStyle(lastIndex, 1);
  345. //初始化下拉框内容同步小窗口索引
  346. int currentComboBoxIndex = m_veCurrentSelectGroup.pSelectGroup->getCurrentComboBoxIndex();
  347. ui->viewwidgetgroup->setComboBox(m_mapFileListMap[m_veCurrentSelectGroup.pSelectGroup->m_nGroupId], currentComboBoxIndex);
  348. BindImageOrMaterial(m_nImageIndex);
  349. if (lastIndex == 1) {
  350. ui->viewwidgetgroup->setEnableControls(true);
  351. BindImageOrMaterial(m_nImageIndex);
  352. }
  353. else {
  354. ui->viewwidgetgroup->setEnableControls(false);
  355. BindImageOrMaterial(m_nMaterialIndex);
  356. }
  357. //m_timerMaterial->start(1000);
  358. }
  359. void SingleCameraOperationWnd::saveInfoOfLast() {
  360. QSettings settings("YourOrganization", "YourApplication");
  361. settings.setValue("SingleLastIndex", lastIndex);
  362. settings.setValue("SingleLastGroupId", lastGroupId);
  363. }
  364. void SingleCameraOperationWnd::GetCurrentSelectSlots(int groupId, int nIndex) {
  365. int nOnClickGroupId = groupId - 1;
  366. if (m_pMainCameraBind == nullptr || m_allGroup.size() < groupId)
  367. {
  368. return;
  369. }
  370. //判断更新前的窗口是否是绑定相机
  371. if (m_veCurrentSelectGroup.isBond == true) {
  372. //解绑
  373. disconnect(m_veCurrentSelectGroup.pSelectGroup, &Group::SetUpDataImageShowSig,
  374. this, &SingleCameraOperationWnd::GetGroupImageShowSignals);
  375. }
  376. m_veCurrentSelectGroup.pSelectGroup = m_allGroup.at(nOnClickGroupId);
  377. //判断index是相机还是物料
  378. //更新下拉框内容同步小窗口索引
  379. int currentComboBoxIndex = m_veCurrentSelectGroup.pSelectGroup->getCurrentComboBoxIndex();
  380. ui->viewwidgetgroup->setComboBox(m_mapFileListMap[m_veCurrentSelectGroup.pSelectGroup->m_nGroupId], currentComboBoxIndex);
  381. if (nIndex == 2) {
  382. BindImageOrMaterial(m_nMaterialIndex);
  383. ui->viewwidgetgroup->setEnableControls(false);
  384. }
  385. else if (nIndex == 1) {
  386. ui->viewwidgetgroup->setEnableControls(true);
  387. BindImageOrMaterial(m_nImageIndex);
  388. QPixmap pixmap = ui->viewwidgetgroup->getCurrentComboBoxPixmap(currentComboBoxIndex);
  389. GetGroupImageShowSignals(pixmap);
  390. }
  391. }
  392. void SingleCameraOperationWnd::UpdataLightJoystickSwitchPage(int groupId, bool isShow)
  393. {
  394. auto Fun = [&](Group* pGroup, LightJoystickSwitchPage* p, ControlOperationPage* pContPage, bool bShow)
  395. {
  396. p->UpdatemPageGroup(pGroup);
  397. p->InitMainCameraBind(m_pMainCameraBind, bShow);
  398. p->HideOrShowPage(bShow);
  399. if (bShow)
  400. {
  401. pContPage->UpDateCameraBind(m_pMainCameraBind);
  402. }
  403. else
  404. {
  405. pContPage->setSwitchJoystickButEnable(bShow);
  406. }
  407. };
  408. disconnect(ui->viewwidgetgroup, &ControlOperationPage::SendModuleTypeSignals,
  409. ui->lightJoystickSwitchPage, &LightJoystickSwitchPage::GetModuleTypeSlots);
  410. Group* currGroup = m_allGroup.at(groupId - 1);
  411. Fun(currGroup, ui->lightJoystickSwitchPage, ui->viewwidgetgroup, isShow);
  412. connect(ui->viewwidgetgroup, &ControlOperationPage::SendModuleTypeSignals,
  413. ui->lightJoystickSwitchPage, &LightJoystickSwitchPage::GetModuleTypeSlots);
  414. }
  415. void SingleCameraOperationWnd::GetGroupComboxChanged(int groupId, int comboxIndex) {
  416. m_allGroup.at(groupId - 1);
  417. if (comboxIndex == 0) {
  418. CameraConnectUpdateImageFun(groupId - 1, m_allGroup.at(groupId - 1), false);
  419. }
  420. else {
  421. CameraConnectUpdateImageFun(groupId - 1, m_allGroup.at(groupId - 1), true);
  422. }
  423. m_allGroup.at(groupId - 1)->setCurrentCombox(comboxIndex);
  424. if (groupId == m_veCurrentSelectGroup.pSelectGroup->m_nGroupId && lastIndex == 1) {
  425. if (comboxIndex != 0) {//图片
  426. QPixmap updatePixmap = ui->viewwidgetgroup->getCurrentComboBoxPixmap(comboxIndex);
  427. m_veCurrentSelectGroup.pSelectGroup->UpDataImageShowSlots(updatePixmap);
  428. }
  429. }
  430. }
  431. void SingleCameraOperationWnd::HandleComboxchange(int index) {
  432. if (index == 0) {
  433. CameraConnectUpdateImageFun(m_veCurrentSelectGroup.pSelectGroup->m_nGroupId - 1, m_allGroup.at(m_veCurrentSelectGroup.pSelectGroup->m_nGroupId - 1), false);
  434. }
  435. else {
  436. CameraConnectUpdateImageFun(m_veCurrentSelectGroup.pSelectGroup->m_nGroupId - 1, m_allGroup.at(m_veCurrentSelectGroup.pSelectGroup->m_nGroupId - 1), true);
  437. QPixmap updatePixmap = ui->viewwidgetgroup->getCurrentComboBoxPixmap(index);
  438. m_veCurrentSelectGroup.pSelectGroup->UpDataImageShowSlots(updatePixmap);
  439. }
  440. }
  441. void SingleCameraOperationWnd::UpdateMaterialByTimer() {
  442. //判断当前大窗口是否是物料窗口
  443. if (lastIndex == 2) {
  444. QSettings settings("YourOrganization", "YourApplication");
  445. settings.beginGroup(QString::number(m_veCurrentSelectGroup.pSelectGroup->m_nGroupId));
  446. int MaterialWndType = settings.value("MaterialWndType").toInt();
  447. settings.endGroup();
  448. switch (MaterialWndType) {
  449. case 1:
  450. {
  451. UpdateWafer(lastGroupId);
  452. ui->viewwidgetgroup->setWafer(waferMap.value(lastGroupId));
  453. m_allGroup[lastGroupId - 1]->setWaferWidget(ui->viewwidgetgroup->getWafer()->getGlobalPixmap());
  454. break;
  455. }
  456. case 2:
  457. {
  458. UpdateWaffle(lastGroupId);
  459. ui->viewwidgetgroup->setWaffle(waffleMap.value(lastGroupId));
  460. m_allGroup[lastGroupId - 1]->setWaffleWidget(ui->viewwidgetgroup->getWaffle()->getGlobalPixmap());
  461. break;
  462. }
  463. case 3:
  464. {
  465. UpdateMaterialBox(lastGroupId);
  466. ui->viewwidgetgroup->setMaterialBox(materialBoxMap.value(lastGroupId));
  467. m_allGroup[lastGroupId - 1]->MaterialBoxWidget();
  468. break;
  469. }
  470. case 4:
  471. {
  472. UpdateBond(lastGroupId);
  473. ui->viewwidgetgroup->setBond(bondMap.value(lastGroupId));
  474. m_allGroup[lastGroupId - 1]->setBondWidget(ui->viewwidgetgroup->getBond()->getGlobalPixmap());
  475. break;
  476. }
  477. }
  478. }
  479. }
  480. void SingleCameraOperationWnd::UpdateWafer(int groupId) {
  481. if (m_pCViewInterface != nullptr)
  482. {
  483. std::vector<ns_mat::WAFER_MATRIX_POINT_INFO_STRUCT> veWafer;
  484. m_pCViewInterface->GetViewMatrix()->GetWaferAllPointInfo(veWafer);
  485. waferMap.value(groupId)->UpdataVal(veWafer);
  486. waferMap.value(groupId)->setWaferInfo(m_pCViewInterface);
  487. }
  488. else
  489. {
  490. waferMap.value(groupId)->UpdataGenerateTestData();
  491. }
  492. }
  493. void SingleCameraOperationWnd::UpdateWaffle(int groupId) {
  494. if (m_pCViewInterface != nullptr)
  495. {
  496. std::vector<ns_mat::WAFFLE_MATRIX_POINT_STRUCT> veWaffle;
  497. m_pCViewInterface->GetViewMatrix()->GetWafflePackAllPointInfo(veWaffle);
  498. waffleMap.value(groupId)->UpdataVal(veWaffle);
  499. }
  500. else
  501. {
  502. waffleMap.value(groupId)->UpdataGenerateTestData();
  503. }
  504. }
  505. void SingleCameraOperationWnd::UpdateBond(int groupId) {
  506. if (m_pCViewInterface != nullptr)
  507. {
  508. std::vector<ns_mat::POINT_INFO_STRUCT> stPointInfo;
  509. m_pCViewInterface->GetViewMatrix()->GetBondAllPointInfo(stPointInfo);
  510. bondMap.value(groupId)->UpdataVal(stPointInfo);
  511. bondMap.value(groupId)->setBondInfo(m_pCViewInterface);
  512. }
  513. else
  514. {
  515. bondMap.value(groupId)->UpdataGenerateTestData();
  516. }
  517. }
  518. void SingleCameraOperationWnd::UpdateMaterialBox(int groupId) {
  519. if (m_pCViewInterface != nullptr)
  520. {
  521. std::vector<ns_module::MATERIAL_BOX_STRUCT> veMaterial;
  522. m_pCViewInterface->GetViewMatrix()->GetMaterialBoxAllPointInfo(veMaterial);
  523. materialBoxMap.value(groupId)->UpdataVal(veMaterial);
  524. materialBoxMap.value(groupId)->setMaterialBoxInfo(m_pCViewInterface);
  525. }
  526. else
  527. {
  528. materialBoxMap.value(groupId)->UpdataGenerateTestData();
  529. }
  530. }