LightJoystickSwitchPage.cpp 21 KB

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