mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-10 05:55:33 +08:00
Ref T261, interpolator mode is now part of setup
* added attribute in setup * adjusted UI * adjusted interpolator / simulator functions
This commit is contained in:
committed by
Roland Winklmeier
parent
eb815ab987
commit
3d2a74a652
@@ -187,10 +187,6 @@ namespace BlackCore
|
||||
//! \copydoc BlackMisc::IProvider::asQObject
|
||||
virtual QObject *asQObject() override { return this; }
|
||||
|
||||
//! Set interpolation mode, empty callsign applies to all know callsigns
|
||||
//! \return Returns true if the mode changed, otherwise false. Note that some implementations always return true.
|
||||
virtual bool setInterpolatorMode(BlackMisc::Simulation::CInterpolatorMulti::Mode mode, const BlackMisc::Aviation::CCallsign &callsign) = 0;
|
||||
|
||||
//! \addtogroup swiftdotcommands
|
||||
//! @{
|
||||
//! <pre>
|
||||
|
||||
@@ -477,10 +477,23 @@ namespace BlackCore
|
||||
|
||||
if (part1.startsWith("spline") || part1.startsWith("linear"))
|
||||
{
|
||||
const CCallsign cs(parser.hasPart(2) ? parser.part(2) : "");
|
||||
const bool changed = this->setInterpolatorMode(CInterpolatorMulti::modeFromString(part1), cs);
|
||||
CLogMessage(this).info(changed ? "Changed interpolation mode" : "Unchanged interpolation mode");
|
||||
return true;
|
||||
if (parser.hasPart(2))
|
||||
{
|
||||
const CCallsign cs(parser.part(2));
|
||||
CInterpolationAndRenderingSetupPerCallsign setup = this->getInterpolationSetupPerCallsignOrDefault(cs);
|
||||
const bool changed = setup.setInterpolatorMode(part1);
|
||||
if (changed) { this->setInterpolationSetupPerCallsign(setup, cs); }
|
||||
CLogMessage(this).info(changed ? "Changed interpolation mode for '%1'" : "Unchanged interpolation mode for '%1'") << cs.asString();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
CInterpolationAndRenderingSetupGlobal setup = this->getInterpolationSetupGlobal();
|
||||
const bool changed = setup.setInterpolatorMode(part1);
|
||||
if (changed) { this->setInterpolationAndRenderingSetup(setup); }
|
||||
CLogMessage(this).info(changed ? "Changed interpolation mode globally" : "Unchanged interpolation mode");
|
||||
return true;
|
||||
}
|
||||
} // spline/linear
|
||||
|
||||
if (part1.startsWith("pos"))
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "blackcore/context/contextsimulator.h"
|
||||
#include "blackmisc/simulation/interpolationsetuplist.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
#include <QPointer>
|
||||
|
||||
using namespace BlackGui::Views;
|
||||
using namespace BlackMisc;
|
||||
@@ -41,7 +42,13 @@ namespace BlackGui
|
||||
connect(ui->rb_Global, &QRadioButton::released, this, &CInterpolationSetupComponent::onModeChanged);
|
||||
|
||||
ui->rb_Global->setChecked(true);
|
||||
QTimer::singleShot(250, this, &CInterpolationSetupComponent::onModeChanged);
|
||||
|
||||
QPointer<CInterpolationSetupComponent> myself(this);
|
||||
QTimer::singleShot(250, this, [ = ]
|
||||
{
|
||||
if (myself.isNull()) { return; }
|
||||
this->onModeChanged();
|
||||
});
|
||||
}
|
||||
|
||||
CInterpolationSetupComponent::~CInterpolationSetupComponent()
|
||||
@@ -118,7 +125,13 @@ namespace BlackGui
|
||||
if (removed < 1) { return; } // nothing done
|
||||
const bool set = this->setSetupsToContext(setups);
|
||||
if (!set) { return; }
|
||||
QTimer::singleShot(100, this, &CInterpolationSetupComponent::displaySetupsPerCallsign);
|
||||
|
||||
QPointer<CInterpolationSetupComponent> myself(this);
|
||||
QTimer::singleShot(100, this, [ = ]
|
||||
{
|
||||
if (myself.isNull()) { return; }
|
||||
this->displaySetupsPerCallsign();
|
||||
});
|
||||
}
|
||||
|
||||
void CInterpolationSetupComponent::setUiValuesFromGlobal()
|
||||
@@ -137,7 +150,7 @@ namespace BlackGui
|
||||
|
||||
bool CInterpolationSetupComponent::checkPrerequisites()
|
||||
{
|
||||
if (!sGui || !sGui->getIContextSimulator())
|
||||
if (!sGui || !sGui->getIContextSimulator() || sGui->isShuttingDown())
|
||||
{
|
||||
const CStatusMessage m = CStatusMessage(this).validationError("No context");
|
||||
this->showOverlayMessage(m);
|
||||
@@ -154,7 +167,7 @@ namespace BlackGui
|
||||
|
||||
bool CInterpolationSetupComponent::setSetupsToContext(const CInterpolationSetupList &setups)
|
||||
{
|
||||
if (!sGui || !sGui->getIContextSimulator()) { return false; }
|
||||
if (!sGui || sGui->isShuttingDown() || !sGui->getIContextSimulator()) { return false; }
|
||||
if (setups == m_lastSetSetups) { return false; }
|
||||
sGui->getIContextSimulator()->setInterpolationAndRenderingSetupsPerCallsign(setups);
|
||||
m_lastSetSetups = setups;
|
||||
|
||||
@@ -28,6 +28,8 @@ namespace BlackGui
|
||||
{
|
||||
connect(cb, &QCheckBox::stateChanged, this, &CInterpolationSetupForm::onCheckboxChanged);
|
||||
}
|
||||
|
||||
connect(ui->co_InterpolatorMode, &QComboBox::currentTextChanged, this, &CInterpolationSetupForm::onInterpolatorModeChanged);
|
||||
}
|
||||
|
||||
CInterpolationSetupForm::~CInterpolationSetupForm()
|
||||
@@ -41,6 +43,10 @@ namespace BlackGui
|
||||
ui->cb_ForceFullInterpolation->setChecked(setup.isForcingFullInterpolation());
|
||||
ui->cb_EnableGndFlag->setChecked(setup.isGndFlagEnabled());
|
||||
ui->cb_SendGndFlagToSim->setChecked(setup.sendGndFlagToSimulator());
|
||||
|
||||
const QString im = setup.getInterpolatorModeAsString();
|
||||
if (im.contains("linear", Qt::CaseInsensitive)) { ui->co_InterpolatorMode->setCurrentIndex(1); }
|
||||
else { ui->co_InterpolatorMode->setCurrentIndex(0); }
|
||||
}
|
||||
|
||||
CInterpolationAndRenderingSetupPerCallsign CInterpolationSetupForm::getValue() const
|
||||
@@ -52,6 +58,7 @@ namespace BlackGui
|
||||
setup.setLogInterpolation(ui->cb_LogInterpolation->isChecked());
|
||||
setup.setSendGndFlagToSimulator(ui->cb_SendGndFlagToSim->isChecked());
|
||||
setup.setSimulatorDebuggingMessages(ui->cb_DebugDriver->isChecked());
|
||||
setup.setInterpolatorMode(ui->co_InterpolatorMode->currentText());
|
||||
return setup;
|
||||
}
|
||||
|
||||
@@ -63,6 +70,7 @@ namespace BlackGui
|
||||
CGuiUtility::checkBoxReadOnly(ui->cb_ForceFullInterpolation, readonly);
|
||||
CGuiUtility::checkBoxReadOnly(ui->cb_EnableGndFlag, readonly);
|
||||
CGuiUtility::checkBoxReadOnly(ui->cb_SendGndFlagToSim, readonly);
|
||||
ui->co_InterpolatorMode->setEnabled(!readonly);
|
||||
}
|
||||
|
||||
CStatusMessageList CInterpolationSetupForm::validate(bool nested) const
|
||||
@@ -76,5 +84,11 @@ namespace BlackGui
|
||||
Q_UNUSED(state);
|
||||
emit this->valueChanged();
|
||||
}
|
||||
|
||||
void CInterpolationSetupForm::onInterpolatorModeChanged(const QString &mode)
|
||||
{
|
||||
Q_UNUSED(mode);
|
||||
emit this->valueChanged();
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -58,6 +58,9 @@ namespace BlackGui
|
||||
|
||||
//! Checkbox has been changed
|
||||
void onCheckboxChanged(int state);
|
||||
|
||||
//! Interpolator mode
|
||||
void onInterpolatorModeChanged(const QString &mode);
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -7,21 +7,35 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>236</width>
|
||||
<height>75</height>
|
||||
<height>102</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Frame</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="cb_ForceFullInterpolation">
|
||||
<property name="text">
|
||||
<string>force full interpolation</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QCheckBox" name="cb_DebugDriver">
|
||||
<property name="text">
|
||||
<string>driver dbg. msgs.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="cb_EnableGndFlag">
|
||||
<property name="text">
|
||||
<string>use gnd.flag</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="cb_EnableParts">
|
||||
<property name="text">
|
||||
<string>enable parts</string>
|
||||
@@ -31,34 +45,34 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="cb_ForceFullInterpolation">
|
||||
<property name="text">
|
||||
<string>force full interpolation</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="cb_DebugDriver">
|
||||
<property name="text">
|
||||
<string>driver dbg. msgs.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="cb_LogInterpolation">
|
||||
<property name="text">
|
||||
<string>log.interpolation</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="cb_SendGndFlagToSim">
|
||||
<property name="text">
|
||||
<string>send gnd.to simulator</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QComboBox" name="co_InterpolatorMode">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Spline interpolator</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Linear interpolator</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
||||
@@ -41,7 +41,34 @@ namespace BlackMisc
|
||||
void CInterpolationAndRenderingSetupBase::consolidateWithClient(const CClient &client)
|
||||
{
|
||||
m_enabledAircraftParts &= client.hasAircraftPartsCapability();
|
||||
// m_enabledGndFlag &= client.hasGndFlagCapability();
|
||||
}
|
||||
|
||||
bool CInterpolationAndRenderingSetupBase::setInterpolatorMode(CInterpolationAndRenderingSetupBase::InterpolatorMode mode)
|
||||
{
|
||||
const int m = static_cast<int>(mode);
|
||||
if (m_interpolatorMode == m) { return false; }
|
||||
m_interpolatorMode = m;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CInterpolationAndRenderingSetupBase::setInterpolatorMode(const QString &mode)
|
||||
{
|
||||
if (mode.contains("spline", Qt::CaseInsensitive)) { return this->setInterpolatorMode(Spline); }
|
||||
if (mode.contains("linear", Qt::CaseInsensitive)) { return this->setInterpolatorMode(Linear); }
|
||||
return false;
|
||||
}
|
||||
|
||||
const QString &CInterpolationAndRenderingSetupBase::modeToString(InterpolatorMode mode)
|
||||
{
|
||||
static const QString l("linear");
|
||||
static const QString s("spline");
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case Linear: return l;
|
||||
case Spline: return s;
|
||||
default: return s;
|
||||
}
|
||||
}
|
||||
|
||||
bool CInterpolationAndRenderingSetupBase::setEnabledAircraftParts(bool enabled)
|
||||
@@ -94,7 +121,8 @@ namespace BlackMisc
|
||||
{
|
||||
Q_UNUSED(i18n);
|
||||
return
|
||||
QStringLiteral("Dbg.sim.msgs: ") % boolToYesNo(m_simulatorDebugMessages) %
|
||||
QStringLiteral("Interpolator: ") % this->getInterpolatorModeAsString() %
|
||||
QStringLiteral(" | Dbg.sim.msgs: ") % boolToYesNo(m_simulatorDebugMessages) %
|
||||
QStringLiteral(" | log interpolation: ") % boolToYesNo(m_logInterpolation) %
|
||||
QStringLiteral(" | force full interpolation: ") % boolToYesNo(m_forceFullInterpolation) %
|
||||
QStringLiteral(" | enable parts: ") % boolToYesNo(m_enabledAircraftParts) %
|
||||
|
||||
@@ -36,7 +36,15 @@ namespace BlackMisc
|
||||
IndexForceFullInterpolation,
|
||||
IndexSendGndFlagToSimulator,
|
||||
IndexEnableGndFlag,
|
||||
IndexEnabledAircraftParts
|
||||
IndexEnabledAircraftParts,
|
||||
IndexInterpolatorMode
|
||||
};
|
||||
|
||||
//! Interpolator type
|
||||
enum InterpolatorMode
|
||||
{
|
||||
Spline,
|
||||
Linear
|
||||
};
|
||||
|
||||
//! Debugging messages for simulation
|
||||
@@ -81,6 +89,18 @@ namespace BlackMisc
|
||||
//! Consolidate with a network client
|
||||
void consolidateWithClient(const Network::CClient &client);
|
||||
|
||||
//! Interpolator mode
|
||||
InterpolatorMode getInterpolatorMode() const { return static_cast<InterpolatorMode>(m_interpolatorMode); }
|
||||
|
||||
//! Interpolator mode
|
||||
const QString &getInterpolatorModeAsString() const { return modeToString(this->getInterpolatorMode()); }
|
||||
|
||||
//! Set interpolator mode
|
||||
bool setInterpolatorMode(InterpolatorMode mode);
|
||||
|
||||
//! Set interpolator mode
|
||||
bool setInterpolatorMode(const QString &mode);
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||
QString convertToQString(bool i18n = false) const;
|
||||
|
||||
@@ -90,6 +110,9 @@ namespace BlackMisc
|
||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||
void setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant);
|
||||
|
||||
//! Interpolator mode as string
|
||||
static const QString &modeToString(InterpolatorMode mode);
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
CInterpolationAndRenderingSetupBase();
|
||||
@@ -103,6 +126,7 @@ namespace BlackMisc
|
||||
bool m_enabledAircraftParts = true; //!< Enable aircraft parts
|
||||
bool m_enabledGndFlag = true; //!< Enable gnd.flag
|
||||
bool m_sendGndToSim = true; //!< Send the gnd.flag to simulator
|
||||
int m_interpolatorMode = static_cast<int>(Spline); //!< interpolator mode (spline, ...)
|
||||
};
|
||||
|
||||
//! Value object for interpolator and rendering
|
||||
@@ -184,6 +208,7 @@ namespace BlackMisc
|
||||
BLACK_METAMEMBER(sendGndToSim),
|
||||
BLACK_METAMEMBER(enabledAircraftParts),
|
||||
BLACK_METAMEMBER(enabledGndFlag),
|
||||
BLACK_METAMEMBER(interpolatorMode),
|
||||
BLACK_METAMEMBER(maxRenderedAircraft),
|
||||
BLACK_METAMEMBER(maxRenderedDistance)
|
||||
);
|
||||
@@ -241,7 +266,8 @@ namespace BlackMisc
|
||||
BLACK_METAMEMBER(forceFullInterpolation),
|
||||
BLACK_METAMEMBER(sendGndToSim),
|
||||
BLACK_METAMEMBER(enabledAircraftParts),
|
||||
BLACK_METAMEMBER(enabledGndFlag)
|
||||
BLACK_METAMEMBER(enabledGndFlag),
|
||||
BLACK_METAMEMBER(interpolatorMode)
|
||||
);
|
||||
};
|
||||
} // namespace
|
||||
@@ -249,5 +275,6 @@ namespace BlackMisc
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Simulation::CInterpolationAndRenderingSetupPerCallsign)
|
||||
Q_DECLARE_METATYPE(BlackMisc::Simulation::CInterpolationAndRenderingSetupGlobal)
|
||||
Q_DECLARE_METATYPE(BlackMisc::Simulation::CInterpolationAndRenderingSetupBase::InterpolatorMode)
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -26,10 +26,10 @@ namespace BlackMisc
|
||||
const CInterpolationAndRenderingSetupPerCallsign &setup,
|
||||
CInterpolationStatus &status)
|
||||
{
|
||||
switch (m_mode)
|
||||
switch (setup.getInterpolatorMode())
|
||||
{
|
||||
case ModeLinear: return m_linear.getInterpolatedSituation(currentTimeSinceEpoc, setup, status);
|
||||
case ModeSpline: return m_spline.getInterpolatedSituation(currentTimeSinceEpoc, setup, status);
|
||||
case CInterpolationAndRenderingSetupBase::Linear: return m_linear.getInterpolatedSituation(currentTimeSinceEpoc, setup, status);
|
||||
case CInterpolationAndRenderingSetupBase::Spline: return m_spline.getInterpolatedSituation(currentTimeSinceEpoc, setup, status);
|
||||
default: break;
|
||||
}
|
||||
return {};
|
||||
@@ -39,11 +39,11 @@ namespace BlackMisc
|
||||
qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetupPerCallsign &setup,
|
||||
CPartsStatus &partsStatus, bool log) const
|
||||
{
|
||||
switch (m_mode)
|
||||
switch (setup.getInterpolatorMode())
|
||||
{
|
||||
// currently calls the same interpolation for parts
|
||||
case ModeLinear: return m_linear.getInterpolatedParts(currentTimeSinceEpoc, setup, partsStatus, log);
|
||||
case ModeSpline: return m_spline.getInterpolatedParts(currentTimeSinceEpoc, setup, partsStatus, log);
|
||||
case CInterpolationAndRenderingSetupBase::Linear: return m_linear.getInterpolatedParts(currentTimeSinceEpoc, setup, partsStatus, log);
|
||||
case CInterpolationAndRenderingSetupBase::Spline: return m_spline.getInterpolatedParts(currentTimeSinceEpoc, setup, partsStatus, log);
|
||||
default: break;
|
||||
}
|
||||
return {};
|
||||
@@ -53,22 +53,22 @@ namespace BlackMisc
|
||||
qint64 currentTimeSinceEpoc, const CInterpolationAndRenderingSetupPerCallsign &setup,
|
||||
CPartsStatus &partsStatus, bool log) const
|
||||
{
|
||||
switch (m_mode)
|
||||
switch (setup.getInterpolatorMode())
|
||||
{
|
||||
// currently calls the same interpolation for parts
|
||||
case ModeLinear: return m_linear.getInterpolatedOrGuessedParts(currentTimeSinceEpoc, setup, partsStatus, log);
|
||||
case ModeSpline: return m_spline.getInterpolatedOrGuessedParts(currentTimeSinceEpoc, setup, partsStatus, log);
|
||||
case CInterpolationAndRenderingSetupBase::Linear: return m_linear.getInterpolatedOrGuessedParts(currentTimeSinceEpoc, setup, partsStatus, log);
|
||||
case CInterpolationAndRenderingSetupBase::Spline: return m_spline.getInterpolatedOrGuessedParts(currentTimeSinceEpoc, setup, partsStatus, log);
|
||||
default: break;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
const CAircraftSituation &CInterpolatorMulti::getLastInterpolatedSituation() const
|
||||
const CAircraftSituation &CInterpolatorMulti::getLastInterpolatedSituation(CInterpolationAndRenderingSetupBase::InterpolatorMode mode) const
|
||||
{
|
||||
switch (m_mode)
|
||||
switch (mode)
|
||||
{
|
||||
case ModeLinear: return m_linear.getLastInterpolatedSituation();
|
||||
case ModeSpline: return m_spline.getLastInterpolatedSituation();
|
||||
case CInterpolationAndRenderingSetupBase::Linear: return m_linear.getLastInterpolatedSituation();
|
||||
case CInterpolationAndRenderingSetupBase::Spline: return m_spline.getLastInterpolatedSituation();
|
||||
default: break;
|
||||
}
|
||||
return CAircraftSituation::null();
|
||||
@@ -86,63 +86,17 @@ namespace BlackMisc
|
||||
m_spline.initCorrespondingModel(model);
|
||||
}
|
||||
|
||||
bool CInterpolatorMulti::setMode(Mode mode)
|
||||
QString CInterpolatorMulti::getInterpolatorInfo(CInterpolationAndRenderingSetupBase::InterpolatorMode mode) const
|
||||
{
|
||||
if (m_mode == mode) { return false; }
|
||||
m_mode = mode;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CInterpolatorMulti::setMode(const QString &mode)
|
||||
{
|
||||
Mode m = modeFromString(mode);
|
||||
if (m == ModeUnknown) { return false; }
|
||||
return setMode(m);
|
||||
}
|
||||
|
||||
void CInterpolatorMulti::toggleMode()
|
||||
{
|
||||
switch (m_mode)
|
||||
switch (mode)
|
||||
{
|
||||
case ModeSpline: m_mode = ModeLinear; break;
|
||||
case ModeLinear: m_mode = ModeSpline; break;
|
||||
default: m_mode = ModeSpline; break;
|
||||
}
|
||||
}
|
||||
|
||||
QString CInterpolatorMulti::getInterpolatorInfo() const
|
||||
{
|
||||
switch (m_mode)
|
||||
{
|
||||
case ModeSpline: return m_spline.getInterpolatorInfo();
|
||||
case ModeLinear: return m_linear.getInterpolatorInfo();
|
||||
case CInterpolationAndRenderingSetupBase::Spline: return m_spline.getInterpolatorInfo();
|
||||
case CInterpolationAndRenderingSetupBase::Linear: return m_linear.getInterpolatorInfo();
|
||||
default: break;
|
||||
}
|
||||
return ("Illegal mode");
|
||||
}
|
||||
|
||||
CInterpolatorMulti::Mode CInterpolatorMulti::modeFromString(const QString &mode)
|
||||
{
|
||||
if (mode.contains("spli"), Qt::CaseInsensitive) { return ModeSpline; }
|
||||
if (mode.contains("lin"), Qt::CaseInsensitive) { return ModeLinear; }
|
||||
return ModeUnknown;
|
||||
}
|
||||
|
||||
const QString &CInterpolatorMulti::modeToString(CInterpolatorMulti::Mode mode)
|
||||
{
|
||||
static const QString l("linear");
|
||||
static const QString s("spline");
|
||||
static const QString u("unknown");
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case ModeLinear: return l;
|
||||
case ModeSpline: return s;
|
||||
case ModeUnknown:
|
||||
default: return u;
|
||||
}
|
||||
}
|
||||
|
||||
CInterpolatorMultiWrapper::CInterpolatorMultiWrapper()
|
||||
{ }
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace BlackMisc
|
||||
CPartsStatus &partsStatus, bool log) const;
|
||||
|
||||
//! \copydoc CInterpolator::getLastInterpolatedSituation
|
||||
const Aviation::CAircraftSituation &getLastInterpolatedSituation() const;
|
||||
const Aviation::CAircraftSituation &getLastInterpolatedSituation(CInterpolationAndRenderingSetupBase::InterpolatorMode mode) const;
|
||||
|
||||
//! \copydoc CInterpolator::attachLogger
|
||||
void attachLogger(CInterpolationLogger *logger);
|
||||
@@ -52,37 +52,10 @@ namespace BlackMisc
|
||||
//! \copydoc CInterpolator::initCorrespondingModel
|
||||
void initCorrespondingModel(const CAircraftModel &model);
|
||||
|
||||
//! Supported interpolation modes.
|
||||
enum Mode
|
||||
{
|
||||
ModeSpline, //!< spline interpolation mode
|
||||
ModeLinear, //!< linear interpolation mode
|
||||
ModeUnknown
|
||||
};
|
||||
|
||||
//! Set interpolation mode. Return true if mode was changed. Mode will not be changed in release build.
|
||||
bool setMode(Mode mode);
|
||||
|
||||
//! Set interpolation mode. Return true if mode was changed. Mode will not be changed in release build.
|
||||
bool setMode(const QString &mode);
|
||||
|
||||
//! Get active interpolation mode.
|
||||
Mode getMode() const { return m_mode; }
|
||||
|
||||
//! Toogle interpolator Mode
|
||||
void toggleMode();
|
||||
|
||||
//! Info string
|
||||
QString getInterpolatorInfo() const;
|
||||
|
||||
//! Mode from string
|
||||
static Mode modeFromString(const QString &mode);
|
||||
|
||||
//! Mode to string
|
||||
static const QString &modeToString(Mode mode);
|
||||
QString getInterpolatorInfo(CInterpolationAndRenderingSetupBase::InterpolatorMode mode) const;
|
||||
|
||||
private:
|
||||
Mode m_mode = ModeSpline;
|
||||
CInterpolatorSpline m_spline;
|
||||
CInterpolatorLinear m_linear;
|
||||
};
|
||||
|
||||
@@ -303,14 +303,6 @@ namespace BlackSimPlugin
|
||||
return c > 0;
|
||||
}
|
||||
|
||||
bool CSimulatorEmulated::setInterpolatorMode(CInterpolatorMulti::Mode mode, const CCallsign &callsign)
|
||||
{
|
||||
if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO, CInterpolatorMulti::modeToString(mode), callsign.toQString());
|
||||
if (!m_interpolators.contains(callsign)) { return false; }
|
||||
CInterpolatorMulti *im = m_interpolators[callsign];
|
||||
return im->setMode(mode);
|
||||
}
|
||||
|
||||
int CSimulatorEmulated::physicallyRemoveAllRemoteAircraft()
|
||||
{
|
||||
if (canLog()) m_monitorWidget->appendReceivingCall(Q_FUNC_INFO);
|
||||
|
||||
@@ -60,7 +60,6 @@ namespace BlackSimPlugin
|
||||
virtual BlackMisc::PhysicalQuantities::CTime getTimeSynchronizationOffset() const override;
|
||||
virtual bool isPhysicallyRenderedAircraft(const BlackMisc::Aviation::CCallsign &callsign) const override;
|
||||
virtual BlackMisc::Aviation::CCallsignSet physicallyRenderedAircraft() const override;
|
||||
virtual bool setInterpolatorMode(BlackMisc::Simulation::CInterpolatorMulti::Mode mode, const BlackMisc::Aviation::CCallsign &callsign) override;
|
||||
|
||||
// functions just logged
|
||||
virtual void highlightAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraftToHighlight, bool enableHighlight, const BlackMisc::PhysicalQuantities::CTime &displayTime) override;
|
||||
|
||||
@@ -279,16 +279,6 @@ namespace BlackSimPlugin
|
||||
this->displayStatusMessage(message.asStatusMessage(true, true));
|
||||
}
|
||||
|
||||
bool CSimulatorFs9::setInterpolatorMode(CInterpolatorMulti::Mode mode, const CCallsign &callsign)
|
||||
{
|
||||
const auto it = m_hashFs9Clients.find(callsign);
|
||||
if (it == m_hashFs9Clients.end()) { return false; }
|
||||
QTimer::singleShot(0, it->data(), [client = *it, mode] { client->getInterpolator()->setMode(mode); });
|
||||
// Always return true if we were setting the mode, since we cannot easily access the return value from
|
||||
// CInterpolatorMulti::setMode in a thread safe manner.
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CSimulatorFs9::isPhysicallyRenderedAircraft(const CCallsign &callsign) const
|
||||
{
|
||||
return m_hashFs9Clients.contains(callsign);
|
||||
|
||||
@@ -106,22 +106,10 @@ namespace BlackSimPlugin
|
||||
return this->hasValidRequestId() && this->hasValidObjectId();
|
||||
}
|
||||
|
||||
void CSimConnectObject::toggleInterpolatorMode()
|
||||
QString CSimConnectObject::getInterpolatorInfo(CInterpolationAndRenderingSetupBase::InterpolatorMode mode) const
|
||||
{
|
||||
Q_ASSERT(m_interpolator);
|
||||
m_interpolator->toggleMode();
|
||||
}
|
||||
|
||||
bool CSimConnectObject::setInterpolatorMode(CInterpolatorMulti::Mode mode)
|
||||
{
|
||||
Q_ASSERT(m_interpolator);
|
||||
return m_interpolator->setMode(mode);
|
||||
}
|
||||
|
||||
QString CSimConnectObject::getInterpolatorInfo() const
|
||||
{
|
||||
Q_ASSERT(m_interpolator);
|
||||
return m_interpolator->getInterpolatorInfo();
|
||||
return m_interpolator->getInterpolatorInfo(mode);
|
||||
}
|
||||
|
||||
void CSimConnectObject::attachInterpolatorLogger(CInterpolationLogger *logger)
|
||||
@@ -157,10 +145,10 @@ namespace BlackSimPlugin
|
||||
return m_interpolator->getInterpolatedOrGuessedParts(currentTimeSinceEpoc, setup, partsStatus, log);
|
||||
}
|
||||
|
||||
const CAircraftSituation &CSimConnectObject::getLastInterpolatedSituation() const
|
||||
const CAircraftSituation &CSimConnectObject::getLastInterpolatedSituation(CInterpolationAndRenderingSetupBase::InterpolatorMode mode) const
|
||||
{
|
||||
if (!m_interpolator) { return CAircraftSituation::null(); }
|
||||
return m_interpolator->getLastInterpolatedSituation();
|
||||
return m_interpolator->getLastInterpolatedSituation(mode);
|
||||
}
|
||||
|
||||
bool CSimConnectObjects::setSimConnectObjectIdForRequestId(DWORD requestId, DWORD objectId, bool resetSentParts)
|
||||
@@ -324,29 +312,5 @@ namespace BlackSimPlugin
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CSimConnectObjects::toggleInterpolatorModes()
|
||||
{
|
||||
for (const CCallsign &cs : this->keys())
|
||||
{
|
||||
(*this)[cs].toggleInterpolatorMode();
|
||||
}
|
||||
}
|
||||
|
||||
void CSimConnectObjects::toggleInterpolatorMode(const CCallsign &callsign)
|
||||
{
|
||||
if (!this->contains(callsign)) { return; }
|
||||
(*this)[callsign].toggleInterpolatorMode();
|
||||
}
|
||||
|
||||
int CSimConnectObjects::setInterpolatorModes(CInterpolatorMulti::Mode mode)
|
||||
{
|
||||
int c = 0;
|
||||
for (const CCallsign &cs : this->keys())
|
||||
{
|
||||
if ((*this)[cs].setInterpolatorMode(mode)) c++;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -163,11 +163,8 @@ namespace BlackSimPlugin
|
||||
//! \copydoc BlackMisc::Simulation::CInterpolatorMulti::toggleMode
|
||||
void toggleInterpolatorMode();
|
||||
|
||||
//! \copydoc BlackMisc::Simulation::CInterpolatorMulti::setMode
|
||||
bool setInterpolatorMode(BlackMisc::Simulation::CInterpolatorMulti::Mode mode);
|
||||
|
||||
//! \copydoc BlackMisc::Simulation::CInterpolator::getInterpolatorInfo
|
||||
QString getInterpolatorInfo() const;
|
||||
QString getInterpolatorInfo(BlackMisc::Simulation::CInterpolationAndRenderingSetupBase::InterpolatorMode mode) const;
|
||||
|
||||
//! \copydoc BlackMisc::Simulation::CInterpolator::attachLogger
|
||||
void attachInterpolatorLogger(BlackMisc::Simulation::CInterpolationLogger *logger);
|
||||
@@ -191,7 +188,7 @@ namespace BlackSimPlugin
|
||||
BlackMisc::Simulation::CPartsStatus &partsStatus, bool log) const;
|
||||
|
||||
//! Last interpolated situation
|
||||
const BlackMisc::Aviation::CAircraftSituation &getLastInterpolatedSituation() const;
|
||||
const BlackMisc::Aviation::CAircraftSituation &getLastInterpolatedSituation(BlackMisc::Simulation::CInterpolationAndRenderingSetupBase::InterpolatorMode mode) const;
|
||||
|
||||
//! Interpolator
|
||||
BlackMisc::Simulation::CInterpolatorMulti *getInterpolator() const { return m_interpolator.data(); }
|
||||
@@ -274,15 +271,6 @@ namespace BlackSimPlugin
|
||||
|
||||
//! Contains object of type
|
||||
bool containsType(CSimConnectObject::SimObjectType type) const;
|
||||
|
||||
//! Toggle interpolator modes
|
||||
void toggleInterpolatorModes();
|
||||
|
||||
//! Toggle interpolator modes
|
||||
void toggleInterpolatorMode(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
//! Set interpolator modes
|
||||
int setInterpolatorModes(BlackMisc::Simulation::CInterpolatorMulti::Mode mode);
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -242,21 +242,6 @@ namespace BlackSimPlugin
|
||||
return CCallsignSet(m_simConnectObjects.keys());
|
||||
}
|
||||
|
||||
bool CSimulatorFsxCommon::setInterpolatorMode(CInterpolatorMulti::Mode mode, const CCallsign &callsign)
|
||||
{
|
||||
if (mode == CInterpolatorMulti::ModeUnknown) { return false; }
|
||||
if (callsign.isEmpty())
|
||||
{
|
||||
const int c = m_simConnectObjects.setInterpolatorModes(mode);
|
||||
return c > 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!m_simConnectObjects.contains(callsign)) { return false; }
|
||||
return m_simConnectObjects[callsign].setInterpolatorMode(mode);
|
||||
}
|
||||
}
|
||||
|
||||
CStatusMessageList CSimulatorFsxCommon::debugVerifyStateAfterAllAircraftRemoved() const
|
||||
{
|
||||
CStatusMessageList msgs;
|
||||
@@ -539,7 +524,8 @@ namespace BlackSimPlugin
|
||||
|
||||
// CElevationPlane: deg, deg, feet
|
||||
// we only remember near ground
|
||||
if (simObject.getLastInterpolatedSituation().canLikelySkipNearGroundInterpolation()) { return; }
|
||||
const CInterpolationAndRenderingSetupPerCallsign setup = this->getInterpolationSetupPerCallsignOrDefault(simObject.getCallsign());
|
||||
if (simObject.getLastInterpolatedSituation(setup.getInterpolatorMode()).canLikelySkipNearGroundInterpolation()) { return; }
|
||||
|
||||
CElevationPlane elevation(remoteAircraftData.latitudeDeg, remoteAircraftData.longitudeDeg, remoteAircraftData.elevationFt);
|
||||
elevation.setSinglePointRadius();
|
||||
@@ -763,10 +749,11 @@ namespace BlackSimPlugin
|
||||
CStatusMessage msg;
|
||||
if (!simObject.getAircraftModelString().isEmpty())
|
||||
{
|
||||
const CInterpolationAndRenderingSetupPerCallsign setup = this->getInterpolationSetupPerCallsignOrDefault(callsign);
|
||||
m_addPendingAircraft.replaceOrAddByCallsign(simObject.getAircraft());
|
||||
msg = CLogMessage(this).warning("Aircraft removed, '%1' '%2' object id '%3' out of reality bubble or other reason. Interpolator: '%4'")
|
||||
<< callsign.toQString() << simObject.getAircraftModelString()
|
||||
<< objectID << simObject.getInterpolatorInfo();
|
||||
<< objectID << simObject.getInterpolatorInfo(setup.getInterpolatorMode());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -127,7 +127,6 @@ namespace BlackSimPlugin
|
||||
virtual void displayTextMessage(const BlackMisc::Network::CTextMessage &message) const override;
|
||||
virtual bool isPhysicallyRenderedAircraft(const BlackMisc::Aviation::CCallsign &callsign) const override;
|
||||
virtual BlackMisc::Aviation::CCallsignSet physicallyRenderedAircraft() const override;
|
||||
virtual bool setInterpolatorMode(BlackMisc::Simulation::CInterpolatorMulti::Mode mode, const BlackMisc::Aviation::CCallsign &callsign) override;
|
||||
virtual void clearAllRemoteAircraftData() override;
|
||||
virtual BlackMisc::CStatusMessageList debugVerifyStateAfterAllAircraftRemoved() const override;
|
||||
//! @}
|
||||
|
||||
@@ -369,23 +369,6 @@ namespace BlackSimPlugin
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CSimulatorXPlane::setInterpolatorMode(CInterpolatorMulti::Mode mode, const CCallsign &callsign)
|
||||
{
|
||||
if (!isConnected()) { return false; }
|
||||
|
||||
if (mode == CInterpolatorMulti::ModeUnknown) { return false; }
|
||||
if (callsign.isEmpty())
|
||||
{
|
||||
const int c = m_xplaneAircraftObjects.setInterpolatorModes(mode);
|
||||
return c > 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!m_xplaneAircraftObjects.contains(callsign)) { return false; }
|
||||
return m_xplaneAircraftObjects[callsign].setInterpolatorMode(mode);
|
||||
}
|
||||
}
|
||||
|
||||
QDBusConnection CSimulatorXPlane::connectionFromString(const QString &str)
|
||||
{
|
||||
if (str == CDBusServer::sessionBusAddress()) { return QDBusConnection::sessionBus(); }
|
||||
|
||||
@@ -134,7 +134,6 @@ namespace BlackSimPlugin
|
||||
virtual BlackMisc::Aviation::CAirportList getAirportsInRange() const override;
|
||||
virtual bool setTimeSynchronization(bool enable, const BlackMisc::PhysicalQuantities::CTime &offset) override;
|
||||
virtual BlackMisc::PhysicalQuantities::CTime getTimeSynchronizationOffset() const override { return BlackMisc::PhysicalQuantities::CTime(0, BlackMisc::PhysicalQuantities::CTimeUnit::hrmin()); }
|
||||
virtual bool setInterpolatorMode(BlackMisc::Simulation::CInterpolatorMulti::Mode mode, const BlackMisc::Aviation::CCallsign &callsign) override;
|
||||
virtual void unload() override;
|
||||
//! @}
|
||||
|
||||
|
||||
@@ -36,22 +36,10 @@ namespace BlackSimPlugin
|
||||
return m_situationAsSent == position;
|
||||
}
|
||||
|
||||
void CXPlaneMPAircraft::toggleInterpolatorMode()
|
||||
QString CXPlaneMPAircraft::getInterpolatorInfo(CInterpolationAndRenderingSetupBase::InterpolatorMode mode) const
|
||||
{
|
||||
Q_ASSERT(m_interpolator);
|
||||
m_interpolator->toggleMode();
|
||||
}
|
||||
|
||||
bool CXPlaneMPAircraft::setInterpolatorMode(CInterpolatorMulti::Mode mode)
|
||||
{
|
||||
Q_ASSERT(m_interpolator);
|
||||
return m_interpolator->setMode(mode);
|
||||
}
|
||||
|
||||
QString CXPlaneMPAircraft::getInterpolatorInfo() const
|
||||
{
|
||||
Q_ASSERT(m_interpolator);
|
||||
return m_interpolator->getInterpolatorInfo();
|
||||
return m_interpolator->getInterpolatorInfo(mode);
|
||||
}
|
||||
|
||||
void CXPlaneMPAircraft::attachInterpolatorLogger(CInterpolationLogger *logger)
|
||||
@@ -91,15 +79,5 @@ namespace BlackSimPlugin
|
||||
{
|
||||
return CCallsignSet(this->keys());
|
||||
}
|
||||
|
||||
int CXPlaneMPAircraftObjects::setInterpolatorModes(CInterpolatorMulti::Mode mode)
|
||||
{
|
||||
int c = 0;
|
||||
for (const CCallsign &cs : this->keys())
|
||||
{
|
||||
if ((*this)[cs].setInterpolatorMode(mode)) c++;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -70,14 +70,8 @@ namespace BlackSimPlugin
|
||||
//! Engine count
|
||||
int getEngineCount() const { return m_aircraft.getEnginesCount(); }
|
||||
|
||||
//! \copydoc BlackMisc::Simulation::CInterpolatorMulti::toggleMode
|
||||
void toggleInterpolatorMode();
|
||||
|
||||
//! \copydoc BlackMisc::Simulation::CInterpolatorMulti::setMode
|
||||
bool setInterpolatorMode(BlackMisc::Simulation::CInterpolatorMulti::Mode mode);
|
||||
|
||||
//! \copydoc BlackMisc::Simulation::CInterpolator::getInterpolatorInfo
|
||||
QString getInterpolatorInfo() const;
|
||||
QString getInterpolatorInfo(BlackMisc::Simulation::CInterpolationAndRenderingSetupBase::InterpolatorMode mode) const;
|
||||
|
||||
//! \copydoc BlackMisc::Simulation::CInterpolator::attachLogger
|
||||
void attachInterpolatorLogger(BlackMisc::Simulation::CInterpolationLogger *logger);
|
||||
@@ -128,9 +122,6 @@ namespace BlackSimPlugin
|
||||
|
||||
//! Toggle interpolator modes
|
||||
void toggleInterpolatorMode(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
//! Set interpolator modes
|
||||
int setInterpolatorModes(BlackMisc::Simulation::CInterpolatorMulti::Mode mode);
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user