From cc55bcbf5ef570534c9adc3586ba6fa0c5d9e451 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Fri, 5 May 2023 13:22:14 +0200 Subject: [PATCH] Conflict checker: automatically set the gcode preview at the layer shown in the notification when hitting the action text in it --- src/slic3r/GUI/GLCanvas3D.cpp | 6 ++++-- src/slic3r/GUI/GUI_Preview.cpp | 6 ++++++ src/slic3r/GUI/GUI_Preview.hpp | 2 ++ src/slic3r/GUI/Plater.cpp | 12 ++++++++++++ src/slic3r/GUI/Plater.hpp | 2 ++ 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 4a3732fe9..227df0b41 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -7493,12 +7493,14 @@ void GLCanvas3D::_set_warning_notification(EWarning warning, bool state) const PrintObject* obj2 = reinterpret_cast(conflict_result->_obj2); auto mo = obj2->model_object(); ObjectID id = mo->id(); - auto action_fn = [id](wxEvtHandler*) { + int layer_id = conflict_result->layer; + auto action_fn = [id, layer_id](wxEvtHandler*) { auto& objects = wxGetApp().model().objects; auto iter = id.id ? std::find_if(objects.begin(), objects.end(), [id](auto o) { return o->id() == id; }) : objects.end(); if (iter != objects.end()) { const unsigned int obj_idx = std::distance(objects.begin(), iter); - wxGetApp().CallAfter([obj_idx]() { + wxGetApp().CallAfter([obj_idx, layer_id]() { + wxGetApp().plater()->set_preview_layers_slider_values_range(0, layer_id - 1); wxGetApp().plater()->select_view_3D("3D"); wxGetApp().plater()->canvas3D()->get_selection().add_object(obj_idx, true); wxGetApp().obj_list()->update_selections(); diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index 656bc0b53..74a8719d8 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -181,6 +181,12 @@ Preview::Preview( load_print(); } +void Preview::set_layers_slider_values_range(int bottom, int top) +{ + m_layers_slider->SetHigherValue(std::min(top, m_layers_slider->GetMaxValue())); + m_layers_slider->SetLowerValue(std::max(bottom, m_layers_slider->GetMinValue())); +} + bool Preview::init(wxWindow* parent, Bed3D& bed, Model* model) { if (!Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 /* disable wxTAB_TRAVERSAL */)) diff --git a/src/slic3r/GUI/GUI_Preview.hpp b/src/slic3r/GUI/GUI_Preview.hpp index 25d9fe084..c7b7fdc61 100644 --- a/src/slic3r/GUI/GUI_Preview.hpp +++ b/src/slic3r/GUI/GUI_Preview.hpp @@ -151,6 +151,8 @@ public: void set_keep_current_preview_type(bool value) { m_keep_current_preview_type = value; } + void set_layers_slider_values_range(int bottom, int top); + private: bool init(wxWindow* parent, Bed3D& bed, Model* model); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index d367f1f19..b598abfaf 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1794,6 +1794,8 @@ struct Plater::priv bool init_view_toolbar(); bool init_collapse_toolbar(); + void set_preview_layers_slider_values_range(int bottom, int top); + void update_preview_moves_slider(); void enable_preview_moves_slider(bool enable); @@ -4632,6 +4634,11 @@ bool Plater::priv::init_collapse_toolbar() return true; } +void Plater::priv::set_preview_layers_slider_values_range(int bottom, int top) +{ + preview->set_layers_slider_values_range(bottom, top); +} + void Plater::priv::update_preview_moves_slider() { preview->update_moves_slider(); @@ -7506,6 +7513,11 @@ GLToolbar& Plater::get_collapse_toolbar() return p->collapse_toolbar; } +void Plater::set_preview_layers_slider_values_range(int bottom, int top) +{ + p->set_preview_layers_slider_values_range(bottom, top); +} + void Plater::update_preview_moves_slider() { p->update_preview_moves_slider(); diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 880448c86..8eeabae42 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -399,6 +399,8 @@ public: const GLToolbar& get_collapse_toolbar() const; GLToolbar& get_collapse_toolbar(); + void set_preview_layers_slider_values_range(int bottom, int top); + void update_preview_moves_slider(); void enable_preview_moves_slider(bool enable);