Match mixed filament swatches to the editor's gradient preview

The sidebar Mixed Filament list, the extruder icons, the color painting
gizmo and the canvas filament bar now show the same bottom-to-top fade the
Edit Mixed Filament preview shows, custom gradient curves included, instead
of a horizontal fade between the two component colours. Ordinary and vendor
multi-colour filaments are drawn exactly as before.
This commit is contained in:
SoftFever
2026-08-23 22:11:49 +08:00
parent ff35dacf4c
commit 4a32a9e066
13 changed files with 429 additions and 133 deletions
+6 -8
View File
@@ -5,6 +5,7 @@
#include <vector>
#include <boost/filesystem/path.hpp>
#include <wx/colour.h>
#include <wx/panel.h>
// BBS
#include <wx/notebook.h>
@@ -607,14 +608,11 @@ public:
std::vector<std::string> get_filament_colors_render_info() const;
std::vector<std::string> get_filament_color_render_type() const;
// Endpoint colours for gradient mixed filaments, so the 3D scene and the paint gizmo can
// draw a two-tone swatch. is_gradient is false for every ordinary filament slot.
struct FilamentGradientInfo {
bool is_gradient = false;
std::array<float, 4> color_from = {0.5f, 0.5f, 0.5f, 1.0f};
std::array<float, 4> color_to = {0.5f, 0.5f, 0.5f, 1.0f};
};
std::vector<FilamentGradientInfo> get_filament_gradient_info() const;
// Per slot, the colours a gradient mixed filament actually prints, sampled bottom (index 0)
// to top, so the sidebar, the paint gizmo and the extruder icons draw the same fade the
// editor previews rather than a straight blend of two endpoints. A slot that is not a
// gradient mixed filament gets an empty ramp. Cached; recomputed when the config changes.
const std::vector<std::vector<wxColour>>& get_filament_gradient_ramps() const;
std::vector<std::string> get_colors_for_color_print(const GCodeProcessorResult* const result = nullptr) const;
void set_global_filament_map_mode(FilamentMapMode mode);