|
@@ -15,12 +15,16 @@ LightJoystickSwitchPage::LightJoystickSwitchPage(QWidget *parent)
|
|
|
|
|
|
LightJoystickSwitchPage::~LightJoystickSwitchPage()
|
|
|
{
|
|
|
+
|
|
|
+ killTimer(m_nUpdateUiAxis);
|
|
|
+
|
|
|
delete ui;
|
|
|
}
|
|
|
|
|
|
void LightJoystickSwitchPage::InitForm()
|
|
|
{
|
|
|
m_nTimeShowPos = startTimer(900);
|
|
|
+ m_nUpdateUiAxis = startTimer(900);
|
|
|
|
|
|
InitLineEdits();
|
|
|
SliderBind();
|
|
@@ -60,14 +64,77 @@ void LightJoystickSwitchPage::InitLineEdits()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void LightJoystickSwitchPage::UpDataAxisToUi()
|
|
|
+{
|
|
|
+ if (m_pCameraBind)
|
|
|
+ {
|
|
|
+ const QHash<QString, QLayout*> axisToLayout = {
|
|
|
+ {"FORCE", ui->forceLayout},
|
|
|
+ {"X", ui->xLayout},
|
|
|
+ {"Y", ui->yLayout},
|
|
|
+ {"R", ui->rLayout},
|
|
|
+ {"Z", ui->zLayout},
|
|
|
+ {"Z1", ui->zLayout}
|
|
|
+ };
|
|
|
+ for (const auto& val : m_listCurrentShowAxis)
|
|
|
+ {
|
|
|
+ if (axisToLayout.contains(val))
|
|
|
+ {
|
|
|
+ QLayout* layout = axisToLayout.value(val);
|
|
|
+ for (int i = 0; i < layout->count(); ++i)
|
|
|
+ {
|
|
|
+ QWidget* widget = layout->itemAt(i)->widget();
|
|
|
+ if (widget && widget->inherits("QLineEdit"))
|
|
|
+ {
|
|
|
+ JReLineEdit* lineEdit = qobject_cast<JReLineEdit*>(widget);
|
|
|
+ if (lineEdit)
|
|
|
+ {
|
|
|
+ double pos = 0;
|
|
|
+ m_pCameraBind->YGetAxisPosition(m_moveAxisInfo.ModuleType, val.toStdString(), pos);
|
|
|
+ lineEdit->setText(QString::number(pos, 'f', 2));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
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);
|
|
|
+ const QHash<QString, QLayout*> m_HaAxisToLayout = {
|
|
|
+ {"FORCE", ui->forceLayout},
|
|
|
+ {"X", ui->xLayout},
|
|
|
+ {"Y", ui->yLayout},
|
|
|
+ {"R", ui->rLayout},
|
|
|
+ {"Z", ui->zLayout},
|
|
|
+ {"Z1", ui->zLayout}
|
|
|
+ };
|
|
|
+
|
|
|
+ if (m_HaAxisToLayout.contains(strAxis))
|
|
|
+ {
|
|
|
+ QLayout* layout = m_HaAxisToLayout.value(strAxis);
|
|
|
+ for (int i = 0; i < layout->count(); ++i)
|
|
|
+ {
|
|
|
+ QWidget* widget = layout->itemAt(i)->widget();
|
|
|
+ if (widget && widget->inherits("QLineEdit"))
|
|
|
+ {
|
|
|
+ JReLineEdit* lineEdit = qobject_cast<JReLineEdit*>(widget);
|
|
|
+ if (lineEdit)
|
|
|
+ {
|
|
|
+ if (lineEdit->m_isSetVal)
|
|
|
+ {
|
|
|
+ // 目前没有测试多轴,多轴在用
|
|
|
+ std::vector<ns_module::MODULE_COORD_MOVE> vecPos;
|
|
|
+ vecPos.push_back({ strAxis.toStdString() ,pos.toDouble() });
|
|
|
+ m_pCameraBind->JModuleMove(ui->modeComboBox->currentText().toStdString(), vecPos, false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -306,6 +373,10 @@ void LightJoystickSwitchPage::timerEvent(QTimerEvent* event)
|
|
|
{
|
|
|
SwitchJoystickPage(false);
|
|
|
}
|
|
|
+ else if (m_nUpdateUiAxis == nID)
|
|
|
+ {
|
|
|
+ UpDataAxisToUi();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
QString LightJoystickSwitchPage::CombiningStr(bool isUpdate /*= false*/)
|
|
@@ -560,6 +631,7 @@ void LightJoystickSwitchPage::on_modeComboBox_currentIndexChanged(int index)
|
|
|
{
|
|
|
if (supportedAxes.contains(it.key()))
|
|
|
{
|
|
|
+ m_listCurrentShowAxis.push_back(it.key());
|
|
|
DisableLayoutWidgets(it.value(), true);
|
|
|
}
|
|
|
}
|