Add 'export to prusa' menu item

An other way to transfert a config to prusa, with the .3mf file.
It's more mandatory now that there is extrusion_spacing
This commit is contained in:
remi durand 2021-04-25 02:27:02 +02:00
parent 715d58da88
commit b6d278a36f
4 changed files with 19 additions and 7 deletions

View File

@ -814,13 +814,21 @@ size_t ConfigBase::load_from_gcode_string(const char* str)
return num_key_value_pairs;
}
void ConfigBase::save(const std::string &file) const
void ConfigBase::save(const std::string &file, bool to_prusa) const
{
boost::nowide::ofstream c;
c.open(file, std::ios::out | std::ios::trunc);
c << "# " << Slic3r::header_slic3r_generated() << std::endl;
for (const std::string &opt_key : this->keys())
c << opt_key << " = " << this->opt_serialize(opt_key) << std::endl;
if (to_prusa)
for (std::string opt_key : this->keys()) {
std::string value = this->opt_serialize(opt_key);
this->to_prusa(opt_key, value);
if(!opt_key.empty())
c << opt_key << " = " << value << std::endl;
}
else
for (const std::string &opt_key : this->keys())
c << opt_key << " = " << this->opt_serialize(opt_key) << std::endl;
c.close();
}

View File

@ -1923,7 +1923,7 @@ public:
// Returns number of key/value pairs extracted.
size_t load_from_gcode_string(const char* str);
void load(const boost::property_tree::ptree &tree);
void save(const std::string &file) const;
void save(const std::string &file, bool to_prusa = false) const;
// Set all the nullable values to nils.
void null_nullables();

View File

@ -1260,6 +1260,10 @@ void MainFrame::init_menubar_as_editor()
append_menu_item(export_menu, wxID_ANY, _L("Export Config Bundle With Physical Printers") + dots, _L("Export all presets including physical printers to file"),
[this](wxCommandEvent&) { export_configbundle(true); }, "export_config_bundle", nullptr,
[]() {return true; }, this);
export_menu->AppendSeparator();
append_menu_item(export_menu, wxID_ANY, _L("Export to &Prusa Config") + dots, _L("Export current configuration to file, with only settings compatible with PrusaSlicer"),
[this](wxCommandEvent&) { export_config(true); }, "export_config", nullptr,
[]() {return true; }, this);
append_submenu(fileMenu, export_menu, wxID_ANY, _L("&Export"), "");
append_menu_item(fileMenu, wxID_ANY, _L("Ejec&t SD card / Flash drive") + dots + "\tCtrl+T", _L("Eject SD card / Flash drive after the G-code was exported to it."),
@ -1717,7 +1721,7 @@ void MainFrame::repair_stl()
Slic3r::GUI::show_info(this, L("Your file was repaired."), L("Repair"));
}
void MainFrame::export_config()
void MainFrame::export_config(bool to_prusa)
{
// Generate a cummulative configuration for the selected print, filaments and printer.
auto config = wxGetApp().preset_bundle->full_config();
@ -1738,7 +1742,7 @@ void MainFrame::export_config()
if (!file.IsEmpty()) {
wxGetApp().app_config->update_config_dir(get_dir_name(file));
m_last_config = file;
config.save(file.ToUTF8().data());
config.save(file.ToUTF8().data(), to_prusa);
}
}

View File

@ -188,7 +188,7 @@ public:
void quick_slice(const int qs = qsUndef);
void reslice_now();
void repair_stl();
void export_config();
void export_config(bool to_prusa = false);
// Query user for the config file and open it.
void load_config_file();
// Open a config file. Return true if loaded.