ENH: allow generate wipe tower when print ByObject

allow generate wipe tower when print ByObject if there is only one object

Change-Id: I199e9cab7bd7c963edf58e829c663bb91c12f4f8
(cherry picked from commit 7153c30800022f3afb9811c67f88ba28c9b25d20)
This commit is contained in:
zhimin.zeng 2022-12-14 15:05:01 +08:00 committed by Lane.Wei
parent 1c5c9bd3d2
commit 93b1a335d2
7 changed files with 38 additions and 9 deletions

View file

@ -1409,6 +1409,8 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
// We don't allow switching of extruders per layer by Model::custom_gcode_per_print_z in sequential mode.
// Use the extruder IDs collected from Regions.
this->set_extruders(print.extruders());
has_wipe_tower = print.has_wipe_tower() && tool_ordering.has_wipe_tower();
} else {
// Find tool ordering for all the objects at once, and the initial extruder ID.
// If the tool ordering has been pre-calculated by Print class for wipe tower already, reuse it.
@ -1582,7 +1584,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
file.write("M981 S1 P20000 ;open spaghetti detector\n");
// Do all objects for each layer.
if (print.config().print_sequence == PrintSequence::ByObject) {
if (print.config().print_sequence == PrintSequence::ByObject && !has_wipe_tower) {
size_t finished_objects = 0;
const PrintObject *prev_object = (*print_object_instance_sequential_active)->print_object;
for (; print_object_instance_sequential_active != print_object_instances_ordering.end(); ++ print_object_instance_sequential_active) {
@ -2752,8 +2754,9 @@ GCode::LayerResult GCode::process_layer(
// BBS: ordering instances by extruder
std::vector<InstanceToPrint> instances_to_print;
bool has_prime_tower = print.config().enable_prime_tower
&& print.config().print_sequence == PrintSequence::ByLayer
&& print.extruders().size() > 1;
&& print.extruders().size() > 1
&& (print.config().print_sequence == PrintSequence::ByLayer
|| (print.config().print_sequence == PrintSequence::ByObject && print.objects().size() == 1));
if (has_prime_tower) {
int plate_idx = print.get_plate_index();
Point wt_pos(print.config().wipe_tower_x.get_at(plate_idx), print.config().wipe_tower_y.get_at(plate_idx));