Skip to content

Commit

Permalink
Add missing operators. Emplace on optional does not want to work in GCC.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianFeldmann committed Jan 20, 2025
1 parent abcff36 commit 7d937fa
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
8 changes: 6 additions & 2 deletions YUViewLib/src/statistics/ColorMapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions YUViewLib/src/statistics/ColorMapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
15 changes: 10 additions & 5 deletions YUViewLib/src/statistics/StatisticsType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ LineDrawStyle convertStringToPen(const QString &str)
return style;
}

void addModifiedValuesToElement(YUViewDomElement &element,
void addModifiedValuesToElement(YUViewDomElement & element,
const std::optional<StatisticsType::ValueDataOptions> &options,
const std::optional<StatisticsType::ValueDataOptions> &initOptions)
{
Expand All @@ -86,7 +86,7 @@ std::vector<StatisticsType::ArrowHead> AllArrowHeads = {StatisticsType::ArrowHea
StatisticsType::ArrowHead::circle,
StatisticsType::ArrowHead::none};

void addModifiedValuesToElement(YUViewDomElement &element,
void addModifiedValuesToElement(YUViewDomElement & element,
const std::optional<StatisticsType::VectorDataOptions> &options,
const std::optional<StatisticsType::VectorDataOptions> &initOptions)
{
Expand All @@ -112,7 +112,7 @@ void addModifiedValuesToElement(YUViewDomElement
}
}

void addModifiedValuesToElement(YUViewDomElement &element,
void addModifiedValuesToElement(YUViewDomElement & element,
const StatisticsType::GridOptions &options,
const StatisticsType::GridOptions &initOptions)
{
Expand All @@ -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;
Expand Down Expand Up @@ -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");
Expand All @@ -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");
Expand Down
1 change: 1 addition & 0 deletions YUViewLib/src/statistics/StatisticsType.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7d937fa

Please sign in to comment.