add plate origin when looking for wipe tower (#2441)

* add plate origin when looking for wipe tower

* fix build errors and handle more plate offset cases

---------

Co-authored-by: SoftFever <103989404+SoftFever@users.noreply.github.com>
Co-authored-by: SoftFever <softfeverever@gmail.com>
This commit is contained in:
Evan Felix 2023-10-18 02:45:54 -07:00 committed by GitHub
parent d0ccc5ee96
commit ef831ab8b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -666,6 +666,8 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
Vec2f wipe_tower_offset = tcr.priming ? Vec2f::Zero() : m_wipe_tower_pos; Vec2f wipe_tower_offset = tcr.priming ? Vec2f::Zero() : m_wipe_tower_pos;
float wipe_tower_rotation = tcr.priming ? 0.f : alpha; float wipe_tower_rotation = tcr.priming ? 0.f : alpha;
Vec2f plate_origin_2d(m_plate_origin(0), m_plate_origin(1));
std::string tcr_rotated_gcode = post_process_wipe_tower_moves(tcr, wipe_tower_offset, wipe_tower_rotation); std::string tcr_rotated_gcode = post_process_wipe_tower_moves(tcr, wipe_tower_offset, wipe_tower_rotation);
@ -689,7 +691,7 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
// then we could simplify the condition and make it more readable. // then we could simplify the condition and make it more readable.
gcode += gcodegen.retract(); gcode += gcodegen.retract();
gcodegen.m_avoid_crossing_perimeters.use_external_mp_once(); gcodegen.m_avoid_crossing_perimeters.use_external_mp_once();
gcode += gcodegen.travel_to(wipe_tower_point_to_object_point(gcodegen, start_pos), erMixed, "Travel to a Wipe Tower"); gcode += gcodegen.travel_to(wipe_tower_point_to_object_point(gcodegen, start_pos + plate_origin_2d), erMixed, "Travel to a Wipe Tower");
gcode += gcodegen.unretract(); gcode += gcodegen.unretract();
} else { } else {
// When this is multiextruder printer without any ramming, we can just change // When this is multiextruder printer without any ramming, we can just change
@ -803,8 +805,8 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
} }
// A phony move to the end position at the wipe tower. // A phony move to the end position at the wipe tower.
gcodegen.writer().travel_to_xy(end_pos.cast<double>()); gcodegen.writer().travel_to_xy((end_pos + plate_origin_2d).cast<double>());
gcodegen.set_last_pos(wipe_tower_point_to_object_point(gcodegen, end_pos)); gcodegen.set_last_pos(wipe_tower_point_to_object_point(gcodegen, end_pos + plate_origin_2d));
if (!is_approx(z, current_z)) { if (!is_approx(z, current_z)) {
gcode += gcodegen.writer().retract(); gcode += gcodegen.writer().retract();
gcode += gcodegen.writer().travel_to_z(current_z, "Travel back up to the topmost object layer."); gcode += gcodegen.writer().travel_to_z(current_z, "Travel back up to the topmost object layer.");