From 29459fe4cb5324ce600f42782576a34f226dd3f2 Mon Sep 17 00:00:00 2001 From: manch1n Date: Mon, 10 Apr 2023 16:03:28 +0800 Subject: [PATCH] FIX: avoid wipe tower conflict with objects Change-Id: I09f6937a4bb698e4981c094c5694b3ce50efd2b4 (cherry picked from commit 2fc3f05732b8e5c7132b6c8a5f4403d30c516bff) --- src/slic3r/GUI/GLCanvas3D.cpp | 22 +++++++++++++++------- src/slic3r/GUI/GLCanvas3D.hpp | 2 +- src/slic3r/GUI/Jobs/ArrangeJob.cpp | 9 ++++++--- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 50224cdb96..0377bf5a93 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1718,7 +1718,7 @@ bool GLCanvas3D::make_current_for_postinit() { return _set_current(); } -Points GLCanvas3D::estimate_wipe_tower_points(int plate_index) const +Points GLCanvas3D::estimate_wipe_tower_points(int plate_index, bool global) const { PartPlateList & ppl = wxGetApp().plater()->get_partplate_list(); DynamicPrintConfig &proj_cfg = wxGetApp().preset_bundle->project_config; @@ -1734,18 +1734,26 @@ Points GLCanvas3D::estimate_wipe_tower_points(int plate_index) const if (wipe_tower_size(1) == 0) { // when depth is unavailable (no items on this plate), we have to estimate the depth using the extruder number of all plates std::set extruder_ids; - auto pl = ppl.get_plate_list(); - for (const auto& p : pl) { - auto es = p->get_extruders(); + if (global) { + auto objs = wxGetApp().obj_list()->objects(); + for (ModelObject *obj : *objs) { + for (ModelVolume *volume : obj->volumes) { + std::vector es = volume->get_extruders(); + extruder_ids.insert(es.begin(), es.end()); + } + } + } else { + PartPlate* pl = ppl.get_plate(plate_index); + std::vector es = pl->get_extruders(); extruder_ids.insert(es.begin(), es.end()); } - int extruder_size = extruder_ids.size(); + int extruder_size = extruder_ids.size(); wipe_tower_size(1) = extruder_size * print.wipe_tower_data(extruder_size).depth + 2 * print.wipe_tower_data().brim_width; } - Vec3d plate_origin = ppl.get_plate(plate_index)->get_origin(); + Vec3d plate_origin = ppl.get_plate(plate_index)->get_origin(); Point wt_min_corner{scale_(x), scale_(y)}; Point wt_max_corner(scale_(x + wipe_tower_size(0)), scale_(y + wipe_tower_size(1))); - return {wt_min_corner, {wt_max_corner.x(), wt_min_corner.y()}, wt_max_corner, {wt_min_corner.x(),wt_max_corner.y()}}; + return {wt_min_corner, {wt_max_corner.x(), wt_min_corner.y()}, wt_max_corner, {wt_min_corner.x(), wt_max_corner.y()}}; } void GLCanvas3D::render(bool only_init) diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index 37f61d0713..8beb998384 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -1059,7 +1059,7 @@ public: bool make_current_for_postinit(); //BBS - Points estimate_wipe_tower_points(int plate_index) const; + Points estimate_wipe_tower_points(int plate_index, bool global = true) const; private: bool _is_shown_on_screen() const; diff --git a/src/slic3r/GUI/Jobs/ArrangeJob.cpp b/src/slic3r/GUI/Jobs/ArrangeJob.cpp index b81b015168..773d257697 100644 --- a/src/slic3r/GUI/Jobs/ArrangeJob.cpp +++ b/src/slic3r/GUI/Jobs/ArrangeJob.cpp @@ -311,9 +311,12 @@ void ArrangeJob::prepare_wipe_tower() const GLCanvas3D* canvas3D=static_cast(m_plater->canvas3D()); for (int bedid = 0; bedid < MAX_NUM_PLATES; bedid++) { if (!plates_have_wipe_tower[bedid]) { - wipe_tower_ap.translation = {0, 0}; - wipe_tower_ap.poly.contour.points = canvas3D->estimate_wipe_tower_points(bedid); - wipe_tower_ap.bed_idx = bedid; + wipe_tower_ap.translation = {0, 0}; + bool global = true; + int state = m_plater->get_prepare_state(); + if (state == Job::JobPrepareState::PREPARE_STATE_MENU) { global = false; } + wipe_tower_ap.poly.contour.points = canvas3D->estimate_wipe_tower_points(bedid, global); + wipe_tower_ap.bed_idx = bedid; m_unselected.emplace_back(wipe_tower_ap); } }