6 using namespace swift::misc::aviation;
8 namespace swift::misc::simulation
10 CInterpolationAndRenderingSetupPerCallsign
11 IInterpolationSetupProvider::getInterpolationSetupPerCallsignOrDefault(
const CCallsign &callsign)
const
14 if (!m_setupsPerCallsign.contains(callsign)) {
return { callsign, m_globalSetup }; }
15 return m_setupsPerCallsign.value(callsign);
18 CInterpolationSetupList IInterpolationSetupProvider::getInterpolationSetupsPerCallsign()
const
21 return { setups.
values() };
24 bool IInterpolationSetupProvider::hasSetupsPerCallsign()
const
27 return !m_setupsPerCallsign.isEmpty();
30 bool IInterpolationSetupProvider::setInterpolationSetupsPerCallsign(
const CInterpolationSetupList &setups,
31 bool ignoreSameAsGlobal)
37 if (ignoreSameAsGlobal && setup.isEqualToGlobal(gs)) {
continue; }
38 setupsPerCs.
insert(setup.getCallsign(), setup);
42 if (m_setupsPerCallsign.isEmpty() && setupsPerCs.
isEmpty()) {
return false; }
43 m_setupsPerCallsign = setupsPerCs;
45 this->emitInterpolationSetupChanged();
61 if (setup.logInterpolation()) { callsigns.
insert(callsign); }
66 bool IInterpolationSetupProvider::isLogCallsign(
const CCallsign &callsign)
const
69 if (!m_setupsPerCallsign.contains(callsign)) {
return false; }
70 return m_setupsPerCallsign[callsign].logInterpolation();
73 bool IInterpolationSetupProvider::setInterpolationMode(
const QString &modeAsString,
const CCallsign &callsign)
79 return this->setInterpolationSetupPerCallsign(setup, callsign,
true);
82 bool IInterpolationSetupProvider::setLogInterpolation(
bool log,
const CCallsign &callsign)
88 return this->setInterpolationSetupPerCallsign(setup, callsign,
true);
95 if (m_globalSetup == setup) {
return false; }
96 m_globalSetup = setup;
98 this->emitInterpolationSetupChanged();
102 bool IInterpolationSetupProvider::setInterpolationSetupPerCallsign(
105 if (removeGlobalSetup)
111 m_setupsPerCallsign.remove(callsign);
117 m_setupsPerCallsign[callsign] = setup;
119 this->emitInterpolationSetupChanged();
123 bool IInterpolationSetupProvider::removeInterpolationSetupPerCallsign(
const CCallsign &callsign)
125 bool removed =
false;
128 removed = m_setupsPerCallsign.remove(callsign) > 0;
130 if (removed) { this->emitInterpolationSetupChanged(); }
134 void IInterpolationSetupProvider::setLogCallsign(
bool log,
const CCallsign &callsign)
139 this->setInterpolationSetupPerCallsign(setup, callsign);
142 void IInterpolationSetupProvider::clearInterpolationLogCallsigns()
145 if (setupsCopy.
isEmpty()) {
return; }
153 setup.setLogInterpolation(
false);
154 if (setup.isEqualToGlobal(global)) {
continue; }
155 setupsToKeep.
insert(callsign, setup);
159 m_setupsPerCallsign = setupsToKeep;
161 this->emitInterpolationSetupChanged();
164 int IInterpolationSetupProvider::clearInterpolationSetupsPerCallsign()
169 r = m_setupsPerCallsign.size();
170 m_setupsPerCallsign.clear();
173 if (r > 0) { this->emitInterpolationSetupChanged(); }
177 bool IInterpolationSetupProvider::logAnyCallsign()
const
180 if (setupsCopy.
isEmpty()) {
return false; }
189 return m_setupsPerCallsign;
193 void CInterpolationSetupAware::anchor() {}
195 CInterpolationAndRenderingSetupPerCallsign
196 CInterpolationSetupAware::getInterpolationSetupPerCallsignOrDefault(
const CCallsign &callsign)
const
198 if (!this->hasProvider()) {
return {}; }
199 return this->provider()->getInterpolationSetupPerCallsignOrDefault(callsign);
204 if (!this->hasProvider()) {
return {}; }
205 return this->provider()->getInterpolationSetupGlobal();
iterator insert(const_iterator hint, const T &value)
For compatibility with std::inserter.
Value object encapsulating information of a callsign.
Value object for a set of callsigns.
bool setLogInterpolation(bool log)
Log.interpolation.
bool logInterpolation() const
Log.interpolation.
bool setInterpolatorMode(InterpolatorMode mode)
Set interpolator mode.
Value object for interpolator and rendering.
Value object for interpolator and rendering per callsign.
bool isEqualToGlobal(const CInterpolationAndRenderingSetupGlobal &globalSetup) const
Equal to global setup?
auto makePairsRange(const T &container)
Returns a const CRange for iterating over the keys and values of a Qt associative container.
QMap< Key, T >::const_iterator cbegin() const const
QMap< Key, T >::const_iterator cend() const const
QMap< Key, T >::iterator insert(QMap< Key, T >::const_iterator pos, const Key &key, const T &value)
bool isEmpty() const const
QList< T > values() const const