Added a project specific config to the PresetBundle class.

This project specific config will be stored into the config.ini,
into .3mf and .amf and .gcode,
and recover it from the same files.
This commit is contained in:
bubnikv 2018-03-14 11:54:11 +01:00
parent 0781dd8271
commit 5f28b89ae0
3 changed files with 16 additions and 0 deletions

View File

@ -32,6 +32,9 @@
namespace Slic3r {
static std::vector<std::string> s_project_options {
};
PresetBundle::PresetBundle() :
prints(Preset::TYPE_PRINT, Preset::print_options()),
filaments(Preset::TYPE_FILAMENT, Preset::filament_options()),
@ -56,6 +59,8 @@ PresetBundle::PresetBundle() :
this->filaments.load_bitmap_default("spool.png");
this->printers .load_bitmap_default("printer_empty.png");
this->load_compatible_bitmaps();
this->project_config.apply_only(FullPrintConfig::defaults(), s_project_options);
}
PresetBundle::~PresetBundle()
@ -223,6 +228,7 @@ DynamicPrintConfig PresetBundle::full_config() const
out.apply(FullPrintConfig());
out.apply(this->prints.get_edited_preset().config);
out.apply(this->printers.get_edited_preset().config);
out.apply(this->project_config);
auto *nozzle_diameter = dynamic_cast<const ConfigOptionFloats*>(out.option("nozzle_diameter"));
size_t num_extruders = nozzle_diameter->values.size();
@ -412,6 +418,9 @@ void PresetBundle::load_config_file_config(const std::string &name_or_path, bool
}
}
// 4) Load the project config values (the per extruder wipe matrix etc).
this->project_config.apply_only(config, s_project_options);
this->update_compatible_with_printer(false);
}

View File

@ -39,6 +39,11 @@ public:
// extruders.size() should be the same as printers.get_edited_preset().config.nozzle_diameter.size()
std::vector<std::string> filament_presets;
// The project configuration values are kept separated from the print/filament/printer preset,
// they are being serialized / deserialized from / to the .amf, .3mf, .config, .gcode,
// and they are being used by slicing core.
DynamicPrintConfig project_config;
bool has_defauls_only() const
{ return prints.size() <= 1 && filaments.size() <= 1 && printers.size() <= 1; }

View File

@ -161,6 +161,8 @@ PresetCollection::arrayref()
Ref<PresetCollection> print() %code%{ RETVAL = &THIS->prints; %};
Ref<PresetCollection> filament() %code%{ RETVAL = &THIS->filaments; %};
Ref<PresetCollection> printer() %code%{ RETVAL = &THIS->printers; %};
Ref<DynamicPrintConfig> project_config() %code%{ RETVAL = &THIS->project_config; %};
bool has_defauls_only();
std::vector<std::string> filament_presets() %code%{ RETVAL = THIS->filament_presets; %};