8 #include "ui_cockpitcomform.h"
17 using namespace swift::misc::aviation;
18 using namespace swift::misc::audio;
19 using namespace swift::misc::physical_quantities;
20 using namespace swift::misc::math;
21 using namespace swift::misc::simulation;
22 using namespace swift::core::context;
25 namespace swift::gui::editors
30 this->alignUiElementsHeight();
33 ui->frp_ComPanelSelcalSelector->clear();
35 connect(ui->frp_ComPanelSelcalSelector, &CSelcalCodeSelector::valueChanged,
this,
36 &CCockpitComForm::onSelcalChanged);
39 connect(ui->cbp_ComPanelTransponderMode, &CTransponderModeSelector::transponderModeChanged,
this,
41 connect(ui->cbp_ComPanelTransponderMode, &CTransponderModeSelector::transponderStateIdentEnded,
this,
45 connect(ui->tb_ComPanelCom1Toggle, &QPushButton::clicked,
this, &CCockpitComForm::onGuiChangedCockpitValues);
46 connect(ui->tb_ComPanelCom2Toggle, &QPushButton::clicked,
this, &CCockpitComForm::onGuiChangedCockpitValues);
47 connect(ui->ds_ComPanelCom1Active, &QDoubleSpinBox::editingFinished,
this,
48 &CCockpitComForm::onGuiChangedCockpitValues);
49 connect(ui->ds_ComPanelCom2Active, &QDoubleSpinBox::editingFinished,
this,
50 &CCockpitComForm::onGuiChangedCockpitValues);
51 connect(ui->ds_ComPanelCom1Standby, &QDoubleSpinBox::editingFinished,
this,
52 &CCockpitComForm::onGuiChangedCockpitValues);
53 connect(ui->ds_ComPanelCom2Standby, &QDoubleSpinBox::editingFinished,
this,
54 &CCockpitComForm::onGuiChangedCockpitValues);
55 connect(ui->sbp_ComPanelTransponder, &QDoubleSpinBox::editingFinished,
this,
56 &CCockpitComForm::onGuiChangedCockpitValues);
57 connect(ui->cbp_ComPanelTransponderMode, &CTransponderModeSelector::transponderModeChanged,
this,
58 &CCockpitComForm::onGuiChangedCockpitValues);
59 connect(ui->frp_ComPanelSelcalSelector, &CSelcalCodeSelector::valueChanged,
this,
60 &CCockpitComForm::onGuiChangedCockpitValues);
64 ui->tb_RequestTextMessageCom1->setIcon(CIcons::appTextMessages16());
65 ui->tb_RequestTextMessageCom2->setIcon(CIcons::appTextMessages16());
74 ui->ds_ComPanelCom1Active->setReadOnly(readonly);
75 ui->ds_ComPanelCom2Active->setReadOnly(readonly);
76 ui->ds_ComPanelCom1Standby->setReadOnly(readonly);
77 ui->ds_ComPanelCom2Standby->setReadOnly(readonly);
78 ui->cbp_ComPanelTransponderMode->setDisabled(!readonly);
79 ui->tb_ComPanelCom1Toggle->setEnabled(!readonly);
80 ui->tb_ComPanelCom2Toggle->setEnabled(!readonly);
95 ui->cbp_ComPanelTransponderMode->setSelectedTransponderModeStateIdent();
103 this->alignUiElementsHeight();
104 this->updateIntegratedFlagFromSimulatorContext();
111 void CCockpitComForm::initLeds()
115 ui->led_ComPanelCom1R->setValues(CLedWidget::Yellow, CLedWidget::Black, shape,
"COM1 receive (sim)",
116 "COM1 not receiving", 14);
117 ui->led_ComPanelCom1T->setValues(CLedWidget::Yellow, CLedWidget::Black, shape,
"COM1 transmit (sim)",
118 "COM1 not transmitting", 14);
119 ui->led_ComPanelCom1R->setTriStateValues(CLedWidget::Blue,
"receive not synced");
120 ui->led_ComPanelCom1T->setTriStateValues(CLedWidget::Blue,
"transmit not synced");
122 ui->led_ComPanelCom2R->setValues(CLedWidget::Yellow, CLedWidget::Black, shape,
"COM2 receive (sim)",
123 "COM2 not receiving", 14);
124 ui->led_ComPanelCom2T->setValues(CLedWidget::Yellow, CLedWidget::Black, shape,
"COM2 transmit (sim)",
125 "COM2 not transmitting", 14);
126 ui->led_ComPanelCom2R->setTriStateValues(CLedWidget::Blue,
"receive not synced");
127 ui->led_ComPanelCom2T->setTriStateValues(CLedWidget::Blue,
"transmit not synced");
140 const QString transponderCode = QString::number(ui->sbp_ComPanelTransponder->value());
141 if (CTransponder::isValidTransponderCode(transponderCode)) { transponder.
setTransponderCode(transponderCode); }
147 transponder.
setTransponderMode(ui->cbp_ComPanelTransponderMode->getSelectedTransponderMode());
167 if (!isFrequenceEqual(freq, ui->ds_ComPanelCom1Active->value())) { ui->ds_ComPanelCom1Active->setValue(freq); }
170 if (!isFrequenceEqual(freq, ui->ds_ComPanelCom2Active->value())) { ui->ds_ComPanelCom2Active->setValue(freq); }
173 if (!isFrequenceEqual(freq, ui->ds_ComPanelCom1Standby->value()))
175 ui->ds_ComPanelCom1Standby->setValue(freq);
179 if (!isFrequenceEqual(freq, ui->ds_ComPanelCom2Standby->value()))
181 ui->ds_ComPanelCom2Standby->setValue(freq);
184 this->updateIntegratedFlagFromSimulatorContext();
192 if (tc != ui->sbp_ComPanelTransponder->value()) { ui->sbp_ComPanelTransponder->setValue(tc); }
194 if (transponder.
getTransponderMode() != ui->cbp_ComPanelTransponderMode->getSelectedTransponderMode())
196 ui->cbp_ComPanelTransponderMode->setSelectedTransponderMode(transponder.
getTransponderMode());
201 void CCockpitComForm::onGuiChangedCockpitValues()
203 const QObject *sender = QObject::sender();
204 if (sender == ui->tb_ComPanelCom1Toggle)
206 if (isFrequenceEqual(ui->ds_ComPanelCom1Standby->value(), ui->ds_ComPanelCom1Active->value())) {
return; }
207 const double f = ui->ds_ComPanelCom1Active->value();
208 ui->ds_ComPanelCom1Active->setValue(ui->ds_ComPanelCom1Standby->value());
209 ui->ds_ComPanelCom1Standby->setValue(f);
211 else if (sender == ui->tb_ComPanelCom2Toggle)
213 if (isFrequenceEqual(ui->ds_ComPanelCom2Standby->value(), ui->ds_ComPanelCom2Active->value())) {
return; }
214 const double f = ui->ds_ComPanelCom2Active->value();
215 ui->ds_ComPanelCom2Active->setValue(ui->ds_ComPanelCom2Standby->value());
216 ui->ds_ComPanelCom2Standby->setValue(f);
219 this->alignUiElementsHeight();
224 void CCockpitComForm::onSelcalChanged()
226 const CSelcal selcal = ui->frp_ComPanelSelcalSelector->getSelcal();
230 void CCockpitComForm::alignUiElementsHeight()
232 const int selcalH = ui->frp_ComPanelSelcalSelector->getComboBoxHeight();
233 if (selcalH > ui->ds_ComPanelCom1Standby->height())
235 ui->ds_ComPanelCom1Standby->setMinimumHeight(selcalH);
236 ui->ds_ComPanelCom2Standby->setMinimumHeight(selcalH);
239 const int xpdrH = ui->cbp_ComPanelTransponderMode->height();
240 if (xpdrH > ui->ds_ComPanelCom1Active->height())
242 ui->ds_ComPanelCom1Active->setMinimumHeight(xpdrH);
243 ui->ds_ComPanelCom2Active->setMinimumHeight(xpdrH);
244 ui->sbp_ComPanelTransponder->setMinimumHeight(xpdrH);
248 void CCockpitComForm::updateActiveCOMUnitLEDs(
bool integratedWithSim,
bool com1T,
bool com1R,
bool com2T,
251 if (!integratedWithSim)
253 ui->led_ComPanelCom1R->setTriState();
254 ui->led_ComPanelCom1T->setTriState();
255 ui->led_ComPanelCom2R->setTriState();
256 ui->led_ComPanelCom2T->setTriState();
260 ui->led_ComPanelCom1R->setOn(com1R);
261 ui->led_ComPanelCom1T->setOn(com1T);
262 ui->led_ComPanelCom2R->setOn(com2R);
263 ui->led_ComPanelCom2T->setOn(com2T);
267 void CCockpitComForm::updateIntegratedFlagFromSimulatorContext()
271 m_integratedWithSim =
false;
275 m_integratedWithSim = integrated;
278 bool CCockpitComForm::isFrequenceEqual(
double f1,
double f2) {
return CMathUtils::epsilonEqual(f1, f2); }
bool isShuttingDown() const
Is application shutting down?
const context::IContextSimulator * getIContextSimulator() const
Direct access to contexts if a CCoreFacade has been initialized.
virtual swift::misc::simulation::settings::CSimulatorSettings getSimulatorSettings() const =0
Get the current simulator settings.
Class for emitting a log message.
Derived & validationWarning(const char16_t(&format)[N])
Set the severity to warning, providing a format string, and adding the validation category.
Status messages, e.g. from Core -> GUI.
void setFrequencyActiveMHz(double frequencyMHz)
Set active frequency.
void setFrequencyStandbyMHz(double frequencyMHz)
Set standby frequency.
bool isTransmitEnabled() const
Enabled?
swift::misc::physical_quantities::CFrequency getFrequencyStandby() const
Standby frequency.
bool isReceiveEnabled() const
Enabled?
swift::misc::physical_quantities::CFrequency getFrequencyActive() const
Active frequency.
void setTransponderCode(int transponderCode)
Set transponder code.
int getTransponderCode() const
Transponder code.
bool setTransponderMode(TransponderMode mode)
Set transponder mode.
TransponderMode getTransponderMode() const
Transponder mode.
double valueRounded(MU unit, int digits=-1) const
Rounded value in given unit.
Comprehensive information of an aircraft.
const aviation::CSelcal getSelcal() const
SELCAL.
const aviation::CComSystem & getCom2System() const
Get COM2 system.
const aviation::CTransponder & getTransponder() const
Get transponder.
void setCom1System(const aviation::CComSystem &comSystem)
Set COM1 system.
void setTransponder(const aviation::CTransponder &transponder)
Set transponder.
void setCom2System(const aviation::CComSystem &comSystem)
Set COM2 system.
const aviation::CComSystem & getCom1System() const
Get COM1 system.
bool isComIntegrated() const
COM unit integration.
SWIFT_GUI_EXPORT swift::gui::CGuiApplication * sGui
Single instance of GUI application object.
High level reusable GUI components.
Free functions in swift::misc.