From 3692ef75f270013ff5da3c609002d0ff8c5a69bc Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Sun, 16 Oct 2022 01:17:10 -0500 Subject: [PATCH] Move to alert when pressing go button - Still need an option to auto-update to nearest WSR-88D site --- scwx-qt/source/scwx/qt/main/main_window.cpp | 7 +++++++ scwx-qt/source/scwx/qt/map/map_widget.cpp | 9 +++++++++ scwx-qt/source/scwx/qt/map/map_widget.hpp | 1 + scwx-qt/source/scwx/qt/ui/alert_dock_widget.cpp | 5 +++-- scwx-qt/source/scwx/qt/ui/alert_dock_widget.hpp | 3 +++ 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/scwx-qt/source/scwx/qt/main/main_window.cpp b/scwx-qt/source/scwx/qt/main/main_window.cpp index ad69cdbd..542f279e 100644 --- a/scwx-qt/source/scwx/qt/main/main_window.cpp +++ b/scwx-qt/source/scwx/qt/main/main_window.cpp @@ -470,6 +470,13 @@ void MainWindowImpl::ConnectOtherSignals() alertDockWidget_, &ui::AlertDockWidget::HandleMapUpdate, Qt::QueuedConnection); + connect( + alertDockWidget_, + &ui::AlertDockWidget::MoveMap, + this, + [=](double latitude, double longitude) + { activeMap_->SetMapLocation(latitude, longitude); }, + Qt::QueuedConnection); connect(mainWindow_, &MainWindow::ActiveMapMoved, radarSiteDialog_, diff --git a/scwx-qt/source/scwx/qt/map/map_widget.cpp b/scwx-qt/source/scwx/qt/map/map_widget.cpp index 026c7edc..f2ac4e22 100644 --- a/scwx-qt/source/scwx/qt/map/map_widget.cpp +++ b/scwx-qt/source/scwx/qt/map/map_widget.cpp @@ -439,6 +439,15 @@ void MapWidget::SetAutoRefresh(bool enabled) } } +void MapWidget::SetMapLocation(double latitude, double longitude) +{ + if (p->map_ != nullptr && p->prevLatitude_ != latitude || + p->prevLongitude_ != longitude) + { + p->map_->setCoordinate({latitude, longitude}); + } +} + void MapWidget::SetMapParameters( double latitude, double longitude, double zoom, double bearing, double pitch) { diff --git a/scwx-qt/source/scwx/qt/map/map_widget.hpp b/scwx-qt/source/scwx/qt/map/map_widget.hpp index ce586243..1896b169 100644 --- a/scwx-qt/source/scwx/qt/map/map_widget.hpp +++ b/scwx-qt/source/scwx/qt/map/map_widget.hpp @@ -51,6 +51,7 @@ public: void SelectRadarSite(const std::string& radarSite); void SetActive(bool isActive); void SetAutoRefresh(bool enabled); + void SetMapLocation(double latitude, double longitude); void SetMapParameters(double latitude, double longitude, double zoom, diff --git a/scwx-qt/source/scwx/qt/ui/alert_dock_widget.cpp b/scwx-qt/source/scwx/qt/ui/alert_dock_widget.cpp index 39cc9220..2102691f 100644 --- a/scwx-qt/source/scwx/qt/ui/alert_dock_widget.cpp +++ b/scwx-qt/source/scwx/qt/ui/alert_dock_widget.cpp @@ -158,9 +158,10 @@ void AlertDockWidgetImpl::ConnectSignals() connect(self_->ui->alertGoButton, &QPushButton::clicked, this, - []() + [=]() { - // TODO: Go to alert + emit self_->MoveMap(selectedAlertCentroid_.latitude_, + selectedAlertCentroid_.longitude_); }); } diff --git a/scwx-qt/source/scwx/qt/ui/alert_dock_widget.hpp b/scwx-qt/source/scwx/qt/ui/alert_dock_widget.hpp index f99df345..6ccdd5f4 100644 --- a/scwx-qt/source/scwx/qt/ui/alert_dock_widget.hpp +++ b/scwx-qt/source/scwx/qt/ui/alert_dock_widget.hpp @@ -27,6 +27,9 @@ public: protected: void showEvent(QShowEvent*) override; +signals: + void MoveMap(double latitude, double longitude); + public slots: void HandleMapUpdate(double latitude, double longitude);