mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-12 04:59:01 +08:00
Remove repeated spaces from the wipe tower gcode (#7503)
This commit is contained in:
parent
684733af52
commit
3934b1dbed
@ -363,7 +363,7 @@ namespace Slic3r {
|
|||||||
// All G1 commands should be translated and rotated. X and Y coords are
|
// All G1 commands should be translated and rotated. X and Y coords are
|
||||||
// only pushed to the output when they differ from last time.
|
// only pushed to the output when they differ from last time.
|
||||||
// WT generator can override this by appending the never_skip_tag
|
// WT generator can override this by appending the never_skip_tag
|
||||||
if (line.find("G1 ") == 0) {
|
if (boost::starts_with(line, "G1 ")) {
|
||||||
bool never_skip = false;
|
bool never_skip = false;
|
||||||
auto it = line.find(WipeTower::never_skip_tag());
|
auto it = line.find(WipeTower::never_skip_tag());
|
||||||
if (it != std::string::npos) {
|
if (it != std::string::npos) {
|
||||||
@ -375,6 +375,7 @@ namespace Slic3r {
|
|||||||
std::istringstream line_str(line);
|
std::istringstream line_str(line);
|
||||||
line_str >> std::noskipws; // don't skip whitespace
|
line_str >> std::noskipws; // don't skip whitespace
|
||||||
char ch = 0;
|
char ch = 0;
|
||||||
|
line_str >> ch >> ch; // read the "G1"
|
||||||
while (line_str >> ch) {
|
while (line_str >> ch) {
|
||||||
if (ch == 'X' || ch == 'Y')
|
if (ch == 'X' || ch == 'Y')
|
||||||
line_str >> (ch == 'X' ? pos.x() : pos.y());
|
line_str >> (ch == 'X' ? pos.x() : pos.y());
|
||||||
@ -386,14 +387,16 @@ namespace Slic3r {
|
|||||||
|
|
||||||
if (transformed_pos != old_pos || never_skip) {
|
if (transformed_pos != old_pos || never_skip) {
|
||||||
line = line_out.str();
|
line = line_out.str();
|
||||||
|
boost::trim_left(line); // Remove leading spaces
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << std::fixed << std::setprecision(3) << "G1 ";
|
oss << std::fixed << std::setprecision(3) << "G1";
|
||||||
if (transformed_pos.x() != old_pos.x() || never_skip)
|
if (transformed_pos.x() != old_pos.x() || never_skip)
|
||||||
oss << " X" << transformed_pos.x() - extruder_offset.x();
|
oss << " X" << transformed_pos.x() - extruder_offset.x();
|
||||||
if (transformed_pos.y() != old_pos.y() || never_skip)
|
if (transformed_pos.y() != old_pos.y() || never_skip)
|
||||||
oss << " Y" << transformed_pos.y() - extruder_offset.y();
|
oss << " Y" << transformed_pos.y() - extruder_offset.y();
|
||||||
|
if (! line.empty())
|
||||||
oss << " ";
|
oss << " ";
|
||||||
line.replace(line.find("G1 "), 3, oss.str());
|
line = oss.str() + line;
|
||||||
old_pos = transformed_pos;
|
old_pos = transformed_pos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user