6 using namespace swift::misc::aviation;
8 namespace swift::misc::simulation
10 CInterpolationAndRenderingSetupPerCallsign
11 IInterpolationSetupProvider::getInterpolationSetupPerCallsignOrDefault(
const CCallsign &callsign)
const
13 QReadLocker l(&m_lockSetup);
14 if (!m_setupsPerCallsign.contains(callsign))
18 return m_setupsPerCallsign.value(callsign);
21 CInterpolationSetupList IInterpolationSetupProvider::getInterpolationSetupsPerCallsign()
const
24 return CInterpolationSetupList(setups.values());
27 bool IInterpolationSetupProvider::hasSetupsPerCallsign()
const
29 QReadLocker l(&m_lockSetup);
30 return !m_setupsPerCallsign.isEmpty();
33 bool IInterpolationSetupProvider::setInterpolationSetupsPerCallsign(
const CInterpolationSetupList &setups,
34 bool ignoreSameAsGlobal)
40 if (ignoreSameAsGlobal && setup.isEqualToGlobal(gs)) {
continue; }
41 setupsPerCs.insert(setup.getCallsign(), setup);
44 QWriteLocker l(&m_lockSetup);
45 if (m_setupsPerCallsign.isEmpty() && setupsPerCs.isEmpty()) {
return false; }
46 m_setupsPerCallsign = setupsPerCs;
48 this->emitInterpolationSetupChanged();
54 QReadLocker l(&m_lockSetup);
64 if (setup.logInterpolation()) { callsigns.
insert(callsign); }
69 bool IInterpolationSetupProvider::isLogCallsign(
const CCallsign &callsign)
const
71 QReadLocker l(&m_lockSetup);
72 if (!m_setupsPerCallsign.contains(callsign)) {
return false; }
73 return m_setupsPerCallsign[callsign].logInterpolation();
76 bool IInterpolationSetupProvider::setInterpolationMode(
const QString &modeAsString,
const CCallsign &callsign)
82 return this->setInterpolationSetupPerCallsign(setup, callsign,
true);
85 bool IInterpolationSetupProvider::setLogInterpolation(
bool log,
const CCallsign &callsign)
91 return this->setInterpolationSetupPerCallsign(setup, callsign,
true);
97 QWriteLocker l(&m_lockSetup);
98 if (m_globalSetup == setup) {
return false; }
99 m_globalSetup = setup;
101 this->emitInterpolationSetupChanged();
105 bool IInterpolationSetupProvider::setInterpolationSetupPerCallsign(
108 if (removeGlobalSetup)
113 QWriteLocker l(&m_lockSetup);
114 m_setupsPerCallsign.remove(callsign);
119 QWriteLocker l(&m_lockSetup);
120 m_setupsPerCallsign[callsign] = setup;
122 this->emitInterpolationSetupChanged();
126 bool IInterpolationSetupProvider::removeInterpolationSetupPerCallsign(
const CCallsign &callsign)
128 bool removed =
false;
130 QWriteLocker l(&m_lockSetup);
131 removed = m_setupsPerCallsign.remove(callsign) > 0;
133 if (removed) { this->emitInterpolationSetupChanged(); }
137 void IInterpolationSetupProvider::setLogCallsign(
bool log,
const CCallsign &callsign)
142 this->setInterpolationSetupPerCallsign(setup, callsign);
145 void IInterpolationSetupProvider::clearInterpolationLogCallsigns()
148 if (setupsCopy.isEmpty()) {
return; }
156 setup.setLogInterpolation(
false);
157 if (setup.isEqualToGlobal(global)) {
continue; }
158 setupsToKeep.insert(callsign, setup);
161 QWriteLocker l(&m_lockSetup);
162 m_setupsPerCallsign = setupsToKeep;
164 this->emitInterpolationSetupChanged();
167 int IInterpolationSetupProvider::clearInterpolationSetupsPerCallsign()
171 QWriteLocker l(&m_lockSetup);
172 r = m_setupsPerCallsign.size();
173 m_setupsPerCallsign.clear();
176 if (r > 0) { this->emitInterpolationSetupChanged(); }
180 bool IInterpolationSetupProvider::logAnyCallsign()
const
183 if (setupsCopy.isEmpty()) {
return false; }
186 if (setup.logInterpolation()) {
return true; }
193 QReadLocker l(&m_lockSetup);
194 return m_setupsPerCallsign;
198 void CInterpolationSetupAware::anchor() {}
200 CInterpolationAndRenderingSetupPerCallsign
201 CInterpolationSetupAware::getInterpolationSetupPerCallsignOrDefault(
const CCallsign &callsign)
const
204 return this->provider()->getInterpolationSetupPerCallsignOrDefault(callsign);
210 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.