ENH: CLI: set -1 to default value of filament_map

jira: no-jira
Change-Id: I12300737061acd1c3e024a3424d3d46a53cf526f
(cherry picked from commit 190904c68f9ddb49df31d7d7e757d780c7876d6e)
This commit is contained in:
lane.wei 2025-09-28 20:48:44 +08:00 committed by Noisyfox
parent 213aa92f8d
commit 14fed10ce6

View file

@ -5742,6 +5742,7 @@ int CLI::run(int argc, char **argv)
mode = m_extra_config.option<ConfigOptionEnum<FilamentMapMode>>("filament_map_mode")->value;
else
mode = part_plate->get_real_filament_map_mode(m_print_config);
BOOST_LOG_TRIVIAL(info) << boost::format("%1% :filament map mode is %2% ") % __LINE__ %(int)mode;
if (mode < FilamentMapMode::fmmManual) {
std::vector<int> conflict_filament_vector;
for (int index = 0; index < new_extruder_count; index++)
@ -5778,6 +5779,43 @@ int CLI::run(int argc, char **argv)
std::vector<int> filament_maps;
if (m_extra_config.option<ConfigOptionInts>("filament_map")) {
filament_maps = m_extra_config.option<ConfigOptionInts>("filament_map")->values;
int default_value = -1;
bool has_invalid_value = false;
for (int f_index = 0; f_index < filament_maps.size(); f_index++)
{
if (filament_maps[f_index] != -1)
{
if (default_value == -1)
default_value = filament_maps[f_index];
else
continue;
}
else
has_invalid_value = true;
if (has_invalid_value && (default_value != -1))
break;
}
BOOST_LOG_TRIVIAL(info) << boost::format("%1% :filament map default_value %2%, has_invalid_value %3% ") % __LINE__ %default_value %has_invalid_value;
if (has_invalid_value)
{
for (int f_index = 0; f_index < filament_maps.size(); f_index++)
{
if (filament_maps[f_index] == -1)
{
if (default_value != -1) {
filament_maps[f_index] = default_value;
BOOST_LOG_TRIVIAL(info) << boost::format("plate %1% : set filament_map of filament %2% to first value %3%.")% (index + 1) %(f_index+1) %default_value;
}
else {
filament_maps[f_index] = 1;
BOOST_LOG_TRIVIAL(info) << boost::format("plate %1% : set filament_map of filament %2% to default value 1.")% (index + 1) %(f_index+1);
}
}
}
m_extra_config.option<ConfigOptionInts>("filament_map")->values = filament_maps;
}
part_plate->set_filament_maps(filament_maps);
}
else