diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-07-20 19:49:45 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-07-21 16:33:19 -0700 |
commit | 1e38d9239a7bac621eedcb2bab98b90d78b988af (patch) | |
tree | 55d30d369aadeb58d19ce5d580fc414b10cfa94c /profile-widget/diveprofileitem.cpp | |
parent | 11a0c0cc701806ccec975c67d27dec97fbb13b1f (diff) | |
download | subsurface-1e38d9239a7bac621eedcb2bab98b90d78b988af.tar.gz |
Start cleaning up sensor indexing for multiple sensors
This is a very timid start at making us actually use multiple sensors
without the magical special case for just CCR oxygen tracking.
It mainly does:
- turn the "sample->sensor" index into an array of two indexes, to
match the pressures themselves.
- get rid of dive->{oxygen_cylinder_index,diluent_cylinder_index},
since a CCR dive should now simply set the sample->sensor[] indices
correctly instead.
- in a couple of places, start actually looping over the sensors rather
than special-case the O2 case (although often the small "loops" are
just unrolled, since it's just two cases.
but in many cases we still end up only covering the zero sensor case,
because the CCR O2 sensor code coverage was fairly limited.
It's entirely possible (even likely) that this migth break some existing
case: it tries to be a fairly direct ("stupid") translation of the old
code, but unlike the preparatory patch this does actually does change
some semantics.
For example, right now the git loader code assumes that if the git save
data contains a o2pressure entry, it just hardcodes the O2 sensor index
to 1.
In fact, one issue is going to simply be that our file formats do not
have that multiple sensor format, but instead had very clearly encoded
things as being the CCR O2 pressure sensor.
But this is hopefully close to usable, and I will need feedback (and
maybe test cases) from people who have existing CCR dives with pressure
data.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'profile-widget/diveprofileitem.cpp')
-rw-r--r-- | profile-widget/diveprofileitem.cpp | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/profile-widget/diveprofileitem.cpp b/profile-widget/diveprofileitem.cpp index ee03e9e6e..096acd898 100644 --- a/profile-widget/diveprofileitem.cpp +++ b/profile-widget/diveprofileitem.cpp @@ -693,13 +693,13 @@ void DiveGasPressureItem::modelDataChanged(const QModelIndex &topLeft, const QMo for (int i = 0, count = dataModel->rowCount(); i < count; i++) { o2mbar = 0; plot_data *entry = dataModel->data().entry + i; - int mbar = GET_PRESSURE(entry); + int mbar = GET_PRESSURE(entry, 0); if (displayed_dive.dc.divemode == CCR) - o2mbar = GET_O2CYLINDER_PRESSURE(entry); + o2mbar = GET_PRESSURE(entry, 1); - if ((int)entry->cylinderindex != last_index) { + if ((int)entry->sensor[0] != last_index) { polygons.append(QPolygonF()); // this is the polygon that will be actually drawn on screen. - last_index = entry->cylinderindex; + last_index = entry->sensor[0]; } if (!mbar) { continue; @@ -739,15 +739,16 @@ void DiveGasPressureItem::modelDataChanged(const QModelIndex &topLeft, const QMo double axisLog = log10(log10(axisRange)); for (int i = 0, count = dataModel->rowCount(); i < count; i++) { entry = dataModel->data().entry + i; - mbar = GET_PRESSURE(entry); - if (displayed_dive.dc.divemode == CCR && displayed_dive.oxygen_cylinder_index >= 0) - o2mbar = GET_O2CYLINDER_PRESSURE(entry); - if (o2mbar) { // If there is an o2mbar value then this is a CCR dive. Then do: - // The first time an o2 value is detected, see if the oxygen cyl pressure graph starts above or below the dil graph + dilcyl = entry->sensor[0]; + o2cyl = entry->sensor[1]; + mbar = GET_PRESSURE(entry, 0); + if (o2cyl >= 0) + o2mbar = GET_PRESSURE(entry, 1); + + if (o2mbar) { // Do we have a second cylinder pressure? If so, do + // The first time an o2 value is detected, see if the oxygen cyl pressure graph starts above or below the dil graph if (!offsets_initialised) { // Initialise the parameters for placing the text correctly near the graph line: - o2cyl = displayed_dive.oxygen_cylinder_index; - dilcyl = displayed_dive.diluent_cylinder_index; if ((o2mbar > mbar)) { // If above, write o2 start cyl pressure above graph and diluent pressure below graph: print_y_offset[o2cyl][0] = -7 * axisLog; // y offset for oxygen gas lable (above); pressure offsets=-0.5, already initialised print_y_offset[dilcyl][0] = 5 * axisLog; // y offset for diluent gas lable (below) @@ -760,21 +761,21 @@ void DiveGasPressureItem::modelDataChanged(const QModelIndex &topLeft, const QMo offsets_initialised = true; } - if (!seen_cyl[displayed_dive.oxygen_cylinder_index]) { //For o2, on the left of profile, write lable and pressure + if (!seen_cyl[o2cyl]) { //For o2, on the left of profile, write lable and pressure plotPressureValue(o2mbar, entry->sec, align_o2, print_y_offset[o2cyl][1]); - plotGasValue(o2mbar, entry->sec, displayed_dive.cylinder[displayed_dive.oxygen_cylinder_index].gasmix, align_o2, print_y_offset[o2cyl][0]); - seen_cyl[displayed_dive.oxygen_cylinder_index] = true; + plotGasValue(o2mbar, entry->sec, displayed_dive.cylinder[o2cyl].gasmix, align_o2, print_y_offset[o2cyl][0]); + seen_cyl[o2cyl] = true; } - last_pressure[displayed_dive.oxygen_cylinder_index] = o2mbar; - last_time[displayed_dive.oxygen_cylinder_index] = entry->sec; + last_pressure[o2cyl] = o2mbar; + last_time[o2cyl] = entry->sec; alignVar = align_dil; } if (!mbar) continue; - if (cyl != (int)entry->cylinderindex) { // Pressure value near the left hand edge of the profile - other cylinders: - cyl = entry->cylinderindex; // For each other cylinder, write the gas lable and pressure + if (cyl != dilcyl) { // Pressure value near the left hand edge of the profile - other cylinders: + cyl = dilcyl; // For each other cylinder, write the gas lable and pressure if (!seen_cyl[cyl]) { plotPressureValue(mbar, entry->sec, alignVar, print_y_offset[cyl][1]); plotGasValue(mbar, entry->sec, displayed_dive.cylinder[cyl].gasmix, align_dil, print_y_offset[cyl][0]); @@ -786,7 +787,7 @@ void DiveGasPressureItem::modelDataChanged(const QModelIndex &topLeft, const QMo } for (cyl = 0; cyl < MAX_CYLINDERS; cyl++) { // For each cylinder, on right hand side of profile, write cylinder pressure - alignVar = ((o2cyl >= 0) && (cyl == displayed_dive.oxygen_cylinder_index)) ? align_o2 : align_dil; + alignVar = ((o2cyl >= 0) && (cyl == o2cyl)) ? align_o2 : align_dil; if (last_time[cyl]) { plotPressureValue(last_pressure[cyl], last_time[cyl], (alignVar | Qt::AlignLeft), print_y_offset[cyl][1]); } |