summaryrefslogtreecommitdiffstats
path: root/profile-widget
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2021-06-15 18:16:44 +0200
committerGravatar bstoeger <32835590+bstoeger@users.noreply.github.com>2021-06-27 19:05:20 +0200
commit248976bf11df2437aa4ceb437e79cb3a7fed27c4 (patch)
treeabeeafb8c9f408884c4cd0665df8b67e1c5ce761 /profile-widget
parent9eb10af68fbfaf43e0098c2ef9cd5e1d98645515 (diff)
downloadsubsurface-248976bf11df2437aa4ceb437e79cb3a7fed27c4.tar.gz
cleanup: factor out duplicate axis-initialization code
The axes of the profile are setup when switching into the "ProfileState" and also when the preferences are changed. The same code existed twice for both cases. Let's factor it out into a single function to avoid future divergence and confusion. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'profile-widget')
-rw-r--r--profile-widget/profilewidget2.cpp62
-rw-r--r--profile-widget/profilewidget2.h1
2 files changed, 8 insertions, 55 deletions
diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp
index 19ee319b0..0e344e87d 100644
--- a/profile-widget/profilewidget2.cpp
+++ b/profile-widget/profilewidget2.cpp
@@ -794,7 +794,7 @@ void ProfileWidget2::actionRequestedReplot(bool)
settingsChanged();
}
-void ProfileWidget2::settingsChanged()
+void ProfileWidget2::updateAxes()
{
#ifndef SUBSURFACE_MOBILE
gasYAxis->update(); // Initialize ticks of partial pressure graph
@@ -850,7 +850,11 @@ void ProfileWidget2::settingsChanged()
temperatureAxis->animateChangeLine(itemPos.temperature.expanded);
cylinderPressureAxis->animateChangeLine(itemPos.cylinder.expanded);
}
+}
+void ProfileWidget2::settingsChanged()
+{
+ updateAxes();
tankItem->setVisible(prefs.tankbar);
replot();
}
@@ -1114,63 +1118,11 @@ void ProfileWidget2::setProfileState()
cylinderPressureAxis->setVisible(true);
profileYAxis->setPos(itemPos.depth.pos.on);
+ updateAxes();
+
#ifndef SUBSURFACE_MOBILE
toolTipItem->readPos();
toolTipItem->setVisible(true);
- if ((prefs.percentagegraph||prefs.hrgraph) && PP_GRAPHS_ENABLED) {
- profileYAxis->animateChangeLine(itemPos.depth.shrinked);
- temperatureAxis->setPos(itemPos.temperatureAll.pos.on);
- temperatureAxis->animateChangeLine(itemPos.temperature.shrinked);
- cylinderPressureAxis->animateChangeLine(itemPos.cylinder.shrinked);
-
- if (prefs.tankbar) {
- percentageAxis->setPos(itemPos.percentageWithTankBar.pos.on);
- percentageAxis->animateChangeLine(itemPos.percentageWithTankBar.expanded);
- heartBeatAxis->setPos(itemPos.heartBeatWithTankBar.pos.on);
- heartBeatAxis->animateChangeLine(itemPos.heartBeatWithTankBar.expanded);
- }else {
- percentageAxis->setPos(itemPos.percentage.pos.on);
- percentageAxis->animateChangeLine(itemPos.percentage.expanded);
- heartBeatAxis->setPos(itemPos.heartBeat.pos.on);
- heartBeatAxis->animateChangeLine(itemPos.heartBeat.expanded);
- }
- gasYAxis->setPos(itemPos.partialPressureTissue.pos.on);
- gasYAxis->animateChangeLine(itemPos.partialPressureTissue.expanded);
-
- } else if (PP_GRAPHS_ENABLED || prefs.hrgraph || prefs.percentagegraph) {
- profileYAxis->animateChangeLine(itemPos.depth.intermediate);
- temperatureAxis->setPos(itemPos.temperature.pos.on);
- temperatureAxis->animateChangeLine(itemPos.temperature.intermediate);
- cylinderPressureAxis->animateChangeLine(itemPos.cylinder.intermediate);
- if (prefs.tankbar) {
- percentageAxis->setPos(itemPos.percentageWithTankBar.pos.on);
- percentageAxis->animateChangeLine(itemPos.percentageWithTankBar.expanded);
- gasYAxis->setPos(itemPos.partialPressureWithTankBar.pos.on);
- gasYAxis->setLine(itemPos.partialPressureWithTankBar.expanded);
- heartBeatAxis->setPos(itemPos.heartBeatWithTankBar.pos.on);
- heartBeatAxis->animateChangeLine(itemPos.heartBeatWithTankBar.expanded);
- } else {
- gasYAxis->setPos(itemPos.partialPressure.pos.on);
- gasYAxis->animateChangeLine(itemPos.partialPressure.expanded);
- percentageAxis->setPos(itemPos.percentage.pos.on);
- percentageAxis->setLine(itemPos.percentage.expanded);
- heartBeatAxis->setPos(itemPos.heartBeat.pos.on);
- heartBeatAxis->animateChangeLine(itemPos.heartBeat.expanded);
- }
- } else {
-#else
- {
-#endif
- profileYAxis->animateChangeLine(itemPos.depth.expanded);
- if (prefs.tankbar) {
- temperatureAxis->setPos(itemPos.temperatureAll.pos.on);
- } else {
- temperatureAxis->setPos(itemPos.temperature.pos.on);
- }
- temperatureAxis->animateChangeLine(itemPos.temperature.expanded);
- cylinderPressureAxis->animateChangeLine(itemPos.cylinder.expanded);
- }
-#ifndef SUBSURFACE_MOBILE
pn2GasItem->setVisible(prefs.pp_graphs.pn2);
po2GasItem->setVisible(prefs.pp_graphs.po2);
pheGasItem->setVisible(prefs.pp_graphs.phe);
diff --git a/profile-widget/profilewidget2.h b/profile-widget/profilewidget2.h
index 460acd259..b5114c63d 100644
--- a/profile-widget/profilewidget2.h
+++ b/profile-widget/profilewidget2.h
@@ -136,6 +136,7 @@ slots: // Necessary to call from QAction's signals.
private:
void setProfileState(); // keep currently displayed dive
+ void updateAxes(); // Update axes according to preferences
void resizeEvent(QResizeEvent *event) override;
#ifndef SUBSURFACE_MOBILE
void wheelEvent(QWheelEvent *event) override;