Fix + Support 'Default' filament option (index 0) (#13887)

* Support 'Default' filament option (index 0)

Treat filament index 0 as the new "Default" (use active object/part filament) instead of using 1. Update config defaults and tooltips for wall/sparse/solid infill filament options (min/default -> 0, tooltip explains "Default"). Adjust normalization and propagation logic to respect explicit feature overrides and only apply base extruder when feature values are zero; only copy sparse->solid infill when sparse > 0. Introduce FeatureFilamentOverrideMask and clamp_feature_filament_to_valid to resolve and clamp feature filaments. Update UI lists and selection behavior to expose a "Default" entry and handle zero-based indices in PartPlate and Plater.

* enable_filament_for_features option

Co-Authored-By: LixNix <105106115+lixnix@users.noreply.github.com>

* \n

* Allow wipe_tower_filament to equal nozzle count

Relax the assertion in Print::extruders to permit wipe_tower_filament == config().nozzle_diameter.size(). The configuration value is 1-based and the code subtracts 1 when pushing the extruder index, so equality should be valid and selecting the last nozzle should not trigger an assertion.

* Revert "Allow wipe_tower_filament to equal nozzle count"

This reverts commit 2c976574327a8bcdc74a1b296bf1aaff7752a94e.

* Revert "enable_filament_for_features option"

This reverts commit 01c13baeddb8e26793f752deab788ee4d086975b.

* Migrate legacy feature filament defaults

Add migration logic to convert legacy feature filament selections from 1 to 0 for older 3mf files. Introduces a local migrate_legacy_feature_filament_defaults lambda in src/OrcaSlicer.cpp and src/slic3r/GUI/Plater.cpp that scans keys (wall_filament, sparse_infill_filament, solid_infill_filament, support_filament, support_interface_filament) on configs/objects/volumes, updates values, counts conversions and logs the result. Also adds a Semver check for "2.4.0-dev" in OrcaSlicer to trigger the migration for files older than that version. This preserves expected default filament selections when loading older project files.

* Update OrcaSlicer.cpp

* Extract migration helper to ConfigMigrations

Centralize legacy feature-filament default migration by moving the duplicated lambda into ConfigMigrations::migrate_legacy_feature_filament_defaults (src/libslic3r/Config.cpp) and declaring it in Config.hpp. Update OrcaSlicer.cpp and slic3r/GUI/Plater.cpp to call the new function instead of inline lambdas. The helper converts specific feature filament keys (wall_filament, sparse_infill_filament, solid_infill_filament, support_filament, support_interface_filament) from int 1 to 0 and returns the count of conversions to avoid duplicated migration logic.

* Remove DynamicFilamentList1Based and consolidate lists

Delete the specialized DynamicFilamentList1Based struct and its global instance. Update Choice registrations to use the single dynamic_filament_list for wall, sparse_infill and solid_infill filaments, and remove the extra update call for the removed instance. This consolidates filament choice handling and removes duplicated logic in Plater.cpp.

* move it

* fix objects

* Update Config.hpp

* Update profiles
This commit is contained in:
Ian Bassi
2026-05-28 23:54:26 -03:00
committed by GitHub
parent 6b0f06dba7
commit 948e88a1dd
95 changed files with 433 additions and 386 deletions

View File

@@ -1591,7 +1591,7 @@ int CLI::run(int argc, char **argv)
record_exit_reson(outfile_dir, CLI_FILE_VERSION_NOT_SUPPORTED, 0, cli_errors[CLI_FILE_VERSION_NOT_SUPPORTED], sliced_info);
flush_and_exit(CLI_FILE_VERSION_NOT_SUPPORTED);
}
Semver old_version(1, 5, 9), old_version2(1, 5, 9), old_version3(2, 0, 0), old_version4(2, 2, 0);
Semver old_version(1, 5, 9), old_version2(1, 5, 9), old_version3(2, 0, 0), old_version4(2, 2, 0), old_version5("2.4.0");
if ((file_version < old_version) && !config.empty()) {
translate_old = true;
BOOST_LOG_TRIVIAL(info) << boost::format("old 3mf version %1%, need to translate")%file_version.to_string();
@@ -1606,6 +1606,19 @@ int CLI::run(int argc, char **argv)
BOOST_LOG_TRIVIAL(info) << boost::format("old 3mf version %1%, need to set enable_wrapping_detection to false")%file_version.to_string();
}
if ((file_version < old_version5) && !config.empty()) {
int converted_count = ConfigMigrations::migrate_legacy_feature_filament_defaults(config);
for (ModelObject *model_object : model.objects) {
converted_count += ConfigMigrations::migrate_legacy_feature_filament_defaults(model_object->config);
for (ModelVolume *model_volume : model_object->volumes)
converted_count += ConfigMigrations::migrate_legacy_feature_filament_defaults(model_volume->config);
}
if (converted_count > 0) {
BOOST_LOG_TRIVIAL(info) << boost::format("old 3mf version %1%, migrated %2% feature filament selections from 1 to 0 (Default)") % file_version.to_string() % converted_count;
}
}
if (normative_check) {
ConfigOptionStrings* postprocess_scripts = config.option<ConfigOptionStrings>("post_process");
if (postprocess_scripts) {