mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 04:45:31 +08:00
committed by
Mathew Sutcliffe
parent
229d7c6068
commit
978f3c88e5
@@ -9,127 +9,118 @@
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Aviation
|
||||
{
|
||||
|
||||
/*!
|
||||
* \brief Track as used in aviation, can be true or magnetic Track
|
||||
* \remarks Intentionally allowing +/- BlackMisc::PhysicalQuantities::CAngle , and >= / <= CAngle.
|
||||
*/
|
||||
class CTrack : public BlackMisc::PhysicalQuantities::CAngle
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* Enum type to distinguish between true north and magnetic north
|
||||
*/
|
||||
enum ReferenceNorth
|
||||
namespace Aviation
|
||||
{
|
||||
Magnetic = 0, //!< magnetic north
|
||||
True = 1, //!< true north
|
||||
};
|
||||
|
||||
private:
|
||||
ReferenceNorth m_north; //!< magnetic or true?
|
||||
/*!
|
||||
* \brief Track as used in aviation, can be true or magnetic Track
|
||||
* \remarks Intentionally allowing +/- BlackMisc::PhysicalQuantities::CAngle ,
|
||||
* and >= / <= CAngle.
|
||||
*/
|
||||
class CTrack : public BlackMisc::PhysicalQuantities::CAngle
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* Enum type to distinguish between true north and magnetic north
|
||||
*/
|
||||
enum ReferenceNorth
|
||||
{
|
||||
Magnetic = 0, //!< magnetic north
|
||||
True = 1 //!< true north
|
||||
};
|
||||
|
||||
protected:
|
||||
/*!
|
||||
* \brief Specific stream operation for Track
|
||||
* \return
|
||||
*/
|
||||
virtual QString convertToQString(bool i18n = false) const;
|
||||
private:
|
||||
ReferenceNorth m_north; //!< magnetic or true?
|
||||
|
||||
/*!
|
||||
* \brief Stream to DBus <<
|
||||
* \param argument
|
||||
*/
|
||||
virtual void marshallToDbus(QDBusArgument &argument) const
|
||||
{
|
||||
this->CAngle::marshallToDbus(argument);
|
||||
argument << qint32(this->m_north);
|
||||
}
|
||||
protected:
|
||||
/*!
|
||||
* \brief Specific stream operation for Track
|
||||
* \return
|
||||
*/
|
||||
virtual QString convertToQString(bool i18n = false) const;
|
||||
|
||||
/*!
|
||||
* \brief Stream from DBus >>
|
||||
* \param argument
|
||||
*/
|
||||
virtual void unmarshallFromDbus(const QDBusArgument &argument)
|
||||
{
|
||||
this->CAngle::unmarshallFromDbus(argument);
|
||||
qint32 north;
|
||||
argument >> north;
|
||||
this->m_north = static_cast<ReferenceNorth>(north);
|
||||
}
|
||||
/*!
|
||||
* \brief Stream to DBus <<
|
||||
* \param argument
|
||||
*/
|
||||
virtual void marshallToDbus(QDBusArgument &argument) const;
|
||||
|
||||
public:
|
||||
/*!
|
||||
* \brief Default constructor: 0 Track magnetic
|
||||
*/
|
||||
CTrack() : BlackMisc::PhysicalQuantities::CAngle(0, BlackMisc::PhysicalQuantities::CAngleUnit::rad()), m_north(Magnetic) {}
|
||||
/*!
|
||||
* \brief Stream from DBus >>
|
||||
* \param argument
|
||||
*/
|
||||
virtual void unmarshallFromDbus(const QDBusArgument &argument);
|
||||
|
||||
/*!
|
||||
* \brief Constructor
|
||||
* \param value
|
||||
* \param north
|
||||
* \param unit
|
||||
*/
|
||||
CTrack(double value, ReferenceNorth north, const BlackMisc::PhysicalQuantities::CAngleUnit &unit) : BlackMisc::PhysicalQuantities::CAngle(value, unit), m_north(north) {}
|
||||
public:
|
||||
/*!
|
||||
* \brief Default constructor: 0 Track magnetic
|
||||
*/
|
||||
CTrack() : BlackMisc::PhysicalQuantities::CAngle(0, BlackMisc::PhysicalQuantities::CAngleUnit::rad()), m_north(Magnetic) {}
|
||||
|
||||
/*!
|
||||
* \brief Constructor by CAngle
|
||||
* \param track
|
||||
* \param north
|
||||
*/
|
||||
CTrack(BlackMisc::PhysicalQuantities::CAngle track, ReferenceNorth north) : BlackMisc::PhysicalQuantities::CAngle(track), m_north(north) {}
|
||||
/*!
|
||||
* \brief Constructor
|
||||
* \param value
|
||||
* \param north
|
||||
* \param unit
|
||||
*/
|
||||
CTrack(double value, ReferenceNorth north, const BlackMisc::PhysicalQuantities::CAngleUnit &unit) : BlackMisc::PhysicalQuantities::CAngle(value, unit), m_north(north) {}
|
||||
|
||||
/*!
|
||||
* \brief Equal operator ==
|
||||
* \param other
|
||||
* \return
|
||||
*/
|
||||
bool operator ==(const CTrack &other);
|
||||
/*!
|
||||
* \brief Constructor by CAngle
|
||||
* \param track
|
||||
* \param north
|
||||
*/
|
||||
CTrack(BlackMisc::PhysicalQuantities::CAngle track, ReferenceNorth north) : BlackMisc::PhysicalQuantities::CAngle(track), m_north(north) {}
|
||||
|
||||
/*!
|
||||
* \brief Unequal operator ==
|
||||
* \param other
|
||||
* \return
|
||||
*/
|
||||
bool operator !=(const CTrack &other);
|
||||
/*!
|
||||
* \brief Equal operator ==
|
||||
* \param other
|
||||
* \return
|
||||
*/
|
||||
bool operator ==(const CTrack &other) const;
|
||||
|
||||
/*!
|
||||
* \brief Magnetic Track?
|
||||
* \return
|
||||
*/
|
||||
bool isMagneticTrack() const
|
||||
{
|
||||
return Magnetic == this->m_north;
|
||||
(void)QT_TRANSLATE_NOOP("Aviation", "magnetic");
|
||||
}
|
||||
/*!
|
||||
* \brief Unequal operator ==
|
||||
* \param other
|
||||
* \return
|
||||
*/
|
||||
bool operator !=(const CTrack &other) const;
|
||||
|
||||
/*!
|
||||
* \brief True Track?
|
||||
* \return
|
||||
*/
|
||||
bool isTrueTrack() const
|
||||
{
|
||||
return True == this->m_north;
|
||||
(void)QT_TRANSLATE_NOOP("Aviation", "true");
|
||||
}
|
||||
/*!
|
||||
* \brief Magnetic Track?
|
||||
* \return
|
||||
*/
|
||||
bool isMagneticTrack() const
|
||||
{
|
||||
return Magnetic == this->m_north;
|
||||
(void)QT_TRANSLATE_NOOP("Aviation", "magnetic");
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Get reference north (magnetic or true)
|
||||
* \return
|
||||
*/
|
||||
ReferenceNorth getReferenceNorth() const { return m_north; }
|
||||
/*!
|
||||
* \brief True Track?
|
||||
* \return
|
||||
*/
|
||||
bool isTrueTrack() const
|
||||
{
|
||||
return True == this->m_north;
|
||||
(void)QT_TRANSLATE_NOOP("Aviation", "true");
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Register metadata
|
||||
*/
|
||||
static void registerMetadata();
|
||||
};
|
||||
/*!
|
||||
* \brief Get reference north (magnetic or true)
|
||||
* \return
|
||||
*/
|
||||
ReferenceNorth getReferenceNorth() const { return m_north; }
|
||||
|
||||
} // namespace
|
||||
/*!
|
||||
* \brief Register metadata
|
||||
*/
|
||||
static void registerMetadata();
|
||||
};
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_METATYPE(BlackMisc::Aviation::CTrack)
|
||||
|
||||
#endif // BLACKMISC_AVTRACK_H
|
||||
#endif // guard
|
||||
|
||||
Reference in New Issue
Block a user