File indexing completed on 2025-01-18 09:11:15
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include <array>
0012 #include <filesystem>
0013 #include <string_view>
0014
0015 namespace Acts {
0016
0017
0018
0019 struct Color {
0020
0021 Color() = default;
0022 Color(const Color&) = default;
0023 Color(Color&&) = default;
0024 Color& operator=(const Color&) = default;
0025 Color& operator=(Color&&) = default;
0026
0027
0028
0029
0030
0031 constexpr Color(int r, int g, int b) : rgb{r, g, b} {}
0032
0033
0034
0035 constexpr explicit Color(std::array<int, 3> values) : rgb(values) {}
0036
0037
0038
0039 constexpr explicit Color(std::array<double, 3> values) {
0040 rgb[0] = static_cast<int>(values[0] * 255);
0041 rgb[1] = static_cast<int>(values[1] * 255);
0042 rgb[2] = static_cast<int>(values[2] * 255);
0043 }
0044
0045
0046
0047
0048
0049 constexpr Color(double r, double g, double b)
0050 : Color{std::array<double, 3>{r, g, b}} {}
0051
0052 private:
0053 constexpr static int hexToInt(std::string_view hex) {
0054 constexpr auto hexCharToInt = [](char c) {
0055 if (c >= '0' && c <= '9') {
0056 return c - '0';
0057 } else if (c >= 'a' && c <= 'f') {
0058 return c - 'a' + 10;
0059 } else if (c >= 'A' && c <= 'F') {
0060 return c - 'A' + 10;
0061 } else {
0062 throw std::invalid_argument("Invalid hex character");
0063 }
0064 };
0065
0066 int value = 0;
0067 for (char c : hex) {
0068 value = (value << 4) + hexCharToInt(c);
0069 }
0070 return value;
0071 };
0072
0073 public:
0074
0075
0076 constexpr explicit Color(std::string_view hex) {
0077 if (hex[0] == '#' && hex.size() == 7) {
0078 rgb[0] = hexToInt(hex.substr(1, 2));
0079 rgb[1] = hexToInt(hex.substr(3, 2));
0080 rgb[2] = hexToInt(hex.substr(5, 2));
0081 } else {
0082 throw std::invalid_argument{
0083 "Invalid hex color format. Expected format: #RRGGBB"};
0084 }
0085 }
0086
0087
0088
0089
0090 int operator[](unsigned int i) const { return rgb.at(i); }
0091
0092
0093
0094
0095 int& operator[](unsigned int i) { return rgb.at(i); }
0096
0097
0098
0099
0100
0101 friend bool operator==(const Color& lhs, const Color& rhs) = default;
0102
0103
0104
0105
0106 friend std::ostream& operator<<(std::ostream& os, const Color& color) {
0107 os << "[" << color.rgb[0] << ", " << color.rgb[1] << ", " << color.rgb[2]
0108 << "]";
0109 return os;
0110 }
0111
0112 std::array<int, 3> rgb{};
0113 };
0114
0115 constexpr Color s_defaultSurfaceColor{"#0000aa"};
0116 constexpr Color s_defaultPortalColor{"#308c48"};
0117 constexpr Color s_defaultVolumColor{"#ffaa00"};
0118
0119
0120
0121 struct ViewConfig {
0122
0123 bool visible = true;
0124
0125 Color color = {250, 0, 0};
0126
0127 double offset = 0.1;
0128
0129 double lineThickness = 0.15;
0130
0131 double surfaceThickness = 0.15;
0132
0133 unsigned int quarterSegments = 72;
0134
0135 bool triangulate = false;
0136
0137 std::filesystem::path outputName = std::filesystem::path("");
0138 };
0139
0140 static const ViewConfig s_viewSurface = {.color = {170, 170, 170}};
0141 static const ViewConfig s_viewPortal = {.color = Color{"#308c48"}};
0142 static const ViewConfig s_viewSensitive = {.color = {0, 180, 240}};
0143 static const ViewConfig s_viewPassive = {.color = {240, 280, 0}};
0144 static const ViewConfig s_viewVolume = {.color = {220, 220, 0}};
0145 static const ViewConfig s_viewGrid = {.color = {220, 0, 0}};
0146 static const ViewConfig s_viewLine = {.color = {0, 0, 220}};
0147
0148 }