From 3f0cfe0ef665b704e1bbff46c24effd52a2ed005 Mon Sep 17 00:00:00 2001 From: Bela Schaum Date: Fri, 6 Dec 2024 17:38:27 +0100 Subject: [PATCH] clang-tidy --- src/base/alg/union_foreach.h | 1 + src/chart/generator/plotbuilder.cpp | 25 ++++++++++++------------- src/chart/options/options.cpp | 3 +-- src/chart/rendering/drawaxes.cpp | 12 ++++++------ 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/base/alg/union_foreach.h b/src/base/alg/union_foreach.h index 375b9e036..dbb444e5c 100644 --- a/src/base/alg/union_foreach.h +++ b/src/base/alg/union_foreach.h @@ -1,6 +1,7 @@ #ifndef ALG_UNION_FOREACH_H #define ALG_UNION_FOREACH_H +#include #include #include "union_foreach.h" diff --git a/src/chart/generator/plotbuilder.cpp b/src/chart/generator/plotbuilder.cpp index 18e3dba2d..dec00919b 100644 --- a/src/chart/generator/plotbuilder.cpp +++ b/src/chart/generator/plotbuilder.cpp @@ -335,24 +335,23 @@ void PlotBuilder::calcAxises(const Data::DataTable &dataTable, auto mainBoundRect = plot->getMarkersBounds(mainAxis); auto subBoundRect = plot->getMarkersBounds(!mainAxis); - if (mainAxis != AxisId::x) std::swap(mainBoundRect, subBoundRect); - plot->getOptions()->setAutoRange(!std::signbit(mainBoundRect.min), - !std::signbit(subBoundRect.min)); - - if (mainAxis != AxisId::x) std::swap(mainBoundRect, subBoundRect); + plot->getOptions()->setAutoRange( + !std::signbit( + (mainAxis == AxisId::x ? mainBoundRect : subBoundRect) + .min), + !std::signbit( + (mainAxis == AxisId::x ? subBoundRect : mainBoundRect) + .min)); mainBoundRect = - plot->getOptions()->getChannels().at(mainAxis).range.getRange( - mainBoundRect); - subBoundRect = plot->getOptions() - ->getChannels() - .at(!mainAxis) - .range.getRange(subBoundRect); + plot->getOptions()->mainAxis().range.getRange(mainBoundRect); + subBoundRect = + plot->getOptions()->subAxis().range.getRange(subBoundRect); for (auto &&[axis, ranges, boundSize] : - {std::tuple{mainAxis, &mainRanges, std::move(mainBoundRect)}, - {!mainAxis, &subRanges, std::move(subBoundRect)}}) { + {std::tuple{mainAxis, &mainRanges, mainBoundRect}, + {!mainAxis, &subRanges, subBoundRect}}) { for (auto &marker : plot->markers) { auto &&markerSize = marker.getSizeBy(axis); if (!boundSize.positive().intersects( diff --git a/src/chart/options/options.cpp b/src/chart/options/options.cpp index ba5c5cdd1..e1954ca8f 100644 --- a/src/chart/options/options.cpp +++ b/src/chart/options/options.cpp @@ -220,8 +220,7 @@ AxisId Options::getHorizontalChannel() const AxisId Options::getVerticalChannel() const { - return getHorizontalChannel() == AxisId::x ? AxisId::y - : AxisId::x; + return !getHorizontalChannel(); } bool Options::isShapeValid(const ShapeType &shapeType) const diff --git a/src/chart/rendering/drawaxes.cpp b/src/chart/rendering/drawaxes.cpp index f1e16b55f..69e930217 100644 --- a/src/chart/rendering/drawaxes.cpp +++ b/src/chart/rendering/drawaxes.cpp @@ -39,14 +39,14 @@ namespace Vizzu::Draw void DrawAxes::drawGeometries() const { - for (auto &xSplit : std::views::values(splits[Gen::AxisId::x])) - for (auto &ySplit : + for (auto &&xSplit : std::views::values(splits[Gen::AxisId::x])) + for (auto &&ySplit : std::views::values(splits[Gen::AxisId::y])) { - double weight = + auto weight = Math::FuzzyBool::And(xSplit.weight, ySplit.weight); if (Math::Floating::is_zero(weight)) continue; - Geom::AffineTransform tr{xSplit.range.size(), + const Geom::AffineTransform tr{xSplit.range.size(), 0.0, xSplit.range.min, 0.0, @@ -70,8 +70,8 @@ void DrawAxes::drawGeometries() const void DrawAxes::drawLabels() const { - for (auto &xSplit : std::views::values(splits[Gen::AxisId::x])) - for (auto &ySplit : + for (auto &&xSplit : std::views::values(splits[Gen::AxisId::x])) + for (auto &&ySplit : std::views::values(splits[Gen::AxisId::y])) { double weight = Math::FuzzyBool::And(xSplit.weight, ySplit.weight);