MainAndSecondaryCamerasWnd.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719
  1. #include "MainAndSecondaryCamerasWnd.h"
  2. #include "ui_MainAndSecondaryCamerasWnd.h"
  3. #include <QSettings>
  4. #include <QCloseEvent>
  5. #include <QVBoxLayout>
  6. #include <QTimer>
  7. #include <QScrollBar>
  8. #include <QDoubleValidator>
  9. #include "CameraDistribute.h"
  10. #include "Src/common/JMessageTip.h"
  11. MainAndSecondaryCamerasWnd::MainAndSecondaryCamerasWnd(QWidget *parent)
  12. : JOriginalMainWnd(parent)
  13. , ui(new Ui::MainAndSecondaryCamerasWnd)
  14. {
  15. ui->setupUi(this);
  16. QSettings settings("YourOrganization", "YourApplication");
  17. settings.beginGroup("LastSettings");
  18. m_lastRightPixmap = settings.value("LastRightPixmap").value<QPixmap>();
  19. lasttextList = settings.value("LasttextList").toStringList();
  20. lastLastRightPixmap = settings.value("LastLastRightPixmap").value<QPixmap>();
  21. lastLasttextList = settings.value("LastLasttextList").toStringList();
  22. lastLastIndex = settings.value("LastLastIndex", 0).toInt();
  23. lastLastGroupId = settings.value("LastLastGroupId", 0).toInt();
  24. settings.endGroup();
  25. ui->control_r->HideOrShowPage(false);
  26. ui->control_L->HideOrShowPage(false);
  27. //initFrom();
  28. qApp->installEventFilter(this);
  29. }
  30. MainAndSecondaryCamerasWnd::~MainAndSecondaryCamerasWnd()
  31. {
  32. m_pMainCameraBind = nullptr;
  33. delete ui;
  34. }
  35. void MainAndSecondaryCamerasWnd::initFrom()
  36. {
  37. {
  38. // 界面刷新
  39. InitPage();
  40. //STR_TEMPLATE strFun = {};
  41. //strFun.pView = ui->scrollArea;
  42. //strFun.veSignalFun.emplace_back(std::bind(&MainAndSecondaryCamerasWnd::UpdateCameraDisplay0, this, std::placeholders::_1, std::placeholders::_2));
  43. //strFun.veSignalFun.emplace_back(std::bind(&MainAndSecondaryCamerasWnd::UpdateCameraDisplay1, this, std::placeholders::_1, std::placeholders::_2));
  44. ////strFun.veSlotFun.emplace_back([this]() { CheckIs(); });
  45. //strFun.veSlotFun.emplace_back(std::bind(&MainAndSecondaryCamerasWnd::CheckIs, this));
  46. //InitAllCamerPage(strFun, this);
  47. //CameraImageHandlera<MainAndSecondaryCamerasWnd, STR_TEMPLATE> A(this, strFun);
  48. //SwitchToConfigAAAAA<MainAndSecondaryCamerasWnd, STR_TEMPLATE>();
  49. }
  50. //ui->LeftOperatewidget->setMouseTracking(true);
  51. //ui->RightOperatewidget->setMouseTracking(true);
  52. QSettings settings2("YourOrganization", "YourApplication_lastWndType");
  53. int lastWndType = settings2.value("LastWndType").toInt();
  54. int LastGroup = settings2.value("LastGroup").toInt();
  55. lastIndex = lastWndType;
  56. lastGroupId = LastGroup;
  57. QTimer* timer = new QTimer(this);
  58. connect(timer, &QTimer::timeout, this, &MainAndSecondaryCamerasWnd::checkSettings);
  59. timer->start(100);
  60. InitModulesShow();
  61. }
  62. void MainAndSecondaryCamerasWnd::InitPage()
  63. {
  64. QWidget* viewport = ui->scrollArea->viewport();
  65. QWidget* container = new QWidget(viewport);
  66. QHBoxLayout* mainLayout = new QHBoxLayout(container);
  67. mainLayout->setSpacing(28);
  68. mainLayout->setMargin(0);
  69. int nSize = 0;
  70. if (m_pMainCameraBind != nullptr)
  71. {
  72. nSize = m_pMainCameraBind->m_vecCamera.size();
  73. if (nSize == 0) // 针对获取不到的情况
  74. {
  75. nSize = 5;
  76. //JMessageTip::Message_warning("a");
  77. }
  78. QList<int> numbers;
  79. for (int i = 1; i <= nSize; i++)
  80. {
  81. numbers.push_back(i);
  82. }
  83. for (int i = 0; i < numbers.size(); ++i)
  84. {
  85. int num = numbers[i];
  86. CameraImageHandler* manager = new CameraImageHandler(num);
  87. Group* widget = manager->getGroup();
  88. CameraConnectUpdateImageFun(i, widget);
  89. if (widget != nullptr)
  90. {
  91. mainLayout->addWidget(widget);
  92. m_currentSelectGroup.liGroup.append(widget);
  93. }
  94. if (manager->getWafer())
  95. {
  96. waferMap.insert(num, manager->getWafer());
  97. }
  98. if (manager->getWafer()) {
  99. waffleMap.insert(num, manager->getWaffle());
  100. }
  101. if (manager->getMaterialBox()) {
  102. materialBoxMap.insert(num, manager->getMaterialBox());
  103. }
  104. delete manager;
  105. }
  106. // 设置控件的最小高度和最大宽度
  107. int minHeight = 162;
  108. int maxWidth = 244;
  109. int num = -28;
  110. for (Group* w : m_currentSelectGroup.liGroup)
  111. {
  112. w->setMinimumHeight(minHeight);
  113. w->setMaximumWidth(maxWidth);
  114. num = num + 272;
  115. }
  116. container->setMinimumSize(num, 162);
  117. container->setLayout(mainLayout);
  118. ui->scrollArea->setWidget(container);
  119. ui->scrollArea->resize(1062, 177);
  120. // 只有一个相机的情况,直接绑定
  121. if (numbers.size() == 1)
  122. {
  123. Group* pGroup = m_currentSelectGroup.liGroup[0];
  124. connect(pGroup, &Group::SetUpDataImageShowSig,
  125. this, &MainAndSecondaryCamerasWnd::GetUpDataImageShowSignals0);
  126. ST_CURRENT_SELECT_GROUP _curr;
  127. _curr.isBond = true;
  128. _curr.pSelectGroup = pGroup;
  129. _curr.nCurrentCameraId = pGroup->m_nGroupId;
  130. _curr.nSelectLeft1 = 1;
  131. m_veCurrentSelectGroup.push_back(_curr);
  132. UpdataLightJoystickSwitchPage(pGroup);
  133. }
  134. }
  135. }
  136. void MainAndSecondaryCamerasWnd::CameraConnectUpdateImageFun(int nIndex, Group* widget)
  137. {
  138. auto BinCamerasImage = [&](void (MainAndSecondaryCamerasWnd::* pCamerasImage)(const QPixmap& imageData))
  139. {
  140. //共用函数
  141. //connect(widget, &Group::send_button_Signal, this, &MainAndSecondaryCamerasWnd::CheckIs);
  142. connect(widget, &Group::SetCurrentSelectSig, this, &MainAndSecondaryCamerasWnd::GetCurrentSelectSlots);
  143. // 相机图片
  144. connect(this, pCamerasImage, widget, &Group::UpDataImageShowSlots);
  145. };
  146. if (nIndex == 0)
  147. {
  148. BinCamerasImage(&MainAndSecondaryCamerasWnd::UpDataImageShowSignals0);
  149. }
  150. else if (nIndex == 1)
  151. {
  152. BinCamerasImage(&MainAndSecondaryCamerasWnd::UpDataImageShowSignals1);
  153. }
  154. else if (nIndex == 2)
  155. {
  156. BinCamerasImage(&MainAndSecondaryCamerasWnd::UpDataImageShowSignals2);
  157. }
  158. else if (nIndex == 3)
  159. {
  160. BinCamerasImage(&MainAndSecondaryCamerasWnd::UpDataImageShowSignals3);
  161. }
  162. else if (nIndex == 4)
  163. {
  164. BinCamerasImage(&MainAndSecondaryCamerasWnd::UpDataImageShowSignals4);
  165. }
  166. }
  167. void MainAndSecondaryCamerasWnd::InitModulesShow()
  168. {
  169. //if (m_pMainCameraBind != nullptr)
  170. //{
  171. // DeduplicationBox(ui->axisComboBox, m_pMainCameraBind->m_vecCAxis, 0);
  172. // DeduplicationBox(ui->axisTypeComboBox, m_pMainCameraBind->m_vecCAxis, 1);
  173. //}
  174. }
  175. template<class T>
  176. void MainAndSecondaryCamerasWnd::DeduplicationBox(QComboBox* pCom, const T& veTemp, int nIndex)
  177. {
  178. QStringList items;
  179. for (int i = 0; i < pCom->count(); ++i)
  180. {
  181. items << pCom->itemText(i);
  182. }
  183. for (auto& a : veTemp)
  184. {
  185. QString strName;
  186. if (nIndex == 0)
  187. {
  188. strName = a->GetModuleType().c_str();
  189. }
  190. else if (nIndex == 1)
  191. {
  192. strName = a->GetStringAxisType().c_str();
  193. }
  194. bool bMa = false; // 是否匹配
  195. for (auto b : items)
  196. {
  197. if (b == strName)
  198. {
  199. bMa = true;
  200. break;
  201. }
  202. }
  203. if (!bMa)
  204. {
  205. pCom->addItem(strName);
  206. }
  207. }
  208. }
  209. void MainAndSecondaryCamerasWnd::checkSettings() {
  210. QSettings settings("YourCompany", "YourApplication_");
  211. int groupId = settings.value("GroupId", 0).toInt();
  212. int index = settings.value("Index", 0).toInt();
  213. if (groupId != lastGroupId || index != lastIndex) {
  214. loadSettings();
  215. lastGroupId = groupId;
  216. lastIndex = index;
  217. }
  218. }
  219. void MainAndSecondaryCamerasWnd::loadSettings()
  220. {
  221. QSettings settings("YourCompany", "YourApplication_");
  222. int groupId = settings.value("GroupId", 0).toInt();
  223. int index = settings.value("Index", 0).toInt();
  224. //TODO: 这个地方目前暂停使用
  225. UpdataGroupSettings(groupId, index);
  226. }
  227. void MainAndSecondaryCamerasWnd::UpdataGroupSettings(int Id, int Index)
  228. {
  229. //int Id = m_currentSelectGroup.nGroupId;
  230. //int Index = m_currentSelectGroup.nSelectLeft1;
  231. // isUpdatingSettings = true;
  232. QSettings settings("YourOrganization", "YourApplication");
  233. settings.beginGroup(QString::number(Id));
  234. QString imagePath = settings.value("ImagePath1").toString();
  235. int materialWndType = settings.value("MaterialWndType").toInt();
  236. QStringList textList = settings.value("TextList").toStringList();
  237. settings.endGroup();
  238. QSettings Last_settings("YourOrganization", "YourApplication");
  239. settings.beginGroup(QString::number(lastGroupId));
  240. QString Last_imagePath1 = settings.value("ImagePath1").toString();
  241. int Last_materialWndType = settings.value("MaterialWndType").toInt();
  242. QStringList Last_textList = settings.value("TextList").toStringList();
  243. settings.endGroup();
  244. QString lastRightImage = settings.value("LastRightImage").toString();
  245. QPixmap newPixmap;
  246. QPixmap Last_newPixmap;
  247. if (Index == 1) {
  248. newPixmap = QPixmap(imagePath);
  249. QStringList test = { "1","2" };
  250. ui->viewwidgetgroup_R->updateOperateWidget(newPixmap, test);
  251. }
  252. if (lastIndex == 1) {
  253. Last_newPixmap = QPixmap(imagePath);
  254. QStringList test = { "1","2" };
  255. ui->viewwidgetgroup_L->updateOperateWidget(Last_newPixmap, test);
  256. }
  257. else if (lastIndex == 2) {
  258. updateMaterialWidget(last_left,Last_materialWndType, lastGroupId);
  259. }
  260. if (Index == 2) {
  261. updateMaterialWidget(current_right,materialWndType, Id);
  262. }
  263. QSettings settings2("YourOrganization", "YourApplication_lastWndType");
  264. settings2.setValue("LastWndType", lastIndex);
  265. settings2.setValue("LastGroup", lastGroupId);
  266. QPixmap scaledPixmap_right = newPixmap.scaled(ui->viewwidgetgroup_R->getOperatewidget()->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
  267. if (isUpdatingSettings) {
  268. lastLastRightPixmap = m_lastRightPixmap;
  269. lastLasttextList = lasttextList;
  270. m_lastRightPixmap = scaledPixmap_right;
  271. lasttextList = textList;
  272. lastLastIndex = lastIndex;
  273. lastLastGroupId = lastGroupId;
  274. }
  275. }
  276. void MainAndSecondaryCamerasWnd::updateMaterialWidget(int side,int materialWndType, int groupId) {
  277. if (side == last_left) {
  278. switch (materialWndType) {
  279. case 1: ui->viewwidgetgroup_L->setWafer(waferMap.value(lastGroupId)); break;
  280. case 2: ui->viewwidgetgroup_L->setWaffle(waffleMap.value(lastGroupId)); break;
  281. case 3: ui->viewwidgetgroup_L->setMaterialBox(materialBoxMap.value(lastGroupId)); break;
  282. }
  283. }
  284. else if (side == current_right) {
  285. switch (materialWndType) {
  286. case 1: ui->viewwidgetgroup_R->setWafer(waferMap.value(lastGroupId)); break;
  287. case 2: ui->viewwidgetgroup_R->setWaffle(waffleMap.value(lastGroupId)); break;
  288. case 3: ui->viewwidgetgroup_R->setMaterialBox(materialBoxMap.value(lastGroupId)); break;
  289. }
  290. }
  291. }
  292. void MainAndSecondaryCamerasWnd::InitMainCameraBind(CameraBind* pCameraBind)
  293. {
  294. m_pMainCameraBind = pCameraBind;
  295. initFrom();
  296. m_nTimeShowPos = startTimer(600);
  297. ResetIdleTimer(true);
  298. }
  299. void MainAndSecondaryCamerasWnd::UpdateCameraDisplay0(int iCameraId, JVision::ImageInfo imageData)
  300. {
  301. // TODO: 这里需要改动
  302. QImage image(imageData.data, imageData.width, imageData.height, QImage::Format_Indexed8);
  303. ui->viewwidgetgroup_L->getOperatewidget()->setGeometry(ui->viewwidgetgroup_L->getOperatewidget()->pos().x(),
  304. ui->viewwidgetgroup_L->getOperatewidget()->pos().y(),
  305. ui->viewwidgetgroup_L->getOperatewidget()->width(),
  306. ui->viewwidgetgroup_L->getOperatewidget()->height());
  307. //ui->LeftOperatewidget->setPixmap(QPixmap::fromImage(image));
  308. emit UpDataImageShowSignals0(QPixmap::fromImage(image));
  309. }
  310. void MainAndSecondaryCamerasWnd::UpdateCameraDisplay1(int iCameraId, JVision::ImageInfo imageData)
  311. {
  312. QImage image(imageData.data, imageData.width, imageData.height, QImage::Format_Indexed8);
  313. ui->viewwidgetgroup_R->getOperatewidget()->setGeometry(ui->viewwidgetgroup_R->getOperatewidget()->pos().x(),
  314. ui->viewwidgetgroup_R->getOperatewidget()->pos().y(),
  315. ui->viewwidgetgroup_R->getOperatewidget()->width(),
  316. ui->viewwidgetgroup_R->getOperatewidget()->height());
  317. //ui->RightOperatewidget->setPixmap(QPixmap::fromImage(image));
  318. emit UpDataImageShowSignals1(QPixmap::fromImage(image));
  319. }
  320. void MainAndSecondaryCamerasWnd::UpdateCameraDisplay2(int iCameraId, JVision::ImageInfo imageData)
  321. {
  322. }
  323. void MainAndSecondaryCamerasWnd::UpdateCameraDisplay3(int iCameraId, JVision::ImageInfo imageData)
  324. {
  325. }
  326. void MainAndSecondaryCamerasWnd::UpdateCameraDisplay4(int iCameraId, JVision::ImageInfo imageData)
  327. {
  328. QImage image(imageData.data, imageData.width, imageData.height, QImage::Format_Indexed8);
  329. ui->viewwidgetgroup_R->getOperatewidget()->setGeometry(ui->viewwidgetgroup_R->getOperatewidget()->pos().x(),
  330. ui->viewwidgetgroup_R->getOperatewidget()->pos().y(),
  331. ui->viewwidgetgroup_R->getOperatewidget()->width(),
  332. ui->viewwidgetgroup_R->getOperatewidget()->height());
  333. //ui->RightOperatewidget->setPixmap(QPixmap::fromImage(image));
  334. emit UpDataImageShowSignals4(QPixmap::fromImage(image));
  335. }
  336. void MainAndSecondaryCamerasWnd::HideLayout(QHBoxLayout* layout, bool isHide)
  337. {
  338. for (int i = 0; i < layout->count(); ++i)
  339. {
  340. QWidget* widget = layout->itemAt(i)->widget();
  341. if (widget)
  342. {
  343. if (isHide)
  344. {
  345. widget->hide();
  346. }
  347. else
  348. {
  349. widget->show();
  350. }
  351. }
  352. }
  353. }
  354. void MainAndSecondaryCamerasWnd::UpdataLightJoystickSwitchPage(Group* pGroup)
  355. {
  356. auto Fun = [&](LightJoystickSwitchPage* p, bool bShow)
  357. {
  358. p->UpdatemPageGroup(pGroup);
  359. p->InitMainCameraBind(m_pMainCameraBind, bShow);
  360. p->HideOrShowPage(bShow);
  361. };
  362. for (int i = 0; i < m_veCurrentSelectGroup.size(); i++)
  363. {
  364. if (i == 0)
  365. {
  366. bool bShow = false;
  367. if (m_veCurrentSelectGroup[0].nSelectLeft1 == 1)
  368. {
  369. bShow = true;
  370. }
  371. Fun(ui->control_L, bShow);
  372. }
  373. else if (i == 1)
  374. {
  375. bool bShow = false;
  376. if (m_veCurrentSelectGroup[1].nSelectLeft1 == 1)
  377. {
  378. bShow = true;
  379. }
  380. Fun(ui->control_L, bShow);
  381. }
  382. }
  383. }
  384. void MainAndSecondaryCamerasWnd::timerEvent(QTimerEvent* event)
  385. {
  386. int nID = event->timerId();
  387. }
  388. void MainAndSecondaryCamerasWnd::ResetIdleTimer(bool bStart /*= false*/)
  389. {
  390. if (bStart)
  391. {
  392. if (isActiveWindow())
  393. {
  394. m_idleTimer = startTimer(3000);
  395. }
  396. }
  397. else
  398. {
  399. killTimer(m_idleTimer);
  400. m_idleTimer = -1;
  401. }
  402. }
  403. void MainAndSecondaryCamerasWnd::GetCurrentSelectSlots(int groupId, int nIndex)
  404. {
  405. if (m_pMainCameraBind == nullptr)
  406. {
  407. return;
  408. }
  409. // 绑定操作,用来初始化
  410. ST_CURRENT_SELECT_GROUP _curr;
  411. _curr.isBond = true;
  412. m_currentSelectGroup.nGroupId = groupId;
  413. //2. 开始干活
  414. int nOnClickGroupId = groupId - 1; // 这里new 有些是0,有些是1 暂时选择
  415. if (m_pMainCameraBind->m_vecCamera.size() > nOnClickGroupId)
  416. {
  417. _curr.nCurrentCameraId = m_pMainCameraBind->m_vecCamera[nOnClickGroupId].iCameraId;
  418. }
  419. else
  420. {
  421. _curr.nCurrentCameraId = 0;
  422. }
  423. _curr.nSelectLeft1 = nIndex; // 是否选中窗口
  424. Group* pGroup = m_currentSelectGroup.liGroup[nOnClickGroupId];
  425. _curr.pSelectGroup = pGroup;
  426. // 1.判断当前是否存储
  427. if (m_veCurrentSelectGroup.size() >= 2)
  428. {
  429. if (pGroup == m_veCurrentSelectGroup[1].pSelectGroup &&
  430. m_veCurrentSelectGroup[1].nSelectLeft1== nIndex)
  431. {
  432. return;
  433. }
  434. // 解绑操作,删除第0个 ,, 主要目前为了实现 相机切换
  435. disconnect(m_veCurrentSelectGroup[0].pSelectGroup, &Group::SetUpDataImageShowSig,
  436. this, &MainAndSecondaryCamerasWnd::GetUpDataImageShowSignals0);
  437. disconnect(m_veCurrentSelectGroup[0].pSelectGroup, &Group::SetUpDataImageShowSig,
  438. this, &MainAndSecondaryCamerasWnd::GetUpDataImageShowSignals4);
  439. disconnect(m_veCurrentSelectGroup[1].pSelectGroup, &Group::SetUpDataImageShowSig,
  440. this, &MainAndSecondaryCamerasWnd::GetUpDataImageShowSignals0);
  441. disconnect(m_veCurrentSelectGroup[1].pSelectGroup, &Group::SetUpDataImageShowSig,
  442. this, &MainAndSecondaryCamerasWnd::GetUpDataImageShowSignals4);
  443. m_veCurrentSelectGroup.erase(m_veCurrentSelectGroup.begin() + 0);// 0个
  444. if (m_veCurrentSelectGroup[0].nSelectLeft1 == 1)
  445. {
  446. connect(m_veCurrentSelectGroup[0].pSelectGroup, &Group::SetUpDataImageShowSig,
  447. this, &MainAndSecondaryCamerasWnd::GetUpDataImageShowSignals0);
  448. // 在绑定
  449. connect(pGroup, &Group::SetUpDataImageShowSig,
  450. this, &MainAndSecondaryCamerasWnd::GetUpDataImageShowSignals4);
  451. }
  452. else
  453. {
  454. // 直接复制图片?
  455. if (_curr.nSelectLeft1 == 1)
  456. {
  457. connect(m_veCurrentSelectGroup[0].pSelectGroup, &Group::SetUpDataImageShowSig,
  458. this, &MainAndSecondaryCamerasWnd::GetUpDataImageShowSignals4);
  459. }
  460. else
  461. {
  462. //loadGroupSettings(groupId, nIndex);
  463. }
  464. }
  465. m_veCurrentSelectGroup.push_back(_curr);
  466. UpdataLightJoystickSwitchPage(pGroup);
  467. }
  468. else
  469. {
  470. if (m_veCurrentSelectGroup[0].pSelectGroup != _curr.pSelectGroup)
  471. {
  472. if (m_veCurrentSelectGroup.size() == 1)
  473. {
  474. connect(pGroup, &Group::SetUpDataImageShowSig,
  475. this, &MainAndSecondaryCamerasWnd::GetUpDataImageShowSignals4);
  476. }
  477. else
  478. {
  479. connect(pGroup, &Group::SetUpDataImageShowSig,
  480. this, &MainAndSecondaryCamerasWnd::GetUpDataImageShowSignals0);
  481. }
  482. m_veCurrentSelectGroup.push_back(_curr);
  483. UpdataLightJoystickSwitchPage(pGroup);
  484. }
  485. }
  486. }
  487. void MainAndSecondaryCamerasWnd::GetUpDataImageShowSignals0(const QPixmap& imageData)
  488. {
  489. //lastIndex = 1;
  490. QSize size_left = ui->viewwidgetgroup_L->getOperatewidget()->size();
  491. QPixmap scaledPixmap_left = m_lastRightPixmap.scaled(size_left, Qt::KeepAspectRatio, Qt::SmoothTransformation);
  492. ui->viewwidgetgroup_L->getOperatewidget()->setPixmap(scaledPixmap_left);
  493. m_lastRightPixmap = imageData;
  494. //UpdataGroupSettings(imageData);
  495. }
  496. void MainAndSecondaryCamerasWnd::GetUpDataImageShowSignals1(const QPixmap& imageData)
  497. {
  498. // lastIndex = 2;
  499. //UpdataGroupSettings(imageData);
  500. }
  501. void MainAndSecondaryCamerasWnd::GetUpDataImageShowSignals4(const QPixmap& imageData)
  502. {
  503. QSize size_left = ui->viewwidgetgroup_R->getOperatewidget()->size();
  504. QPixmap scaledPixmap_left = imageData.scaled(size_left, Qt::KeepAspectRatio, Qt::SmoothTransformation);
  505. ui->viewwidgetgroup_R->getOperatewidget()->setPixmap(scaledPixmap_left);
  506. //m_lastRightPixmap = imageData;
  507. }
  508. void MainAndSecondaryCamerasWnd::wheelEvent(QWheelEvent *event)
  509. {
  510. if (ui->viewwidgetgroup_L->getOperatewidget()->rect().contains(ui->viewwidgetgroup_L->getOperatewidget()->mapFromGlobal(event->globalPos()))) {
  511. mousePos = ui->viewwidgetgroup_L->getOperatewidget()->mapFromGlobal(event->globalPos());
  512. if (event->angleDelta().y() > 0) {
  513. ui->viewwidgetgroup_L->updateScale(Left_scaleFactor * 1.1); // 放大
  514. } else {
  515. ui->viewwidgetgroup_L->updateScale(Left_scaleFactor * 0.9); // 缩小
  516. }
  517. }
  518. if (ui->viewwidgetgroup_R->getOperatewidget()->rect().contains(ui->viewwidgetgroup_R->getOperatewidget()->mapFromGlobal(event->globalPos()))) {
  519. mousePos = ui->viewwidgetgroup_R->getOperatewidget()->mapFromGlobal(event->globalPos());
  520. if (event->angleDelta().y() > 0) {
  521. ui->viewwidgetgroup_R->updateScale(Right_scaleFactor * 1.1); // 放大
  522. } else {
  523. ui->viewwidgetgroup_R->updateScale(Right_scaleFactor * 0.9); // 缩小
  524. }
  525. }
  526. if (ui->scrollArea->rect().contains(ui->scrollArea->mapFromGlobal(event->globalPos()))) {
  527. // 获取 QScrollArea 的横向滚动条
  528. QScrollBar *scrollBar = ui->scrollArea->horizontalScrollBar();
  529. // 根据滚轮滚动方向改变滚动条的值
  530. if (event->angleDelta().y() > 0) {
  531. scrollBar->setValue(scrollBar->value() - 50);
  532. } else {
  533. scrollBar->setValue(scrollBar->value() + 50);
  534. }
  535. }
  536. QMainWindow::wheelEvent(event);
  537. }
  538. bool MainAndSecondaryCamerasWnd::eventFilter(QObject* obj, QEvent* event)
  539. {
  540. // 检测用户活动事件
  541. switch (event->type())
  542. {
  543. case QEvent::KeyPress:
  544. case QEvent::MouseMove:
  545. case QEvent::MouseButtonPress:
  546. case QEvent::MouseButtonDblClick:
  547. case QEvent::Wheel:
  548. ResetIdleTimer();
  549. ResetIdleTimer(true);
  550. break;
  551. default:
  552. break;
  553. }
  554. return QMainWindow::eventFilter(obj, event);
  555. }
  556. void MainAndSecondaryCamerasWnd::showEvent(QShowEvent *event) {
  557. isUpdatingSettings = false;
  558. QMainWindow::showEvent(event);
  559. //loadSettings();
  560. isUpdatingSettings = false;
  561. }
  562. void MainAndSecondaryCamerasWnd::hideEvent(QHideEvent *event) {
  563. isUpdatingSettings = false;
  564. QMainWindow::hideEvent(event);
  565. }
  566. void MainAndSecondaryCamerasWnd::CheckIs()
  567. {
  568. /*QSettings settings("YourCompany", "YourApplication_Button");
  569. int groupId = settings.value("GroupId_button", 0).toInt();
  570. if (groupId == lastGroupId) {
  571. if (lastIndex == 1 ) {
  572. if(isShow == true){
  573. isShow = false;
  574. } else {
  575. isShow = true;
  576. }
  577. }
  578. if (lastLastIndex == 1 && groupId == lastLastGroupId) {
  579. if(isShow_L == true){
  580. isShow_L = false;
  581. } else {
  582. isShow_L = true;
  583. }
  584. }
  585. showAndHide();
  586. showAndHide_L();
  587. } else if (groupId == lastLastGroupId) {
  588. if (lastLastIndex == 1) {
  589. if(isShow_L == true){
  590. isShow_L = false;
  591. } else {
  592. isShow_L = true;
  593. }
  594. }
  595. showAndHide_L();
  596. }*/
  597. }