Support for new "default_materials" property at PrinterModel
of system profiles. The "default_materials" key accepts "default_filaments" as well.
This commit is contained in:
parent
19f0f50e98
commit
9a3901e159
3 changed files with 32 additions and 16 deletions
|
@ -341,24 +341,10 @@ void Bed3D::calc_gridlines(const ExPolygon& poly, const BoundingBox& bed_bbox)
|
|||
printf("Unable to create bed grid lines\n");
|
||||
}
|
||||
|
||||
static const VendorProfile::PrinterModel* system_printer_model(const Preset &preset)
|
||||
{
|
||||
const VendorProfile::PrinterModel *out = nullptr;
|
||||
if (preset.vendor != nullptr) {
|
||||
auto *printer_model = preset.config.opt<ConfigOptionString>("printer_model");
|
||||
if (printer_model != nullptr && ! printer_model->value.empty()) {
|
||||
auto it = std::find_if(preset.vendor->models.begin(), preset.vendor->models.end(), [printer_model](const VendorProfile::PrinterModel &pm) { return pm.id == printer_model->value; });
|
||||
if (it != preset.vendor->models.end())
|
||||
out = &(*it);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
static std::string system_print_bed_model(const Preset &preset)
|
||||
{
|
||||
std::string out;
|
||||
const VendorProfile::PrinterModel *pm = system_printer_model(preset);
|
||||
const VendorProfile::PrinterModel *pm = PresetUtils::system_printer_model(preset);
|
||||
if (pm != nullptr && ! pm->bed_model.empty())
|
||||
out = Slic3r::resources_dir() + "/profiles/" + preset.vendor->id + "/" + pm->bed_model;
|
||||
return out;
|
||||
|
@ -367,7 +353,7 @@ static std::string system_print_bed_model(const Preset &preset)
|
|||
static std::string system_print_bed_texture(const Preset &preset)
|
||||
{
|
||||
std::string out;
|
||||
const VendorProfile::PrinterModel *pm = system_printer_model(preset);
|
||||
const VendorProfile::PrinterModel *pm = PresetUtils::system_printer_model(preset);
|
||||
if (pm != nullptr && ! pm->bed_texture.empty())
|
||||
out = Slic3r::resources_dir() + "/profiles/" + preset.vendor->id + "/" + pm->bed_texture;
|
||||
return out;
|
||||
|
|
|
@ -184,6 +184,14 @@ VendorProfile VendorProfile::from_ini(const ptree &tree, const boost::filesystem
|
|||
} else {
|
||||
BOOST_LOG_TRIVIAL(error) << boost::format("Vendor bundle: `%1%`: Malformed variants field: `%2%`") % id % variants_field;
|
||||
}
|
||||
auto default_materials_field = section.second.get<std::string>("default_materials", "");
|
||||
if (default_materials_field.empty())
|
||||
default_materials_field = section.second.get<std::string>("default_filaments", "");
|
||||
if (Slic3r::unescape_strings_cstyle(default_materials_field, model.default_materials)) {
|
||||
Slic3r::sort_remove_duplicates(model.default_materials);
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(error) << boost::format("Vendor bundle: `%1%`: Malformed default_materials field: `%2%`") % id % default_materials_field;
|
||||
}
|
||||
model.bed_model = section.second.get<std::string>("bed_model", "");
|
||||
model.bed_texture = section.second.get<std::string>("bed_texture", "");
|
||||
if (! model.id.empty() && ! model.variants.empty())
|
||||
|
@ -1502,4 +1510,20 @@ const Preset* PrinterPresetCollection::find_by_model_id(const std::string &model
|
|||
return it != cend() ? &*it : nullptr;
|
||||
}
|
||||
|
||||
namespace PresetUtils {
|
||||
const VendorProfile::PrinterModel* system_printer_model(const Preset &preset)
|
||||
{
|
||||
const VendorProfile::PrinterModel *out = nullptr;
|
||||
if (preset.vendor != nullptr) {
|
||||
auto *printer_model = preset.config.opt<ConfigOptionString>("printer_model");
|
||||
if (printer_model != nullptr && ! printer_model->value.empty()) {
|
||||
auto it = std::find_if(preset.vendor->models.begin(), preset.vendor->models.end(), [printer_model](const VendorProfile::PrinterModel &pm) { return pm.id == printer_model->value; });
|
||||
if (it != preset.vendor->models.end())
|
||||
out = &(*it);
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
} // namespace PresetUtils
|
||||
|
||||
} // namespace Slic3r
|
||||
|
|
|
@ -61,6 +61,7 @@ public:
|
|||
PrinterTechnology technology;
|
||||
std::string family;
|
||||
std::vector<PrinterVariant> variants;
|
||||
std::vector<std::string> default_materials;
|
||||
// Vendor & Printer Model specific print bed model & texture.
|
||||
std::string bed_model;
|
||||
std::string bed_texture;
|
||||
|
@ -563,6 +564,11 @@ public:
|
|||
const Preset* find_by_model_id(const std::string &model_id) const;
|
||||
};
|
||||
|
||||
namespace PresetUtils {
|
||||
// PrinterModel of a system profile, from which this preset is derived, or null if it is not derived from a system profile.
|
||||
const VendorProfile::PrinterModel* system_printer_model(const Preset &preset);
|
||||
} // namespace PresetUtils
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif /* slic3r_Preset_hpp_ */
|
||||
|
|
Loading…
Reference in a new issue