mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
profile: fix displaying of gas pressures
Due to bit-rot the gas pressure and gas type were displayed on top of each other. I don't understand the meaning of the old code [log10(log10(axisRange))] (!). Therefore let's just add the height of the label to separate the labels. Probably needs some fine-tuning. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
85d1e1d199
commit
56f6e5051f
1 changed files with 5 additions and 12 deletions
|
@ -471,8 +471,7 @@ void DiveGasPressureItem::replot(const dive *d, int fromIn, int toIn, bool in_pl
|
||||||
QFlags<Qt::AlignmentFlag> alignVar = Qt::AlignTop;
|
QFlags<Qt::AlignmentFlag> alignVar = Qt::AlignTop;
|
||||||
std::vector<QFlags<Qt::AlignmentFlag>> align(pInfo->nr_cylinders);
|
std::vector<QFlags<Qt::AlignmentFlag>> align(pInfo->nr_cylinders);
|
||||||
|
|
||||||
double axisRange = (vAxis.maximum() - vAxis.minimum())/1000; // Convert axis pressure range to bar
|
double labelHeight = DiveTextItem::fontHeight(dpr, 1.0);
|
||||||
double axisLog = log10(log10(axisRange));
|
|
||||||
|
|
||||||
for (int i = from; i < to; i++) {
|
for (int i = from; i < to; i++) {
|
||||||
const struct plot_data *entry = pInfo->entry + i;
|
const struct plot_data *entry = pInfo->entry + i;
|
||||||
|
@ -484,17 +483,11 @@ void DiveGasPressureItem::replot(const dive *d, int fromIn, int toIn, bool in_pl
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!seen_cyl[cyl]) {
|
if (!seen_cyl[cyl]) {
|
||||||
double value_y_offset, label_y_offset;
|
|
||||||
|
|
||||||
// Magic Y offset depending on whether we're aliging
|
// Magic Y offset depending on whether we're aliging
|
||||||
// the top of the text or the bottom of the text to
|
// the top of the text or the bottom of the text to
|
||||||
// the pressure line.
|
// the pressure line.
|
||||||
value_y_offset = -0.5;
|
double value_y_offset = -0.5;
|
||||||
if (alignVar & Qt::AlignTop) {
|
double label_y_offset = alignVar & Qt::AlignTop ? labelHeight : -labelHeight;
|
||||||
label_y_offset = 5 * axisLog;
|
|
||||||
} else {
|
|
||||||
label_y_offset = -7 * axisLog;
|
|
||||||
}
|
|
||||||
plotPressureValue(mbar, entry->sec, alignVar, value_y_offset);
|
plotPressureValue(mbar, entry->sec, alignVar, value_y_offset);
|
||||||
plotGasValue(mbar, entry->sec, get_cylinder(d, cyl)->gasmix, alignVar, label_y_offset);
|
plotGasValue(mbar, entry->sec, get_cylinder(d, cyl)->gasmix, alignVar, label_y_offset);
|
||||||
seen_cyl[cyl] = true;
|
seen_cyl[cyl] = true;
|
||||||
|
@ -523,7 +516,7 @@ void DiveGasPressureItem::plotPressureValue(int mbar, int sec, QFlags<Qt::Alignm
|
||||||
int pressure = get_pressure_units(mbar, &unit);
|
int pressure = get_pressure_units(mbar, &unit);
|
||||||
DiveTextItem *text = new DiveTextItem(dpr, 1.0, align, this);
|
DiveTextItem *text = new DiveTextItem(dpr, 1.0, align, this);
|
||||||
text->set(QString("%1%2").arg(pressure).arg(unit), getColor(PRESSURE_TEXT));
|
text->set(QString("%1%2").arg(pressure).arg(unit), getColor(PRESSURE_TEXT));
|
||||||
text->setPos(hAxis.posAtValue(sec), vAxis.posAtValue(mbar) + pressure_offset );
|
text->setPos(hAxis.posAtValue(sec), vAxis.posAtValue(mbar) + pressure_offset);
|
||||||
texts.push_back(text);
|
texts.push_back(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -532,7 +525,7 @@ void DiveGasPressureItem::plotGasValue(int mbar, int sec, struct gasmix gasmix,
|
||||||
QString gas = get_gas_string(gasmix);
|
QString gas = get_gas_string(gasmix);
|
||||||
DiveTextItem *text = new DiveTextItem(dpr, 1.0, align, this);
|
DiveTextItem *text = new DiveTextItem(dpr, 1.0, align, this);
|
||||||
text->set(gas, getColor(PRESSURE_TEXT));
|
text->set(gas, getColor(PRESSURE_TEXT));
|
||||||
text->setPos(hAxis.posAtValue(sec), vAxis.posAtValue(mbar) + gasname_offset );
|
text->setPos(hAxis.posAtValue(sec), vAxis.posAtValue(mbar) + gasname_offset);
|
||||||
texts.push_back(text);
|
texts.push_back(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue