diff --git a/src/blackgui/editors/interpolationsetupform.cpp b/src/blackgui/editors/interpolationsetupform.cpp index 67bb59e7c..4c32efc85 100644 --- a/src/blackgui/editors/interpolationsetupform.cpp +++ b/src/blackgui/editors/interpolationsetupform.cpp @@ -29,7 +29,8 @@ namespace BlackGui connect(cb, &QCheckBox::stateChanged, this, &CInterpolationSetupForm::onCheckboxChanged); } - connect(ui->co_InterpolatorMode, &QComboBox::currentTextChanged, this, &CInterpolationSetupForm::onInterpolatorModeChanged); + // one conect is enough, otherwise 2 change signals + connect(ui->rb_Linear, &QRadioButton::toggled, this, &CInterpolationSetupForm::onInterpolatorModeChanged); } CInterpolationSetupForm::~CInterpolationSetupForm() @@ -43,10 +44,7 @@ namespace BlackGui ui->cb_ForceVtolInterpolation->setChecked(setup.isForcingVtolInterpolation()); ui->cb_SendGndFlagToSim->setChecked(setup.isSendingGndFlagToSimulator()); ui->cb_FixSceneryOffset->setChecked(setup.isFixingSceneryOffset()); - - const QString im = setup.getInterpolatorModeAsString(); - if (im.contains("linear", Qt::CaseInsensitive)) { ui->co_InterpolatorMode->setCurrentIndex(1); } - else { ui->co_InterpolatorMode->setCurrentIndex(0); } + this->setInterpolatorMode(setup.getInterpolatorMode()); } CInterpolationAndRenderingSetupPerCallsign CInterpolationSetupForm::getValue() const @@ -58,7 +56,7 @@ namespace BlackGui setup.setSendingGndFlagToSimulator(ui->cb_SendGndFlagToSim->isChecked()); setup.setSimulatorDebuggingMessages(ui->cb_DebugDriver->isChecked()); setup.setFixingSceneryOffset(ui->cb_FixSceneryOffset->isChecked()); - setup.setInterpolatorMode(ui->co_InterpolatorMode->currentText()); + setup.setInterpolatorMode(this->getInterpolatorMode()); return setup; } @@ -70,7 +68,8 @@ namespace BlackGui CGuiUtility::checkBoxReadOnly(ui->cb_ForceVtolInterpolation, readonly); CGuiUtility::checkBoxReadOnly(ui->cb_SendGndFlagToSim, readonly); CGuiUtility::checkBoxReadOnly(ui->cb_FixSceneryOffset, readonly); - ui->co_InterpolatorMode->setEnabled(!readonly); + ui->rb_Linear->setEnabled(!readonly); + ui->rb_Spline->setEnabled(!readonly); } CStatusMessageList CInterpolationSetupForm::validate(bool nested) const @@ -85,9 +84,27 @@ namespace BlackGui emit this->valueChanged(); } - void CInterpolationSetupForm::onInterpolatorModeChanged(const QString &mode) + CInterpolationAndRenderingSetupBase::InterpolatorMode CInterpolationSetupForm::getInterpolatorMode() const { - Q_UNUSED(mode); + if (ui->rb_Linear->isChecked()) { return CInterpolationAndRenderingSetupBase::Linear; } + return CInterpolationAndRenderingSetupBase::Spline; + } + + void CInterpolationSetupForm::setInterpolatorMode(CInterpolationAndRenderingSetupBase::InterpolatorMode mode) + { + switch (mode) + { + case CInterpolationAndRenderingSetupBase::Linear : ui->rb_Linear->setChecked(true); break; + case CInterpolationAndRenderingSetupBase::Spline: + default: + ui->rb_Spline->setChecked(true); + break; + } + } + + void CInterpolationSetupForm::onInterpolatorModeChanged(bool checked) + { + Q_UNUSED(checked); emit this->valueChanged(); } } // ns diff --git a/src/blackgui/editors/interpolationsetupform.h b/src/blackgui/editors/interpolationsetupform.h index ba6436f69..ed9c6d21f 100644 --- a/src/blackgui/editors/interpolationsetupform.h +++ b/src/blackgui/editors/interpolationsetupform.h @@ -60,7 +60,13 @@ namespace BlackGui void onCheckboxChanged(int state); //! Interpolator mode - void onInterpolatorModeChanged(const QString &mode); + void onInterpolatorModeChanged(bool checked); + + //! Mode from UI + BlackMisc::Simulation::CInterpolationAndRenderingSetupBase::InterpolatorMode getInterpolatorMode() const; + + //! Set mode + void setInterpolatorMode(BlackMisc::Simulation::CInterpolationAndRenderingSetupBase::InterpolatorMode mode); }; } // ns } // ns diff --git a/src/blackgui/editors/interpolationsetupform.ui b/src/blackgui/editors/interpolationsetupform.ui index 25291ee09..defbf190b 100644 --- a/src/blackgui/editors/interpolationsetupform.ui +++ b/src/blackgui/editors/interpolationsetupform.ui @@ -6,8 +6,8 @@ 0 0 - 231 - 96 + 223 + 91 @@ -40,24 +40,10 @@ - - - - - Spline interpolator - - - - - Linear interpolator - - - - - - + + - send gnd.to simulator + enable parts true @@ -81,18 +67,75 @@ - - + + - enable parts + send gnd.to simulator true + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + spline + + + true + + + + + + + linear + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + rb_Spline + cb_EnableParts + cb_SendGndFlagToSim + cb_FixSceneryOffset + cb_ForceVtolInterpolation + cb_DebugDriver + cb_LogInterpolation +