From 1c6a6635786ad14428b8fe02fd371654b7902e13 Mon Sep 17 00:00:00 2001 From: Bela Schaum Date: Wed, 31 Jul 2024 20:32:19 +0200 Subject: [PATCH 01/10] fix clang-tidy(-18) issues --- src/.clang-tidy | 1 - src/base/conv/auto_json.h | 8 ++++---- src/base/conv/numtostr.cpp | 1 + src/base/gfx/colorgradient.cpp | 2 ++ src/base/gfx/colortransform.cpp | 1 + src/base/refl/auto_enum.h | 1 + src/base/text/character.h | 1 + src/base/text/funcstring.cpp | 3 +++ src/base/text/smartstring.h | 4 ---- src/chart/generator/plotbuilder.cpp | 3 +-- src/chart/rendering/drawchart.cpp | 12 ++++++------ .../rendering/painter/coordinatesystem.cpp | 19 +++++++++++-------- .../rendering/painter/coordinatesystem.h | 11 ++++++++--- src/dataframe/impl/data_source.cpp | 2 +- src/dataframe/interface.h | 2 +- src/dataframe/old/datatable.cpp | 5 ++--- 16 files changed, 43 insertions(+), 33 deletions(-) diff --git a/src/.clang-tidy b/src/.clang-tidy index db56db7d9..71c6986ef 100644 --- a/src/.clang-tidy +++ b/src/.clang-tidy @@ -27,7 +27,6 @@ Checks: > -cppcoreguidelines-pro-type-vararg, -cppcoreguidelines-special-member-functions, fuchsia-statically-constructed-objects, - fuchsia-trailing-return, google-build-using-namespace, google-default-arguments, google-explicit-constructor, diff --git a/src/base/conv/auto_json.h b/src/base/conv/auto_json.h index 2c5d71b84..384b3b325 100644 --- a/src/base/conv/auto_json.h +++ b/src/base/conv/auto_json.h @@ -216,7 +216,7 @@ struct JSONAutoObj : JSON requires(JSONSerializable || Optional || StringConvertable || SerializableRange || Tuple) - inline void operator()(const T &val, + inline void add(const T &val, const std::initializer_list &il) { closeOpenObj(il); @@ -224,7 +224,7 @@ struct JSONAutoObj : JSON } template - inline void operator()(const T &val, + inline void add(const T &val, std::initializer_list &&il) = delete; const std::initializer_list *cp{}; @@ -238,9 +238,9 @@ template struct JSONNoBaseAutoObj : JSONAutoObj requires(!std::is_base_of_v) inline auto operator()(const T &val, const std::initializer_list &il) - -> decltype(std::declval()(val, il)) + -> decltype(add(val, il)) { - return static_cast(*this)(val, il); + return add(val, il); } }; diff --git a/src/base/conv/numtostr.cpp b/src/base/conv/numtostr.cpp index 50f6b926d..c681ff206 100644 --- a/src/base/conv/numtostr.cpp +++ b/src/base/conv/numtostr.cpp @@ -2,6 +2,7 @@ #include "numtostr.h" #include +#include #include #include diff --git a/src/base/gfx/colorgradient.cpp b/src/base/gfx/colorgradient.cpp index d359268a5..eb1790ee0 100644 --- a/src/base/gfx/colorgradient.cpp +++ b/src/base/gfx/colorgradient.cpp @@ -1,5 +1,7 @@ #include "colorgradient.h" +#include + #include "base/math/interpolation.h" #include "base/math/range.h" #include "base/math/segmentedfunc.tpp" diff --git a/src/base/gfx/colortransform.cpp b/src/base/gfx/colortransform.cpp index 48ee9d902..69a41ee60 100644 --- a/src/base/gfx/colortransform.cpp +++ b/src/base/gfx/colortransform.cpp @@ -1,6 +1,7 @@ #include "colortransform.h" +#include #include #include "base/text/funcstring.h" diff --git a/src/base/refl/auto_enum.h b/src/base/refl/auto_enum.h index 46e4442eb..3ab0167b4 100644 --- a/src/base/refl/auto_enum.h +++ b/src/base/refl/auto_enum.h @@ -2,6 +2,7 @@ #define VIZZU_REFL_AUTO_ENUM_H #include +#include #include #include #include diff --git a/src/base/text/character.h b/src/base/text/character.h index d116cafc5..31900dd02 100644 --- a/src/base/text/character.h +++ b/src/base/text/character.h @@ -1,6 +1,7 @@ #ifndef TEXT_CHARACTER #define TEXT_CHARACTER +#include #include namespace Text::Character diff --git a/src/base/text/funcstring.cpp b/src/base/text/funcstring.cpp index d3a529ad9..563e53e5c 100644 --- a/src/base/text/funcstring.cpp +++ b/src/base/text/funcstring.cpp @@ -1,5 +1,8 @@ #include "funcstring.h" +#include +#include + #include "smartstring.h" namespace Text diff --git a/src/base/text/smartstring.h b/src/base/text/smartstring.h index 72d6e6240..ac1fd9a11 100644 --- a/src/base/text/smartstring.h +++ b/src/base/text/smartstring.h @@ -1,10 +1,6 @@ #ifndef TEXT_SMARTSTRING #define TEXT_SMARTSTRING -#include -#include -#include -#include #include #include diff --git a/src/chart/generator/plotbuilder.cpp b/src/chart/generator/plotbuilder.cpp index fb86dff4f..44b373393 100644 --- a/src/chart/generator/plotbuilder.cpp +++ b/src/chart/generator/plotbuilder.cpp @@ -107,8 +107,7 @@ Buckets PlotBuilder::generateMarkers(std::size_t &mainBucketSize) Buckets buckets(plot->markers); auto &&hasMarkerConnection = linkMarkers(buckets.sort(&Marker::mainId), true); - [[maybe_unused]] auto &&_ = - linkMarkers(buckets.sort(&Marker::subId), false); + std::ignore = linkMarkers(buckets.sort(&Marker::subId), false); if (hasMarkerConnection && plot->getOptions()->geometry.get() == ShapeType::line diff --git a/src/chart/rendering/drawchart.cpp b/src/chart/rendering/drawchart.cpp index 0147a7b9b..5302005a5 100644 --- a/src/chart/rendering/drawchart.cpp +++ b/src/chart/rendering/drawchart.cpp @@ -107,23 +107,23 @@ void DrawChart::draw(Gfx::ICanvas &canvas, const Layout &layout) const drawHeading<&Events::Targets::chartTitle>(canvas, layout, - [](auto &obj) -> decltype((obj.title)) + [](auto &obj) -> auto & { - return (obj.title); + return obj.title; }); drawHeading<&Events::Targets::chartSubtitle>(canvas, layout, - [](auto &obj) -> decltype((obj.subtitle)) + [](auto &obj) -> auto & { - return (obj.subtitle); + return obj.subtitle; }); drawHeading<&Events::Targets::chartCaption>(canvas, layout, - [](auto &obj) -> decltype((obj.caption)) + [](auto &obj) -> auto & { - return (obj.caption); + return obj.caption; }); drawMarkerInfo(canvas, layout.boundary); diff --git a/src/chart/rendering/painter/coordinatesystem.cpp b/src/chart/rendering/painter/coordinatesystem.cpp index 47fb6391f..9904020de 100644 --- a/src/chart/rendering/painter/coordinatesystem.cpp +++ b/src/chart/rendering/painter/coordinatesystem.cpp @@ -98,7 +98,7 @@ CompoundTransform::CompoundTransform(const Geom::Rect &rect, double angle, const Anim::Interpolated &coordSystem, Math::FuzzyBool keepAspectRatio) : - PolarDescartesTransform(coordSystem), + polarDescartes(coordSystem), rect(rect), keepAspectRatio(keepAspectRatio) { @@ -107,19 +107,21 @@ CompoundTransform::CompoundTransform(const Geom::Rect &rect, void CompoundTransform::setAngle(double value) { - angle = value - static_cast(polar) * M_PI; + angle = + value - static_cast(polarDescartes.getPolar()) * M_PI; cosAngle = cos(angle); sinAngle = sin(angle); } double CompoundTransform::getAngle() const { - return angle + static_cast(polar) * M_PI; + return angle + + static_cast(polarDescartes.getPolar()) * M_PI; } Geom::Point CompoundTransform::convert(const Geom::Point &p) const { - auto transformed = PolarDescartesTransform::convert(p); + auto transformed = polarDescartes.convert(p); auto rotated = rotate(transformed); auto aligned = align(rotated); return rect.pos @@ -151,13 +153,13 @@ Geom::Line CompoundTransform::convertDirectionAt( double CompoundTransform::horConvert(double length) const { return (rotatedSize() * alignedSize()).x - * PolarDescartesTransform::horConvert(length); + * polarDescartes.horConvert(length); } double CompoundTransform::verConvert(double length) const { return (rotatedSize() * alignedSize()).y - * PolarDescartesTransform::verConvert(length); + * polarDescartes.verConvert(length); } Geom::Point CompoundTransform::getOriginal(const Geom::Point &p) const @@ -166,7 +168,7 @@ Geom::Point CompoundTransform::getOriginal(const Geom::Point &p) const relative = Geom::Point{relative.x, 1.0 - relative.y}; relative = deAlign(relative); auto rotated = rotate(relative, true); - return PolarDescartesTransform::getOriginal(rotated); + return polarDescartes.getOriginal(rotated); } Geom::Rect CompoundTransform::getRect() const { return rect; } @@ -207,7 +209,8 @@ Geom::Size CompoundTransform::alignedSize() const auto minAspectRatio = std::min(aspectRatio, 1.0); - auto factor = static_cast(polar || keepAspectRatio); + auto factor = static_cast( + polarDescartes.getPolar() || keepAspectRatio); auto aspectRatioVer = Math::interpolate(1.0, minAspectRatio, factor); diff --git a/src/chart/rendering/painter/coordinatesystem.h b/src/chart/rendering/painter/coordinatesystem.h index e767c04fd..8749fbec7 100644 --- a/src/chart/rendering/painter/coordinatesystem.h +++ b/src/chart/rendering/painter/coordinatesystem.h @@ -20,6 +20,11 @@ class PolarDescartesTransform [[nodiscard]] double verConvert(double length) const; [[nodiscard]] Geom::Point getOriginal(const Geom::Point &p) const; + [[nodiscard]] const Math::FuzzyBool &getPolar() const + { + return polar; + } + protected: bool zoomOut{}; Math::FuzzyBool polar; @@ -27,15 +32,14 @@ class PolarDescartesTransform [[nodiscard]] Geom::Size mappedSize() const; }; -class CompoundTransform : public PolarDescartesTransform +class CompoundTransform { public: CompoundTransform() = default; explicit CompoundTransform(const Geom::Rect &rect, double angle = 0.0, const ::Anim::Interpolated &coordSystem = - ::Anim::Interpolated{ - Gen::CoordSystem::cartesian}, + ::Anim::Interpolated{Gen::CoordSystem::cartesian}, Math::FuzzyBool keepAspectRatio = {}); [[nodiscard]] Geom::Point convert(const Geom::Point &p) const; [[nodiscard]] double horConvert(double length) const; @@ -47,6 +51,7 @@ class CompoundTransform : public PolarDescartesTransform [[nodiscard]] double getAngle() const; private: + PolarDescartesTransform polarDescartes; Geom::Rect rect; double angle{}; Math::FuzzyBool keepAspectRatio; diff --git a/src/dataframe/impl/data_source.cpp b/src/dataframe/impl/data_source.cpp index daa43206b..c506b84bf 100644 --- a/src/dataframe/impl/data_source.cpp +++ b/src/dataframe/impl/data_source.cpp @@ -573,7 +573,7 @@ void error(error_type err_t, std::string_view arg) auto &&[data, size] = Refl::enum_name>(err_t); std::array arr{}; - [[maybe_unused]] auto &&_ = std::snprintf(arr.data(), + std::ignore = std::snprintf(arr.data(), arr.size(), "dataframe error: %.*s: %.*s", size, diff --git a/src/dataframe/interface.h b/src/dataframe/interface.h index 629475447..591ad4fcc 100644 --- a/src/dataframe/interface.h +++ b/src/dataframe/interface.h @@ -96,7 +96,7 @@ class alignas(align_impl) dataframe_interface void aggregate_by(const std::string_view &series) { - [[maybe_unused]] auto &&_ = set_aggregate(series, {}); + std::ignore = set_aggregate(series, {}); } void set_sort(const std::string_view &series, diff --git a/src/dataframe/old/datatable.cpp b/src/dataframe/old/datatable.cpp index c414f6cbd..a1603074a 100644 --- a/src/dataframe/old/datatable.cpp +++ b/src/dataframe/old/datatable.cpp @@ -194,9 +194,8 @@ DataCube::DataCube(const DataTable &table, else ++first; - [[maybe_unused]] auto &&new_name = - sub_df.set_aggregate(meas->getColIndex(), - meas->getAggr()); + std::ignore = sub_df.set_aggregate(meas->getColIndex(), + meas->getAggr()); sub_df.finalize(); } From daab53b5eb35c9eea86ad0aefbea1508e6e80811 Mon Sep 17 00:00:00 2001 From: Bela Schaum Date: Thu, 1 Aug 2024 08:38:32 +0200 Subject: [PATCH 02/10] remove c++20 flags --- project/cmake/common.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/project/cmake/common.txt b/project/cmake/common.txt index 92b7e7801..4c0412798 100644 --- a/project/cmake/common.txt +++ b/project/cmake/common.txt @@ -3,6 +3,7 @@ set(sourceDir ${root}/src) set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) if (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "") set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE) @@ -63,11 +64,11 @@ if (cpplint) endif() if (WIN32) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++20 /Zi /GR-") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zi /GR-") add_definitions(-D_USE_MATH_DEFINES) set(CMAKE_SHARED_LINKER_FLAGS "/INCREMENTAL:NO /Debug") else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20 \ + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \ -Wpedantic \ -Wall \ -Wextra \ From b8d760b8194d964c20a637f4cdcccd044b49c951 Mon Sep 17 00:00:00 2001 From: Bela Schaum Date: Thu, 1 Aug 2024 18:04:14 +0200 Subject: [PATCH 03/10] Clang-tidy fixes: - Replace CHAR_BITS and M_PI to C++ replacements - Remove void function returns - move rvalue references / prefect forward universal references - move type_traits to C++17 '_v' suffixes - include all includes to c++ - Remove nested ? : ternary operators - Remove implicit inlines - Make all enum base to uint8_t - Remove some unnecessary namespace prefix - Change enable_if to requires - std::ignore some argument - header guard to canvas.h --- src/.clang-tidy | 11 ++- src/apps/weblib/cinterface.cpp | 86 ++++++++++--------- src/apps/weblib/interface.cpp | 38 +++++--- src/apps/weblib/jscriptcanvas.cpp | 26 ++++-- src/base/anim/control.cpp | 4 + src/base/anim/control.h | 5 +- src/base/anim/duration.cpp | 13 ++- src/base/anim/easing.cpp | 5 +- src/base/anim/easingfunc.h | 15 ++-- src/base/anim/easinggradient.cpp | 7 +- src/base/anim/group.cpp | 10 ++- src/base/anim/interpolated.h | 8 +- src/base/anim/sequence.cpp | 5 ++ src/base/app/version.cpp | 2 + src/base/conv/auto_json.h | 73 ++++++++-------- src/base/conv/numtostr.cpp | 4 + src/base/conv/numtostr.h | 4 +- src/base/conv/parse.h | 4 +- src/base/geom/affinetransform.cpp | 8 +- src/base/geom/angle.cpp | 12 +-- src/base/geom/angle.h | 8 +- src/base/geom/circle.cpp | 35 +++++--- src/base/geom/circle.h | 6 +- src/base/geom/point.cpp | 8 +- src/base/geom/point.h | 7 +- src/base/geom/polygon.cpp | 8 +- src/base/geom/quadrilateral.cpp | 2 + src/base/geom/rect.cpp | 15 ++-- src/base/geom/triangle.cpp | 2 + src/base/gfx/color.cpp | 4 + src/base/gfx/colorgradient.cpp | 7 +- src/base/gfx/colorgradient.h | 11 ++- src/base/gfx/colorpalette.cpp | 15 ++-- src/base/gfx/colortransform.cpp | 3 + src/base/gfx/draw/infobubble.cpp | 8 +- src/base/gfx/draw/roundedrect.cpp | 4 + src/base/gfx/draw/textbox.cpp | 8 ++ src/base/gfx/font.cpp | 1 + src/base/gfx/font.h | 3 +- src/base/gfx/length.cpp | 1 + src/base/gfx/pathsampler.cpp | 3 + src/base/gui/pointer.h | 2 +- src/base/math/fuzzybool.h | 16 ++-- src/base/math/renard.cpp | 2 +- src/base/math/trig.cpp | 3 +- src/base/refl/auto_name.h | 3 +- src/base/refl/auto_struct.h | 55 ++++++------ src/base/style/impl.tpp | 8 +- src/base/style/paramregistry.h | 7 +- src/base/text/funcstring.cpp | 1 + src/base/text/naturalcmp.cpp | 3 +- src/base/text/numberscale.cpp | 4 + src/base/text/numberscale.h | 3 +- src/base/text/smartstring.cpp | 8 +- src/base/text/smartstring.h | 3 +- src/base/text/valueunit.cpp | 3 + src/base/type/physicalvalue.h | 2 +- src/base/type/uniquelist.h | 3 +- src/base/util/eventdispatcher.cpp | 7 +- src/chart/animator/animation.cpp | 36 +++++--- src/chart/animator/animator.cpp | 12 ++- src/chart/animator/keyframe.cpp | 9 +- src/chart/animator/morph.cpp | 10 +++ src/chart/animator/options.cpp | 6 ++ src/chart/animator/options.h | 10 ++- src/chart/animator/planner.cpp | 34 ++++++-- src/chart/animator/styles.cpp | 9 +- src/chart/generator/axis.cpp | 14 +++ src/chart/generator/axis.h | 9 +- src/chart/generator/buckets.cpp | 3 + src/chart/generator/guides.cpp | 9 ++ src/chart/generator/marker.cpp | 13 +++ src/chart/generator/plot.cpp | 19 ++-- src/chart/generator/plotbuilder.cpp | 55 +++++++++--- src/chart/main/chart.cpp | 14 ++- src/chart/main/events.cpp | 2 + src/chart/main/events.h | 4 +- src/chart/main/layout.cpp | 4 +- src/chart/main/style.cpp | 14 ++- src/chart/main/style.h | 47 ++++++---- src/chart/main/stylesheet.cpp | 17 +++- src/chart/main/version.cpp | 2 + src/chart/options/align.h | 8 +- src/chart/options/channel.cpp | 13 ++- src/chart/options/channel.h | 10 ++- src/chart/options/channelrange.cpp | 4 + src/chart/options/channelrange.h | 4 +- src/chart/options/channels.cpp | 7 ++ src/chart/options/config.cpp | 29 +++++-- src/chart/options/coordsystem.h | 4 +- src/chart/options/options.cpp | 18 +++- src/chart/options/orientation.h | 4 +- src/chart/options/shapetype.h | 2 +- src/chart/options/sort.h | 4 +- src/chart/rendering/colorbuilder.cpp | 11 ++- src/chart/rendering/drawaxes.cpp | 27 ++++-- src/chart/rendering/drawbackground.cpp | 10 +++ src/chart/rendering/drawchart.cpp | 10 +++ src/chart/rendering/drawguides.cpp | 11 ++- src/chart/rendering/drawinterlacing.cpp | 22 +++-- src/chart/rendering/drawlabel.cpp | 19 +++- src/chart/rendering/drawlegend.cpp | 16 +++- src/chart/rendering/drawmarkerinfo.cpp | 7 ++ src/chart/rendering/drawplot.cpp | 12 ++- src/chart/rendering/logo.cpp | 6 ++ src/chart/rendering/markerrenderer.cpp | 33 +++++-- .../rendering/markers/abstractmarker.cpp | 8 ++ src/chart/rendering/markers/circlemarker.cpp | 12 +++ .../rendering/markers/connectingmarker.cpp | 12 +++ .../rendering/markers/rectanglemarker.cpp | 12 +++ src/chart/rendering/orientedlabel.cpp | 41 ++++++--- .../rendering/painter/coordinatesystem.cpp | 43 ++++++---- src/chart/rendering/painter/drawline.cpp | 7 +- src/chart/rendering/painter/drawpolygon.cpp | 9 +- src/chart/rendering/painter/painter.cpp | 5 ++ src/chart/rendering/painter/painter.h | 3 +- src/chart/rendering/painter/pathsampler.cpp | 3 + src/chart/rendering/renderedchart.cpp | 10 ++- src/chart/speclayout/bubblechart.cpp | 7 ++ src/chart/speclayout/sizedependentlayout.h | 2 + src/chart/speclayout/treemap.cpp | 5 ++ src/chart/ui/chart.cpp | 5 ++ src/chart/ui/events.cpp | 4 +- src/dataframe/impl/aggregators.cpp | 7 ++ src/dataframe/impl/data_source.cpp | 56 ++++++++---- src/dataframe/impl/data_source.h | 17 ++-- src/dataframe/impl/dataframe.cpp | 25 ++++-- src/dataframe/impl/dataframe.h | 10 ++- src/dataframe/interface.cpp | 12 +++ src/dataframe/interface.h | 9 +- src/dataframe/old/datatable.cpp | 17 +++- src/dataframe/old/datatable.h | 2 +- src/dataframe/old/types.h | 4 +- tools/ci/type/gen-canvas-h.cjs | 4 +- 134 files changed, 1194 insertions(+), 432 deletions(-) diff --git a/src/.clang-tidy b/src/.clang-tidy index 71c6986ef..07f4a73c7 100644 --- a/src/.clang-tidy +++ b/src/.clang-tidy @@ -47,10 +47,10 @@ Checks: > -readability-identifier-length, -readability-implicit-bool-conversion, -readability-magic-numbers, - -readability-named-parameter + -readability-named-parameter, + -readability-redundant-member-init WarningsAsErrors: '*,-readability-function-size,-readability-function-cognitive-complexity,-misc-no-recursion' HeaderFilterRegex: '.*' -AnalyzeTemporaryDtors: false FormatStyle: none User: simon CheckOptions: @@ -374,5 +374,12 @@ CheckOptions: value: '0' - key: readability-simplify-subscript-expr.Types value: '::std::basic_string;::std::basic_string_view;::std::vector;::std::array' + - key: cppcoreguidelines-rvalue-reference-param-not-moved.IgnoreUnnamedParams + value: 'true' + - key: cppcoreguidelines-rvalue-reference-param-not-moved.AllowPartialMove + value: 'true' + - key: misc-include-cleaner.IgnoreHeaders + value: (.*\.tpp) + ... diff --git a/src/apps/weblib/cinterface.cpp b/src/apps/weblib/cinterface.cpp index 527ec151f..1c88e39e6 100644 --- a/src/apps/weblib/cinterface.cpp +++ b/src/apps/weblib/cinterface.cpp @@ -1,5 +1,18 @@ #include "cinterface.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include "interface.h" using Vizzu::Interface; @@ -17,7 +30,8 @@ constexpr std::uint_fast32_t hash(std::string_view s) noexcept for (size_t i = 0; i < s.size(); ++i) val ^= static_cast(s[i]) - << ((i % sizeof(std::uint_fast32_t)) * CHAR_BIT); + << ((i % sizeof(std::uint_fast32_t)) + * std::numeric_limits::digits); return val; } @@ -90,6 +104,7 @@ const char *vizzu_errorMessage(APIHandles::Exception exceptionPtr, static_cast( exceptionPtr); break; + default: break; } if (realException) return realException->what(); @@ -106,10 +121,7 @@ const char *vizzu_errorMessage(APIHandles::Exception exceptionPtr, const char *vizzu_version() { return Interface::version(); } -void vizzu_setLogging(bool enable) -{ - return Interface::setLogging(enable); -} +void vizzu_setLogging(bool enable) { Interface::setLogging(enable); } APIHandles::Chart vizzu_createChart() { @@ -127,7 +139,7 @@ void vizzu_pointerMove(APIHandles::Chart chart, double x, double y) { - return Interface::getInstance().pointerMove(chart, + Interface::getInstance().pointerMove(chart, canvas, pointerId, x, @@ -140,7 +152,7 @@ void vizzu_pointerDown(APIHandles::Chart chart, double x, double y) { - return Interface::getInstance().pointerDown(chart, + Interface::getInstance().pointerDown(chart, canvas, pointerId, x, @@ -153,7 +165,7 @@ void vizzu_pointerUp(APIHandles::Chart chart, double x, double y) { - return Interface::getInstance().pointerUp(chart, + Interface::getInstance().pointerUp(chart, canvas, pointerId, x, @@ -164,16 +176,14 @@ void vizzu_pointerLeave(APIHandles::Chart chart, APIHandles::Canvas canvas, int pointerId) { - return Interface::getInstance().pointerLeave(chart, - canvas, - pointerId); + Interface::getInstance().pointerLeave(chart, canvas, pointerId); } void vizzu_wheel(APIHandles::Chart chart, APIHandles::Canvas canvas, double delta) { - return Interface::getInstance().wheel(chart, canvas, delta); + Interface::getInstance().wheel(chart, canvas, delta); } void vizzu_update(APIHandles::Chart chart, double timeInMSecs) @@ -186,10 +196,7 @@ void vizzu_render(APIHandles::Chart chart, double width, double height) { - return Interface::getInstance().render(chart, - canvas, - width, - height); + Interface::getInstance().render(chart, canvas, width, height); } void vizzu_setLineResolution(APIHandles::Canvas canvas, @@ -207,7 +214,7 @@ void style_setValue(APIHandles::Chart chart, const char *path, const char *value) { - return Interface::getInstance().setStyleValue(chart, path, value); + Interface::getInstance().setStyleValue(chart, path, value); } const char *style_getValue(APIHandles::Chart chart, @@ -227,7 +234,7 @@ APIHandles::Snapshot chart_store(APIHandles::Chart chart) void chart_restore(APIHandles::Chart chart, APIHandles::Snapshot snapshot) { - return Interface::getInstance().restoreChart(chart, snapshot); + Interface::getInstance().restoreChart(chart, snapshot); } APIHandles::Animation chart_anim_store(APIHandles::Chart chart) @@ -238,12 +245,12 @@ APIHandles::Animation chart_anim_store(APIHandles::Chart chart) void chart_anim_restore(APIHandles::Chart chart, APIHandles::Animation anim) { - return Interface::getInstance().restoreAnim(chart, anim); + Interface::getInstance().restoreAnim(chart, anim); } void object_free(APIHandles::Any handle) { - return Interface::getInstance().freeObj(handle); + Interface::getInstance().freeObj(handle); } const char *chart_getList() { return Interface::getChartParamList(); } @@ -257,15 +264,14 @@ void chart_setValue(APIHandles::Chart chart, const char *path, const char *value) { - return Interface::getInstance().setChartValue(chart, path, value); + Interface::getInstance().setChartValue(chart, path, value); } void chart_setFilter(APIHandles::Chart chart, bool (*filter)(const Vizzu::Data::RowWrapper *), void (*deleter)(bool (*)(const Vizzu::Data::RowWrapper *))) { - return Interface::getInstance().setChartFilter(chart, - {filter, deleter}); + Interface::getInstance().setChartFilter(chart, {filter, deleter}); } const Value *record_getValue(const Vizzu::Data::RowWrapper *record, @@ -273,13 +279,17 @@ const Value *record_getValue(const Vizzu::Data::RowWrapper *record, { thread_local Value val{{}, {}}; if (auto &&cval = Interface::getRecordValue(*record, column); - (val.dimension = cval.index())) { + cval.index()) { + val.dimension = true; auto &&dim = *std::get_if(&cval); - new (&val.dimensionValue) + new ( + &val.dimensionValue) // NOLINT(bugprone-multi-level-implicit-pointer-conversion) const char *{dim ? dim->c_str() : nullptr}; } - else + else { + val.dimension = false; new (&val.measureValue) double{*std::get_if(&cval)}; + } return &val; } @@ -290,7 +300,7 @@ void data_addDimension(APIHandles::Chart chart, const std::uint32_t *categoryIndices, std::uint32_t categoryIndicesCount) { - return Interface::getInstance().addDimension(chart, + Interface::getInstance().addDimension(chart, name, categories, categoriesCount, @@ -304,7 +314,7 @@ void data_addMeasure(APIHandles::Chart chart, const double *values, std::uint32_t count) { - return Interface::getInstance().addMeasure(chart, + Interface::getInstance().addMeasure(chart, name, unit, values, @@ -315,7 +325,7 @@ void data_addRecord(APIHandles::Chart chart, const char *const *cells, std::uint32_t count) { - return Interface::getInstance().addRecord(chart, cells, count); + Interface::getInstance().addRecord(chart, cells, count); } const char *data_metaInfo(APIHandles::Chart chart) @@ -327,28 +337,26 @@ void addEventListener(APIHandles::Chart chart, const char *name, void (*callback)(APIHandles::Event event, const char *)) { - return Interface::getInstance().addEventListener(chart, - name, - callback); + Interface::getInstance().addEventListener(chart, name, callback); } void removeEventListener(APIHandles::Chart chart, const char *name, void (*callback)(APIHandles::Event event, const char *)) { - return Interface::getInstance().removeEventListener(chart, + Interface::getInstance().removeEventListener(chart, name, callback); } void event_preventDefault(APIHandles::Event event) { - return Interface::preventDefaultEvent(event); + Interface::preventDefaultEvent(event); } void chart_animate(APIHandles::Chart chart, void (*callback)(bool)) { - return Interface::getInstance().animate(chart, callback); + Interface::getInstance().animate(chart, callback); } const Point * @@ -377,16 +385,14 @@ chart_canvasToRelCoords(APIHandles::Chart chart, double x, double y) void chart_setKeyframe(APIHandles::Chart chart) { - return Interface::getInstance().setKeyframe(chart); + Interface::getInstance().setKeyframe(chart); } void anim_control_setValue(APIHandles::Chart chart, const char *path, const char *value) { - return Interface::getInstance().setAnimControlValue(chart, - path, - value); + Interface::getInstance().setAnimControlValue(chart, path, value); } const char *anim_control_getValue(APIHandles::Chart chart, @@ -399,5 +405,5 @@ void anim_setValue(APIHandles::Chart chart, const char *path, const char *value) { - return Interface::getInstance().setAnimValue(chart, path, value); + Interface::getInstance().setAnimValue(chart, path, value); } diff --git a/src/apps/weblib/interface.cpp b/src/apps/weblib/interface.cpp index 949b96d47..4b1261612 100644 --- a/src/apps/weblib/interface.cpp +++ b/src/apps/weblib/interface.cpp @@ -1,17 +1,34 @@ #include "interface.h" +#include +#include +#include +#include +#include #include +#include +#include +#include +#include "base/anim/duration.h" #include "base/conv/auto_json.h" #include "base/io/log.h" #include "base/refl/auto_accessor.h" +#include "chart/animator/animation.h" +#include "chart/generator/plotptr.h" +#include "chart/main/style.h" +#include "chart/main/stylesheet.h" #include "chart/main/version.h" +#include "chart/options/config.h" +#include "chart/options/options.h" #include "chart/ui/chart.h" +#include "dataframe/old/types.h" -#include "canvas.h" +#include "cinterface.h" #include "interfacejs.h" #include "jscriptcanvas.h" #include "jsfunctionwrapper.h" +#include "objectregistry.h" namespace Vizzu { @@ -20,7 +37,7 @@ template std::unique_ptr create_unique_ptr(T *&&ptr, Deleter &&deleter) { - return {ptr, std::forward(deleter)}; + return {std::move(ptr), std::forward(deleter)}; } struct Interface::Snapshot @@ -122,8 +139,8 @@ const char *Interface::getStyleValue(ObjectRegistryHandle chart, { auto &&chartPtr = getChart(chart); thread_local std::string res; - auto &styles = computed ? chartPtr->getComputedStyles() - : chartPtr->getStyles(); + const auto &styles = computed ? chartPtr->getComputedStyles() + : chartPtr->getStyles(); res = Styles::Sheet::getParam(styles, path); return res.c_str(); } @@ -343,7 +360,7 @@ ObjectRegistryHandle Interface::createChart() auto &openUrl = widget->openUrl; auto &doChange = widget->getChart().onChanged; - auto handle = objects.reg(std::move(widget)); + const auto *handle = objects.reg(std::move(widget)); openUrl.attach( [handle](const std::string &url) @@ -375,15 +392,12 @@ void Interface::update(ObjectRegistryHandle chart, double timeInMSecs) { auto &&widget = objects.get(chart); - std::chrono::duration milliSecs(timeInMSecs); - - auto nanoSecs = + auto &&nanoSecs = std::chrono::duration_cast( - milliSecs); - - ::Anim::TimePoint time(nanoSecs); + std::chrono::duration{timeInMSecs}); - widget->getChart().getAnimControl().update(time); + widget->getChart().getAnimControl().update( + ::Anim::TimePoint{nanoSecs}); } void Interface::render(ObjectRegistryHandle chart, diff --git a/src/apps/weblib/jscriptcanvas.cpp b/src/apps/weblib/jscriptcanvas.cpp index 4d79f58d0..6f6dfde09 100644 --- a/src/apps/weblib/jscriptcanvas.cpp +++ b/src/apps/weblib/jscriptcanvas.cpp @@ -1,5 +1,19 @@ #include "jscriptcanvas.h" +#include +#include +#include +#include + +#include "base/geom/affinetransform.h" +#include "base/geom/circle.h" +#include "base/geom/line.h" +#include "base/geom/rect.h" +#include "base/gfx/canvas.h" +#include "base/gfx/color.h" +#include "base/gfx/colorgradient.h" +#include "base/gfx/font.h" + #include "canvas.h" #include "interfacejs.h" @@ -175,17 +189,15 @@ void JScriptCanvas::setBrushGradient(const Geom::Line &line, static_assert(sizeof(Stop) == sizeof(double) * 5); static_assert(offsetof(Stop, pos) == 0); - static_assert(std::is_same::value); + static_assert(std::is_same_v); static_assert(offsetof(Stop, value) == sizeof(double)); + static_assert(std::is_same_v); static_assert( - std::is_same::value); - static_assert( - std::is_same::value); - static_assert( - std::is_same::value); + std::is_same_v); + static_assert(std::is_same_v); static_assert( - std::is_same::value); + std::is_same_v); ::canvas_setBrushGradient(this, line.begin.x, diff --git a/src/base/anim/control.cpp b/src/base/anim/control.cpp index 5249ef81b..61d48b8c3 100644 --- a/src/base/anim/control.cpp +++ b/src/base/anim/control.cpp @@ -1,9 +1,13 @@ #include "control.h" +#include #include #include "base/text/valueunit.h" +#include "controllable.h" +#include "duration.h" + namespace Anim { diff --git a/src/base/anim/control.h b/src/base/anim/control.h index 5504d16e3..9b895913d 100644 --- a/src/base/anim/control.h +++ b/src/base/anim/control.h @@ -1,6 +1,7 @@ #ifndef BASE_ANIM_CONTROL_H #define BASE_ANIM_CONTROL_H +#include #include #include "base/anim/controllable.h" @@ -12,8 +13,8 @@ namespace Anim class Control { public: - enum class PlayState { paused, running }; - enum class Direction { normal, reverse }; + enum class PlayState : std::uint8_t { paused, running }; + enum class Direction : std::uint8_t { normal, reverse }; struct Option { diff --git a/src/base/anim/duration.cpp b/src/base/anim/duration.cpp index 28ffe3aae..093d040da 100644 --- a/src/base/anim/duration.cpp +++ b/src/base/anim/duration.cpp @@ -1,6 +1,9 @@ #include "duration.h" +#include +#include #include +#include #include "base/text/valueunit.h" @@ -19,11 +22,13 @@ Duration::Duration(double nanosec) : Duration::Duration(const Text::ValueUnit &valueUnit) : Base((valueUnit.getUnit() == "ms" ? MSec(valueUnit.getValue()) - : valueUnit.getUnit() == "s" || valueUnit.getUnit().empty() - ? Sec(valueUnit.getValue()) - : throw std::logic_error("invalid time unit")) + : Sec(valueUnit.getValue())) .count()) -{} +{ + if (valueUnit.getUnit() != "ms" && valueUnit.getUnit() != "s" + && !valueUnit.getUnit().empty()) [[unlikely]] + throw std::logic_error("invalid time unit"); +} Duration::Duration(const std::string &str) : Duration(Text::ValueUnit{str}) diff --git a/src/base/anim/easing.cpp b/src/base/anim/easing.cpp index dee6f6df2..c243ddbbe 100644 --- a/src/base/anim/easing.cpp +++ b/src/base/anim/easing.cpp @@ -1,8 +1,11 @@ #include "easing.h" -#include "base/anim/easingfunc.h" +#include +#include + #include "base/anim/easinggradient.h" #include "base/conv/parse.h" +#include "base/geom/point.h" #include "base/text/funcstring.h" #include "base/text/smartstring.h" diff --git a/src/base/anim/easingfunc.h b/src/base/anim/easingfunc.h index 565b6442c..1bf61eb64 100644 --- a/src/base/anim/easingfunc.h +++ b/src/base/anim/easingfunc.h @@ -2,9 +2,7 @@ #define ANIM_EASINGFUNC #include -#include - -#include "easing.h" +#include namespace Anim { @@ -37,7 +35,7 @@ struct EaseFunc static double sine(double x) { - return 1.0 - cos((x * M_PI) / 2.0); + return 1.0 - cos(x * std::numbers::pi / 2.0); } static double quad(double x) { return x * x; } static double cubic(double x) { return x * x * x; } @@ -58,11 +56,10 @@ struct EaseFunc static double elastic(double x) { - const double c4 = (2.0 * M_PI) / 3.0; - return x == 0 ? 0 - : x == 1 - ? 1 - : -pow(2, 10 * x - 10) * sin((x * 10 - 10.75) * c4); + const double c4 = 2.0 * std::numbers::pi / 3.0; + return 0 < x && x < 1 + ? -pow(2, 10 * x - 10) * sin((x * 10 - 10.75) * c4) + : x; } }; } diff --git a/src/base/anim/easinggradient.cpp b/src/base/anim/easinggradient.cpp index 5b9a71914..b93a4a7f6 100644 --- a/src/base/anim/easinggradient.cpp +++ b/src/base/anim/easinggradient.cpp @@ -1,7 +1,12 @@ #include "easinggradient.h" +#include +#include + #include "base/geom/bezier.h" +#include "base/geom/point.h" +#include "base/math/segmentedfunc.h" #include "base/math/segmentedfunc.tpp" template struct Math::SegmentedFunction; @@ -11,7 +16,7 @@ namespace Anim EasingGradient EasingGradient::Bezier(const Geom::Point &p1, const Geom::Point &p2, - size_t stepCount) + std::size_t stepCount) { if (stepCount < 2) throw std::logic_error("not enough bezier steps"); diff --git a/src/base/anim/group.cpp b/src/base/anim/group.cpp index 33b7beaf7..d568582b1 100644 --- a/src/base/anim/group.cpp +++ b/src/base/anim/group.cpp @@ -1,4 +1,10 @@ -#include "base/anim/group.h" +#include "group.h" + +#include +#include + +#include "duration.h" +#include "element.h" namespace Anim { @@ -10,7 +16,7 @@ void Group::calcDuration(Duration duration) return; } - setDuration(::Anim::Duration()); + setDuration(Duration()); for (const auto &element : elements) if (element.options.end() > getDuration()) setDuration(element.options.end()); diff --git a/src/base/anim/interpolated.h b/src/base/anim/interpolated.h index d254786ae..1978cf2bf 100644 --- a/src/base/anim/interpolated.h +++ b/src/base/anim/interpolated.h @@ -133,7 +133,8 @@ template class Interpolated } template - [[nodiscard]] auto get(T &&index) const = delete; + // NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward) + [[nodiscard]] auto get(T &&) const = delete; explicit operator std::string() const { @@ -176,7 +177,7 @@ template class Interpolated { if (values[0].hasValue()) branch(first, values[0]); if (has_second && values[1].hasValue()) - branch(second, values[1]); + std::forward(branch)(second, values[1]); } template class Interpolated * values[0].weight; if (has_second) res = res - + static_cast(branch(values[1].value)) + + static_cast( + std::forward(branch)(values[1].value)) * values[1].weight; return static_cast(res); } diff --git a/src/base/anim/sequence.cpp b/src/base/anim/sequence.cpp index 71a2bcf8b..eadc77367 100644 --- a/src/base/anim/sequence.cpp +++ b/src/base/anim/sequence.cpp @@ -1,5 +1,10 @@ #include "sequence.h" +#include + +#include "base/anim/controllable.h" +#include "base/anim/duration.h" + namespace Anim { diff --git a/src/base/app/version.cpp b/src/base/app/version.cpp index 8e0b0d97e..36e21b616 100644 --- a/src/base/app/version.cpp +++ b/src/base/app/version.cpp @@ -1,5 +1,7 @@ #include "base/app/version.h" +#include + #include "base/app/git.h" namespace App diff --git a/src/base/conv/auto_json.h b/src/base/conv/auto_json.h index 384b3b325..b371288eb 100644 --- a/src/base/conv/auto_json.h +++ b/src/base/conv/auto_json.h @@ -2,17 +2,17 @@ #define BASE_AUTO_JSON_H #include +#include #include #include #include -#include #include #include +#include #include #include "base/refl/auto_struct.h" #include "base/text/character.h" -#include "base/text/smartstring.h" #include "tostring.h" @@ -47,7 +47,7 @@ concept SerializableRange = struct JSON { - template inline void escaped(const T &str) const + template void escaped(const T &str) const { for (auto ch : str) { if (ch >= 0 && ch <= 31) [[unlikely]] { @@ -64,7 +64,7 @@ struct JSON } } - template inline void primitive(const T &val) const + template void primitive(const T &val) const { if constexpr (std::is_floating_point_v) { if (std::isfinite(val)) @@ -92,9 +92,9 @@ struct JSON } } - template inline void array(const T &val) const; + template void array(const T &val) const; - template inline void tupleObj(const T &val) const; + template void tupleObj(const T &val) const; template void dynamicObj(const T &val) const; @@ -102,7 +102,7 @@ struct JSON template requires(JSONSerializable) - inline void any(const T &val) const + void any(const T &val) const { json += val.toJSON(); } @@ -111,14 +111,14 @@ struct JSON requires( std::is_same_v, std::nullptr_t> || std::is_same_v, std::nullopt_t>) - inline void any(const T &) const + void any(const T &) const { json += "null"; } template requires(Optional) - inline void any(const T &val) const + void any(const T &val) const { if (!val) json += "null"; @@ -128,14 +128,14 @@ struct JSON template requires(StringConvertable) - inline void any(const T &val) const + void any(const T &val) const { primitive(val); } template requires(SerializableRange) - inline void any(const T &val) const + void any(const T &val) const { if constexpr (Pair>) { dynamicObj(val); @@ -147,7 +147,7 @@ struct JSON template requires( !JSONSerializable && !SerializableRange && Tuple) - inline void any(const T &val) const + void any(const T &val) const { tupleObj(val); } @@ -159,12 +159,12 @@ struct JSON && !std::is_same_v, std::nullopt_t> && !Optional && !StringConvertable && !SerializableRange && !Tuple) - inline void any(const T &val) const + void any(const T &val) const { staticObj(val); } - explicit inline JSON(std::string &json) : json(json) {} + explicit JSON(std::string &json) : json(json) {} std::string &json; }; @@ -173,7 +173,7 @@ struct JSONAutoObj : JSON { using JSON::JSON; - inline ~JSONAutoObj() + ~JSONAutoObj() { if (cp) json.append(std::size(*cp), '}'); @@ -186,7 +186,7 @@ struct JSONAutoObj : JSON JSONAutoObj &operator=(JSONAutoObj &&) = delete; JSONAutoObj &operator=(const JSONAutoObj &) = delete; - inline void closeOpenObj( + void closeOpenObj( const std::initializer_list &il) { const auto *from = std::begin(il); @@ -216,7 +216,7 @@ struct JSONAutoObj : JSON requires(JSONSerializable || Optional || StringConvertable || SerializableRange || Tuple) - inline void add(const T &val, + void add(const T &val, const std::initializer_list &il) { closeOpenObj(il); @@ -224,7 +224,7 @@ struct JSONAutoObj : JSON } template - inline void add(const T &val, + void add(const T &val, std::initializer_list &&il) = delete; const std::initializer_list *cp{}; @@ -236,7 +236,7 @@ template struct JSONNoBaseAutoObj : JSONAutoObj template requires(!std::is_base_of_v) - inline auto operator()(const T &val, + auto operator()(const T &val, const std::initializer_list &il) -> decltype(add(val, il)) { @@ -253,7 +253,7 @@ template struct JSONRepeat : JSON JSONRepeat &operator=(const JSONRepeat &) = delete; JSONRepeat &operator=(JSONRepeat &&) = delete; - inline ~JSONRepeat() + ~JSONRepeat() { if (!was) json += open; json += close; @@ -270,8 +270,7 @@ struct JSONObj : protected JSONRepeat<'{', '}'> { using JSONRepeat::JSONRepeat; - template - inline JSON &key(std::string_view key) + template JSON &key(std::string_view key) { sep(); json += '\"'; @@ -285,17 +284,17 @@ struct JSONObj : protected JSONRepeat<'{', '}'> } template - inline JSONObj nested(std::string_view key) + JSONObj nested(std::string_view key) { this->key(key); return JSONObj{json}; } template - inline JSONArr nestedArr(std::string_view key); + JSONArr nestedArr(std::string_view key); template - inline JSONObj &raw(std::string_view key, const std::string &str) + JSONObj &raw(std::string_view key, const std::string &str) { this->key(key); json += str; @@ -303,7 +302,7 @@ struct JSONObj : protected JSONRepeat<'{', '}'> } template - inline JSONObj &operator()(std::string_view key, const T &val) & + JSONObj &operator()(std::string_view key, const T &val) & { this->key(key); any(val); @@ -311,14 +310,14 @@ struct JSONObj : protected JSONRepeat<'{', '}'> } template - inline JSONObj &&operator()(std::string_view key, const T &val) && + JSONObj &&operator()(std::string_view key, const T &val) && { this->key(key); any(val); return std::move(*this); } - inline JSONObj &&merge(std::string_view jsonObj) && + JSONObj &&merge(std::string_view jsonObj) && { if (jsonObj.size() > 2) { sep(); @@ -332,33 +331,33 @@ struct JSONArr : protected JSONRepeat<'[', ']'> { using JSONRepeat::JSONRepeat; - template inline JSONArr &operator<<(const T &obj) + template JSONArr &operator<<(const T &obj) { sep(); any(obj); return *this; } - inline JSONArr nested() + JSONArr nested() { sep(); return JSONArr{json}; } - inline JSONObj nestedObj() + JSONObj nestedObj() { sep(); return JSONObj{json}; } }; -template inline void JSON::array(const T &val) const +template void JSON::array(const T &val) const { auto arr = JSONArr{json}; for (const auto &e : val) arr << e; } -template inline void JSON::tupleObj(const T &val) const +template void JSON::tupleObj(const T &val) const { std::apply( [this](const auto &...args) @@ -368,7 +367,7 @@ template inline void JSON::tupleObj(const T &val) const val); } -template inline void JSON::dynamicObj(const T &val) const +template void JSON::dynamicObj(const T &val) const { auto j = JSONObj{json}; for (const auto &[k, v] : val) { @@ -376,19 +375,19 @@ template inline void JSON::dynamicObj(const T &val) const } } -template inline void JSON::staticObj(const T &val) const +template void JSON::staticObj(const T &val) const { Refl::visit(JSONNoBaseAutoObj{json}, val); } template -inline JSONArr JSONObj::nestedArr(std::string_view key) +JSONArr JSONObj::nestedArr(std::string_view key) { this->key(key); return JSONArr{json}; } -template inline std::string toJSON(const T &v) +template std::string toJSON(const T &v) { std::string res; JSON{res}.any(v); diff --git a/src/base/conv/numtostr.cpp b/src/base/conv/numtostr.cpp index c681ff206..27324e741 100644 --- a/src/base/conv/numtostr.cpp +++ b/src/base/conv/numtostr.cpp @@ -2,9 +2,13 @@ #include "numtostr.h" #include +#include #include #include +#include #include +#include +#include namespace Conv { diff --git a/src/base/conv/numtostr.h b/src/base/conv/numtostr.h index c7be49c0f..e4c06aa11 100644 --- a/src/base/conv/numtostr.h +++ b/src/base/conv/numtostr.h @@ -2,9 +2,7 @@ #define CONV_NUMTOSTR #include -#include #include -#include namespace Conv { @@ -16,7 +14,7 @@ struct NumberToString char integerGgrouping = '\0'; char fractionGgrouping = '\0'; char decimalPointChar = '.'; - constexpr static inline auto MAX_BUFFER_SIZE = 430; + constexpr static auto MAX_BUFFER_SIZE = 430; std::array buffer = {}; [[nodiscard]] std::string convert(double number); diff --git a/src/base/conv/parse.h b/src/base/conv/parse.h index afee57413..929135308 100644 --- a/src/base/conv/parse.h +++ b/src/base/conv/parse.h @@ -33,10 +33,10 @@ template To parse(const std::string &string) return string == "true" || (string != "false" && (throw std::bad_cast(), true)); } - else if constexpr (std::is_floating_point::value) { + else if constexpr (std::is_floating_point_v) { return static_cast(strtod(string.c_str(), nullptr)); } - else if constexpr (std::is_integral::value) { + else if constexpr (std::is_integral_v) { return static_cast(strtoll(string.c_str(), nullptr, 10)); } else diff --git a/src/base/geom/affinetransform.cpp b/src/base/geom/affinetransform.cpp index 489f5f66f..efb204d48 100644 --- a/src/base/geom/affinetransform.cpp +++ b/src/base/geom/affinetransform.cpp @@ -1,11 +1,15 @@ #include "affinetransform.h" +#include +#include +#include + #include "base/conv/auto_json.h" +#include "base/math/floating.h" -#include "circle.h" #include "line.h" +#include "point.h" #include "polygon.h" -#include "rect.h" namespace Geom { diff --git a/src/base/geom/angle.cpp b/src/base/geom/angle.cpp index 993a19197..804b463be 100644 --- a/src/base/geom/angle.cpp +++ b/src/base/geom/angle.cpp @@ -1,7 +1,9 @@ #include "angle.h" #include +#include #include +#include #include "base/text/valueunit.h" @@ -10,12 +12,12 @@ namespace Geom template double CircularAngle::degToRad(double deg) { - return M_PI * deg / 180.0; + return std::numbers::pi * deg / 180.0; } template double CircularAngle::radToDeg(double rad) { - return 180.0 * rad / M_PI; + return 180.0 * rad / std::numbers::pi; } template @@ -48,13 +50,13 @@ CircularAngle CircularAngle::Deg(double value) template CircularAngle CircularAngle::Grad(double value) { - return CircularAngle(M_PI * value / 200.0); + return CircularAngle(std::numbers::pi * value / 200.0); } template CircularAngle CircularAngle::Turn(double value) { - return CircularAngle(2.0 * M_PI * value); + return CircularAngle(2.0 * std::numbers::pi * value); } template double CircularAngle::deg() const @@ -64,7 +66,7 @@ template double CircularAngle::deg() const template double CircularAngle::turn() const { - return value / (2.0 * M_PI); + return value / (2.0 * std::numbers::pi); } template void CircularAngle::sanitize() diff --git a/src/base/geom/angle.h b/src/base/geom/angle.h index b09f9777d..4dd042d4c 100644 --- a/src/base/geom/angle.h +++ b/src/base/geom/angle.h @@ -2,6 +2,7 @@ #define MATH_ANGLE #include +#include #include #include "base/text/valueunit.h" @@ -54,17 +55,18 @@ CircularAngle interpolate(CircularAngle op0, if (factor >= 1.0) return op1; - if (fabs(op0.rad() - op1.rad()) <= M_PI) + if (fabs(op0.rad() - op1.rad()) <= std::numbers::pi) return CircularAngle( op0.rad() * (1.0 - factor) + op1.rad() * factor); if (op0.rad() < op1.rad()) return CircularAngle( - (op0.rad() + 2 * M_PI) * (1.0 - factor) + (op0.rad() + 2 * std::numbers::pi) * (1.0 - factor) + op1.rad() * factor); return CircularAngle( - op0.rad() * (1.0 - factor) + (op1.rad() + 2 * M_PI) * factor); + op0.rad() * (1.0 - factor) + + (op1.rad() + 2 * std::numbers::pi) * factor); } using Angle180 = CircularAngle<180>; diff --git a/src/base/geom/circle.cpp b/src/base/geom/circle.cpp index 32d17eefc..7b0df4143 100644 --- a/src/base/geom/circle.cpp +++ b/src/base/geom/circle.cpp @@ -1,22 +1,34 @@ #include "circle.h" #include +#include +#include +#include +#include +#include "base/math/floating.h" #include "base/math/tolerance.h" +#include "rect.h" +#include "solutions.h" + namespace Geom { -Circle::Circle(const Rect &rect, FromRect fromRect) +Circle::Circle(const Rect &rect, FromRect fromRect) : + center(rect.pos + rect.size / 2.0) { - radius = fromRect == FromRect::inscribed - ? rect.size.minSize() / 2.0 - : fromRect == FromRect::sameWidth ? rect.size.x / 2.0 - : fromRect == FromRect::sameHeight ? rect.size.y / 2.0 - : fromRect == FromRect::outscribed - ? rect.size.diagonal() / 2.0 - : throw std::logic_error("invalid circle parameter"); - center = rect.pos + rect.size / 2.0; + switch (fromRect) { + case FromRect::inscribed: + radius = rect.size.minSize() / 2.0; + break; + case FromRect::sameWidth: radius = rect.size.x / 2.0; break; + case FromRect::sameHeight: radius = rect.size.y / 2.0; break; + case FromRect::outscribed: + radius = rect.size.diagonal() / 2.0; + break; + default: throw std::logic_error("invalid circle parameter"); + } } Circle::Circle(const Circle &c0, @@ -46,7 +58,10 @@ bool Circle::colateral(const Circle &c, double tolerance) const == (radius + c.radius); } -double Circle::area() const { return M_PI * radius * radius; } +double Circle::area() const +{ + return std::numbers::pi * radius * radius; +} bool Circle::overlaps(const Circle &c, double tolerance) const { diff --git a/src/base/geom/circle.h b/src/base/geom/circle.h index 973cd3ef6..802239d53 100644 --- a/src/base/geom/circle.h +++ b/src/base/geom/circle.h @@ -1,7 +1,7 @@ #ifndef GEOM_CIRCLE #define GEOM_CIRCLE -#include +#include #include "point.h" #include "rect.h" @@ -13,7 +13,7 @@ namespace Geom class Circle { public: - enum class FromRect { + enum class FromRect : std::uint8_t { inscribed, sameWidth, sameHeight, @@ -23,7 +23,7 @@ class Circle Point center; double radius; - Circle() : radius(0) {} + Circle() : radius{} {} Circle(Point center, double radius) : center(center), diff --git a/src/base/geom/point.cpp b/src/base/geom/point.cpp index c0e0c5efa..b100d6182 100644 --- a/src/base/geom/point.cpp +++ b/src/base/geom/point.cpp @@ -1,13 +1,17 @@ #include "point.h" +#include + +#include "base/math/floating.h" + namespace Geom { Size Size::rotatedSize(double angle) const { Size res; - auto c = ::fabs(::cos(angle)); - auto s = ::fabs(::sin(angle)); + auto c = fabs(cos(angle)); + auto s = fabs(sin(angle)); res.x = x * c + y * s; res.y = x * s + y * c; return res; diff --git a/src/base/geom/point.h b/src/base/geom/point.h index 770c6825f..ac9c1be18 100644 --- a/src/base/geom/point.h +++ b/src/base/geom/point.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -135,9 +136,9 @@ struct Point [[nodiscard]] double angle() const { using Math::Floating::is_zero; - if (is_zero(y)) return std::signbit(x) ? M_PI : 0.0; - if (is_zero(x)) - return std::signbit(y) ? -M_PI / 2.0 : M_PI / 2.0; + using std::numbers::pi; + if (is_zero(y)) return std::signbit(x) ? pi : 0.0; + if (is_zero(x)) return std::signbit(y) ? -pi / 2.0 : pi / 2.0; return atan2f(static_cast(y), static_cast(x)); } diff --git a/src/base/geom/polygon.cpp b/src/base/geom/polygon.cpp index a4000b6c4..b9d4198b8 100644 --- a/src/base/geom/polygon.cpp +++ b/src/base/geom/polygon.cpp @@ -1,13 +1,13 @@ #include "polygon.h" +#include "point.h" +#include "rect.h" + namespace Geom { void Polygon::add(const Point &point) { points.push_back(point); } -Rect Polygon::boundary() const -{ - return Geom::Rect::Boundary(points); -} +Rect Polygon::boundary() const { return Rect::Boundary(points); } } \ No newline at end of file diff --git a/src/base/geom/quadrilateral.cpp b/src/base/geom/quadrilateral.cpp index 1e13899e9..f9a7ca415 100644 --- a/src/base/geom/quadrilateral.cpp +++ b/src/base/geom/quadrilateral.cpp @@ -2,6 +2,8 @@ #include "base/math/tolerance.h" +#include "point.h" +#include "rect.h" #include "triangle.h" namespace Geom diff --git a/src/base/geom/rect.cpp b/src/base/geom/rect.cpp index 0934a3684..078dece32 100644 --- a/src/base/geom/rect.cpp +++ b/src/base/geom/rect.cpp @@ -1,16 +1,19 @@ #include "rect.h" #include +#include +#include + +#include "base/math/floating.h" + +#include "point.h" namespace Geom { -Rect Rect::Ident() { return {Geom::Point(), Geom::Size::Identity()}; } +Rect Rect::Ident() { return {Point(), Size::Identity()}; } -Rect Rect::CenteredMax() -{ - return {Geom::Point::Min() / 2, {Geom::Size::Max()}}; -} +Rect Rect::CenteredMax() { return {Point::Min() / 2, {Size::Max()}}; } Rect Rect::boundary(const Rect &rect) const { @@ -77,7 +80,7 @@ Rect Rect::operator*(double factor) const return {pos * factor, {size * factor}}; } -Rect Rect::operator+(const Geom::Rect &other) const +Rect Rect::operator+(const Rect &other) const { return {pos + other.pos, {size + other.size}}; } diff --git a/src/base/geom/triangle.cpp b/src/base/geom/triangle.cpp index 3c558b4b8..1b06430ec 100644 --- a/src/base/geom/triangle.cpp +++ b/src/base/geom/triangle.cpp @@ -1,5 +1,7 @@ #include "triangle.h" +#include + namespace Geom { diff --git a/src/base/gfx/color.cpp b/src/base/gfx/color.cpp index 85c5c0aed..ef509fb56 100644 --- a/src/base/gfx/color.cpp +++ b/src/base/gfx/color.cpp @@ -1,5 +1,9 @@ #include "color.h" +#include +#include +#include + #include "base/conv/parse.h" #include "base/text/character.h" #include "base/text/funcstring.h" diff --git a/src/base/gfx/colorgradient.cpp b/src/base/gfx/colorgradient.cpp index eb1790ee0..c2753e4a4 100644 --- a/src/base/gfx/colorgradient.cpp +++ b/src/base/gfx/colorgradient.cpp @@ -1,12 +1,15 @@ #include "colorgradient.h" +#include #include +#include -#include "base/math/interpolation.h" -#include "base/math/range.h" +#include "base/math/segmentedfunc.h" #include "base/math/segmentedfunc.tpp" #include "base/text/smartstring.h" +#include "color.h" + template struct Math::SegmentedFunction; namespace Gfx diff --git a/src/base/gfx/colorgradient.h b/src/base/gfx/colorgradient.h index daeeeb78f..0628b43b5 100644 --- a/src/base/gfx/colorgradient.h +++ b/src/base/gfx/colorgradient.h @@ -10,16 +10,15 @@ namespace Gfx { -struct ColorGradient : Math::SegmentedFunction +struct ColorGradient : Math::SegmentedFunction { static ColorGradient HeatMap5Color(); static ColorGradient HeatMap7Color(); - using Math::SegmentedFunction::SegmentedFunction; + using SegmentedFunction::SegmentedFunction; - explicit ColorGradient( - Math::SegmentedFunction gradient) : - Math::SegmentedFunction(std::move(gradient)) + explicit ColorGradient(SegmentedFunction gradient) : + SegmentedFunction(std::move(gradient)) {} explicit ColorGradient( @@ -27,7 +26,7 @@ struct ColorGradient : Math::SegmentedFunction explicit operator std::string() const; - using Math::SegmentedFunction::at; + using SegmentedFunction::at; }; } diff --git a/src/base/gfx/colorpalette.cpp b/src/base/gfx/colorpalette.cpp index 97553c0eb..22169badd 100644 --- a/src/base/gfx/colorpalette.cpp +++ b/src/base/gfx/colorpalette.cpp @@ -1,11 +1,17 @@ #include "colorpalette.h" +#include +#include +#include + #include "base/text/smartstring.h" +#include "color.h" + namespace Gfx { -ColorPalette::ColorPalette(std::initializer_list colors) : +ColorPalette::ColorPalette(std::initializer_list colors) : colors(colors) {} @@ -29,13 +35,12 @@ ColorPalette::operator std::string() const return res; } -Gfx::Color ColorPalette::operator[](unsigned index) const +Color ColorPalette::operator[](unsigned index) const { - return colors.empty() ? Gfx::Color() - : colors[index % colors.size()]; + return colors.empty() ? Color() : colors[index % colors.size()]; } -Gfx::Color &ColorPalette::operator[](unsigned index) +Color &ColorPalette::operator[](unsigned index) { if (index >= colors.size()) colors.resize(index + 1); diff --git a/src/base/gfx/colortransform.cpp b/src/base/gfx/colortransform.cpp index 69a41ee60..dbbf3970e 100644 --- a/src/base/gfx/colortransform.cpp +++ b/src/base/gfx/colortransform.cpp @@ -2,11 +2,14 @@ #include "colortransform.h" #include +#include #include #include "base/text/funcstring.h" #include "base/text/smartstring.h" +#include "color.h" + namespace Gfx { diff --git a/src/base/gfx/draw/infobubble.cpp b/src/base/gfx/draw/infobubble.cpp index ff9845ae9..cdf0f8e9f 100644 --- a/src/base/gfx/draw/infobubble.cpp +++ b/src/base/gfx/draw/infobubble.cpp @@ -1,4 +1,10 @@ -#include "base/gfx/draw/infobubble.h" +#include "infobubble.h" + +#include "base/geom/point.h" +#include "base/geom/rect.h" +#include "base/gfx/canvas.h" + +#include "roundedrect.h" namespace Gfx::Draw { diff --git a/src/base/gfx/draw/roundedrect.cpp b/src/base/gfx/draw/roundedrect.cpp index f001228f3..788d70f53 100644 --- a/src/base/gfx/draw/roundedrect.cpp +++ b/src/base/gfx/draw/roundedrect.cpp @@ -1,5 +1,9 @@ #include "base/gfx/draw/roundedrect.h" +#include "base/geom/point.h" +#include "base/geom/rect.h" +#include "base/gfx/canvas.h" + namespace Gfx::Draw { diff --git a/src/base/gfx/draw/textbox.cpp b/src/base/gfx/draw/textbox.cpp index d69d38b21..b4ef4984e 100644 --- a/src/base/gfx/draw/textbox.cpp +++ b/src/base/gfx/draw/textbox.cpp @@ -1,5 +1,13 @@ #include "textbox.h" +#include +#include + +#include "base/geom/point.h" +#include "base/gfx/canvas.h" +#include "base/gfx/color.h" +#include "base/gfx/font.h" + namespace Gfx::Draw { diff --git a/src/base/gfx/font.cpp b/src/base/gfx/font.cpp index 22fed7666..5c91b850b 100644 --- a/src/base/gfx/font.cpp +++ b/src/base/gfx/font.cpp @@ -1,5 +1,6 @@ #include "font.h" +#include #include #include "base/conv/parse.h" diff --git a/src/base/gfx/font.h b/src/base/gfx/font.h index aa813dd01..476290bbf 100644 --- a/src/base/gfx/font.h +++ b/src/base/gfx/font.h @@ -1,6 +1,7 @@ #ifndef GFX_FONT #define GFX_FONT +#include #include namespace Gfx @@ -27,7 +28,7 @@ class Font int value; }; - enum class Style { normal, italic, oblique }; + enum class Style : std::uint8_t { normal, italic, oblique }; std::string family; Style style; diff --git a/src/base/gfx/length.cpp b/src/base/gfx/length.cpp index bee74287a..a9ecfc129 100644 --- a/src/base/gfx/length.cpp +++ b/src/base/gfx/length.cpp @@ -1,6 +1,7 @@ #include "length.h" #include +#include #include "base/text/valueunit.h" diff --git a/src/base/gfx/pathsampler.cpp b/src/base/gfx/pathsampler.cpp index da07c940c..c4f6a2f1a 100644 --- a/src/base/gfx/pathsampler.cpp +++ b/src/base/gfx/pathsampler.cpp @@ -1,5 +1,8 @@ #include "pathsampler.h" +#include + +#include "base/geom/point.h" #include "base/geom/triangle.h" namespace Gfx diff --git a/src/base/gui/pointer.h b/src/base/gui/pointer.h index 81f4e862a..0a2eac14e 100644 --- a/src/base/gui/pointer.h +++ b/src/base/gui/pointer.h @@ -13,7 +13,7 @@ namespace GUI struct PointerEvent { - int pointerId; + int pointerId{}; Geom::Point position; }; diff --git a/src/base/math/fuzzybool.h b/src/base/math/fuzzybool.h index 4e23d486f..2e3927752 100644 --- a/src/base/math/fuzzybool.h +++ b/src/base/math/fuzzybool.h @@ -20,14 +20,14 @@ class FuzzyBool explicit FuzzyBool(bool value) : value(value ? 1.0 : 0.0) {} - template - && std::is_same_v< - std::remove_cvref_t< - decltype(*std::declval())>, - bool>>> - explicit FuzzyBool(Optional &&opt) : FuzzyBool(opt && *opt) + template + requires(std::is_convertible_v + && std::is_same_v< + std::remove_cvref_t< + decltype(*std::declval())>, + bool>) + explicit FuzzyBool(Optional &&opt) : + FuzzyBool(opt && *std::forward(opt)) {} explicit FuzzyBool(double val) diff --git a/src/base/math/renard.cpp b/src/base/math/renard.cpp index 6f0fce8a5..6d6b64764 100644 --- a/src/base/math/renard.cpp +++ b/src/base/math/renard.cpp @@ -1,7 +1,7 @@ #include "renard.h" -#include +#include #include #include #include diff --git a/src/base/math/trig.cpp b/src/base/math/trig.cpp index e691d9a50..2ec91c3f5 100644 --- a/src/base/math/trig.cpp +++ b/src/base/math/trig.cpp @@ -1,8 +1,9 @@ #include "trig.h" #include +#include int Math::rad2quadrant(double angle) { - return static_cast(round(angle / (M_PI / 2.0))); + return static_cast(round(angle / (std::numbers::pi / 2.0))); } diff --git a/src/base/refl/auto_name.h b/src/base/refl/auto_name.h index 6f108e37e..5c9c9a5bf 100644 --- a/src/base/refl/auto_name.h +++ b/src/base/refl/auto_name.h @@ -63,8 +63,7 @@ template consteval auto name() last); if constexpr (constexpr std::string_view res = sv.substr(val + 1, last - val); - res.length() > 0 - && (res[0] < '0' || res[0] > '9')) { + !res.empty() && (res[0] < '0' || res[0] > '9')) { std::array arr{}; std::ranges::copy(res, arr.begin()); return arr; diff --git a/src/base/refl/auto_struct.h b/src/base/refl/auto_struct.h index a3656447f..b51b80cf1 100644 --- a/src/base/refl/auto_struct.h +++ b/src/base/refl/auto_struct.h @@ -2,11 +2,10 @@ #define VIZZU_REFL_AUTO_STRUCT_H #include +#include #include -#include #include #include -#include #include "auto_name.h" @@ -48,9 +47,9 @@ template struct ubiq_base template ::value>::type> -consteval typename std::add_pointer::type + class = + typename std::enable_if_t>> +consteval std::add_pointer_t enable_if_constructible(std::index_sequence) noexcept; #ifdef __clang__ @@ -58,8 +57,8 @@ consteval typename std::add_pointer::type #endif template -consteval typename std::add_pointer{B}..., - ubiq{I}...))>::type +consteval std::add_pointer_t{B}..., + ubiq{I}...))> enable_if_constructible_base(std::index_sequence, std::index_sequence) noexcept; @@ -257,7 +256,11 @@ constexpr inline bool same_as_decomposed = U>; } -enum class structure_bindable { no, through_base, through_members }; +enum class structure_bindable : std::uint8_t { + no, + through_base, + through_members +}; template , @@ -562,7 +565,7 @@ template struct Applier && std::is_invocable_v &>) - constexpr static inline __attribute__((always_inline)) void apply( + constexpr static __attribute__((always_inline)) void apply( Visitor &v) noexcept { v(FuncPtr, @@ -575,14 +578,14 @@ template struct Applier && !std::is_invocable_v &>) - constexpr static inline __attribute__((always_inline)) void apply( + constexpr static __attribute__((always_inline)) void apply( Visitor &v) noexcept { v(FuncPtr); } template - constexpr static inline __attribute__((always_inline)) void apply( + constexpr static __attribute__((always_inline)) void apply( [[maybe_unused]] Visitor &v) noexcept { if constexpr (!std::is_empty_v) { @@ -628,17 +631,17 @@ struct GetterVisitor, std::index_sequence> { - Visitor &visitor; + Visitor &&visitor; std::tuple ts; - constexpr inline GetterVisitor(Visitor &p_visitor, + constexpr GetterVisitor(Visitor &&p_visitor, std::tuple t) : - visitor(p_visitor), + visitor(std::forward(p_visitor)), ts(std::move(t)) {} template - constexpr inline std::invoke_result_t...> operator()(Getter &&getter) const noexcept { @@ -647,7 +650,7 @@ struct GetterVisitor - constexpr inline std::invoke_result_t..., const std::initializer_list &> operator()(Getter &&getter, @@ -664,11 +667,12 @@ struct GetterVisitor -constexpr inline __attribute__((always_inline)) auto visit( - [[maybe_unused]] Visitor &&visitor) +constexpr __attribute__((always_inline)) auto visit(Visitor &&visitor) { #ifndef __clang_analyzer__ return Functors::Applier::template apply(visitor); +#else + std::ignore = std::forward(visitor); #endif } @@ -676,16 +680,19 @@ template requires((std::is_same_v, std::remove_cvref_t> && ...)) -constexpr inline void visit([[maybe_unused]] Visitor &&visitor, - [[maybe_unused]] T &visitable, - [[maybe_unused]] Ts &&...ts) +constexpr void +visit(Visitor &&visitor, [[maybe_unused]] T &visitable, Ts &&...ts) { #ifndef __clang_analyzer__ using TT = std::remove_cvref_t; visit( - Functors::GetterVisitor>{ - visitor, - {visitable, ts...}}); + Functors::GetterVisitor>{ + std::forward(visitor), + {visitable, std::forward(ts)...}}); +#else + std::ignore = std::forward(visitor); + std::ignore = + std::forward_as_tuple(std::forward(ts)...); #endif } diff --git a/src/base/style/impl.tpp b/src/base/style/impl.tpp index 5f02dd00f..0453484fa 100644 --- a/src/base/style/impl.tpp +++ b/src/base/style/impl.tpp @@ -15,11 +15,11 @@ template T Sheet::getFullParams() const template ParamRegistry::ParamRegistry() { - Refl::visit([this]>>( + Refl::visit([this]( U && accessor, - const std::initializer_list &thePath = {}) { + const std::initializer_list &thePath = {}) + requires std::is_constructible_v + { std::string currentPath; for (auto sv : thePath) { if (!currentPath.empty()) currentPath += '.'; diff --git a/src/base/style/paramregistry.h b/src/base/style/paramregistry.h index 74895d314..726681675 100644 --- a/src/base/style/paramregistry.h +++ b/src/base/style/paramregistry.h @@ -44,15 +44,16 @@ template class ParamRegistry requires(Type::isoptional< std::remove_cvref_t>>::value) - constexpr inline + constexpr __attribute__((always_inline)) explicit Accessor(T &&t) : toString( - [t](const Root &r) + [t = std::forward(t)](const Root &r) { return Conv::toString(t(r)); }), fromString( - [t](Root &r, const std::string &str) + [t = std::forward(t)](Root &r, + const std::string &str) { auto &e = t(r); e = Conv::parse>( diff --git a/src/base/text/funcstring.cpp b/src/base/text/funcstring.cpp index 563e53e5c..af6f35125 100644 --- a/src/base/text/funcstring.cpp +++ b/src/base/text/funcstring.cpp @@ -2,6 +2,7 @@ #include #include +#include #include "smartstring.h" diff --git a/src/base/text/naturalcmp.cpp b/src/base/text/naturalcmp.cpp index aa748065e..be3d15560 100644 --- a/src/base/text/naturalcmp.cpp +++ b/src/base/text/naturalcmp.cpp @@ -1,6 +1,7 @@ #include "naturalcmp.h" -#include +#include +#include #include "character.h" diff --git a/src/base/text/numberscale.cpp b/src/base/text/numberscale.cpp index 44b86f3c2..c62d56b97 100644 --- a/src/base/text/numberscale.cpp +++ b/src/base/text/numberscale.cpp @@ -1,5 +1,9 @@ #include "numberscale.h" +#include +#include +#include + #include "base/conv/parse.h" #include "base/text/smartstring.h" diff --git a/src/base/text/numberscale.h b/src/base/text/numberscale.h index a5a45b12b..f2ca94ac5 100644 --- a/src/base/text/numberscale.h +++ b/src/base/text/numberscale.h @@ -1,13 +1,14 @@ #ifndef TEXT_NUMBERSCALE #define TEXT_NUMBERSCALE +#include #include #include namespace Text { -enum class PrefixType { +enum class PrefixType : std::uint8_t { SISymbol, shortScaleSymbolUS, shortScaleSymbolUK diff --git a/src/base/text/smartstring.cpp b/src/base/text/smartstring.cpp index fb8a48615..1365f6563 100644 --- a/src/base/text/smartstring.cpp +++ b/src/base/text/smartstring.cpp @@ -3,12 +3,16 @@ #include #include -#include -#include +#include +#include +#include +#include #include "base/conv/numtostr.h" #include "base/math/normalizednumber.h" +#include "numberscale.h" + namespace Text::SmartString { void trim(std::string &string) diff --git a/src/base/text/smartstring.h b/src/base/text/smartstring.h index ac1fd9a11..a041dcbb4 100644 --- a/src/base/text/smartstring.h +++ b/src/base/text/smartstring.h @@ -1,6 +1,7 @@ #ifndef TEXT_SMARTSTRING #define TEXT_SMARTSTRING +#include #include #include @@ -9,7 +10,7 @@ namespace Text { -enum class NumberFormat { none, grouped, prefixed }; +enum class NumberFormat : std::uint8_t { none, grouped, prefixed }; namespace SmartString { diff --git a/src/base/text/valueunit.cpp b/src/base/text/valueunit.cpp index dcc17a57b..a2f64830c 100644 --- a/src/base/text/valueunit.cpp +++ b/src/base/text/valueunit.cpp @@ -1,5 +1,8 @@ #include "valueunit.h" +#include +#include + #include "base/text/smartstring.h" namespace Text diff --git a/src/base/type/physicalvalue.h b/src/base/type/physicalvalue.h index 940330d33..c8c33cc12 100644 --- a/src/base/type/physicalvalue.h +++ b/src/base/type/physicalvalue.h @@ -6,7 +6,7 @@ namespace Type { -enum class SimpleUnit : uint32_t { none, relative, absolute }; +enum class SimpleUnit : std::uint8_t { none, relative, absolute }; template class PhysicalValue diff --git a/src/base/type/uniquelist.h b/src/base/type/uniquelist.h index 50a06135c..1307090f6 100644 --- a/src/base/type/uniquelist.h +++ b/src/base/type/uniquelist.h @@ -216,8 +216,7 @@ template class UniqueList } template - [[nodiscard]] bool contains_any(It &&first1, - Sentinel &&last1) const + [[nodiscard]] bool contains_any(It first1, Sentinel last1) const { for (auto first2 = items.begin(), last2 = items.end(); first1 != last1 && first2 != last2;) diff --git a/src/base/util/eventdispatcher.cpp b/src/base/util/eventdispatcher.cpp index 432aeaa4f..6b99f387b 100644 --- a/src/base/util/eventdispatcher.cpp +++ b/src/base/util/eventdispatcher.cpp @@ -1,5 +1,10 @@ #include "eventdispatcher.h" +#include +#include +#include +#include + #include "base/conv/auto_json.h" namespace Util @@ -31,7 +36,7 @@ bool EventDispatcher::Event::invoke(Params &¶ms) const operator()(params, params.toJSON()); - return !params.preventDefault; + return !std::move(params).preventDefault; } EventDispatcher::~EventDispatcher() = default; diff --git a/src/chart/animator/animation.cpp b/src/chart/animator/animation.cpp index 0e12e9c93..0e9d7a244 100644 --- a/src/chart/animator/animation.cpp +++ b/src/chart/animator/animation.cpp @@ -1,24 +1,34 @@ #include "animation.h" +#include +#include +#include #include +#include "base/anim/control.h" +#include "base/anim/controllable.h" +#include "base/anim/sequence.h" #include "chart/animator/keyframe.h" #include "chart/generator/plot.h" #include "chart/generator/plotbuilder.h" +#include "chart/generator/plotptr.h" +#include "dataframe/old/datatable.h" + +#include "options.h" namespace Vizzu::Anim { Animation::Animation(const Gen::PlotPtr &plot) : - ::Anim::Control(static_cast(*this)), + Control(static_cast(*this)), source(plot), target(plot) { onChange.attach( [this] { - if (!::Anim::Sequence::actual) return; - auto plot = ::Anim::Sequence::actual->data(); + if (!actual) return; + auto plot = actual->data(); if (!plot) return; onPlotChanged( std::static_pointer_cast(std::move(plot))); @@ -54,12 +64,12 @@ void Animation::addKeyframe(const Gen::PlotPtr &next, strategy = RegroupStrategy::fade; } - Vizzu::Gen::PlotPtr intermediate0; - Vizzu::Gen::PlotPtr intermediate1; + Gen::PlotPtr intermediate0; + Gen::PlotPtr intermediate1; if (strategy == RegroupStrategy::drilldown) { - auto drilldown = +[](Vizzu::Gen::Options &base, - const Vizzu::Gen::Options &other) + auto drilldown = + +[](Gen::Options &base, const Gen::Options &other) { base.drilldownTo(other); }; @@ -89,9 +99,8 @@ void Animation::addKeyframe(const Gen::PlotPtr &next, && next->getOptions()->dataFilter]( bool drilldownToBase) { - return [&andFilter, - drilldownToBase](Vizzu::Gen::Options &base, - const Vizzu::Gen::Options &target) + return [&andFilter, drilldownToBase](Gen::Options &base, + const Gen::Options &target) { auto baseCopy = base; base.intersection(target); @@ -180,7 +189,8 @@ Gen::PlotPtr Animation::getIntermediate(const Gen::PlotPtr &base, auto extOptions = std::make_shared(*base->getOptions()); - modifier(*extOptions, *other->getOptions()); + std::forward( + modifier)(*extOptions, *other->getOptions()); if (*extOptions != *other->getOptions() && *extOptions != *base->getOptions()) { @@ -206,14 +216,14 @@ void Animation::addKeyframe(const Gen::PlotPtr &source, isInstant)); } -void Animation::animate(const ::Anim::Control::Option &options, +void Animation::animate(const Option &options, OnComplete &&onThisCompletes) { if (isRunning()) throw std::logic_error("animation already in progress"); completionCallback = std::move(onThisCompletes); - ::Anim::Control::reset(); + reset(); this->options = options; onBegin(); } diff --git a/src/chart/animator/animator.cpp b/src/chart/animator/animator.cpp index d497f4930..8e6b15448 100644 --- a/src/chart/animator/animator.cpp +++ b/src/chart/animator/animator.cpp @@ -1,6 +1,16 @@ #include "animator.h" -#include "chart/animator/keyframe.h" +#include +#include +#include + +#include "base/anim/control.h" +#include "base/util/eventdispatcher.h" +#include "chart/generator/plotptr.h" +#include "dataframe/old/datatable.h" + +#include "animation.h" +#include "options.h" namespace Vizzu::Anim { diff --git a/src/chart/animator/keyframe.cpp b/src/chart/animator/keyframe.cpp index 1c4f79c76..182a52fe6 100644 --- a/src/chart/animator/keyframe.cpp +++ b/src/chart/animator/keyframe.cpp @@ -1,9 +1,16 @@ #include "keyframe.h" -#include +#include #include +#include "base/anim/duration.h" #include "chart/generator/plot.h" +#include "chart/generator/plotbuilder.h" +#include "chart/generator/plotptr.h" +#include "chart/options/options.h" +#include "dataframe/old/datatable.h" + +#include "options.h" namespace Vizzu::Anim { diff --git a/src/chart/animator/morph.cpp b/src/chart/animator/morph.cpp index b076aeded..f4e6fcaff 100644 --- a/src/chart/animator/morph.cpp +++ b/src/chart/animator/morph.cpp @@ -1,7 +1,17 @@ #include "morph.h" +#include +#include + +#include "base/anim/interpolated.h" #include "base/math/interpolation.h" +#include "chart/generator/axis.h" +#include "chart/generator/guides.h" #include "chart/generator/plot.h" +#include "chart/options/channel.h" +#include "chart/options/shapetype.h" + +#include "options.h" namespace Vizzu::Anim::Morph { diff --git a/src/chart/animator/options.cpp b/src/chart/animator/options.cpp index 0290f404d..9067970dc 100644 --- a/src/chart/animator/options.cpp +++ b/src/chart/animator/options.cpp @@ -1,5 +1,11 @@ #include "options.h" +#include +#include + +#include "base/anim/control.h" +#include "base/anim/duration.h" +#include "base/anim/easing.h" #include "base/conv/parse.h" #include "base/text/smartstring.h" diff --git a/src/chart/animator/options.h b/src/chart/animator/options.h index 8c6628d30..65e35fa64 100644 --- a/src/chart/animator/options.h +++ b/src/chart/animator/options.h @@ -1,7 +1,7 @@ #ifndef CHART_ANIM_OPTIONS #define CHART_ANIM_OPTIONS -#include +#include #include #include "base/anim/control.h" @@ -11,7 +11,7 @@ namespace Vizzu::Anim { -enum class SectionId { +enum class SectionId : std::uint8_t { style, title, subtitle, @@ -28,7 +28,11 @@ enum class SectionId { connection }; -enum class RegroupStrategy { fade, drilldown, aggregate }; +enum class RegroupStrategy : std::uint8_t { + fade, + drilldown, + aggregate +}; class Options { diff --git a/src/chart/animator/planner.cpp b/src/chart/animator/planner.cpp index 9c5f99ad4..d3cdf4ea5 100644 --- a/src/chart/animator/planner.cpp +++ b/src/chart/animator/planner.cpp @@ -1,9 +1,25 @@ #include "planner.h" +#include +#include +#include +#include +#include +#include +#include + +#include "base/anim/duration.h" +#include "base/anim/easing.h" #include "base/anim/easingfunc.h" +#include "base/anim/element.h" +#include "base/anim/group.h" #include "chart/generator/plot.h" +#include "chart/options/channel.h" +#include "chart/options/orientation.h" +#include "chart/options/shapetype.h" #include "morph.h" +#include "options.h" #include "styles.h" namespace Vizzu::Anim @@ -106,17 +122,21 @@ void Planner::createPlan(const Gen::Plot &source, addMorph(SectionId::color, step); addMorph(SectionId::coordSystem, std::max(step, posDuration)); - const auto &geomEasing = - srcOpt->geometry == Gen::ShapeType::circle ? in3 - : trgOpt->geometry == Gen::ShapeType::circle ? out3 - : srcOpt->geometry == Gen::ShapeType::line ? in3 - : trgOpt->geometry == Gen::ShapeType::line ? out3 - : inOut5; + const ::Anim::Easing *geomEasing{&inOut5}; + if (auto &&targetCircle = + trgOpt->geometry == Gen::ShapeType::circle; + srcOpt->geometry == Gen::ShapeType::circle + || (!targetCircle + && srcOpt->geometry == Gen::ShapeType::line)) + geomEasing = &in3; + else if (targetCircle + || trgOpt->geometry == Gen::ShapeType::line) + geomEasing = &out3; addMorph(SectionId::geometry, std::max(step, posDuration), 0ms, - geomEasing); + *geomEasing); setBaseline(); diff --git a/src/chart/animator/styles.cpp b/src/chart/animator/styles.cpp index 2bdc13c62..8a2f0ab5d 100644 --- a/src/chart/animator/styles.cpp +++ b/src/chart/animator/styles.cpp @@ -1,6 +1,13 @@ -#include "chart/animator/styles.h" +#include "styles.h" +#include + +#include "base/anim/group.h" +#include "base/anim/options.h" #include "base/refl/auto_struct.h" +#include "base/text/numberscale.h" +#include "base/text/smartstring.h" +#include "chart/main/style.h" namespace Vizzu::Anim::Morph { diff --git a/src/chart/generator/axis.cpp b/src/chart/generator/axis.cpp index 4d43dc693..7867eccd9 100644 --- a/src/chart/generator/axis.cpp +++ b/src/chart/generator/axis.cpp @@ -1,7 +1,21 @@ #include "axis.h" +#include +#include +#include +#include +#include +#include +#include + +#include "base/anim/interpolated.h" +#include "base/geom/point.h" +#include "base/math/floating.h" #include "base/math/interpolation.h" +#include "base/math/range.h" #include "base/math/renard.h" +#include "chart/options/channel.h" +#include "dataframe/old/types.h" namespace Vizzu::Gen { diff --git a/src/chart/generator/axis.h b/src/chart/generator/axis.h index 727fd6dcc..0bc3fea5c 100644 --- a/src/chart/generator/axis.h +++ b/src/chart/generator/axis.h @@ -158,10 +158,11 @@ struct Axises [[nodiscard]] const Axis &other(ChannelId channelType) const { - return channelType == ChannelId::x ? axises.at(ChannelId::y) - : channelType == ChannelId::y - ? axises.at(ChannelId::x) - : throw std::logic_error("not an axis channel"); + switch (channelType) { + case ChannelId::x: return axises.at(ChannelId::y); + case ChannelId::y: return axises.at(ChannelId::x); + default: throw std::logic_error("not an axis channel"); + } } [[nodiscard]] Geom::Point origo() const; diff --git a/src/chart/generator/buckets.cpp b/src/chart/generator/buckets.cpp index 443446076..857735937 100644 --- a/src/chart/generator/buckets.cpp +++ b/src/chart/generator/buckets.cpp @@ -1,7 +1,10 @@ #include "buckets.h" +#include +#include #include +#include #include "dataframe/old/types.h" diff --git a/src/chart/generator/guides.cpp b/src/chart/generator/guides.cpp index 71e7cee09..c86a52b2a 100644 --- a/src/chart/generator/guides.cpp +++ b/src/chart/generator/guides.cpp @@ -1,5 +1,14 @@ #include "guides.h" +#include + +#include "base/math/interpolation.h" +#include "chart/options/align.h" +#include "chart/options/channel.h" +#include "chart/options/coordsystem.h" +#include "chart/options/options.h" +#include "chart/options/shapetype.h" + namespace Vizzu::Gen { diff --git a/src/chart/generator/marker.cpp b/src/chart/generator/marker.cpp index 28f7486fc..9aa24c6f3 100644 --- a/src/chart/generator/marker.cpp +++ b/src/chart/generator/marker.cpp @@ -1,6 +1,19 @@ #include "marker.h" +#include +#include +#include +#include + +#include "base/conv/auto_json.h" +#include "base/geom/point.h" +#include "base/geom/rect.h" +#include "base/math/range.h" +#include "chart/options/align.h" +#include "chart/options/coordsystem.h" +#include "chart/options/shapetype.h" #include "dataframe/old/datatable.h" +#include "dataframe/old/types.h" #include "axis.h" diff --git a/src/chart/generator/plot.cpp b/src/chart/generator/plot.cpp index 0c4eeca14..75b7637c6 100644 --- a/src/chart/generator/plot.cpp +++ b/src/chart/generator/plot.cpp @@ -1,14 +1,19 @@ #include "plot.h" -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include "base/anim/interpolated.h" -#include "base/conv/numtostr.h" -#include "base/math/range.h" -#include "chart/speclayout/bubblechartbuilder.h" -#include "chart/speclayout/tablechart.h" -#include "chart/speclayout/treemap.h" +#include "chart/main/style.h" +#include "chart/options/options.h" + +#include "marker.h" namespace Vizzu::Gen { diff --git a/src/chart/generator/plotbuilder.cpp b/src/chart/generator/plotbuilder.cpp index 44b373393..ae3ad7ea5 100644 --- a/src/chart/generator/plotbuilder.cpp +++ b/src/chart/generator/plotbuilder.cpp @@ -1,11 +1,34 @@ #include "plotbuilder.h" -#include -#include -#include -#include - +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "base/anim/interpolated.h" #include "base/math/floating.h" +#include "base/math/range.h" +#include "chart/main/style.h" +#include "chart/options/align.h" +#include "chart/options/channel.h" +#include "chart/options/coordsystem.h" +#include "chart/options/options.h" +#include "chart/options/shapetype.h" +#include "chart/options/sort.h" +#include "chart/speclayout/bubblechartbuilder.h" +#include "chart/speclayout/tablechart.h" +#include "chart/speclayout/treemap.h" +#include "dataframe/old/datatable.h" +#include "dataframe/old/types.h" #include "buckets.h" #include "plot.h" @@ -47,7 +70,7 @@ PlotBuilder::PlotBuilder(const Data::DataTable &dataTable, void PlotBuilder::initDimensionTrackers() const { - for (const Channel &ch : + for (const auto &ch : plot->options->getChannels().getChannels()) { if (!ch.isDimension()) continue; plot->axises.at(ch.type).dimension.trackedValues = @@ -134,6 +157,7 @@ PlotBuilder::sortedBuckets(const Buckets &buckets, bool main) const for (auto &&[marker, idx] : bucket) { if (!marker.enabled) continue; + // NOLINTNEXTLINE(misc-include-cleaner) auto it = std::ranges::lower_bound(sorted, idx.itemId, std::less{}, @@ -364,10 +388,12 @@ void PlotBuilder::calcMeasureAxis(const Data::DataTable &dataTable, const auto &scale = plot->getOptions()->getChannels().at(type); auto range = getMeasTrackRange(type); if (auto &&meas = scale.measureId) { - plot->axises.at(type).common.title = - scale.title.isAuto() ? dataCube.getName(*meas) - : scale.title ? *scale.title - : std::string{}; + + if (auto &title = plot->axises.at(type).common.title; + scale.title.isAuto()) + title = dataCube.getName(*meas); + else if (scale.title) + title = *scale.title; if (type == plot->getOptions()->subAxisType() && plot->getOptions()->align @@ -439,10 +465,11 @@ void PlotBuilder::calcDimensionAxis(ChannelId type) if (auto &&series = scale.labelSeries()) axis.category = series.value().getColIndex(); - plot->axises.at(type).common.title = - scale.title.isAuto() && !hasLabel ? axis.category - : scale.title ? *scale.title - : std::string{}; + auto &title = plot->axises.at(type).common.title; + if (scale.title.isAuto() && !hasLabel) + title = axis.category; + else if (scale.title) + title = *scale.title; } void PlotBuilder::addAlignment(const Buckets &subBuckets) const diff --git a/src/chart/main/chart.cpp b/src/chart/main/chart.cpp index 34e81b56c..054b52294 100644 --- a/src/chart/main/chart.cpp +++ b/src/chart/main/chart.cpp @@ -1,9 +1,21 @@ #include "chart.h" -#include +#include +#include +#include "base/geom/rect.h" +#include "base/gfx/canvas.h" +#include "base/gfx/length.h" +#include "chart/animator/animation.h" #include "chart/generator/plot.h" +#include "chart/generator/plotbuilder.h" +#include "chart/generator/plotptr.h" +#include "chart/options/config.h" +#include "chart/options/options.h" #include "chart/rendering/drawchart.h" +#include "chart/rendering/drawingcontext.h" + +#include "style.h" namespace Vizzu { diff --git a/src/chart/main/events.cpp b/src/chart/main/events.cpp index 4a93d11b7..1d9cda777 100644 --- a/src/chart/main/events.cpp +++ b/src/chart/main/events.cpp @@ -1,5 +1,7 @@ #include "events.h" +#include "base/util/eventdispatcher.h" + namespace Vizzu { diff --git a/src/chart/main/events.h b/src/chart/main/events.h index 4417e7b30..09bbde4f0 100644 --- a/src/chart/main/events.h +++ b/src/chart/main/events.h @@ -162,7 +162,7 @@ class Events virtual void appendToJSON(Conv::JSONObj &&jsonObj) const { - jsonObj("tagName", tagName); + std::move(jsonObj)("tagName", tagName); } }; @@ -195,7 +195,7 @@ class Events template explicit Text(std::string text, Args &&...args) : - Base(args...), + Base(std::forward(args)...), text(std::move(text)) {} diff --git a/src/chart/main/layout.cpp b/src/chart/main/layout.cpp index dc1d152db..3af8ade60 100644 --- a/src/chart/main/layout.cpp +++ b/src/chart/main/layout.cpp @@ -1,6 +1,8 @@ #include "layout.h" -#include "chart/rendering/drawlabel.h" +#include "base/anim/interpolated.h" +#include "base/geom/rect.h" +#include "chart/options/options.h" #include "chart/rendering/logo.h" #include "stylesheet.h" diff --git a/src/chart/main/style.cpp b/src/chart/main/style.cpp index 4dc94ccd7..5ed598e81 100644 --- a/src/chart/main/style.cpp +++ b/src/chart/main/style.cpp @@ -1,6 +1,16 @@ #include "style.h" +#include + +#include "base/anim/interpolated.h" +#include "base/gfx/color.h" +#include "base/gfx/colorgradient.h" +#include "base/gfx/colorpalette.h" +#include "base/gfx/colortransform.h" +#include "base/gfx/font.h" +#include "base/gfx/length.h" #include "base/refl/auto_struct.h" +#include "base/text/smartstring.h" namespace Vizzu::Styles { @@ -572,13 +582,13 @@ struct FontParentSetter Font *parent; template requires(std::is_same_v) - inline void operator()(T &f) const noexcept + void operator()(T &f) const noexcept { f.fontParent = parent; } template - inline void operator()(Styles::Param const &) const noexcept + void operator()(Param const &) const noexcept {} }; diff --git a/src/chart/main/style.h b/src/chart/main/style.h index fa7ea40dd..401891208 100644 --- a/src/chart/main/style.h +++ b/src/chart/main/style.h @@ -1,6 +1,8 @@ #ifndef STYLE_H #define STYLE_H +#include + #include "base/anim/interpolated.h" #include "base/geom/angle.h" #include "base/geom/rect.h" @@ -12,7 +14,6 @@ #include "base/gfx/font.h" #include "base/gfx/length.h" #include "base/gui/accessories.h" -#include "base/math/fuzzybool.h" #include "base/style/param.h" #include "base/text/numberscale.h" #include "base/text/smartstring.h" @@ -23,8 +24,8 @@ namespace Vizzu::Styles using ::Style::Param; -enum class Visibility { hidden, visible }; -enum class Overflow { hidden, visible }; +enum class Visibility : std::uint8_t { hidden, visible }; +enum class Overflow : std::uint8_t { hidden, visible }; struct Padding { @@ -160,7 +161,7 @@ struct Label : Padding, Font, Text struct Tick { - enum class Position { outside, inside, center }; + enum class Position : std::uint8_t { outside, inside, center }; Param color; Param lineWidth; @@ -181,7 +182,7 @@ struct Interlacing struct OrientedLabelParams { - enum class Orientation { + enum class Orientation : std::uint8_t { normal, tangential, horizontal, @@ -197,9 +198,9 @@ struct OrientedLabel : Label, OrientedLabelParams struct AxisLabelParams { - enum class Position { axis, min_edge, max_edge }; + enum class Position : std::uint8_t { axis, min_edge, max_edge }; - enum class Side { positive, negative }; + enum class Side : std::uint8_t { positive, negative }; Param<::Anim::Interpolated> position; Param<::Anim::Interpolated> side; @@ -215,12 +216,12 @@ consteval auto unique_enum_names(AxisLabelParams::Position) struct AxisTitleParams { - enum class Position { axis, min_edge, max_edge }; + enum class Position : std::uint8_t { axis, min_edge, max_edge }; - enum class Side { positive, upon, negative }; - enum class VPosition { begin, middle, end }; - enum class VSide { positive, upon, negative }; - enum class Orientation { horizontal, vertical }; + enum class Side : std::uint8_t { positive, upon, negative }; + enum class VPosition : std::uint8_t { begin, middle, end }; + enum class VSide : std::uint8_t { positive, upon, negative }; + enum class Orientation : std::uint8_t { horizontal, vertical }; Param<::Anim::Interpolated> position; Param<::Anim::Interpolated> side; @@ -249,8 +250,17 @@ struct Axis struct MarkerLabelParams { - enum class Position { center, left, right, top, bottom }; - enum class Format { measureFirst, dimensionsFirst }; + enum class Position : std::uint8_t { + center, + left, + right, + top, + bottom + }; + enum class Format : std::uint8_t { + measureFirst, + dimensionsFirst + }; Param<::Anim::Interpolated> position; Param filter; @@ -262,7 +272,7 @@ struct MarkerLabel : OrientedLabel, MarkerLabelParams struct TooltipParams { - enum class Layout { singleLine, multiLine }; + enum class Layout : std::uint8_t { singleLine, multiLine }; Param<::Anim::Interpolated> layout; Param color; @@ -298,7 +308,10 @@ struct DataPoint struct MarkerParams { - enum class BorderOpacityMode { straight, premultiplied }; + enum class BorderOpacityMode : std::uint8_t { + straight, + premultiplied + }; Param borderWidth; Param borderOpacity; @@ -315,7 +328,7 @@ struct LegendParams { struct Marker { - enum class Type { circle, square }; + enum class Type : std::uint8_t { circle, square }; Param<::Anim::Interpolated> type; Param size; diff --git a/src/chart/main/stylesheet.cpp b/src/chart/main/stylesheet.cpp index 3a7cd176b..f6917de63 100644 --- a/src/chart/main/stylesheet.cpp +++ b/src/chart/main/stylesheet.cpp @@ -1,9 +1,22 @@ #include "stylesheet.h" +#include #include - +#include +#include + +#include "base/geom/point.h" +#include "base/gfx/canvas.h" +#include "base/gfx/colortransform.h" +#include "base/gfx/font.h" +#include "base/gfx/length.h" +#include "base/math/range.h" #include "base/style/impl.tpp" #include "chart/generator/plot.h" +#include "chart/options/channel.h" +#include "chart/options/coordsystem.h" +#include "chart/options/options.h" +#include "chart/options/shapetype.h" #include "layout.h" @@ -240,7 +253,7 @@ void Sheet::setAfterStyles(Gen::Plot &plot, const Geom::Size &size) ranges.push_back(next_range); } - xLabel.angle.emplace(has_collision * M_PI / 4); + xLabel.angle.emplace(has_collision * std::numbers::pi / 4); } } diff --git a/src/chart/main/version.cpp b/src/chart/main/version.cpp index ddd3dc478..25840ba47 100644 --- a/src/chart/main/version.cpp +++ b/src/chart/main/version.cpp @@ -1,5 +1,7 @@ #include "version.h" +#include "base/app/version.h" + const App::Version Vizzu::Main::version(0, 12, 0); const char *const Vizzu::Main::siteUrl = "https://vizzu.io/"; diff --git a/src/chart/options/align.h b/src/chart/options/align.h index f9ba07a08..390cfa54c 100644 --- a/src/chart/options/align.h +++ b/src/chart/options/align.h @@ -11,7 +11,13 @@ namespace Vizzu::Base struct Align : private Math::Range { public: - enum class Type : uint32_t { none, min, center, max, stretch }; + enum class Type : std::uint8_t { + none, + min, + center, + max, + stretch + }; Align(Type type, const Range &range) : Range(range), diff --git a/src/chart/options/channel.cpp b/src/chart/options/channel.cpp index bddd59345..5b839ebec 100644 --- a/src/chart/options/channel.cpp +++ b/src/chart/options/channel.cpp @@ -1,10 +1,17 @@ #include "channel.h" -#include #include -#include - +#include +#include +#include +#include +#include +#include +#include + +#include "chart/options/autoparam.h" #include "dataframe/old/datatable.h" +#include "dataframe/old/types.h" namespace Vizzu::Gen { diff --git a/src/chart/options/channel.h b/src/chart/options/channel.h index c6b6b6f0e..3cf7c59ba 100644 --- a/src/chart/options/channel.h +++ b/src/chart/options/channel.h @@ -13,7 +13,15 @@ namespace Vizzu::Gen { -enum class ChannelId { color, lightness, size, label, x, y, noop }; +enum class ChannelId : std::uint8_t { + color, + lightness, + size, + label, + x, + y, + noop +}; class Channel { diff --git a/src/chart/options/channelrange.cpp b/src/chart/options/channelrange.cpp index 91e91e639..bda11114e 100644 --- a/src/chart/options/channelrange.cpp +++ b/src/chart/options/channelrange.cpp @@ -1,6 +1,10 @@ #include "channelrange.h" +#include + +#include "base/conv/parse.h" #include "base/conv/tostring.h" +#include "base/math/range.h" #include "base/text/valueunit.h" namespace Vizzu::Gen diff --git a/src/chart/options/channelrange.h b/src/chart/options/channelrange.h index 7f4a5d491..c2c54aeaa 100644 --- a/src/chart/options/channelrange.h +++ b/src/chart/options/channelrange.h @@ -1,7 +1,7 @@ #ifndef CHANNELRANGE_H #define CHANNELRANGE_H -#include +#include #include "base/math/range.h" #include "base/type/physicalvalue.h" @@ -11,7 +11,7 @@ namespace Vizzu::Gen { -enum class ChannelExtremaType { +enum class ChannelExtremaType : std::uint8_t { absolute, relative, minOffset, diff --git a/src/chart/options/channels.cpp b/src/chart/options/channels.cpp index 1a03d977c..0317627f9 100644 --- a/src/chart/options/channels.cpp +++ b/src/chart/options/channels.cpp @@ -1,5 +1,12 @@ #include "channels.h" +#include +#include + +#include "dataframe/old/types.h" + +#include "channel.h" + namespace Vizzu::Gen { diff --git a/src/chart/options/config.cpp b/src/chart/options/config.cpp index e095650db..1fefc5025 100644 --- a/src/chart/options/config.cpp +++ b/src/chart/options/config.cpp @@ -1,9 +1,21 @@ #include "config.h" +#include +#include +#include +#include +#include +#include +#include + +#include "base/anim/interpolated.h" #include "base/conv/auto_json.h" #include "base/conv/parse.h" -#include "base/refl/auto_struct.h" +#include "base/math/fuzzybool.h" +#include "base/refl/auto_enum.h" #include "base/text/smartstring.h" +#include "chart/options/channel.h" +#include "chart/options/options.h" namespace Vizzu::Gen { @@ -38,7 +50,7 @@ using ExtractType = decltype(Refl::Name::getBase(Mptr))>>>; template -inline constexpr std::pair +constexpr std::pair Config::accessor = {Refl::Name::in_data_name< Refl::Name::name()>, {.get = @@ -57,8 +69,7 @@ inline constexpr std::pair const Config::Accessors &Config::getAccessors() { - static const Config::Accessors accessors = { - accessor<&Options::title>, + static const Accessors accessors = {accessor<&Options::title>, accessor<&Options::subtitle>, accessor<&Options::caption>, accessor<&Options::legend>, @@ -221,11 +232,11 @@ void Config::setChannelParam(const std::string &path, const auto &accessors = getChannelAccessors(); if (auto it = accessors.find(property); it != accessors.end()) - return it->second.set(channel, value); - - throw std::logic_error( - path + "/" + value - + ": invalid channel parameter: " + property); + it->second.set(channel, value); + else + throw std::logic_error( + path + "/" + value + + ": invalid channel parameter: " + property); } std::string Config::getChannelParam(const std::string &path) const diff --git a/src/chart/options/coordsystem.h b/src/chart/options/coordsystem.h index d3e7ef64d..678421293 100644 --- a/src/chart/options/coordsystem.h +++ b/src/chart/options/coordsystem.h @@ -1,10 +1,12 @@ #ifndef CHART_OPTIONS_COORDSYSTEM_H #define CHART_OPTIONS_COORDSYSTEM_H +#include + namespace Vizzu::Gen { -enum class CoordSystem { cartesian, polar }; +enum class CoordSystem : std::uint8_t { cartesian, polar }; } diff --git a/src/chart/options/options.cpp b/src/chart/options/options.cpp index 402689ec0..f5827371a 100644 --- a/src/chart/options/options.cpp +++ b/src/chart/options/options.cpp @@ -1,9 +1,20 @@ #include "options.h" +#include #include +#include +#include #include "base/math/trig.h" +#include "dataframe/old/types.h" + +#include "align.h" +#include "channel.h" +#include "channelrange.h" +#include "coordsystem.h" +#include "orientation.h" +#include "shapetype.h" namespace Vizzu::Gen { @@ -41,10 +52,9 @@ const Channel *Options::subAxisOf(ChannelId id) const return id == mainAxisType() ? &subAxis() : nullptr; case ShapeType::area: - return id == mainAxisType() ? &subAxis() - : id == subAxisType() ? &mainAxis() - : nullptr; - + if (id == mainAxisType()) return &subAxis(); + if (id == subAxisType()) return &mainAxis(); + return nullptr; case ShapeType::line: return id == subAxisType() || (id == ChannelId::size diff --git a/src/chart/options/orientation.h b/src/chart/options/orientation.h index 735ad957c..28cea459d 100644 --- a/src/chart/options/orientation.h +++ b/src/chart/options/orientation.h @@ -1,10 +1,12 @@ #ifndef CHART_OPTIONS_ORIENTATION_H #define CHART_OPTIONS_ORIENTATION_H +#include + namespace Vizzu::Gen { -enum class Orientation { horizontal, vertical }; +enum class Orientation : std::uint8_t { horizontal, vertical }; } diff --git a/src/chart/options/shapetype.h b/src/chart/options/shapetype.h index 378ba16bc..6148f5b82 100644 --- a/src/chart/options/shapetype.h +++ b/src/chart/options/shapetype.h @@ -6,7 +6,7 @@ namespace Vizzu::Gen { -enum class ShapeType : uint32_t { rectangle, circle, area, line }; +enum class ShapeType : std::uint8_t { rectangle, circle, area, line }; bool isConnecting(ShapeType type); diff --git a/src/chart/options/sort.h b/src/chart/options/sort.h index 005e07b4e..ebcd47056 100644 --- a/src/chart/options/sort.h +++ b/src/chart/options/sort.h @@ -1,10 +1,12 @@ #ifndef CHART_OPTIONS_SORT_H #define CHART_OPTIONS_SORT_H +#include + namespace Vizzu::Gen { -enum class Sort { none, byValue }; +enum class Sort : std::uint8_t { none, byValue }; } diff --git a/src/chart/rendering/colorbuilder.cpp b/src/chart/rendering/colorbuilder.cpp index b0a4b51f4..8391c0248 100644 --- a/src/chart/rendering/colorbuilder.cpp +++ b/src/chart/rendering/colorbuilder.cpp @@ -1,7 +1,14 @@ -#include "chart/rendering/colorbuilder.h" +#include "colorbuilder.h" -#include "base/math/interpolation.h" +#include +#include + +#include "base/anim/interpolated.h" +#include "base/gfx/color.h" +#include "base/gfx/colorgradient.h" +#include "base/gfx/colorpalette.h" +#include "chart/generator/colorbase.h" namespace Vizzu::Draw { diff --git a/src/chart/rendering/drawaxes.cpp b/src/chart/rendering/drawaxes.cpp index 89b76f32c..008e23f1e 100644 --- a/src/chart/rendering/drawaxes.cpp +++ b/src/chart/rendering/drawaxes.cpp @@ -1,11 +1,26 @@ #include "drawaxes.h" +#include +#include +#include +#include + +#include "base/anim/interpolated.h" +#include "base/geom/affinetransform.h" +#include "base/geom/line.h" +#include "base/geom/point.h" +#include "base/geom/transformedrect.h" +#include "base/gfx/font.h" #include "base/type/booliter.h" -#include "chart/generator/plot.h" -#include "chart/rendering/drawguides.h" -#include "chart/rendering/orientedlabel.h" +#include "chart/generator/plot.h" // NOLINT(misc-include-cleaner) +#include "chart/main/events.h" +#include "chart/main/style.h" +#include "chart/options/channel.h" +#include "drawguides.h" #include "drawlabel.h" +#include "orientedlabel.h" +#include "renderedchart.h" namespace Vizzu::Draw { @@ -206,7 +221,7 @@ void DrawAxes::drawTitle(Gen::ChannelId axisIndex) const }; auto angle = - -M_PI / 2.0 + -std::numbers::pi / 2.0 * (fades == ::Anim::second ? titleStyle.orientation->get_or_first(index) .value @@ -227,8 +242,8 @@ void DrawAxes::drawTitle(Gen::ChannelId axisIndex) const * Geom::AffineTransform((orientedSize / -2.0)); auto realAngle = Geom::Angle(-posAngle + angle).rad(); - auto upsideDown = - realAngle > M_PI / 2.0 && realAngle < 3 * M_PI / 2.0; + auto upsideDown = realAngle > std::numbers::pi / 2.0 + && realAngle < 3 * std::numbers::pi / 2.0; DrawLabel{{ctx()}}.draw(canvas, Geom::TransformedRect{transform, Geom::Size{size}}, diff --git a/src/chart/rendering/drawbackground.cpp b/src/chart/rendering/drawbackground.cpp index ea1a076f4..c8682e343 100644 --- a/src/chart/rendering/drawbackground.cpp +++ b/src/chart/rendering/drawbackground.cpp @@ -1,5 +1,15 @@ #include "drawbackground.h" +#include +#include + +#include "base/geom/rect.h" +#include "base/geom/transformedrect.h" +#include "base/gfx/canvas.h" +#include "base/util/eventdispatcher.h" +#include "chart/main/events.h" +#include "chart/main/style.h" + namespace Vizzu::Draw { diff --git a/src/chart/rendering/drawchart.cpp b/src/chart/rendering/drawchart.cpp index 5302005a5..b116593c9 100644 --- a/src/chart/rendering/drawchart.cpp +++ b/src/chart/rendering/drawchart.cpp @@ -1,5 +1,15 @@ #include "drawchart.h" +#include + +#include "base/anim/interpolated.h" +#include "base/geom/point.h" +#include "base/geom/rect.h" +#include "base/geom/transformedrect.h" +#include "base/gfx/canvas.h" +#include "chart/main/layout.h" +#include "painter/painter.h" + #include "drawbackground.h" #include "drawlabel.h" #include "drawlegend.h" diff --git a/src/chart/rendering/drawguides.cpp b/src/chart/rendering/drawguides.cpp index 07ff5868a..507cfed85 100644 --- a/src/chart/rendering/drawguides.cpp +++ b/src/chart/rendering/drawguides.cpp @@ -1,6 +1,15 @@ #include "drawguides.h" -#include "chart/generator/plot.h" +#include +#include + +#include "base/geom/line.h" +#include "base/geom/point.h" +#include "chart/generator/plot.h" // NOLINT(misc-include-cleaner) +#include "chart/main/events.h" +#include "chart/options/channel.h" + +#include "renderedchart.h" namespace Vizzu::Draw { diff --git a/src/chart/rendering/drawinterlacing.cpp b/src/chart/rendering/drawinterlacing.cpp index b61da9078..6c52728e0 100644 --- a/src/chart/rendering/drawinterlacing.cpp +++ b/src/chart/rendering/drawinterlacing.cpp @@ -1,12 +1,24 @@ #include "drawinterlacing.h" -#include - +#include +#include +#include +#include + +#include "base/anim/interpolated.h" +#include "base/geom/point.h" +#include "base/geom/rect.h" +#include "base/gfx/font.h" +#include "base/math/range.h" #include "base/math/renard.h" #include "base/text/smartstring.h" -#include "chart/generator/plot.h" -#include "chart/rendering/drawlabel.h" -#include "chart/rendering/orientedlabel.h" +#include "base/type/booliter.h" +#include "chart/generator/plot.h" // NOLINT(misc-include-cleaner) +#include "chart/main/events.h" +#include "chart/options/channel.h" + +#include "orientedlabel.h" +#include "renderedchart.h" namespace Vizzu::Draw { diff --git a/src/chart/rendering/drawlabel.cpp b/src/chart/rendering/drawlabel.cpp index 041373fcc..c457cc042 100644 --- a/src/chart/rendering/drawlabel.cpp +++ b/src/chart/rendering/drawlabel.cpp @@ -1,5 +1,19 @@ #include "drawlabel.h" +#include +#include +#include +#include + +#include "base/geom/point.h" +#include "base/geom/rect.h" +#include "base/geom/transformedrect.h" +#include "base/gfx/canvas.h" +#include "base/gfx/font.h" +#include "base/util/eventdispatcher.h" +#include "chart/main/events.h" +#include "chart/main/style.h" + namespace Vizzu::Draw { @@ -39,8 +53,9 @@ void DrawLabel::draw(Gfx::ICanvas &canvas, auto copyRect = fullRect; if (options.flip) - copyRect.transform *= - Geom::AffineTransform(fullRect.size, 1.0, -M_PI); + copyRect.transform *= Geom::AffineTransform(fullRect.size, + 1.0, + -std::numbers::pi); if (onDraw.invoke(Events::OnTextDrawEvent{*eventTarget, copyRect, diff --git a/src/chart/rendering/drawlegend.cpp b/src/chart/rendering/drawlegend.cpp index 3ba7c60d1..40cb13647 100644 --- a/src/chart/rendering/drawlegend.cpp +++ b/src/chart/rendering/drawlegend.cpp @@ -1,7 +1,21 @@ #include "drawlegend.h" +#include +#include +#include +#include +#include +#include + +#include "base/anim/interpolated.h" +#include "base/geom/rect.h" +#include "base/geom/transformedrect.h" +#include "base/gfx/canvas.h" #include "base/gfx/draw/roundedrect.h" -#include "chart/generator/plot.h" +#include "base/text/smartstring.h" +#include "chart/generator/plot.h" // NOLINT(misc-include-cleaner) +#include "chart/main/events.h" +#include "chart/options/channel.h" #include "chart/rendering/colorbuilder.h" #include "chart/rendering/drawbackground.h" #include "chart/rendering/drawlabel.h" diff --git a/src/chart/rendering/drawmarkerinfo.cpp b/src/chart/rendering/drawmarkerinfo.cpp index 695c0efee..4b1193794 100644 --- a/src/chart/rendering/drawmarkerinfo.cpp +++ b/src/chart/rendering/drawmarkerinfo.cpp @@ -1,6 +1,13 @@ #include "drawmarkerinfo.h" +#include + +#include "base/anim/interpolated.h" +#include "base/geom/rect.h" +#include "base/gfx/canvas.h" +#include "base/gfx/color.h" #include "base/gfx/draw/infobubble.h" +#include "base/gfx/font.h" #include "chart/main/style.h" #include "chart/rendering/markers/abstractmarker.h" diff --git a/src/chart/rendering/drawplot.cpp b/src/chart/rendering/drawplot.cpp index cd6c5e231..245d23d39 100644 --- a/src/chart/rendering/drawplot.cpp +++ b/src/chart/rendering/drawplot.cpp @@ -1,10 +1,16 @@ #include "drawplot.h" -#include "base/text/smartstring.h" -#include "chart/rendering/drawaxes.h" -#include "chart/rendering/drawbackground.h" +#include +#include "base/geom/rect.h" +#include "base/gfx/canvas.h" +#include "chart/main/style.h" +#include "painter/painter.h" + +#include "drawaxes.h" +#include "drawbackground.h" #include "markerrenderer.h" +#include "renderedchart.h" namespace Vizzu::Draw { diff --git a/src/chart/rendering/logo.cpp b/src/chart/rendering/logo.cpp index 596ffc041..4278daf78 100644 --- a/src/chart/rendering/logo.cpp +++ b/src/chart/rendering/logo.cpp @@ -1,6 +1,12 @@ #include "logo.h" #include +#include + +#include "base/geom/circle.h" +#include "base/geom/point.h" +#include "base/gfx/color.h" +#include "base/gfx/colortransform.h" namespace Vizzu::Draw { diff --git a/src/chart/rendering/markerrenderer.cpp b/src/chart/rendering/markerrenderer.cpp index 8e7b16a10..d0eb6db9e 100644 --- a/src/chart/rendering/markerrenderer.cpp +++ b/src/chart/rendering/markerrenderer.cpp @@ -1,15 +1,30 @@ #include "markerrenderer.h" -#include "base/geom/angle.h" +#include +#include +#include +#include +#include + +#include "base/anim/interpolated.h" +#include "base/geom/line.h" +#include "base/gfx/canvas.h" +#include "base/math/interpolation.h" #include "base/text/smartstring.h" -#include "chart/generator/plot.h" -#include "chart/rendering/colorbuilder.h" -#include "chart/rendering/drawlabel.h" -#include "chart/rendering/markers/abstractmarker.h" -#include "chart/rendering/markers/circlemarker.h" -#include "chart/rendering/markers/connectingmarker.h" -#include "chart/rendering/markers/rectanglemarker.h" -#include "chart/rendering/orientedlabel.h" +#include "chart/generator/plot.h" // NOLINT(misc-include-cleaner) +#include "chart/main/events.h" +#include "chart/options/channel.h" +#include "chart/options/coordsystem.h" +#include "chart/options/shapetype.h" +#include "markers/abstractmarker.h" +#include "markers/circlemarker.h" +#include "markers/connectingmarker.h" +#include "painter/painter.h" + +#include "colorbuilder.h" +#include "drawingcontext.h" +#include "orientedlabel.h" +#include "renderedchart.h" namespace Vizzu::Draw { diff --git a/src/chart/rendering/markers/abstractmarker.cpp b/src/chart/rendering/markers/abstractmarker.cpp index 0fb287e48..662b8d941 100644 --- a/src/chart/rendering/markers/abstractmarker.cpp +++ b/src/chart/rendering/markers/abstractmarker.cpp @@ -4,6 +4,14 @@ #include "abstractmarker.h" +#include "base/anim/interpolated.h" +#include "base/geom/line.h" +#include "chart/generator/marker.h" +#include "chart/main/style.h" +#include "chart/options/shapetype.h" +#include "chart/rendering/drawingcontext.h" +#include "chart/rendering/painter/coordinatesystem.h" + #include "circlemarker.h" #include "connectingmarker.h" #include "rectanglemarker.h" diff --git a/src/chart/rendering/markers/circlemarker.cpp b/src/chart/rendering/markers/circlemarker.cpp index 1eb909173..093c00fe2 100644 --- a/src/chart/rendering/markers/circlemarker.cpp +++ b/src/chart/rendering/markers/circlemarker.cpp @@ -1,5 +1,17 @@ #include "circlemarker.h" +#include +#include + +#include "base/math/floating.h" +#include "chart/generator/marker.h" +#include "chart/main/style.h" +#include "chart/options/options.h" +#include "chart/options/shapetype.h" +#include "chart/rendering/painter/coordinatesystem.h" + +#include "abstractmarker.h" + namespace Vizzu::Draw { diff --git a/src/chart/rendering/markers/connectingmarker.cpp b/src/chart/rendering/markers/connectingmarker.cpp index a3e4dcfd7..79a35fab1 100644 --- a/src/chart/rendering/markers/connectingmarker.cpp +++ b/src/chart/rendering/markers/connectingmarker.cpp @@ -1,8 +1,20 @@ #include "connectingmarker.h" #include +#include +#include "base/anim/interpolated.h" +#include "base/geom/point.h" +#include "base/math/floating.h" +#include "base/math/fuzzybool.h" +#include "chart/generator/marker.h" #include "chart/generator/plot.h" +#include "chart/options/coordsystem.h" +#include "chart/options/orientation.h" +#include "chart/options/shapetype.h" +#include "chart/rendering/drawingcontext.h" + +#include "abstractmarker.h" namespace Vizzu::Draw { diff --git a/src/chart/rendering/markers/rectanglemarker.cpp b/src/chart/rendering/markers/rectanglemarker.cpp index 556c412e8..5c6774ae1 100644 --- a/src/chart/rendering/markers/rectanglemarker.cpp +++ b/src/chart/rendering/markers/rectanglemarker.cpp @@ -1,5 +1,17 @@ #include "rectanglemarker.h" +#include +#include + +#include "base/geom/point.h" +#include "chart/generator/marker.h" +#include "chart/main/style.h" +#include "chart/options/coordsystem.h" +#include "chart/options/options.h" +#include "chart/options/shapetype.h" + +#include "abstractmarker.h" + namespace Vizzu::Draw { diff --git a/src/chart/rendering/orientedlabel.cpp b/src/chart/rendering/orientedlabel.cpp index 97e3d1dd1..aeb359434 100644 --- a/src/chart/rendering/orientedlabel.cpp +++ b/src/chart/rendering/orientedlabel.cpp @@ -1,6 +1,21 @@ #include "orientedlabel.h" +#include +#include +#include +#include +#include +#include + #include "base/geom/angle.h" +#include "base/geom/line.h" +#include "base/geom/point.h" +#include "base/gfx/canvas.h" +#include "base/gfx/font.h" +#include "base/util/eventdispatcher.h" +#include "chart/main/style.h" + +#include "drawlabel.h" namespace Vizzu::Draw { @@ -15,7 +30,8 @@ void OrientedLabel::draw(Gfx::ICanvas &canvas, Util::EventDispatcher::Event &event, std::unique_ptr eventTarget) const { - auto baseAngle = labelPos.getDirection().angle() + M_PI / 2.0; + auto baseAngle = + labelPos.getDirection().angle() + std::numbers::pi / 2.0; auto absAngle = labelStyle.orientation->combine( @@ -25,21 +41,23 @@ void OrientedLabel::draw(Gfx::ICanvas &canvas, switch (orientation) { default: case horizontal: return 0.0; - case vertical: return M_PI / 2.0; + case vertical: return std::numbers::pi / 2.0; case normal: return labelPos.getDirection().angle(); case tangential: return labelPos.getDirection().angle() - + M_PI / 2.0; + + std::numbers::pi / 2.0; } }) + labelStyle.angle->rad(); auto relAngle = Geom::Angle(absAngle - baseAngle).rad(); - if (relAngle > M_PI) relAngle -= M_PI; + if (relAngle > std::numbers::pi) relAngle -= std::numbers::pi; - auto xOffsetAngle = relAngle < M_PI / 4.0 ? 0 - : relAngle < 3 * M_PI / 4.0 ? M_PI / 2.0 - : M_PI; + auto xOffsetAngle = std::numbers::pi; + if (relAngle < std::numbers::pi / 4.0) + xOffsetAngle = 0.0; + else if (relAngle < 3.0 * std::numbers::pi / 4.0) + xOffsetAngle /= 2.0; const Gfx::Font font(labelStyle); canvas.setFont(font); @@ -60,9 +78,12 @@ void OrientedLabel::draw(Gfx::ICanvas &canvas, * Geom::AffineTransform(paddedSize / -2, 1.0, 0); if (auto realAngle = Geom::Angle(baseAngle + relAngle).rad(); - realAngle > M_PI / 2.0 && realAngle < 3 * M_PI / 2.0) - transform = - transform * Geom::AffineTransform(paddedSize, 1.0, -M_PI); + realAngle > std::numbers::pi / 2.0 + && realAngle < 3 * std::numbers::pi / 2.0) + transform = transform + * Geom::AffineTransform(paddedSize, + 1.0, + -std::numbers::pi); DrawLabel::draw(canvas, {transform, paddedSize}, diff --git a/src/chart/rendering/painter/coordinatesystem.cpp b/src/chart/rendering/painter/coordinatesystem.cpp index 9904020de..100ebfd55 100644 --- a/src/chart/rendering/painter/coordinatesystem.cpp +++ b/src/chart/rendering/painter/coordinatesystem.cpp @@ -1,8 +1,16 @@ #include "coordinatesystem.h" +#include #include +#include +#include "base/anim/interpolated.h" +#include "base/geom/line.h" +#include "base/geom/point.h" +#include "base/geom/rect.h" +#include "base/math/floating.h" #include "base/math/interpolation.h" +#include "chart/options/coordsystem.h" namespace Vizzu::Draw { @@ -20,14 +28,14 @@ Geom::Point PolarDescartesTransform::convert( auto mapped = mappedSize(); auto usedAngle = Math::interpolate(0.0, - 2.0 * M_PI, + 2.0 * std::numbers::pi, static_cast(polar)); - auto hEquidist = mapped.area() / M_PI; + auto hEquidist = mapped.area() / std::numbers::pi; auto yCircTop = 1.0 - mapped.y; auto radius = mapped.x / usedAngle - hEquidist; const Geom::Point center(0.5, yCircTop - radius); - auto angle = M_PI / 2.0 + (0.5 - p.x) * usedAngle; + auto angle = std::numbers::pi / 2.0 + (0.5 - p.x) * usedAngle; auto converted = center + Geom::Point::Polar(radius + p.y * mapped.y, angle); @@ -59,11 +67,12 @@ Geom::Point PolarDescartesTransform::getOriginal( const Geom::Point center(0.5, 0.5); auto polar = (p - center).toPolar(); - polar.y = -polar.y + 3 * M_PI / 2; - if (polar.y < 0) polar.y += 2 * M_PI; - if (polar.y > 2 * M_PI) polar.y -= 2 * M_PI; + polar.y = -polar.y + 3 * std::numbers::pi / 2; + if (polar.y < 0) polar.y += 2 * std::numbers::pi; + if (polar.y > 2 * std::numbers::pi) + polar.y -= 2 * std::numbers::pi; - return {polar.y / (2 * M_PI), 2 * polar.x}; + return {polar.y / (2 * std::numbers::pi), 2 * polar.x}; } Geom::Point pZoomed = p; @@ -75,17 +84,19 @@ Geom::Point PolarDescartesTransform::getOriginal( } auto mapped = mappedSize(); auto usedAngle = Math::interpolate(0.0, - 2.0 * M_PI, + 2.0 * std::numbers::pi, static_cast(polar)); - auto hEquidist = mapped.area() / M_PI; + auto hEquidist = mapped.area() / std::numbers::pi; auto yCircTop = 1.0 - mapped.y; auto radius = mapped.x / usedAngle - hEquidist; const Geom::Point center(0.5, yCircTop - radius); auto polar = (pZoomed - center).toPolar(); - polar.y = polar.y - M_PI / 2.0; - while (polar.y < M_PI) polar.y += 2 * M_PI; - while (polar.y > M_PI) polar.y -= 2 * M_PI; + polar.y = polar.y - std::numbers::pi / 2.0; + while (polar.y < std::numbers::pi) + polar.y += 2 * std::numbers::pi; + while (polar.y > std::numbers::pi) + polar.y -= 2 * std::numbers::pi; return {0.5 - polar.y / usedAngle, (polar.x - radius) / mapped.y}; } @@ -107,8 +118,9 @@ CompoundTransform::CompoundTransform(const Geom::Rect &rect, void CompoundTransform::setAngle(double value) { - angle = - value - static_cast(polarDescartes.getPolar()) * M_PI; + angle = value + - static_cast(polarDescartes.getPolar()) + * std::numbers::pi; cosAngle = cos(angle); sinAngle = sin(angle); } @@ -116,7 +128,8 @@ void CompoundTransform::setAngle(double value) double CompoundTransform::getAngle() const { return angle - + static_cast(polarDescartes.getPolar()) * M_PI; + + static_cast(polarDescartes.getPolar()) + * std::numbers::pi; } Geom::Point CompoundTransform::convert(const Geom::Point &p) const diff --git a/src/chart/rendering/painter/drawline.cpp b/src/chart/rendering/painter/drawline.cpp index af61d6c1c..97c7dcf23 100644 --- a/src/chart/rendering/painter/drawline.cpp +++ b/src/chart/rendering/painter/drawline.cpp @@ -1,9 +1,14 @@ #include "drawline.h" +#include + +#include "base/geom/line.h" #include "base/geom/quadrilateral.h" +#include "base/gfx/canvas.h" #include "base/math/interpolation.h" -#include "drawpolygon.h" +#include "coordinatesystem.h" +#include "pathsampler.h" namespace Vizzu::Draw { diff --git a/src/chart/rendering/painter/drawpolygon.cpp b/src/chart/rendering/painter/drawpolygon.cpp index 3b09374b3..9fd5889fa 100644 --- a/src/chart/rendering/painter/drawpolygon.cpp +++ b/src/chart/rendering/painter/drawpolygon.cpp @@ -1,10 +1,17 @@ #include "drawpolygon.h" +#include +#include + +#include "base/geom/circle.h" +#include "base/geom/point.h" #include "base/geom/rect.h" -#include "base/geom/triangle.h" +#include "base/gfx/canvas.h" #include "base/math/interpolation.h" #include "base/math/statistics.h" +#include "pathsampler.h" + namespace Vizzu::Draw { diff --git a/src/chart/rendering/painter/painter.cpp b/src/chart/rendering/painter/painter.cpp index 346759bb2..c08fe01fa 100644 --- a/src/chart/rendering/painter/painter.cpp +++ b/src/chart/rendering/painter/painter.cpp @@ -1,5 +1,10 @@ #include "painter.h" +#include + +#include "base/geom/line.h" +#include "base/geom/point.h" + #include "drawline.h" #include "drawpolygon.h" diff --git a/src/chart/rendering/painter/painter.h b/src/chart/rendering/painter/painter.h index 52790b250..a481d3181 100644 --- a/src/chart/rendering/painter/painter.h +++ b/src/chart/rendering/painter/painter.h @@ -40,7 +40,8 @@ class Painter void drawPolygon(const std::array &ps, bool clip = false); - void setPathSamplerOptions(Gfx::PathSampler::Options &&options) + void setPathSamplerOptions( + const Gfx::PathSampler::Options &options) { pathSamplerOptions = options; } diff --git a/src/chart/rendering/painter/pathsampler.cpp b/src/chart/rendering/painter/pathsampler.cpp index b8c745b3a..f8e8a4f78 100644 --- a/src/chart/rendering/painter/pathsampler.cpp +++ b/src/chart/rendering/painter/pathsampler.cpp @@ -1,6 +1,9 @@ #include "pathsampler.h" +#include "base/geom/point.h" +#include "base/gfx/pathsampler.h" + namespace Vizzu::Draw { diff --git a/src/chart/rendering/renderedchart.cpp b/src/chart/rendering/renderedchart.cpp index 263da810a..194c882e2 100644 --- a/src/chart/rendering/renderedchart.cpp +++ b/src/chart/rendering/renderedchart.cpp @@ -1,8 +1,16 @@ #include "renderedchart.h" +#include #include +#include -#include "chart/rendering/markerrenderer.h" +#include "base/geom/point.h" +#include "base/geom/transformedrect.h" +#include "base/math/floating.h" +#include "base/math/fuzzybool.h" +#include "base/util/eventdispatcher.h" +#include "chart/generator/marker.h" // NOLINT(misc-include-cleaner) +#include "chart/options/shapetype.h" namespace Vizzu::Draw { diff --git a/src/chart/speclayout/bubblechart.cpp b/src/chart/speclayout/bubblechart.cpp index e2338de5d..c4f5ec9ee 100644 --- a/src/chart/speclayout/bubblechart.cpp +++ b/src/chart/speclayout/bubblechart.cpp @@ -2,6 +2,13 @@ #include #include +#include +#include + +#include "base/geom/point.h" +#include "base/geom/rect.h" + +#include "specmarker.h" namespace Vizzu::Charts { diff --git a/src/chart/speclayout/sizedependentlayout.h b/src/chart/speclayout/sizedependentlayout.h index 7d31b1209..971177d27 100644 --- a/src/chart/speclayout/sizedependentlayout.h +++ b/src/chart/speclayout/sizedependentlayout.h @@ -40,6 +40,8 @@ template struct SizeDependentLayout subChart.markers[subCnt++]); } } + std::ignore = + std::forward(afterMarkerSetter); } }; } diff --git a/src/chart/speclayout/treemap.cpp b/src/chart/speclayout/treemap.cpp index 94d187780..e495be0e7 100644 --- a/src/chart/speclayout/treemap.cpp +++ b/src/chart/speclayout/treemap.cpp @@ -1,9 +1,14 @@ #include "treemap.h" #include +#include +#include +#include #include "base/math/interpolation.h" +#include "specmarker.h" + namespace Vizzu::Charts { diff --git a/src/chart/ui/chart.cpp b/src/chart/ui/chart.cpp index 4b2280f91..1b5401c88 100644 --- a/src/chart/ui/chart.cpp +++ b/src/chart/ui/chart.cpp @@ -1,5 +1,10 @@ #include "chart.h" +#include + +#include "base/geom/point.h" +#include "base/gfx/canvas.h" +#include "base/gui/pointer.h" #include "chart/main/version.h" #include "events.h" diff --git a/src/chart/ui/events.cpp b/src/chart/ui/events.cpp index e77a8d7be..bdba6ff13 100644 --- a/src/chart/ui/events.cpp +++ b/src/chart/ui/events.cpp @@ -1,8 +1,8 @@ #include "events.h" #include "base/conv/auto_json.h" -#include "base/conv/tostring.h" -#include "base/text/smartstring.h" +#include "base/gui/pointer.h" +#include "base/util/eventdispatcher.h" namespace Vizzu::UI { diff --git a/src/dataframe/impl/aggregators.cpp b/src/dataframe/impl/aggregators.cpp index 7c555c9d2..a455afc50 100644 --- a/src/dataframe/impl/aggregators.cpp +++ b/src/dataframe/impl/aggregators.cpp @@ -2,8 +2,15 @@ #include "aggregators.h" #include +#include #include #include +#include +#include +#include + +#include "base/refl/auto_enum.h" +#include "dataframe/interface.h" namespace Vizzu::dataframe { diff --git a/src/dataframe/impl/data_source.cpp b/src/dataframe/impl/data_source.cpp index c506b84bf..1e8eeff70 100644 --- a/src/dataframe/impl/data_source.cpp +++ b/src/dataframe/impl/data_source.cpp @@ -2,16 +2,33 @@ #include "data_source.h" #include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include #include #include -#include "../old/datatable.h" +#include "base/refl/auto_enum.h" #include "base/text/naturalcmp.h" +#include "dataframe/interface.h" #include "aggregators.h" -#include "dataframe.h" namespace Vizzu::dataframe { @@ -38,7 +55,8 @@ constexpr void index_erase_if::operator()( auto curr = cont.begin() + indices[i]; into = std::move(std::exchange(prev, curr + 1), curr, into); } - cont.erase(std::move(prev, cont.end(), into), cont.end()); + std::forward(cont).erase(std::move(prev, cont.end(), into), + cont.end()); } template <> @@ -49,7 +67,7 @@ constexpr void index_erase_if<>::operator()( auto from = cont.end(); for (auto i : std::ranges::views::reverse(indices)) cont[i] = std::move(*--from); - cont.erase(from, cont.end()); + std::forward(cont).erase(from, cont.end()); } template <> @@ -57,11 +75,13 @@ template constexpr void index_erase_if::operator()( Cont &&cont) const noexcept { - std::erase_if(cont, + std::erase_if(std::forward(cont), [i = std::size_t{}, c = indices.begin(), e = indices.end()]( const auto &) mutable { - return c != e && i++ == *c && (++c, true); + auto &&res = c != e && i++ == *c; + if (res) ++c; + return res; }); } @@ -79,6 +99,8 @@ constexpr void index_erase_if::operator()( first != last; cont[*first++] = std::move(cont[from_ix])) while (--from_ix == from[-1]) --from; + + std::ignore = std::forward(cont); } std::size_t data_source::get_record_count() const @@ -111,11 +133,12 @@ struct data_source::sorter cmp_mea(double lhs, double rhs, na_position na, sort_type sort) { using std::strong_order; - return std::isnan(lhs) != std::isnan(rhs) - ? (na == na_position::last) == std::isnan(rhs) - ? std::weak_ordering::less - : std::weak_ordering::greater - : sort == sort_type::less ? strong_order(lhs, rhs) + if (std::isnan(lhs) != std::isnan(rhs)) + return (na == na_position::last) == std::isnan(rhs) + ? std::weak_ordering::less + : std::weak_ordering::greater; + + return sort == sort_type::less ? strong_order(lhs, rhs) : strong_order(rhs, lhs); } @@ -144,7 +167,7 @@ std::vector data_source::get_sorted_indices( thread_local const sorting_type *sorters_ptr{}; sorters_ptr = &sorters; - return data_source::get_sorted_indices(get_record_count(), + return get_sorted_indices(get_record_count(), [](std::size_t a, std::size_t b) { for (const auto &sorter : *sorters_ptr) { @@ -155,6 +178,7 @@ std::vector data_source::get_sorted_indices( }); } +// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved) void data_source::sort(std::vector &&indices) { std::vector tmp_mea(measures.size()); @@ -392,7 +416,7 @@ data_source::data_source(aggregating_type &&aggregating, const std::vector *filtered, std::size_t record_count) { - auto &[dims, meas] = aggregating; + auto &&[dims, meas] = std::move(aggregating); dimensions.reserve(dims.size()); dimension_names.reserve(dims.size()); @@ -485,9 +509,9 @@ data_source::data_source( dimension_names(copying->dimension_names), dimensions(copying->dimensions) { - if (sorted) { this->sort(std::move(*sorted)); } + if (sorted) { this->sort(*std::move(sorted)); } if (filtered) { - const auto &filt = *filtered; + const auto &filt = *std::move(filtered); std::vector remove_ix; remove_ix.reserve(filt.size()); for (std::size_t i{}; i < filt.size(); ++i) @@ -643,7 +667,7 @@ data_source::dimension_t::get_categories_usage() const } void data_source::dimension_t::remove_unused_categories( - std::vector &&used) + const std::vector &used) { std::vector remap(categories.size()); std::size_t new_size{}; diff --git a/src/dataframe/impl/data_source.h b/src/dataframe/impl/data_source.h index 364c22217..a06e23f45 100644 --- a/src/dataframe/impl/data_source.h +++ b/src/dataframe/impl/data_source.h @@ -15,9 +15,9 @@ namespace Vizzu::dataframe { -enum class series_type { unknown, dimension, measure }; +enum class series_type : std::uint8_t { unknown, dimension, measure }; -enum class error_type { +enum class error_type : std::uint8_t { series_not_found, duplicated_series, wrong_type, @@ -73,7 +73,11 @@ class data_source : public std::enable_shared_from_this contains_nav{std::any_of(this->values.begin(), this->values.end(), is_nav)} - {} + { + std::ignore = std::forward(categories); + std::ignore = std::forward(values); + std::ignore = std::forward(info); + } void add_more_data(std::span categories, std::span values); @@ -96,7 +100,7 @@ class data_source : public std::enable_shared_from_this [[nodiscard]] std::vector get_categories_usage() const; - void remove_unused_categories(std::vector &&used); + void remove_unused_categories(const std::vector &used); }; struct measure_t @@ -114,7 +118,10 @@ class data_source : public std::enable_shared_from_this contains_nan(std::any_of(this->values.begin(), this->values.end(), is_nan)) - {} + { + std::ignore = std::forward(values); + std::ignore = std::forward(info); + } [[nodiscard]] const double &get(std::size_t index) const; diff --git a/src/dataframe/impl/dataframe.cpp b/src/dataframe/impl/dataframe.cpp index 536ff09ab..e1a8a54c4 100644 --- a/src/dataframe/impl/dataframe.cpp +++ b/src/dataframe/impl/dataframe.cpp @@ -1,14 +1,29 @@ #include "dataframe.h" -#include +#include #include -#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include #include +#include +#include -#include "../old/datatable.h" +#include "base/conv/auto_json.h" +#include "base/refl/auto_enum.h" +#include "dataframe/interface.h" +#include "dataframe/old/types.h" // NOLINT(misc-include-cleaner) -#include "aggregators.h" +#include "data_source.h" namespace Vizzu::dataframe { @@ -513,7 +528,7 @@ void dataframe::remove_unused_categories(std::string_view column) & unsafe_get( unsafe_get(source)->get_series(column)) - .second.remove_unused_categories(std::move(usage)); + .second.remove_unused_categories(usage); } void dataframe::change_data(std::size_t record_id, diff --git a/src/dataframe/impl/dataframe.h b/src/dataframe/impl/dataframe.h index 7a859390b..a64b82b99 100644 --- a/src/dataframe/impl/dataframe.h +++ b/src/dataframe/impl/dataframe.h @@ -1,7 +1,7 @@ #ifndef VIZZU_DATAFRAME_DATAFRAME_H #define VIZZU_DATAFRAME_DATAFRAME_H -#include +#include #include "../interface.h" @@ -12,16 +12,16 @@ namespace Vizzu::dataframe class dataframe { - enum class state_type { + enum class state_type : std::uint8_t { modifying, aggregating, sorting, finalized }; - enum class source_type { owning, copying }; + enum class source_type : std::uint8_t { owning, copying }; - enum class state_modification_reason { + enum class state_modification_reason : std::uint8_t { needs_series_type, needs_record_count, needs_sorted_records, @@ -154,8 +154,10 @@ class dataframe [[nodiscard]] const dataframe_interface *as_if() const { + // NOLINTBEGIN(bugprone-casting-through-void) return std::launder(static_cast( static_cast(this))); + // NOLINTEND(bugprone-casting-through-void) } Refl::EnumVariant +#include +#include +#include #include #include +#include +#include +#include +#include #include "impl/dataframe.h" @@ -13,14 +21,18 @@ static_assert(alignof(dataframe) <= align_impl); dataframe &as_impl(dataframe_interface *df) { + // NOLINTBEGIN(bugprone-casting-through-void) return *std::launder( static_cast(static_cast(df->data))); + // NOLINTEND(bugprone-casting-through-void) } const dataframe &as_impl(const dataframe_interface *df) { + // NOLINTBEGIN(bugprone-casting-through-void) return *std::launder(static_cast( static_cast(df->data))); + // NOLINTEND(bugprone-casting-through-void) } std::shared_ptr dataframe_interface::copy( diff --git a/src/dataframe/interface.h b/src/dataframe/interface.h index 591ad4fcc..b14c70b7f 100644 --- a/src/dataframe/interface.h +++ b/src/dataframe/interface.h @@ -1,6 +1,7 @@ #ifndef VIZZU_DATAFRAME_INTERFACE_H #define VIZZU_DATAFRAME_INTERFACE_H +#include #include #include #include @@ -20,7 +21,7 @@ namespace Vizzu::dataframe using cell_value = std::variant; using cell_reference = std::variant; -enum class aggregator_type { +enum class aggregator_type : std::uint8_t { sum, min, max, @@ -30,7 +31,7 @@ enum class aggregator_type { exists }; -enum class sort_type { +enum class sort_type : std::uint8_t { less, greater, natural_less, @@ -38,9 +39,9 @@ enum class sort_type { by_categories }; -enum class na_position { last, first }; +enum class na_position : std::uint8_t { last, first }; -enum class adding_type { +enum class adding_type : std::uint8_t { create_or_add, create_or_throw, create_or_override, diff --git a/src/dataframe/old/datatable.cpp b/src/dataframe/old/datatable.cpp index a1603074a..8b50c5929 100644 --- a/src/dataframe/old/datatable.cpp +++ b/src/dataframe/old/datatable.cpp @@ -1,15 +1,28 @@ #include "datatable.h" +#include #include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include #include "base/conv/auto_json.h" +#include "base/conv/numtostr.h" +#include "base/refl/auto_enum.h" #include "base/text/funcstring.h" #include "chart/options/options.h" -#include "dataframe/impl/aggregators.h" +#include "chart/options/shapetype.h" #include "dataframe/interface.h" +#include "types.h" + namespace Vizzu::Data { diff --git a/src/dataframe/old/datatable.h b/src/dataframe/old/datatable.h index 5c0aaa24b..b9006bfb2 100644 --- a/src/dataframe/old/datatable.h +++ b/src/dataframe/old/datatable.h @@ -14,7 +14,7 @@ namespace Vizzu::Gen { class Options; -enum class ChannelId; +enum class ChannelId : std::uint8_t; } namespace Vizzu::Data diff --git a/src/dataframe/old/types.h b/src/dataframe/old/types.h index 7a2d616e6..af50b92ac 100644 --- a/src/dataframe/old/types.h +++ b/src/dataframe/old/types.h @@ -83,8 +83,8 @@ class Filter template