mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 15:15:50 +08:00
refs #484 Added value class for working with X-Plane nav data, CNavDataReference.
This commit is contained in:
58
src/blackmisc/simulation/xplane/navdatareference.cpp
Normal file
58
src/blackmisc/simulation/xplane/navdatareference.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
/* Copyright (C) 2015
|
||||
* 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.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#include "blackmisc/simulation/xplane/navdatareference.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Simulation
|
||||
{
|
||||
namespace XPlane
|
||||
{
|
||||
CNavDataReference::CNavDataReference() = default;
|
||||
|
||||
CNavDataReference::CNavDataReference(int id, const Geo::CLatitude &latitude, const Geo::CLongitude &longitude) :
|
||||
m_id(id),
|
||||
m_position(latitude, longitude, {})
|
||||
{}
|
||||
|
||||
CNavDataReference::CNavDataReference(int id, float latitudeDegrees, float longitudeDegrees) :
|
||||
m_id(id),
|
||||
m_position(latitudeDegrees, longitudeDegrees, 0)
|
||||
{}
|
||||
|
||||
CVariant CNavDataReference::propertyByIndex(const BlackMisc::CPropertyIndex &index) const
|
||||
{
|
||||
if (index.isMyself()) { return CVariant::from(*this); }
|
||||
return ICoordinateGeodetic::canHandleIndex(index) ?
|
||||
ICoordinateGeodetic::propertyByIndex(index) :
|
||||
CValueObject::propertyByIndex(index);
|
||||
}
|
||||
|
||||
void CNavDataReference::setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index)
|
||||
{
|
||||
if (index.isMyself()) { (*this) = variant.to<CNavDataReference>(); return; }
|
||||
CValueObject::setPropertyByIndex(variant, index);
|
||||
}
|
||||
|
||||
QString CNavDataReference::convertToQString(bool i18n) const
|
||||
{
|
||||
return QString::number(id()) + ":" + m_position.convertToQString(i18n);
|
||||
}
|
||||
|
||||
CNavDataReferenceList::CNavDataReferenceList() = default;
|
||||
|
||||
CNavDataReferenceList::CNavDataReferenceList(const CSequence<CNavDataReference> &other) :
|
||||
CSequence<CNavDataReference>(other)
|
||||
{}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user