LightJoystickSwitchPage.cpp 22 KB

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