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
98
core/color.h
98
core/color.h
|
|
@ -7,65 +7,67 @@
|
||||||
|
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
|
||||||
|
#define MAKEQCOLOR(r,g,b,a) QColor::fromRgbF((float)(r), (float)(b), (float)(g), (float)(a))
|
||||||
|
|
||||||
// Greens
|
// Greens
|
||||||
#define CAMARONE1 QColor::fromRgbF(0.0, 0.4, 0.0, 1)
|
#define CAMARONE1 MAKEQCOLOR(0.0, 0.4, 0.0, 1)
|
||||||
#define FUNGREEN1 QColor::fromRgbF(0.0, 0.4, 0.2, 1)
|
#define FUNGREEN1 MAKEQCOLOR(0.0, 0.4, 0.2, 1)
|
||||||
#define FUNGREEN1_HIGH_TRANS QColor::fromRgbF(0.0, 0.4, 0.2, 0.25)
|
#define FUNGREEN1_HIGH_TRANS MAKEQCOLOR(0.0, 0.4, 0.2, 0.25)
|
||||||
#define KILLARNEY1 QColor::fromRgbF(0.2, 0.4, 0.2, 1)
|
#define KILLARNEY1 MAKEQCOLOR(0.2, 0.4, 0.2, 1)
|
||||||
#define APPLE1 QColor::fromRgbF(0.2, 0.6, 0.2, 1)
|
#define APPLE1 MAKEQCOLOR(0.2, 0.6, 0.2, 1)
|
||||||
#define APPLE1_MED_TRANS QColor::fromRgbF(0.2, 0.6, 0.2, 0.5)
|
#define APPLE1_MED_TRANS MAKEQCOLOR(0.2, 0.6, 0.2, 0.5)
|
||||||
#define APPLE1_HIGH_TRANS QColor::fromRgbF(0.2, 0.6, 0.2, 0.25)
|
#define APPLE1_HIGH_TRANS MAKEQCOLOR(0.2, 0.6, 0.2, 0.25)
|
||||||
#define LIMENADE1 QColor::fromRgbF(0.4, 0.8, 0.0, 1)
|
#define LIMENADE1 MAKEQCOLOR(0.4, 0.8, 0.0, 1)
|
||||||
#define ATLANTIS1 QColor::fromRgbF(0.4, 0.8, 0.2, 1)
|
#define ATLANTIS1 MAKEQCOLOR(0.4, 0.8, 0.2, 1)
|
||||||
#define ATLANTIS2 QColor::fromRgbF(0.6, 0.8, 0.2, 1)
|
#define ATLANTIS2 MAKEQCOLOR(0.6, 0.8, 0.2, 1)
|
||||||
#define RIOGRANDE1 QColor::fromRgbF(0.8, 0.8, 0.0, 1)
|
#define RIOGRANDE1 MAKEQCOLOR(0.8, 0.8, 0.0, 1)
|
||||||
#define EARLSGREEN1 QColor::fromRgbF(0.8, 0.8, 0.2, 1)
|
#define EARLSGREEN1 MAKEQCOLOR(0.8, 0.8, 0.2, 1)
|
||||||
#define FORESTGREEN1 QColor::fromRgbF(0.1, 0.5, 0.1, 1)
|
#define FORESTGREEN1 MAKEQCOLOR(0.1, 0.5, 0.1, 1)
|
||||||
#define NITROX_GREEN QColor::fromRgbF(0, 0.54, 0.375, 1)
|
#define NITROX_GREEN MAKEQCOLOR(0, 0.54, 0.375, 1)
|
||||||
|
|
||||||
// Reds
|
// Reds
|
||||||
#define PERSIANRED1 QColor::fromRgbF(0.8, 0.2, 0.2, 1)
|
#define PERSIANRED1 MAKEQCOLOR(0.8, 0.2, 0.2, 1)
|
||||||
#define TUSCANY1 QColor::fromRgbF(0.8, 0.4, 0.2, 1)
|
#define TUSCANY1 MAKEQCOLOR(0.8, 0.4, 0.2, 1)
|
||||||
#define PIRATEGOLD1 QColor::fromRgbF(0.8, 0.5, 0.0, 1)
|
#define PIRATEGOLD1 MAKEQCOLOR(0.8, 0.5, 0.0, 1)
|
||||||
#define PIRATEGOLD1_MED_TRANS QColor::fromRgbF(0.8, 0.5, 0.0, 0.75)
|
#define PIRATEGOLD1_MED_TRANS MAKEQCOLOR(0.8, 0.5, 0.0, 0.75)
|
||||||
#define HOKEYPOKEY1 QColor::fromRgbF(0.8, 0.6, 0.2, 1)
|
#define HOKEYPOKEY1 MAKEQCOLOR(0.8, 0.6, 0.2, 1)
|
||||||
#define CINNABAR1 QColor::fromRgbF(0.9, 0.3, 0.2, 1)
|
#define CINNABAR1 MAKEQCOLOR(0.9, 0.3, 0.2, 1)
|
||||||
#define REDORANGE1 QColor::fromRgbF(1.0, 0.2, 0.2, 1)
|
#define REDORANGE1 MAKEQCOLOR(1.0, 0.2, 0.2, 1)
|
||||||
#define REDORANGE1_HIGH_TRANS QColor::fromRgbF(1.0, 0.2, 0.2, 0.25)
|
#define REDORANGE1_HIGH_TRANS MAKEQCOLOR(1.0, 0.2, 0.2, 0.25)
|
||||||
#define REDORANGE1_MED_TRANS QColor::fromRgbF(1.0, 0.2, 0.2, 0.5)
|
#define REDORANGE1_MED_TRANS MAKEQCOLOR(1.0, 0.2, 0.2, 0.5)
|
||||||
#define RED1_MED_TRANS QColor::fromRgbF(1.0, 0.0, 0.0, 0.5)
|
#define RED1_MED_TRANS MAKEQCOLOR(1.0, 0.0, 0.0, 0.5)
|
||||||
#define RED1 QColor::fromRgbF(1.0, 0.0, 0.0, 1)
|
#define RED1 MAKEQCOLOR(1.0, 0.0, 0.0, 1)
|
||||||
|
|
||||||
// Monochromes
|
// Monochromes
|
||||||
#define BLACK1 QColor::fromRgbF(0.0, 0.0, 0.0, 1)
|
#define BLACK1 MAKEQCOLOR(0.0, 0.0, 0.0, 1)
|
||||||
#define BLACK1_LOW_TRANS QColor::fromRgbF(0.0, 0.0, 0.0, 0.75)
|
#define BLACK1_LOW_TRANS MAKEQCOLOR(0.0, 0.0, 0.0, 0.75)
|
||||||
#define BLACK1_HIGH_TRANS QColor::fromRgbF(0.0, 0.0, 0.0, 0.25)
|
#define BLACK1_HIGH_TRANS MAKEQCOLOR(0.0, 0.0, 0.0, 0.25)
|
||||||
#define TUNDORA1_MED_TRANS QColor::fromRgbF(0.3, 0.3, 0.3, 0.5)
|
#define TUNDORA1_MED_TRANS MAKEQCOLOR(0.3, 0.3, 0.3, 0.5)
|
||||||
#define MED_GRAY_HIGH_TRANS QColor::fromRgbF(0.5, 0.5, 0.5, 0.25)
|
#define MED_GRAY_HIGH_TRANS MAKEQCOLOR(0.5, 0.5, 0.5, 0.25)
|
||||||
#define MERCURY1_MED_TRANS QColor::fromRgbF(0.9, 0.9, 0.9, 0.5)
|
#define MERCURY1_MED_TRANS MAKEQCOLOR(0.9, 0.9, 0.9, 0.5)
|
||||||
#define CONCRETE1_LOWER_TRANS QColor::fromRgbF(0.95, 0.95, 0.95, 0.9)
|
#define CONCRETE1_LOWER_TRANS MAKEQCOLOR(0.95, 0.95, 0.95, 0.9)
|
||||||
#define WHITE1_MED_TRANS QColor::fromRgbF(1.0, 1.0, 1.0, 0.5)
|
#define WHITE1_MED_TRANS MAKEQCOLOR(1.0, 1.0, 1.0, 0.5)
|
||||||
#define WHITE1 QColor::fromRgbF(1.0, 1.0, 1.0, 1)
|
#define WHITE1 MAKEQCOLOR(1.0, 1.0, 1.0, 1)
|
||||||
|
|
||||||
// Blues
|
// Blues
|
||||||
#define GOVERNORBAY2 QColor::fromRgbF(0.2, 0.2, 0.7, 1)
|
#define GOVERNORBAY2 MAKEQCOLOR(0.2, 0.2, 0.7, 1)
|
||||||
#define GOVERNORBAY1_MED_TRANS QColor::fromRgbF(0.2, 0.2, 0.8, 0.5)
|
#define GOVERNORBAY1_MED_TRANS MAKEQCOLOR(0.2, 0.2, 0.8, 0.5)
|
||||||
#define ROYALBLUE2 QColor::fromRgbF(0.2, 0.2, 0.9, 1)
|
#define ROYALBLUE2 MAKEQCOLOR(0.2, 0.2, 0.9, 1)
|
||||||
#define ROYALBLUE2_LOW_TRANS QColor::fromRgbF(0.2, 0.2, 0.9, 0.75)
|
#define ROYALBLUE2_LOW_TRANS MAKEQCOLOR(0.2, 0.2, 0.9, 0.75)
|
||||||
#define AIR_BLUE QColor::fromRgbF(0.25, 0.75, 1.0, 1)
|
#define AIR_BLUE MAKEQCOLOR(0.25, 0.75, 1.0, 1)
|
||||||
#define AIR_BLUE_TRANS QColor::fromRgbF(0.25, 0.75, 1.0, 0.5)
|
#define AIR_BLUE_TRANS MAKEQCOLOR(0.25, 0.75, 1.0, 0.5)
|
||||||
|
|
||||||
// Yellows / BROWNS
|
// Yellows / BROWNS
|
||||||
#define SPRINGWOOD1 QColor::fromRgbF(0.95, 0.95, 0.9, 1)
|
#define SPRINGWOOD1 MAKEQCOLOR(0.95, 0.95, 0.9, 1)
|
||||||
#define SPRINGWOOD1_MED_TRANS QColor::fromRgbF(0.95, 0.95, 0.9, 0.5)
|
#define SPRINGWOOD1_MED_TRANS MAKEQCOLOR(0.95, 0.95, 0.9, 0.5)
|
||||||
#define BROOM1_LOWER_TRANS QColor::fromRgbF(1.0, 1.0, 0.1, 0.9)
|
#define BROOM1_LOWER_TRANS MAKEQCOLOR(1.0, 1.0, 0.1, 0.9)
|
||||||
#define PEANUT QColor::fromRgbF(0.5, 0.2, 0.1, 1.0)
|
#define PEANUT MAKEQCOLOR(0.5, 0.2, 0.1, 1.0)
|
||||||
#define PEANUT_MED_TRANS QColor::fromRgbF(0.5, 0.2, 0.1, 0.5)
|
#define PEANUT_MED_TRANS MAKEQCOLOR(0.5, 0.2, 0.1, 0.5)
|
||||||
#define NITROX_YELLOW QColor::fromRgbF(0.98, 0.89, 0.07, 1.0)
|
#define NITROX_YELLOW MAKEQCOLOR(0.98, 0.89, 0.07, 1.0)
|
||||||
|
|
||||||
// Magentas
|
// Magentas
|
||||||
#define MEDIUMREDVIOLET1_HIGHER_TRANS QColor::fromRgbF(0.7, 0.2, 0.7, 0.1)
|
#define MEDIUMREDVIOLET1_HIGHER_TRANS MAKEQCOLOR(0.7, 0.2, 0.7, 0.1)
|
||||||
#define MAGENTA QColor::fromRgbF(1.0, 0.0, 1.0, 1.0)
|
#define MAGENTA MAKEQCOLOR(1.0, 0.0, 1.0, 1.0)
|
||||||
|
|
||||||
#define SAC_COLORS_START_IDX SAC_1
|
#define SAC_COLORS_START_IDX SAC_1
|
||||||
#define SAC_COLORS 9
|
#define SAC_COLORS 9
|
||||||
|
|
|
||||||
|
|
@ -250,9 +250,9 @@ KMessageWidget::MessageType KMessageWidget::messageType() const
|
||||||
|
|
||||||
static QColor darkShade(QColor c)
|
static QColor darkShade(QColor c)
|
||||||
{
|
{
|
||||||
qreal contrast = 0.7; // taken from kcolorscheme for the dark shade
|
double contrast = 0.7; // taken from kcolorscheme for the dark shade
|
||||||
|
|
||||||
qreal darkAmount;
|
double darkAmount;
|
||||||
if (c.lightnessF() < 0.006) { /* too dark */
|
if (c.lightnessF() < 0.006) { /* too dark */
|
||||||
darkAmount = 0.02 + 0.40 * contrast;
|
darkAmount = 0.02 + 0.40 * contrast;
|
||||||
} else if (c.lightnessF() > 0.93) { /* too bright */
|
} else if (c.lightnessF() > 0.93) { /* too bright */
|
||||||
|
|
@ -261,9 +261,9 @@ static QColor darkShade(QColor c)
|
||||||
darkAmount = (-c.lightnessF()) * (0.55 + contrast * 0.35);
|
darkAmount = (-c.lightnessF()) * (0.55 + contrast * 0.35);
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal v = c.lightnessF() + darkAmount;
|
double v = c.lightnessF() + darkAmount;
|
||||||
v = v > 0.0 ? (v < 1.0 ? v : 1.0) : 0.0;
|
v = v > 0.0 ? (v < 1.0 ? v : 1.0) : 0.0;
|
||||||
c.setHsvF(c.hslHueF(), c.hslSaturationF(), v);
|
c.setHsvF(c.hslHueF(), c.hslSaturationF(), (float)v);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -272,7 +272,7 @@ QColor QtWaitingSpinner::currentLineColor(int countDistance, int totalNrOfLines,
|
||||||
int distanceThreshold =
|
int distanceThreshold =
|
||||||
static_cast<int>(ceil((totalNrOfLines - 1) * trailFadePerc / 100.0));
|
static_cast<int>(ceil((totalNrOfLines - 1) * trailFadePerc / 100.0));
|
||||||
if (countDistance > distanceThreshold) {
|
if (countDistance > distanceThreshold) {
|
||||||
color.setAlphaF(minAlphaF);
|
color.setAlphaF((float)minAlphaF);
|
||||||
} else {
|
} else {
|
||||||
qreal alphaDiff = color.alphaF() - minAlphaF;
|
qreal alphaDiff = color.alphaF() - minAlphaF;
|
||||||
qreal gradient = alphaDiff / static_cast<qreal>(distanceThreshold + 1);
|
qreal gradient = alphaDiff / static_cast<qreal>(distanceThreshold + 1);
|
||||||
|
|
@ -280,7 +280,7 @@ QColor QtWaitingSpinner::currentLineColor(int countDistance, int totalNrOfLines,
|
||||||
|
|
||||||
// If alpha is out of bounds, clip it.
|
// If alpha is out of bounds, clip it.
|
||||||
resultAlpha = std::min(1.0, std::max(0.0, resultAlpha));
|
resultAlpha = std::min(1.0, std::max(0.0, resultAlpha));
|
||||||
color.setAlphaF(resultAlpha);
|
color.setAlphaF((float)resultAlpha);
|
||||||
}
|
}
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,29 +52,30 @@ static std::array<int, num_tissues> calcLinesPerTissue(int size)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define SETHSVF(h, s, v) setHsvF((float)(h), (float)(s), (float)(v))
|
||||||
static QRgb colorScale(double value, int inert)
|
static QRgb colorScale(double value, int inert)
|
||||||
{
|
{
|
||||||
QColor color;
|
QColor color;
|
||||||
double scaledValue = value / (AMB_PERCENTAGE * inert) * 1000.0;
|
double scaledValue = value / (AMB_PERCENTAGE * inert) * 1000.0;
|
||||||
if (scaledValue < 0.8) // grade from cyan to blue to purple
|
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
|
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
|
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)
|
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)
|
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)
|
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
|
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
|
else // white
|
||||||
color.setHsvF(0.0, 0.0, 1.0);
|
color.SETHSVF(0.0, 0.0, 1.0);
|
||||||
return color.rgba();
|
return color.rgba();
|
||||||
}
|
}
|
||||||
|
#undef SETHSVF
|
||||||
void DivePercentageItem::replot(const dive *d, const struct divecomputer *dc, const plot_info &pi)
|
void DivePercentageItem::replot(const dive *d, const struct divecomputer *dc, const plot_info &pi)
|
||||||
{
|
{
|
||||||
auto [minX, maxX] = hAxis.screenMinMax();
|
auto [minX, maxX] = hAxis.screenMinMax();
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ DivePixmaps::DivePixmaps(int dpr) : dpr(dpr)
|
||||||
// The transparen pixmap is a very obscure feature to enable tooltips without showing a pixmap.
|
// The transparen pixmap is a very obscure feature to enable tooltips without showing a pixmap.
|
||||||
// See code in diveeventitem.cpp. This should probably be replaced by a different mechanism.
|
// See code in diveeventitem.cpp. This should probably be replaced by a different mechanism.
|
||||||
QPixmap transparentPixmap(lrint(4 * dprf), lrint(20 * dprf));
|
QPixmap transparentPixmap(lrint(4 * dprf), lrint(20 * dprf));
|
||||||
transparentPixmap.fill(QColor::fromRgbF(1.0, 1.0, 1.0, 0.01));
|
transparentPixmap.fill(QColor::fromRgbF(1.0f, 1.0f, 1.0f, 0.01f));
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::vector<std::shared_ptr<const DivePixmaps>> cache;
|
static std::vector<std::shared_ptr<const DivePixmaps>> cache;
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ void RegressionItem::updatePosition()
|
||||||
img->fill(Qt::transparent);
|
img->fill(Qt::transparent);
|
||||||
if (confidence) {
|
if (confidence) {
|
||||||
QColor col(regressionItemColor);
|
QColor col(regressionItemColor);
|
||||||
col.setAlphaF(reg.r2);
|
col.setAlphaF((float)reg.r2);
|
||||||
painter->setPen(Qt::NoPen);
|
painter->setPen(Qt::NoPen);
|
||||||
painter->setBrush(QBrush(col));
|
painter->setBrush(QBrush(col));
|
||||||
painter->drawPolygon(poly);
|
painter->drawPolygon(poly);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue