summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-11-19 16:15:10 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-11-19 16:29:27 -0800
commit3dc864f1b109012042887ddd9b421871c63e1bd8 (patch)
tree81582722e05588d4ca564b581145e90783892143
parentf2a2ded04e89376874b9ec11a7e7a2a9ba8097ff (diff)
downloadsubsurface-3dc864f1b109012042887ddd9b421871c63e1bd8.tar.gz
Profile: adjust tank pressures at gas change (incomplete)
This code sets up the UI that will allow the user to adjust tank pressures at a gaschange event. The actual changing of the pressure is not implemented, yet, so this is disabled until someone finds time to do so. The scenario is this: a tec diver or sidemount diver without pressure sensors on at least one of their tanks still wants to reasonably accurately track gas consumption during a dive. The diver takes notes of the pressures at every tank switch (I find that odd, but apparently some cave divers indeed do that as they switch back and forth between different gases) and then wants to adjust the pressures in Subsurface to match those written down. One difficulty here is that the first and last pressure of a tank with no sensor data is still considered "sensor pressure" - this is basically an implementation detail in the code that is used to do the pressure interpolation to have constant-SAC pressure plots for tanks without sensors. So when we check if there is indeed no pressure data available at the gas change, we can't just work with the interpolated pressure - if this is the first (or last) time the tank was used, that pressure may be marked as sensor pressure. What's missing is the UI to enter the desired new pressure plus the black magic that actually inserts this into the dive in a way that doesn't break the assumptions in the rest of the code. I'm running out of time to do that but wanted to preserve this code so someone can continue this later. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-ui/profile/profilewidget2.cpp40
1 files changed, 39 insertions, 1 deletions
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index c4ef97ddc..e1892b2fa 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -1141,13 +1141,51 @@ void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event)
action->setData(QVariant::fromValue<void *>(item));
connect(action, SIGNAL(triggered(bool)), this, SLOT(hideEvents()));
m.addAction(action);
- if (item->getEvent()->type == SAMPLE_EVENT_BOOKMARK) {
+ struct event *dcEvent = item->getEvent();
+ if (dcEvent->type == SAMPLE_EVENT_BOOKMARK) {
action = new QAction(&m);
action->setText(tr("Edit name"));
action->setData(QVariant::fromValue<void *>(item));
connect(action, SIGNAL(triggered(bool)), this, SLOT(editName()));
m.addAction(action);
}
+#if 0 // FIXME::: FINISH OR DISABLE
+ // this shows how to figure out if we should ask the user if they want adjust interpolated pressures
+ // at either side of a gas change
+ if (dcEvent->type == SAMPLE_EVENT_GASCHANGE || dcEvent->type == SAMPLE_EVENT_GASCHANGE2) {
+ qDebug() << "figure out if there are interpolated pressures";
+ struct plot_data *gasChangeEntry = entry;
+ struct plot_data *newGasEntry;
+ while (gasChangeEntry > plotInfo.entry) {
+ --gasChangeEntry;
+ if (gasChangeEntry->sec <= dcEvent->time.seconds)
+ break;
+ }
+ qDebug() << "at gas change at" << gasChangeEntry->sec << ": sensor pressure" << gasChangeEntry->pressure[0] << "interpolated" << gasChangeEntry->pressure[1];
+ // now gasChangeEntry points at the gas change, that entry has the final pressure of
+ // the old tank, the next entry has the starting pressure of the next tank
+ if (gasChangeEntry + 1 <= plotInfo.entry + plotInfo.nr) {
+ newGasEntry = gasChangeEntry + 1;
+ qDebug() << "after gas change at " << newGasEntry->sec << ": sensor pressure" << newGasEntry->pressure[0] << "interpolated" << newGasEntry->pressure[1];
+ if (SENSOR_PRESSURE(gasChangeEntry) == 0 || displayed_dive.cylinder[gasChangeEntry->cylinderindex].sample_start.mbar == 0) {
+ // if we have no sensorpressure or if we have no pressure from samples we can assume that
+ // we only have interpolated pressure (the pressure in the entry may be stored in the sensor
+ // pressure field if this is the first or last entry for this tank... see details in gaspressures.c
+ pressure_t pressure;
+ pressure.mbar = INTERPOLATED_PRESSURE(gasChangeEntry) ? : SENSOR_PRESSURE(gasChangeEntry);
+ QAction *adjustOldPressure = m.addAction(tr("Adjust pressure of tank %1 (currently interpolated as %2)")
+ .arg(gasChangeEntry->cylinderindex + 1).arg(get_pressure_string(pressure)));
+ }
+ if (SENSOR_PRESSURE(newGasEntry) == 0 || displayed_dive.cylinder[newGasEntry->cylinderindex].sample_start.mbar == 0) {
+ // we only have interpolated press -- see commend above
+ pressure_t pressure;
+ pressure.mbar = INTERPOLATED_PRESSURE(newGasEntry) ? : SENSOR_PRESSURE(newGasEntry);
+ QAction *adjustOldPressure = m.addAction(tr("Adjust pressure of tank %1 (currently interpolated as %2)")
+ .arg(newGasEntry->cylinderindex + 1).arg(get_pressure_string(pressure)));
+ }
+ }
+ }
+#endif
}
bool some_hidden = false;
for (int i = 0; i < evn_used; i++) {