diff options
Diffstat (limited to 'qt-ui/profile/diveprofileitem.cpp')
-rw-r--r-- | qt-ui/profile/diveprofileitem.cpp | 48 |
1 files changed, 17 insertions, 31 deletions
diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp index 3bc79832e..7d29d28b4 100644 --- a/qt-ui/profile/diveprofileitem.cpp +++ b/qt-ui/profile/diveprofileitem.cpp @@ -9,6 +9,9 @@ #include "helpers.h" #include "libdivecomputer/parser.h" #include "mainwindow.h" +#include "maintab.h" +#include "profile/profilewidget2.h" +#include "diveplanner.h" #include <QSettings> @@ -166,7 +169,7 @@ void DiveProfileItem::modelDataChanged(const QModelIndex &topLeft, const QModelI for (int i = 0; i < dataModel->rowCount(); i++, entry++) { int max = maxCeiling(i); // Don't scream if we violate the ceiling by a few cm - if (entry->depth < max - 100) { + if (entry->depth < max - 100 && entry->sec > 0) { profileColor = QColor(Qt::red); if (!eventAdded) { add_event(&displayed_dive.dc, entry->sec, SAMPLE_EVENT_CEILING, -1, max / 1000, "planned waypoint above ceiling"); @@ -682,8 +685,8 @@ void DiveGasPressureItem::modelDataChanged(const QModelIndex &topLeft, const QMo bool offsets_initialised = false; int o2cyl = -1, dilcyl = -1; - QFlags<Qt::AlignmentFlag> alignVar, align_dil = Qt::AlignBottom, align_o2 = Qt::AlignBottom; - double axisRange = (vAxis->maximum() - vAxis->minimum())/1000; + QFlags<Qt::AlignmentFlag> alignVar= Qt::AlignTop, align_dil = Qt::AlignBottom, align_o2 = Qt::AlignTop; + double axisRange = (vAxis->maximum() - vAxis->minimum())/1000; // Convert axis pressure range to bar double axisLog = log10(log10(axisRange)); for (int i = 0, count = dataModel->rowCount(); i < count; i++) { entry = dataModel->data().entry + i; @@ -691,23 +694,17 @@ void DiveGasPressureItem::modelDataChanged(const QModelIndex &topLeft, const QMo if (displayed_dive.dc.divemode == CCR && displayed_dive.oxygen_cylinder_index >= 0) o2mbar = GET_O2CYLINDER_PRESSURE(entry); - if (o2mbar) { + 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 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) - print_y_offset[o2cyl][1] = -0.5; // y offset for oxygen start pressure value (above) + 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) - print_y_offset[dilcyl][1] = 0; // y offset for diluent start pressure value (below) - align_dil = Qt::AlignBottom; - align_o2 = Qt::AlignTop; - } else { // ... else write o2 start cyl pressure below graph: - print_y_offset[o2cyl][0] = 5 * axisLog; // o2 lable & pressure below graph, - print_y_offset[o2cyl][1] = 0; - print_y_offset[dilcyl][0] = -7 * axisLog; // and diluent lable above graph. - print_y_offset[dilcyl][1] = -0.5; // and diluent pressure above graph. + } else { // ... else write o2 start cyl pressure below graph: + print_y_offset[o2cyl][0] = 5 * axisLog; // o2 lable & pressure below graph; pressure offsets=-0.5, already initialised + print_y_offset[dilcyl][0] = -7.8 * axisLog; // and diluent lable above graph. align_dil = Qt::AlignTop; align_o2 = Qt::AlignBottom; } @@ -722,9 +719,6 @@ void DiveGasPressureItem::modelDataChanged(const QModelIndex &topLeft, const QMo last_pressure[displayed_dive.oxygen_cylinder_index] = o2mbar; last_time[displayed_dive.oxygen_cylinder_index] = entry->sec; alignVar = align_dil; - } else { - alignVar = Qt::AlignBottom; - align_dil = Qt::AlignTop; } if (!mbar) @@ -733,29 +727,19 @@ void DiveGasPressureItem::modelDataChanged(const QModelIndex &topLeft, const QMo if (cyl != 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 (!seen_cyl[cyl]) { - plotPressureValue(mbar, entry->sec, alignVar, print_y_offset[cyl][0]); - plotGasValue(mbar, entry->sec, displayed_dive.cylinder[cyl].gasmix, align_dil, print_y_offset[cyl][1]); + 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]); seen_cyl[cyl] = true; } } last_pressure[cyl] = mbar; last_time[cyl] = entry->sec; } - // Now, for the cylinder pressure written near the right edge of the profile: - if ((o2cyl >= 0) && (dilcyl >= 0)) { // At first, skip uninitialised values of o2cyl and dilcyl - if (last_pressure[o2cyl] > last_pressure[dilcyl]) { // If oxygen cyl pressure graph ends above diluent graph: - align_dil = Qt::AlignTop; // initialise to write diluent cyl end pressure underneath the graph - align_o2 = Qt::AlignBottom; - } else { - align_dil = Qt::AlignBottom; // else initialise to write diluent cyl end pressure above the graph - align_o2 = Qt::AlignTop; - } - } 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; if (last_time[cyl]) { - plotPressureValue(last_pressure[cyl], last_time[cyl], (alignVar | Qt::AlignLeft), print_y_offset[cyl][0]); + plotPressureValue(last_pressure[cyl], last_time[cyl], (alignVar | Qt::AlignLeft), print_y_offset[cyl][1]); } } } @@ -808,12 +792,14 @@ DiveCalculatedCeiling::DiveCalculatedCeiling() : is3mIncrement(false), gradientF gradientFactor->setY(0); gradientFactor->setBrush(getColor(PRESSURE_TEXT)); gradientFactor->setAlignment(Qt::AlignHCenter | Qt::AlignBottom); - connect(MainWindow::instance()->information(), SIGNAL(dateTimeChanged()), this, SLOT(recalc())); settingsChanged(); } void DiveCalculatedCeiling::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) { + if (MainWindow::instance()->information()) + connect(MainWindow::instance()->information(), SIGNAL(dateTimeChanged()), this, SLOT(recalc()), Qt::UniqueConnection); + // We don't have enougth data to calculate things, quit. if (!shouldCalculateStuff(topLeft, bottomRight)) return; |