Skip to content

Commit b52a9c3

Browse files
committed
some clang-tidy + first try to purge horizontalAxis/verticalAxis
1 parent fbf039a commit b52a9c3

File tree

15 files changed

+41
-55
lines changed

15 files changed

+41
-55
lines changed

src/base/alg/union_foreach.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#ifndef ALG_UNION_FOREACH_H
22
#define ALG_UNION_FOREACH_H
33

4+
#include <cstdint>
45
#include <functional>
56
#include <ranges>
67

7-
#include "union_foreach.h"
8-
98
namespace Alg
109
{
1110

@@ -192,8 +191,8 @@ template <std::ranges::forward_range R,
192191
std::ranges::less,
193192
Impl::address_binary_invocable<std::ranges::iterator_t<R>> Fun,
194193
Impl::Property Prop = Impl::default_property_t<R>>
195-
constexpr void union_foreach(R &&r1,
196-
R &&r2,
194+
constexpr void union_foreach(const R &r1,
195+
const R &r2,
197196
Fun f,
198197
Comp comp = {},
199198
Proj proj = {},

src/base/geom/point.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,9 @@ struct Point
236236

237237
struct Size : Point
238238
{
239-
[[nodiscard]] static Size
240-
Coord(Orientation orientation, double value, double other = 0.0)
239+
[[nodiscard]] static Size Oriented(Orientation orientation,
240+
double value,
241+
double other = 0.0)
241242
{
242243
return {Point::Coord(orientation, value, other)};
243244
}

src/base/geom/rect.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include <algorithm>
44
#include <array>
55
#include <cmath>
6-
#include <compare>
76

87
#include "base/math/floating.h"
98

src/chart/generator/axis.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include <cmath>
55
#include <cstdint>
66
#include <functional>
7-
#include <iterator>
87
#include <limits>
98
#include <optional>
109
#include <string>

src/chart/generator/marker.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
#include <utility>
77

88
#include "base/conv/auto_json.h"
9-
#include "base/geom/orientation.h"
109
#include "base/geom/point.h"
11-
#include "base/geom/rect.h"
1210
#include "base/math/range.h"
1311
#include "base/refl/auto_enum.h"
1412
#include "chart/options/align.h"

src/chart/generator/plot.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
#include <vector>
1010

1111
#include "base/anim/interpolated.h"
12+
#include "base/math/range.h"
1213
#include "chart/main/style.h"
14+
#include "chart/options/channel.h"
1315
#include "chart/options/options.h"
1416

1517
#include "marker.h"

src/chart/generator/plotbuilder.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
#include <cmath>
55
#include <cstddef>
66
#include <cstdint>
7+
#include <functional>
78
#include <limits>
8-
#include <map>
99
#include <memory>
1010
#include <optional>
1111
#include <ranges>
12+
#include <set>
1213
#include <stdexcept>
1314
#include <tuple>
1415
#include <utility>

src/chart/main/style.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,11 @@ struct Plot : Padding, Box, PlotParams
368368
{
369369
return id == Gen::AxisId::x ? xAxis : yAxis;
370370
}
371+
372+
[[nodiscard]] Axis &getAxis(Gen::AxisId id)
373+
{
374+
return id == Gen::AxisId::x ? xAxis : yAxis;
375+
}
371376
};
372377

373378
struct LogoParams

src/chart/main/stylesheet.cpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ void Sheet::setPlot()
9292
defaultParams.plot.paddingLeft =
9393
Gfx::Length::Emphemeral(45.0 / 12.0);
9494
}
95-
else if (!options->isMeasure(+options->getVerticalChannel())) {
95+
else if (!options->isMeasure(+!options->getHorizontalChannel())) {
9696
defaultParams.plot.paddingLeft =
9797
Gfx::Length::Emphemeral(80.0 / 12.0);
9898
}
@@ -115,11 +115,10 @@ void Sheet::setAxisLabels()
115115
def.position = AxisLabel::Position::max_edge;
116116
def.side = AxisLabel::Side::positive;
117117
}
118-
else if (!options->isMeasure(Gen::ChannelId::x)
118+
else if (!options->isMeasure(+options->getHorizontalChannel())
119119
&& options->getChannels()
120-
.at(Gen::AxisId::x)
121-
.hasDimension()
122-
&& options->angle == 0)
120+
.at(+options->getHorizontalChannel())
121+
.hasDimension())
123122
def.angle.reset();
124123
}
125124

@@ -154,13 +153,14 @@ void Sheet::setMarkers()
154153
defaultParams.plot.marker.fillOpacity = 0.8;
155154
}
156155
else if (options->geometry == Gen::ShapeType::rectangle) {
157-
auto vIsMeasure =
158-
options->isMeasure(+options->getVerticalChannel());
159-
auto hIsMeasure =
160-
options->isMeasure(+options->getHorizontalChannel());
156+
auto vIsMeasure = options->isMeasure(Gen::ChannelId::y);
157+
auto hIsMeasure = options->isMeasure(Gen::ChannelId::x);
161158
if (auto polar = options->coordSystem.get()
162159
== Gen::CoordSystem::polar;
163-
polar && options->getVerticalAxis().isEmpty())
160+
polar
161+
&& options->getChannels()
162+
.at(Gen::ChannelId::y)
163+
.isEmpty())
164164
defaultParams.plot.marker.rectangleSpacing = 0;
165165
else if (auto needRectangleSpacing =
166166
vIsMeasure != hIsMeasure
@@ -221,7 +221,11 @@ void Sheet::setAfterStyles(Gen::Plot &plot, const Geom::Size &size)
221221
auto &style = plot.getStyle();
222222
style.setup();
223223

224-
if (auto &xLabel = style.plot.xAxis.label; !xLabel.angle) {
224+
if (auto &xLabel =
225+
style.plot
226+
.getAxis(plot.getOptions()->getHorizontalChannel())
227+
.label;
228+
!xLabel.angle) {
225229
auto plotX = size.x;
226230

227231
auto em = style.calculatedSize();

src/chart/options/options.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "base/geom/orientation.h"
1010
#include "base/math/trig.h"
11+
#include "base/refl/auto_enum.h"
1112
#include "dataframe/old/types.h"
1213

1314
#include "channel.h"
@@ -218,11 +219,6 @@ AxisId Options::getHorizontalChannel() const
218219
return Math::rad2quadrant(angle) % 2 == 0 ? AxisId::x : AxisId::y;
219220
}
220221

221-
AxisId Options::getVerticalChannel() const
222-
{
223-
return !getHorizontalChannel();
224-
}
225-
226222
bool Options::isShapeValid(const ShapeType &shapeType) const
227223
{
228224
if (mainAxis().hasDimension()) return true;
@@ -299,10 +295,10 @@ std::optional<LegendId> Options::getAutoLegend() const
299295

300296
void Options::setAutoRange(bool hPositive, bool vPositive)
301297
{
302-
auto &v = getVerticalAxis();
303-
auto &h = getHorizontalAxis();
304-
auto vHasMeasure = getVerticalAxis().hasMeasure();
305-
auto hHasMeasure = getHorizontalAxis().hasMeasure();
298+
auto &v = getChannels().at(AxisId::y);
299+
auto &h = getChannels().at(AxisId::x);
300+
auto vHasMeasure = v.hasMeasure();
301+
auto hHasMeasure = h.hasMeasure();
306302
auto &&cart = coordSystem.get() == CoordSystem::cartesian;
307303
auto &&nrect = geometry != ShapeType::rectangle;
308304

0 commit comments

Comments
 (0)