Ref T723 [xswiftbus] UI/settings for TCAS enabled and debug mode

* UI checkboxes added
* Qt free settings updated
This commit is contained in:
Klaus Basan
2019-12-30 01:27:51 +01:00
committed by Mat Sutcliffe
parent 0f6b7d910e
commit 12fbd87bbc
6 changed files with 121 additions and 47 deletions

View File

@@ -7,13 +7,13 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>350</width> <width>350</width>
<height>400</height> <height>450</height>
</rect> </rect>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>350</width> <width>350</width>
<height>400</height> <height>450</height>
</size> </size>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">

View File

@@ -121,6 +121,18 @@ namespace BlackMisc
return true; 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 //! Load and parse config file
bool parseXSwiftBusString(const std::string &json); bool parseXSwiftBusString(const std::string &json);
@@ -145,6 +157,8 @@ namespace BlackMisc
//! The JSON members @{ //! The JSON members @{
static constexpr char JsonDBusServerAddress[] = "dbusserveradress"; static constexpr char JsonDBusServerAddress[] = "dbusserveradress";
static constexpr char JsonDrawingLabels[] = "drawinglabels"; static constexpr char JsonDrawingLabels[] = "drawinglabels";
static constexpr char JsonLogRenderPhases[] = "renderPhases";
static constexpr char JsonTcas[] = "tcas";
static constexpr char JsonMaxPlanes[] = "maxplanes"; static constexpr char JsonMaxPlanes[] = "maxplanes";
static constexpr char JsonMaxDrawDistance[] = "maxDrawDistance"; static constexpr char JsonMaxDrawDistance[] = "maxDrawDistance";
static constexpr char JsonNightTextureMode[] = "nighttexture"; static constexpr char JsonNightTextureMode[] = "nighttexture";
@@ -157,13 +171,15 @@ namespace BlackMisc
//! Object has been updated //! Object has been updated
virtual void objectUpdated() = 0; 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_nightTextureMode { "auto" }; //!< night texture mode
std::string m_msgBox { "20;20;20;-1;5;5000" }; //!< left, top, right, bottom, lines, duration 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 int m_followAircraftDistanceM = 200; //!< follow aircraft in distance
bool m_drawingLabels = true; //!< labels in XPlane bool m_drawingLabels = true; //!< labels in XPlane
bool m_bundleTaxiLandingLights = true; //!< bundle taxi and landing lights 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 double m_maxDrawDistanceNM = 50.0; //!< distance in XPlane
int64_t m_msSinceEpochQtFree = 0; //!< timestamp int64_t m_msSinceEpochQtFree = 0; //!< timestamp
}; };

View File

