mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 21:15:33 +08:00
refs #742, allow to search by colors
* color distance in livery * and in container
This commit is contained in:
committed by
Mathew Sutcliffe
parent
940137b921
commit
74740991a3
@@ -74,6 +74,34 @@ namespace BlackMisc
|
||||
return this->findStdLiveryByAirlineIcaoVDesignator(icao.getVDesignator());
|
||||
}
|
||||
|
||||
CLivery CLiveryList::findColorLiveryOrDefault(const CRgbColor &fuselage, const CRgbColor &tail) const
|
||||
{
|
||||
if (!fuselage.isValid() || !tail.isValid()) { return CLivery(); }
|
||||
return this->findFirstByOrDefault([&](const CLivery & livery)
|
||||
{
|
||||
if (!livery.isColorLivery()) { return false; }
|
||||
return livery.matchesColors(fuselage, tail);
|
||||
});
|
||||
}
|
||||
|
||||
CLivery CLiveryList::findClosestColorLiveryOrDefault(const CRgbColor &fuselage, const CRgbColor &tail) const
|
||||
{
|
||||
if (!fuselage.isValid() || !tail.isValid()) { return CLivery(); }
|
||||
CLivery bestMatch;
|
||||
double bestDistance = 1.0;
|
||||
for (const CLivery &livery : *this)
|
||||
{
|
||||
double d = livery.getColorDistance(fuselage, tail);
|
||||
if (d == 0.0) { return livery; } // exact match
|
||||
if (d < bestDistance)
|
||||
{
|
||||
bestMatch = livery;
|
||||
bestDistance = d;
|
||||
}
|
||||
}
|
||||
return bestMatch;
|
||||
}
|
||||
|
||||
CLivery CLiveryList::findByCombinedCode(const QString &combinedCode) const
|
||||
{
|
||||
if (!CLivery::isValidCombinedCode(combinedCode)) { return CLivery(); }
|
||||
|
||||
Reference in New Issue
Block a user