Files
OrcaSlicer/src/slic3r/GUI/GuiColor.cpp
T
HanifKoh 1a5f91d727 Add Missing Includes Across src/slic3r/GUI (#16048)
* Add Missing Includes Across src/slic3r/GUI

Every GUI source and header now directly includes the headers declaring what it uses, rather than relying on the precompiled header or transitive includes. Generated with clang-tidy misc-include-cleaner, plus one hand edit making CalibrationPanel.hpp self-contained.

* Drop the OS-Specific Includes Added Outside Their Platform Guards

GLib, GTK, D-Bus and POSIX headers are only used inside platform #if blocks, which already include them. Added unconditionally at the top of the file they broke the Windows build.

* Add the clang-tidy Configuration That Generated These Includes

Only misc-include-cleaner's missing-include check, with the headers it must never suggest: per-platform, internal and OS-specific ones that would break other platforms or are not meant to be included directly.

* Match Windows Paths in the clang-tidy Ignore List

Header paths use backslashes on Windows, so every / in a pattern is now [/\\]. The Windows SDK headers are ignored alongside the other OS-specific ones, and the list is one pattern per line. Suggested by @raistlin7447 from a Windows clang-cl run.
2026-10-02 14:56:56 +08:00

47 lines
1.4 KiB
C++

#include "GuiColor.hpp"
#include <wx/colour.h>
#include "libslic3r/Color.hpp"
#include <algorithm>
#include "ColorSpaceConvert.hpp"
namespace Slic3r { namespace GUI {
wxColour convert_to_wxColour(const RGBA &color)
{
auto r = std::clamp((int) (color[0] * 255.f), 0, 255);
auto g = std::clamp((int) (color[1] * 255.f), 0, 255);
auto b = std::clamp((int) (color[2] * 255.f), 0, 255);
auto a = std::clamp((int) (color[3] * 255.f), 0, 255);
wxColour wx_color(r, g, b, a);
return wx_color;
}
RGBA convert_to_rgba(const wxColour &color)
{
RGBA rgba;
rgba[0] = std::clamp(color.Red() / 255.f, 0.f, 1.f);
rgba[1] = std::clamp(color.Green() / 255.f, 0.f, 1.f);
rgba[2] = std::clamp(color.Blue() / 255.f, 0.f, 1.f);
rgba[3] = std::clamp(color.Alpha() / 255.f, 0.f, 1.f);
return rgba;
}
float calc_color_distance(wxColour c1, wxColour c2)
{
float lab[2][3];
RGB2Lab(c1.Red(), c1.Green(), c1.Blue(), &lab[0][0], &lab[0][1], &lab[0][2]);
RGB2Lab(c2.Red(), c2.Green(), c2.Blue(), &lab[1][0], &lab[1][1], &lab[1][2]);
return DeltaE76(lab[0][0], lab[0][1], lab[0][2], lab[1][0], lab[1][1], lab[1][2]);
}
float calc_color_distance(RGBA c1, RGBA c2)
{
float lab[2][3];
RGB2Lab(c1[0], c1[1], c1[2], &lab[0][0], &lab[0][1], &lab[0][2]);
RGB2Lab(c2[0], c2[1], c2[2], &lab[1][0], &lab[1][1], &lab[1][2]);
return DeltaE76(lab[0][0], lab[0][1], lab[0][2], lab[1][0], lab[1][1], lab[1][2]);
}
} }