mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 16:45:53 +08:00
Improve filtering on Klipper exclude_objects labels (#11802, PR#11813 by @jschuh)
This commit is contained in:
parent
33d5b4d60b
commit
834f6ef37c
@ -81,7 +81,8 @@ void LabelObjects::init(const Print& print)
|
|||||||
if (object_has_more_instances)
|
if (object_has_more_instances)
|
||||||
name += " (Instance " + std::to_string(instance_id) + ")";
|
name += " (Instance " + std::to_string(instance_id) + ")";
|
||||||
if (m_flavor == gcfKlipper) {
|
if (m_flavor == gcfKlipper) {
|
||||||
const std::string banned = "-. \r\n\v\t\f";
|
// Disallow Klipper special chars, common illegal filename chars, etc.
|
||||||
|
const std::string banned = "\b\t\n\v\f\r \"#%&\'*-./:;<>\\";
|
||||||
std::replace_if(name.begin(), name.end(), [&banned](char c) { return banned.find(c) != std::string::npos; }, '_');
|
std::replace_if(name.begin(), name.end(), [&banned](char c) { return banned.find(c) != std::string::npos; }, '_');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -111,7 +112,7 @@ std::string LabelObjects::all_objects_header() const
|
|||||||
for (const auto& [print_instance, label] : label_data_sorted) {
|
for (const auto& [print_instance, label] : label_data_sorted) {
|
||||||
if (m_label_objects_style == LabelObjectsStyle::Firmware && m_flavor == gcfKlipper) {
|
if (m_label_objects_style == LabelObjectsStyle::Firmware && m_flavor == gcfKlipper) {
|
||||||
char buffer[64];
|
char buffer[64];
|
||||||
out += "EXCLUDE_OBJECT_DEFINE NAME=" + label.name;
|
out += "EXCLUDE_OBJECT_DEFINE NAME='" + label.name + "'";
|
||||||
Polygon outline = instance_outline(print_instance);
|
Polygon outline = instance_outline(print_instance);
|
||||||
assert(! outline.empty());
|
assert(! outline.empty());
|
||||||
outline.douglas_peucker(50000.f);
|
outline.douglas_peucker(50000.f);
|
||||||
@ -154,7 +155,7 @@ std::string LabelObjects::start_object(const PrintInstance& print_instance, Incl
|
|||||||
}
|
}
|
||||||
out += "\n";
|
out += "\n";
|
||||||
} else if (m_flavor == gcfKlipper)
|
} else if (m_flavor == gcfKlipper)
|
||||||
out += "EXCLUDE_OBJECT_START NAME=" + label.name + "\n";
|
out += "EXCLUDE_OBJECT_START NAME='" + label.name + "'\n";
|
||||||
else {
|
else {
|
||||||
// Not supported by / implemented for the other firmware flavors.
|
// Not supported by / implemented for the other firmware flavors.
|
||||||
}
|
}
|
||||||
@ -178,7 +179,7 @@ std::string LabelObjects::stop_object(const PrintInstance& print_instance) const
|
|||||||
if (m_flavor == GCodeFlavor::gcfMarlinFirmware || m_flavor == GCodeFlavor::gcfMarlinLegacy || m_flavor == GCodeFlavor::gcfRepRapFirmware)
|
if (m_flavor == GCodeFlavor::gcfMarlinFirmware || m_flavor == GCodeFlavor::gcfMarlinLegacy || m_flavor == GCodeFlavor::gcfRepRapFirmware)
|
||||||
out += std::string("M486 S-1\n");
|
out += std::string("M486 S-1\n");
|
||||||
else if (m_flavor ==gcfKlipper)
|
else if (m_flavor ==gcfKlipper)
|
||||||
out += "EXCLUDE_OBJECT_END NAME=" + label.name + "\n";
|
out += "EXCLUDE_OBJECT_END NAME='" + label.name + "'\n";
|
||||||
else {
|
else {
|
||||||
// Not supported by / implemented for the other firmware flavors.
|
// Not supported by / implemented for the other firmware flavors.
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user