aboutsummaryrefslogtreecommitdiffstats
path: root/profile-widget
diff options
context:
space:
mode:
Diffstat (limited to 'profile-widget')
-rw-r--r--profile-widget/diveprofileitem.cpp39
-rw-r--r--profile-widget/profilewidget2.cpp10
-rw-r--r--profile-widget/tankitem.cpp6
3 files changed, 28 insertions, 27 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]);
}
diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp
index 90bf6dbb2..17f3544f3 100644
--- a/profile-widget/profilewidget2.cpp
+++ b/profile-widget/profilewidget2.cpp
@@ -1407,7 +1407,7 @@ void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event)
action->setText(model->data(model->index(i, 0), Qt::DisplayRole).toString() + QString(tr(" (Tank %1)")).arg(i + 1));
connect(action, SIGNAL(triggered(bool)), this, SLOT(changeGas()));
action->setData(event->globalPos());
- if (i == entry->cylinderindex)
+ if (i == entry->sensor[0])
action->setDisabled(true);
gasChange->addAction(action);
}
@@ -1457,21 +1457,21 @@ void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event)
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 (SENSOR_PRESSURE(gasChangeEntry) == 0 || displayed_dive.cylinder[gasChangeEntry->sensor[0]].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)));
+ .arg(gasChangeEntry->sensor[0] + 1).arg(get_pressure_string(pressure)));
}
- if (SENSOR_PRESSURE(newGasEntry) == 0 || displayed_dive.cylinder[newGasEntry->cylinderindex].sample_start.mbar == 0) {
+ if (SENSOR_PRESSURE(newGasEntry) == 0 || displayed_dive.cylinder[newGasEntry->sensor[0]].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)));
+ .arg(newGasEntry->sensor[0] + 1).arg(get_pressure_string(pressure)));
}
}
}
diff --git a/profile-widget/tankitem.cpp b/profile-widget/tankitem.cpp
index 307d3d397..89ddffed9 100644
--- a/profile-widget/tankitem.cpp
+++ b/profile-widget/tankitem.cpp
@@ -98,7 +98,7 @@ void TankItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &b
// walk the list and figure out which tanks go where
struct plot_data *entry = pInfoEntry;
struct plot_data *lastentry = pInfoEntry;
- int cylIdx = entry->cylinderindex;
+ int cylIdx = entry->sensor[0];
int i = -1;
int startTime = 0;
struct gasmix *gas = &diveCylinderStore.cylinder[cylIdx].gasmix;
@@ -106,12 +106,12 @@ void TankItem::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &b
while (++i < pInfoNr) {
entry = &pInfoEntry[i];
lastentry = &pInfoEntry[i-1];
- if (entry->cylinderindex == cylIdx)
+ if (entry->sensor[0] == cylIdx)
continue;
width = hAxis->posAtValue(lastentry->sec) - hAxis->posAtValue(startTime);
left = hAxis->posAtValue(startTime);
createBar(left, width, gas);
- cylIdx = entry->cylinderindex;
+ cylIdx = entry->sensor[0];
gas = &diveCylinderStore.cylinder[cylIdx].gasmix;
startTime = lastentry->sec;
}