From 7d937fa5c72c2f26b3f0e40ab09766b1f02367eb Mon Sep 17 00:00:00 2001 From: Christian Feldmann Date: Mon, 20 Jan 2025 08:45:17 +0100 Subject: [PATCH] Add missing operators. Emplace on optional does not want to work in GCC. --- YUViewLib/src/statistics/ColorMapper.cpp | 8 ++++++-- YUViewLib/src/statistics/ColorMapper.h | 1 + YUViewLib/src/statistics/StatisticsType.cpp | 15 ++++++++++----- YUViewLib/src/statistics/StatisticsType.h | 1 + 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/YUViewLib/src/statistics/ColorMapper.cpp b/YUViewLib/src/statistics/ColorMapper.cpp index 649305261..43f6c3fa5 100644 --- a/YUViewLib/src/statistics/ColorMapper.cpp +++ b/YUViewLib/src/statistics/ColorMapper.cpp @@ -152,8 +152,7 @@ Color ColorMapper::getColor(double value) const // The value scaled from 0 to 1 within the range (rangeMin ... rangeMax) auto valScaled = (value - this->valueRange.min) / rangeWidth; - auto interpolate = [&valScaled](int start, int end) - { + auto interpolate = [&valScaled](int start, int end) { auto range = end - start; auto rangeScaled = std::floor(valScaled * double(range) + 0.5); return start + int(rangeScaled); @@ -465,4 +464,9 @@ bool ColorMapper::operator==(const ColorMapper &other) const return false; } +bool ColorMapper::operator!=(const ColorMapper &other) const +{ + return !(*this == other); +} + } // namespace stats::color diff --git a/YUViewLib/src/statistics/ColorMapper.h b/YUViewLib/src/statistics/ColorMapper.h index 879c769d7..cab0a420b 100644 --- a/YUViewLib/src/statistics/ColorMapper.h +++ b/YUViewLib/src/statistics/ColorMapper.h @@ -131,6 +131,7 @@ class ColorMapper // Two colorMappers are identical if they will return the same color when asked for any value. // When changing the type of one of the mappers, this might not be true anymore. bool operator==(const ColorMapper &other) const; + bool operator!=(const ColorMapper &other) const; MappingType mappingType{MappingType::Predefined}; diff --git a/YUViewLib/src/statistics/StatisticsType.cpp b/YUViewLib/src/statistics/StatisticsType.cpp index 0a386fc53..8d4fa6c3f 100644 --- a/YUViewLib/src/statistics/StatisticsType.cpp +++ b/YUViewLib/src/statistics/StatisticsType.cpp @@ -67,7 +67,7 @@ LineDrawStyle convertStringToPen(const QString &str) return style; } -void addModifiedValuesToElement(YUViewDomElement &element, +void addModifiedValuesToElement(YUViewDomElement & element, const std::optional &options, const std::optional &initOptions) { @@ -86,7 +86,7 @@ std::vector AllArrowHeads = {StatisticsType::ArrowHea StatisticsType::ArrowHead::circle, StatisticsType::ArrowHead::none}; -void addModifiedValuesToElement(YUViewDomElement &element, +void addModifiedValuesToElement(YUViewDomElement & element, const std::optional &options, const std::optional &initOptions) { @@ -112,7 +112,7 @@ void addModifiedValuesToElement(YUViewDomElement } } -void addModifiedValuesToElement(YUViewDomElement &element, +void addModifiedValuesToElement(YUViewDomElement & element, const StatisticsType::GridOptions &options, const StatisticsType::GridOptions &initOptions) { @@ -131,6 +131,11 @@ bool LineDrawStyle::operator==(const LineDrawStyle &other) const return color == other.color && width == other.width && pattern == other.pattern; } +bool LineDrawStyle::operator!=(const LineDrawStyle &other) const +{ + return !(*this == other); +} + void StatisticsType::setInitialState() { this->init.render = this->render; @@ -190,7 +195,7 @@ void StatisticsType::loadPlaylist(const YUViewDomElement &root) name == "colorMapperType") { if (!this->valueDataOptions) - this->valueDataOptions.emplace(); + this->valueDataOptions = ValueDataOptions(); if (name == "renderValueData") this->valueDataOptions->render = (value != "0"); @@ -204,7 +209,7 @@ void StatisticsType::loadPlaylist(const YUViewDomElement &root) name == "mapVectorToColor" || name == "renderarrowHead") { if (!this->vectorDataOptions) - this->vectorDataOptions.emplace(); + this->vectorDataOptions = VectorDataOptions(); if (name == "renderVectorData") this->vectorDataOptions->render = (value != "0"); diff --git a/YUViewLib/src/statistics/StatisticsType.h b/YUViewLib/src/statistics/StatisticsType.h index 2825e001e..3ec5cbf1a 100644 --- a/YUViewLib/src/statistics/StatisticsType.h +++ b/YUViewLib/src/statistics/StatisticsType.h @@ -59,6 +59,7 @@ struct LineDrawStyle Pattern pattern{Pattern::Solid}; bool operator==(const LineDrawStyle &other) const; + bool operator!=(const LineDrawStyle &other) const; }; /* This class defines a type of statistic to render. Each statistics type entry defines the name and