LightJoystickSwitchPage.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751
  1. #include "LightJoystickSwitchPage.h"
  2. #include "ui_LightJoystickSwitchPage.h"
  3. #include "../common/JMessageTip.h"
  4. #include "../common/JQCommon.h"
  5. #include <QHash>
  6. #include <utility>
  7. LightJoystickSwitchPage::LightJoystickSwitchPage(QWidget *parent)
  8. : QWidget(parent)
  9. , ui(new Ui::LightJoystickSwitchPage)
  10. {
  11. ui->setupUi(this);
  12. InitForm();
  13. }
  14. LightJoystickSwitchPage::~LightJoystickSwitchPage()
  15. {
  16. killTimer(m_nUpdateUiAxis);
  17. delete ui;
  18. }
  19. void LightJoystickSwitchPage::InitForm()
  20. {
  21. m_nTimeShowPos = startTimer(900);
  22. m_nUpdateUiAxis = startTimer(900);
  23. InitLineEdits();
  24. SliderBind();
  25. // JQCommon::SetQLineEditLimit(ui->valLineEdit);
  26. }
  27. void LightJoystickSwitchPage::SliderBind()
  28. {
  29. connect(ui->RedLightverticalSlider, &QSlider::valueChanged, ui->RedLightprogressBar, &QProgressBar::setValue);
  30. connect(ui->BlueLightverticalSlider, &QSlider::valueChanged, ui->BlueLightprogressBar, &QProgressBar::setValue);
  31. connect(ui->GreenLightverticalSlider, &QSlider::valueChanged, ui->GreenLightprogressBar, &QProgressBar::setValue);
  32. connect(ui->DotLightverticalSlider, &QSlider::valueChanged, ui->DotLightprogressBar, &QProgressBar::setValue);
  33. BondSliderAndLineEdit(ui->RedLightverticalSlider, ui->RedLightlineEdit);
  34. BondSliderAndLineEdit(ui->GreenLightverticalSlider, ui->GreenLightlineEdit);
  35. BondSliderAndLineEdit(ui->BlueLightverticalSlider, ui->BlueLightlineEdit);
  36. BondSliderAndLineEdit(ui->DotLightverticalSlider, ui->DotLightlineEdit);
  37. }
  38. void LightJoystickSwitchPage::InitLineEdits()
  39. {
  40. ui->switchTabWidget->tabBar()->hide();
  41. QList<QLineEdit*> lineEdits = {
  42. ui->RedLightlineEdit, ui->GreenLightlineEdit,
  43. ui->BlueLightlineEdit, ui->DotLightlineEdit,
  44. };
  45. for (QLineEdit* lineEdit : lineEdits)
  46. {
  47. QRegExp regExp("^(0|([1-9]\\d?)|(1\\d{2})|(2[0-5]\\d))$");
  48. QRegExpValidator* validator = new QRegExpValidator(regExp, lineEdit);
  49. lineEdit->setValidator(validator);
  50. lineEdit->setAlignment(Qt::AlignCenter);
  51. }
  52. }
  53. void LightJoystickSwitchPage::UpDataAxisToUi()
  54. {
  55. if (m_pCameraBind)
  56. {
  57. const QHash<QString, QLayout*> axisToLayout = {
  58. {"FORCE", ui->forceLayout},
  59. {"X", ui->xLayout},
  60. {"Y", ui->yLayout},
  61. {"R", ui->rLayout},
  62. {"Z", ui->zLayout},
  63. {"Z1", ui->z1Layout}
  64. };
  65. for (const auto& val : m_listCurrentShowAxis)
  66. {
  67. if (axisToLayout.contains(val))
  68. {
  69. QLayout* layout = axisToLayout.value(val);
  70. if (layout)
  71. {
  72. for (int i = 0; i < layout->count(); ++i)
  73. {
  74. QWidget* widget = layout->itemAt(i)->widget();
  75. if (widget && widget->inherits("QLineEdit"))
  76. {
  77. JReLineEdit* lineEdit = qobject_cast<JReLineEdit*>(widget);
  78. if (lineEdit)
  79. {
  80. double pos = 0;
  81. m_pCameraBind->YGetAxisPosition(m_moveAxisInfo.ModuleType, val.toStdString(), pos);
  82. lineEdit->setText(QString::number(pos, 'f', 2));
  83. }
  84. }
  85. }
  86. }
  87. }
  88. }
  89. }
  90. }
  91. void LightJoystickSwitchPage::MoveModule(const QString strAxis, const QString pos)
  92. {
  93. if (m_pCameraBind)
  94. {
  95. const QHash<QString, QLayout*> m_HaAxisToLayout = {
  96. {"FORCE", ui->forceLayout},
  97. {"X", ui->xLayout},
  98. {"Y", ui->yLayout},
  99. {"R", ui->rLayout},
  100. {"Z", ui->zLayout},
  101. {"Z1", ui->z1Layout}
  102. };
  103. if (m_HaAxisToLayout.contains(strAxis))
  104. {
  105. QLayout* layout = m_HaAxisToLayout.value(strAxis);
  106. for (int i = 0; i < layout->count(); ++i)
  107. {
  108. QWidget* widget = layout->itemAt(i)->widget();
  109. if (widget && widget->inherits("QLineEdit"))
  110. {
  111. JReLineEdit* lineEdit = qobject_cast<JReLineEdit*>(widget);
  112. if (lineEdit)
  113. {
  114. if (lineEdit->m_isSetVal)
  115. {
  116. std::thread run([&, strAxis, pos]()
  117. {
  118. // 目前没有测试多轴,多轴在用
  119. std::vector<ns_module::MODULE_COORD_MOVE> vecPos;
  120. vecPos.push_back({ strAxis.toStdString() ,pos.toDouble() });
  121. m_pCameraBind->JModuleMove(ui->modeComboBox->currentText().toStdString(), vecPos, false);
  122. });
  123. run.detach();
  124. }
  125. }
  126. }
  127. }
  128. }
  129. //std::thread runFun([&, strAxis, pos]() {
  130. // auto LoopFun = [&](const QHash<QString, QLayout*> lay, bool isDisable)
  131. // {
  132. // for (auto it = lay.begin(); it != lay.end(); ++it)
  133. // {
  134. // const QString& key = it.key();
  135. // QLayout* layout = it.value();
  136. // DisableLayoutWidgets(layout, isDisable);
  137. // }
  138. // };
  139. // const QHash<QString, QLayout*> m_HaAxisToLayout = {
  140. // {"FORCE", ui->forceLayout},
  141. // {"X", ui->xLayout},
  142. // {"Y", ui->yLayout},
  143. // {"R", ui->rLayout},
  144. // {"Z", ui->zLayout},
  145. // {"Z1", ui->zLayout}
  146. // };
  147. // //LoopFun(m_HaAxisToLayout, false);
  148. // if (m_HaAxisToLayout.contains(strAxis))
  149. // {
  150. // QLayout* layout = m_HaAxisToLayout.value(strAxis);
  151. // for (int i = 0; i < layout->count(); ++i)
  152. // {
  153. // QWidget* widget = layout->itemAt(i)->widget();
  154. // if (widget && widget->inherits("QLineEdit"))
  155. // {
  156. // JReLineEdit* lineEdit = qobject_cast<JReLineEdit*>(widget);
  157. // if (lineEdit)
  158. // {
  159. // if (lineEdit->m_isSetVal)
  160. // {
  161. // m_pCameraBind->SetModuleMove(
  162. // ui->modeComboBox->currentText().toStdString(),
  163. // strAxis.toStdString(),
  164. // pos.toDouble(), false);
  165. // //// 目前没有测试多轴,多轴在用 ,没有多轴的情况
  166. // //std::vector<ns_module::MODULE_COORD_MOVE> vecPos;
  167. // //vecPos.push_back({ strAxis.toStdString() ,pos.toDouble() });
  168. // //m_pCameraBind->JModuleMove(ui->modeComboBox->currentText().toStdString(), vecPos, false);
  169. // }
  170. // }
  171. // }
  172. // }
  173. // }
  174. // //LoopFun(m_HaAxisToLayout, true);
  175. // });
  176. }
  177. }
  178. void LightJoystickSwitchPage::DisableLayoutWidgets(QLayout* layout, bool isShow /*= false*/)
  179. {
  180. for (int i = 0; i < layout->count(); ++i)
  181. {
  182. QLayoutItem* item = layout->itemAt(i);
  183. if (item->widget())
  184. {
  185. item->widget()->setEnabled(isShow);
  186. }
  187. else if (item->layout())
  188. {
  189. DisableLayoutWidgets(item->layout());
  190. }
  191. }
  192. }
  193. void LightJoystickSwitchPage::AdjustComboBoxWidth(QComboBox* comboBox)
  194. {
  195. if (!comboBox || comboBox->count() == 0) return;
  196. // 获取字体度量
  197. QFontMetrics metrics(comboBox->font());
  198. int max_width = 0;
  199. // 遍历所有项目
  200. for (int i = 0; i < comboBox->count(); ++i)
  201. {
  202. const QString text = comboBox->itemText(i);
  203. max_width = qMax(max_width, metrics.horizontalAdvance(text));
  204. }
  205. comboBox->setMinimumWidth(max_width);
  206. }
  207. template<class T>
  208. void LightJoystickSwitchPage::DeduplicationBox(QComboBox* pCom, const T& veTemp, int nIndex)
  209. {
  210. for (auto& a : veTemp)
  211. {
  212. QString strName;
  213. if (nIndex == 0)
  214. {
  215. strName = a->GetModuleType().c_str();
  216. }
  217. else if (nIndex == 1)
  218. {
  219. strName = a->GetStringAxisType().c_str();
  220. }
  221. QStringList items;
  222. for (int i = 0; i < pCom->count(); ++i)
  223. {
  224. items << pCom->itemText(i);
  225. }
  226. bool bMa = false; // 是否匹配
  227. for (auto b : items)
  228. {
  229. if (b == strName)
  230. {
  231. bMa = true;
  232. break;
  233. }
  234. }
  235. if (!bMa)
  236. {
  237. pCom->addItem(strName);
  238. }
  239. }
  240. AdjustComboBoxWidth(pCom);
  241. pCom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
  242. }
  243. void LightJoystickSwitchPage::BondSliderAndLineEdit(QSlider* slider, QLineEdit* lineEdit)
  244. {
  245. QIntValidator* validator = new QIntValidator(slider->minimum(), slider->maximum(), lineEdit);
  246. lineEdit->setValidator(validator);
  247. connect(slider, &QSlider::valueChanged, [lineEdit](int value) {
  248. lineEdit->setText(QString::number(value));
  249. });
  250. connect(lineEdit, &QLineEdit::textChanged, [&, slider, lineEdit](const QString& text)
  251. {
  252. bool ok;
  253. int value = text.toInt(&ok);
  254. if (ok && value >= slider->minimum() && value <= slider->maximum())
  255. {
  256. slider->setValue(value);
  257. }
  258. else if (!text.isEmpty())
  259. {
  260. int closestValue = qMin(qMax(text.toInt(&ok), slider->minimum()), slider->maximum());
  261. slider->setValue(closestValue);
  262. }
  263. if (m_pPageSwitchGroup)
  264. {
  265. // 执行匹配灯光
  266. int niD = m_pPageSwitchGroup->m_cameaInfo.iCameraId;
  267. //if (niD == 1)
  268. {
  269. // 相机窗口
  270. if (m_pCameraBind)
  271. {
  272. m_pCameraBind->JSetRedLight(niD, MatchSelectedLightIndex(lineEdit), value);
  273. }
  274. }
  275. }
  276. });
  277. }
  278. void LightJoystickSwitchPage::setLigthValue(int redLight,int greenLight,int blueLight,int dotLight)
  279. {
  280. setLightWidget(redLight, ui->RedLight, ui->RedLightlineEdit, ui->RedLightverticalSlider, ui->RedLightprogressBar, ui->RedLightlabel);
  281. setLightWidget(greenLight, ui->GreenLight, ui->GreenLightlineEdit, ui->GreenLightverticalSlider, ui->GreenLightprogressBar, ui->GreenLightlabel);
  282. setLightWidget(blueLight, ui->BlueLight, ui->BlueLightlineEdit, ui->BlueLightverticalSlider, ui->BlueLightprogressBar, ui->BlueLightlabel);
  283. setLightWidget(dotLight, ui->DotLight, ui->DotLightlineEdit, ui->DotLightverticalSlider, ui->DotLightprogressBar, ui->DotLightlabel);
  284. }
  285. void LightJoystickSwitchPage::setLightWidget(int value, QWidget *lightWidget, QLineEdit *lineEdit, QSlider *slider, QProgressBar *progressBar, QLabel *label)
  286. {
  287. if (0 <= value && value <= 100)
  288. {
  289. lightWidget->show();
  290. lineEdit->show();
  291. slider->show();
  292. progressBar->show();
  293. label->show();
  294. lineEdit->setText(QString::number(value));
  295. progressBar->setValue(value);
  296. slider->setValue(value);
  297. }
  298. else if (value == -1)
  299. {
  300. lightWidget->hide();
  301. lineEdit->hide();
  302. slider->hide();
  303. progressBar->hide();
  304. label->hide();
  305. }
  306. }
  307. void LightJoystickSwitchPage::on_move_Button_clicked()
  308. {
  309. RunMoveOrMoveTo(false);
  310. }
  311. void LightJoystickSwitchPage::on_moveTo_Button_clicked()
  312. {
  313. RunMoveOrMoveTo(true);
  314. }
  315. void LightJoystickSwitchPage::on_left_Button_clicked()
  316. {
  317. m_moveAxisInfo.AxisType = "X";
  318. MoveJoystick();
  319. }
  320. void LightJoystickSwitchPage::on_up_Button_clicked()
  321. {
  322. m_moveAxisInfo.AxisType = "Y";
  323. MoveJoystick();
  324. }
  325. void LightJoystickSwitchPage::on_right_Button_clicked()
  326. {
  327. m_moveAxisInfo.AxisType = "X";
  328. MoveJoystick();
  329. }
  330. void LightJoystickSwitchPage::on_down_Button_clicked()
  331. {
  332. m_moveAxisInfo.AxisType = "Y";
  333. MoveJoystick();
  334. }
  335. void LightJoystickSwitchPage::GetModuleTypeSlots(const ST_MOVE_AXIS& _module)
  336. {
  337. if (!_module.isNoNull)
  338. {
  339. int newIndex = (ui->switchTabWidget->currentIndex() + 1) % ui->switchTabWidget->count();
  340. ui->switchTabWidget->setCurrentIndex(newIndex);
  341. }
  342. /*m_isSlots = true;
  343. SetMoveJoystickInfo(_module);*/
  344. }
  345. void LightJoystickSwitchPage::InitMainCameraBind(CameraBind* pCameraBind, bool bUpdate /*= true*/)
  346. {
  347. m_pCameraBind = pCameraBind;
  348. if (bUpdate)
  349. {
  350. UpdataLightVal();
  351. }
  352. if (m_pCameraBind)
  353. {
  354. DeduplicationBox(ui->modeComboBox, m_pCameraBind->m_vecCAxis, 0);
  355. }
  356. }
  357. void LightJoystickSwitchPage::UpdatemPageGroup(Group* pGroup)
  358. {
  359. m_pPageSwitchGroup = pGroup;
  360. }
  361. void LightJoystickSwitchPage::SwitchJoystickPage(bool bSwitch)
  362. {
  363. ResetIdleTimer(bSwitch);
  364. //int newIndex = (ui->switchTabWidget->currentIndex() + 1) % ui->switchTabWidget->count();
  365. if (m_isSlots)
  366. {
  367. ui->switchTabWidget->setCurrentIndex(1);
  368. }
  369. else
  370. {
  371. ui->switchTabWidget->setCurrentIndex(0);
  372. }
  373. m_isSlots = false;
  374. }
  375. void LightJoystickSwitchPage::HideOrShowPage(bool isHide)
  376. {
  377. ui->switchTabWidget->setVisible(isHide);
  378. }
  379. void LightJoystickSwitchPage::SetMoveJoystickInfo(const ST_MOVE_AXIS& movInfo)
  380. {
  381. //m_moveAxisInfo.ModuleType = movInfo.ModuleType;
  382. //m_moveAxisInfo.AxisType = movInfo.AxisType;
  383. //m_moveAxisInfo.pos = movInfo.pos; // 这个距离可能会变动// 根据摇杆区分等级
  384. m_moveAxisInfo = movInfo;
  385. if (m_moveAxisInfo.isSwitch)
  386. {
  387. // 点击摇杆的时候开启定时器,然后3秒关闭
  388. SwitchJoystickPage(true);
  389. }
  390. }
  391. void LightJoystickSwitchPage::timerEvent(QTimerEvent* event)
  392. {
  393. int nID = event->timerId();
  394. if (m_nTimeShowPos == nID)
  395. {
  396. RealTimeUpdatesToU();
  397. }
  398. else if (m_idleTimer == nID)
  399. {
  400. SwitchJoystickPage(false);
  401. }
  402. else if (m_nUpdateUiAxis == nID)
  403. {
  404. UpDataAxisToUi();
  405. }
  406. }
  407. QString LightJoystickSwitchPage::CombiningStr(bool isUpdate /*= false*/)
  408. {
  409. double pos = m_moveAxisInfo.pos;
  410. QString strShow = tr("Currently selected mode:", "当前选中模式:");
  411. if (isUpdate)
  412. {
  413. strShow = tr("Move Pos:","移动点:");
  414. if (m_pCameraBind)
  415. {
  416. m_pCameraBind->YGetAxisPosition(m_moveAxisInfo.ModuleType, m_moveAxisInfo.AxisType, pos);
  417. }
  418. }
  419. strShow += m_moveAxisInfo.ModuleType.c_str();
  420. strShow += " ";
  421. strShow += m_moveAxisInfo.AxisType.c_str();
  422. strShow += " ";
  423. strShow += QString::number(pos, 'f', 2);
  424. return strShow;
  425. }
  426. void LightJoystickSwitchPage::RealTimeUpdatesToU()
  427. {
  428. if (m_pCameraBind)
  429. {
  430. // ui->JTabShowLableLoop->setText(CombiningStr(true));
  431. }
  432. }
  433. void LightJoystickSwitchPage::ResetIdleTimer(bool bStart /*= false*/)
  434. {
  435. if (bStart)
  436. {
  437. if (m_idleTimer != -1)
  438. {
  439. // 计时器没关,关闭重新打开
  440. ResetIdleTimer(false);
  441. ResetIdleTimer(true);
  442. }
  443. if (isActiveWindow())
  444. {
  445. m_idleTimer = startTimer(g_unnSuspensionWaitingTime);
  446. }
  447. }
  448. else
  449. {
  450. killTimer(m_idleTimer);
  451. m_idleTimer = -1;
  452. }
  453. }
  454. void LightJoystickSwitchPage::MoveJoystick()
  455. {
  456. if (m_pCameraBind)
  457. {
  458. m_pCameraBind->YGetAxisPosition(m_moveAxisInfo.ModuleType, m_moveAxisInfo.AxisType, m_moveAxisInfo.pos);
  459. }
  460. }
  461. void LightJoystickSwitchPage::RunMoveOrMoveTo(bool isMoveTo)
  462. {
  463. QString strErrInfo = {};
  464. QString strNum = "1";//ui->valLineEdit->text().trimmed();
  465. if (strNum.isEmpty())
  466. {
  467. strErrInfo = tr("please input value","请输入值");
  468. }
  469. else
  470. {
  471. double doNum = strNum.toDouble();
  472. if (m_moveAxisInfo.ModuleType != "")
  473. {
  474. if (m_moveAxisInfo.AxisType != "")
  475. {
  476. m_pCameraBind->SetModuleMove(m_moveAxisInfo.ModuleType, m_moveAxisInfo.AxisType, doNum, isMoveTo);
  477. }
  478. else
  479. {
  480. strErrInfo = tr("AxisType is Empty", "AxisType 为空");
  481. }
  482. }
  483. else
  484. {
  485. strErrInfo = tr("ModuleType is Empty", "ModuleType 为空");
  486. }
  487. }
  488. if (!strErrInfo.isEmpty())
  489. {
  490. JMessageTip::Message_question(strErrInfo);
  491. }
  492. }
  493. void LightJoystickSwitchPage::UpdataLightVal()
  494. {
  495. if (m_pCameraBind->m_pCViewInterface == nullptr)
  496. {
  497. return;
  498. }
  499. if (m_pPageSwitchGroup)
  500. {
  501. int niD = m_pPageSwitchGroup->m_cameaInfo.iCameraId;
  502. //if (niD == 1)
  503. {
  504. // 切换灯光
  505. ST_LIGHT_VAL _val = m_pCameraBind->JGetLight(niD);
  506. setLigthValue(_val.redLightValue, _val.greenLightValue, _val.blueLightValue, _val.pointLightValue);
  507. }
  508. }
  509. }
  510. EN_LIGHT_INDEX LightJoystickSwitchPage::MatchSelectedLightIndex(QLineEdit* lineEdit)
  511. {
  512. EN_LIGHT_INDEX nIndex = EN_LIGHT_INDEX::Red;
  513. if (lineEdit == ui->RedLightlineEdit)
  514. {
  515. nIndex = EN_LIGHT_INDEX::Red;
  516. }
  517. else if (lineEdit == ui->GreenLightlineEdit)
  518. {
  519. nIndex = EN_LIGHT_INDEX::Green;
  520. }
  521. else if (lineEdit == ui->BlueLightlineEdit)
  522. {
  523. nIndex = EN_LIGHT_INDEX::Blue;
  524. }
  525. else if (lineEdit == ui->DotLightlineEdit)
  526. {
  527. nIndex = EN_LIGHT_INDEX::Point;
  528. }
  529. return nIndex;
  530. }
  531. void LightJoystickSwitchPage::resizeSingleUI() {
  532. ui->switchTabWidget->setGeometry(QRect(0, 0, 265, 240));
  533. ui->GreenLightTab->setGeometry(QRect(0, 0, 60, 32));
  534. ui->JoystickTab->setGeometry(QRect(0, 0, 259, 215));
  535. ui->RedLight->setGeometry(QRect(0, 0, 61, 114));
  536. ui->RedLightlineEdit->setGeometry(QRect(10, 78, 40, 24));
  537. ui->RedLightprogressBar->setGeometry(QRect(32, 15, 18, 51));
  538. ui->RedLightverticalSlider->setGeometry(QRect(10, 12, 18, 56));
  539. ui->RedLightlabel->setGeometry(QRect(39, 22, 10, 34));
  540. ui->GreenLight->setGeometry(QRect(70, 0, 61, 114));
  541. ui->GreenLightlineEdit->setGeometry(QRect(10, 78, 40, 24));
  542. ui->GreenLightprogressBar->setGeometry(QRect(32, 15, 18, 51));
  543. ui->GreenLightverticalSlider->setGeometry(QRect(10, 12, 18, 56));
  544. ui->GreenLightlabel->setGeometry(QRect(36, 22, 10, 34));
  545. ui->BlueLight->setGeometry(QRect(140, 0, 61, 114));
  546. ui->BlueLightlineEdit->setGeometry(QRect(10, 78, 40, 24));
  547. ui->BlueLightprogressBar->setGeometry(QRect(32, 15, 18, 51));
  548. ui->BlueLightverticalSlider->setGeometry(QRect(10, 12, 18, 56));
  549. ui->BlueLightlabel->setGeometry(QRect(32, 22, 19, 34));
  550. ui->DotLight->setGeometry(QRect(200, 0, 61, 114));
  551. ui->DotLightlineEdit->setGeometry(QRect(10, 78, 40, 24));
  552. ui->DotLightprogressBar->setGeometry(QRect(32, 15, 18, 51));
  553. ui->DotLightverticalSlider->setGeometry(QRect(10, 12, 18, 56));
  554. ui->DotLightlabel->setGeometry(QRect(32, 22, 19, 34));
  555. ui->groupBox_2->setGeometry(QRect(0, 0, 250, 131));
  556. ui->xCheckBox->setGeometry(QRect(0, 0, 30, 30));
  557. ui->xLineEdit->setGeometry(QRect(31, 0, 50, 30));
  558. ui->rCheckBox->setGeometry(QRect(0, 0, 30, 30));
  559. ui->rLineEdit->setGeometry(QRect(31, 0, 50, 30));
  560. ui->xLayout->setGeometry(QRect(30, 0, 90, 30));
  561. ui->groupBox->setGeometry(QRect(0, 100, 141, 111));
  562. ui->left_Button->setGeometry(QRect(10, 40, 41, 31));
  563. ui->right_Button->setGeometry(QRect(90, 40, 41, 31));
  564. ui->up_Button->setGeometry(QRect(50, 10, 41, 31));
  565. ui->down_Button->setGeometry(QRect(50, 70, 41, 31));
  566. }
  567. void LightJoystickSwitchPage::on_xLineEdit_textChanged(const QString &arg1)
  568. {
  569. MoveModule("X", arg1);
  570. }
  571. void LightJoystickSwitchPage::on_yLineEdit_textChanged(const QString &arg1)
  572. {
  573. MoveModule("Y", arg1);
  574. }
  575. void LightJoystickSwitchPage::on_zLineEdit_textChanged(const QString &arg1)
  576. {
  577. MoveModule("Z", arg1);
  578. }
  579. void LightJoystickSwitchPage::on_z1LineEdit_textChanged(const QString& arg1)
  580. {
  581. MoveModule("Z1", arg1);
  582. }
  583. void LightJoystickSwitchPage::on_rLineEdit_textChanged(const QString &arg1)
  584. {
  585. MoveModule("R", arg1);
  586. }
  587. void LightJoystickSwitchPage::on_forceLineEdit_textChanged(const QString &arg1)
  588. {
  589. MoveModule("FORCE", arg1);
  590. }
  591. void LightJoystickSwitchPage::on_modeComboBox_currentIndexChanged(int index)
  592. {
  593. QString strMod = ui->modeComboBox->itemText(index);
  594. // 先禁用所有相关布局
  595. const QList<QLayout*> allLayouts = {
  596. ui->forceLayout,
  597. ui->xLayout,
  598. ui->yLayout,
  599. ui->rLayout,
  600. ui->zLayout,
  601. ui->z1Layout
  602. };
  603. for (auto* layout : allLayouts)
  604. {
  605. DisableLayoutWidgets(layout, false);
  606. }
  607. // 收集当前模块支持的轴类型
  608. QSet<QString> supportedAxes;
  609. for (const auto& axis : m_pCameraBind->m_vecCAxis)
  610. {
  611. if (strMod == axis->GetModuleType().c_str())
  612. {
  613. supportedAxes.insert(axis->GetStringAxisType().c_str());
  614. }
  615. }
  616. // 根据支持的轴启用对应布局
  617. const QHash<QString, QLayout*> axisToLayout = {
  618. {"FORCE", ui->forceLayout},
  619. {"X", ui->xLayout},
  620. {"Y", ui->yLayout},
  621. {"R", ui->rLayout},
  622. {"Z", ui->zLayout},
  623. {"Z1", ui->zLayout}
  624. };
  625. for (auto it = axisToLayout.constBegin(); it != axisToLayout.constEnd(); ++it)
  626. {
  627. if (supportedAxes.contains(it.key()))
  628. {
  629. m_listCurrentShowAxis.push_back(it.key());
  630. DisableLayoutWidgets(it.value(), true);
  631. }
  632. }
  633. m_moveAxisInfo.ModuleType = ui->modeComboBox->currentText().toStdString();
  634. }