LightJoystickSwitchPage.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  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_nGroupId;
  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. m_isSlots = true;
  318. SetMoveJoystickInfo(_module);
  319. }
  320. void LightJoystickSwitchPage::InitMainCameraBind(CameraBind* pCameraBind, bool bUpdate /*= true*/)
  321. {
  322. m_pCameraBind = pCameraBind;
  323. if (bUpdate)
  324. {
  325. UpdataLightVal();
  326. }
  327. if (m_pCameraBind)
  328. {
  329. DeduplicationBox(ui->modeComboBox, m_pCameraBind->m_vecCAxis, 0);
  330. }
  331. }
  332. void LightJoystickSwitchPage::UpdatemPageGroup(Group* pGroup)
  333. {
  334. m_pPageSwitchGroup = pGroup;
  335. }
  336. void LightJoystickSwitchPage::SwitchJoystickPage(bool bSwitch)
  337. {
  338. ResetIdleTimer(bSwitch);
  339. //int newIndex = (ui->switchTabWidget->currentIndex() + 1) % ui->switchTabWidget->count();
  340. if (m_isSlots)
  341. {
  342. ui->switchTabWidget->setCurrentIndex(1);
  343. }
  344. else
  345. {
  346. ui->switchTabWidget->setCurrentIndex(0);
  347. }
  348. m_isSlots = false;
  349. }
  350. void LightJoystickSwitchPage::HideOrShowPage(bool isHide)
  351. {
  352. ui->switchTabWidget->setVisible(isHide);
  353. }
  354. void LightJoystickSwitchPage::SetMoveJoystickInfo(const ST_MOVE_AXIS& movInfo)
  355. {
  356. //m_moveAxisInfo.ModuleType = movInfo.ModuleType;
  357. //m_moveAxisInfo.AxisType = movInfo.AxisType;
  358. //m_moveAxisInfo.pos = movInfo.pos; // 这个距离可能会变动// 根据摇杆区分等级
  359. m_moveAxisInfo = movInfo;
  360. if (m_moveAxisInfo.isSwitch)
  361. {
  362. // 点击摇杆的时候开启定时器,然后3秒关闭
  363. SwitchJoystickPage(true);
  364. }
  365. }
  366. void LightJoystickSwitchPage::timerEvent(QTimerEvent* event)
  367. {
  368. int nID = event->timerId();
  369. if (m_nTimeShowPos == nID)
  370. {
  371. RealTimeUpdatesToU();
  372. }
  373. else if (m_idleTimer == nID)
  374. {
  375. SwitchJoystickPage(false);
  376. }
  377. else if (m_nUpdateUiAxis == nID)
  378. {
  379. UpDataAxisToUi();
  380. }
  381. }
  382. QString LightJoystickSwitchPage::CombiningStr(bool isUpdate /*= false*/)
  383. {
  384. double pos = m_moveAxisInfo.pos;
  385. QString strShow = tr("Currently selected mode:", "当前选中模式:");
  386. if (isUpdate)
  387. {
  388. strShow = tr("Move Pos:","移动点:");
  389. if (m_pCameraBind)
  390. {
  391. m_pCameraBind->YGetAxisPosition(m_moveAxisInfo.ModuleType, m_moveAxisInfo.AxisType, pos);
  392. }
  393. }
  394. strShow += m_moveAxisInfo.ModuleType.c_str();
  395. strShow += " ";
  396. strShow += m_moveAxisInfo.AxisType.c_str();
  397. strShow += " ";
  398. strShow += QString::number(pos, 'f', 2);
  399. return strShow;
  400. }
  401. void LightJoystickSwitchPage::RealTimeUpdatesToU()
  402. {
  403. if (m_pCameraBind)
  404. {
  405. // ui->JTabShowLableLoop->setText(CombiningStr(true));
  406. }
  407. }
  408. void LightJoystickSwitchPage::ResetIdleTimer(bool bStart /*= false*/)
  409. {
  410. if (bStart)
  411. {
  412. if (m_idleTimer != -1)
  413. {
  414. // 计时器没关,关闭重新打开
  415. ResetIdleTimer(false);
  416. ResetIdleTimer(true);
  417. }
  418. if (isActiveWindow())
  419. {
  420. m_idleTimer = startTimer(g_unnSuspensionWaitingTime);
  421. }
  422. }
  423. else
  424. {
  425. killTimer(m_idleTimer);
  426. m_idleTimer = -1;
  427. }
  428. }
  429. void LightJoystickSwitchPage::MoveJoystick()
  430. {
  431. if (m_pCameraBind)
  432. {
  433. m_pCameraBind->YGetAxisPosition(m_moveAxisInfo.ModuleType, m_moveAxisInfo.AxisType, m_moveAxisInfo.pos);
  434. }
  435. }
  436. void LightJoystickSwitchPage::RunMoveOrMoveTo(bool isMoveTo)
  437. {
  438. QString strErrInfo = {};
  439. QString strNum = "1";//ui->valLineEdit->text().trimmed();
  440. if (strNum.isEmpty())
  441. {
  442. strErrInfo = tr("please input value","请输入值");
  443. }
  444. else
  445. {
  446. double doNum = strNum.toDouble();
  447. if (m_moveAxisInfo.ModuleType != "")
  448. {
  449. if (m_moveAxisInfo.AxisType != "")
  450. {
  451. m_pCameraBind->SetModuleMove(m_moveAxisInfo.ModuleType, m_moveAxisInfo.AxisType, doNum, isMoveTo);
  452. }
  453. else
  454. {
  455. strErrInfo = tr("AxisType is Empty", "AxisType 为空");
  456. }
  457. }
  458. else
  459. {
  460. strErrInfo = tr("ModuleType is Empty", "ModuleType 为空");
  461. }
  462. }
  463. if (!strErrInfo.isEmpty())
  464. {
  465. JMessageTip::Message_question(strErrInfo);
  466. }
  467. }
  468. void LightJoystickSwitchPage::UpdataLightVal()
  469. {
  470. if (m_pCameraBind->m_pCViewInterface == nullptr)
  471. {
  472. return;
  473. }
  474. if (m_pPageSwitchGroup)
  475. {
  476. int niD = m_pPageSwitchGroup->m_nGroupId;
  477. //if (niD == 1)
  478. {
  479. // 切换灯光
  480. ST_LIGHT_VAL _val = m_pCameraBind->JGetLight(niD);
  481. setLigthValue(_val.redLightValue, _val.greenLightValue, _val.blueLightValue, _val.pointLightValue);
  482. }
  483. }
  484. }
  485. EN_LIGHT_INDEX LightJoystickSwitchPage::MatchSelectedLightIndex(QLineEdit* lineEdit)
  486. {
  487. EN_LIGHT_INDEX nIndex = EN_LIGHT_INDEX::Red;
  488. if (lineEdit == ui->RedLightlineEdit)
  489. {
  490. nIndex = EN_LIGHT_INDEX::Red;
  491. }
  492. else if (lineEdit == ui->GreenLightlineEdit)
  493. {
  494. nIndex = EN_LIGHT_INDEX::Green;
  495. }
  496. else if (lineEdit == ui->BlueLightlineEdit)
  497. {
  498. nIndex = EN_LIGHT_INDEX::Blue;
  499. }
  500. else if (lineEdit == ui->DotLightlineEdit)
  501. {
  502. nIndex = EN_LIGHT_INDEX::Point;
  503. }
  504. return nIndex;
  505. }
  506. void LightJoystickSwitchPage::resizeSingleUI() {
  507. ui->switchTabWidget->setGeometry(QRect(0, 0, 265, 240));
  508. ui->GreenLightTab->setGeometry(QRect(0, 0, 60, 32));
  509. ui->JoystickTab->setGeometry(QRect(0, 0, 259, 215));
  510. ui->RedLight->setGeometry(QRect(0, 0, 61, 114));
  511. ui->RedLightlineEdit->setGeometry(QRect(10, 78, 40, 24));
  512. ui->RedLightprogressBar->setGeometry(QRect(32, 15, 18, 51));
  513. ui->RedLightverticalSlider->setGeometry(QRect(10, 12, 18, 56));
  514. ui->RedLightlabel->setGeometry(QRect(39, 22, 10, 34));
  515. ui->GreenLight->setGeometry(QRect(70, 0, 61, 114));
  516. ui->GreenLightlineEdit->setGeometry(QRect(10, 78, 40, 24));
  517. ui->GreenLightprogressBar->setGeometry(QRect(32, 15, 18, 51));
  518. ui->GreenLightverticalSlider->setGeometry(QRect(10, 12, 18, 56));
  519. ui->GreenLightlabel->setGeometry(QRect(36, 22, 10, 34));
  520. ui->BlueLight->setGeometry(QRect(140, 0, 61, 114));
  521. ui->BlueLightlineEdit->setGeometry(QRect(10, 78, 40, 24));
  522. ui->BlueLightprogressBar->setGeometry(QRect(32, 15, 18, 51));
  523. ui->BlueLightverticalSlider->setGeometry(QRect(10, 12, 18, 56));
  524. ui->BlueLightlabel->setGeometry(QRect(32, 22, 19, 34));
  525. ui->DotLight->setGeometry(QRect(200, 0, 61, 114));
  526. ui->DotLightlineEdit->setGeometry(QRect(10, 78, 40, 24));
  527. ui->DotLightprogressBar->setGeometry(QRect(32, 15, 18, 51));
  528. ui->DotLightverticalSlider->setGeometry(QRect(10, 12, 18, 56));
  529. ui->DotLightlabel->setGeometry(QRect(32, 22, 19, 34));
  530. ui->groupBox_2->setGeometry(QRect(0, 0, 250, 131));
  531. ui->xCheckBox->setGeometry(QRect(0, 0, 30, 30));
  532. ui->xLineEdit->setGeometry(QRect(31, 0, 50, 30));
  533. ui->rCheckBox->setGeometry(QRect(0, 0, 30, 30));
  534. ui->rLineEdit->setGeometry(QRect(31, 0, 50, 30));
  535. ui->xLayout->setGeometry(QRect(30, 0, 90, 30));
  536. ui->groupBox->setGeometry(QRect(0, 100, 141, 111));
  537. ui->left_Button->setGeometry(QRect(10, 40, 41, 31));
  538. ui->right_Button->setGeometry(QRect(90, 40, 41, 31));
  539. ui->up_Button->setGeometry(QRect(50, 10, 41, 31));
  540. ui->down_Button->setGeometry(QRect(50, 70, 41, 31));
  541. }
  542. void LightJoystickSwitchPage::on_xLineEdit_textChanged(const QString &arg1)
  543. {
  544. MoveModule("X", arg1);
  545. }
  546. void LightJoystickSwitchPage::on_yLineEdit_textChanged(const QString &arg1)
  547. {
  548. MoveModule("Y", arg1);
  549. }
  550. void LightJoystickSwitchPage::on_zLineEdit_textChanged(const QString &arg1)
  551. {
  552. MoveModule("Z", arg1);
  553. }
  554. void LightJoystickSwitchPage::on_rLineEdit_textChanged(const QString &arg1)
  555. {
  556. MoveModule("R", arg1);
  557. }
  558. void LightJoystickSwitchPage::on_forceLineEdit_textChanged(const QString &arg1)
  559. {
  560. MoveModule("FORCE", arg1);
  561. }
  562. void LightJoystickSwitchPage::on_modeComboBox_currentIndexChanged(int index)
  563. {
  564. QString strMod = ui->modeComboBox->itemText(index);
  565. // 先禁用所有相关布局
  566. const QList<QLayout*> allLayouts = {
  567. ui->forceLayout,
  568. ui->xLayout,
  569. ui->yLayout,
  570. ui->rLayout,
  571. ui->zLayout,
  572. };
  573. for (auto* layout : allLayouts)
  574. {
  575. DisableLayoutWidgets(layout, false);
  576. }
  577. // 收集当前模块支持的轴类型
  578. QSet<QString> supportedAxes;
  579. for (const auto& axis : m_pCameraBind->m_vecCAxis)
  580. {
  581. if (strMod == axis->GetModuleType().c_str())
  582. {
  583. supportedAxes.insert(axis->GetStringAxisType().c_str());
  584. }
  585. }
  586. // 根据支持的轴启用对应布局
  587. const QHash<QString, QLayout*> axisToLayout = {
  588. {"FORCE", ui->forceLayout},
  589. {"X", ui->xLayout},
  590. {"Y", ui->yLayout},
  591. {"R", ui->rLayout},
  592. {"Z", ui->zLayout},
  593. {"Z1", ui->zLayout}
  594. };
  595. for (auto it = axisToLayout.constBegin(); it != axisToLayout.constEnd(); ++it)
  596. {
  597. if (supportedAxes.contains(it.key()))
  598. {
  599. m_listCurrentShowAxis.push_back(it.key());
  600. DisableLayoutWidgets(it.value(), true);
  601. }
  602. }
  603. m_moveAxisInfo.ModuleType = ui->modeComboBox->currentText().toStdString();
  604. }