8 #include "ui_cockpitcomform.h"
17 using namespace swift::misc::aviation;
18 using namespace swift::misc::physical_quantities;
19 using namespace swift::misc::math;
20 using namespace swift::misc::simulation;
21 using namespace swift::core::context;
24 namespace swift::gui::editors
29 this->alignUiElementsHeight();
32 ui->frp_ComPanelSelcalSelector->clear();
34 connect(ui->frp_ComPanelSelcalSelector, &CSelcalCodeSelector::valueChanged,
this,
35 &CCockpitComForm::onSelcalChanged);
38 connect(ui->cbp_ComPanelTransponderMode, &CTransponderModeSelector::transponderModeChanged,
this,
40 connect(ui->cbp_ComPanelTransponderMode, &CTransponderModeSelector::transponderStateIdentEnded,
this,
47 &CCockpitComForm::onGuiChangedCockpitValues);
49 &CCockpitComForm::onGuiChangedCockpitValues);
51 &CCockpitComForm::onGuiChangedCockpitValues);
53 &CCockpitComForm::onGuiChangedCockpitValues);
55 &CCockpitComForm::onGuiChangedCockpitValues);
56 connect(ui->cbp_ComPanelTransponderMode, &CTransponderModeSelector::transponderModeChanged,
this,
57 &CCockpitComForm::onGuiChangedCockpitValues);
58 connect(ui->frp_ComPanelSelcalSelector, &CSelcalCodeSelector::valueChanged,
this,
59 &CCockpitComForm::onGuiChangedCockpitValues);
63 ui->tb_RequestTextMessageCom1->setIcon(CIcons::appTextMessages16());
64 ui->tb_RequestTextMessageCom2->setIcon(CIcons::appTextMessages16());
73 ui->ds_ComPanelCom1Active->setReadOnly(readonly);
74 ui->ds_ComPanelCom2Active->setReadOnly(readonly);
75 ui->ds_ComPanelCom1Standby->setReadOnly(readonly);
76 ui->ds_ComPanelCom2Standby->setReadOnly(readonly);
77 ui->cbp_ComPanelTransponderMode->setDisabled(!readonly);
78 ui->tb_ComPanelCom1Toggle->setEnabled(!readonly);
79 ui->tb_ComPanelCom2Toggle->setEnabled(!readonly);
94 ui->cbp_ComPanelTransponderMode->setSelectedTransponderModeStateIdent();
102 this->alignUiElementsHeight();
103 this->updateIntegratedFlagFromSimulatorContext();
110 void CCockpitComForm::initLeds()
114 ui->led_ComPanelCom1R->setValues(CLedWidget::Yellow, CLedWidget::Black, shape,
"COM1 receive (sim)",
115 "COM1 not receiving", 14);
116 ui->led_ComPanelCom1T->setValues(CLedWidget::Yellow, CLedWidget::Black, shape,
"COM1 transmit (sim)",
117 "COM1 not transmitting", 14);
118 ui->led_ComPanelCom1R->setTriStateValues(CLedWidget::Blue,
"receive not synced");
119 ui->led_ComPanelCom1T->setTriStateValues(CLedWidget::Blue,
"transmit not synced");
121 ui->led_ComPanelCom2R->setValues(CLedWidget::Yellow, CLedWidget::Black, shape,
"COM2 receive (sim)",
122 "COM2 not receiving", 14);
123 ui->led_ComPanelCom2T->setValues(CLedWidget::Yellow, CLedWidget::Black, shape,
"COM2 transmit (sim)",
124 "COM2 not transmitting", 14);
125 ui->led_ComPanelCom2R->setTriStateValues(CLedWidget::Blue,
"receive not synced");
126 ui->led_ComPanelCom2T->setTriStateValues(CLedWidget::Blue,
"transmit not synced");
140 if (CTransponder::isValidTransponderCode(transponderCode)) { transponder.
setTransponderCode(transponderCode); }
146 transponder.
setTransponderMode(ui->cbp_ComPanelTransponderMode->getSelectedTransponderMode());
166 if (!isFrequenceEqual(freq, ui->ds_ComPanelCom1Active->value())) { ui->ds_ComPanelCom1Active->setValue(freq); }
169 if (!isFrequenceEqual(freq, ui->ds_ComPanelCom2Active->value())) { ui->ds_ComPanelCom2Active->setValue(freq); }
172 if (!isFrequenceEqual(freq, ui->ds_ComPanelCom1Standby->value()))
174 ui->ds_ComPanelCom1Standby->setValue(freq);
178 if (!isFrequenceEqual(freq, ui->ds_ComPanelCom2Standby->value()))
180 ui->ds_ComPanelCom2Standby->setValue(freq);
183 this->updateIntegratedFlagFromSimulatorContext();
191 if (tc != ui->sbp_ComPanelTransponder->value()) { ui->sbp_ComPanelTransponder->setValue(tc); }
193 if (transponder.
getTransponderMode() != ui->cbp_ComPanelTransponderMode->getSelectedTransponderMode())
195 ui->cbp_ComPanelTransponderMode->setSelectedTransponderMode(transponder.
getTransponderMode());
200 void CCockpitComForm::onGuiChangedCockpitValues()
203 if (
sender == ui->tb_ComPanelCom1Toggle)
205 if (isFrequenceEqual(ui->ds_ComPanelCom1Standby->value(), ui->ds_ComPanelCom1Active->value())) {
return; }
206 const double f = ui->ds_ComPanelCom1Active->value();
207 ui->ds_ComPanelCom1Active->setValue(ui->ds_ComPanelCom1Standby->value());
208 ui->ds_ComPanelCom1Standby->setValue(f);
210 else if (
sender == ui->tb_ComPanelCom2Toggle)
212 if (isFrequenceEqual(ui->ds_ComPanelCom2Standby->value(), ui->ds_ComPanelCom2Active->value())) {
return; }
213 const double f = ui->ds_ComPanelCom2Active->value();
214 ui->ds_ComPanelCom2Active->setValue(ui->ds_ComPanelCom2Standby->value());
215 ui->ds_ComPanelCom2Standby->setValue(f);
218 this->alignUiElementsHeight();
223 void CCockpitComForm::onSelcalChanged()
225 const CSelcal selcal = ui->frp_ComPanelSelcalSelector->getSelcal();
229 void CCockpitComForm::alignUiElementsHeight()
231 const int selcalH = ui->frp_ComPanelSelcalSelector->getComboBoxHeight();
232 if (selcalH > ui->ds_ComPanelCom1Standby->height())
234 ui->ds_ComPanelCom1Standby->setMinimumHeight(selcalH);
235 ui->ds_ComPanelCom2Standby->setMinimumHeight(selcalH);
238 const int xpdrH = ui->cbp_ComPanelTransponderMode->height();
239 if (xpdrH > ui->ds_ComPanelCom1Active->height())
241 ui->ds_ComPanelCom1Active->setMinimumHeight(xpdrH);
242 ui->ds_ComPanelCom2Active->setMinimumHeight(xpdrH);
243 ui->sbp_ComPanelTransponder->setMinimumHeight(xpdrH);
247 void CCockpitComForm::updateActiveCOMUnitLEDs(
bool integratedWithSim,
bool com1T,
bool com1R,
bool com2T,
250 if (!integratedWithSim)
252 ui->led_ComPanelCom1R->setTriState();
253 ui->led_ComPanelCom1T->setTriState();
254 ui->led_ComPanelCom2R->setTriState();
255 ui->led_ComPanelCom2T->setTriState();
259 ui->led_ComPanelCom1R->setOn(com1R);
260 ui->led_ComPanelCom1T->setOn(com1T);
261 ui->led_ComPanelCom2R->setOn(com2R);
262 ui->led_ComPanelCom2T->setOn(com2T);
266 void CCockpitComForm::updateIntegratedFlagFromSimulatorContext()
270 m_integratedWithSim =
false;
274 m_integratedWithSim = integrated;
277 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.
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QObject * sender() const const
QString number(double n, char format, int precision)