Improved rounding for COM frequencies to 25KHz in GUI

This commit is contained in:
Klaus Basan
2014-01-20 13:18:34 +01:00
parent 4f8b63cdf1
commit f0b97aac24
3 changed files with 39 additions and 21 deletions

View File

@@ -176,6 +176,13 @@ private:
*/ */
bool isCockpitUpdatePending() const; bool isCockpitUpdatePending() const;
/*!
* \brief Round the com frequency display
* \param com1
* \param com2
*/
void roundComFrequencyDisplays(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2);
/*! /*!
* \brief Add new text message tab * \brief Add new text message tab
* \param tabName * \param tabName

View File

@@ -388,7 +388,7 @@ QSizeGrip {
<enum>QFrame::NoFrame</enum> <enum>QFrame::NoFrame</enum>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>6</number> <number>3</number>
</property> </property>
<widget class="QWidget" name="pg_StatusPage"> <widget class="QWidget" name="pg_StatusPage">
<property name="sizePolicy"> <property name="sizePolicy">
@@ -894,7 +894,7 @@ QSizeGrip {
<double>136.000000000000000</double> <double>136.000000000000000</double>
</property> </property>
<property name="singleStep"> <property name="singleStep">
<double>0.250000000000000</double> <double>0.025000000000000</double>
</property> </property>
<property name="value"> <property name="value">
<double>118.000000000000000</double> <double>118.000000000000000</double>
@@ -946,7 +946,7 @@ QSizeGrip {
<double>136.000000000000000</double> <double>136.000000000000000</double>
</property> </property>
<property name="singleStep"> <property name="singleStep">
<double>0.250000000000000</double> <double>0.025000000000000</double>
</property> </property>
<property name="value"> <property name="value">
<double>119.000000000000000</double> <double>119.000000000000000</double>
@@ -980,7 +980,7 @@ QSizeGrip {
<double>136.000000000000000</double> <double>136.000000000000000</double>
</property> </property>
<property name="singleStep"> <property name="singleStep">
<double>0.250000000000000</double> <double>0.025000000000000</double>
</property> </property>
<property name="value"> <property name="value">
<double>118.250000000000000</double> <double>118.250000000000000</double>
@@ -1011,7 +1011,7 @@ QSizeGrip {
<double>136.000000000000000</double> <double>136.000000000000000</double>
</property> </property>
<property name="singleStep"> <property name="singleStep">
<double>0.250000000000000</double> <double>0.025000000000000</double>
</property> </property>
<property name="value"> <property name="value">
<double>119.250000000000000</double> <double>119.250000000000000</double>

View File

@@ -54,6 +54,7 @@ void MainWindow::cockpitValuesChanged()
} }
// this will call send cockpit updates with all changes made // this will call send cockpit updates with all changes made
// send cockpit updates
this->m_timerCollectedCockpitUpdates->stop(); this->m_timerCollectedCockpitUpdates->stop();
this->m_timerCollectedCockpitUpdates->start(1000); // start this->m_timerCollectedCockpitUpdates->start(1000); // start
this->m_timerCollectedCockpitUpdates->setSingleShot(true); this->m_timerCollectedCockpitUpdates->setSingleShot(true);
@@ -78,22 +79,7 @@ void MainWindow::updateCockpitFromContext()
const CComSystem com2 = this->m_ownAircraft.getCom2System(); const CComSystem com2 = this->m_ownAircraft.getCom2System();
const CTransponder transponder = this->m_ownAircraft.getTransponder(); const CTransponder transponder = this->m_ownAircraft.getTransponder();
double freq = com1.getFrequencyActive().valueRounded(3); this->roundComFrequencyDisplays(com1, com2);
if (freq != this->ui->ds_CockpitCom1Active->value())
this->ui->ds_CockpitCom1Active->setValue(freq);
freq = com2.getFrequencyActive().valueRounded(3);
if (freq != this->ui->ds_CockpitCom2Active->value())
this->ui->ds_CockpitCom2Active->setValue(freq);
freq = com1.getFrequencyStandby().valueRounded(3);
if (freq != this->ui->ds_CockpitCom1Standby->value())
this->ui->ds_CockpitCom1Standby->setValue(freq);
freq = com2.getFrequencyStandby().valueRounded(3);
if (freq != this->ui->ds_CockpitCom2Standby->value())
this->ui->ds_CockpitCom2Standby->setValue(freq);
qint32 tc = transponder.getTransponderCode(); qint32 tc = transponder.getTransponderCode();
if (tc != static_cast<qint32>(this->ui->ds_CockpitTransponder->value())) if (tc != static_cast<qint32>(this->ui->ds_CockpitTransponder->value()))
this->ui->ds_CockpitTransponder->setValue(tc); this->ui->ds_CockpitTransponder->setValue(tc);
@@ -146,6 +132,30 @@ void MainWindow::updateCockpitFromContext()
} }
} }
/*
* Round the com frequency displays
*/
void MainWindow::roundComFrequencyDisplays(const CComSystem &com1, const CComSystem &com2)
{
// do not just set! Leads to unwanted signals fired
double freq = com1.getFrequencyActive().valueRounded(3);
if (freq != this->ui->ds_CockpitCom1Active->value())
this->ui->ds_CockpitCom1Active->setValue(freq);
freq = com2.getFrequencyActive().valueRounded(3);
if (freq != this->ui->ds_CockpitCom2Active->value())
this->ui->ds_CockpitCom2Active->setValue(freq);
freq = com1.getFrequencyStandby().valueRounded(3);
if (freq != this->ui->ds_CockpitCom1Standby->value())
this->ui->ds_CockpitCom1Standby->setValue(freq);
freq = com2.getFrequencyStandby().valueRounded(3);
if (freq != this->ui->ds_CockpitCom2Standby->value())
this->ui->ds_CockpitCom2Standby->setValue(freq);
}
/* /*
* Reset transponder mode to Standby / Charly * Reset transponder mode to Standby / Charly
*/ */
@@ -210,6 +220,7 @@ void MainWindow::sendCockpitUpdates()
com1.setFrequencyStandbyMHz(this->ui->ds_CockpitCom1Standby->value()); com1.setFrequencyStandbyMHz(this->ui->ds_CockpitCom1Standby->value());
com2.setFrequencyActiveMHz(this->ui->ds_CockpitCom2Active->value()); com2.setFrequencyActiveMHz(this->ui->ds_CockpitCom2Active->value());
com2.setFrequencyStandbyMHz(this->ui->ds_CockpitCom2Standby->value()); com2.setFrequencyStandbyMHz(this->ui->ds_CockpitCom2Standby->value());
this->roundComFrequencyDisplays(com1, com2);
// //
// Send to context // Send to context