mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-05 20:26:11 +08:00
Merge branch 'dk_trim_repo_prefix'
This commit is contained in:
commit
e5faaca377
@ -451,6 +451,23 @@ void Preset::set_visible_from_appconfig(const AppConfig &app_config)
|
||||
}
|
||||
}
|
||||
|
||||
std::string Preset::trim_vendor_repo_prefix(const std::string& id) const
|
||||
{
|
||||
return Preset::trim_vendor_repo_prefix(id, this->vendor);
|
||||
}
|
||||
std::string Preset::trim_vendor_repo_prefix(const std::string& id, const VendorProfile* vendor_profile) const
|
||||
{
|
||||
if (!vendor_profile) {
|
||||
return id;
|
||||
}
|
||||
std::string res = id;
|
||||
if (boost::algorithm::starts_with(res, vendor_profile->repo_prefix)) {
|
||||
boost::algorithm::erase_head(res, vendor_profile->repo_prefix.size());
|
||||
boost::algorithm::trim_left(res);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static std::vector<std::string> s_Preset_print_options {
|
||||
"layer_height", "first_layer_height", "perimeters", "spiral_vase", "slice_closing_radius", "slicing_mode",
|
||||
"top_solid_layers", "top_solid_min_thickness", "bottom_solid_layers", "bottom_solid_min_thickness",
|
||||
|
@ -224,6 +224,10 @@ public:
|
||||
// Sort lexicographically by a preset name. The preset name shall be unique across a single PresetCollection.
|
||||
bool operator<(const Preset &other) const { return this->name < other.name; }
|
||||
|
||||
// Returns id without trimmed prefix if present and vendor has any.
|
||||
std::string trim_vendor_repo_prefix(const std::string& id) const;
|
||||
std::string trim_vendor_repo_prefix(const std::string& id, const VendorProfile* vendor_profile) const;
|
||||
|
||||
static const std::vector<std::string>& print_options();
|
||||
static const std::vector<std::string>& filament_options();
|
||||
// Printer options contain the nozzle options.
|
||||
|
@ -713,6 +713,16 @@ void SLAPrint::export_print(const std::string &fname, const ThumbnailsList &thum
|
||||
}
|
||||
}
|
||||
|
||||
bool SLAPrint::is_prusa_print(const std::string& printer_model)
|
||||
{
|
||||
static const std::vector<std::string> prusa_printer_models = { "SL1", "SL1S", "M1", "SLX" };
|
||||
for (const std::string& model : prusa_printer_models)
|
||||
if (model == printer_model)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SLAPrint::invalidate_step(SLAPrintStep step)
|
||||
{
|
||||
bool invalidated = Inherited::invalidate_step(step);
|
||||
|
@ -582,6 +582,8 @@ public:
|
||||
void export_print(const std::string &fname,
|
||||
const ThumbnailsList &thumbnails,
|
||||
const std::string &projectname = "");
|
||||
|
||||
static bool is_prusa_print(const std::string& printer_model);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -1148,8 +1148,7 @@ void SLAPrint::Steps::merge_slices_and_eval_stats() {
|
||||
ExposureProfile above(material_config, 1);
|
||||
|
||||
const int first_slow_layers = fade_layers_cnt + first_extra_slow_layers;
|
||||
const std::string printer_model = printer_config.printer_model;
|
||||
const bool is_prusa_print = printer_model == "SL1" || printer_model == "SL1S" || printer_model == "M1";
|
||||
const bool is_prusa_print = SLAPrint::is_prusa_print(printer_config.printer_model);
|
||||
|
||||
const auto width = scaled<double>(printer_config.display_width.getFloat());
|
||||
const auto height = scaled<double>(printer_config.display_height.getFloat());
|
||||
|
@ -3888,20 +3888,8 @@ const Preset* find_preset_by_nozzle_and_options(
|
||||
for (const Preset &preset : collection) {
|
||||
// trim repo prefix
|
||||
std::string printer_model = preset.config.opt_string("printer_model");
|
||||
std::string vendor_repo_prefix;
|
||||
if (preset.vendor) {
|
||||
vendor_repo_prefix = preset.vendor->repo_prefix;
|
||||
} else if (std::string inherits = preset.inherits(); !inherits.empty()) {
|
||||
const Preset *parent = wxGetApp().preset_bundle->printers.find_preset(inherits);
|
||||
if (parent && parent->vendor) {
|
||||
vendor_repo_prefix = parent->vendor->repo_prefix;
|
||||
}
|
||||
}
|
||||
if (printer_model.find(vendor_repo_prefix) == 0) {
|
||||
printer_model = printer_model.substr(vendor_repo_prefix.size()
|
||||
);
|
||||
boost::trim_left(printer_model);
|
||||
}
|
||||
const PresetWithVendorProfile& printer_with_vendor = collection.get_preset_with_vendor_profile(preset);
|
||||
printer_model = preset.trim_vendor_repo_prefix(printer_model, printer_with_vendor.vendor);
|
||||
|
||||
if (!preset.is_system || printer_model != model_id)
|
||||
continue;
|
||||
|
@ -703,6 +703,7 @@ void PhysicalPrinterDialog::update_host_type(bool printer_change)
|
||||
bool supported { true };
|
||||
wxString label;
|
||||
} link, connect;
|
||||
#if 0 // Functions replaced with model_supports_prusa_service as all new printers will support both services.
|
||||
// allowed models are: all MINI, all MK3 and newer, MK2.5 and MK2.5S
|
||||
auto model_supports_prusalink = [](const std::string& model) {
|
||||
return model.size() >= 2 &&
|
||||
@ -725,30 +726,32 @@ void PhysicalPrinterDialog::update_host_type(bool printer_change)
|
||||
|| boost::starts_with(model, "CORE")
|
||||
);
|
||||
};
|
||||
#endif // 0
|
||||
auto model_supports_prusa_service = [](const std::string& model) {
|
||||
// We used to name all supported services, which causes headache with each now model line
|
||||
// The only unsupported models are MK2 variants (MK2.5 is supported)
|
||||
if (boost::starts_with(model, "MK2") && !boost::starts_with(model, "MK2.5")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
// set all_presets_are_prusalink_supported
|
||||
for (PresetForPrinter* prstft : m_presets) {
|
||||
std::string preset_name = prstft->get_preset_name();
|
||||
if (Preset* preset = wxGetApp().preset_bundle->printers.find_preset(preset_name)) {
|
||||
std::string model_id = preset->config.opt_string("printer_model");
|
||||
if (preset->vendor) {
|
||||
std::string model_id_no_pref = model_id;
|
||||
std::string vendor_repo_prefix;
|
||||
vendor_repo_prefix = preset->vendor->repo_prefix;
|
||||
if (model_id_no_pref.find(vendor_repo_prefix) == 0) {
|
||||
model_id_no_pref = model_id_no_pref.substr(vendor_repo_prefix.size());
|
||||
boost::trim_left(model_id_no_pref);
|
||||
}
|
||||
if (preset->vendor->name.find("Prusa Research") != std::string::npos) {
|
||||
const std::vector<VendorProfile::PrinterModel>& models = preset->vendor->models;
|
||||
const PresetWithVendorProfile& printer_with_vendor = wxGetApp().preset_bundle->printers.get_preset_with_vendor_profile(*preset);
|
||||
std::string model_id_no_pref = preset->trim_vendor_repo_prefix(model_id, printer_with_vendor.vendor);
|
||||
if (printer_with_vendor.vendor) {
|
||||
if (printer_with_vendor.vendor->name.find("Prusa Research") != std::string::npos) {
|
||||
const std::vector<VendorProfile::PrinterModel>& models = printer_with_vendor.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(model_id_no_pref))
|
||||
if (it != models.end() && model_supports_prusa_service(model_id_no_pref))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else if (model_supports_prusalink(model_id))
|
||||
continue;
|
||||
}
|
||||
link.supported = false;
|
||||
break;
|
||||
@ -763,21 +766,14 @@ void PhysicalPrinterDialog::update_host_type(bool printer_change)
|
||||
break;
|
||||
}
|
||||
std::string model_id = preset->config.opt_string("printer_model");
|
||||
// remove prefix from printer_model
|
||||
if (preset->vendor) {
|
||||
std::string vendor_repo_prefix;
|
||||
vendor_repo_prefix = preset->vendor->repo_prefix;
|
||||
if (model_id.find(vendor_repo_prefix) == 0) {
|
||||
model_id = model_id.substr(vendor_repo_prefix.size());
|
||||
boost::trim_left(model_id);
|
||||
}
|
||||
}
|
||||
if (preset->vendor && preset->vendor->name.find("Prusa Research") == std::string::npos) {
|
||||
const PresetWithVendorProfile& printer_with_vendor = wxGetApp().preset_bundle->printers.get_preset_with_vendor_profile(*preset);
|
||||
model_id = preset->trim_vendor_repo_prefix(model_id, printer_with_vendor.vendor);
|
||||
if (!printer_with_vendor.vendor || printer_with_vendor.vendor->name.find("Prusa Research") == std::string::npos) {
|
||||
connect.supported = false;
|
||||
break;
|
||||
}
|
||||
// model id should be enough for this case
|
||||
if (!model_supports_prusaconnect(model_id)) {
|
||||
if (!model_supports_prusa_service(model_id)) {
|
||||
connect.supported = false;
|
||||
break;
|
||||
}
|
||||
|
@ -2157,33 +2157,19 @@ unsigned int Plater::priv::update_background_process(bool force_validation, bool
|
||||
if (full_config.has("binary_gcode")) // needed for SLA
|
||||
full_config.set("binary_gcode", bool(full_config.opt_bool("binary_gcode") & wxGetApp().app_config->get_bool("use_binary_gcode_when_supported")));
|
||||
|
||||
// Set printer_model in full_config a model without repo prefix (including inherited profiles)
|
||||
const Preset &selected_printer = wxGetApp().preset_bundle->printers.get_selected_preset();
|
||||
std::string printer_model_serialized = full_config.option("printer_model")->serialize();
|
||||
std::string printer_model = selected_printer.config.opt_string("printer_model");
|
||||
const PresetWithVendorProfile& printer_with_vendor = wxGetApp().preset_bundle->printers.get_preset_with_vendor_profile(selected_printer);
|
||||
printer_model = selected_printer.trim_vendor_repo_prefix(printer_model, printer_with_vendor.vendor);
|
||||
full_config.set("printer_model", printer_model);
|
||||
|
||||
const VendorProfile* vendor = nullptr;
|
||||
std::string vendor_repo_prefix;
|
||||
if (selected_printer.vendor) {
|
||||
vendor = selected_printer.vendor;
|
||||
|
||||
} else if (std::string inherits = selected_printer.inherits(); !inherits.empty()) {
|
||||
const Preset *parent = wxGetApp().preset_bundle->printers.find_preset(inherits);
|
||||
if (parent && parent->vendor) {
|
||||
vendor_repo_prefix = parent->vendor->repo_prefix;
|
||||
}
|
||||
}
|
||||
|
||||
if (vendor) {
|
||||
vendor_repo_prefix = vendor->repo_prefix;
|
||||
// Passing extra info about preset vendor and version, so these can be inserted as metadata to GCode
|
||||
full_config.set("profile_vendor", vendor->name, true);
|
||||
full_config.set("profile_version", vendor->config_version.to_string(), true);
|
||||
full_config.set("profile_vendor", selected_printer.vendor->name, true);
|
||||
full_config.set("profile_version", selected_printer.vendor->config_version.to_string(), true);
|
||||
}
|
||||
|
||||
if (printer_model_serialized.find(vendor_repo_prefix) == 0) {
|
||||
printer_model_serialized = printer_model_serialized.substr(vendor_repo_prefix.size());
|
||||
boost::trim_left(printer_model_serialized);
|
||||
full_config.set("printer_model", printer_model_serialized);
|
||||
}
|
||||
// If the update_background_process() was not called by the timer, kill the timer,
|
||||
// so the update_restart_background_process() will not be called again in vain.
|
||||
background_process_timer.Stop();
|
||||
|
@ -979,20 +979,9 @@ static std::string get_connect_state_suffix_for_printer(const Preset& printer_pr
|
||||
|
||||
for (const auto& [printer_model_nozzle_pair, states] : printer_state_map) {
|
||||
std::string printer_model = printer_preset.config.opt_string("printer_model");
|
||||
std::string vendor_repo_prefix;
|
||||
if (printer_preset.vendor) {
|
||||
vendor_repo_prefix = printer_preset.vendor->repo_prefix;
|
||||
} else if (std::string inherits = printer_preset.inherits(); !inherits.empty()) {
|
||||
const Preset *parent = wxGetApp().preset_bundle->printers.find_preset(inherits);
|
||||
if (parent && parent->vendor) {
|
||||
vendor_repo_prefix = parent->vendor->repo_prefix;
|
||||
}
|
||||
}
|
||||
if (printer_model.find(vendor_repo_prefix) == 0) {
|
||||
printer_model = printer_model.substr(vendor_repo_prefix.size());
|
||||
boost::trim_left(printer_model);
|
||||
}
|
||||
|
||||
const PresetWithVendorProfile& printer_with_vendor = wxGetApp().preset_bundle->printers.get_preset_with_vendor_profile(printer_preset);
|
||||
printer_model = printer_preset.trim_vendor_repo_prefix(printer_model, printer_with_vendor.vendor);
|
||||
|
||||
if (printer_preset.config.has("nozzle_diameter")) {
|
||||
double nozzle_diameter = static_cast<const ConfigOptionFloats*>(printer_preset.config.option("nozzle_diameter"))->values[0];
|
||||
wxString nozzle_diameter_serialized = double_to_string(nozzle_diameter);
|
||||
@ -1043,19 +1032,8 @@ static bool fill_data_to_connect_info_line( const Preset& printer_preset,
|
||||
for (const auto& [printer_model_nozzle_pair, states] : printer_state_map) {
|
||||
// get printer_model without repo prefix
|
||||
std::string printer_model = printer_preset.config.opt_string("printer_model");
|
||||
std::string vendor_repo_prefix;
|
||||
if (printer_preset.vendor) {
|
||||
vendor_repo_prefix = printer_preset.vendor->repo_prefix;
|
||||
} else if (std::string inherits = printer_preset.inherits(); !inherits.empty()) {
|
||||
const Preset *parent = wxGetApp().preset_bundle->printers.find_preset(inherits);
|
||||
if (parent && parent->vendor) {
|
||||
vendor_repo_prefix = parent->vendor->repo_prefix;
|
||||
}
|
||||
}
|
||||
if (printer_model.find(vendor_repo_prefix) == 0) {
|
||||
printer_model = printer_model.substr(vendor_repo_prefix.size());
|
||||
boost::trim_left(printer_model);
|
||||
}
|
||||
const PresetWithVendorProfile& printer_with_vendor = wxGetApp().preset_bundle->printers.get_preset_with_vendor_profile(printer_preset);
|
||||
printer_model = printer_preset.trim_vendor_repo_prefix(printer_model, printer_with_vendor.vendor);
|
||||
|
||||
if (printer_preset.config.has("nozzle_diameter")) {
|
||||
double nozzle_diameter = static_cast<const ConfigOptionFloats*>(printer_preset.config.option("nozzle_diameter"))->values[0];
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#include "libslic3r/Model.hpp"
|
||||
#include "libslic3r/SLAPrint.hpp"
|
||||
#include "libslic3r/GCode/GCodeProcessor.hpp"
|
||||
#include "libslic3r/GCode/GCodeWriter.hpp"
|
||||
#include "libslic3r/GCode/Thumbnails.hpp"
|
||||
@ -3671,8 +3672,9 @@ void TabPrinter::update_fff()
|
||||
|
||||
bool Tab::is_prusa_printer() const
|
||||
{
|
||||
std::string printer_model = m_preset_bundle->printers.get_edited_preset().config.opt_string("printer_model");
|
||||
return printer_model == "SL1" || printer_model == "SL1S" || printer_model == "M1";
|
||||
const Preset& edited_preset = m_preset_bundle->printers.get_edited_preset();
|
||||
std::string printer_model = edited_preset.trim_vendor_repo_prefix(edited_preset.config.opt_string("printer_model"));
|
||||
return SLAPrint::is_prusa_print(printer_model);
|
||||
}
|
||||
|
||||
void TabPrinter::update_sla()
|
||||
|
@ -577,19 +577,8 @@ void PrinterPickWebViewDialog::request_compatible_printers_FFF() {
|
||||
filament_abrasive_serialized += "]";
|
||||
|
||||
std::string printer_model_serialized = full_config.option("printer_model")->serialize();
|
||||
std::string vendor_repo_prefix;
|
||||
if (selected_printer.vendor) {
|
||||
vendor_repo_prefix = selected_printer.vendor->repo_prefix;
|
||||
} else if (std::string inherits = selected_printer.inherits(); !inherits.empty()) {
|
||||
const Preset *parent = wxGetApp().preset_bundle->printers.find_preset(inherits);
|
||||
if (parent && parent->vendor) {
|
||||
vendor_repo_prefix = parent->vendor->repo_prefix;
|
||||
}
|
||||
}
|
||||
if (printer_model_serialized.find(vendor_repo_prefix) == 0) {
|
||||
printer_model_serialized = printer_model_serialized.substr(vendor_repo_prefix.size());
|
||||
boost::trim_left(printer_model_serialized);
|
||||
}
|
||||
const PresetWithVendorProfile& printer_with_vendor = wxGetApp().preset_bundle->printers.get_preset_with_vendor_profile(selected_printer);
|
||||
printer_model_serialized = selected_printer.trim_vendor_repo_prefix(printer_model_serialized, printer_with_vendor.vendor);
|
||||
|
||||
const std::string uuid = wxGetApp().plater()->get_user_account()->get_current_printer_uuid_from_connect(printer_model_serialized);
|
||||
const std::string filename = wxGetApp().plater()->get_upload_filename();
|
||||
@ -615,18 +604,9 @@ void PrinterPickWebViewDialog::request_compatible_printers_SLA()
|
||||
std::string printer_model_serialized = selected_printer.config.option("printer_model")->serialize();
|
||||
|
||||
std::string vendor_repo_prefix;
|
||||
if (selected_printer.vendor) {
|
||||
vendor_repo_prefix = selected_printer.vendor->repo_prefix;
|
||||
} else if (std::string inherits = selected_printer.inherits(); !inherits.empty()) {
|
||||
const Preset *parent = wxGetApp().preset_bundle->printers.find_preset(inherits);
|
||||
if (parent && parent->vendor) {
|
||||
vendor_repo_prefix = parent->vendor->repo_prefix;
|
||||
}
|
||||
}
|
||||
if (printer_model_serialized.find(vendor_repo_prefix) == 0) {
|
||||
printer_model_serialized = printer_model_serialized.substr(vendor_repo_prefix.size());
|
||||
boost::trim_left(printer_model_serialized);
|
||||
}
|
||||
const PresetWithVendorProfile& printer_with_vendor = wxGetApp().preset_bundle->printers.get_preset_with_vendor_profile(selected_printer);
|
||||
printer_model_serialized = selected_printer.trim_vendor_repo_prefix(printer_model_serialized, printer_with_vendor.vendor);
|
||||
|
||||
const Preset& selected_material = wxGetApp().preset_bundle->sla_materials.get_selected_preset();
|
||||
const std::string material_type_serialized = selected_material.config.option("material_type")->serialize();
|
||||
const std::string uuid = wxGetApp().plater()->get_user_account()->get_current_printer_uuid_from_connect(printer_model_serialized);
|
||||
|
Loading…
x
Reference in New Issue
Block a user