From 42b1e5a1ea0f58aeae31bdeff993ee9b7b7fb8eb Mon Sep 17 00:00:00 2001 From: Konstantin Leontev Date: Fri, 6 Dec 2024 16:26:45 +0000 Subject: [PATCH] [bos #43815][EDF 31529] Dependency of libGEOMEngine. Removed Qt dependencies. --- src/GEOM/CMakeLists.txt | 2 -- src/GEOM/GEOM_ColorUtils.cxx | 66 +++++++++++++++++++++++++++++------- 2 files changed, 53 insertions(+), 15 deletions(-) diff --git a/src/GEOM/CMakeLists.txt b/src/GEOM/CMakeLists.txt index 989788e07..5a1a73e86 100644 --- a/src/GEOM/CMakeLists.txt +++ b/src/GEOM/CMakeLists.txt @@ -26,7 +26,6 @@ INCLUDE_DIRECTORIES( ${KERNEL_INCLUDE_DIRS} ${PROJECT_SOURCE_DIR}/src/SKETCHER ${CMAKE_CURRENT_SOURCE_DIR} - ${PROJECT_BINARY_DIR}/idl ) # additional preprocessor / compiler flags @@ -41,7 +40,6 @@ SET(_link_LIBRARIES ${KERNEL_SALOMELocalTrace} ${KERNEL_OpUtil} GEOMSketcher - ${QT_LIBRARIES} ) # --- headers --- diff --git a/src/GEOM/GEOM_ColorUtils.cxx b/src/GEOM/GEOM_ColorUtils.cxx index b8a6a9d1a..b7f9a3081 100644 --- a/src/GEOM/GEOM_ColorUtils.cxx +++ b/src/GEOM/GEOM_ColorUtils.cxx @@ -22,21 +22,56 @@ #include "GEOM_ColorUtils.hxx" -#include -#include +#include +#include +#include +namespace +{ + struct ColorRGB + { + double r{0.0}; + double g{0.0}; + double b{0.0}; + }; + + ColorRGB fromHsv(const int h, const int s, const int v) + { + const double hh = h / 60.0; + const double ss = s / 255.0; + const double vv = v / 255.0; + + const int i = static_cast(std::floor(hh)) % 6; + const double f = hh - std::floor(hh); + const double p = vv * (1.0 - ss); + const double q = vv * (1.0 - f * ss); + const double t = vv * (1.0 - (1.0 - f) * ss); + + switch (i) + { + case 0: return { vv, t, p }; + case 1: return { q, vv, p }; + case 2: return { p, vv, t }; + case 3: return { p, q, vv }; + case 4: return { t, p, vv }; + case 5: return { vv, p, q }; + default: return { 0.0, 0.0, 0.0 }; + } + } +} SALOMEDS::Color GEOM_ColorUtils::getPredefinedUniqueColor() { - static QList colors = []() { - QList tempColors; + static const std::vector colors = []() + { + std::vector tempColors; for (int s = 0; s < 2; s++) { - for (int v = 100; v >= 40; v = v - 20) + for (int v = 100; v >= 40; v -= 20) { - for (int h = 0; h < 359; h = h + 60) + for (int h = 0; h < 359; h += 60) { - tempColors.append(QColor::fromHsv(h, 255 - s * 127, v * 255 / 100)); + tempColors.push_back(fromHsv(h, 255 - s * 127, v * 255 / 100)); } } } @@ -45,17 +80,22 @@ SALOMEDS::Color GEOM_ColorUtils::getPredefinedUniqueColor() static int currentColor = randomize(colors.size()); - SALOMEDS::Color color; - color.R = (double)colors[currentColor].red() / 255.0; - color.G = (double)colors[currentColor].green() / 255.0; - color.B = (double)colors[currentColor].blue() / 255.0; + const SALOMEDS::Color color + { + colors[currentColor].r, + colors[currentColor].g, + colors[currentColor].b + }; - currentColor = (currentColor+1) % colors.count(); + currentColor = (currentColor + 1) % colors.size(); return color; } int GEOM_ColorUtils::randomize(int size) { - return QRandomGenerator::global()->bounded(size); + std::random_device rd; + std::mt19937 gen(rd()); + std::uniform_int_distribution<> dis(0, size - 1); + return dis(gen); } \ No newline at end of file