TankBar: hook into prefs and make ppGraphs resize accordingly

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2014-08-15 08:11:14 -06:00
parent e71119b40b
commit e8d430341c
7 changed files with 71 additions and 16 deletions

1
pref.h
View file

@ -46,6 +46,7 @@ struct preferences {
short zoomed_plot; short zoomed_plot;
short hrgraph; short hrgraph;
short rulergraph; short rulergraph;
short tankbar;
short save_userid_local; short save_userid_local;
char *userid; char *userid;
int ascrate75; int ascrate75;

View file

@ -242,6 +242,7 @@ void MainWindow::setToolButtonsEnabled(bool enabled)
ui.profScaled->setEnabled(enabled); ui.profScaled->setEnabled(enabled);
ui.profHR->setEnabled(enabled); ui.profHR->setEnabled(enabled);
ui.profTogglePicture->setEnabled(enabled); ui.profTogglePicture->setEnabled(enabled);
ui.profTankbar->setEnabled(enabled);
} }
bool MainWindow::okToClose(QString message) bool MainWindow::okToClose(QString message)
@ -796,6 +797,7 @@ void MainWindow::readSettings()
TOOLBOX_PREF_BUTTON(rulergraph, rulergraph, profRuler); TOOLBOX_PREF_BUTTON(rulergraph, rulergraph, profRuler);
TOOLBOX_PREF_BUTTON(show_sac, show_sac, profSAC); TOOLBOX_PREF_BUTTON(show_sac, show_sac, profSAC);
TOOLBOX_PREF_BUTTON(show_pictures_in_profile, show_pictures_in_profile, profTogglePicture); TOOLBOX_PREF_BUTTON(show_pictures_in_profile, show_pictures_in_profile, profTogglePicture);
TOOLBOX_PREF_BUTTON(tankbar, tankbar, profTankbar);
s.endGroup(); s.endGroup();
s.beginGroup("DiveComputer"); s.beginGroup("DiveComputer");
default_dive_computer_vendor = getSetting(s, "dive_computer_vendor"); 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(profSAC, show_sac, show_sac);
TOOLBOX_PREF_PROFILE(profScaled, zoomed_plot, zoomed_plot); TOOLBOX_PREF_PROFILE(profScaled, zoomed_plot, zoomed_plot);
TOOLBOX_PREF_PROFILE(profTogglePicture, show_pictures_in_profile, show_pictures_in_profile); TOOLBOX_PREF_PROFILE(profTogglePicture, show_pictures_in_profile, show_pictures_in_profile);
TOOLBOX_PREF_PROFILE(profTankbar, tankbar, tankbar);
void MainWindow::turnOffNdlTts() void MainWindow::turnOffNdlTts()
{ {
@ -1289,10 +1292,11 @@ void MainWindow::on_actionExport_triggered()
void MainWindow::setEnabledToolbar(bool arg1) void MainWindow::setEnabledToolbar(bool arg1)
{ {
QList<QToolButton*> toolBar; toolBar << ui.profCalcAllTissues << ui.profCalcCeiling QList<QToolButton*> toolBar;
<< ui.profDcCeiling << ui.profEad << ui.profHR << ui.profIncrement3m toolBar << ui.profCalcAllTissues << ui.profCalcCeiling << ui.profDcCeiling << ui.profEad <<
<< ui.profMod << ui.profNdl_tts << ui.profNdl_tts << ui.profPhe << ui.profPn2 ui.profHR << ui.profIncrement3m << ui.profMod << ui.profNdl_tts << ui.profNdl_tts <<
<< ui.profPO2 << ui.profRuler << ui.profSAC << ui.profScaled << ui.profTogglePicture; ui.profPhe << ui.profPn2 << ui.profPO2 << ui.profRuler << ui.profSAC << ui.profScaled <<
ui.profTogglePicture << ui.profTankbar;
Q_FOREACH(QToolButton *b, toolBar) Q_FOREACH(QToolButton *b, toolBar)
b->setEnabled(arg1); b->setEnabled(arg1);
} }

View file

@ -141,6 +141,7 @@ slots:
void on_profSAC_clicked(bool triggered); void on_profSAC_clicked(bool triggered);
void on_profScaled_clicked(bool triggered); void on_profScaled_clicked(bool triggered);
void on_profTogglePicture_clicked(bool triggered); void on_profTogglePicture_clicked(bool triggered);
void on_profTankbar_clicked(bool triggered);
void on_actionExport_triggered(); void on_actionExport_triggered();
protected: protected:

View file

@ -109,7 +109,7 @@
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<item row="15" column="0"> <item row="17" column="0">
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
@ -440,6 +440,9 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1" rowspan="19">
<widget class="ProfileWidget2" name="newProfile"/>
</item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QToolButton" name="profPO2"> <widget class="QToolButton" name="profPO2">
<property name="toolTip"> <property name="toolTip">
@ -466,9 +469,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1" rowspan="16">
<widget class="ProfileWidget2" name="newProfile"/>
</item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QToolButton" name="profPn2"> <widget class="QToolButton" name="profPn2">
<property name="toolTip"> <property name="toolTip">
@ -495,6 +495,32 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="15" column="0">
<widget class="QToolButton" name="profTankbar">
<property name="toolTip">
<string>Toggle Cylinder Bar</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../subsurface.qrc">
<normaloff>:/gaschange</normaloff>:/gaschange</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="14" column="0"> <item row="14" column="0">
<widget class="QToolButton" name="profTogglePicture"> <widget class="QToolButton" name="profTogglePicture">
<property name="toolTip"> <property name="toolTip">
@ -664,7 +690,7 @@ p, li { white-space: pre-wrap; }
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1682</width> <width>1682</width>
<height>27</height> <height>19</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFile"> <widget class="QMenu" name="menuFile">

View file

@ -315,6 +315,7 @@ void PreferencesDialog::loadSettings()
GET_BOOL("calcndltts", calcndltts); GET_BOOL("calcndltts", calcndltts);
GET_BOOL("calcalltissues", calcalltissues); GET_BOOL("calcalltissues", calcalltissues);
GET_BOOL("hrgraph", hrgraph); GET_BOOL("hrgraph", hrgraph);
GET_BOOL("tankbar", tankbar);
GET_INT("gflow", gflow); GET_INT("gflow", gflow);
GET_INT("gfhigh", gfhigh); GET_INT("gfhigh", gfhigh);
GET_BOOL("gf_low_at_maxdepth", gf_low_at_maxdepth); GET_BOOL("gf_low_at_maxdepth", gf_low_at_maxdepth);

View file

@ -56,6 +56,7 @@ static struct _ItemPos {
_Pos tankBar; _Pos tankBar;
_Axis depth; _Axis depth;
_Axis partialPressure; _Axis partialPressure;
_Axis partialPressureWithTankBar;
_Axis time; _Axis time;
_Axis cylinder; _Axis cylinder;
_Axis temperature; _Axis temperature;
@ -306,7 +307,9 @@ void ProfileWidget2::setupItemSizes()
itemPos.partialPressure.pos.off.setX(110); itemPos.partialPressure.pos.off.setX(110);
itemPos.partialPressure.pos.off.setY(63); itemPos.partialPressure.pos.off.setY(63);
itemPos.partialPressure.expanded.setP1(QPointF(0, 0)); 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 // cylinder axis config
itemPos.cylinder.pos.on.setX(3); 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 // reset some item visibility on printMode changes
toolTipItem->setVisible(!printMode); toolTipItem->setVisible(!printMode);
rulerItem->setVisible(prefs.rulergraph && !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) if (currentState == EMPTY)
setProfileState(); setProfileState();
@ -563,6 +573,13 @@ void ProfileWidget2::settingsChanged()
temperatureAxis->animateChangeLine(itemPos.temperature.expanded); temperatureAxis->animateChangeLine(itemPos.temperature.expanded);
cylinderPressureAxis->animateChangeLine(itemPos.cylinder.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) { if (prefs.zoomed_plot != isPlotZoomed) {
isPlotZoomed = prefs.zoomed_plot; isPlotZoomed = prefs.zoomed_plot;
needReplot = true; needReplot = true;
@ -796,9 +813,13 @@ void ProfileWidget2::setProfileState()
po2GasItem->setVisible(prefs.pp_graphs.po2); po2GasItem->setVisible(prefs.pp_graphs.po2);
pheGasItem->setVisible(prefs.pp_graphs.phe); pheGasItem->setVisible(prefs.pp_graphs.phe);
gasYAxis->setPos(itemPos.partialPressure.pos.on); if (prefs.tankbar) {
gasYAxis->setLine(itemPos.partialPressure.expanded); 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->setPos(itemPos.time.pos.on);
timeAxis->setLine(itemPos.time.expanded); timeAxis->setLine(itemPos.time.expanded);
@ -821,7 +842,7 @@ void ProfileWidget2::setProfileState()
} }
} }
rulerItem->setVisible(prefs.rulergraph); rulerItem->setVisible(prefs.rulergraph);
tankItem->setVisible(true); tankItem->setVisible(prefs.tankbar);
tankItem->setPos(itemPos.tankBar.on); tankItem->setPos(itemPos.tankBar.on);
#define HIDE_ALL(TYPE, CONTAINER) \ #define HIDE_ALL(TYPE, CONTAINER) \

View file

@ -44,7 +44,8 @@ struct preferences default_prefs = {
.drop_stone_mode = false, .drop_stone_mode = false,
.bottomsac = 20000, .bottomsac = 20000,
.decosac = 17000, .decosac = 17000,
.show_pictures_in_profile = true .show_pictures_in_profile = true,
.tankbar = false
}; };
int run_survey; int run_survey;