mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 07:35:48 +08:00
* Include only what is used * Use forward declaration when possible * Sorted includes refs #630
116 lines
4.3 KiB
C++
116 lines
4.3 KiB
C++
/* 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/gridpoint.h"
|
|
#include "blackmisc/propertyindex.h"
|
|
#include "blackmisc/variant.h"
|
|
|
|
#include <QtDebug>
|
|
|
|
using namespace BlackMisc::Aviation;
|
|
using namespace BlackMisc::Geo;
|
|
using namespace BlackMisc::PhysicalQuantities;
|
|
|
|
namespace BlackMisc
|
|
{
|
|
namespace Weather
|
|
{
|
|
CGridPoint::CGridPoint(const QString &identifier,
|
|
const Geo::CCoordinateGeodetic &position) :
|
|
m_identifier(identifier),
|
|
m_position(position)
|
|
{ }
|
|
|
|
CGridPoint::CGridPoint(const QString &identifier,
|
|
const Geo::CCoordinateGeodetic &position,
|
|
const CCloudLayerList &cloudLayers,
|
|
const CTemperatureLayerList &temperatureLayers,
|
|
const CVisibilityLayerList &visibilityLayers,
|
|
const CWindLayerList &windLayers,
|
|
const CPressure &surfacePressure) :
|
|
m_identifier(identifier),
|
|
m_position(position),
|
|
m_cloudLayers(cloudLayers),
|
|
m_temperatureLayers(temperatureLayers),
|
|
m_visibilityLayers(visibilityLayers),
|
|
m_windLayers(windLayers),
|
|
m_surfacePressure(surfacePressure)
|
|
{ }
|
|
|
|
void CGridPoint::copyWeatherDataFrom(const CGridPoint &other)
|
|
{
|
|
setCloudLayers(other.getCloudLayers());
|
|
setTemperatureLayers(other.getTemperatureLayers());
|
|
setVisibilityLayers(other.getVisibilityLayers());
|
|
setWindLayers(other.getWindLayers());
|
|
setSurfacePressure(other.getSurfacePressure());
|
|
}
|
|
|
|
CVariant CGridPoint::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
|
{
|
|
if (index.isMyself()) { return CVariant::from(*this); }
|
|
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
|
switch (i)
|
|
{
|
|
case IndexIdentifier:
|
|
return CVariant::fromValue(m_identifier);
|
|
case IndexPosition:
|
|
return CVariant::fromValue(m_position);
|
|
case IndexCloudLayers:
|
|
return CVariant::fromValue(m_cloudLayers);
|
|
case IndexTemperatureLayers:
|
|
return CVariant::fromValue(m_temperatureLayers);
|
|
case IndexWindLayers:
|
|
return CVariant::fromValue(m_windLayers);
|
|
case IndexSurfacePressure:
|
|
return CVariant::fromValue(m_surfacePressure);
|
|
default:
|
|
return CValueObject::propertyByIndex(index);
|
|
}
|
|
}
|
|
|
|
void CGridPoint::setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant)
|
|
{
|
|
if (index.isMyself()) { (*this) = variant.to<CGridPoint>(); return; }
|
|
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
|
switch (i)
|
|
{
|
|
case IndexIdentifier:
|
|
setIdentifier(variant.value<QString>());
|
|
break;
|
|
case IndexPosition:
|
|
setPosition(variant.value<CCoordinateGeodetic>());
|
|
break;
|
|
case IndexCloudLayers:
|
|
setCloudLayers(variant.value<CCloudLayerList>());
|
|
break;
|
|
case IndexTemperatureLayers:
|
|
setTemperatureLayers(variant.value<CTemperatureLayerList>());
|
|
break;
|
|
case IndexWindLayers:
|
|
setWindLayers(variant.value<CWindLayerList>());
|
|
break;
|
|
case IndexSurfacePressure:
|
|
setSurfacePressure(variant.value<CPressure>());
|
|
break;
|
|
default:
|
|
CValueObject::setPropertyByIndex(index, variant);
|
|
break;
|
|
}
|
|
}
|
|
|
|
QString CGridPoint::convertToQString(bool /** i18n **/) const
|
|
{
|
|
qFatal("Not yet implemented!");
|
|
return {};
|
|
}
|
|
|
|
} // namespace
|
|
} // namespace
|