mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-08 16:21:14 +00:00
Size a Project's Mixed-Colour Metadata to the Filaments in the CLI (#16247)
The mixed-colour metadata options are parallel per-slot arrays in the project config. A project saved before they were sized per slot stores a single value for the gradient ones, and one saved before they existed stores none. The GUI sizes all seven to the filament count when it opens a project; the CLI kept the stored arrays and exported one-element defaults for absent ones, so a project it exported carried one-element arrays where the GUI writes one entry per filament. Slicing is unaffected, every reader treats a missing entry as not mixed / no gradient, but the GUI-vs-CLI comparison reported the four gradient keys on every mixed-filament project. The resize helper moves from PresetBundle.cpp, where it was file-local, to PrintConfig.cpp next to set_filament_dev_options(). It creates an option the config lacks before sizing it, a no-op for the bundle's project config where all seven always exist. The CLI calls it with its filament count once the project and loaded filaments are merged, after the check that every mixed slot has a filament of its own.
This commit is contained in:
@@ -863,3 +863,23 @@ TEST_CASE("The device drying options are rebuilt as each filament's values in sl
|
||||
set_filament_dev_options(config, {&two_values, &no_value});
|
||||
REQUIRE(config.option<ConfigOptionStrings>("filament_dev_ams_drying_ams_limitations")->values == std::vector<std::string>({"1", "0", ""}));
|
||||
}
|
||||
|
||||
TEST_CASE("The mixed filament metadata is sized to the filament count", "[Config]")
|
||||
{
|
||||
DynamicPrintConfig config;
|
||||
config.option<ConfigOptionBools>("filament_is_mixed", true)->values = {false, false, true};
|
||||
config.option<ConfigOptionStrings>("filament_mixed_components", true)->values = {"", "", "1,2"};
|
||||
config.option<ConfigOptionBools>("filament_mixed_gradient", true)->values = {false};
|
||||
config.option<ConfigOptionStrings>("filament_mixed_gradient_range", true)->values = {""};
|
||||
|
||||
resize_mixed_filament_metadata(config, 3, 3);
|
||||
REQUIRE(config.option<ConfigOptionBools>("filament_is_mixed")->values == std::vector<unsigned char>({false, false, true}));
|
||||
REQUIRE(config.option<ConfigOptionStrings>("filament_mixed_components")->values == std::vector<std::string>({"", "", "1,2"}));
|
||||
REQUIRE(config.option<ConfigOptionBools>("filament_mixed_gradient")->values == std::vector<unsigned char>({false, false, false}));
|
||||
REQUIRE(config.option<ConfigOptionStrings>("filament_mixed_gradient_range")->values == std::vector<std::string>({"", "", ""}));
|
||||
REQUIRE(config.option<ConfigOptionStrings>("filament_mixed_gradient_curve")->values == std::vector<std::string>({"", "", ""}));
|
||||
|
||||
resize_mixed_filament_metadata(config, 2, 4);
|
||||
REQUIRE(config.option<ConfigOptionBools>("filament_is_mixed")->values == std::vector<unsigned char>({false, false, false, false}));
|
||||
REQUIRE(config.option<ConfigOptionStrings>("filament_mixed_components")->values == std::vector<std::string>({"", "", "", ""}));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user