mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 10:55:32 +08:00
Allow to save interpolation/rendering setup
- setting trait - save/load logic in context - adjusted UI, allow to reset global setup
This commit is contained in:
@@ -306,7 +306,7 @@ namespace BlackCore
|
|||||||
CInterpolationAndRenderingSetupGlobal CContextSimulator::getInterpolationAndRenderingSetupGlobal() const
|
CInterpolationAndRenderingSetupGlobal CContextSimulator::getInterpolationAndRenderingSetupGlobal() const
|
||||||
{
|
{
|
||||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||||
if (m_simulatorPlugin.first.isUnspecified()) { return CInterpolationAndRenderingSetupGlobal(); }
|
if (m_simulatorPlugin.first.isUnspecified()) { return m_renderSettings.get(); }
|
||||||
Q_ASSERT(m_simulatorPlugin.second);
|
Q_ASSERT(m_simulatorPlugin.second);
|
||||||
return m_simulatorPlugin.second->getInterpolationSetupGlobal();
|
return m_simulatorPlugin.second->getInterpolationSetupGlobal();
|
||||||
}
|
}
|
||||||
@@ -338,6 +338,12 @@ namespace BlackCore
|
|||||||
void CContextSimulator::setInterpolationAndRenderingSetupGlobal(const CInterpolationAndRenderingSetupGlobal &setup)
|
void CContextSimulator::setInterpolationAndRenderingSetupGlobal(const CInterpolationAndRenderingSetupGlobal &setup)
|
||||||
{
|
{
|
||||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << setup; }
|
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << setup; }
|
||||||
|
|
||||||
|
// anyway save for future reference
|
||||||
|
const CStatusMessage m = m_renderSettings.setAndSave(setup);
|
||||||
|
CLogMessage::preformatted(m);
|
||||||
|
|
||||||
|
// transfer to sim
|
||||||
if (m_simulatorPlugin.first.isUnspecified()) { return; }
|
if (m_simulatorPlugin.first.isUnspecified()) { return; }
|
||||||
Q_ASSERT(m_simulatorPlugin.second);
|
Q_ASSERT(m_simulatorPlugin.second);
|
||||||
m_simulatorPlugin.second->setInterpolationSetupGlobal(setup);
|
m_simulatorPlugin.second->setInterpolationSetupGlobal(setup);
|
||||||
@@ -439,8 +445,9 @@ namespace BlackCore
|
|||||||
// when everything is set up connected, update the current plugin info
|
// when everything is set up connected, update the current plugin info
|
||||||
m_simulatorPlugin.first = simulatorPluginInfo;
|
m_simulatorPlugin.first = simulatorPluginInfo;
|
||||||
m_simulatorPlugin.second = simulator;
|
m_simulatorPlugin.second = simulator;
|
||||||
|
m_simulatorPlugin.second->setInterpolationSetupGlobal(m_renderSettings.get());
|
||||||
|
|
||||||
// Emit signal after this function completes
|
// Emit signal after this function completes completely decoupled
|
||||||
QPointer<CContextSimulator> myself(this);
|
QPointer<CContextSimulator> myself(this);
|
||||||
QTimer::singleShot(0, this, [ = ]
|
QTimer::singleShot(0, this, [ = ]
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include "blackmisc/simulation/data/modelcaches.h"
|
#include "blackmisc/simulation/data/modelcaches.h"
|
||||||
#include "blackmisc/simulation/settings/modelmatchersettings.h"
|
#include "blackmisc/simulation/settings/modelmatchersettings.h"
|
||||||
#include "blackmisc/simulation/settings/simulatorsettings.h"
|
#include "blackmisc/simulation/settings/simulatorsettings.h"
|
||||||
|
#include "blackmisc/simulation/settings/interpolationrenderingsetupsettings.h"
|
||||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||||
#include "blackmisc/simulation/interpolationsetuplist.h"
|
#include "blackmisc/simulation/interpolationsetuplist.h"
|
||||||
#include "blackmisc/simulation/remoteaircraftprovider.h"
|
#include "blackmisc/simulation/remoteaircraftprovider.h"
|
||||||
@@ -244,18 +245,20 @@ namespace BlackCore
|
|||||||
CWeatherManager m_weatherManager { this }; //!< weather management
|
CWeatherManager m_weatherManager { this }; //!< weather management
|
||||||
CAircraftMatcher m_aircraftMatcher { this }; //!< model matcher
|
CAircraftMatcher m_aircraftMatcher { this }; //!< model matcher
|
||||||
QMap<BlackMisc::Aviation::CCallsign, BlackMisc::CStatusMessageList> m_matchingMessages; //!< all matching log messages per callsign
|
QMap<BlackMisc::Aviation::CCallsign, BlackMisc::CStatusMessageList> m_matchingMessages; //!< all matching log messages per callsign
|
||||||
BlackMisc::CSetting<BlackMisc::Simulation::Settings::TModelMatching> m_matchingSettings { this }; //!< settings
|
|
||||||
|
|
||||||
bool m_initallyAddAircraft = false;
|
bool m_initallyAddAircraft = false;
|
||||||
bool m_enableMatchingMessages = true;
|
bool m_enableMatchingMessages = true;
|
||||||
bool m_isWeatherActivated = false;
|
bool m_isWeatherActivated = false;
|
||||||
|
|
||||||
|
QString m_networkSessionId; //!< Network session of CServer::getServerSessionId, if not connected empty
|
||||||
|
|
||||||
// settings
|
// settings
|
||||||
|
BlackMisc::CSettingReadOnly<Application::TEnabledSimulators> m_enabledSimulators { this, &CContextSimulator::changeEnabledSimulators };
|
||||||
|
BlackMisc::CSetting<BlackMisc::Simulation::Settings::TModelMatching> m_matchingSettings { this }; //!< settings
|
||||||
BlackMisc::CData<BlackMisc::Simulation::Data::TSimulatorLastSelection> m_modelSetSimulator { this }; //!< current simulator (used with radio buttons)
|
BlackMisc::CData<BlackMisc::Simulation::Data::TSimulatorLastSelection> m_modelSetSimulator { this }; //!< current simulator (used with radio buttons)
|
||||||
BlackMisc::Simulation::Settings::CMultiSimulatorSettings m_simulatorSettings { this }; //!< for directories of XPlane
|
BlackMisc::Simulation::Settings::CMultiSimulatorSettings m_simulatorSettings { this }; //!< for directories of XPlane
|
||||||
|
BlackMisc::CSetting<BlackMisc::Simulation::Settings::TInterpolationAndRenderingSetupGlobal> m_renderSettings { this }; //!< rendering/interpolation settings
|
||||||
BlackMisc::CSettingReadOnly<BlackMisc::Simulation::Settings::TSimulatorMessages> m_messageSettings { this }; //!< settings for messages
|
BlackMisc::CSettingReadOnly<BlackMisc::Simulation::Settings::TSimulatorMessages> m_messageSettings { this }; //!< settings for messages
|
||||||
BlackMisc::CSettingReadOnly<Application::TEnabledSimulators> m_enabledSimulators { this, &CContextSimulator::changeEnabledSimulators };
|
|
||||||
QString m_networkSessionId; //!< Network session of CServer::getServerSessionId, if not connected empty
|
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
connect(ui->pb_RenderingSetup, &QPushButton::clicked, this, &CInterpolationSetupComponent::requestRenderingRestrictionsWidget);
|
connect(ui->pb_RenderingSetup, &QPushButton::clicked, this, &CInterpolationSetupComponent::requestRenderingRestrictionsWidget);
|
||||||
connect(ui->pb_Save, &QPushButton::clicked, this, &CInterpolationSetupComponent::saveSetup);
|
connect(ui->pb_Save, &QPushButton::clicked, this, &CInterpolationSetupComponent::saveSetup);
|
||||||
connect(ui->pb_Delete, &QPushButton::clicked, this, &CInterpolationSetupComponent::removeSetup);
|
connect(ui->pb_Delete, &QPushButton::clicked, this, &CInterpolationSetupComponent::removeOrResetSetup);
|
||||||
connect(ui->pb_Reload, &QPushButton::clicked, this, &CInterpolationSetupComponent::reloadSetup);
|
connect(ui->pb_Reload, &QPushButton::clicked, this, &CInterpolationSetupComponent::reloadSetup);
|
||||||
connect(ui->tvp_InterpolationSetup, &CInterpolationSetupView::doubleClicked, this, &CInterpolationSetupComponent::onRowDoubleClicked);
|
connect(ui->tvp_InterpolationSetup, &CInterpolationSetupView::doubleClicked, this, &CInterpolationSetupComponent::onRowDoubleClicked);
|
||||||
connect(ui->tvp_InterpolationSetup, &CInterpolationSetupView::modelChanged, this, &CInterpolationSetupComponent::onModelChanged, Qt::QueuedConnection);
|
connect(ui->tvp_InterpolationSetup, &CInterpolationSetupView::modelChanged, this, &CInterpolationSetupComponent::onModelChanged, Qt::QueuedConnection);
|
||||||
@@ -99,7 +99,7 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
this->displaySetupsPerCallsign();
|
this->displaySetupsPerCallsign();
|
||||||
ui->comp_CallsignCompleter->setReadOnly(!enableCallsign);
|
ui->comp_CallsignCompleter->setReadOnly(!enableCallsign);
|
||||||
ui->pb_Delete->setEnabled(enableCallsign);
|
ui->pb_Delete->setText(enableCallsign ? "delete" : "reset");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInterpolationSetupComponent::onModelChanged()
|
void CInterpolationSetupComponent::onModelChanged()
|
||||||
@@ -109,9 +109,10 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CInterpolationSetupComponent::reloadSetup()
|
void CInterpolationSetupComponent::reloadSetup()
|
||||||
{
|
{
|
||||||
|
const bool global = (this->getSetupMode() == CInterpolationSetupComponent::SetupGlobal);
|
||||||
const bool overlay = QObject::sender() == ui->pb_Reload;
|
const bool overlay = QObject::sender() == ui->pb_Reload;
|
||||||
if (!this->checkPrerequisites(overlay)) { return; }
|
if (!this->checkPrerequisites(!global, overlay)) { return; }
|
||||||
if (this->getSetupMode() == CInterpolationSetupComponent::SetupGlobal)
|
if (global)
|
||||||
{
|
{
|
||||||
CInterpolationAndRenderingSetupGlobal gs = sGui->getIContextSimulator()->getInterpolationAndRenderingSetupGlobal();
|
CInterpolationAndRenderingSetupGlobal gs = sGui->getIContextSimulator()->getInterpolationAndRenderingSetupGlobal();
|
||||||
ui->form_InterpolationSetup->setValue(gs);
|
ui->form_InterpolationSetup->setValue(gs);
|
||||||
@@ -127,10 +128,11 @@ namespace BlackGui
|
|||||||
|
|
||||||
void CInterpolationSetupComponent::saveSetup()
|
void CInterpolationSetupComponent::saveSetup()
|
||||||
{
|
{
|
||||||
if (!this->checkPrerequisites(true)) { return; }
|
const bool global = (this->getSetupMode() == CInterpolationSetupComponent::SetupGlobal);
|
||||||
|
if (!this->checkPrerequisites(!global, true)) { return; }
|
||||||
CInterpolationAndRenderingSetupPerCallsign setup = ui->form_InterpolationSetup->getValue();
|
CInterpolationAndRenderingSetupPerCallsign setup = ui->form_InterpolationSetup->getValue();
|
||||||
CInterpolationAndRenderingSetupGlobal gs = sGui->getIContextSimulator()->getInterpolationAndRenderingSetupGlobal();
|
CInterpolationAndRenderingSetupGlobal gs = sGui->getIContextSimulator()->getInterpolationAndRenderingSetupGlobal();
|
||||||
if (this->getSetupMode() == CInterpolationSetupComponent::SetupGlobal)
|
if (global)
|
||||||
{
|
{
|
||||||
gs.setBaseValues(setup);
|
gs.setBaseValues(setup);
|
||||||
gs.setLogInterpolation(false); // that would globally log all values
|
gs.setLogInterpolation(false); // that would globally log all values
|
||||||
@@ -172,10 +174,18 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInterpolationSetupComponent::removeSetup()
|
void CInterpolationSetupComponent::removeOrResetSetup()
|
||||||
|
{
|
||||||
|
const bool global = (this->getSetupMode() == CInterpolationSetupComponent::SetupGlobal);
|
||||||
|
if (!this->checkPrerequisites(!global, true)) { }
|
||||||
|
if (global)
|
||||||
|
{
|
||||||
|
CInterpolationAndRenderingSetupGlobal gs;
|
||||||
|
sGui->getIContextSimulator()->setInterpolationAndRenderingSetupGlobal(gs);
|
||||||
|
this->reloadSetup();
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (!this->checkPrerequisites(true)) { return; }
|
|
||||||
if (this->getSetupMode() == CInterpolationSetupComponent::SetupGlobal) { return; }
|
|
||||||
const CCallsign cs = ui->comp_CallsignCompleter->getCallsign(false);
|
const CCallsign cs = ui->comp_CallsignCompleter->getCallsign(false);
|
||||||
CInterpolationSetupList setups = ui->tvp_InterpolationSetup->container();
|
CInterpolationSetupList setups = ui->tvp_InterpolationSetup->container();
|
||||||
const int removed = setups.removeByCallsign(cs);
|
const int removed = setups.removeByCallsign(cs);
|
||||||
@@ -190,6 +200,7 @@ namespace BlackGui
|
|||||||
this->displaySetupsPerCallsign();
|
this->displaySetupsPerCallsign();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CInterpolationSetupComponent::setUiValuesFromGlobal()
|
void CInterpolationSetupComponent::setUiValuesFromGlobal()
|
||||||
{
|
{
|
||||||
@@ -205,7 +216,7 @@ namespace BlackGui
|
|||||||
ui->tvp_InterpolationSetup->updateContainerMaybeAsync(setups);
|
ui->tvp_InterpolationSetup->updateContainerMaybeAsync(setups);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CInterpolationSetupComponent::checkPrerequisites(bool showOverlay)
|
bool CInterpolationSetupComponent::checkPrerequisites(bool checkSim, bool showOverlay)
|
||||||
{
|
{
|
||||||
if (!sGui || !sGui->getIContextSimulator() || sGui->isShuttingDown())
|
if (!sGui || !sGui->getIContextSimulator() || sGui->isShuttingDown())
|
||||||
{
|
{
|
||||||
@@ -216,7 +227,7 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!sGui->getIContextSimulator()->isSimulatorAvailable())
|
if (checkSim && !sGui->getIContextSimulator()->isSimulatorAvailable())
|
||||||
{
|
{
|
||||||
if (showOverlay)
|
if (showOverlay)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ namespace BlackGui
|
|||||||
void saveSetup();
|
void saveSetup();
|
||||||
|
|
||||||
//! Delete a setup
|
//! Delete a setup
|
||||||
void removeSetup();
|
void removeOrResetSetup();
|
||||||
|
|
||||||
//! Values from global setup
|
//! Values from global setup
|
||||||
void setUiValuesFromGlobal();
|
void setUiValuesFromGlobal();
|
||||||
@@ -77,7 +77,7 @@ namespace BlackGui
|
|||||||
void displaySetupsPerCallsign();
|
void displaySetupsPerCallsign();
|
||||||
|
|
||||||
//! Check prerequisites before saving etc.
|
//! Check prerequisites before saving etc.
|
||||||
bool checkPrerequisites(bool showOverlay);
|
bool checkPrerequisites(bool checkSim, bool showOverlay);
|
||||||
|
|
||||||
//! Send to context
|
//! Send to context
|
||||||
bool setSetupsToContext(const BlackMisc::Simulation::CInterpolationSetupList &setups, bool force = false);
|
bool setSetupsToContext(const BlackMisc::Simulation::CInterpolationSetupList &setups, bool force = false);
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
/* Copyright (C) 2018
|
||||||
|
* 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 and at http://www.swift-project.org/license.html. 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 BLACKMISC_SIMULATION_SETTINGS_INTERPOLATIONRENDERINGSETUP_H
|
||||||
|
#define BLACKMISC_SIMULATION_SETTINGS_INTERPOLATIONRENDERINGSETUP_H
|
||||||
|
|
||||||
|
#include "blackmisc/simulation/interpolationrenderingsetup.h"
|
||||||
|
#include "blackmisc/settingscache.h"
|
||||||
|
|
||||||
|
namespace BlackMisc
|
||||||
|
{
|
||||||
|
namespace Simulation
|
||||||
|
{
|
||||||
|
namespace Settings
|
||||||
|
{
|
||||||
|
//! Last model used
|
||||||
|
struct TInterpolationAndRenderingSetupGlobal : public TSettingTrait<CInterpolationAndRenderingSetupGlobal>
|
||||||
|
{
|
||||||
|
//! \copydoc BlackCore::TSettingTrait::key
|
||||||
|
static const char *key() { return "settingsglobalinterpolationsetup"; }
|
||||||
|
|
||||||
|
//! \copydoc BlackCore::TSettingTrait::humanReadable
|
||||||
|
static const QString &humanReadable() { static const QString name("Interpolation setup"); return name; }
|
||||||
|
};
|
||||||
|
} // ns
|
||||||
|
} // ns
|
||||||
|
} // ns
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
Reference in New Issue
Block a user