From 6ec40fc91be8ce30f7318710dccbe591530ee6d8 Mon Sep 17 00:00:00 2001 From: Ewoud Smeur Date: Wed, 21 Feb 2024 15:42:37 +0100 Subject: [PATCH] checkbox to turn on crash prediction --- src/widgets/map/acitemmanager.cpp | 4 ++-- src/widgets/map/mapwidget.cpp | 25 +++++++++++++++++++++++++ src/widgets/map/mapwidget.h | 3 +++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/widgets/map/acitemmanager.cpp b/src/widgets/map/acitemmanager.cpp index 8e35fea2..74f4d5b7 100644 --- a/src/widgets/map/acitemmanager.cpp +++ b/src/widgets/map/acitemmanager.cpp @@ -2,8 +2,8 @@ ACItemManager::ACItemManager(QString ac_id, WaypointItem* target, AircraftItem* aircraft_item, ArrowItem* arrow, WaypointItem* crash_item, QObject* parent): QObject(parent), - ac_id(ac_id), target(target), aircraft_item(aircraft_item), crash_item(crash_item), - current_nav_shape(nullptr), max_dist_circle(nullptr), arrow_item(arrow), gvf_trajectory(nullptr) + ac_id(ac_id), target(target), aircraft_item(aircraft_item), + current_nav_shape(nullptr), max_dist_circle(nullptr), arrow_item(arrow), crash_item(crash_item), gvf_trajectory(nullptr) { } diff --git a/src/widgets/map/mapwidget.cpp b/src/widgets/map/mapwidget.cpp index 1a59391f..0c11392c 100644 --- a/src/widgets/map/mapwidget.cpp +++ b/src/widgets/map/mapwidget.cpp @@ -114,6 +114,13 @@ MapWidget::MapWidget(QWidget *parent) : Map2D(parent), connect(show_hidden_wp_action, &QAction::toggled, [=](bool show) { setProperty("show_hidden_waypoints", show); }); + + show_crash_prediction_action = mapMenu->addAction("Show crash prediction"); + show_crash_prediction_action->setCheckable(true); + connect(show_crash_prediction_action, &QAction::toggled, [=](bool show) { + setProperty("show_crash_prediction", show); + }); + auto clear_shapes = mapMenu->addAction("Clear Shapes"); connect(clear_shapes, &QAction::triggered, this, [=](){ clearShapes(); @@ -756,6 +763,11 @@ void MapWidget::handleNewAC(QString ac_id) { // create crash item at dummy position auto crash_item = new WaypointItem(Point2DLatLon(0, 0), ac_id, 16); crash_item->setStyle(GraphicsObject::Style::CRASH); + if(!show_crash_prediction_action->isChecked()) { + crash_item->setSize(0); + } else { + crash_item->setSize(5); + } addItem(crash_item); ArrowItem* arrow = new ArrowItem(ac_id, 15, this); @@ -1396,3 +1408,16 @@ void MapWidget::showHiddenWaypoints(bool state) { } } } + +void MapWidget::showCrashPrediction(bool state) { + show_crash_prediction_action->blockSignals(true); + show_crash_prediction_action->setChecked(state); + show_crash_prediction_action->blockSignals(false); + for(auto &itemManager: ac_items_managers) { + if(state) { + itemManager->getCrashItem()->setSize(5*2); + } else { + itemManager->getCrashItem()->setSize(0); + } + } +} diff --git a/src/widgets/map/mapwidget.h b/src/widgets/map/mapwidget.h index 6a4851e9..6fcfee29 100644 --- a/src/widgets/map/mapwidget.h +++ b/src/widgets/map/mapwidget.h @@ -42,6 +42,7 @@ class MapWidget : public Map2D, public Configurable Q_OBJECT Q_PROPERTY(int ac_arrow_size MEMBER _ac_arrow_size WRITE setAcArrowSize) Q_PROPERTY(bool show_hidden_waypoints WRITE showHiddenWaypoints) + Q_PROPERTY(bool show_crash_prediction WRITE showCrashPrediction) public: explicit MapWidget(QWidget *parent = nullptr); @@ -61,6 +62,7 @@ class MapWidget : public Map2D, public Configurable void rotateMap(double rot); void setAcArrowSize(int s); void showHiddenWaypoints(bool state); + void showCrashPrediction(bool state); signals: void mouseMoved(QPointF scenePos); @@ -155,6 +157,7 @@ private slots: QMenu* mapMenu; QMenu* menu_clear_track; QAction* show_hidden_wp_action; + QAction* show_crash_prediction_action; }; #endif // MAPWIDGET_H