Skip to content

Commit e0a208c

Browse files
committed
clangTidy+op++ -> orientation
1 parent b3a728d commit e0a208c

File tree

13 files changed

+44
-35
lines changed

13 files changed

+44
-35
lines changed

src/base/refl/auto_enum.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ template <class E> consteval auto enum_values()
202202
constexpr auto n = std::size(enum_names<E>);
203203
std::array<E, n> res{};
204204
for (std::size_t i = 0; i < n; ++i)
205+
// NOLINTNEXTLINE(clang-analyzer-optin.core.EnumCastOutOfRange)
205206
res[i] = static_cast<E>(i + first);
206207
return res;
207208
}

src/chart/generator/axis.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include <iterator>
88
#include <limits>
99
#include <optional>
10-
#include <set>
1110
#include <string>
1211
#include <string_view>
1312
#include <tuple>

src/chart/generator/marker.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "marker.h"
22

3+
#include <cmath>
34
#include <cstdint>
45
#include <optional>
56
#include <utility>
@@ -223,14 +224,14 @@ void Marker::fromRectangle(const Geom::Rect &rect)
223224

224225
Math::Range<> Marker::getSizeBy(AxisId axisId) const
225226
{
226-
return isHorizontal(++axisId) ? toRectangle().hSize()
227-
: toRectangle().vSize();
227+
return isHorizontal(orientation(axisId)) ? toRectangle().hSize()
228+
: toRectangle().vSize();
228229
}
229230

230231
void Marker::setSizeBy(AxisId axisId, const Math::Range<> range)
231232
{
232233
auto rect = toRectangle();
233-
if (isHorizontal(++axisId))
234+
if (isHorizontal(orientation(axisId)))
234235
rect.setHSize(range);
235236
else
236237
rect.setVSize(range);

src/chart/generator/plotbuilder.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "base/anim/interpolated.h"
1818
#include "base/math/floating.h"
1919
#include "base/math/range.h"
20+
#include "base/refl/auto_enum.h"
2021
#include "chart/main/style.h"
2122
#include "chart/options/align.h"
2223
#include "chart/options/channel.h"
@@ -228,7 +229,7 @@ bool PlotBuilder::linkMarkers(const Buckets &buckets,
228229
auto &marker = **it.base().base().base();
229230
if (!marker.enabled) continue;
230231
o = std::max(o,
231-
marker.size.getCoord(++axisIndex),
232+
marker.size.getCoord(orientation(axisIndex)),
232233
Math::Floating::less);
233234
}
234235
if (o == std::numeric_limits<double>::lowest()) o = 0.0;
@@ -274,7 +275,8 @@ bool PlotBuilder::linkMarkers(const Buckets &buckets,
274275
: *it.base().base().base();
275276

276277
if (act)
277-
prevPos = act->position.getCoord(++axisIndex) +=
278+
prevPos =
279+
act->position.getCoord(orientation(axisIndex)) +=
278280
isAggregatable ? dimOffset[i] : prevPos;
279281

280282
hasConnection |=

src/chart/options/channel.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#include "channel.h"
22

33
#include <cmath>
4-
#include <cstddef>
5-
#include <cstdint>
6-
#include <iterator>
74
#include <optional>
85
#include <stdexcept>
96
#include <string>

src/chart/options/channel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static_assert(std::ranges::all_of(Refl::enum_names<LegendId>,
6363
Refl::get_enum<ChannelId>(name));
6464
}));
6565

