diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 2efeeee10d..3af7340c28 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -13513,7 +13513,7 @@ bool Plater::up_to_date(bool saved, bool backup) !Slic3r::has_other_changes(backup)); } -void Plater::add_model(bool imperial_units, std::string fname) +bool Plater::add_model(bool imperial_units, std::string fname) { wxArrayString input_files; @@ -13521,7 +13521,7 @@ void Plater::add_model(bool imperial_units, std::string fname) if (fname.empty()) { wxGetApp().import_model(this, input_files); if (input_files.empty()) - return; + return false; for (const auto& file : input_files) paths.emplace_back(into_path(file)); @@ -13565,7 +13565,8 @@ void Plater::add_model(bool imperial_units, std::string fname) auto strategy = LoadStrategy::LoadModel; if (imperial_units) strategy = strategy | LoadStrategy::ImperialUnits; - if (!load_files(paths, strategy, ask_multi).empty()) { + const bool loaded = !load_files(paths, strategy, ask_multi).empty(); + if (loaded) { if (get_project_name() == _L("Untitled") && paths.size() > 0) { boost::filesystem::path full_path(paths[0].string()); @@ -13574,6 +13575,7 @@ void Plater::add_model(bool imperial_units, std::string fname) wxGetApp().mainframe->update_title(); } + return loaded; } void Plater::calib_pa(const Calib_Params& params) @@ -13860,7 +13862,8 @@ void Plater::cut_horizontal(size_t obj_idx, size_t instance_idx, double z, Model } void Plater::_calib_pa_tower(const Calib_Params& params) { - add_model(false, Slic3r::resources_dir() + "/calib/pressure_advance/tower_with_seam.drc"); + if (!add_model(false, Slic3r::resources_dir() + "/calib/pressure_advance/tower_with_seam.drc")) + return; auto& print_config = wxGetApp().preset_bundle->prints.get_edited_preset().config; auto printer_config = &wxGetApp().preset_bundle->printers.get_edited_preset().config; @@ -14100,7 +14103,8 @@ void Plater::calib_temp(const Calib_Params& params) { wxGetApp().mainframe->select_tab(size_t(MainFrame::tp3DEditor)); if (params.mode != CalibMode::Calib_Temp_Tower) return; - add_model(false, Slic3r::resources_dir() + "/calib/temperature_tower/temperature_tower.drc"); + if (!add_model(false, Slic3r::resources_dir() + "/calib/temperature_tower/temperature_tower.drc")) + return; auto printer_config = &wxGetApp().preset_bundle->printers.get_edited_preset().config; auto filament_config = &wxGetApp().preset_bundle->filaments.get_edited_preset().config; auto start_temp = lround(params.start); @@ -14176,7 +14180,8 @@ void Plater::calib_max_vol_speed(const Calib_Params& params) wxGetApp().mainframe->select_tab(size_t(MainFrame::tp3DEditor)); if (params.mode != CalibMode::Calib_Vol_speed_Tower) return; - add_model(false, Slic3r::resources_dir() + "/calib/volumetric_speed/SpeedTestStructure.drc"); + if (!add_model(false, Slic3r::resources_dir() + "/calib/volumetric_speed/SpeedTestStructure.drc")) + return; auto print_config = &wxGetApp().preset_bundle->prints.get_edited_preset().config; auto filament_config = &wxGetApp().preset_bundle->filaments.get_edited_preset().config; @@ -14255,7 +14260,8 @@ void Plater::calib_retraction(const Calib_Params& params) if (params.mode != CalibMode::Calib_Retraction_tower) return; - add_model(false, Slic3r::resources_dir() + "/calib/retraction/retraction_tower.drc"); + if (!add_model(false, Slic3r::resources_dir() + "/calib/retraction/retraction_tower.drc")) + return; auto print_config = &wxGetApp().preset_bundle->prints.get_edited_preset().config; auto filament_config = &wxGetApp().preset_bundle->filaments.get_edited_preset().config; @@ -14314,7 +14320,8 @@ void Plater::calib_VFA(const Calib_Params& params) if (params.mode != CalibMode::Calib_VFA_Tower) return; - add_model(false, Slic3r::resources_dir() + "/calib/vfa/vfa.drc"); + if (!add_model(false, Slic3r::resources_dir() + "/calib/vfa/vfa.drc")) + return; auto print_config = &wxGetApp().preset_bundle->prints.get_edited_preset().config; auto filament_config = &wxGetApp().preset_bundle->filaments.get_edited_preset().config; auto printer_config = &wxGetApp().preset_bundle->printers.get_edited_preset().config; @@ -14359,7 +14366,8 @@ void Plater::calib_input_shaping_freq(const Calib_Params& params) if (params.mode != CalibMode::Calib_Input_shaping_freq) return; - add_model(false, Slic3r::resources_dir() + (params.test_model < 1 ? "/calib/input_shaping/ringing_tower.drc" : "/calib/input_shaping/fast_tower_test.drc")); + if (!add_model(false, Slic3r::resources_dir() + (params.test_model < 1 ? "/calib/input_shaping/ringing_tower.drc" : "/calib/input_shaping/fast_tower_test.drc"))) + return; auto print_config = &wxGetApp().preset_bundle->prints.get_edited_preset().config; auto filament_config = &wxGetApp().preset_bundle->filaments.get_edited_preset().config; auto printer_config = &wxGetApp().preset_bundle->printers.get_edited_preset().config; @@ -14424,7 +14432,8 @@ void Plater::calib_input_shaping_damp(const Calib_Params& params) if (params.mode != CalibMode::Calib_Input_shaping_damp) return; - add_model(false, Slic3r::resources_dir() + (params.test_model < 1 ? "/calib/input_shaping/ringing_tower.drc" : "/calib/input_shaping/fast_tower_test.drc")); + if (!add_model(false, Slic3r::resources_dir() + (params.test_model < 1 ? "/calib/input_shaping/ringing_tower.drc" : "/calib/input_shaping/fast_tower_test.drc"))) + return; auto print_config = &wxGetApp().preset_bundle->prints.get_edited_preset().config; auto filament_config = &wxGetApp().preset_bundle->filaments.get_edited_preset().config; auto printer_config = &wxGetApp().preset_bundle->printers.get_edited_preset().config; @@ -14491,7 +14500,8 @@ void Plater::Calib_Cornering(const Calib_Params& params) const std::string cornering_model_path = params.test_model == 0 ? "/calib/input_shaping/ringing_tower.drc" : (params.test_model == 1 ? "/calib/input_shaping/fast_tower_test.drc" : "/calib/cornering/SCV-V2.drc"); - add_model(false, Slic3r::resources_dir() + cornering_model_path); + if (!add_model(false, Slic3r::resources_dir() + cornering_model_path)) + return; auto print_config = &wxGetApp().preset_bundle->prints.get_edited_preset().config; auto filament_config = &wxGetApp().preset_bundle->filaments.get_edited_preset().config; auto printer_config = &wxGetApp().preset_bundle->printers.get_edited_preset().config; diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 82e56e68e0..b60c0eb242 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -328,7 +328,8 @@ public: bool open_3mf_file(const fs::path &file_path); int get_3mf_file_count(std::vector paths); void add_file(); - void add_model(bool imperial_units = false, std::string fname = ""); + // Returns false when no object was added (e.g. the user cancelled the load dialog). + bool add_model(bool imperial_units = false, std::string fname = ""); void import_zip_archive(); void import_sl1_archive(); void extract_config_from_project();