LightJoystickSwitchPage.cpp 21 KB

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