summaryrefslogtreecommitdiffstats
path: root/profile-widget
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2017-08-02 08:53:10 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-08-07 00:57:58 -0700
commite04ef1df1e2be525fa5bee5d2e849d609a58eb83 (patch)
tree18b20dcb0d313506cb3d108415ba22c8b60b2556 /profile-widget
parent3f1a20cbaa53501c66ed41b3a8cda36d2fd53e8e (diff)
downloadsubsurface-e04ef1df1e2be525fa5bee5d2e849d609a58eb83.tar.gz
Fix the overprinting of gas name and pressure value on the profile
When I massaged the code to do multiple gas pressures in commit e1b880f4 ("Profile support for multiple concurrent pressure sensors") some of the Y offsetting code got cut out as being too specific to the old o2pressure code. But I removed a bit too much, leaving the label (gas name) and number (gas pressure) overlapping. This should fix it. If we really care about multiple gas pressure labels overlapping each other, we'll have to revisit this code, but the old two-gas case didn't do a very good job either (both that old code - and this new version - can look very good in particular cases, but there are cases where it won't work so well). So we may need to revisit this eventually, but this gets it looking fine for the normal cases. Reported-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'profile-widget')
-rw-r--r--profile-widget/diveprofileitem.cpp29
1 files changed, 21 insertions, 8 deletions
diff --git a/profile-widget/diveprofileitem.cpp b/profile-widget/diveprofileitem.cpp
index 6f2bf98b0..02a0745e7 100644
--- a/profile-widget/diveprofileitem.cpp
+++ b/profile-widget/diveprofileitem.cpp
@@ -736,12 +736,13 @@ void DiveGasPressureItem::modelDataChanged(const QModelIndex &topLeft, const QMo
int last_pressure[MAX_CYLINDERS] = { 0, };
int last_time[MAX_CYLINDERS] = { 0, };
- double print_y_offset[8][2] = { { 0, -0.5 }, { 0, -0.5 }, { 0, -0.5 }, { 0, -0.5 }, { 0, -0.5 } ,{ 0, -0.5 }, { 0, -0.5 }, { 0, -0.5 } };
// These are offset values used to print the gas lables and pressures on a
- // dive profile at appropriate Y-coordinates: One doublet of values for each
- // of 8 cylinders.
- // Order of offsets within a doublet: gas lable offset; gas pressure offset.
- // The array is initialised with default values that apply to non-CCR dives.
+ // dive profile at appropriate Y-coordinates. We alternate aligning the
+ // label and the gas pressure above and under the pressure line.
+ // The values are historical, and we could try to pick the over/under
+ // depending on whether this pressure is higher or lower than the average.
+ // Right now it's just strictly alternating when you have multiple gas
+ // pressures.
QFlags<Qt::AlignmentFlag> alignVar = Qt::AlignTop;
QFlags<Qt::AlignmentFlag> align[MAX_CYLINDERS];
@@ -759,8 +760,19 @@ void DiveGasPressureItem::modelDataChanged(const QModelIndex &topLeft, const QMo
continue;
if (!seen_cyl[cyl]) {
- plotPressureValue(mbar, entry->sec, alignVar, print_y_offset[cyl][1]);
- plotGasValue(mbar, entry->sec, displayed_dive.cylinder[cyl].gasmix, alignVar, print_y_offset[cyl][0]);
+ double value_y_offset, label_y_offset;
+
+ // Magic Y offset depending on whether we're aliging
+ // the top of the text or the bottom of the text to
+ // the pressure line.
+ value_y_offset = -0.5;
+ if (alignVar & Qt::AlignTop) {
+ label_y_offset = 5 * axisLog;
+ } else {
+ label_y_offset = -7 * axisLog;
+ }
+ plotPressureValue(mbar, entry->sec, alignVar, value_y_offset);
+ plotGasValue(mbar, entry->sec, displayed_dive.cylinder[cyl].gasmix, alignVar, label_y_offset);
seen_cyl[cyl] = true;
/* Alternate alignment as we see cylinder use.. */
@@ -775,7 +787,8 @@ void DiveGasPressureItem::modelDataChanged(const QModelIndex &topLeft, const QMo
// For each cylinder, on right hand side of profile, write cylinder pressure
for (int cyl = 0; cyl < MAX_CYLINDERS; cyl++) {
if (last_time[cyl]) {
- plotPressureValue(last_pressure[cyl], last_time[cyl], align[cyl] | Qt::AlignLeft, print_y_offset[cyl][1]);
+ double value_y_offset = -0.5;
+ plotPressureValue(last_pressure[cyl], last_time[cyl], align[cyl] | Qt::AlignLeft, value_y_offset);
}
}
}