FIX: wrong wipe tower when open 3mf file

1.wipe tower pos in 3mf was overwritten by default pos when opening 3mf
with a different printer profile.This patch fix it

jira: STUDIO-5890

Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Change-Id: I12e5d4b80a0ad86194db0682c1763ba4a9492521
This commit is contained in:
xun.zhang 2024-05-08 16:55:18 +08:00 committed by Lane.Wei
parent afd647d764
commit 1ceaabea5c
1 changed files with 21 additions and 0 deletions

View File

@ -3850,6 +3850,16 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
//always load config
{
// BBS: save the wipe tower pos in file here, will be used later
ConfigOptionFloats* wipe_tower_x_opt = config.opt<ConfigOptionFloats>("wipe_tower_x");
ConfigOptionFloats* wipe_tower_y_opt = config.opt<ConfigOptionFloats>("wipe_tower_y");
std::optional<ConfigOptionFloats>file_wipe_tower_x;
std::optional<ConfigOptionFloats>file_wipe_tower_y;
if (wipe_tower_x_opt)
file_wipe_tower_x = *wipe_tower_x_opt;
if (wipe_tower_y_opt)
file_wipe_tower_y = *wipe_tower_y_opt;
preset_bundle->load_config_model(filename.string(), std::move(config), file_version);
ConfigOption* bed_type_opt = preset_bundle->project_config.option("curr_bed_type");
@ -3928,6 +3938,17 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
// when for extruder colors are used filament colors
q->on_filaments_change(preset_bundle->filament_presets.size());
is_project_file = true;
//BBS: rewrite wipe tower pos stored in 3mf file , the code above should be seriously reconsidered
{
DynamicConfig& proj_cfg = wxGetApp().preset_bundle->project_config;
ConfigOptionFloats* wipe_tower_x = proj_cfg.opt<ConfigOptionFloats>("wipe_tower_x");
ConfigOptionFloats* wipe_tower_y = proj_cfg.opt<ConfigOptionFloats>("wipe_tower_y");
if (file_wipe_tower_x)
*wipe_tower_x = *file_wipe_tower_x;
if (file_wipe_tower_y)
*wipe_tower_y = *file_wipe_tower_y;
}
}
}
if (!silence) wxGetApp().app_config->update_config_dir(path.parent_path().string());