swift
Loading...
Searching...
No Matches
heading.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) 2013 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
6#ifndef SWIFT_MISC_AVIATION_HEADING_H
7#define SWIFT_MISC_AVIATION_HEADING_H
8
9#include <QMetaType>
10#include <QString>
11
12#include "misc/metaclass.h"
20#include "misc/pq/angle.h"
21#include "misc/pq/units.h"
23
24namespace swift::misc::aviation
25{
32 public mixin::MetaType<CHeading>,
33 public mixin::EqualsByMetaClass<CHeading>,
34 public mixin::CompareByMetaClass<CHeading>,
35 public mixin::HashByMetaClass<CHeading>,
36 public mixin::DBusByMetaClass<CHeading>,
37 public mixin::DataStreamByMetaClass<CHeading>,
38 public mixin::JsonByMetaClass<CHeading>,
39 public mixin::String<CHeading>,
40 public mixin::Index<CHeading>
41 {
42 public:
45
52
53
55 {
57 True = 1
58 };
59
61 QString convertToQString(bool i18n = false) const;
62
64 CHeading() : CAngle(0, physical_quantities::CAngleUnit::rad()), m_north(True) {}
65
67 CHeading(double value, const physical_quantities::CAngleUnit &unit) : CAngle(value, unit), m_north(True) {}
68
71 : CAngle(value, unit), m_north(north)
72 {}
73
75 CHeading(const CAngle &heading, ReferenceNorth north) : CAngle(heading), m_north(north) {}
76
78 bool isMagneticHeading() const { return Magnetic == this->m_north; }
79
81 bool isTrueHeading() const { return True == this->m_north; }
82
84 ReferenceNorth getReferenceNorth() const { return m_north; }
85
87 void normalizeTo360Degrees();
88
90 void normalizeToPlusMinus180Degrees();
91
93 CHeading normalizedToPlusMinus180Degrees() const;
94
96 CHeading normalizedTo360Degrees() const;
97
99 static void registerMetadata();
100
101 private:
102 ReferenceNorth m_north;
103
105 CHeading,
106 SWIFT_METAMEMBER(north));
107 };
108} // namespace swift::misc::aviation
109
110Q_DECLARE_METATYPE(swift::misc::aviation::CHeading)
112
113#endif // SWIFT_MISC_AVIATION_HEADING_H
Specialized class for angles (degrees, radian).
Definition units.h:231
Heading as used in aviation, can be true or magnetic heading.
Definition heading.h:41
ReferenceNorth getReferenceNorth() const
Get reference north (magnetic or true).
Definition heading.h:84
CHeading(double value, const physical_quantities::CAngleUnit &unit)
Constructor.
Definition heading.h:67
CHeading()
Default constructor: 0.
Definition heading.h:64
CHeading(const CAngle &heading, ReferenceNorth north)
Constructor by CAngle.
Definition heading.h:75
physical_quantities::CAngle base_type
Base type.
Definition heading.h:44
bool isMagneticHeading() const
Magnetic heading?
Definition heading.h:78
bool isTrueHeading() const
True heading?
Definition heading.h:81
CHeading(double value, ReferenceNorth north, const physical_quantities::CAngleUnit &unit)
Constructor.
Definition heading.h:70
ReferenceNorth
Enum type to distinguish between true north and magnetic north.
Definition heading.h:55
CRTP class template from which a derived class can inherit non-member compare() implemented by metacl...
CRTP class template from which a derived class can inherit common methods dealing with marshalling in...
Definition mixindbus.h:71
CRTP class template to generate QDataStream marshalling methods using CMetaClass.
CRTP class template from which a derived class can inherit operator== implemented by metaclass.
CRTP class template from which a derived class can inherit common methods dealing with hashing instan...
Definition mixinhash.h:48
CRTP class template from which a derived class can inherit property indexing functions.
Definition mixinindex.h:40
CRTP class template from which a derived class can inherit common methods dealing with JSON by metatu...
Definition mixinjson.h:90
CRTP class template from which a derived class can inherit common methods dealing with the metatype o...
CRTP class template from which a derived class can inherit string streaming operations.
Definition mixinstring.h:29
Physical unit angle (radians, degrees).
Definition angle.h:23
CAngle()
Default constructor.
Definition angle.h:26
Specialized class for angles (degrees, radian).
Definition units.h:231
#define SWIFT_METAMEMBER(MEMBER,...)
Macro to define an element within a metaclass.
Definition metaclass.h:72
#define SWIFT_METACLASS(CLASS,...)
Macro to define a nested metaclass that describes the attributes of its enclosing class.
Definition metaclass.h:52
#define SWIFT_MISC_DECLARE_USING_MIXIN_DATASTREAM(DERIVED)
When a derived class and a base class both inherit from mixin::DataStreamByMetaClass,...
#define SWIFT_MISC_DECLARE_USING_MIXIN_DBUS(DERIVED,...)
When a derived class and a base class both inherit from mixin::DBusByTuple, the derived class uses th...
Definition mixindbus.h:193
#define SWIFT_MISC_DECLARE_USING_MIXIN_INDEX(DERIVED)
When a derived class and a base class both inherit from mixin::Index, the derived class uses this mac...
Definition mixinindex.h:159
#define SWIFT_MISC_DECLARE_USING_MIXIN_JSON(DERIVED)
When a derived class and a base class both inherit from mixin::JsonByTuple, the derived class uses th...
Definition mixinjson.h:287
#define SWIFT_MISC_DECLARE_USING_MIXIN_METATYPE(DERIVED)
When a derived class and a base class both inherit from mixin::MetaType, the derived class uses this ...
#define SWIFT_MISC_DECLARE_USING_MIXIN_STRING(DERIVED)
When a derived class and a base class both inherit from mixin::String, the derived class uses this ma...
#define SWIFT_MISC_EXPORT
Export a class or function from the library.