mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Ref T723 [xswiftbus] UI/settings for TCAS enabled and debug mode
* UI checkboxes added * Qt free settings updated
This commit is contained in:
committed by
Mat Sutcliffe
parent
0f6b7d910e
commit
12fbd87bbc
@@ -7,13 +7,13 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>350</width>
|
||||
<height>400</height>
|
||||
<height>450</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>350</width>
|
||||
<height>400</height>
|
||||
<height>450</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
||||
@@ -121,6 +121,18 @@ namespace BlackMisc
|
||||
return true;
|
||||
}
|
||||
|
||||
//! Debug messages?
|
||||
bool isLogRenderPhases() const { return m_logRenderPhases; }
|
||||
|
||||
//! Debug messages?
|
||||
void setLogRenderPhases(bool log) { m_logRenderPhases = log; }
|
||||
|
||||
//! TCAS functionality?
|
||||
bool isTcasEnabled() const { return m_tcasEnabled; }
|
||||
|
||||
//! TCAS functionality?
|
||||
void setTcasEnabled(bool tcas) { m_tcasEnabled = tcas; }
|
||||
|
||||
//! Load and parse config file
|
||||
bool parseXSwiftBusString(const std::string &json);
|
||||
|
||||
@@ -145,6 +157,8 @@ namespace BlackMisc
|
||||
//! The JSON members @{
|
||||
static constexpr char JsonDBusServerAddress[] = "dbusserveradress";
|
||||
static constexpr char JsonDrawingLabels[] = "drawinglabels";
|
||||
static constexpr char JsonLogRenderPhases[] = "renderPhases";
|
||||
static constexpr char JsonTcas[] = "tcas";
|
||||
static constexpr char JsonMaxPlanes[] = "maxplanes";
|
||||
static constexpr char JsonMaxDrawDistance[] = "maxDrawDistance";
|
||||
static constexpr char JsonNightTextureMode[] = "nighttexture";
|
||||
@@ -157,13 +171,15 @@ namespace BlackMisc
|
||||
//! Object has been updated
|
||||
virtual void objectUpdated() = 0;
|
||||
|
||||
std::string m_dBusServerAddress { "tcp:host=127.0.0.1,port=45001" }; //!< DBus server
|
||||
std::string m_dBusServerAddress { "tcp:host=127.0.0.1,port=45001" }; //!< DBus server (also in class CXSwiftBusConfigWriter)
|
||||
std::string m_nightTextureMode { "auto" }; //!< night texture mode
|
||||
std::string m_msgBox { "20;20;20;-1;5;5000" }; //!< left, top, right, bottom, lines, duration
|
||||
int m_maxPlanes = 100; //!< max. planes in XPlane
|
||||
int m_maxPlanes = 100; //!< max. planes in XPlane
|
||||
int m_followAircraftDistanceM = 200; //!< follow aircraft in distance
|
||||
bool m_drawingLabels = true; //!< labels in XPlane
|
||||
bool m_bundleTaxiLandingLights = true; //!< bundle taxi and landing lights
|
||||
bool m_logRenderPhases = false; //!< render phases debug messages
|
||||
bool m_tcasEnabled = true; //!< TCAS functionality
|
||||
double m_maxDrawDistanceNM = 50.0; //!< distance in XPlane
|
||||
int64_t m_msSinceEpochQtFree = 0; //!< timestamp
|
||||
};
|
||||
|
||||
@@ -29,6 +29,8 @@ constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonNi
|
||||
constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonMessageBox[];
|
||||
constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonBundleTaxiLandingLights[];
|
||||
constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonTimestamp[];
|
||||
constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonTcas[];
|
||||
constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonLogRenderPhases[];
|
||||
//! @endcond
|
||||
|
||||
namespace BlackMisc
|
||||
@@ -67,6 +69,14 @@ namespace BlackMisc
|
||||
{
|
||||
m_bundleTaxiLandingLights = settingsDoc[CXSwiftBusSettingsQtFree::JsonBundleTaxiLandingLights].GetBool(); c++;
|
||||
}
|
||||
if (settingsDoc.HasMember(CXSwiftBusSettingsQtFree::JsonTcas) && settingsDoc[CXSwiftBusSettingsQtFree::JsonTcas].IsBool())
|
||||
{
|
||||
m_tcasEnabled = settingsDoc[CXSwiftBusSettingsQtFree::JsonTcas].GetBool(); c++;
|
||||
}
|
||||
if (settingsDoc.HasMember(CXSwiftBusSettingsQtFree::JsonLogRenderPhases) && settingsDoc[CXSwiftBusSettingsQtFree::JsonLogRenderPhases].IsBool())
|
||||
{
|
||||
m_logRenderPhases = settingsDoc[CXSwiftBusSettingsQtFree::JsonLogRenderPhases].GetBool(); c++;
|
||||
}
|
||||
if (settingsDoc.HasMember(CXSwiftBusSettingsQtFree::JsonMaxPlanes) && settingsDoc[CXSwiftBusSettingsQtFree::JsonMaxPlanes].IsInt())
|
||||
{
|
||||
m_maxPlanes = settingsDoc[CXSwiftBusSettingsQtFree::JsonMaxPlanes].GetInt(); c++;
|
||||
@@ -84,7 +94,7 @@ namespace BlackMisc
|
||||
m_msSinceEpochQtFree = settingsDoc[CXSwiftBusSettingsQtFree::JsonTimestamp].GetInt64(); c++;
|
||||
}
|
||||
this->objectUpdated(); // post processing
|
||||
return c == 9;
|
||||
return c == 11;
|
||||
}
|
||||
|
||||
std::string CXSwiftBusSettingsQtFree::toXSwiftBusJsonString() const
|
||||
@@ -97,15 +107,17 @@ namespace BlackMisc
|
||||
Document::AllocatorType &a = document.GetAllocator();
|
||||
// Value k1(JsonDBusServerAddress, a);
|
||||
// Value v1(m_dBusServerAddress, a);
|
||||
document.AddMember(JsonDBusServerAddress, StringRef(m_dBusServerAddress.c_str()), a);
|
||||
document.AddMember(JsonNightTextureMode, StringRef(m_nightTextureMode.c_str()), a);
|
||||
document.AddMember(JsonMessageBox, StringRef(m_msgBox.c_str()), a);
|
||||
document.AddMember(JsonDBusServerAddress, StringRef(m_dBusServerAddress.c_str()), a);
|
||||
document.AddMember(JsonNightTextureMode, StringRef(m_nightTextureMode.c_str()), a);
|
||||
document.AddMember(JsonMessageBox, StringRef(m_msgBox.c_str()), a);
|
||||
document.AddMember(JsonMaxPlanes, m_maxPlanes, a);
|
||||
document.AddMember(JsonMaxDrawDistance, m_maxDrawDistanceNM, a);
|
||||
document.AddMember(JsonMaxDrawDistance, m_maxDrawDistanceNM, a);
|
||||
document.AddMember(JsonTimestamp, m_msSinceEpochQtFree, a);
|
||||
document.AddMember(JsonDrawingLabels, m_drawingLabels, a);
|
||||
document.AddMember(JsonBundleTaxiLandingLights, m_bundleTaxiLandingLights, a);
|
||||
document.AddMember(JsonFollowAircraftDistanceM, m_followAircraftDistanceM, a);
|
||||
document.AddMember(JsonLogRenderPhases, m_logRenderPhases, a);
|
||||
document.AddMember(JsonTcas, m_tcasEnabled, a);
|
||||
|
||||
// document[CXSwiftBusSettingsQtFree::JsonDBusServerAddress].SetString(StringRef(m_dBusServerAddress.c_str(), m_dBusServerAddress.size()));
|
||||
// document[CXSwiftBusSettingsQtFree::JsonDrawingLabels].SetBool(m_drawingLabels);
|
||||
@@ -122,27 +134,31 @@ namespace BlackMisc
|
||||
std::string CXSwiftBusSettingsQtFree::convertToString() const
|
||||
{
|
||||
return "DBusServer: " + m_dBusServerAddress +
|
||||
", drawLabels: " + QtFreeUtils::boolToYesNo(m_drawingLabels) +
|
||||
", bundle lights: " + QtFreeUtils::boolToYesNo(m_bundleTaxiLandingLights) +
|
||||
", night t.: " + m_nightTextureMode +
|
||||
", max planes: " + std::to_string(m_maxPlanes) +
|
||||
", drawLabels: " + QtFreeUtils::boolToYesNo(m_drawingLabels) +
|
||||
", bundle lights: " + QtFreeUtils::boolToYesNo(m_bundleTaxiLandingLights) +
|
||||
", phases: " + QtFreeUtils::boolToYesNo(m_logRenderPhases) +
|
||||
", TCAS: " + QtFreeUtils::boolToYesNo(m_tcasEnabled) +
|
||||
", night t.: " + m_nightTextureMode +
|
||||
", max planes: " + std::to_string(m_maxPlanes) +
|
||||
", max distance NM: " + std::to_string(m_maxDrawDistanceNM) +
|
||||
", follow dist m: " + std::to_string(m_followAircraftDistanceM) +
|
||||
", msg.box: " + m_msgBox +
|
||||
", ts: " + std::to_string(m_msSinceEpochQtFree);
|
||||
", msg.box: " + m_msgBox +
|
||||
", ts: " + std::to_string(m_msSinceEpochQtFree);
|
||||
}
|
||||
|
||||
int CXSwiftBusSettingsQtFree::update(const CXSwiftBusSettingsQtFree &newValues)
|
||||
{
|
||||
int changed = 0;
|
||||
if (m_dBusServerAddress != newValues.m_dBusServerAddress) { m_dBusServerAddress = newValues.m_dBusServerAddress; changed++; }
|
||||
if (m_msgBox != newValues.m_msgBox) { m_msgBox = newValues.m_msgBox; changed++; }
|
||||
if (m_msgBox != newValues.m_msgBox) { m_msgBox = newValues.m_msgBox; changed++; }
|
||||
if (m_drawingLabels != newValues.m_drawingLabels) { m_drawingLabels = newValues.m_drawingLabels; changed++; }
|
||||
if (m_bundleTaxiLandingLights != newValues.m_bundleTaxiLandingLights) { m_bundleTaxiLandingLights = newValues.m_bundleTaxiLandingLights; changed++; }
|
||||
if (m_nightTextureMode != newValues.m_nightTextureMode) { m_nightTextureMode = newValues.m_nightTextureMode; changed++; }
|
||||
if (m_logRenderPhases != newValues.m_logRenderPhases) { m_logRenderPhases = newValues.m_logRenderPhases; changed++; }
|
||||
if (m_tcasEnabled != newValues.m_tcasEnabled) { m_tcasEnabled = newValues.m_tcasEnabled; changed++; }
|
||||
if (m_maxPlanes != newValues.m_maxPlanes) { m_maxPlanes = newValues.m_maxPlanes; changed++; }
|
||||
if (m_msSinceEpochQtFree != newValues.m_msSinceEpochQtFree) { m_msSinceEpochQtFree = newValues.m_msSinceEpochQtFree; changed++; }
|
||||
if (m_followAircraftDistanceM != newValues.m_followAircraftDistanceM) { m_followAircraftDistanceM = newValues.m_followAircraftDistanceM; changed++; }
|
||||
if (m_bundleTaxiLandingLights != newValues.m_bundleTaxiLandingLights) { m_bundleTaxiLandingLights = newValues.m_bundleTaxiLandingLights; changed++; }
|
||||
if (m_followAircraftDistanceM != newValues.m_followAircraftDistanceM) { m_followAircraftDistanceM = newValues.m_followAircraftDistanceM; changed++; }
|
||||
if (!QtFreeUtils::isFuzzyEqual(m_maxDrawDistanceNM, newValues.m_maxDrawDistanceNM)) { m_maxDrawDistanceNM = newValues.m_maxDrawDistanceNM; changed++; }
|
||||
|
||||
if (changed > 0) { this->objectUpdated(); } // post processing
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace BlackSimPlugin
|
||||
CSimulatorXPlaneConfig(QObject *parent = nullptr);
|
||||
|
||||
//! Dtor
|
||||
virtual ~CSimulatorXPlaneConfig() {}
|
||||
virtual ~CSimulatorXPlaneConfig() override {}
|
||||
|
||||
//! \copydoc BlackGui::IPluginConfig::createConfigWindow()
|
||||
BlackGui::CPluginConfigWindow *createConfigWindow(QWidget *parent) override;
|
||||
|
||||
@@ -55,6 +55,8 @@ namespace BlackSimPlugin
|
||||
m_xSwiftBusServerSettings.set(changed);
|
||||
CXSwiftBusConfigWriter xswiftbusConfigWriter;
|
||||
xswiftbusConfigWriter.setDBusAddress(changed.getDBusServerAddressQt());
|
||||
xswiftbusConfigWriter.setDebugMode(s.isLogRenderPhases());
|
||||
xswiftbusConfigWriter.setTcasEnabled(s.isTcasEnabled());
|
||||
xswiftbusConfigWriter.updateInAllXPlaneVersions();
|
||||
}
|
||||
this->close();
|
||||
@@ -70,6 +72,8 @@ namespace BlackSimPlugin
|
||||
s.setDrawingLabels(ui->cb_DrawLabels->isChecked());
|
||||
s.setNightTextureModeQt(ui->cb_NightTextureMode->currentText());
|
||||
s.setBundlingTaxiAndLandingLights(ui->cb_BundleTaxiLandingLights->isChecked());
|
||||
s.setTcasEnabled(ui->cb_TcasEnabled->isChecked());
|
||||
s.setLogRenderPhases(ui->cb_LogRenderPhases->isChecked());
|
||||
|
||||
// left, top, right, bottom, height
|
||||
s.setMessageBoxValues(
|
||||
@@ -88,9 +92,11 @@ namespace BlackSimPlugin
|
||||
ui->comp_SettingsXSwiftBus->set(settings.getDBusServerAddressQt());
|
||||
ui->sb_MaxAircraft->setValue(settings.getMaxPlanes());
|
||||
ui->sb_FollowAircraftDistanceM->setValue(settings.getFollowAircraftDistanceM());
|
||||
ui->cb_DrawLabels->setChecked(settings.isDrawingLabels());
|
||||
ui->ds_MaxDrawDistanceNM->setValue(settings.getMaxDrawDistanceNM());
|
||||
ui->cb_DrawLabels->setChecked(settings.isDrawingLabels());
|
||||
ui->cb_BundleTaxiLandingLights->setChecked(settings.isBundlingTaxiAndLandingLights());
|
||||
ui->cb_TcasEnabled->setChecked(settings.isTcasEnabled());
|
||||
ui->cb_LogRenderPhases->setChecked(settings.isLogRenderPhases());
|
||||
|
||||
const QString s = settings.getNightTextureModeQt().left(1);
|
||||
if (!s.isEmpty())
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>300</width>
|
||||
<height>450</height>
|
||||
<width>378</width>
|
||||
<height>585</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>300</width>
|
||||
<height>425</height>
|
||||
<width>275</width>
|
||||
<height>475</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -158,14 +158,14 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="lbl_MessageBox">
|
||||
<property name="text">
|
||||
<string>Message box </string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<item row="7" column="1">
|
||||
<widget class="QWidget" name="wi_MessageBox" native="true">
|
||||
<layout class="QHBoxLayout" name="hl_MessageBox">
|
||||
<property name="leftMargin">
|
||||
@@ -193,33 +193,17 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="sb_MessageBoxDuration">
|
||||
<property name="suffix">
|
||||
<string>ms</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>25000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>250</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="lbl_MessageBoxMargins">
|
||||
<property name="text">
|
||||
<string>Box margins px.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<item row="9" column="1">
|
||||
<widget class="QWidget" name="wi_Margins" native="true">
|
||||
<layout class="QGridLayout" name="gl_MessageBoxMargins">
|
||||
<property name="leftMargin">
|
||||
@@ -293,14 +277,14 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<item row="10" column="0">
|
||||
<widget class="QLabel" name="lbl_NightTextureMode">
|
||||
<property name="text">
|
||||
<string>Night texture</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<item row="10" column="1">
|
||||
<widget class="QComboBox" name="cb_NightTextureMode">
|
||||
<item>
|
||||
<property name="text">
|
||||
@@ -319,6 +303,57 @@
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QCheckBox" name="cb_LogRenderPhases">
|
||||
<property name="text">
|
||||
<string>log.render phases</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="lbl_DebugMode">
|
||||
<property name="text">
|
||||
<string>Logging</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QCheckBox" name="cb_TcasEnabled">
|
||||
<property name="text">
|
||||
<string>show traffic on TCAS</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="lbl_TcasEnabled">
|
||||
<property name="text">
|
||||
<string>TCAS</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QSpinBox" name="sb_MessageBoxDuration">
|
||||
<property name="suffix">
|
||||
<string>ms</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1000</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>25000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>250</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="lbl_MessageBoxDuration">
|
||||
<property name="text">
|
||||
<string>Box disappears after</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -351,8 +386,9 @@
|
||||
<tabstop>sb_FollowAircraftDistanceM</tabstop>
|
||||
<tabstop>cb_DrawLabels</tabstop>
|
||||
<tabstop>cb_BundleTaxiLandingLights</tabstop>
|
||||
<tabstop>cb_TcasEnabled</tabstop>
|
||||
<tabstop>cb_LogRenderPhases</tabstop>
|
||||
<tabstop>sb_MessageBoxLines</tabstop>
|
||||
<tabstop>sb_MessageBoxDuration</tabstop>
|
||||
<tabstop>le_MsgBoxMarginsTop</tabstop>
|
||||
<tabstop>le_MsgBoxMarginsBottom</tabstop>
|
||||
<tabstop>le_MsgBoxMarginsLeft</tabstop>
|
||||
|
||||
Reference in New Issue
Block a user