diff --git a/src/blackgui/components/cgsourceselector.cpp b/src/blackgui/components/cgsourceselector.cpp new file mode 100644 index 000000000..a44b4807a --- /dev/null +++ b/src/blackgui/components/cgsourceselector.cpp @@ -0,0 +1,55 @@ +/* Copyright (C) 2019 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated, + * or distributed except according to the terms contained in the LICENSE file. + */ + +#include "cgsourceselector.h" +#include "ui_cgsourceselector.h" + +using namespace BlackMisc::Simulation::Settings; + +namespace BlackGui +{ + namespace Components + { + CCGSourceSelector::CCGSourceSelector(QWidget *parent) : + QFrame(parent), + ui(new Ui::CCGSourceSelector) + { + ui->setupUi(this); + this->initComboBox(); + } + + CCGSourceSelector::~CCGSourceSelector() + { } + + CSimulatorSettings::CGSource CCGSourceSelector::getValue() const + { + const int d = ui->cb_CGSourceSelector->currentData().toInt(); + return static_cast(d); + } + + void CCGSourceSelector::setValue(const CSimulatorSettings &settings) + { + this->setValue(settings.getCGSource()); + } + + void CCGSourceSelector::setValue(CSimulatorSettings::CGSource source) + { + ui->cb_CGSourceSelector->setCurrentText(CSimulatorSettings::cgSourceAsString(source)); + } + + void CCGSourceSelector::initComboBox() + { + ui->cb_CGSourceSelector->clear(); + ui->cb_CGSourceSelector->addItem(CSimulatorSettings::cgSourceAsString(CSimulatorSettings::CGFromSimulatorFirst), CSimulatorSettings::CGFromSimulatorFirst); + ui->cb_CGSourceSelector->addItem(CSimulatorSettings::cgSourceAsString(CSimulatorSettings::CGFromDBFirst), CSimulatorSettings::CGFromDBFirst); + ui->cb_CGSourceSelector->addItem(CSimulatorSettings::cgSourceAsString(CSimulatorSettings::CGFromSimulatorOnly), CSimulatorSettings::CGFromSimulatorOnly); + ui->cb_CGSourceSelector->addItem(CSimulatorSettings::cgSourceAsString(CSimulatorSettings::CGFromDBOnly), CSimulatorSettings::CGFromDBOnly); + this->setValue(CSimulatorSettings::CGFromSimulatorFirst); + } + } // ns +} // ns diff --git a/src/blackgui/components/cgsourceselector.h b/src/blackgui/components/cgsourceselector.h new file mode 100644 index 000000000..716c0b111 --- /dev/null +++ b/src/blackgui/components/cgsourceselector.h @@ -0,0 +1,50 @@ +/* Copyright (C) 2013 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated, + * or distributed except according to the terms contained in the LICENSE file. + */ + +//! \file + +#ifndef BLACKGUI_COMPONENTS_CGSOURCESELECTOR_H +#define BLACKGUI_COMPONENTS_CGSOURCESELECTOR_H + +#include "blackmisc/simulation/settings/simulatorsettings.h" +#include +#include + +namespace Ui { class CCGSourceSelector; } +namespace BlackGui +{ + namespace Components + { + //! CG (aka vertical offset) selector + class CCGSourceSelector : public QFrame + { + Q_OBJECT + + public: + //! Ctor + explicit CCGSourceSelector(QWidget *parent = nullptr); + + //! Dtor + virtual ~CCGSourceSelector() override; + + //! Get/set value @{ + BlackMisc::Simulation::Settings::CSimulatorSettings::CGSource getValue() const; + void setValue(const BlackMisc::Simulation::Settings::CSimulatorSettings &settings); + void setValue(BlackMisc::Simulation::Settings::CSimulatorSettings::CGSource source); + //! @} + + private: + //! Init the combobox + void initComboBox(); + + QScopedPointer ui; + }; + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/components/cgsourceselector.ui b/src/blackgui/components/cgsourceselector.ui new file mode 100644 index 000000000..0b82d2034 --- /dev/null +++ b/src/blackgui/components/cgsourceselector.ui @@ -0,0 +1,49 @@ + + + CCGSourceSelector + + + CG selector + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + Simulator first + + + + + DB first + + + + + Simulator only + + + + + DB only + + + + + + + + + diff --git a/src/blackgui/components/settingscomponent.ui b/src/blackgui/components/settingscomponent.ui index bd296cad5..357e8f7c1 100644 --- a/src/blackgui/components/settingscomponent.ui +++ b/src/blackgui/components/settingscomponent.ui @@ -2,11 +2,19 @@ CSettingsComponent + + + 0 + 0 + 211 + 378 + + Settings - 0 + 7 @@ -479,7 +487,7 @@ 1 - + diff --git a/src/blackgui/components/settingssimulatorcomponent.cpp b/src/blackgui/components/settingssimulatorcomponent.cpp index 3d205eb4c..d3bc17e79 100644 --- a/src/blackgui/components/settingssimulatorcomponent.cpp +++ b/src/blackgui/components/settingssimulatorcomponent.cpp @@ -18,11 +18,11 @@ #include "blackgui/pluginselector.h" #include "blackmisc/simulation/simulatorplugininfo.h" #include "blackmisc/simulation/simulatorplugininfolist.h" -#include "blackmisc/iterator.h" -#include "blackmisc/logmessage.h" #include "blackmisc/pq/length.h" #include "blackmisc/pq/time.h" #include "blackmisc/pq/units.h" +#include "blackmisc/iterator.h" +#include "blackmisc/logmessage.h" #include "blackmisc/statusmessage.h" #include "blackmisc/verify.h" #include "ui_settingssimulatorcomponent.h" @@ -74,9 +74,11 @@ namespace BlackGui connect(ui->pluginSelector_EnabledSimulators, &CPluginSelector::pluginConfigRequested, this, &CSettingsSimulatorComponent::showPluginConfig); connect(ui->pb_ApplyMaxAircraft, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::onApplyMaxRenderedAircraft, Qt::QueuedConnection); - connect(ui->pb_ApplyTimeSync, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::onApplyTimeSync, Qt::QueuedConnection); + connect(ui->pb_ApplyTimeSync, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::onApplyTimeSync, Qt::QueuedConnection); connect(ui->pb_ApplyMaxDistance, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::onApplyMaxRenderedDistance, Qt::QueuedConnection); connect(ui->pb_ApplyComSync, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::onApplyComSync, Qt::QueuedConnection); + connect(ui->pb_ApplyCGSource, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::onApplyCGSource, Qt::QueuedConnection); + connect(ui->pb_ApplyRecordOwnAircraftGnd, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::onApplyRecordGnd, Qt::QueuedConnection); connect(ui->pb_ClearRestrictedRendering, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::clearRestricedRendering); connect(ui->pb_DisableRendering, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::onApplyDisableRendering); @@ -120,6 +122,13 @@ namespace BlackGui ui->pb_ApplyComSync->setEnabled(m_pluginLoaded); ui->cb_ComSync->setEnabled(m_pluginLoaded); + // CG + ui->comp_CGSourceSelector->setEnabled(m_pluginLoaded); + + // record GND + ui->pb_ApplyRecordOwnAircraftGnd->setEnabled(m_pluginLoaded); + ui->cb_RecordOwnGndPositions->setEnabled(m_pluginLoaded); + // led ui->led_RestrictedRendering->setOn(m_pluginLoaded ? setup.isRenderingRestricted() : false); ui->lbl_RestrictionText->setText(m_pluginLoaded ? setup.getRenderRestrictionText() : ""); @@ -131,6 +140,7 @@ namespace BlackGui ui->pb_ClearRestrictedRendering->setEnabled((m_pluginLoaded)); ui->pb_DisableRendering->setEnabled(m_pluginLoaded); ui->pb_Check->setEnabled(!m_pluginLoaded); + ui->pb_ApplyCGSource->setEnabled(m_pluginLoaded); if (m_pluginLoaded) { @@ -144,6 +154,9 @@ namespace BlackGui const CSimulatorSettings settings = sim->getSimulatorSettings(); ui->cb_ComSync->setChecked(settings.isComIntegrated()); + // CG + ui->comp_CGSourceSelector->setValue(settings); + // rendering const int maxAircraft = setup.getMaxRenderedAircraft(); ui->le_MaxAircraft->setText(setup.isMaxAircraftRestricted() ? QString::number(maxAircraft) : ""); @@ -278,19 +291,51 @@ namespace BlackGui } } - void CSettingsSimulatorComponent::onApplyComSync() + CSimulatorSettings CSettingsSimulatorComponent::getSimulatorSettings(bool &ok) + { + ok = false; + if (!sGui || sGui->isShuttingDown() || !sGui->getIContextSimulator()) { return {}; } + const IContextSimulator *sim = sGui->getIContextSimulator(); + const CSimulatorInfo simulator = sim->getSimulatorPluginInfo().getSimulatorInfo(); + if (!simulator.isSingleSimulator()) { return {}; } + ok = true; + const CSimulatorSettings settings = sim->getSimulatorSettings(); + return settings; + } + + void CSettingsSimulatorComponent::setSimulatorSettings(CSimulatorSettings &settings) { if (!sGui || sGui->isShuttingDown() || !sGui->getIContextSimulator()) { return; } - IContextSimulator *sim = sGui->getIContextSimulator(); const CSimulatorInfo simulator = sim->getSimulatorPluginInfo().getSimulatorInfo(); - if (!simulator.isSingleSimulator()) { return; } - CSimulatorSettings settings = sim->getSimulatorSettings(); - if (settings.isComIntegrated() == ui->cb_ComSync->isChecked()) { return; } - settings.setComIntegrated(ui->cb_ComSync->isChecked()); sim->setSimulatorSettings(settings, simulator); } + void CSettingsSimulatorComponent::onApplyComSync() + { + bool ok = false; + CSimulatorSettings settings = getSimulatorSettings(ok); + if (!ok || !settings.setComIntegrated(ui->cb_ComSync->isChecked())) { return; } + setSimulatorSettings(settings); + } + + void CSettingsSimulatorComponent::onApplyCGSource() + { + bool ok = false; + const CSimulatorSettings::CGSource source = ui->comp_CGSourceSelector->getValue(); + CSimulatorSettings settings = getSimulatorSettings(ok); + if (!ok || !settings.setCGSource(source)) { return; } + setSimulatorSettings(settings); + } + + void CSettingsSimulatorComponent::onApplyRecordGnd() + { + bool ok = false; + CSimulatorSettings settings = getSimulatorSettings(ok); + if (!ok || !settings.setRecordOwnAircraftGnd(ui->cb_RecordOwnGndPositions->isChecked())) { return; } + setSimulatorSettings(settings); + } + void CSettingsSimulatorComponent::clearRestricedRendering() { if (!sGui || sGui->isShuttingDown() || !sGui->getIContextSimulator()) { return; } diff --git a/src/blackgui/components/settingssimulatorcomponent.h b/src/blackgui/components/settingssimulatorcomponent.h index f00b9124a..7f23a5049 100644 --- a/src/blackgui/components/settingssimulatorcomponent.h +++ b/src/blackgui/components/settingssimulatorcomponent.h @@ -13,8 +13,9 @@ #include "blackcore/application/applicationsettings.h" #include "blackgui/blackguiexport.h" -#include "blackmisc/settingscache.h" +#include "blackmisc/simulation/settings/simulatorsettings.h" #include "blackmisc/simulation/simulatorplugininfolist.h" +#include "blackmisc/settingscache.h" #include #include @@ -59,6 +60,12 @@ namespace BlackGui //! Apply COM sync void onApplyComSync(); + //! Apply CG source + void onApplyCGSource(); + + //! Record GND + void onApplyRecordGnd(); + //! Clear restricted rendering void clearRestricedRendering(); @@ -83,6 +90,12 @@ namespace BlackGui //! Available plugins, auto pseudo plugin added BlackMisc::Simulation::CSimulatorPluginInfoList getAvailablePlugins() const; + //! Get the simulator settings + static BlackMisc::Simulation::Settings::CSimulatorSettings getSimulatorSettings(bool &ok); + + //! Get the simulator settings + static void setSimulatorSettings(BlackMisc::Simulation::Settings::CSimulatorSettings &settings); + QScopedPointer ui; //!< UI bool m_pluginLoaded = false; //!< plugin loaded? BlackCore::CPluginManagerSimulator *m_plugins = nullptr; diff --git a/src/blackgui/components/settingssimulatorcomponent.ui b/src/blackgui/components/settingssimulatorcomponent.ui index f5898a989..0b1ff6649 100644 --- a/src/blackgui/components/settingssimulatorcomponent.ui +++ b/src/blackgui/components/settingssimulatorcomponent.ui @@ -2,10 +2,18 @@ CSettingsSimulatorComponent - - Frame + + + 0 + 0 + 352 + 343 + - + + Simulator settings + + 2 @@ -18,58 +26,7 @@ 2 - - - - 4 - - - - - - - - restriction info - - - - - - - - - 4 - - - - - no restrictions - - - - - - - - - Current rendering restrictions (if any) - - - Restrictions - - - - - - - - 10 - 0 - - - - - + Simulator info will go here @@ -79,213 +36,17 @@ - - - - Time synchronization - - - Time synch. - - - - - - - - 3 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Enable time syncronization - - - - - - - - - - - 75 - 16777215 - - - - offset +/-hh:mm - - - #99:99 - - - +00:00 - - - 6 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - apply - - - - - - - Rendering enabled - - - Rendering enabled - - - - - - - apply - - - - - - - Max.dist.(NM) - - - - - - - clear - - - - - - - 4 - - - - - no restrictions - - - - - - - - - apply - - - 0 - 50 + 40 - - - - use COM sync. - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - Loaded - - - - - - - Max.aircraft - - - - - - - disable - - - - - - - apply - - - - - - - Synchronize COM unit with simulator - - - COM synch. - - - - + @@ -298,6 +59,299 @@ + + + + true + + + + + 0 + 0 + 346 + 269 + + + + + 4 + + + 4 + + + 4 + + + 4 + + + + + apply + + + + + + + apply + + + + + + + apply + + + + + + + apply + + + + + + + + 10 + 0 + + + + + + + + Current rendering restrictions (if any) + + + Restrictions + + + + + + + Record gnd. + + + + + + + Max.dist.(NM) + + + + + + + + + + CG (vert offset): + + + + + + + record own gnd positions + + + + + + + disable + + + + + + + use COM sync. + + + + + + + apply + + + + + + + + 3 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Enable time syncronization + + + + + + + + + + + 75 + 16777215 + + + + offset +/-hh:mm + + + #99:99 + + + +00:00 + + + 6 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + clear + + + + + + + Time synchronization + + + Time synch. + + + + + + + 4 + + + + + + + + restriction info + + + + + + + + + Max.aircraft + + + + + + + Synchronize COM unit with simulator + + + COM synch. + + + + + + + apply + + + + + + + Rendering enabled + + + Rendering enabled + + + + + + + 4 + + + + + no restrictions + + + + + + + + + 4 + + + + + no restrictions + + + + + + + + + @@ -313,20 +367,18 @@
blackgui/pluginselector.h
1 + + BlackGui::Components::CCGSourceSelector + QFrame +
blackgui/components/cgsourceselector.h
+ 1 +
- pb_Check cb_TimeSync le_TimeSyncOffset - pb_ApplyTimeSync - cb_ComSync - pb_ApplyComSync - pb_DisableRendering - pb_ClearRestrictedRendering le_MaxAircraft - pb_ApplyMaxAircraft le_MaxDistance - pb_ApplyMaxDistance