mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 08:47:52 -06:00
Filaments and materials selection/installation
This commit is contained in:
parent
a93e63e296
commit
34b3548102
8 changed files with 608 additions and 58 deletions
|
@ -99,6 +99,9 @@ static const std::unordered_map<std::string, std::string> pre_family_model_map {
|
|||
VendorProfile VendorProfile::from_ini(const ptree &tree, const boost::filesystem::path &path, bool load_all)
|
||||
{
|
||||
static const std::string printer_model_key = "printer_model:";
|
||||
static const std::string filaments_section = "default_filaments";
|
||||
static const std::string materials_section = "default_sla_materials";
|
||||
|
||||
const std::string id = path.stem().string();
|
||||
|
||||
if (! boost::filesystem::exists(path)) {
|
||||
|
@ -107,6 +110,7 @@ VendorProfile VendorProfile::from_ini(const ptree &tree, const boost::filesystem
|
|||
|
||||
VendorProfile res(id);
|
||||
|
||||
// Helper to get compulsory fields
|
||||
auto get_or_throw = [&](const ptree &tree, const std::string &key) -> ptree::const_assoc_iterator
|
||||
{
|
||||
auto res = tree.find(key);
|
||||
|
@ -116,6 +120,7 @@ VendorProfile VendorProfile::from_ini(const ptree &tree, const boost::filesystem
|
|||
return res;
|
||||
};
|
||||
|
||||
// Load the header
|
||||
const auto &vendor_section = get_or_throw(tree, "vendor")->second;
|
||||
res.name = get_or_throw(vendor_section, "name")->second.data();
|
||||
|
||||
|
@ -127,6 +132,7 @@ VendorProfile VendorProfile::from_ini(const ptree &tree, const boost::filesystem
|
|||
res.config_version = std::move(*config_version);
|
||||
}
|
||||
|
||||
// Load URLs
|
||||
const auto config_update_url = vendor_section.find("config_update_url");
|
||||
if (config_update_url != vendor_section.not_found()) {
|
||||
res.config_update_url = config_update_url->second.data();
|
||||
|
@ -141,6 +147,7 @@ VendorProfile VendorProfile::from_ini(const ptree &tree, const boost::filesystem
|
|||
return res;
|
||||
}
|
||||
|
||||
// Load printer models
|
||||
for (auto §ion : tree) {
|
||||
if (boost::starts_with(section.first, printer_model_key)) {
|
||||
VendorProfile::PrinterModel model;
|
||||
|
@ -182,6 +189,24 @@ VendorProfile VendorProfile::from_ini(const ptree &tree, const boost::filesystem
|
|||
}
|
||||
}
|
||||
|
||||
// Load filaments and sla materials to be installed by default
|
||||
const auto filaments = tree.find(filaments_section);
|
||||
if (filaments != tree.not_found()) {
|
||||
for (auto &pair : filaments->second) {
|
||||
if (pair.second.data() == "1") {
|
||||
res.default_filaments.insert(pair.first);
|
||||
}
|
||||
}
|
||||
}
|
||||
const auto materials = tree.find(materials_section);
|
||||
if (materials != tree.not_found()) {
|
||||
for (auto &pair : materials->second) {
|
||||
if (pair.second.data() == "1") {
|
||||
res.default_sla_materials.insert(pair.first);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -351,10 +376,17 @@ bool Preset::update_compatible(const Preset &active_printer, const DynamicPrintC
|
|||
void Preset::set_visible_from_appconfig(const AppConfig &app_config)
|
||||
{
|
||||
if (vendor == nullptr) { return; }
|
||||
const std::string &model = config.opt_string("printer_model");
|
||||
const std::string &variant = config.opt_string("printer_variant");
|
||||
if (model.empty() || variant.empty()) { return; }
|
||||
is_visible = app_config.get_variant(vendor->id, model, variant);
|
||||
|
||||
if (type == TYPE_PRINTER) {
|
||||
const std::string &model = config.opt_string("printer_model");
|
||||
const std::string &variant = config.opt_string("printer_variant");
|
||||
if (model.empty() || variant.empty()) { return; }
|
||||
is_visible = app_config.get_variant(vendor->id, model, variant);
|
||||
} else if (type == TYPE_FILAMENT) {
|
||||
is_visible = app_config.has("filaments", name);
|
||||
} else if (type == TYPE_SLA_MATERIAL) {
|
||||
is_visible = app_config.has("sla_materials", name);
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<std::string>& Preset::print_options()
|
||||
|
@ -404,7 +436,7 @@ const std::vector<std::string>& Preset::filament_options()
|
|||
"filament_retract_length", "filament_retract_lift", "filament_retract_lift_above", "filament_retract_lift_below", "filament_retract_speed", "filament_deretract_speed", "filament_retract_restart_extra", "filament_retract_before_travel",
|
||||
"filament_retract_layer_change", "filament_wipe", "filament_retract_before_wipe",
|
||||
// Profile compatibility
|
||||
"compatible_prints", "compatible_prints_condition", "compatible_printers", "compatible_printers_condition", "inherits"
|
||||
"filament_vendor", "compatible_prints", "compatible_prints_condition", "compatible_printers", "compatible_printers_condition", "inherits"
|
||||
};
|
||||
return s_opts;
|
||||
}
|
||||
|
@ -504,6 +536,7 @@ const std::vector<std::string>& Preset::sla_material_options()
|
|||
"initial_exposure_time",
|
||||
"material_correction",
|
||||
"material_notes",
|
||||
"material_vendor",
|
||||
"default_sla_material_profile",
|
||||
"compatible_prints", "compatible_prints_condition",
|
||||
"compatible_printers", "compatible_printers_condition", "inherits"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue