mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-25 07:34:03 -06:00
Fixes to storing and loading configs from AMF/3MF.
This commit is contained in:
parent
e529315ef9
commit
041de161a9
14 changed files with 53 additions and 67 deletions
|
@ -596,8 +596,7 @@ void MainFrame::load_config_file(wxString file/* = wxEmptyString*/)
|
|||
// if (Slic3r::GUI::catch_error(this))
|
||||
// return;
|
||||
}
|
||||
for (auto tab : m_options_tabs )
|
||||
tab.second->load_current_preset();
|
||||
wxGetApp().load_current_presets();
|
||||
wxGetApp().app_config->update_config_dir(get_dir_name(file));
|
||||
m_last_config = file;
|
||||
}
|
||||
|
@ -659,8 +658,7 @@ void MainFrame::load_configbundle(wxString file/* = wxEmptyString, const bool re
|
|||
}
|
||||
|
||||
// Load the currently selected preset into the GUI, update the preset selection box.
|
||||
for (auto tab : m_options_tabs)
|
||||
tab.second->load_current_preset();
|
||||
wxGetApp().load_current_presets();
|
||||
|
||||
const auto message = wxString::Format(_(L("%d presets successfully imported.")), presets_imported);
|
||||
Slic3r::GUI::show_info(this, message, "Info");
|
||||
|
|
|
@ -1154,10 +1154,10 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path> &input_
|
|||
{
|
||||
DynamicPrintConfig config_loaded;
|
||||
model = Slic3r::Model::read_from_archive(path.string(), &config_loaded, false);
|
||||
// Based on the printer technology field found in the loaded config, select the base for the config,
|
||||
PrinterTechnology printer_technology = Preset::printer_technology(config_loaded);
|
||||
if (! config_loaded.empty()) {
|
||||
config.apply(printer_technology == ptFFF ?
|
||||
// Based on the printer technology field found in the loaded config, select the base for the config,
|
||||
PrinterTechnology printer_technology = Preset::printer_technology(config_loaded);
|
||||
config.apply(printer_technology == ptFFF ?
|
||||
static_cast<const ConfigBase&>(FullPrintConfig::defaults()) :
|
||||
static_cast<const ConfigBase&>(SLAFullPrintConfig::defaults()));
|
||||
// and place the loaded config over the base.
|
||||
|
@ -1167,8 +1167,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path> &input_
|
|||
if (! config.empty()) {
|
||||
Preset::normalize(config);
|
||||
wxGetApp().preset_bundle->load_config_model(filename.string(), std::move(config));
|
||||
for (const auto &kv : main_frame->options_tabs())
|
||||
kv.second->load_current_preset();
|
||||
wxGetApp().load_current_presets();
|
||||
}
|
||||
wxGetApp().app_config->update_config_dir(path.parent_path().string());
|
||||
} else {
|
||||
|
@ -2117,7 +2116,8 @@ void Plater::export_amf()
|
|||
wxString path = dialog->GetPath();
|
||||
auto path_cstr = path.c_str();
|
||||
|
||||
if (Slic3r::store_amf(path_cstr, &p->model, &p->print, dialog->get_checkbox_value())) {
|
||||
DynamicPrintConfig cfg = wxGetApp().preset_bundle->full_config();
|
||||
if (Slic3r::store_amf(path_cstr, &p->model, dialog->get_checkbox_value() ? &cfg : nullptr)) {
|
||||
// Success
|
||||
p->statusbar()->set_status_text(wxString::Format(_(L("AMF file exported to %s")), path));
|
||||
} else {
|
||||
|
@ -2136,7 +2136,8 @@ void Plater::export_3mf()
|
|||
wxString path = dialog->GetPath();
|
||||
auto path_cstr = path.c_str();
|
||||
|
||||
if (Slic3r::store_3mf(path_cstr, &p->model, &p->print, dialog->get_checkbox_value())) {
|
||||
DynamicPrintConfig cfg = wxGetApp().preset_bundle->full_config();
|
||||
if (Slic3r::store_3mf(path_cstr, &p->model, dialog->get_checkbox_value() ? &cfg : nullptr)) {
|
||||
// Success
|
||||
p->statusbar()->set_status_text(wxString::Format(_(L("3MF file exported to %s")), path));
|
||||
} else {
|
||||
|
|
|
@ -618,18 +618,6 @@ void PresetBundle::load_config_file(const std::string &path)
|
|||
}
|
||||
}
|
||||
|
||||
void PresetBundle::load_config_string(const char* str, const char* source_filename)
|
||||
{
|
||||
if (str != nullptr)
|
||||
{
|
||||
DynamicPrintConfig config;
|
||||
config.apply(FullPrintConfig::defaults());
|
||||
config.load_from_gcode_string(str);
|
||||
Preset::normalize(config);
|
||||
load_config_file_config((source_filename == nullptr) ? "" : source_filename, true, std::move(config));
|
||||
}
|
||||
}
|
||||
|
||||
// Load a config file from a boost property_tree. This is a private method called from load_config_file.
|
||||
void PresetBundle::load_config_file_config(const std::string &name_or_path, bool is_external, DynamicPrintConfig &&config)
|
||||
{
|
||||
|
@ -677,7 +665,7 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
|
|||
compatible_printers_condition = compatible_printers_condition_values[idx];
|
||||
if (is_external)
|
||||
presets.load_external_preset(name_or_path, name,
|
||||
config.opt_string((i_group == 0) ? ((printer_technology == ptFFF) ? "print_settings_id" : "sla_material_id") : "printer_settings_id", true),
|
||||
config.opt_string((i_group == 0) ? ((printer_technology == ptFFF) ? "print_settings_id" : "sla_material_settings_id") : "printer_settings_id", true),
|
||||
config);
|
||||
else
|
||||
presets.load_preset(presets.path_from_name(name), name, config).save();
|
||||
|
|
|
@ -84,11 +84,6 @@ public:
|
|||
// If the file is loaded successfully, its print / filament / printer profiles will be activated.
|
||||
void load_config_file(const std::string &path);
|
||||
|
||||
// Load an external config source containing the print, filament and printer presets.
|
||||
// The given string must contain the full set of parameters (same as those exported to gcode).
|
||||
// If the string is parsed successfully, its print / filament / printer profiles will be activated.
|
||||
void load_config_string(const char* str, const char* source_filename = nullptr);
|
||||
|
||||
// Load a config bundle file, into presets and store the loaded presets into separate files
|
||||
// of the local configuration directory.
|
||||
// Load settings into the provided settings instance.
|
||||
|
|
|
@ -108,7 +108,7 @@ RammingPanel::RammingPanel(wxWindow* parent, const std::string& parameters)
|
|||
m_widget_time->Bind(wxEVT_CHAR,[](wxKeyEvent&){}); // do nothing - prevents the user to change the value
|
||||
m_widget_volume->Bind(wxEVT_CHAR,[](wxKeyEvent&){}); // do nothing - prevents the user to change the value
|
||||
Bind(EVT_WIPE_TOWER_CHART_CHANGED,[this](wxCommandEvent&) {m_widget_volume->SetValue(m_chart->get_volume()); m_widget_time->SetValue(m_chart->get_time());} );
|
||||
Refresh(this);
|
||||
Refresh(true); // erase background
|
||||
}
|
||||
|
||||
void RammingPanel::line_parameters_changed() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue