From 9ab7819fd14d264e584cb062673c03c95605f793 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 20 May 2023 15:37:11 +0200 Subject: [PATCH] profile: replot profile when settings changed It would be nice to have a single "any setting changed" signal and not to have to listen to all of them individually... Signed-off-by: Berthold Stoeger --- profile-widget/profileview.cpp | 34 ++++++++++++++++++++++++++++++- profile-widget/profileview.h | 1 + profile-widget/profilewidget2.cpp | 25 ----------------------- 3 files changed, 34 insertions(+), 26 deletions(-) diff --git a/profile-widget/profileview.cpp b/profile-widget/profileview.cpp index 8084808f6..3c23269d0 100644 --- a/profile-widget/profileview.cpp +++ b/profile-widget/profileview.cpp @@ -5,8 +5,9 @@ #include "core/dive.h" #include "core/errorhelper.h" #include "core/pref.h" -#include "core/settings/qPrefTechnicalDetails.h" #include "core/settings/qPrefDisplay.h" +#include "core/settings/qPrefPartialPressureGas.h" +#include "core/settings/qPrefTechnicalDetails.h" #include "qt-quick/chartitem.h" #include @@ -60,6 +61,31 @@ ProfileView::ProfileView(QQuickItem *parent) : ChartView(parent, ProfileZValue:: setAcceptHoverEvents(true); setAcceptedMouseButtons(Qt::LeftButton); + + auto tec = qPrefTechnicalDetails::instance(); + connect(tec, &qPrefTechnicalDetails::calcalltissuesChanged , this, &ProfileView::replot); + connect(tec, &qPrefTechnicalDetails::calcceilingChanged , this, &ProfileView::replot); + connect(tec, &qPrefTechnicalDetails::gflowChanged , this, &ProfileView::replot); + connect(tec, &qPrefTechnicalDetails::gfhighChanged , this, &ProfileView::replot); + connect(tec, &qPrefTechnicalDetails::dcceilingChanged , this, &ProfileView::replot); + connect(tec, &qPrefTechnicalDetails::eadChanged , this, &ProfileView::replot); + connect(tec, &qPrefTechnicalDetails::calcceiling3mChanged , this, &ProfileView::replot); + connect(tec, &qPrefTechnicalDetails::modChanged , this, &ProfileView::replot); + connect(tec, &qPrefTechnicalDetails::calcndlttsChanged , this, &ProfileView::replot); + connect(tec, &qPrefTechnicalDetails::hrgraphChanged , this, &ProfileView::replot); + connect(tec, &qPrefTechnicalDetails::rulergraphChanged , this, &ProfileView::replot); + connect(tec, &qPrefTechnicalDetails::show_sacChanged , this, &ProfileView::replot); + connect(tec, &qPrefTechnicalDetails::zoomed_plotChanged , this, &ProfileView::replot); + connect(tec, &qPrefTechnicalDetails::decoinfoChanged , this, &ProfileView::replot); + connect(tec, &qPrefTechnicalDetails::show_pictures_in_profileChanged , this, &ProfileView::replot); + connect(tec, &qPrefTechnicalDetails::tankbarChanged , this, &ProfileView::replot); + connect(tec, &qPrefTechnicalDetails::percentagegraphChanged , this, &ProfileView::replot); + connect(tec, &qPrefTechnicalDetails::infoboxChanged , this, &ProfileView::replot); + + auto pp_gas = qPrefPartialPressureGas::instance(); + connect(pp_gas, &qPrefPartialPressureGas::pheChanged, this, &ProfileView::replot); + connect(pp_gas, &qPrefPartialPressureGas::pn2Changed, this, &ProfileView::replot); + connect(pp_gas, &qPrefPartialPressureGas::po2Changed, this, &ProfileView::replot); } ProfileView::ProfileView() : ProfileView(nullptr) @@ -81,6 +107,12 @@ void ProfileView::plotAreaChanged(const QSizeF &s) plotDive(d, dc, RenderFlags::Instant); } +void ProfileView::replot() +{ + if (!empty) + plotDive(d, dc, RenderFlags::None); +} + void ProfileView::clear() { //clearPictures(); diff --git a/profile-widget/profileview.h b/profile-widget/profileview.h index b651b6a4b..275fcbd92 100644 --- a/profile-widget/profileview.h +++ b/profile-widget/profileview.h @@ -41,6 +41,7 @@ private: void plotAreaChanged(const QSizeF &size) override; void resetPointers() override; + void replot(); }; #endif diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index cc4ae7b5c..4b1fc0563 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -91,31 +91,6 @@ ProfileWidget2::ProfileWidget2(DivePlannerPointsModel *plannerModelIn, double dp diveDepthTableView->show(); #endif - auto tec = qPrefTechnicalDetails::instance(); - connect(tec, &qPrefTechnicalDetails::calcalltissuesChanged , this, &ProfileWidget2::actionRequestedReplot); - connect(tec, &qPrefTechnicalDetails::calcceilingChanged , this, &ProfileWidget2::actionRequestedReplot); - connect(tec, &qPrefTechnicalDetails::gflowChanged , this, &ProfileWidget2::actionRequestedReplot); - connect(tec, &qPrefTechnicalDetails::gfhighChanged , this, &ProfileWidget2::actionRequestedReplot); - connect(tec, &qPrefTechnicalDetails::dcceilingChanged , this, &ProfileWidget2::actionRequestedReplot); - connect(tec, &qPrefTechnicalDetails::eadChanged , this, &ProfileWidget2::actionRequestedReplot); - connect(tec, &qPrefTechnicalDetails::calcceiling3mChanged , this, &ProfileWidget2::actionRequestedReplot); - connect(tec, &qPrefTechnicalDetails::modChanged , this, &ProfileWidget2::actionRequestedReplot); - connect(tec, &qPrefTechnicalDetails::calcndlttsChanged , this, &ProfileWidget2::actionRequestedReplot); - connect(tec, &qPrefTechnicalDetails::hrgraphChanged , this, &ProfileWidget2::actionRequestedReplot); - connect(tec, &qPrefTechnicalDetails::rulergraphChanged , this, &ProfileWidget2::actionRequestedReplot); - connect(tec, &qPrefTechnicalDetails::show_sacChanged , this, &ProfileWidget2::actionRequestedReplot); - connect(tec, &qPrefTechnicalDetails::zoomed_plotChanged , this, &ProfileWidget2::actionRequestedReplot); - connect(tec, &qPrefTechnicalDetails::decoinfoChanged , this, &ProfileWidget2::actionRequestedReplot); - connect(tec, &qPrefTechnicalDetails::show_pictures_in_profileChanged , this, &ProfileWidget2::actionRequestedReplot); - connect(tec, &qPrefTechnicalDetails::tankbarChanged , this, &ProfileWidget2::actionRequestedReplot); - connect(tec, &qPrefTechnicalDetails::percentagegraphChanged , this, &ProfileWidget2::actionRequestedReplot); - connect(tec, &qPrefTechnicalDetails::infoboxChanged , this, &ProfileWidget2::actionRequestedReplot); - - auto pp_gas = qPrefPartialPressureGas::instance(); - connect(pp_gas, &qPrefPartialPressureGas::pheChanged, this, &ProfileWidget2::actionRequestedReplot); - connect(pp_gas, &qPrefPartialPressureGas::pn2Changed, this, &ProfileWidget2::actionRequestedReplot); - connect(pp_gas, &qPrefPartialPressureGas::po2Changed, this, &ProfileWidget2::actionRequestedReplot); - setProfileState(); }