From 1fe0d7be8cf5627facd71ba3cceda7ee9fb5d6ae Mon Sep 17 00:00:00 2001 From: "lane.wei" Date: Tue, 31 Jan 2023 10:59:31 +0800 Subject: [PATCH] ENH: refine some small logic 1. continue post_init when gl window not ready under linux 2. use deleted_wipe_towers in reload_scene to judge whether it is deleted Change-Id: I5be2ac876842e5432d254d47e4fe31f066455106 (cherry picked from commit 5e61a21d5662ccc656136b6a219c2358364c36d9) --- src/slic3r/GUI/GLCanvas3D.cpp | 15 +++++------ src/slic3r/GUI/GUI_App.cpp | 48 ++++++++++++++++------------------- 2 files changed, 29 insertions(+), 34 deletions(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index b08d25368..bb4b7edfd 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -2170,16 +2170,15 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re struct GLVolumeState { GLVolumeState() : - volume_idx(size_t(-1)), was_wipe_tower(0) {} + volume_idx(size_t(-1)) {} GLVolumeState(const GLVolume* volume, unsigned int volume_idx) : - composite_id(volume->composite_id), volume_idx(volume_idx), was_wipe_tower(volume->is_wipe_tower) {} + composite_id(volume->composite_id), volume_idx(volume_idx) {} GLVolumeState(const GLVolume::CompositeID &composite_id) : - composite_id(composite_id), volume_idx(size_t(-1)), was_wipe_tower(0) {} + composite_id(composite_id), volume_idx(size_t(-1)) {} GLVolume::CompositeID composite_id; // Volume index in the old GLVolume vector. size_t volume_idx; - bool was_wipe_tower; }; // SLA steps to pull the preview meshes for. @@ -2388,8 +2387,8 @@ void GLCanvas3D::reload_scene(bool refresh_immediately, bool force_full_scene_re // slow thing of seeing if they were in the deleted list, and if // so, if they were a wipe tower. bool was_deleted_wipe_tower = false; - for (int del_idx = 0; del_idx < deleted_volumes.size(); del_idx++) { - if (deleted_volumes[del_idx].volume_idx == temp_idx && deleted_volumes[del_idx].was_wipe_tower) { + for (int del_idx = 0; del_idx < deleted_wipe_towers.size(); del_idx++) { + if (deleted_wipe_towers[del_idx].volume_idx == temp_idx) { was_deleted_wipe_tower = true; break; } @@ -4275,8 +4274,8 @@ void GLCanvas3D::on_paint(wxPaintEvent& evt) this->render(); } -void GLCanvas3D::force_set_focus() { - m_canvas->SetFocus(); +void GLCanvas3D::force_set_focus() { + m_canvas->SetFocus(); }; void GLCanvas3D::on_set_focus(wxFocusEvent& evt) diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index a66d6faf5..1f5da3634 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -1018,34 +1018,30 @@ void GUI_App::post_init() plater_->select_view_3D("3D"); //BBS init the opengl resource here #ifdef __linux__ - if (!plater_->canvas3D()->get_wxglcanvas()->IsShownOnScreen() || - !plater_->canvas3D()->make_current_for_postinit()) { - /* The canvas3d didn't actually exist (and therefore, there is - * no current EGL context) -- try again later, I guess. - */ - m_post_initialized = false; - return; + if (plater_->canvas3D()->get_wxglcanvas()->IsShownOnScreen()&&plater_->canvas3D()->make_current_for_postinit()) { +#endif + Size canvas_size = plater_->canvas3D()->get_canvas_size(); + wxGetApp().imgui()->set_display_size(static_cast(canvas_size.get_width()), static_cast(canvas_size.get_height())); + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", start to init opengl"; + wxGetApp().init_opengl(); + + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", finished init opengl"; + plater_->canvas3D()->init(); + + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", finished init canvas3D"; + wxGetApp().imgui()->new_frame(); + + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", finished init imgui frame"; + plater_->canvas3D()->enable_render(true); + + if (!slow_bootup) { + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", start to render a first frame for test"; + plater_->canvas3D()->render(false); + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", finished rendering a first frame for test"; + } +#ifdef __linux__ } #endif - Size canvas_size = plater_->canvas3D()->get_canvas_size(); - wxGetApp().imgui()->set_display_size(static_cast(canvas_size.get_width()), static_cast(canvas_size.get_height())); - BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", start to init opengl"; - wxGetApp().init_opengl(); - - BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", finished init opengl"; - plater_->canvas3D()->init(); - - BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", finished init canvas3D"; - wxGetApp().imgui()->new_frame(); - - BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", finished init imgui frame"; - plater_->canvas3D()->enable_render(true); - - if (!slow_bootup) { - BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", start to render a first frame for test"; - plater_->canvas3D()->render(false); - BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", finished rendering a first frame for test"; - } if (is_editor()) mainframe->select_tab(size_t(0)); mainframe->Thaw();