Skip to content

Commit 71a61fb

Browse files
committed
fix clang-tidy + review fix
1 parent 70b381c commit 71a61fb

File tree

12 files changed

+47
-44
lines changed

12 files changed

+47
-44
lines changed

src/base/type/physicalvalue.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ template <typename Value, Refl::is_enum Unit> struct PhysicalValue
1717
constexpr bool operator==(const PhysicalValue &) const = default;
1818

1919
template <std::same_as<double> = Value>
20-
static PhysicalValue fromString(const std::string &str)
20+
[[nodiscard]] static PhysicalValue fromString(
21+
const std::string &str)
2122
{
2223
const Text::ValueUnit vu{str};
2324
return {vu.getValue(), Refl::get_enum<Unit>(vu.getUnit())};
2425
}
2526

26-
std::string toString() const
27+
[[nodiscard]] std::string toString() const
2728
{
2829
return Conv::toString(value)
2930
+ std::string{Conv::toString(unit)};

src/chart/generator/axis.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct ChannelStats
2929
template <ChannelIdLike T>
3030
[[nodiscard]] const TrackType &at(const T &id) const
3131
{
32-
return tracked[-id];
32+
return tracked[+id];
3333
}
3434

3535
void track(ChannelId at, const Data::MarkerId &id)
@@ -47,7 +47,7 @@ struct ChannelStats
4747
template <ChannelIdLike Id>
4848
void setIfRange(Id at, const Math::Range<> &range)
4949
{
50-
if (auto *r = std::get_if<0>(&tracked[-at])) *r = range;
50+
if (auto *r = std::get_if<0>(&tracked[+at])) *r = range;
5151
}
5252
};
5353

src/chart/generator/marker.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ Marker::Marker(const Options &options,
3131
bool needMarkerInfo) :
3232
cellInfo(data.cellInfo(index, needMarkerInfo)),
3333
mainId(data.getId(mainAxisList,
34-
options.dimLabelIndex(-options.mainAxisType()),
34+
options.dimLabelIndex(+options.mainAxisType()),
3535
index)),
3636
subId(data.getId(subAxisList,
37-
options.dimLabelIndex(-options.subAxisType()),
37+
options.dimLabelIndex(+options.subAxisType()),
3838
index)),
3939
sizeId(data.getId(
4040
options.getChannels().at(ChannelId::size).dimensions(),
@@ -76,7 +76,7 @@ Marker::Marker(const Options &options,
7676
if (subAxisList != options.subAxis().dimensions())
7777
subId.label =
7878
data.getId(options.subAxis().dimensions(),
79-
options.dimLabelIndex(-options.subAxisType()),
79+
options.dimLabelIndex(+options.subAxisType()),
8080
index)
8181
.label;
8282

@@ -223,14 +223,14 @@ void Marker::fromRectangle(const Geom::Rect &rect)
223223

224224
Math::Range<> Marker::getSizeBy(AxisId axisId) const
225225
{
226-
return isHorizontal(+axisId) ? toRectangle().hSize()
227-
: toRectangle().vSize();
226+
return isHorizontal(++axisId) ? toRectangle().hSize()
227+
: toRectangle().vSize();
228228
}
229229

230230
void Marker::setSizeBy(AxisId axisId, const Math::Range<> range)
231231
{
232232
auto rect = toRectangle();
233-
if (isHorizontal(+axisId))
233+
if (isHorizontal(++axisId))
234234
rect.setHSize(range);
235235
else
236236
rect.setVSize(range);

src/chart/generator/plotbuilder.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ bool PlotBuilder::linkMarkers(const Buckets &buckets,
206206
std::numeric_limits<double>::lowest());
207207

208208
auto isAggregatable =
209-
!plot->getOptions()->isMeasure(-axisIndex)
210-
|| (isMain && plot->getOptions()->isMeasure(-!axisIndex)
209+
!plot->getOptions()->isMeasure(+axisIndex)
210+
|| (isMain && plot->getOptions()->isMeasure(+!axisIndex)
211211
&& plot->getOptions()->geometry.get()
212212
== ShapeType::rectangle);
213213

@@ -228,7 +228,7 @@ bool PlotBuilder::linkMarkers(const Buckets &buckets,
228228
auto &marker = **it.base().base().base();
229229
if (!marker.enabled) continue;
230230
o = std::max(o,
231-
marker.size.getCoord(+axisIndex),
231+
marker.size.getCoord(++axisIndex),
232232
Math::Floating::less);
233233
}
234234
if (o == std::numeric_limits<double>::lowest()) o = 0.0;
@@ -274,7 +274,7 @@ bool PlotBuilder::linkMarkers(const Buckets &buckets,
274274
: *it.base().base().base();
275275

276276
if (act)
277-
prevPos = act->position.getCoord(+axisIndex) +=
277+
prevPos = act->position.getCoord(++axisIndex) +=
278278
isAggregatable ? dimOffset[i] : prevPos;
279279

280280
hasConnection |=
@@ -350,7 +350,7 @@ void PlotBuilder::calcLegendAndLabel(const Data::DataTable &dataTable)
350350
if (scale.title) calcLegend.title = *scale.title;
351351

352352
if (auto &&meas = scale.measure()) {
353-
if (plot->getOptions()->isMeasure(-type)) {
353+
if (plot->getOptions()->isMeasure(+type)) {
354354
if (isAutoTitle)
355355
calcLegend.title = dataCube.getName(*meas);
356356
calcLegend.measure = {std::get<0>(stats.at(type)),
@@ -364,7 +364,7 @@ void PlotBuilder::calcLegendAndLabel(const Data::DataTable &dataTable)
364364
auto merge =
365365
type == LegendId::size
366366
|| (type == LegendId::lightness
367-
&& plot->getOptions()->dimLabelIndex(-type) == 0);
367+
&& plot->getOptions()->dimLabelIndex(+type) == 0);
368368
for (std::uint32_t i{}, count{}; i < indices.size(); ++i)
369369
if (const auto &sliceIndex = indices[i]) {
370370
auto rangeId = static_cast<double>(i);
@@ -412,7 +412,7 @@ void PlotBuilder::calcAxis(const Data::DataTable &dataTable,
412412
auto isAutoTitle = scale.title.isAuto();
413413
if (scale.title) axis.title = *scale.title;
414414

415-
if (plot->getOptions()->isMeasure(-type)) {
415+
if (plot->getOptions()->isMeasure(+type)) {
416416
const auto &meas = *scale.measure();
417417
if (isAutoTitle) axis.title = dataCube.getName(meas);
418418

@@ -431,7 +431,7 @@ void PlotBuilder::calcAxis(const Data::DataTable &dataTable,
431431
}
432432
else {
433433
for (auto merge =
434-
plot->getOptions()->dimLabelIndex(-type) == 0
434+
plot->getOptions()->dimLabelIndex(+type) == 0
435435
&& (type != plot->getOptions()->mainAxisType()
436436
|| plot->getOptions()->sort != Sort::byValue
437437
|| scale.dimensions().size() == 1);

src/chart/main/stylesheet.cpp

Lines changed: 5 additions & 5 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->getVerticalChannel())) {
9696
defaultParams.plot.paddingLeft =
9797
Gfx::Length::Emphemeral(80.0 / 12.0);
9898
}
@@ -146,18 +146,18 @@ void Sheet::setMarkers()
146146
else {
147147
auto sizeMeasure = options->isMeasure(Gen::ChannelId::size);
148148
auto mainMeasure =
149-
options->isMeasure(-options->mainAxisType());
150-
auto subMeasure = options->isMeasure(-options->subAxisType());
149+
options->isMeasure(+options->mainAxisType());
150+
auto subMeasure = options->isMeasure(+options->subAxisType());
151151
if (options->geometry == Gen::ShapeType::circle && sizeMeasure
152152
&& (mainMeasure || subMeasure)) {
153153
defaultParams.plot.marker.borderWidth = 1;
154154
defaultParams.plot.marker.fillOpacity = 0.8;
155155
}
156156
else if (options->geometry == Gen::ShapeType::rectangle) {
157157
auto vIsMeasure =
158-
options->isMeasure(-options->getVerticalChannel());
158+
options->isMeasure(+options->getVerticalChannel());
159159
auto hIsMeasure =
160-
options->isMeasure(-options->getHorizontalChannel());
160+
options->isMeasure(+options->getHorizontalChannel());
161161
if (auto polar = options->coordSystem.get()
162162
== Gen::CoordSystem::polar;
163163
polar && options->getVerticalAxis().isEmpty())

src/chart/options/channel.h

Lines changed: 5 additions & 5 deletions
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 operator++(
6767
const AxisId &axis)
6868
{
6969
return axis == AxisId::x ? Geom::Orientation::horizontal
@@ -170,28 +170,28 @@ class Channel
170170
Base::AutoParam<double> step{};
171171
};
172172

173-
[[nodiscard]] constexpr ChannelId operator-(const AxisId &axis)
173+
[[nodiscard]] constexpr ChannelId operator+(const AxisId &axis)
174174
{
175175
return static_cast<ChannelId>(axis);
176176
}
177177

178-
[[nodiscard]] constexpr ChannelId operator-(const LegendId &legend)
178+
[[nodiscard]] constexpr ChannelId operator+(const LegendId &legend)
179179
{
180180
return static_cast<ChannelId>(legend);
181181
}
182182

183183
template <class T>
184184
concept ChannelIdLike = requires(const T &v) {
185185
{
186-
-v
186+
+v
187187
} -> std::same_as<ChannelId>;
188188
};
189189

190190
template <ChannelIdLike T>
191191
[[nodiscard]] constexpr bool operator==(const T &l,
192192
const ChannelId &c)
193193
{
194-
return -l == c;
194+
return +l == c;
195195
}
196196

197197
template <ChannelIdLike T, ChannelIdLike U>

src/chart/options/channels.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ struct Channels : Refl::EnumArray<ChannelId, Channel>
2929
template <ChannelIdLike T>
3030
[[nodiscard]] const Channel &at(const T &id) const
3131
{
32-
return at(-id);
32+
return at(+id);
3333
}
3434

3535
template <ChannelIdLike T> [[nodiscard]] Channel &at(const T &id)
3636
{
37-
return at(-id);
37+
return at(+id);
3838
}
3939

4040
void removeSeries(const Data::SeriesIndex &index);

src/chart/options/options.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ ChannelId Options::stackChannelType() const
7474
if (channels.anyAxisSet()) {
7575
switch (geometry.get()) {
7676
case ShapeType::area:
77-
case ShapeType::rectangle: return -subAxisType();
77+
case ShapeType::rectangle: return +subAxisType();
7878
default:
7979
case ShapeType::circle:
8080
case ShapeType::line: return ChannelId::size;
@@ -86,7 +86,7 @@ ChannelId Options::stackChannelType() const
8686
std::optional<ChannelId> Options::secondaryStackType() const
8787
{
8888
if (channels.anyAxisSet() && geometry == ShapeType::line)
89-
return -subAxisType();
89+
return +subAxisType();
9090

9191
return std::nullopt;
9292
}

src/chart/options/options.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class Options : public OptionProperties
121121
IdType channel) const
122122
{
123123
auto &&ch = channels.at(channel);
124-
if (auto dimIndex = dimLabelIndex(-channel))
124+
if (auto dimIndex = dimLabelIndex(+channel))
125125
return *std::next(ch.set.dimensionIds.begin(),
126126
static_cast<std::intptr_t>(*dimIndex));
127127
return ch.labelLevel.getValue(0) == 0 ? ch.measure()

src/chart/rendering/drawaxes.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ void DrawAxes::generateMeasure(Gen::AxisId axisIndex,
145145
double stepSize,
146146
double weight)
147147
{
148-
auto orientation = !+axisIndex;
148+
auto orientation = ++!axisIndex;
149149
const auto &meas = getAxis(axisIndex).measure;
150150
auto rangeSize = meas.range.size();
151151
auto singleLabelRange = Math::Floating::is_zero(rangeSize);
@@ -213,9 +213,9 @@ void DrawAxes::generateMeasure(Gen::AxisId axisIndex,
213213

214214
Geom::Line DrawAxes::getAxisLine(Gen::AxisId axisIndex) const
215215
{
216-
auto offset = this->origo().getCoord(+!axisIndex);
216+
auto offset = this->origo().getCoord(++!axisIndex);
217217

218-
auto direction = Geom::Point::Ident(+axisIndex);
218+
auto direction = Geom::Point::Ident(++axisIndex);
219219

220220
auto p0 = direction.flip() * offset;
221221
auto p1 = p0 + direction;
@@ -266,7 +266,9 @@ Geom::Point DrawAxes::getTitleBasePos(Gen::AxisId axisIndex,
266266
default:
267267
case Pos::min_edge: break;
268268
case Pos::max_edge: orthogonal = 1.0; break;
269-
case Pos::axis: orthogonal = origo().getCoord(+!axisIndex); break;
269+
case Pos::axis:
270+
orthogonal = origo().getCoord(++!axisIndex);
271+
break;
270272
}
271273

272274
double parallel{0.0};
@@ -440,7 +442,7 @@ void DrawAxes::drawDimensionLabel(Gen::AxisId axisIndex,
440442
double weight) const
441443
{
442444
if (weight == 0) return;
443-
auto orientation = +axisIndex;
445+
auto orientation = ++axisIndex;
444446

445447
const auto &labelStyle = rootStyle.plot.getAxis(axisIndex).label;
446448

0 commit comments

Comments
 (0)