mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 07:35:48 +08:00
Add CTemperatureLayer, CTemperatureLayerList and CWindLayerList classes
refs #556
This commit is contained in:
74
src/blackmisc/weather/temperaturelayer.cpp
Normal file
74
src/blackmisc/weather/temperaturelayer.cpp
Normal file
@@ -0,0 +1,74 @@
|
||||
/* Copyright (C) 2016
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "blackmisc/weather/temperaturelayer.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include "blackmisc/variant.h"
|
||||
|
||||
#include <tuple>
|
||||
#include <QRegularExpression>
|
||||
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Weather
|
||||
{
|
||||
|
||||
CTemperatureLayer::CTemperatureLayer(const CAltitude &level, const CTemperature &value, double relativeHumidity) :
|
||||
m_level(level), m_temperature(value), m_relativeHumidity(relativeHumidity)
|
||||
{ }
|
||||
|
||||
CVariant CTemperatureLayer::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return CVariant::from(*this); }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexLevel:
|
||||
return CVariant::fromValue(m_level);
|
||||
case IndexTemperature:
|
||||
return CVariant::fromValue(m_temperature);
|
||||
case IndexRelativeHumidity:
|
||||
return CVariant::fromValue(m_relativeHumidity);
|
||||
default:
|
||||
return CValueObject::propertyByIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
void CTemperatureLayer::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
{
|
||||
if (index.isMyself()) { (*this) = variant.to<CTemperatureLayer>(); return; }
|
||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
case IndexLevel:
|
||||
setLevel(variant.value<CAltitude>());
|
||||
break;
|
||||
case IndexTemperature:
|
||||
setTemperature(variant.value<CTemperature>());
|
||||
break;
|
||||
case IndexRelativeHumidity:
|
||||
setRelativeHumidity(variant.value<double>());
|
||||
break;
|
||||
default:
|
||||
CValueObject::setPropertyByIndex(variant, index);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QString CTemperatureLayer::convertToQString(bool /** i18n **/) const
|
||||
{
|
||||
return QString("%1 %2 at %3").arg(m_temperature.toQString(), QString::number(m_relativeHumidity), m_level.toQString());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
Reference in New Issue
Block a user