From e8d430341c1102c0da1a3847ad2d39f41fc642d3 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 15 Aug 2014 08:11:14 -0600 Subject: TankBar: hook into prefs and make ppGraphs resize accordingly Signed-off-by: Dirk Hohndel --- pref.h | 1 + qt-ui/mainwindow.cpp | 12 ++++++++---- qt-ui/mainwindow.h | 1 + qt-ui/mainwindow.ui | 36 +++++++++++++++++++++++++++++++----- qt-ui/preferences.cpp | 1 + qt-ui/profile/profilewidget2.cpp | 33 +++++++++++++++++++++++++++------ subsurfacestartup.c | 3 ++- 7 files changed, 71 insertions(+), 16 deletions(-) diff --git a/pref.h b/pref.h index 7292f1363..8bde0da80 100644 --- a/pref.h +++ b/pref.h @@ -46,6 +46,7 @@ struct preferences { short zoomed_plot; short hrgraph; short rulergraph; + short tankbar; short save_userid_local; char *userid; int ascrate75; diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 1a4594bab..687fc778d 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -242,6 +242,7 @@ void MainWindow::setToolButtonsEnabled(bool enabled) ui.profScaled->setEnabled(enabled); ui.profHR->setEnabled(enabled); ui.profTogglePicture->setEnabled(enabled); + ui.profTankbar->setEnabled(enabled); } bool MainWindow::okToClose(QString message) @@ -796,6 +797,7 @@ void MainWindow::readSettings() TOOLBOX_PREF_BUTTON(rulergraph, rulergraph, profRuler); TOOLBOX_PREF_BUTTON(show_sac, show_sac, profSAC); TOOLBOX_PREF_BUTTON(show_pictures_in_profile, show_pictures_in_profile, profTogglePicture); + TOOLBOX_PREF_BUTTON(tankbar, tankbar, profTankbar); s.endGroup(); s.beginGroup("DiveComputer"); default_dive_computer_vendor = getSetting(s, "dive_computer_vendor"); @@ -1270,6 +1272,7 @@ TOOLBOX_PREF_PROFILE(profRuler, rulergraph, rulergraph); TOOLBOX_PREF_PROFILE(profSAC, show_sac, show_sac); TOOLBOX_PREF_PROFILE(profScaled, zoomed_plot, zoomed_plot); TOOLBOX_PREF_PROFILE(profTogglePicture, show_pictures_in_profile, show_pictures_in_profile); +TOOLBOX_PREF_PROFILE(profTankbar, tankbar, tankbar); void MainWindow::turnOffNdlTts() { @@ -1289,10 +1292,11 @@ void MainWindow::on_actionExport_triggered() void MainWindow::setEnabledToolbar(bool arg1) { - QList toolBar; toolBar << ui.profCalcAllTissues << ui.profCalcCeiling - << ui.profDcCeiling << ui.profEad << ui.profHR << ui.profIncrement3m - << ui.profMod << ui.profNdl_tts << ui.profNdl_tts << ui.profPhe << ui.profPn2 - << ui.profPO2 << ui.profRuler << ui.profSAC << ui.profScaled << ui.profTogglePicture; + QList toolBar; + toolBar << ui.profCalcAllTissues << ui.profCalcCeiling << ui.profDcCeiling << ui.profEad << + ui.profHR << ui.profIncrement3m << ui.profMod << ui.profNdl_tts << ui.profNdl_tts << + ui.profPhe << ui.profPn2 << ui.profPO2 << ui.profRuler << ui.profSAC << ui.profScaled << + ui.profTogglePicture << ui.profTankbar; Q_FOREACH(QToolButton *b, toolBar) b->setEnabled(arg1); } diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h index 5c0ec8efa..9081bf457 100644 --- a/qt-ui/mainwindow.h +++ b/qt-ui/mainwindow.h @@ -141,6 +141,7 @@ slots: void on_profSAC_clicked(bool triggered); void on_profScaled_clicked(bool triggered); void on_profTogglePicture_clicked(bool triggered); + void on_profTankbar_clicked(bool triggered); void on_actionExport_triggered(); protected: diff --git a/qt-ui/mainwindow.ui b/qt-ui/mainwindow.ui index ac72673c8..5faac083b 100644 --- a/qt-ui/mainwindow.ui +++ b/qt-ui/mainwindow.ui @@ -109,7 +109,7 @@ 0 - + Qt::Vertical @@ -440,6 +440,9 @@ + + + @@ -466,9 +469,6 @@ - - - @@ -495,6 +495,32 @@ + + + + Toggle Cylinder Bar + + + ... + + + + :/gaschange:/gaschange + + + + 24 + 24 + + + + true + + + true + + + @@ -664,7 +690,7 @@ p, li { white-space: pre-wrap; } 0 0 1682 - 27 + 19 diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp index 6000f453a..edd95d838 100644 --- a/qt-ui/preferences.cpp +++ b/qt-ui/preferences.cpp @@ -315,6 +315,7 @@ void PreferencesDialog::loadSettings() GET_BOOL("calcndltts", calcndltts); GET_BOOL("calcalltissues", calcalltissues); GET_BOOL("hrgraph", hrgraph); + GET_BOOL("tankbar", tankbar); GET_INT("gflow", gflow); GET_INT("gfhigh", gfhigh); GET_BOOL("gf_low_at_maxdepth", gf_low_at_maxdepth); diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 400bedde1..409328918 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -56,6 +56,7 @@ static struct _ItemPos { _Pos tankBar; _Axis depth; _Axis partialPressure; + _Axis partialPressureWithTankBar; _Axis time; _Axis cylinder; _Axis temperature; @@ -306,7 +307,9 @@ void ProfileWidget2::setupItemSizes() itemPos.partialPressure.pos.off.setX(110); itemPos.partialPressure.pos.off.setY(63); itemPos.partialPressure.expanded.setP1(QPointF(0, 0)); - itemPos.partialPressure.expanded.setP2(QPointF(0, 27)); + itemPos.partialPressure.expanded.setP2(QPointF(0, 30)); + itemPos.partialPressureWithTankBar = itemPos.partialPressure; + itemPos.partialPressureWithTankBar.expanded.setP2(QPointF(0, 27)); // cylinder axis config itemPos.cylinder.pos.on.setX(3); @@ -418,7 +421,14 @@ void ProfileWidget2::plotDive(struct dive *d, bool force) // reset some item visibility on printMode changes toolTipItem->setVisible(!printMode); rulerItem->setVisible(prefs.rulergraph && !printMode); - tankItem->setVisible(true); + tankItem->setVisible(prefs.tankbar); + if (prefs.tankbar) { + gasYAxis->setPos(itemPos.partialPressureWithTankBar.pos.on); + gasYAxis->setLine(itemPos.partialPressureWithTankBar.expanded); + } else { + gasYAxis->setPos(itemPos.partialPressure.pos.on); + gasYAxis->setLine(itemPos.partialPressure.expanded); + } if (currentState == EMPTY) setProfileState(); @@ -563,6 +573,13 @@ void ProfileWidget2::settingsChanged() temperatureAxis->animateChangeLine(itemPos.temperature.expanded); cylinderPressureAxis->animateChangeLine(itemPos.cylinder.expanded); } + if (prefs.tankbar) { + gasYAxis->setPos(itemPos.partialPressureWithTankBar.pos.on); + gasYAxis->animateChangeLine(itemPos.partialPressureWithTankBar.expanded); + } else { + gasYAxis->setPos(itemPos.partialPressure.pos.on); + gasYAxis->animateChangeLine(itemPos.partialPressure.expanded); + } if (prefs.zoomed_plot != isPlotZoomed) { isPlotZoomed = prefs.zoomed_plot; needReplot = true; @@ -796,9 +813,13 @@ void ProfileWidget2::setProfileState() po2GasItem->setVisible(prefs.pp_graphs.po2); pheGasItem->setVisible(prefs.pp_graphs.phe); - gasYAxis->setPos(itemPos.partialPressure.pos.on); - gasYAxis->setLine(itemPos.partialPressure.expanded); - + if (prefs.tankbar) { + gasYAxis->setPos(itemPos.partialPressureWithTankBar.pos.on); + gasYAxis->setLine(itemPos.partialPressureWithTankBar.expanded); + } else { + gasYAxis->setPos(itemPos.partialPressure.pos.on); + gasYAxis->setLine(itemPos.partialPressure.expanded); + } timeAxis->setPos(itemPos.time.pos.on); timeAxis->setLine(itemPos.time.expanded); @@ -821,7 +842,7 @@ void ProfileWidget2::setProfileState() } } rulerItem->setVisible(prefs.rulergraph); - tankItem->setVisible(true); + tankItem->setVisible(prefs.tankbar); tankItem->setPos(itemPos.tankBar.on); #define HIDE_ALL(TYPE, CONTAINER) \ diff --git a/subsurfacestartup.c b/subsurfacestartup.c index b7b1b6504..8edc409be 100644 --- a/subsurfacestartup.c +++ b/subsurfacestartup.c @@ -44,7 +44,8 @@ struct preferences default_prefs = { .drop_stone_mode = false, .bottomsac = 20000, .decosac = 17000, - .show_pictures_in_profile = true + .show_pictures_in_profile = true, + .tankbar = false }; int run_survey; -- cgit v1.2.3-70-g09d2