|
@@ -2,6 +2,7 @@
|
|
#include "ui_LightJoystickSwitchPage.h"
|
|
#include "ui_LightJoystickSwitchPage.h"
|
|
#include "../common/JMessageTip.h"
|
|
#include "../common/JMessageTip.h"
|
|
#include "../common/JQCommon.h"
|
|
#include "../common/JQCommon.h"
|
|
|
|
+#include <QHash>
|
|
|
|
|
|
LightJoystickSwitchPage::LightJoystickSwitchPage(QWidget *parent)
|
|
LightJoystickSwitchPage::LightJoystickSwitchPage(QWidget *parent)
|
|
: QWidget(parent)
|
|
: QWidget(parent)
|
|
@@ -24,7 +25,7 @@ void LightJoystickSwitchPage::InitForm()
|
|
InitLineEdits();
|
|
InitLineEdits();
|
|
SliderBind();
|
|
SliderBind();
|
|
|
|
|
|
- JQCommon::SetQLineEditLimit(ui->valLineEdit);
|
|
|
|
|
|
+ // JQCommon::SetQLineEditLimit(ui->valLineEdit);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -59,6 +60,71 @@ void LightJoystickSwitchPage::InitLineEdits()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void LightJoystickSwitchPage::MoveModule(const QString strAxis, const QString pos)
|
|
|
|
+{
|
|
|
|
+ if (m_pCameraBind)
|
|
|
|
+ {
|
|
|
|
+ // 目前没有测试多轴,多轴在用
|
|
|
|
+ std::vector<ns_module::MODULE_COORD_MOVE> vecPos;
|
|
|
|
+ vecPos.push_back({ strAxis.toStdString() ,pos.toDouble() });
|
|
|
|
+ m_pCameraBind->JModuleMove(ui->modeComboBox->currentText().toStdString(), vecPos, false);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void LightJoystickSwitchPage::DisableLayoutWidgets(QLayout* layout, bool isShow /*= false*/)
|
|
|
|
+{
|
|
|
|
+ for (int i = 0; i < layout->count(); ++i)
|
|
|
|
+ {
|
|
|
|
+ QLayoutItem* item = layout->itemAt(i);
|
|
|
|
+ if (item->widget())
|
|
|
|
+ {
|
|
|
|
+ item->widget()->setEnabled(isShow);
|
|
|
|
+ }
|
|
|
|
+ else if (item->layout())
|
|
|
|
+ {
|
|
|
|
+ DisableLayoutWidgets(item->layout());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+template<class T>
|
|
|
|
+void LightJoystickSwitchPage::DeduplicationBox(QComboBox* pCom, const T& veTemp, int nIndex)
|
|
|
|
+{
|
|
|
|
+ for (auto& a : veTemp)
|
|
|
|
+ {
|
|
|
|
+ QString strName;
|
|
|
|
+ if (nIndex == 0)
|
|
|
|
+ {
|
|
|
|
+ strName = a->GetModuleType().c_str();
|
|
|
|
+ }
|
|
|
|
+ else if (nIndex == 1)
|
|
|
|
+ {
|
|
|
|
+ strName = a->GetStringAxisType().c_str();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ QStringList items;
|
|
|
|
+ for (int i = 0; i < pCom->count(); ++i)
|
|
|
|
+ {
|
|
|
|
+ items << pCom->itemText(i);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ bool bMa = false; // 是否匹配
|
|
|
|
+ for (auto b : items)
|
|
|
|
+ {
|
|
|
|
+ if (b == strName)
|
|
|
|
+ {
|
|
|
|
+ bMa = true;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!bMa)
|
|
|
|
+ {
|
|
|
|
+ pCom->addItem(strName);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
void LightJoystickSwitchPage::BondSliderAndLineEdit(QSlider* slider, QLineEdit* lineEdit)
|
|
void LightJoystickSwitchPage::BondSliderAndLineEdit(QSlider* slider, QLineEdit* lineEdit)
|
|
{
|
|
{
|
|
QIntValidator* validator = new QIntValidator(slider->minimum(), slider->maximum(), lineEdit);
|
|
QIntValidator* validator = new QIntValidator(slider->minimum(), slider->maximum(), lineEdit);
|
|
@@ -182,6 +248,10 @@ void LightJoystickSwitchPage::InitMainCameraBind(CameraBind* pCameraBind, bool b
|
|
{
|
|
{
|
|
UpdataLightVal();
|
|
UpdataLightVal();
|
|
}
|
|
}
|
|
|
|
+ if (m_pCameraBind)
|
|
|
|
+ {
|
|
|
|
+ DeduplicationBox(ui->modeComboBox, m_pCameraBind->m_vecCAxis, 0);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
void LightJoystickSwitchPage::UpdatemPageGroup(Group* pGroup)
|
|
void LightJoystickSwitchPage::UpdatemPageGroup(Group* pGroup)
|
|
@@ -264,7 +334,7 @@ void LightJoystickSwitchPage::RealTimeUpdatesToU()
|
|
{
|
|
{
|
|
if (m_pCameraBind)
|
|
if (m_pCameraBind)
|
|
{
|
|
{
|
|
- ui->JTabShowLableLoop->setText(CombiningStr(true));
|
|
|
|
|
|
+ // ui->JTabShowLableLoop->setText(CombiningStr(true));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -302,7 +372,7 @@ void LightJoystickSwitchPage::MoveJoystick()
|
|
void LightJoystickSwitchPage::RunMoveOrMoveTo(bool isMoveTo)
|
|
void LightJoystickSwitchPage::RunMoveOrMoveTo(bool isMoveTo)
|
|
{
|
|
{
|
|
QString strErrInfo = {};
|
|
QString strErrInfo = {};
|
|
- QString strNum = ui->valLineEdit->text().trimmed();
|
|
|
|
|
|
+ QString strNum = "1";//ui->valLineEdit->text().trimmed();
|
|
if (strNum.isEmpty())
|
|
if (strNum.isEmpty())
|
|
{
|
|
{
|
|
strErrInfo = tr("please input value","请输入值");
|
|
strErrInfo = tr("please input value","请输入值");
|
|
@@ -413,9 +483,85 @@ void LightJoystickSwitchPage::resizeSingleUI() {
|
|
ui->right_Button->setGeometry(QRect(90, 40, 41, 31));
|
|
ui->right_Button->setGeometry(QRect(90, 40, 41, 31));
|
|
ui->up_Button->setGeometry(QRect(50, 10, 41, 31));
|
|
ui->up_Button->setGeometry(QRect(50, 10, 41, 31));
|
|
ui->down_Button->setGeometry(QRect(50, 70, 41, 31));
|
|
ui->down_Button->setGeometry(QRect(50, 70, 41, 31));
|
|
- ui->move_Button->setGeometry(QRect(170, 130, 60, 23));
|
|
|
|
- ui->JTabShowLableLoop->setGeometry(QRect(10, 50, 200, 41));
|
|
|
|
- ui->moveTo_Button->setGeometry(QRect(170, 170, 60, 23));
|
|
|
|
- ui->valLineEdit->setGeometry(QRect(160, 100, 71, 21));
|
|
|
|
|
|
+ //ui->move_Button->setGeometry(QRect(170, 130, 60, 23));
|
|
|
|
+ //ui->JTabShowLableLoop->setGeometry(QRect(10, 50, 200, 41));
|
|
|
|
+ //ui->moveTo_Button->setGeometry(QRect(170, 170, 60, 23));
|
|
|
|
+ //ui->valLineEdit->setGeometry(QRect(160, 100, 71, 21));
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+void LightJoystickSwitchPage::on_xLineEdit_textChanged(const QString &arg1)
|
|
|
|
+{
|
|
|
|
+ MoveModule("X", arg1);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+void LightJoystickSwitchPage::on_yLineEdit_textChanged(const QString &arg1)
|
|
|
|
+{
|
|
|
|
+ MoveModule("Y", arg1);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+void LightJoystickSwitchPage::on_zLineEdit_textChanged(const QString &arg1)
|
|
|
|
+{
|
|
|
|
+ MoveModule("Z", arg1);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+void LightJoystickSwitchPage::on_rLineEdit_textChanged(const QString &arg1)
|
|
|
|
+{
|
|
|
|
+ MoveModule("R", arg1);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+void LightJoystickSwitchPage::on_forceLineEdit_textChanged(const QString &arg1)
|
|
|
|
+{
|
|
|
|
+ MoveModule("FORCE", arg1);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void LightJoystickSwitchPage::on_modeComboBox_currentIndexChanged(int index)
|
|
|
|
+{
|
|
|
|
+ QString strMod = ui->modeComboBox->itemText(index);
|
|
|
|
+ // 先禁用所有相关布局
|
|
|
|
+ const QList<QLayout*> allLayouts = {
|
|
|
|
+ ui->forceLayout,
|
|
|
|
+ ui->xLayout,
|
|
|
|
+ ui->yLayout,
|
|
|
|
+ ui->rLayout,
|
|
|
|
+ ui->zLayout,
|
|
|
|
+ };
|
|
|
|
+ for (auto* layout : allLayouts)
|
|
|
|
+ {
|
|
|
|
+ DisableLayoutWidgets(layout, false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 收集当前模块支持的轴类型
|
|
|
|
+ QSet<QString> supportedAxes;
|
|
|
|
+ for (const auto& axis : m_pCameraBind->m_vecCAxis)
|
|
|
|
+ {
|
|
|
|
+ if (strMod == axis->GetModuleType().c_str())
|
|
|
|
+ {
|
|
|
|
+ supportedAxes.insert(axis->GetStringAxisType().c_str());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 根据支持的轴启用对应布局
|
|
|
|
+ const QHash<QString, QLayout*> axisToLayout = {
|
|
|
|
+ {"FORCE", ui->forceLayout},
|
|
|
|
+ {"X", ui->xLayout},
|
|
|
|
+ {"Y", ui->yLayout},
|
|
|
|
+ {"R", ui->rLayout},
|
|
|
|
+ {"Z", ui->zLayout},
|
|
|
|
+ {"Z1", ui->zLayout}
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ for (auto it = axisToLayout.constBegin(); it != axisToLayout.constEnd(); ++it)
|
|
|
|
+ {
|
|
|
|
+ if (supportedAxes.contains(it.key()))
|
|
|
|
+ {
|
|
|
|
+ DisableLayoutWidgets(it.value(), true);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|