66-
[[nodiscard]] constexpr Geom::Orientation operator++(
66+
[[nodiscard]] constexpr Geom::Orientation orientation(
6767
const AxisId &axis)
6868
{
6969
return axis == AxisId::x ? Geom::Orientation::horizontal

src/chart/options/channelrange.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
#include "channelrange.h"
22

3-
#include <string>
4-
5-
#include "base/conv/parse.h"
6-
#include "base/conv/tostring.h"
73
#include "base/math/range.h"
8-
#include "base/text/valueunit.h"
94

105
namespace Vizzu::Gen
116
{

src/chart/rendering/drawaxes.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#include "drawaxes.h"
22

3+
#include <algorithm>
4+
#include <cmath>
35
#include <numbers>
6+
#include <ranges>
47
#include <string>
58
#include <utility>
69

@@ -12,8 +15,12 @@
1215
#include "base/geom/transformedrect.h"
1316
#include "base/gfx/colortransform.h"
1417
#include "base/gfx/font.h"
18+
#include "base/math/floating.h"
1519
#include "base/math/fuzzybool.h"
20+
#include "base/math/interpolation.h"
21+
#include "base/math/range.h"
1622
#include "base/math/renard.h"
23+
#include "base/refl/auto_enum.h"
1724
#include "base/type/booliter.h"
1825
#include "chart/generator/plot.h" // NOLINT(misc-include-cleaner)
1926
#include "chart/main/events.h"
@@ -145,7 +152,7 @@ void DrawAxes::generateMeasure(Gen::AxisId axisIndex,
145152
double stepSize,
146153
double weight)
147154
{
148-
auto orientation = !++axisIndex;
155+
auto orientation = !Gen::orientation(axisIndex);
149156
const auto &meas = getAxis(axisIndex).measure;
150157
auto rangeSize = meas.range.size();
151158
auto singleLabelRange = Math::Floating::is_zero(rangeSize);
@@ -213,9 +220,9 @@ void DrawAxes::generateMeasure(Gen::AxisId axisIndex,
213220

214221
Geom::Line DrawAxes::getAxisLine(Gen::AxisId axisIndex) const
215222
{
216-
auto offset = this->origo().getCoord(!++axisIndex);
223+
auto offset = this->origo().getCoord(!orientation(axisIndex));
217224

218-
auto direction = Geom::Point::Ident(++axisIndex);
225+
auto direction = Geom::Point::Ident(orientation(axisIndex));
219226

220227
auto p0 = direction.flip() * offset;
221228
auto p1 = p0 + direction;
@@ -267,7 +274,7 @@ Geom::Point DrawAxes::getTitleBasePos(Gen::AxisId axisIndex,
267274
case Pos::min_edge: break;
268275
case Pos::max_edge: orthogonal = 1.0; break;
269276
case Pos::axis:
270-
orthogonal = origo().getCoord(!++axisIndex);
277+
orthogonal = origo().getCoord(!orientation(axisIndex));
271278
break;
272279
}
273280

@@ -442,7 +449,7 @@ void DrawAxes::drawDimensionLabel(Gen::AxisId axisIndex,
442449
double weight) const
443450
{
444451
if (weight == 0) return;
445-
auto orientation = ++axisIndex;
452+
auto orientation = Gen::orientation(axisIndex);
446453

447454
const auto &labelStyle = rootStyle.plot.getAxis(axisIndex).label;
448455

src/chart/rendering/drawguides.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "drawguides.h"
22

3-
#include <iterator>
43
#include <utility>
54

65
#include "base/geom/line.h"
@@ -42,8 +41,8 @@ void DrawGuides::drawGuide(Gen::AxisId axisId,
4241
{
4342
auto eventTarget = Events::Targets::axisGuide(axisId);
4443

45-
auto ident = Geom::Point::Ident(++axisId);
46-
auto normal = Geom::Point::Ident(!++axisId);
44+
auto ident = Geom::Point::Ident(orientation(axisId));
45+
auto normal = Geom::Point::Ident(!orientation(axisId));
4746
auto relMax = ident * val;
4847

4948
parent.canvas.setLineColor(color);

src/chart/rendering/drawinterlacing.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
#include <algorithm>
44
#include <cmath>
55
#include <cstddef>
6-
#include <ranges>
6+
#include <iterator>
7+
#include <map>
78
#include <utility>
89

910
#include "base/anim/interpolated.h"
@@ -12,8 +13,8 @@
1213
#include "base/gfx/colortransform.h"
1314
#include "base/math/floating.h"
1415
#include "base/math/fuzzybool.h"
16+
#include "base/math/interpolation.h"
1517
#include "base/math/range.h"
16-
#include "base/math/renard.h"
1718
#include "base/text/smartstring.h"
1819
#include "base/type/booliter.h"
1920
#include "chart/generator/plot.h" // NOLINT(misc-include-cleaner)
@@ -65,7 +66,7 @@ void DrawInterlacing::drawGeometries(Gen::AxisId axisIndex) const
6566
othGuides.interlacings);
6667
}
6768

68-
auto orientation = !++axisIndex;
69+
auto orientation = !Gen::orientation(axisIndex);
6970

7071
parent.painter.setPolygonToCircleFactor(0);
7172
parent.painter.setPolygonStraightFactor(0);
@@ -143,7 +144,7 @@ void DrawInterlacing::drawGeometries(Gen::AxisId axisIndex) const
143144
void DrawInterlacing::drawTexts(Gen::AxisId axisIndex) const
144145
{
145146
const auto &axis = parent.getAxis(axisIndex).measure;
146-
auto orientation = !++axisIndex;
147+
auto orientation = !Gen::orientation(axisIndex);
147148
auto origo = parent.origo().getCoord(orientation);
148149
const auto &guides = parent.plot->guides.at(axisIndex);
149150
const auto &axisStyle = parent.rootStyle.plot.getAxis(axisIndex);
@@ -212,7 +213,7 @@ void DrawInterlacing::drawDataLabel(
212213
const ::Anim::String &unit,
213214
double alpha) const
214215
{
215-
auto orientation = !++axisIndex;
216+
auto orientation = !Gen::orientation(axisIndex);
216217
const auto &labelStyle =
217218
parent.rootStyle.plot.getAxis(axisIndex).label;
218219

@@ -283,12 +284,13 @@ void DrawInterlacing::drawSticks(double tickLength,
283284
canvas.setLineWidth(*tickStyle.lineWidth);
284285

285286
auto tickLine = tickStyle.position->combine(
286-
[tickLine =
287-
parent.coordSys
288-
.convertDirectionAt({tickPos,
289-
tickPos
290-
+ Geom::Point::Coord(!++axisIndex, -1.0)})
291-
.segment(0, tickLength)](const auto &position)
287+
[tickLine = parent.coordSys
288+
.convertDirectionAt({tickPos,
289+
tickPos
290+
+ Geom::Point::Coord(
291+
!orientation(axisIndex),
292+
-1.0)})
293+
.segment(0, tickLength)](const auto &position)
292294
{
293295
switch (position) {
294296
using enum Styles::Tick::Position;

0 commit comments

Comments
 (0)