mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-04 08:55:43 +08:00
[Weather] Allow to trigger reload of weather from UI
This commit is contained in:
committed by
Mat Sutcliffe
parent
c2ecf167b7
commit
24bc57ac32
@@ -77,7 +77,6 @@ namespace BlackCore
|
|||||||
m_plugins->collectPlugins();
|
m_plugins->collectPlugins();
|
||||||
this->restoreSimulatorPlugins();
|
this->restoreSimulatorPlugins();
|
||||||
|
|
||||||
connect(&m_weatherManager, &CWeatherManager::weatherGridReceived, this, &CContextSimulator::weatherGridReceived, Qt::QueuedConnection);
|
|
||||||
connect(&m_weatherManager, &CWeatherManager::weatherGridReceived, this, &CContextSimulator::onWeatherGridReceived, Qt::QueuedConnection);
|
connect(&m_weatherManager, &CWeatherManager::weatherGridReceived, this, &CContextSimulator::onWeatherGridReceived, Qt::QueuedConnection);
|
||||||
connect(&m_aircraftMatcher, &CAircraftMatcher::setupChanged, this, &CContextSimulator::matchingSetupChanged);
|
connect(&m_aircraftMatcher, &CAircraftMatcher::setupChanged, this, &CContextSimulator::matchingSetupChanged);
|
||||||
connect(&CCentralMultiSimulatorModelSetCachesProvider::modelCachesInstance(), &CCentralMultiSimulatorModelSetCachesProvider::cacheChanged, this, &CContextSimulator::modelSetChanged);
|
connect(&CCentralMultiSimulatorModelSetCachesProvider::modelCachesInstance(), &CCentralMultiSimulatorModelSetCachesProvider::cacheChanged, this, &CContextSimulator::modelSetChanged);
|
||||||
@@ -882,6 +881,9 @@ namespace BlackCore
|
|||||||
|
|
||||||
void CContextSimulator::onWeatherGridReceived(const CWeatherGrid &weatherGrid, const CIdentifier &identifier)
|
void CContextSimulator::onWeatherGridReceived(const CWeatherGrid &weatherGrid, const CIdentifier &identifier)
|
||||||
{
|
{
|
||||||
|
if (!sApp || sApp->isShuttingDown()) { return; }
|
||||||
|
emit this->weatherGridReceived(weatherGrid, identifier);
|
||||||
|
|
||||||
if (!this->isSimulatorPluginAvailable()) { return; }
|
if (!this->isSimulatorPluginAvailable()) { return; }
|
||||||
if (!m_simulatorPlugin.second) { return; }
|
if (!m_simulatorPlugin.second) { return; }
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ namespace BlackGui
|
|||||||
m_coordinateDialog->showElevation(false);
|
m_coordinateDialog->showElevation(false);
|
||||||
m_coordinateDialog->setReadOnly(ui->cb_UseOwnAcftPosition->isChecked());
|
m_coordinateDialog->setReadOnly(ui->cb_UseOwnAcftPosition->isChecked());
|
||||||
connect(ui->pb_SetPosition, &QPushButton::clicked, this, &CWeatherComponent::showCoordinateDialog);
|
connect(ui->pb_SetPosition, &QPushButton::clicked, this, &CWeatherComponent::showCoordinateDialog);
|
||||||
|
connect(ui->pb_Update, &QPushButton::clicked, this, &CWeatherComponent::updateWeatherInformationForced);
|
||||||
|
|
||||||
m_weatherScenarios = CWeatherGrid::getAllScenarios();
|
m_weatherScenarios = CWeatherGrid::getAllScenarios();
|
||||||
for (const auto &scenario : as_const(m_weatherScenarios))
|
for (const auto &scenario : as_const(m_weatherScenarios))
|
||||||
@@ -76,11 +77,9 @@ namespace BlackGui
|
|||||||
QPointer<CWeatherComponent> myself(this);
|
QPointer<CWeatherComponent> myself(this);
|
||||||
QTimer::singleShot(1000, this, [ = ]
|
QTimer::singleShot(1000, this, [ = ]
|
||||||
{
|
{
|
||||||
if (myself)
|
if (!myself) { return; }
|
||||||
{
|
myself->updateWeatherInformation(true);
|
||||||
myself->updateWeatherInformation();
|
|
||||||
myself->updateWeatherInfoLine();
|
myself->updateWeatherInfoLine();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +89,7 @@ namespace BlackGui
|
|||||||
bool CWeatherComponent::setParentDockWidgetInfoArea(CDockWidgetInfoArea *parentDockableWidget)
|
bool CWeatherComponent::setParentDockWidgetInfoArea(CDockWidgetInfoArea *parentDockableWidget)
|
||||||
{
|
{
|
||||||
CEnableForDockWidgetInfoArea::setParentDockWidgetInfoArea(parentDockableWidget);
|
CEnableForDockWidgetInfoArea::setParentDockWidgetInfoArea(parentDockableWidget);
|
||||||
bool c = connect(this->getParentInfoArea(), &CInfoArea::changedInfoAreaTabBarIndex, this, &CWeatherComponent::infoAreaTabBarChanged, Qt::QueuedConnection);
|
const bool c = connect(this->getParentInfoArea(), &CInfoArea::changedInfoAreaTabBarIndex, this, &CWeatherComponent::infoAreaTabBarChanged, Qt::QueuedConnection);
|
||||||
Q_ASSERT_X(c, Q_FUNC_INFO, "failed connect");
|
Q_ASSERT_X(c, Q_FUNC_INFO, "failed connect");
|
||||||
Q_ASSERT_X(parentDockableWidget, Q_FUNC_INFO, "missing parent");
|
Q_ASSERT_X(parentDockableWidget, Q_FUNC_INFO, "missing parent");
|
||||||
return c && parentDockableWidget;
|
return c && parentDockableWidget;
|
||||||
@@ -123,7 +122,7 @@ namespace BlackGui
|
|||||||
m_coordinateDialog->setCoordinate(c);
|
m_coordinateDialog->setCoordinate(c);
|
||||||
ui->pb_SetPosition->setText("Select Position");
|
ui->pb_SetPosition->setText("Select Position");
|
||||||
}
|
}
|
||||||
updateWeatherInformation();
|
updateWeatherInformation(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWeatherComponent::toggleWeatherActivation()
|
void CWeatherComponent::toggleWeatherActivation()
|
||||||
@@ -154,7 +153,7 @@ namespace BlackGui
|
|||||||
m_lastOwnAircraftPosition = {};
|
m_lastOwnAircraftPosition = {};
|
||||||
const CWeatherScenario scenario = m_weatherScenarios[index];
|
const CWeatherScenario scenario = m_weatherScenarios[index];
|
||||||
m_weatherScenarioSetting.set(scenario);
|
m_weatherScenarioSetting.set(scenario);
|
||||||
this->updateWeatherInformation();
|
this->updateWeatherInformation(false);
|
||||||
this->updateWeatherInfoLine();
|
this->updateWeatherInfoLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,7 +184,7 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWeatherComponent::updateWeatherInformation()
|
void CWeatherComponent::updateWeatherInformation(bool forceRealWeatherReload)
|
||||||
{
|
{
|
||||||
setWeatherGrid({});
|
setWeatherGrid({});
|
||||||
ui->lbl_Status->setText({});
|
ui->lbl_Status->setText({});
|
||||||
@@ -212,7 +211,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
if (CWeatherScenario::isRealWeatherScenario(scenario))
|
if (CWeatherScenario::isRealWeatherScenario(scenario))
|
||||||
{
|
{
|
||||||
if (m_lastOwnAircraftPosition.isNull() ||
|
if (m_lastOwnAircraftPosition.isNull() || forceRealWeatherReload ||
|
||||||
calculateGreatCircleDistance(position, m_lastOwnAircraftPosition).value(CLengthUnit::km()) > 20)
|
calculateGreatCircleDistance(position, m_lastOwnAircraftPosition).value(CLengthUnit::km()) > 20)
|
||||||
{
|
{
|
||||||
this->requestWeatherGrid(position);
|
this->requestWeatherGrid(position);
|
||||||
@@ -244,10 +243,10 @@ namespace BlackGui
|
|||||||
void CWeatherComponent::setupConnections()
|
void CWeatherComponent::setupConnections()
|
||||||
{
|
{
|
||||||
// UI connections
|
// UI connections
|
||||||
|
connect(m_coordinateDialog.data(), &CCoordinateDialog::changedCoordinate, this, &CWeatherComponent::updateWeatherInformationForced);
|
||||||
|
connect(&m_weatherUpdateTimer, &QTimer::timeout, this, &CWeatherComponent::updateWeatherInformationChecked);
|
||||||
connect(ui->cb_weatherScenario, qOverload<int>(&QComboBox::currentIndexChanged), this, &CWeatherComponent::setWeatherScenario);
|
connect(ui->cb_weatherScenario, qOverload<int>(&QComboBox::currentIndexChanged), this, &CWeatherComponent::setWeatherScenario);
|
||||||
connect(m_coordinateDialog.data(), &CCoordinateDialog::changedCoordinate, this, &CWeatherComponent::updateWeatherInformation);
|
|
||||||
connect(ui->cb_UseOwnAcftPosition, &QCheckBox::toggled, this, &CWeatherComponent::toggleUseOwnAircraftPosition);
|
connect(ui->cb_UseOwnAcftPosition, &QCheckBox::toggled, this, &CWeatherComponent::toggleUseOwnAircraftPosition);
|
||||||
connect(&m_weatherUpdateTimer, &QTimer::timeout, this, &CWeatherComponent::updateWeatherInformation);
|
|
||||||
connect(ui->pb_ActivateWeather, &QPushButton::clicked, this, &CWeatherComponent::toggleWeatherActivation);
|
connect(ui->pb_ActivateWeather, &QPushButton::clicked, this, &CWeatherComponent::toggleWeatherActivation);
|
||||||
|
|
||||||
// Context connections
|
// Context connections
|
||||||
|
|||||||
@@ -65,7 +65,9 @@ namespace BlackGui
|
|||||||
void setCavok();
|
void setCavok();
|
||||||
|
|
||||||
void updateWeatherInfoLine();
|
void updateWeatherInfoLine();
|
||||||
void updateWeatherInformation();
|
void updateWeatherInformationForced() { this->updateWeatherInformation(true); }
|
||||||
|
void updateWeatherInformationChecked() { this->updateWeatherInformation(false); }
|
||||||
|
void updateWeatherInformation(bool forceRealWeatherReload);
|
||||||
void onWeatherGridReceived(const BlackMisc::Weather::CWeatherGrid &weatherGrid, const BlackMisc::CIdentifier &identifier);
|
void onWeatherGridReceived(const BlackMisc::Weather::CWeatherGrid &weatherGrid, const BlackMisc::CIdentifier &identifier);
|
||||||
|
|
||||||
void setupConnections();
|
void setupConnections();
|
||||||
@@ -78,7 +80,7 @@ namespace BlackGui
|
|||||||
QScopedPointer<Ui::CWeatherComponent> ui;
|
QScopedPointer<Ui::CWeatherComponent> ui;
|
||||||
QScopedPointer<CCoordinateDialog> m_coordinateDialog { new CCoordinateDialog(this) };
|
QScopedPointer<CCoordinateDialog> m_coordinateDialog { new CCoordinateDialog(this) };
|
||||||
QVector<BlackMisc::Weather::CWeatherScenario> m_weatherScenarios;
|
QVector<BlackMisc::Weather::CWeatherScenario> m_weatherScenarios;
|
||||||
QTimer m_weatherUpdateTimer;
|
QTimer m_weatherUpdateTimer; //!< this is the timer for weather updates
|
||||||
BlackMisc::Geo::CCoordinateGeodetic m_lastOwnAircraftPosition;
|
BlackMisc::Geo::CCoordinateGeodetic m_lastOwnAircraftPosition;
|
||||||
BlackMisc::CSetting<BlackMisc::Simulation::Settings::TSelectedWeatherScenario> m_weatherScenarioSetting { this, &CWeatherComponent::onScenarioChanged };
|
BlackMisc::CSetting<BlackMisc::Simulation::Settings::TSelectedWeatherScenario> m_weatherScenarioSetting { this, &CWeatherComponent::onScenarioChanged };
|
||||||
BlackCore::CActionBindings m_hotkeyBindings; //!< allow binding of hotkey
|
BlackCore::CActionBindings m_hotkeyBindings; //!< allow binding of hotkey
|
||||||
|
|||||||
@@ -34,27 +34,52 @@
|
|||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="gb_weatherControl">
|
<widget class="QGroupBox" name="gb_weatherControl">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>100</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Weather Control</string>
|
<string>Weather Control</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gl_WeatherComponent">
|
<layout class="QGridLayout" name="gl_WeatherComponent">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
<item row="0" column="0" colspan="2">
|
<item row="0" column="0" colspan="2">
|
||||||
<widget class="QComboBox" name="cb_weatherScenario"/>
|
<widget class="QComboBox" name="cb_weatherScenario"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="2">
|
<item row="0" column="2">
|
||||||
<widget class="QPushButton" name="pb_ActivateWeather">
|
<widget class="QPushButton" name="pb_ActivateWeather">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Activate</string>
|
<string>activate</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0" colspan="3">
|
<item row="1" column="0" colspan="2">
|
||||||
<widget class="QLabel" name="lbl_WeatherEngineInfo">
|
<widget class="QLabel" name="lbl_WeatherEngineInfo">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>info goes here</string>
|
<string>info goes here</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="2">
|
||||||
|
<widget class="QPushButton" name="pb_Update">
|
||||||
|
<property name="text">
|
||||||
|
<string>update</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -100,7 +125,7 @@
|
|||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Show Position</string>
|
<string>show Position</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -267,6 +292,17 @@
|
|||||||
<header>blackgui/views/windlayerview.h</header>
|
<header>blackgui/views/windlayerview.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
|
<tabstops>
|
||||||
|
<tabstop>cb_weatherScenario</tabstop>
|
||||||
|
<tabstop>pb_ActivateWeather</tabstop>
|
||||||
|
<tabstop>pb_Update</tabstop>
|
||||||
|
<tabstop>cb_UseOwnAcftPosition</tabstop>
|
||||||
|
<tabstop>pb_SetPosition</tabstop>
|
||||||
|
<tabstop>tw_weatherGrid</tabstop>
|
||||||
|
<tabstop>tvp_TemperatureLayers</tabstop>
|
||||||
|
<tabstop>tvp_CloudLayers</tabstop>
|
||||||
|
<tabstop>tvp_WindLayers</tabstop>
|
||||||
|
</tabstops>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|||||||
Reference in New Issue
Block a user