swift
interpolationrenderingsetup.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2016 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_SIMULATION_INTERPOLATION_INTERPOLATIONRENDERINGSETUP_H
7 #define SWIFT_MISC_SIMULATION_INTERPOLATION_INTERPOLATIONRENDERINGSETUP_H
8 
9 #include <QString>
10 
11 #include "misc/aviation/callsign.h"
12 #include "misc/pq/angle.h"
13 #include "misc/pq/length.h"
14 #include "misc/propertyindexlist.h"
15 #include "misc/swiftmiscexport.h"
16 #include "misc/valueobject.h"
17 
18 SWIFT_DECLARE_VALUEOBJECT_MIXINS(swift::misc::simulation, CInterpolationAndRenderingSetupGlobal)
19 SWIFT_DECLARE_VALUEOBJECT_MIXINS(swift::misc::simulation, CInterpolationAndRenderingSetupPerCallsign)
20 
21 namespace swift::misc
22 {
23  namespace network
24  {
25  class CClient;
26  }
27  namespace simulation
28  {
31  {
32  public:
35  {
36  IndexLogInterpolation = CPropertyIndexRef::GlobalIndexCInterpolatioRenderingSetup,
37  IndexSimulatorDebugMessages,
38  IndexForceFullInterpolation,
39  IndexSendGndFlagToSimulator,
40  IndexEnabledAircraftParts,
41  IndexInterpolatorMode,
42  IndexInterpolatorModeAsString,
43  IndexFixSceneryOffset,
44  IndexPitchOnGround
45  };
46 
49  {
50  Spline,
51  Linear
52  };
53 
55  bool showSimulatorDebugMessages() const { return m_simulatorDebugMessages; }
56 
58  void setSimulatorDebuggingMessages(bool debug) { m_simulatorDebugMessages = debug; }
59 
61  bool logInterpolation() const { return m_logInterpolation; }
62 
64  bool setLogInterpolation(bool log);
65 
67  bool isForcingFullInterpolation() const { return m_forceFullInterpolation; }
68 
70  void setForceFullInterpolation(bool force) { m_forceFullInterpolation = force; }
71 
73  bool setEnabledAircraftParts(bool enabled);
74 
76  bool maskEnabledAircraftParts(bool mask);
77 
79  bool isAircraftPartsEnabled() const { return m_enabledAircraftParts; }
80 
82  bool isSendingGndFlagToSimulator() const { return m_sendGndToSim; }
83 
85  bool setSendingGndFlagToSimulator(bool sendFLag);
86 
88  bool isFixingSceneryOffset() const { return m_fixSceneryOffset; }
89 
91  void setFixingSceneryOffset(bool fix) { m_fixSceneryOffset = fix; }
92 
94  const physical_quantities::CAngle &getPitchOnGround() const { return m_pitchOnGround; }
95 
97  bool setPitchOnGround(const physical_quantities::CAngle &pitchOnGround);
98 
100  void consolidateWithClient(const network::CClient &client);
101 
103  InterpolatorMode getInterpolatorMode() const { return static_cast<InterpolatorMode>(m_interpolatorMode); }
104 
106  const QString &getInterpolatorModeAsString() const { return modeToString(this->getInterpolatorMode()); }
107 
109  bool setInterpolatorMode(InterpolatorMode mode);
110 
112  bool setInterpolatorMode(const QString &mode);
113 
115  QString convertToQString(bool i18n = false) const;
116 
118  QVariant propertyByIndex(CPropertyIndexRef index) const;
119 
121  void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant);
122 
124  static const QString &modeToString(InterpolatorMode mode);
125 
126  protected:
129 
131  static bool canHandleIndex(int index);
132 
133  bool m_logInterpolation = false;
134  bool m_simulatorDebugMessages = false;
135  bool m_forceFullInterpolation = false;
136  bool m_enabledAircraftParts = true;
137  bool m_sendGndToSim = true;
138  bool m_fixSceneryOffset = false;
139  int m_interpolatorMode = static_cast<int>(Spline);
140  physical_quantities::CAngle m_pitchOnGround =
142  };
143 
146  public CValueObject<CInterpolationAndRenderingSetupGlobal>,
148  {
149  public:
152  {
153  IndexMaxRenderedAircraft = CInterpolationAndRenderingSetupBase::IndexFixSceneryOffset + 1,
154  IndexMaxRenderedDistance
155  };
156 
159 
161  static int InfiniteAircraft();
162 
164  int getMaxRenderedAircraft() const;
165 
167  bool setMaxRenderedAircraft(int maxRenderedAircraft);
168 
170  bool setMaxRenderedDistance(const physical_quantities::CLength &distance);
171 
173  void clearMaxRenderedDistance();
174 
176  bool isRenderingEnabled() const;
177 
179  bool isRenderingRestricted() const;
180 
182  physical_quantities::CLength getMaxRenderedDistance() const { return m_maxRenderedDistance; }
183 
185  bool isMaxDistanceRestricted() const;
186 
188  bool isMaxAircraftRestricted() const;
189 
191  void clearAllRenderingRestrictions();
192 
194  void disableRendering();
195 
197  QString getRenderRestrictionText() const;
198 
200  void setBaseValues(const CInterpolationAndRenderingSetupBase &baseValues);
201 
203  QString convertToQString(bool i18n = false) const;
204 
206  QVariant propertyByIndex(CPropertyIndexRef index) const;
207 
209  void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant);
210 
211  private:
212  int m_maxRenderedAircraft = InfiniteAircraft();
213  physical_quantities::CLength m_maxRenderedDistance { 0, nullptr };
214 
216  CInterpolationAndRenderingSetupGlobal,
217  SWIFT_METAMEMBER(logInterpolation),
218  SWIFT_METAMEMBER(simulatorDebugMessages),
219  SWIFT_METAMEMBER(forceFullInterpolation),
220  SWIFT_METAMEMBER(sendGndToSim),
221  SWIFT_METAMEMBER(enabledAircraftParts),
222  SWIFT_METAMEMBER(fixSceneryOffset),
223  SWIFT_METAMEMBER(interpolatorMode),
224  SWIFT_METAMEMBER(pitchOnGround),
225  SWIFT_METAMEMBER(maxRenderedAircraft),
226  SWIFT_METAMEMBER(maxRenderedDistance));
227  };
228 
231  public CValueObject<CInterpolationAndRenderingSetupPerCallsign>,
233  {
234  public:
237  {
238  IndexCallsign = CInterpolationAndRenderingSetupGlobal::IndexMaxRenderedDistance + 1
239  };
240 
243 
246  const CInterpolationAndRenderingSetupGlobal &globalSetup);
247 
249  CPropertyIndexList unequalToGlobal(const CInterpolationAndRenderingSetupGlobal &globalSetup) const;
250 
252  bool isEqualToGlobal(const CInterpolationAndRenderingSetupGlobal &globalSetup) const;
253 
255  const aviation::CCallsign &getCallsign() const { return m_callsign; }
256 
258  void setCallsign(const aviation::CCallsign &callsign) { m_callsign = callsign; }
259 
261  bool isNull() const { return m_callsign.isEmpty(); }
262 
264  QVariant propertyByIndex(CPropertyIndexRef index) const;
265 
267  void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant);
268 
270  static const CInterpolationAndRenderingSetupPerCallsign &null();
271 
272  private:
273  aviation::CCallsign m_callsign;
274 
277  SWIFT_METAMEMBER(logInterpolation),
278  SWIFT_METAMEMBER(simulatorDebugMessages),
279  SWIFT_METAMEMBER(forceFullInterpolation),
280  SWIFT_METAMEMBER(sendGndToSim),
281  SWIFT_METAMEMBER(enabledAircraftParts),
282  SWIFT_METAMEMBER(fixSceneryOffset),
283  SWIFT_METAMEMBER(interpolatorMode),
284  SWIFT_METAMEMBER(pitchOnGround));
285  };
286  } // namespace simulation
287 } // namespace swift::misc
288 
292 
293 #endif // SWIFT_MISC_SIMULATION_INTERPOLATION_INTERPOLATIONRENDERINGSETUP_H
Value object encapsulating a list of property indexes.
Non-owning reference to a CPropertyIndex with a subset of its features.
Mix of the most commonly used mixin classes.
Definition: valueobject.h:114
Value object encapsulating information of a callsign.
Definition: callsign.h:30
ColumnIndex
Base class enums.
Definition: mixinindex.h:44
Another client software.
Definition: client.h:27
Physical unit angle (radians, degrees)
Definition: angle.h:23
Physical unit length (length)
Definition: length.h:18
Value object for interpolator and rendering base class.
void setFixingSceneryOffset(bool fix)
Enable fix scenery offset if it has been detected.
bool isFixingSceneryOffset() const
Fix scenery offset if it has been detected.
bool isAircraftPartsEnabled() const
Aircraft parts enabled (still requires the other aircraft to send parts)
void setSimulatorDebuggingMessages(bool debug)
Debugging messages for simulation.
const physical_quantities::CAngle & getPitchOnGround() const
Force a given pitch on ground.
bool showSimulatorDebugMessages() const
Debugging messages for simulation.
bool isForcingFullInterpolation() const
Full interpolation (skip optimizations like checking if aircraft moves etc.)
physical_quantities::CLength getMaxRenderedDistance() const
Max.distance for rendering.
Value object for interpolator and rendering per callsign.
void setCallsign(const aviation::CCallsign &callsign)
Set callsign.
#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
Free functions in swift::misc.
#define SWIFT_MISC_EXPORT
Export a class or function from the library.
#define SWIFT_DECLARE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template declaration of mixins for a CValueObject subclass to be placed near the top of the ...
Definition: valueobject.h:65