mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: move cylinder related functions to struct dive
Seems natural in a C++ code base. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
3aab33ba4c
commit
1b593dc56c
29 changed files with 250 additions and 259 deletions
|
@ -51,7 +51,7 @@ void DiveEventItem::setupPixmap(struct gasmix lastgasmix, const DivePixmaps &pix
|
|||
setPixmap(pixmaps.bookmark);
|
||||
setOffset(QPointF(0.0, -pixmap().height()));
|
||||
} else if (ev.is_gaschange()) {
|
||||
struct gasmix mix = get_gasmix_from_event(dive, ev);
|
||||
struct gasmix mix = dive->get_gasmix_from_event(ev);
|
||||
struct icd_data icd_data;
|
||||
bool icd = isobaric_counterdiffusion(lastgasmix, mix, &icd_data);
|
||||
if (mix.he.permille) {
|
||||
|
@ -123,7 +123,7 @@ void DiveEventItem::setupToolTipString(struct gasmix lastgasmix)
|
|||
|
||||
if (ev.is_gaschange()) {
|
||||
struct icd_data icd_data;
|
||||
struct gasmix mix = get_gasmix_from_event(dive, ev);
|
||||
struct gasmix mix = dive->get_gasmix_from_event(ev);
|
||||
name += ": ";
|
||||
name += gasname(mix);
|
||||
|
||||
|
|
|
@ -602,9 +602,7 @@ void DiveGasPressureItem::replot(const dive *d, int fromIn, int toIn, bool in_pl
|
|||
|
||||
bool showDescriptions = false;
|
||||
for (int cyl = 0; cyl < pInfo.nr_cylinders; cyl++) {
|
||||
const cylinder_t *c = get_cylinder(d, cyl);
|
||||
if (!c)
|
||||
continue;
|
||||
const cylinder_t *c = d->get_cylinder(cyl);
|
||||
showDescriptions = showDescriptions || (c && same_gasmix_cylinder(*c, cyl, d, true) != -1);
|
||||
if (act_segments[cyl].polygon.empty())
|
||||
continue;
|
||||
|
@ -634,7 +632,7 @@ void DiveGasPressureItem::replot(const dive *d, int fromIn, int toIn, bool in_pl
|
|||
|
||||
// For each cylinder, on right hand side of the curve, write cylinder pressure
|
||||
double x_offset = plotPressureValue(segment.last.pressure, segment.last.time, Qt::AlignTop | Qt::AlignLeft, y_offset) + 2;
|
||||
plotGasValue(segment.last.pressure, segment.last.time, get_cylinder(d, segment.cyl), Qt::AlignTop | Qt::AlignLeft, x_offset, y_offset, showDescriptions);
|
||||
plotGasValue(segment.last.pressure, segment.last.time, d->get_cylinder(segment.cyl), Qt::AlignTop | Qt::AlignLeft, x_offset, y_offset, showDescriptions);
|
||||
|
||||
/* Alternate alignment as we see cylinder use.. */
|
||||
startAlignVar ^= Qt::AlignTop | Qt::AlignBottom;
|
||||
|
|
|
@ -551,7 +551,7 @@ void ProfileScene::plotDive(const struct dive *dIn, int dcIn, DivePlannerPointsM
|
|||
// while all other items are up there on the constructor.
|
||||
qDeleteAll(eventItems);
|
||||
eventItems.clear();
|
||||
struct gasmix lastgasmix = get_gasmix_at_time(*d, *currentdc, duration_t{1});
|
||||
struct gasmix lastgasmix = d->get_gasmix_at_time(*currentdc, duration_t{1});
|
||||
|
||||
for (auto [idx, event]: enumerated_range(currentdc->events)) {
|
||||
// if print mode is selected only draw headings, SP change, gas events or bookmark event
|
||||
|
@ -571,7 +571,7 @@ void ProfileScene::plotDive(const struct dive *dIn, int dcIn, DivePlannerPointsM
|
|||
eventItems.push_back(item);
|
||||
}
|
||||
if (event.is_gaschange())
|
||||
lastgasmix = get_gasmix_from_event(d, event);
|
||||
lastgasmix = d->get_gasmix_from_event(event);
|
||||
}
|
||||
|
||||
QString dcText = QString::fromStdString(get_dc_nickname(currentdc));
|
||||
|
|
|
@ -614,7 +614,7 @@ void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event)
|
|||
if (gasChangeIdx < plotInfo.nr - 1) {
|
||||
int newGasIdx = gasChangeIdx + 1;
|
||||
const struct plot_data &newGasEntry = plotInfo.entry[newGasIdx];
|
||||
if (get_plot_sensor_pressure(&plotInfo, gasChangeIdx) == 0 || get_cylinder(d, gasChangeEntry->sensor[0])->sample_start.mbar == 0) {
|
||||
if (get_plot_sensor_pressure(&plotInfo, gasChangeIdx) == 0 || d->get_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
|
||||
|
@ -623,7 +623,7 @@ void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event)
|
|||
QAction *adjustOldPressure = m.addAction(tr("Adjust pressure of cyl. %1 (currently interpolated as %2)")
|
||||
.arg(gasChangeEntry->sensor[0] + 1).arg(get_pressure_string(pressure)));
|
||||
}
|
||||
if (get_plot_sensor_pressure(&plotInfo, newGasIdx) == 0 || get_cylinder(d, newGasEntry->sensor[0])->sample_start.mbar == 0) {
|
||||
if (get_plot_sensor_pressure(&plotInfo, newGasIdx) == 0 || d->get_cylinder(newGasEntry->sensor[0])->sample_start.mbar == 0) {
|
||||
// we only have interpolated press -- see commend above
|
||||
pressure_t pressure;
|
||||
pressure.mbar = get_plot_interpolated_pressure(&plotInfo, newGasIdx) ? : get_plot_sensor_pressure(&plotInfo, newGasIdx);
|
||||
|
@ -920,7 +920,7 @@ void ProfileWidget2::repositionDiveHandlers()
|
|||
QPointF pos = line.pointAt(0.5);
|
||||
gases[i]->setPos(pos);
|
||||
if (datapoint.cylinderid >= 0 && datapoint.cylinderid < static_cast<int>(d->cylinders.size()))
|
||||
gases[i]->setText(get_gas_string(get_cylinder(d, datapoint.cylinderid)->gasmix));
|
||||
gases[i]->setText(get_gas_string(d->get_cylinder(datapoint.cylinderid)->gasmix));
|
||||
else
|
||||
gases[i]->setText(QString());
|
||||
gases[i]->setVisible(datapoint.entered &&
|
||||
|
|
|
@ -84,14 +84,14 @@ void TankItem::setData(const struct dive *d, const struct divecomputer *dc, int
|
|||
struct gasmix gasmix = gasmix_invalid;
|
||||
const struct event *ev;
|
||||
while ((ev = loop.next(*dc)) != nullptr && ev->time.seconds <= plotStartTime)
|
||||
gasmix = get_gasmix_from_event(d, *ev);
|
||||
gasmix = d->get_gasmix_from_event(*ev);
|
||||
|
||||
// work through all the gas changes and add the rectangle for each gas while it was used
|
||||
int startTime = plotStartTime;
|
||||
while (ev && (int)ev->time.seconds < plotEndTime) {
|
||||
createBar(startTime, ev->time.seconds, gasmix);
|
||||
startTime = ev->time.seconds;
|
||||
gasmix = get_gasmix_from_event(d, *ev);
|
||||
gasmix = d->get_gasmix_from_event(*ev);
|
||||
ev = loop.next(*dc);
|
||||
}
|
||||
createBar(startTime, plotEndTime, gasmix);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue