Add a menu option to import prusa config.

Add infill_anchor_max==0 => not connected if from prusa config
supermerill/SuperSlicer#1705
This commit is contained in:
supermerill 2021-10-27 04:08:15 +02:00
parent 003a0dba07
commit d981097cc3
11 changed files with 218 additions and 50 deletions

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 23.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve">
<g id="export_x5F_config">
<path fill="#808080" d="M14.22,6.61c-0.25-0.12-0.52-0.43-0.6-0.68s-0.32-1.09-0.23-1.35l0.12-0.35c0.09-0.26,0-0.63-0.2-0.83
L12.6,2.7c-0.19-0.19-0.57-0.28-0.83-0.2l-0.35,0.12c-0.26,0.09-0.67,0.06-0.91-0.05s-1-0.54-1.12-0.79L9.22,1.45
C9.1,1.2,8.77,1,8.5,1h-1C7.22,1,6.9,1.2,6.78,1.45L6.61,1.78C6.49,2.02,6.18,2.3,5.93,2.38S4.84,2.7,4.58,2.62L4.23,2.5
C3.97,2.41,3.6,2.5,3.4,2.7L2.7,3.4C2.5,3.6,2.41,3.97,2.5,4.23l0.12,0.35C2.7,4.84,2.68,5.25,2.57,5.49s-0.54,1-0.79,1.12
L1.45,6.78C1.2,6.9,1,7.22,1,7.5v1c0,0.27,0.2,0.6,0.45,0.72l0.33,0.17c0.25,0.12,0.52,0.43,0.6,0.68s0.32,1.09,0.23,1.35
L2.5,11.77c-0.09,0.26,0,0.63,0.2,0.83L3.4,13.3c0.19,0.19,0.57,0.28,0.83,0.2l0.35-0.12c0.26-0.09,0.67-0.06,0.91,0.05
s1,0.54,1.12,0.79l0.17,0.33C6.9,14.8,7.22,15,7.5,15h1c0.27,0,0.6-0.2,0.72-0.45l0.17-0.33c0.12-0.25,0.43-0.52,0.68-0.6
s1.09-0.32,1.35-0.23l0.35,0.12c0.26,0.09,0.63,0,0.83-0.2l0.71-0.71c0.19-0.19,0.28-0.57,0.2-0.83l-0.12-0.35
c-0.09-0.26-0.06-0.67,0.05-0.91s0.54-1,0.79-1.12l0.33-0.17C14.8,9.1,15,8.77,15,8.5v-1c0-0.28-0.2-0.6-0.45-0.72L14.22,6.61z
M8,13c-2.76,0-5-2.24-5-5s2.24-5,5-5s5,2.24,5,5S10.76,13,8,13z"/>
<path fill="#2172eb" d="M11.65,8.35c0.19-0.19,0.19-0.51,0-0.71L8.92,4.92C8.73,4.73,8.57,4.8,8.57,5.07v1.29
c0,0.28-0.22,0.5-0.5,0.5H4.5C4.22,6.86,4,7.08,4,7.36v1.29c0,0.27,0.22,0.5,0.5,0.5h3.57c0.28,0,0.5,0.22,0.5,0.5v1.29
c0,0.27,0.16,0.34,0.35,0.15L11.65,8.35z"/>
</g>
<g id="prusa_logo" transform="matrix(0.01746785,0,0,0.01746785,-2.5333011,3.4006166)">
<path fill="#363636" d="m 599.3,186.8 c -93.9,-93.9 -246.1,-93.9 -340,0 -93.9,93.9 -93.9,246.1 0,340 z"/>
<path fill="#ed6b21" d="m 202.7,612.5 c 93.9,93.9 246.1,93.9 340,0 93.9,-93.9 93.9,-246.1 0,-340" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 23.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve">
<g id="import_x5F_config">
<g>
<path fill="#808080" d="M14.22,6.61c-0.25-0.12-0.52-0.43-0.6-0.68s-0.32-1.09-0.23-1.35l0.12-0.35c0.09-0.26,0-0.63-0.2-0.83
L12.6,2.7c-0.19-0.19-0.57-0.28-0.83-0.2l-0.35,0.12c-0.26,0.09-0.67,0.06-0.91-0.05s-1-0.54-1.12-0.79L9.22,1.45
C9.1,1.2,8.77,1,8.5,1h-1C7.22,1,6.9,1.2,6.78,1.45L6.61,1.78C6.49,2.02,6.18,2.3,5.93,2.38S4.84,2.7,4.58,2.62L4.23,2.5
C3.97,2.41,3.6,2.5,3.4,2.7L2.7,3.4C2.5,3.6,2.41,3.97,2.5,4.23l0.12,0.35C2.7,4.84,2.68,5.25,2.57,5.49s-0.54,1-0.79,1.12
L1.45,6.78C1.2,6.9,1,7.22,1,7.5v1c0,0.27,0.2,0.6,0.45,0.72l0.33,0.17c0.25,0.12,0.52,0.43,0.6,0.68s0.32,1.09,0.23,1.35
L2.5,11.77c-0.09,0.26,0,0.63,0.2,0.83L3.4,13.3c0.19,0.19,0.57,0.28,0.83,0.2l0.35-0.12c0.26-0.09,0.67-0.06,0.91,0.05
s1,0.54,1.12,0.79l0.17,0.33C6.9,14.8,7.22,15,7.5,15h1c0.27,0,0.6-0.2,0.72-0.45l0.17-0.33c0.12-0.25,0.43-0.52,0.68-0.6
s1.09-0.32,1.35-0.23l0.35,0.12c0.26,0.09,0.63,0,0.83-0.2l0.71-0.71c0.19-0.19,0.28-0.57,0.2-0.83l-0.12-0.35
c-0.09-0.26-0.06-0.67,0.05-0.91s0.54-1,0.79-1.12l0.33-0.17C14.8,9.1,15,8.77,15,8.5v-1c0-0.28-0.2-0.6-0.45-0.72L14.22,6.61z
M8,13c-2.76,0-5-2.24-5-5s2.24-5,5-5s5,2.24,5,5S10.76,13,8,13z"/>
</g>
<g>
<path fill="#2172eb" d="M8,12c-0.55,0-1-0.45-1-1V5c0-0.55,0.45-1,1-1s1,0.45,1,1v6C9,11.55,8.55,12,8,12z"/>
</g>
<g>
<path fill="#2172eb" d="M11,9H5C4.45,9,4,8.55,4,8s0.45-1,1-1h6c0.55,0,1,0.45,1,1S11.55,9,11,9z"/>
</g>
</g>
<g id="prusa_logo" transform="matrix(0.01746785,0,0,0.01746785,-2.5333011,3.4006166)">
<path fill="#363636" d="m 599.3,186.8 c -93.9,-93.9 -246.1,-93.9 -340,0 -93.9,93.9 -93.9,246.1 0,340 z"/>
<path fill="#ed6b21" d="m 202.7,612.5 c 93.9,93.9 246.1,93.9 340,0 93.9,-93.9 93.9,-246.1 0,-340" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 23.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve">
<g id="import_x5F_config_x5F_bundle">
<g>
<g>
<path fill="#808080" d="M1.2,12.61c0.11,0.08,0.21,0.22,0.23,0.31c0.02,0.09,0.04,0.43-0.03,0.55s-0.05,0.31,0.03,0.42l0.12,0.17
c0.08,0.11,0.25,0.19,0.39,0.17c0.13-0.02,0.3,0.01,0.38,0.06s0.33,0.28,0.37,0.41c0.04,0.13,0.18,0.25,0.32,0.27l0.21,0.04
c0.14,0.02,0.31-0.05,0.39-0.16s0.22-0.21,0.31-0.23c0.09-0.02,0.43-0.04,0.55,0.03c0.12,0.06,0.31,0.05,0.42-0.03l0.17-0.12
c0.11-0.08,0.19-0.25,0.17-0.39c-0.02-0.13,0.01-0.3,0.06-0.38s0.28-0.33,0.41-0.37c0.13-0.04,0.25-0.18,0.27-0.32l0.04-0.21
c0.02-0.14-0.05-0.31-0.16-0.39c-0.11-0.08-0.21-0.22-0.23-0.31c-0.02-0.09-0.04-0.43,0.03-0.55c0.06-0.12,0.05-0.31-0.03-0.42
L5.5,10.98c-0.08-0.11-0.25-0.19-0.39-0.17c-0.13,0.02-0.3-0.01-0.38-0.06c-0.08-0.05-0.33-0.28-0.37-0.41
c-0.04-0.13-0.18-0.25-0.32-0.27l-0.21-0.04c-0.14-0.02-0.31,0.05-0.39,0.16s-0.22,0.21-0.31,0.23S2.7,10.46,2.58,10.4
c-0.12-0.06-0.31-0.05-0.42,0.03l-0.17,0.12c-0.11,0.08-0.19,0.25-0.17,0.39s-0.01,0.3-0.06,0.38c-0.05,0.08-0.28,0.33-0.41,0.37
c-0.13,0.04-0.25,0.18-0.27,0.32l-0.04,0.21C1.02,12.36,1.09,12.53,1.2,12.61z M3.71,11.42c0.61,0.1,1.02,0.68,0.92,1.28
c-0.1,0.61-0.68,1.02-1.28,0.92c-0.61-0.1-1.02-0.68-0.92-1.28C2.53,11.73,3.1,11.32,3.71,11.42z"/>
</g>
</g>
<g>
<g>
<path fill="#808080" d="M10.39,4.47c0.13,0.03,0.28,0.13,0.33,0.21c0.05,0.08,0.19,0.38,0.18,0.52s0.07,0.3,0.19,0.38l0.18,0.11
c0.12,0.07,0.31,0.08,0.42,0.01c0.12-0.07,0.28-0.11,0.38-0.09c0.09,0.02,0.41,0.13,0.5,0.24c0.09,0.1,0.26,0.17,0.4,0.13
l0.21-0.05c0.13-0.03,0.27-0.16,0.3-0.29c0.03-0.13,0.13-0.28,0.21-0.33c0.08-0.05,0.38-0.19,0.52-0.18
c0.13,0.01,0.3-0.07,0.38-0.19l0.11-0.18c0.07-0.12,0.08-0.31,0.01-0.42c-0.07-0.12-0.11-0.28-0.09-0.38
c0.02-0.09,0.13-0.41,0.24-0.5c0.1-0.09,0.17-0.26,0.13-0.4l-0.05-0.21c-0.03-0.13-0.16-0.27-0.29-0.3
c-0.13-0.03-0.28-0.13-0.33-0.21s-0.19-0.38-0.18-0.52c0.01-0.13-0.07-0.3-0.19-0.38l-0.18-0.11c-0.12-0.07-0.31-0.08-0.42-0.01
c-0.12,0.07-0.28,0.11-0.38,0.09c-0.09-0.02-0.41-0.13-0.5-0.24c-0.09-0.1-0.26-0.17-0.4-0.13L11.87,1.1
c-0.13,0.03-0.27,0.16-0.3,0.29s-0.13,0.28-0.21,0.33s-0.38,0.19-0.52,0.18s-0.3,0.07-0.38,0.19l-0.11,0.18
c-0.07,0.12-0.08,0.31-0.01,0.42c0.07,0.12,0.11,0.28,0.09,0.38s-0.13,0.41-0.24,0.5c-0.1,0.09-0.17,0.26-0.13,0.4l0.05,0.21
C10.13,4.3,10.26,4.44,10.39,4.47z M12.27,2.43c0.6-0.13,1.2,0.24,1.33,0.84c0.13,0.6-0.24,1.2-0.84,1.33
c-0.6,0.13-1.2-0.24-1.33-0.84C11.3,3.16,11.67,2.56,12.27,2.43z"/>
</g>
</g>
<g>
<g>
<path fill="#808080" d="M1.85,4.19C1.8,4.32,1.66,4.47,1.53,4.53L1.15,4.71C1.02,4.77,0.92,4.93,0.91,5.06L0.89,5.92
c0,0.14,0.09,0.3,0.21,0.37l0.37,0.2C1.6,6.55,1.73,6.71,1.77,6.84l0.17,0.44C2,7.41,2,7.62,1.96,7.75l-0.15,0.4
C1.76,8.28,1.8,8.47,1.89,8.57l0.58,0.62c0.09,0.1,0.28,0.15,0.41,0.11L3.3,9.17c0.13-0.04,0.34-0.02,0.46,0.04l0.43,0.2
c0.13,0.05,0.28,0.19,0.34,0.32l0.18,0.39c0.06,0.12,0.22,0.23,0.35,0.23l0.85,0.03c0.14,0,0.3-0.09,0.37-0.21l0.2-0.37
c0.07-0.12,0.23-0.25,0.36-0.29l0.44-0.17c0.13-0.06,0.33-0.06,0.46-0.02l0.4,0.15C8.28,9.5,8.47,9.47,8.57,9.37l0.62-0.58
c0.1-0.09,0.15-0.28,0.11-0.41L9.17,7.97C9.13,7.84,9.16,7.63,9.22,7.51l0.2-0.43c0.05-0.13,0.19-0.28,0.32-0.34l0.39-0.18
c0.12-0.06,0.23-0.22,0.23-0.35l0.03-0.85c0-0.14-0.09-0.3-0.21-0.37l-0.37-0.2C9.67,4.71,9.54,4.55,9.49,4.42L9.33,3.98
C9.27,3.85,9.26,3.64,9.31,3.52l0.15-0.4C9.5,2.99,9.47,2.8,9.37,2.7L8.79,2.08c-0.09-0.1-0.28-0.15-0.41-0.11L7.97,2.09
C7.84,2.13,7.63,2.11,7.51,2.05l-0.43-0.2C6.94,1.8,6.79,1.66,6.73,1.53L6.56,1.15C6.5,1.02,6.34,0.92,6.2,0.91L5.35,0.89
c-0.14,0-0.3,0.09-0.37,0.21l-0.2,0.37C4.71,1.6,4.55,1.73,4.42,1.77L3.98,1.94C3.85,2,3.64,2,3.52,1.96l-0.4-0.15
C2.99,1.76,2.8,1.8,2.7,1.89L2.08,2.48c-0.1,0.09-0.15,0.28-0.11,0.41L2.09,3.3c0.04,0.13,0.02,0.34-0.04,0.46L1.85,4.19z
M6.75,3.15c1.37,0.62,1.98,2.23,1.36,3.6s-2.23,1.98-3.6,1.36C3.15,7.5,2.54,5.89,3.15,4.52S5.38,2.54,6.75,3.15z"/>
</g>
</g>
<g>
<g>
<path fill="#2172eb" d="M11,15c-0.55,0-1-0.45-1-1V8c0-0.55,0.45-1,1-1s1,0.45,1,1v6C12,14.55,11.55,15,11,15z"/>
</g>
</g>
<g>
<g>
<path fill="#2172eb" d="M14,12H8c-0.55,0-1-0.45-1-1s0.45-1,1-1h6c0.55,0,1,0.45,1,1S14.55,12,14,12z"/>
</g>
</g>
</g>
<g id="prusa_logo" transform="matrix(0.01746785,0,0,0.01746785,-2.5333011,3.4006166)">
<path fill="#363636" d="m 599.3,186.8 c -93.9,-93.9 -246.1,-93.9 -340,0 -93.9,93.9 -93.9,246.1 0,340 z"/>
<path fill="#ed6b21" d="m 202.7,612.5 c 93.9,93.9 246.1,93.9 340,0 93.9,-93.9 93.9,-246.1 0,-340" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

@ -5,6 +5,7 @@
#include "../GCode.hpp" #include "../GCode.hpp"
#include "../Geometry.hpp" #include "../Geometry.hpp"
#include "../GCode/ThumbnailData.hpp" #include "../GCode/ThumbnailData.hpp"
#include "../PrintConfig.hpp"
#include "../Time.hpp" #include "../Time.hpp"
#include "../I18N.hpp" #include "../I18N.hpp"
@ -592,34 +593,6 @@ namespace Slic3r {
XML_StopParser(m_xml_parser, false); XML_StopParser(m_xml_parser, false);
} }
template<typename CONFIG_CLASS>
void convert_from_prusa(CONFIG_CLASS& conf, const DynamicPrintConfig& global_config) {
//void convert_from_prusa(DynamicPrintConfig& conf, const DynamicPrintConfig & global_config) {
//void convert_from_prusa(ModelConfigObject& conf, const DynamicPrintConfig& global_config) {
for (const t_config_option_key& opt_key : conf.keys()) {
const ConfigOption* opt = conf.option(opt_key);
std::string serialized = opt->serialize();
std::string key = opt_key;
std::map<std::string, std::string> result = PrintConfigDef::from_prusa(key, serialized, global_config);
if (key != opt_key) {
conf.erase(opt_key);
}
if (!key.empty() && serialized != opt->serialize()) {
ConfigOption* opt_new = opt->clone();
opt_new->deserialize(serialized);
conf.set_key_value(key, opt_new);
}
for (auto entry : result) {
const ConfigOptionDef* def = print_config_def.get(entry.first);
if (def) {
ConfigOption* opt_new = def->default_value.get()->clone();
opt_new->deserialize(entry.second);
conf.set_key_value(entry.first, opt_new);
}
}
}
}
bool _3MF_Importer::_load_model_from_file(const std::string& filename, Model& model, DynamicPrintConfig& config, ConfigSubstitutionContext& config_substitutions) bool _3MF_Importer::_load_model_from_file(const std::string& filename, Model& model, DynamicPrintConfig& config, ConfigSubstitutionContext& config_substitutions)
{ {
mz_zip_archive archive; mz_zip_archive archive;
@ -761,7 +734,7 @@ namespace Slic3r {
return false; return false;
else { else {
use_prusa_config = true; use_prusa_config = true;
convert_from_prusa(config, config); config.convert_from_prusa();
} }
close_zip_reader(&archive); close_zip_reader(&archive);
@ -841,11 +814,11 @@ namespace Slic3r {
return false; return false;
if (use_prusa_config) { if (use_prusa_config) {
convert_from_prusa(model_object->config, config); model_object->config.convert_from_prusa(config);
for (ModelVolume* volume : model_object->volumes) for (ModelVolume* volume : model_object->volumes)
convert_from_prusa(volume->config, config); volume->config.convert_from_prusa(config);
for (auto entry : model_object->layer_config_ranges) for (auto entry : model_object->layer_config_ranges)
convert_from_prusa(entry.second, config); entry.second.convert_from_prusa(config);
} }
} }

View File

@ -5,6 +5,7 @@
#include "Utils.hpp" #include "Utils.hpp"
#include "Model.hpp" #include "Model.hpp"
#include "format.hpp" #include "format.hpp"
#include "PrintConfig.hpp"
#include <algorithm> #include <algorithm>
#include <set> #include <set>
@ -679,13 +680,15 @@ DynamicPrintConfig PresetBundle::full_sla_config() const
// Instead of a config file, a G-code may be loaded containing the full set of parameters. // Instead of a config file, a G-code may be loaded containing the full set of parameters.
// In the future the configuration will likely be read from an AMF file as well. // In the future the configuration will likely be read from an AMF file as well.
// If the file is loaded successfully, its print / filament / printer profiles will be activated. // If the file is loaded successfully, its print / filament / printer profiles will be activated.
ConfigSubstitutions PresetBundle::load_config_file(const std::string &path, ForwardCompatibilitySubstitutionRule compatibility_rule) ConfigSubstitutions PresetBundle::load_config_file(const std::string &path, ForwardCompatibilitySubstitutionRule compatibility_rule, bool from_prusa)
{ {
if (is_gcode_file(path)) { if (is_gcode_file(path)) {
DynamicPrintConfig config; DynamicPrintConfig config;
config.apply(FullPrintConfig::defaults()); config.apply(FullPrintConfig::defaults());
ConfigSubstitutions config_substitutions = config.load_from_gcode_file(path, compatibility_rule); ConfigSubstitutions config_substitutions = config.load_from_gcode_file(path, compatibility_rule);
Preset::normalize(config); Preset::normalize(config);
if(from_prusa)
config.convert_from_prusa();
load_config_file_config(path, true, std::move(config)); load_config_file_config(path, true, std::move(config));
return config_substitutions; return config_substitutions;
} }
@ -720,11 +723,13 @@ ConfigSubstitutions PresetBundle::load_config_file(const std::string &path, Forw
config.apply(FullPrintConfig::defaults()); config.apply(FullPrintConfig::defaults());
config_substitutions = config.load(tree, compatibility_rule); config_substitutions = config.load(tree, compatibility_rule);
Preset::normalize(config); Preset::normalize(config);
if (from_prusa)
config.convert_from_prusa();
load_config_file_config(path, true, std::move(config)); load_config_file_config(path, true, std::move(config));
return config_substitutions; return config_substitutions;
} }
case CONFIG_FILE_TYPE_CONFIG_BUNDLE: case CONFIG_FILE_TYPE_CONFIG_BUNDLE:
return load_config_file_config_bundle(path, tree, compatibility_rule); return load_config_file_config_bundle(path, tree, compatibility_rule, from_prusa);
} }
} catch (const ConfigurationError &e) { } catch (const ConfigurationError &e) {
throw Slic3r::RuntimeError(format("Invalid configuration file %1%: %2%", path, e.what())); throw Slic3r::RuntimeError(format("Invalid configuration file %1%: %2%", path, e.what()));
@ -906,11 +911,11 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
// Load the active configuration of a config bundle from a boost property_tree. This is a private method called from load_config_file. // Load the active configuration of a config bundle from a boost property_tree. This is a private method called from load_config_file.
// Note: only called when using --load from cli. Will load the bundle like with the menu but wihtout saving it. // Note: only called when using --load from cli. Will load the bundle like with the menu but wihtout saving it.
ConfigSubstitutions PresetBundle::load_config_file_config_bundle( ConfigSubstitutions PresetBundle::load_config_file_config_bundle(
const std::string &path, const boost::property_tree::ptree &tree, ForwardCompatibilitySubstitutionRule compatibility_rule) const std::string &path, const boost::property_tree::ptree &tree, ForwardCompatibilitySubstitutionRule compatibility_rule, bool from_prusa)
{ {
// Load the config bundle, but don't save the loaded presets to user profile directory // Load the config bundle, but don't save the loaded presets to user profile directory
// [PresetsConfigSubstitutions, size_t] // [PresetsConfigSubstitutions, size_t]
auto [presets_substitutions, presets_imported] = this->load_configbundle(path, { }, compatibility_rule); auto [presets_substitutions, presets_imported] = this->load_configbundle(path, (from_prusa ? LoadConfigBundleAttributes{ LoadConfigBundleAttribute::ConvertFromPrusa } : LoadConfigBundleAttribute{ }), compatibility_rule);
ConfigSubstitutions config_substitutions; ConfigSubstitutions config_substitutions;
this->update_compatible(PresetSelectCompatibleType::Never); this->update_compatible(PresetSelectCompatibleType::Never);
for (PresetConfigSubstitutions &sub : presets_substitutions) for (PresetConfigSubstitutions &sub : presets_substitutions)
@ -1205,7 +1210,7 @@ std::pair<PresetsConfigSubstitutions, size_t> PresetBundle::load_configbundle(
std::string alias_name; std::string alias_name;
std::vector<std::string> renamed_from; std::vector<std::string> renamed_from;
try { try {
auto parse_config_section = [&section, &alias_name, &renamed_from, &substitution_context, &path](DynamicPrintConfig &config) { auto parse_config_section = [&section, &alias_name, &renamed_from, &substitution_context, &path, &flags](DynamicPrintConfig &config) {
substitution_context.substitutions.clear(); substitution_context.substitutions.clear();
for (auto &kvp : section.second) { for (auto &kvp : section.second) {
if (kvp.first == "alias") if (kvp.first == "alias")
@ -1219,6 +1224,8 @@ std::pair<PresetsConfigSubstitutions, size_t> PresetBundle::load_configbundle(
// Throws on parsing error. For system presets, no substituion is being done, but an exception is thrown. // Throws on parsing error. For system presets, no substituion is being done, but an exception is thrown.
config.set_deserialize(kvp.first, kvp.second.data(), substitution_context); config.set_deserialize(kvp.first, kvp.second.data(), substitution_context);
} }
if (flags.has(LoadConfigBundleAttribute::ConvertFromPrusa))
config.convert_from_prusa();
}; };
if (presets == &this->printers) { if (presets == &this->printers) {
// Select the default config based on the printer_technology field extracted from kvp. // Select the default config based on the printer_technology field extracted from kvp.

View File

@ -85,7 +85,7 @@ public:
// Instead of a config file, a G-code may be loaded containing the full set of parameters. // Instead of a config file, a G-code may be loaded containing the full set of parameters.
// In the future the configuration will likely be read from an AMF file as well. // In the future the configuration will likely be read from an AMF file as well.
// If the file is loaded successfully, its print / filament / printer profiles will be activated. // If the file is loaded successfully, its print / filament / printer profiles will be activated.
ConfigSubstitutions load_config_file(const std::string &path, ForwardCompatibilitySubstitutionRule compatibility_rule); ConfigSubstitutions load_config_file(const std::string &path, ForwardCompatibilitySubstitutionRule compatibility_rule, bool from_prusa = false);
// Load a config bundle file, into presets and store the loaded presets into separate files // Load a config bundle file, into presets and store the loaded presets into separate files
// of the local configuration directory. // of the local configuration directory.
@ -100,6 +100,8 @@ public:
// Load a system config bundle. // Load a system config bundle.
LoadSystem, LoadSystem,
LoadVendorOnly, LoadVendorOnly,
//apply import rule from prusa
ConvertFromPrusa,
}; };
using LoadConfigBundleAttributes = enum_bitmask<LoadConfigBundleAttribute>; using LoadConfigBundleAttributes = enum_bitmask<LoadConfigBundleAttribute>;
// Load the config bundle based on the flags. // Load the config bundle based on the flags.
@ -162,7 +164,7 @@ private:
// If it is not an external config, then the config will be stored into the user profile directory. // If it is not an external config, then the config will be stored into the user profile directory.
void load_config_file_config(const std::string &name_or_path, bool is_external, DynamicPrintConfig &&config); void load_config_file_config(const std::string &name_or_path, bool is_external, DynamicPrintConfig &&config);
ConfigSubstitutions load_config_file_config_bundle( ConfigSubstitutions load_config_file_config_bundle(
const std::string &path, const boost::property_tree::ptree &tree, ForwardCompatibilitySubstitutionRule compatibility_rule); const std::string &path, const boost::property_tree::ptree &tree, ForwardCompatibilitySubstitutionRule compatibility_rule, bool from_prusa = false);
DynamicPrintConfig full_fff_config() const; DynamicPrintConfig full_fff_config() const;
DynamicPrintConfig full_sla_config() const; DynamicPrintConfig full_sla_config() const;

View File

@ -5724,9 +5724,49 @@ std::map<std::string,std::string> PrintConfigDef::from_prusa(t_config_option_key
if ("xy_size_compensation" == opt_key) { if ("xy_size_compensation" == opt_key) {
output["xy_inner_size_compensation"] = value; output["xy_inner_size_compensation"] = value;
} }
if ("infill_anchor_max" == opt_key) {
if(value == "0")
output["infill_connection"] = "notconnected";
}
return output; return output;
} }
template<typename CONFIG_CLASS>
void _convert_from_prusa(CONFIG_CLASS& conf, const DynamicPrintConfig& global_config) {
//void convert_from_prusa(DynamicPrintConfig& conf, const DynamicPrintConfig & global_config) {
//void convert_from_prusa(ModelConfigObject& conf, const DynamicPrintConfig& global_config) {
for (const t_config_option_key& opt_key : conf.keys()) {
const ConfigOption* opt = conf.option(opt_key);
std::string serialized = opt->serialize();
std::string key = opt_key;
std::map<std::string, std::string> result = PrintConfigDef::from_prusa(key, serialized, global_config);
if (key != opt_key) {
conf.erase(opt_key);
}
if (!key.empty() && serialized != opt->serialize()) {
ConfigOption* opt_new = opt->clone();
opt_new->deserialize(serialized);
conf.set_key_value(key, opt_new);
}
for (auto entry : result) {
const ConfigOptionDef* def = print_config_def.get(entry.first);
if (def) {
ConfigOption* opt_new = def->default_value.get()->clone();
opt_new->deserialize(entry.second);
conf.set_key_value(entry.first, opt_new);
}
}
}
}
void DynamicPrintConfig::convert_from_prusa() {
_convert_from_prusa(*this, *this);
}
void ModelConfig::convert_from_prusa(const DynamicPrintConfig& global_config) {
_convert_from_prusa(*this, global_config);
}
std::unordered_set<std::string> prusa_export_to_remove_keys = { std::unordered_set<std::string> prusa_export_to_remove_keys = {
"allow_empty_layers", "allow_empty_layers",
"avoid_crossing_not_first_layer", "avoid_crossing_not_first_layer",
@ -5972,6 +6012,12 @@ void PrintConfigDef::to_prusa(t_config_option_key& opt_key, std::string& value,
} }
} }
} }
if ("infill_anchor_max" == opt_key) {
//it's infill_anchor == 0 that disable it for prusa
if (all_conf.opt_serialize("infill_connection") == "notconnected") {
value = "0";
}
}
} }

View File

@ -425,6 +425,8 @@ private:
std::vector<std::string> m_milling_option_keys; std::vector<std::string> m_milling_option_keys;
}; };
// The one and only global definition of SLic3r configuration options. // The one and only global definition of SLic3r configuration options.
// This definition is constant. // This definition is constant.
extern const PrintConfigDef print_config_def; extern const PrintConfigDef print_config_def;
@ -477,6 +479,8 @@ public:
void to_prusa(t_config_option_key& opt_key, std::string& value) const override void to_prusa(t_config_option_key& opt_key, std::string& value) const override
{ PrintConfigDef::to_prusa(opt_key, value, *this); } { PrintConfigDef::to_prusa(opt_key, value, *this); }
// utilities to help convert from prusa config.
void convert_from_prusa();
/// <summary> /// <summary>
/// callback to changed other settings that are linked (like width & spacing) /// callback to changed other settings that are linked (like width & spacing)
@ -1986,6 +1990,10 @@ public:
// Not thread safe! Should not be called from other than the main thread! // Not thread safe! Should not be called from other than the main thread!
void touch() { m_timestamp = ++ s_last_timestamp; } void touch() { m_timestamp = ++ s_last_timestamp; }
// utilities to help convert from prusa config.
void convert_from_prusa(const DynamicPrintConfig& global_config);
private: private:
friend class cereal::access; friend class cereal::access;
template<class Archive> void serialize(Archive& ar) { ar(m_timestamp); ar(m_data); } template<class Archive> void serialize(Archive& ar) { ar(m_timestamp); ar(m_data); }
@ -1996,6 +2004,8 @@ private:
static uint64_t s_last_timestamp; static uint64_t s_last_timestamp;
}; };
} // namespace Slic3r } // namespace Slic3r
// Serialization through the Cereal library // Serialization through the Cereal library

