Generalize PrusaLink

This commit is contained in:
Vojtech Bubnik 2021-11-19 15:32:33 +01:00
parent 67373ca722
commit 4a7ac79637

View File

@ -528,16 +528,21 @@ void PhysicalPrinterDialog::update_host_type(bool printer_change)
std::string preset_name = prstft->get_preset_name(); std::string preset_name = prstft->get_preset_name();
if (Preset* preset = wxGetApp().preset_bundle->printers.find_preset(preset_name)) { if (Preset* preset = wxGetApp().preset_bundle->printers.find_preset(preset_name)) {
std::string model_id = preset->config.opt_string("printer_model"); std::string model_id = preset->config.opt_string("printer_model");
if (preset->vendor && preset->vendor->name == "Prusa Research") { auto model_supports_prusalink = [](const std::string &model) {
const std::vector<VendorProfile::PrinterModel>& models = preset->vendor->models; return model.size() >= 3 &&
auto it = std::find_if(models.begin(), models.end(), ((boost::starts_with(model, "MK") && model[2] > '2' && model[2] <= '9') ||
[model_id](const VendorProfile::PrinterModel& model) { return model.id == model_id; }); boost::starts_with(model, "MINI"));
if (it != models.end() && (it->family == "MK3" || it->family == "MINI")) };
continue; if (preset->vendor) {
} else if (!preset->vendor && (boost::starts_with(model_id, "MK3") || boost::starts_with(model_id, "MINI"))) { if (preset->vendor->name == "Prusa Research") {
const std::vector<VendorProfile::PrinterModel>& models = preset->vendor->models;
auto it = std::find_if(models.begin(), models.end(),
[model_id](const VendorProfile::PrinterModel& model) { return model.id == model_id; });
if (it != models.end() && model_supports_prusalink(it->family))
continue;
}
} else if (model_supports_prusalink(model_id))
continue; continue;
}
} }
all_presets_are_from_mk3_family = false; all_presets_are_from_mk3_family = false;
break; break;