mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
cleanup: prevent distracing conversion warnings
We do want the -Wfloat-conversion warnings where they point out potential bugs. But they are very distracting when they are triggered by floating point literals (which the standard defines as double) passed to a function expecting float arguments. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
4b539ef044
commit
008f8ad21e
6 changed files with 68 additions and 65 deletions
|
|
@ -52,29 +52,30 @@ static std::array<int, num_tissues> calcLinesPerTissue(int size)
|
|||
return res;
|
||||
}
|
||||
|
||||
#define SETHSVF(h, s, v) setHsvF((float)(h), (float)(s), (float)(v))
|
||||
static QRgb colorScale(double value, int inert)
|
||||
{
|
||||
QColor color;
|
||||
double scaledValue = value / (AMB_PERCENTAGE * inert) * 1000.0;
|
||||
if (scaledValue < 0.8) // grade from cyan to blue to purple
|
||||
color.setHsvF(0.5 + 0.25 * scaledValue / 0.8, 1.0, 1.0);
|
||||
color.SETHSVF(0.5 + 0.25 * scaledValue / 0.8, 1.0, 1.0);
|
||||
else if (scaledValue < 1.0) // grade from magenta to black
|
||||
color.setHsvF(0.75, 1.0, (1.0 - scaledValue) / 0.2);
|
||||
color.SETHSVF(0.75, 1.0, (1.0 - scaledValue) / 0.2);
|
||||
else if (value < AMB_PERCENTAGE) // grade from black to bright green
|
||||
color.setHsvF(0.333, 1.0, (value - AMB_PERCENTAGE * inert / 1000.0) / (AMB_PERCENTAGE - AMB_PERCENTAGE * inert / 1000.0));
|
||||
color.SETHSVF(0.333, 1.0, (value - AMB_PERCENTAGE * inert / 1000.0) / (AMB_PERCENTAGE - AMB_PERCENTAGE * inert / 1000.0));
|
||||
else if (value < 65) // grade from bright green (0% M) to yellow-green (30% M)
|
||||
color.setHsvF(0.333 - 0.133 * (value - AMB_PERCENTAGE) / (65.0 - AMB_PERCENTAGE), 1.0, 1.0);
|
||||
color.SETHSVF(0.333 - 0.133 * (value - AMB_PERCENTAGE) / (65.0 - AMB_PERCENTAGE), 1.0, 1.0);
|
||||
else if (value < 85) // grade from yellow-green (30% M) to orange (70% M)
|
||||
color.setHsvF(0.2 - 0.1 * (value - 65.0) / 20.0, 1.0, 1.0);
|
||||
color.SETHSVF(0.2 - 0.1 * (value - 65.0) / 20.0, 1.0, 1.0);
|
||||
else if (value < 100) // grade from orange (70% M) to red (100% M)
|
||||
color.setHsvF(0.1 * (100.0 - value) / 15.0, 1.0, 1.0);
|
||||
color.SETHSVF(0.1 * (100.0 - value) / 15.0, 1.0, 1.0);
|
||||
else if (value < 120) // M value exceeded - grade from red to white
|
||||
color.setHsvF(0.0, 1 - (value - 100.0) / 20.0, 1.0);
|
||||
color.SETHSVF(0.0, 1 - (value - 100.0) / 20.0, 1.0);
|
||||
else // white
|
||||
color.setHsvF(0.0, 0.0, 1.0);
|
||||
color.SETHSVF(0.0, 0.0, 1.0);
|
||||
return color.rgba();
|
||||
}
|
||||
|
||||
#undef SETHSVF
|
||||
void DivePercentageItem::replot(const dive *d, const struct divecomputer *dc, const plot_info &pi)
|
||||
{
|
||||
auto [minX, maxX] = hAxis.screenMinMax();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue