diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-07-06 11:58:27 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-11-09 19:19:04 +0100 |
commit | 4724c8853342580d2bc60bf85a566f6285330927 (patch) | |
tree | 40e6cb7939281a5baf98de697fe66bfcc6b618af /profile-widget | |
parent | fbd74c26d6652543cbc7331734e304dbf2ef5113 (diff) | |
download | subsurface-4724c8853342580d2bc60bf85a566f6285330927.tar.gz |
Profile: change get_plot_pressure to take index instead of pointer
The goal here is to make it possible to detach the pressure related
data from the plot_info structure. Thus, the pressure related data
can be allocated independently depending on the number of cylinders
per dive.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'profile-widget')
-rw-r--r-- | profile-widget/diveprofileitem.cpp | 9 | ||||
-rw-r--r-- | profile-widget/divetooltipitem.cpp | 6 | ||||
-rw-r--r-- | profile-widget/ruleritem.cpp | 2 |
3 files changed, 9 insertions, 8 deletions
diff --git a/profile-widget/diveprofileitem.cpp b/profile-widget/diveprofileitem.cpp index da3028ebb..bc74f7f40 100644 --- a/profile-widget/diveprofileitem.cpp +++ b/profile-widget/diveprofileitem.cpp @@ -665,11 +665,12 @@ void DiveGasPressureItem::modelDataChanged(const QModelIndex &topLeft, const QMo QPolygonF boundingPoly; polygons.clear(); + const struct plot_info *pInfo = &dataModel->data(); for (int i = 0, count = dataModel->rowCount(); i < count; i++) { - struct plot_data *entry = dataModel->data().entry + i; + const struct plot_data *entry = pInfo->entry + i; for (int cyl = 0; cyl < MAX_CYLINDERS; cyl++) { - int mbar = get_plot_pressure(entry, cyl); + int mbar = get_plot_pressure(pInfo, i, cyl); int time = entry->sec; if (!mbar) @@ -726,10 +727,10 @@ void DiveGasPressureItem::modelDataChanged(const QModelIndex &topLeft, const QMo double axisLog = log10(log10(axisRange)); for (int i = 0, count = dataModel->rowCount(); i < count; i++) { - struct plot_data *entry = dataModel->data().entry + i; + const struct plot_data *entry = pInfo->entry + i; for (int cyl = 0; cyl < MAX_CYLINDERS; cyl++) { - int mbar = get_plot_pressure(entry, cyl); + int mbar = get_plot_pressure(pInfo, i, cyl); if (!mbar) continue; diff --git a/profile-widget/divetooltipitem.cpp b/profile-widget/divetooltipitem.cpp index f88d3b769..16be94c15 100644 --- a/profile-widget/divetooltipitem.cpp +++ b/profile-widget/divetooltipitem.cpp @@ -230,7 +230,6 @@ void ToolTipItem::setTimeAxis(DiveCartesianAxis *axis) void ToolTipItem::refresh(const QPointF &pos) { - struct plot_data *entry; static QPixmap tissues(16,60); static QPainter painter(&tissues); static struct membuffer mb = {}; @@ -245,7 +244,7 @@ void ToolTipItem::refresh(const QPointF &pos) clear(); mb.len = 0; - entry = get_plot_details_new(&pInfo, time, &mb); + int idx = get_plot_details_new(&pInfo, time, &mb); tissues.fill(); painter.setPen(QColor(0, 0, 0, 0)); @@ -255,10 +254,11 @@ void ToolTipItem::refresh(const QPointF &pos) painter.drawRect(0, 10, 16, (100 - AMB_PERCENTAGE) / 2); painter.setBrush(QColor(Qt::red)); painter.drawRect(0,0,16,10); - if (entry) { + if (idx) { ProfileWidget2 *view = qobject_cast<ProfileWidget2*>(scene()->views().first()); Q_ASSERT(view); + const struct plot_data *entry = &pInfo.entry[idx]; painter.setPen(QColor(0, 0, 0, 255)); if (decoMode() == BUEHLMANN) painter.drawLine(0, lrint(60 - entry->gfline / 2), 16, lrint(60 - entry->gfline / 2)); diff --git a/profile-widget/ruleritem.cpp b/profile-widget/ruleritem.cpp index aecbab85b..a76012739 100644 --- a/profile-widget/ruleritem.cpp +++ b/profile-widget/ruleritem.cpp @@ -116,7 +116,7 @@ void RulerItem2::recalculate() } QLineF line(startPoint, endPoint); setLine(line); - compare_samples(&pInfo.entry[source->idx], &pInfo.entry[dest->idx], buffer, 500, 1); + compare_samples(&pInfo, source->idx, dest->idx, buffer, 500, 1); text = QString(buffer); // draw text |