@@ -29,6 +29,8 @@ constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonNi
constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonMessageBox[]; constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonMessageBox[];
constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonBundleTaxiLandingLights[]; constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonBundleTaxiLandingLights[];
constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonTimestamp[]; constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonTimestamp[];
constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonTcas[];
constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonLogRenderPhases[];
//! @endcond //! @endcond
namespace BlackMisc namespace BlackMisc
@@ -67,6 +69,14 @@ namespace BlackMisc
{ {
m_bundleTaxiLandingLights = settingsDoc[CXSwiftBusSettingsQtFree::JsonBundleTaxiLandingLights].GetBool(); c++; 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()) if (settingsDoc.HasMember(CXSwiftBusSettingsQtFree::JsonMaxPlanes) && settingsDoc[CXSwiftBusSettingsQtFree::JsonMaxPlanes].IsInt())
{ {
m_maxPlanes = settingsDoc[CXSwiftBusSettingsQtFree::JsonMaxPlanes].GetInt(); c++; m_maxPlanes = settingsDoc[CXSwiftBusSettingsQtFree::JsonMaxPlanes].GetInt(); c++;
@@ -84,7 +94,7 @@ namespace BlackMisc
m_msSinceEpochQtFree = settingsDoc[CXSwiftBusSettingsQtFree::JsonTimestamp].GetInt64(); c++; m_msSinceEpochQtFree = settingsDoc[CXSwiftBusSettingsQtFree::JsonTimestamp].GetInt64(); c++;
} }
this->objectUpdated(); // post processing this->objectUpdated(); // post processing
return c == 9; return c == 11;
} }
std::string CXSwiftBusSettingsQtFree::toXSwiftBusJsonString() const std::string CXSwiftBusSettingsQtFree::toXSwiftBusJsonString() const
@@ -106,6 +116,8 @@ namespace BlackMisc
document.AddMember(JsonDrawingLabels, m_drawingLabels, a); document.AddMember(JsonDrawingLabels, m_drawingLabels, a);
document.AddMember(JsonBundleTaxiLandingLights, m_bundleTaxiLandingLights, a); document.AddMember(JsonBundleTaxiLandingLights, m_bundleTaxiLandingLights, a);
document.AddMember(JsonFollowAircraftDistanceM, m_followAircraftDistanceM, 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::JsonDBusServerAddress].SetString(StringRef(m_dBusServerAddress.c_str(), m_dBusServerAddress.size()));
// document[CXSwiftBusSettingsQtFree::JsonDrawingLabels].SetBool(m_drawingLabels); // document[CXSwiftBusSettingsQtFree::JsonDrawingLabels].SetBool(m_drawingLabels);
@@ -124,6 +136,8 @@ namespace BlackMisc
return "DBusServer: " + m_dBusServerAddress + return "DBusServer: " + m_dBusServerAddress +
", drawLabels: " + QtFreeUtils::boolToYesNo(m_drawingLabels) + ", drawLabels: " + QtFreeUtils::boolToYesNo(m_drawingLabels) +
", bundle lights: " + QtFreeUtils::boolToYesNo(m_bundleTaxiLandingLights) + ", bundle lights: " + QtFreeUtils::boolToYesNo(m_bundleTaxiLandingLights) +
", phases: " + QtFreeUtils::boolToYesNo(m_logRenderPhases) +
", TCAS: " + QtFreeUtils::boolToYesNo(m_tcasEnabled) +
", night t.: " + m_nightTextureMode + ", night t.: " + m_nightTextureMode +
", max planes: " + std::to_string(m_maxPlanes) + ", max planes: " + std::to_string(m_maxPlanes) +
", max distance NM: " + std::to_string(m_maxDrawDistanceNM) + ", max distance NM: " + std::to_string(m_maxDrawDistanceNM) +
@@ -138,10 +152,12 @@ namespace BlackMisc
if (m_dBusServerAddress != newValues.m_dBusServerAddress) { m_dBusServerAddress = newValues.m_dBusServerAddress; changed++; } 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_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_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_maxPlanes != newValues.m_maxPlanes) { m_maxPlanes = newValues.m_maxPlanes; changed++; }
if (m_msSinceEpochQtFree != newValues.m_msSinceEpochQtFree) { m_msSinceEpochQtFree = newValues.m_msSinceEpochQtFree; changed++; } if (m_msSinceEpochQtFree != newValues.m_msSinceEpochQtFree) { m_msSinceEpochQtFree = newValues.m_msSinceEpochQtFree; 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 (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 (!QtFreeUtils::isFuzzyEqual(m_maxDrawDistanceNM, newValues.m_maxDrawDistanceNM)) { m_maxDrawDistanceNM = newValues.m_maxDrawDistanceNM; changed++; }

View File

@@ -38,7 +38,7 @@ namespace BlackSimPlugin
CSimulatorXPlaneConfig(QObject *parent = nullptr); CSimulatorXPlaneConfig(QObject *parent = nullptr);
//! Dtor //! Dtor
virtual ~CSimulatorXPlaneConfig() {} virtual ~CSimulatorXPlaneConfig() override {}
//! \copydoc BlackGui::IPluginConfig::createConfigWindow() //! \copydoc BlackGui::IPluginConfig::createConfigWindow()
BlackGui::CPluginConfigWindow *createConfigWindow(QWidget *parent) override; BlackGui::CPluginConfigWindow *createConfigWindow(QWidget *parent) override;

View File

@@ -55,6 +55,8 @@ namespace BlackSimPlugin
m_xSwiftBusServerSettings.set(changed); m_xSwiftBusServerSettings.set(changed);
CXSwiftBusConfigWriter xswiftbusConfigWriter; CXSwiftBusConfigWriter xswiftbusConfigWriter;
xswiftbusConfigWriter.setDBusAddress(changed.getDBusServerAddressQt()); xswiftbusConfigWriter.setDBusAddress(changed.getDBusServerAddressQt());
xswiftbusConfigWriter.setDebugMode(s.isLogRenderPhases());
xswiftbusConfigWriter.setTcasEnabled(s.isTcasEnabled());
xswiftbusConfigWriter.updateInAllXPlaneVersions(); xswiftbusConfigWriter.updateInAllXPlaneVersions();
} }
this->close(); this->close();
@@ -70,6 +72,8 @@ namespace BlackSimPlugin
s.setDrawingLabels(ui->cb_DrawLabels->isChecked()); s.setDrawingLabels(ui->cb_DrawLabels->isChecked());
s.setNightTextureModeQt(ui->cb_NightTextureMode->currentText()); s.setNightTextureModeQt(ui->cb_NightTextureMode->currentText());
s.setBundlingTaxiAndLandingLights(ui->cb_BundleTaxiLandingLights->isChecked()); s.setBundlingTaxiAndLandingLights(ui->cb_BundleTaxiLandingLights->isChecked());
s.setTcasEnabled(ui->cb_TcasEnabled->isChecked());
s.setLogRenderPhases(ui->cb_LogRenderPhases->isChecked());
// left, top, right, bottom, height // left, top, right, bottom, height
s.setMessageBoxValues( s.setMessageBoxValues(
@@ -88,9 +92,11 @@ namespace BlackSimPlugin
ui->comp_SettingsXSwiftBus->set(settings.getDBusServerAddressQt()); ui->comp_SettingsXSwiftBus->set(settings.getDBusServerAddressQt());
ui->sb_MaxAircraft->setValue(settings.getMaxPlanes()); ui->sb_MaxAircraft->setValue(settings.getMaxPlanes());
ui->sb_FollowAircraftDistanceM->setValue(settings.getFollowAircraftDistanceM()); ui->sb_FollowAircraftDistanceM->setValue(settings.getFollowAircraftDistanceM());
ui->cb_DrawLabels->setChecked(settings.isDrawingLabels());
ui->ds_MaxDrawDistanceNM->setValue(settings.getMaxDrawDistanceNM()); ui->ds_MaxDrawDistanceNM->setValue(settings.getMaxDrawDistanceNM());
ui->cb_DrawLabels->setChecked(settings.isDrawingLabels());
ui->cb_BundleTaxiLandingLights->setChecked(settings.isBundlingTaxiAndLandingLights()); 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); const QString s = settings.getNightTextureModeQt().left(1);
if (!s.isEmpty()) if (!s.isEmpty())

View File

@@ -6,14 +6,14 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>300</width> <width>378</width>
<height>450</height> <height>585</height>
</rect> </rect>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>300</width> <width>275</width>
<height>425</height> <height>475</height>
</size> </size>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@@ -158,14 +158,14 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0"> <item row="7" column="0">
<widget class="QLabel" name="lbl_MessageBox"> <widget class="QLabel" name="lbl_MessageBox">
<property name="text"> <property name="text">
<string>Message box </string> <string>Message box </string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="1"> <item row="7" column="1">
<widget class="QWidget" name="wi_MessageBox" native="true"> <widget class="QWidget" name="wi_MessageBox" native="true">
<layout class="QHBoxLayout" name="hl_MessageBox"> <layout class="QHBoxLayout" name="hl_MessageBox">
<property name="leftMargin"> <property name="leftMargin">
@@ -193,33 +193,17 @@
</property> </property>
</widget> </widget>
</item> </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> </layout>
</widget> </widget>
</item> </item>
<item row="6" column="0"> <item row="9" column="0">
<widget class="QLabel" name="lbl_MessageBoxMargins"> <widget class="QLabel" name="lbl_MessageBoxMargins">
<property name="text"> <property name="text">
<string>Box margins px.</string> <string>Box margins px.</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="1"> <item row="9" column="1">
<widget class="QWidget" name="wi_Margins" native="true"> <widget class="QWidget" name="wi_Margins" native="true">
<layout class="QGridLayout" name="gl_MessageBoxMargins"> <layout class="QGridLayout" name="gl_MessageBoxMargins">
<property name="leftMargin"> <property name="leftMargin">
@@ -293,14 +277,14 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="7" column="0"> <item row="10" column="0">
<widget class="QLabel" name="lbl_NightTextureMode"> <widget class="QLabel" name="lbl_NightTextureMode">
<property name="text"> <property name="text">
<string>Night texture</string> <string>Night texture</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="1"> <item row="10" column="1">
<widget class="QComboBox" name="cb_NightTextureMode"> <widget class="QComboBox" name="cb_NightTextureMode">
<item> <item>
<property name="text"> <property name="text">
@@ -319,6 +303,57 @@
</item> </item>
</widget> </widget>
</item> </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> </layout>
</widget> </widget>
</item> </item>
@@ -351,8 +386,9 @@
<tabstop>sb_FollowAircraftDistanceM</tabstop> <tabstop>sb_FollowAircraftDistanceM</tabstop>
<tabstop>cb_DrawLabels</tabstop> <tabstop>cb_DrawLabels</tabstop>
<tabstop>cb_BundleTaxiLandingLights</tabstop> <tabstop>cb_BundleTaxiLandingLights</tabstop>
<tabstop>cb_TcasEnabled</tabstop>
<tabstop>cb_LogRenderPhases</tabstop>
<tabstop>sb_MessageBoxLines</tabstop> <tabstop>sb_MessageBoxLines</tabstop>
<tabstop>sb_MessageBoxDuration</tabstop>
<tabstop>le_MsgBoxMarginsTop</tabstop> <tabstop>le_MsgBoxMarginsTop</tabstop>
<tabstop>le_MsgBoxMarginsBottom</tabstop> <tabstop>le_MsgBoxMarginsBottom</tabstop>
<tabstop>le_MsgBoxMarginsLeft</tabstop> <tabstop>le_MsgBoxMarginsLeft</tabstop>