FIX: avoid wipe tower conflict with objects

Change-Id: I09f6937a4bb698e4981c094c5694b3ce50efd2b4
(cherry picked from commit 2fc3f05732b8e5c7132b6c8a5f4403d30c516bff)
This commit is contained in:
manch1n 2023-04-10 16:03:28 +08:00 committed by Lane.Wei
parent 229b173894
commit 29459fe4cb
3 changed files with 22 additions and 11 deletions

View file

@ -1718,7 +1718,7 @@ bool GLCanvas3D::make_current_for_postinit() {
return _set_current(); 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(); PartPlateList & ppl = wxGetApp().plater()->get_partplate_list();
DynamicPrintConfig &proj_cfg = wxGetApp().preset_bundle->project_config; DynamicPrintConfig &proj_cfg = wxGetApp().preset_bundle->project_config;
@ -1734,9 +1734,17 @@ Points GLCanvas3D::estimate_wipe_tower_points(int plate_index) const
if (wipe_tower_size(1) == 0) { 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 // when depth is unavailable (no items on this plate), we have to estimate the depth using the extruder number of all plates
std::set<int> extruder_ids; std::set<int> extruder_ids;
auto pl = ppl.get_plate_list(); if (global) {
for (const auto& p : pl) { auto objs = wxGetApp().obj_list()->objects();
auto es = p->get_extruders(); for (ModelObject *obj : *objs) {
for (ModelVolume *volume : obj->volumes) {
std::vector<int> es = volume->get_extruders();
extruder_ids.insert(es.begin(), es.end());
}
}
} else {
PartPlate* pl = ppl.get_plate(plate_index);
std::vector<int> es = pl->get_extruders();
extruder_ids.insert(es.begin(), es.end()); extruder_ids.insert(es.begin(), es.end());
} }
int extruder_size = extruder_ids.size(); int extruder_size = extruder_ids.size();
@ -1745,7 +1753,7 @@ Points GLCanvas3D::estimate_wipe_tower_points(int plate_index) const
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_min_corner{scale_(x), scale_(y)};
Point wt_max_corner(scale_(x + wipe_tower_size(0)), scale_(y + wipe_tower_size(1))); 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) void GLCanvas3D::render(bool only_init)

View file

@ -1059,7 +1059,7 @@ public:
bool make_current_for_postinit(); bool make_current_for_postinit();
//BBS //BBS
Points estimate_wipe_tower_points(int plate_index) const; Points estimate_wipe_tower_points(int plate_index, bool global = true) const;
private: private:
bool _is_shown_on_screen() const; bool _is_shown_on_screen() const;

View file

@ -312,7 +312,10 @@ void ArrangeJob::prepare_wipe_tower()
for (int bedid = 0; bedid < MAX_NUM_PLATES; bedid++) { for (int bedid = 0; bedid < MAX_NUM_PLATES; bedid++) {
if (!plates_have_wipe_tower[bedid]) { if (!plates_have_wipe_tower[bedid]) {
wipe_tower_ap.translation = {0, 0}; wipe_tower_ap.translation = {0, 0};
wipe_tower_ap.poly.contour.points = canvas3D->estimate_wipe_tower_points(bedid); 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; wipe_tower_ap.bed_idx = bedid;
m_unselected.emplace_back(wipe_tower_ap); m_unselected.emplace_back(wipe_tower_ap);
} }