Skip to content

Commit

Permalink
checkbox to turn on crash prediction
Browse files Browse the repository at this point in the history
  • Loading branch information
EwoudSmeur committed Feb 21, 2024
1 parent ac11b40 commit 6ec40fc
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/widgets/map/acitemmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{

}
Expand Down
25 changes: 25 additions & 0 deletions src/widgets/map/mapwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}
}
3 changes: 3 additions & 0 deletions src/widgets/map/mapwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
Expand Down Expand Up @@ -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

0 comments on commit 6ec40fc

Please sign in to comment.