View File

@ -388,7 +388,9 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig* config)
"solid_infill_every_layers", "solid_infill_below_area", "infill_extruder", "infill_anchor_max" }) "solid_infill_every_layers", "solid_infill_below_area", "infill_extruder", "infill_anchor_max" })
toggle_field(el, have_infill); toggle_field(el, have_infill);
// Only allow configuration of open anchors if the anchoring is enabled. // Only allow configuration of open anchors if the anchoring is enabled.
bool has_infill_anchors = have_infill && config->option<ConfigOptionFloatOrPercent>("infill_anchor_max")->value > 0; bool has_infill_anchors = have_infill && config->option<ConfigOptionEnum<InfillConnection>>("infill_connection")->value != InfillConnection::icNotConnected;
toggle_field("infill_anchor_max", has_infill_anchors);
has_infill_anchors = has_infill_anchors && config->option<ConfigOptionFloatOrPercent>("infill_anchor_max")->value > 0;
toggle_field("infill_anchor", has_infill_anchors); toggle_field("infill_anchor", has_infill_anchors);
bool can_have_infill_dense = config->option<ConfigOptionPercent>("fill_density")->value < 50; bool can_have_infill_dense = config->option<ConfigOptionPercent>("fill_density")->value < 50;

View File

@ -1277,6 +1277,9 @@ void MainFrame::init_menubar_as_editor()
append_menu_item(import_menu, wxID_ANY, _L("Import &Config") + dots + "\tCtrl+L", _L("Load exported configuration file"), append_menu_item(import_menu, wxID_ANY, _L("Import &Config") + dots + "\tCtrl+L", _L("Load exported configuration file"),
[this](wxCommandEvent&) { load_config_file(); }, "import_config", nullptr, [this](wxCommandEvent&) { load_config_file(); }, "import_config", nullptr,
[]() {return true; }, this); []() {return true; }, this);
append_menu_item(import_menu, wxID_ANY, _L("Import Prusa Config") + dots, _L("Load configuration file exported from PrusaSlicer"),
[this](wxCommandEvent&) { load_config_file(true); }, "import_prusa_config", nullptr,
[]() {return true; }, this);
append_menu_item(import_menu, wxID_ANY, _L("Import Config from &project") + dots +"\tCtrl+Alt+L", _L("Load configuration from project file"), append_menu_item(import_menu, wxID_ANY, _L("Import Config from &project") + dots +"\tCtrl+Alt+L", _L("Load configuration from project file"),
[this](wxCommandEvent&) { if (m_plater) m_plater->extract_config_from_project(); }, "import_config", nullptr, [this](wxCommandEvent&) { if (m_plater) m_plater->extract_config_from_project(); }, "import_config", nullptr,
[]() {return true; }, this); []() {return true; }, this);
@ -1284,6 +1287,9 @@ void MainFrame::init_menubar_as_editor()
append_menu_item(import_menu, wxID_ANY, _L("Import Config &Bundle") + dots, _L("Load presets from a bundle"), append_menu_item(import_menu, wxID_ANY, _L("Import Config &Bundle") + dots, _L("Load presets from a bundle"),
[this](wxCommandEvent&) { load_configbundle(); }, "import_config_bundle", nullptr, [this](wxCommandEvent&) { load_configbundle(); }, "import_config_bundle", nullptr,
[]() {return true; }, this); []() {return true; }, this);
append_menu_item(import_menu, wxID_ANY, _L("Import Prusa Config Bundle") + dots, _L("Load presets from a PrusaSlicer bundle"),
[this](wxCommandEvent&) { load_configbundle(wxEmptyString, true); }, "import_prusa_config_bundle", nullptr,
[]() {return true; }, this);
append_submenu(fileMenu, import_menu, wxID_ANY, _L("&Import"), ""); append_submenu(fileMenu, import_menu, wxID_ANY, _L("&Import"), "");
wxMenu* export_menu = new wxMenu(); wxMenu* export_menu = new wxMenu();
@ -1324,7 +1330,7 @@ void MainFrame::init_menubar_as_editor()
[]() {return true; }, this); []() {return true; }, this);
export_menu->AppendSeparator(); 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"), 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, [this](wxCommandEvent&) { export_config(true); }, "export_prusa_config", nullptr,
[]() {return true; }, this); []() {return true; }, this);
append_submenu(fileMenu, export_menu, wxID_ANY, _L("&Export"), ""); append_submenu(fileMenu, export_menu, wxID_ANY, _L("&Export"), "");
@ -1812,7 +1818,7 @@ void MainFrame::export_config(bool to_prusa)
} }
// Load a config file containing a Print, Filament & Printer preset. // Load a config file containing a Print, Filament & Printer preset.
void MainFrame::load_config_file() void MainFrame::load_config_file(bool from_prusa)
{ {
if (!wxGetApp().check_unsaved_changes()) if (!wxGetApp().check_unsaved_changes())
return; return;
@ -1822,17 +1828,17 @@ void MainFrame::load_config_file()
wxString file; wxString file;
if (dlg.ShowModal() == wxID_OK) if (dlg.ShowModal() == wxID_OK)
file = dlg.GetPath(); file = dlg.GetPath();
if (! file.IsEmpty() && this->load_config_file(file.ToUTF8().data())) { if (! file.IsEmpty() && this->load_config_file(file.ToUTF8().data(), from_prusa)) {
wxGetApp().app_config->update_config_dir(get_dir_name(file)); wxGetApp().app_config->update_config_dir(get_dir_name(file));
m_last_config = file; m_last_config = file;
} }
} }
// Load a config file containing a Print, Filament & Printer preset from command line. // Load a config file containing a Print, Filament & Printer preset from command line.
bool MainFrame::load_config_file(const std::string &path) bool MainFrame::load_config_file(const std::string &path, bool from_prusa)
{ {
try { try {
ConfigSubstitutions config_substitutions = wxGetApp().preset_bundle->load_config_file(path, ForwardCompatibilitySubstitutionRule::Enable); ConfigSubstitutions config_substitutions = wxGetApp().preset_bundle->load_config_file(path, ForwardCompatibilitySubstitutionRule::Enable, from_prusa);
if (!config_substitutions.empty()) if (!config_substitutions.empty())
show_substitutions_info(config_substitutions, path); show_substitutions_info(config_substitutions, path);
} catch (const std::exception& ex) { } catch (const std::exception& ex) {
@ -1875,7 +1881,7 @@ void MainFrame::export_configbundle(bool export_physical_printers /*= false*/)
// Loading a config bundle with an external file name used to be used // Loading a config bundle with an external file name used to be used
// to auto - install a config bundle on a fresh user account, // to auto - install a config bundle on a fresh user account,
// but that behavior was not documented and likely buggy. // but that behavior was not documented and likely buggy.
void MainFrame::load_configbundle(wxString file/* = wxEmptyString, const bool reset_user_profile*/) void MainFrame::load_configbundle(wxString file/* = wxEmptyString*/, bool from_prusa/* = false*/)
{ {
if (!wxGetApp().check_unsaved_changes()) if (!wxGetApp().check_unsaved_changes())
return; return;
@ -1893,9 +1899,12 @@ void MainFrame::load_configbundle(wxString file/* = wxEmptyString, const bool re
size_t presets_imported = 0; size_t presets_imported = 0;
PresetsConfigSubstitutions config_substitutions; PresetsConfigSubstitutions config_substitutions;
try { try {
PresetBundle::LoadConfigBundleAttributes lcba{ PresetBundle::LoadConfigBundleAttribute::SaveImported };
// Report all substitutions. // Report all substitutions.
std::tie(config_substitutions, presets_imported) = wxGetApp().preset_bundle->load_configbundle( std::tie(config_substitutions, presets_imported) = wxGetApp().preset_bundle->load_configbundle(
file.ToUTF8().data(), PresetBundle::LoadConfigBundleAttribute::SaveImported, ForwardCompatibilitySubstitutionRule::Enable); file.ToUTF8().data(),
(from_prusa ? lcba | PresetBundle::LoadConfigBundleAttribute::ConvertFromPrusa : lcba),
ForwardCompatibilitySubstitutionRule::Enable);
} catch (const std::exception &ex) { } catch (const std::exception &ex) {
show_error(this, ex.what()); show_error(this, ex.what());
return; return;

View File

@ -192,11 +192,11 @@ public:
void repair_stl(); void repair_stl();
void export_config(bool to_prusa = false); void export_config(bool to_prusa = false);
// Query user for the config file and open it. // Query user for the config file and open it.
void load_config_file(); void load_config_file(bool from_prusa = false);
// Open a config file. Return true if loaded. // Open a config file. Return true if loaded.
bool load_config_file(const std::string &path); bool load_config_file(const std::string &path, bool from_prusa = false);
void export_configbundle(bool export_physical_printers = false); void export_configbundle(bool export_physical_printers = false);
void load_configbundle(wxString file = wxEmptyString); void load_configbundle(wxString file = wxEmptyString, bool from_prusa = false);
void load_config(const DynamicPrintConfig& config); void load_config(const DynamicPrintConfig& config);
// Select tab in m_tabpanel // Select tab in m_tabpanel
// When tab == -1, will be selected last selected tab // When tab == -1, will be selected last selected tab