mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-15 21:55:59 +08:00
common filament profile available for all printers
This commit is contained in:
parent
af2a55f261
commit
9ddc1b4479
@ -146,6 +146,11 @@ VendorProfile VendorProfile::from_ini(const ptree &tree, const boost::filesystem
|
||||
res.changelog_url = changelog_url->second.data();
|
||||
}
|
||||
|
||||
const auto common_profile = vendor_section.find("common_profile");
|
||||
if (common_profile != vendor_section.not_found()) {
|
||||
res.common_profile = common_profile->second.data() == "1";
|
||||
}
|
||||
|
||||
if (! load_all) {
|
||||
return res;
|
||||
}
|
||||
@ -336,6 +341,10 @@ std::string Preset::label() const
|
||||
|
||||
bool is_compatible_with_print(const PresetWithVendorProfile &preset, const PresetWithVendorProfile &active_print, const PresetWithVendorProfile &active_printer)
|
||||
{
|
||||
// custom filament profiles are aviable for all prints
|
||||
if (preset.preset.type == Preset::Type::TYPE_FILAMENT && preset.vendor != nullptr && preset.vendor != active_printer.vendor && preset.vendor->common_profile)
|
||||
return true;
|
||||
|
||||
if (preset.vendor != nullptr && preset.vendor != active_printer.vendor)
|
||||
// The current profile has a vendor assigned and it is different from the active print's vendor.
|
||||
return false;
|
||||
@ -358,6 +367,10 @@ bool is_compatible_with_print(const PresetWithVendorProfile &preset, const Prese
|
||||
|
||||
bool is_compatible_with_printer(const PresetWithVendorProfile &preset, const PresetWithVendorProfile &active_printer, const DynamicPrintConfig *extra_config)
|
||||
{
|
||||
// custom filament profiles are aviable for all printers
|
||||
if (preset.preset.type == Preset::Type::TYPE_FILAMENT && preset.vendor != nullptr && preset.vendor != active_printer.vendor && preset.vendor->common_profile)
|
||||
return true;
|
||||
|
||||
if (preset.vendor != nullptr && preset.vendor != active_printer.vendor)
|
||||
// The current profile has a vendor assigned and it is different from the active print's vendor.
|
||||
return false;
|
||||
|
@ -34,6 +34,7 @@ public:
|
||||
Semver config_version;
|
||||
std::string config_update_url;
|
||||
std::string changelog_url;
|
||||
bool common_profile { false };
|
||||
|
||||
struct PrinterVariant {
|
||||
PrinterVariant() {}
|
||||
|
@ -1263,10 +1263,10 @@ std::pair<PresetsConfigSubstitutions, size_t> PresetBundle::load_configbundle(
|
||||
const VendorProfile *vendor_profile = nullptr;
|
||||
if (flags.has(LoadConfigBundleAttribute::LoadSystem) || flags.has(LoadConfigBundleAttribute::LoadVendorOnly)) {
|
||||
auto vp = VendorProfile::from_ini(tree, path);
|
||||
if (vp.models.size() == 0) {
|
||||
if (vp.models.size() == 0 && !vp.common_profile) {
|
||||
BOOST_LOG_TRIVIAL(error) << boost::format("Vendor bundle: `%1%`: No printer model defined.") % path;
|
||||
return std::make_pair(PresetsConfigSubstitutions{}, 0);
|
||||
} else if (vp.num_variants() == 0) {
|
||||
} else if (vp.num_variants() == 0 && !vp.common_profile) {
|
||||
BOOST_LOG_TRIVIAL(error) << boost::format("Vendor bundle: `%1%`: No printer variant defined") % path;
|
||||
return std::make_pair(PresetsConfigSubstitutions{}, 0);
|
||||
}
|
||||
|
@ -2140,7 +2140,17 @@ void ConfigWizard::priv::update_materials(Technology technology)
|
||||
filaments.add_printer(&printer);
|
||||
}
|
||||
}
|
||||
|
||||
// common filament bundle has no printers - filament would be never added
|
||||
if(pair.second.preset_bundle->printers.begin() == pair.second.preset_bundle->printers.end())
|
||||
{
|
||||
if (!filaments.containts(&filament)) {
|
||||
filaments.push(&filament);
|
||||
if (!filament.alias.empty())
|
||||
aliases_fff[filament.alias].insert(filament.name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
// count compatible printers
|
||||
@ -2420,6 +2430,21 @@ bool ConfigWizard::priv::check_and_install_missing_materials(Technology technolo
|
||||
has_material = true;
|
||||
break;
|
||||
}
|
||||
|
||||
// find if preset.first is part of the common profile (up is searching if preset.first is part of printer vendor preset)
|
||||
for (const auto& bp : bundles) {
|
||||
if (!bp.second.preset_bundle->vendors.empty() && bp.second.preset_bundle->vendors.begin()->second.common_profile) {
|
||||
const PresetCollection& common_materials = bp.second.preset_bundle->materials(technology);
|
||||
const Preset* common_material = common_materials.find_preset(preset.first, false);
|
||||
if(common_material) {
|
||||
has_material = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (has_material)
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
if (! has_material)
|
||||
|
@ -136,7 +136,7 @@ struct Materials
|
||||
for (auto preset : presets) {
|
||||
const Preset& prst = *(preset);
|
||||
const Preset& prntr = *printer;
|
||||
if ((printer == nullptr || is_compatible_with_printer(PresetWithVendorProfile(prst, prst.vendor), PresetWithVendorProfile(prntr, prntr.vendor))) &&
|
||||
if ((printer == nullptr || is_compatible_with_printer(PresetWithVendorProfile(prst, prst.vendor), PresetWithVendorProfile(prntr, prntr.vendor))) &&
|
||||
(type.empty() || get_type(preset) == type) &&
|
||||
(vendor.empty() || get_vendor(preset) == vendor)) {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user