mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Ref T709, review points
* overload "normalize" * renamed to CSettingsProvider
This commit is contained in:
committed by
Mat Sutcliffe
parent
741843d0c6
commit
55690b423f
@@ -9,11 +9,11 @@
|
||||
#include "dbusobject.h"
|
||||
#include <cassert>
|
||||
|
||||
XSwiftBus::ISettingsProvider *XSwiftBus::CDBusObject::s_settingsProvider = nullptr;
|
||||
XSwiftBus::CSettingsProvider *XSwiftBus::CDBusObject::s_settingsProvider = nullptr;
|
||||
|
||||
namespace XSwiftBus
|
||||
{
|
||||
CDBusObject::CDBusObject(ISettingsProvider *settingsProvider)
|
||||
CDBusObject::CDBusObject(CSettingsProvider *settingsProvider)
|
||||
{
|
||||
if (!CDBusObject::s_settingsProvider)
|
||||
{
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace XSwiftBus
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
CDBusObject(ISettingsProvider *settingsProvider);
|
||||
CDBusObject(CSettingsProvider *settingsProvider);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CDBusObject();
|
||||
@@ -86,7 +86,7 @@ namespace XSwiftBus
|
||||
//! Set the settings
|
||||
bool setSettings(const CSettings &s);
|
||||
|
||||
static ISettingsProvider *s_settingsProvider; //!< get the settings from here, still protected for the static functions
|
||||
static CSettingsProvider *s_settingsProvider; //!< get the settings from here, still protected for the static functions
|
||||
|
||||
private:
|
||||
static void dbusObjectPathUnregisterFunction(DBusConnection *connection, void *data);
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace XSwiftBus
|
||||
/*!
|
||||
* Main plugin class
|
||||
*/
|
||||
class CPlugin : public ISettingsProvider
|
||||
class CPlugin : public CSettingsProvider
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
|
||||
@@ -22,7 +22,7 @@ using namespace BlackMisc::Simulation::XPlane::QtFreeUtils;
|
||||
|
||||
namespace XSwiftBus
|
||||
{
|
||||
CService::CService(ISettingsProvider *settingsProvider) : CDBusObject(settingsProvider)
|
||||
CService::CService(CSettingsProvider *settingsProvider) : CDBusObject(settingsProvider)
|
||||
{
|
||||
updateAirportsInRange();
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace XSwiftBus
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
CService(ISettingsProvider *settingsProvider);
|
||||
CService(CSettingsProvider *settingsProvider);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CService() override = default;
|
||||
|
||||
@@ -27,13 +27,13 @@ namespace XSwiftBus
|
||||
// void
|
||||
}
|
||||
|
||||
CSettings ISettingsProvider::getSettings() const
|
||||
CSettings CSettingsProvider::getSettings() const
|
||||
{
|
||||
std::lock_guard<std::mutex> l(m_settingsMutex);
|
||||
return m_pluginSettings;
|
||||
}
|
||||
|
||||
void ISettingsProvider::setSettings(const CSettings &settings)
|
||||
void CSettingsProvider::setSettings(const CSettings &settings)
|
||||
{
|
||||
std::lock_guard<std::mutex> l(m_settingsMutex);
|
||||
m_pluginSettings = settings;
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace XSwiftBus
|
||||
};
|
||||
|
||||
//! Something owning the settings
|
||||
class ISettingsProvider
|
||||
class CSettingsProvider
|
||||
{
|
||||
public:
|
||||
//! By value
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace XSwiftBus
|
||||
}
|
||||
|
||||
// *INDENT-OFF*
|
||||
CTraffic::CTraffic(ISettingsProvider *settingsProvider) :
|
||||
CTraffic::CTraffic(CSettingsProvider *settingsProvider) :
|
||||
CDBusObject(settingsProvider),
|
||||
m_followPlaneViewNextCommand("org/swift-project/xswiftbus/follow_next_plane", "Changes plane view to follow next plane in sequence", [this] { followNextPlane(); }),
|
||||
m_followPlaneViewPreviousCommand("org/swift-project/xswiftbus/follow_previous_plane", "Changes plane view to follow previous plane in sequence", [this] { followPreviousPlane(); })
|
||||
@@ -945,7 +945,7 @@ namespace XSwiftBus
|
||||
return 0;
|
||||
}
|
||||
|
||||
traffic->m_deltaCameraPosition.headingDeg = normalizeToZero360DegD(360.0 * static_cast<double>(x) / static_cast<double>(w)); // range 0-360
|
||||
traffic->m_deltaCameraPosition.headingDeg = normalizeToZero360Deg(360.0 * static_cast<double>(x) / static_cast<double>(w)); // range 0-360
|
||||
double usedCameraPitchDeg = 60.0 - (60.0 * 2.0 * static_cast<double>(y) / static_cast<double>(h)); // range +-
|
||||
|
||||
// make sure we can use it with tan in range +-90 degrees and the result of tan not getting too high
|
||||
@@ -1022,8 +1022,8 @@ namespace XSwiftBus
|
||||
cameraPosition->z = static_cast<float>(lz + traffic->m_deltaCameraPosition.dz);
|
||||
// cameraPosition->pitch = static_cast<float>(traffic->m_deltaCameraPosition.pitch);
|
||||
// cameraPosition->heading = static_cast<float>(traffic->m_deltaCameraPosition.heading);
|
||||
cameraPosition->pitch = CTraffic::normalizeToPlusMinus180DegF(static_cast<float>(traffic->m_deltaCameraPosition.pitchDeg));
|
||||
cameraPosition->heading = CTraffic::normalizeToPlusMinus180DegF(static_cast<float>(traffic->m_deltaCameraPosition.headingDeg));
|
||||
cameraPosition->pitch = CTraffic::normalizeToPlusMinus180Deg(static_cast<float>(traffic->m_deltaCameraPosition.pitchDeg));
|
||||
cameraPosition->heading = CTraffic::normalizeToPlusMinus180Deg(static_cast<float>(traffic->m_deltaCameraPosition.headingDeg));
|
||||
cameraPosition->roll = 0.0;
|
||||
cameraPosition->zoom = 1.0;
|
||||
|
||||
@@ -1119,13 +1119,13 @@ namespace XSwiftBus
|
||||
return true;
|
||||
}
|
||||
|
||||
float CTraffic::normalizeToPlusMinus180DegF(float v)
|
||||
float CTraffic::normalizeToPlusMinus180Deg(float v)
|
||||
{
|
||||
if (std::isnan(v)) { return 0.0f; }
|
||||
return static_cast<float>(normalizeToPlusMinus180DegD(static_cast<double>(v)));
|
||||
return static_cast<float>(normalizeToPlusMinus180Deg(static_cast<double>(v)));
|
||||
}
|
||||
|
||||
double CTraffic::normalizeToPlusMinus180DegD(double v)
|
||||
double CTraffic::normalizeToPlusMinus180Deg(double v)
|
||||
{
|
||||
if (std::isnan(v)) { return 0.0; }
|
||||
const double n = normalizeValue(v, -180.0, 180.0);
|
||||
@@ -1134,14 +1134,14 @@ namespace XSwiftBus
|
||||
return n;
|
||||
}
|
||||
|
||||
float CTraffic::normalizeToZero360DegF(float v)
|
||||
float CTraffic::normalizeToZero360Deg(float v)
|
||||
{
|
||||
if (std::isnan(v)) { return 0.0f; }
|
||||
return static_cast<float>(normalizeToZero360DegD(static_cast<double>(v)));
|
||||
return static_cast<float>(normalizeToZero360Deg(static_cast<double>(v)));
|
||||
|
||||
}
|
||||
|
||||
double CTraffic::normalizeToZero360DegD(double v)
|
||||
double CTraffic::normalizeToZero360Deg(double v)
|
||||
{
|
||||
if (std::isnan(v)) { return 0.0; }
|
||||
const double n = normalizeValue(v, 0, 360.0);
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace XSwiftBus
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
CTraffic(ISettingsProvider *settingsProvider);
|
||||
CTraffic(CSettingsProvider *settingsProvider);
|
||||
|
||||
//! Destructor
|
||||
virtual ~CTraffic() override;
|
||||
@@ -197,10 +197,10 @@ namespace XSwiftBus
|
||||
//! @}
|
||||
|
||||
//! Normalize to (-180, 180] or [0, 360) degrees @{
|
||||
static float normalizeToPlusMinus180DegF(float v);
|
||||
static double normalizeToPlusMinus180DegD(double v);
|
||||
static float normalizeToZero360DegF(float v);
|
||||
static double normalizeToZero360DegD(double v);
|
||||
static float normalizeToPlusMinus180Deg(float v);
|
||||
static double normalizeToPlusMinus180Deg(double v);
|
||||
static float normalizeToZero360Deg(float v);
|
||||
static double normalizeToZero360Deg(double v);
|
||||
//! @}
|
||||
|
||||
//! Check the position if values are valid @{
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
namespace XSwiftBus
|
||||
{
|
||||
CWeather::CWeather(ISettingsProvider *settingsProvider) : CDBusObject(settingsProvider)
|
||||
CWeather::CWeather(CSettingsProvider *settingsProvider) : CDBusObject(settingsProvider)
|
||||
{
|
||||
// void
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace XSwiftBus
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
CWeather(ISettingsProvider *settingsProvider);
|
||||
CWeather(CSettingsProvider *settingsProvider);
|
||||
|
||||
//! DBus interface name
|
||||
static const std::string &InterfaceName()
|
||||
|
||||
Reference in New Issue
Block a user