swift
track.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_TRACK_H
7 #define SWIFT_MISC_AVIATION_TRACK_H
8 
9 #include <QMetaType>
10 #include <QString>
11 #include <QtGlobal>
12 
13 #include "misc/metaclass.h"
15 #include "misc/mixin/mixindbus.h"
16 #include "misc/mixin/mixinhash.h"
17 #include "misc/mixin/mixinindex.h"
18 #include "misc/mixin/mixinjson.h"
20 #include "misc/mixin/mixinstring.h"
21 #include "misc/pq/angle.h"
22 #include "misc/pq/units.h"
23 #include "misc/swiftmiscexport.h"
24 
25 namespace swift::misc::aviation
26 {
27 
35  public mixin::MetaType<CTrack>,
36  public mixin::EqualsByMetaClass<CTrack>,
37  public mixin::CompareByMetaClass<CTrack>,
38  public mixin::HashByMetaClass<CTrack>,
39  public mixin::DBusByMetaClass<CTrack>,
40  public mixin::DataStreamByMetaClass<CTrack>,
41  public mixin::JsonByMetaClass<CTrack>,
42  public mixin::String<CTrack>,
43  public mixin::Index<CTrack>
44  {
45  public:
48 
55 
56 
60  {
61  Magnetic = 0,
62  True = 1
63  };
64 
66  CTrack() : CAngle(0, swift::misc::physical_quantities::CAngleUnit::rad()), m_north(Magnetic) {}
67 
70  : CAngle(value, unit), m_north(north)
71  {}
72 
75  : CAngle(track), m_north(north)
76  {}
77 
79  bool isMagneticTrack() const
80  {
81  (void)QT_TRANSLATE_NOOP("Aviation", "magnetic");
82  return Magnetic == this->m_north;
83  }
84 
86  bool isTrueTrack() const
87  {
88  (void)QT_TRANSLATE_NOOP("Aviation", "true");
89  return True == this->m_north;
90  }
91 
93  ReferenceNorth getReferenceNorth() const { return m_north; }
94 
96  QString convertToQString(bool i18n = false) const;
97 
98  private:
99  ReferenceNorth m_north;
100 
102  CTrack,
103  SWIFT_METAMEMBER(north));
104  };
105 } // namespace swift::misc::aviation
106 
107 Q_DECLARE_METATYPE(swift::misc::aviation::CTrack)
108 
109 #endif // SWIFT_MISC_AVIATION_TRACK_H
Track as used in aviation, can be true or magnetic Track.
Definition: track.h:44
ReferenceNorth
Enum type to distinguish between true north and magnetic north.
Definition: track.h:60
CTrack(double value, ReferenceNorth north, const swift::misc::physical_quantities::CAngleUnit &unit)
Constructor.
Definition: track.h:69
bool isMagneticTrack() const
Magnetic Track?
Definition: track.h:79
CTrack()
Default constructor: 0 Track magnetic.
Definition: track.h:66
ReferenceNorth getReferenceNorth() const
Get reference north (magnetic or true)
Definition: track.h:93
CTrack(const swift::misc::physical_quantities::CAngle &track, ReferenceNorth north)
Constructor by CAngle.
Definition: track.h:74
bool isTrueTrack() const
True Track?
Definition: track.h:86
CRTP class template from which a derived class can inherit non-member compare() implemented by metacl...
Definition: mixincompare.h:216
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.
Definition: mixincompare.h:46
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...
Definition: mixinmetatype.h:29
CRTP class template from which a derived class can inherit string streaming operations.
Definition: mixinstring.h:31
Physical unit angle (radians, degrees)
Definition: angle.h:23
Specialized class for angles (degrees, radian).
Definition: units.h:233
#define SWIFT_METAMEMBER(MEMBER,...)
Macro to define an element within a metaclass.
Definition: metaclass.h:73
#define SWIFT_METACLASS(CLASS,...)
Macro to define a nested metaclass that describes the attributes of its enclosing class.
Definition: metaclass.h:53
#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:182
#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:151
#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:281
#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...
Definition: mixinstring.h:110
#define SWIFT_MISC_EXPORT
Export a class or function from the library.