From da18e25dfb917a2e165973160b3340a46888a4a8 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 26 Jul 2018 10:59:03 +0200 Subject: [PATCH] Added callback for 3dScene updating after extruder changing --- lib/Slic3r/GUI/MainFrame.pm | 13 +++++++++-- lib/Slic3r/GUI/Plater.pm | 4 +++- resources/icons/erase.png | Bin 0 -> 488 bytes resources/icons/exclamation_mark_.png | Bin 0 -> 327 bytes xs/src/slic3r/GUI/GUI.cpp | 4 +++- xs/src/slic3r/GUI/GUI.hpp | 3 ++- xs/src/slic3r/GUI/GUI_ObjectParts.cpp | 31 ++++++++++++++------------ xs/src/slic3r/GUI/GUI_ObjectParts.hpp | 1 + xs/xsp/GUI.xsp | 6 +++-- 9 files changed, 41 insertions(+), 21 deletions(-) create mode 100644 resources/icons/erase.png create mode 100644 resources/icons/exclamation_mark_.png diff --git a/lib/Slic3r/GUI/MainFrame.pm b/lib/Slic3r/GUI/MainFrame.pm index 1465c1215..6cf80f24a 100644 --- a/lib/Slic3r/GUI/MainFrame.pm +++ b/lib/Slic3r/GUI/MainFrame.pm @@ -31,6 +31,8 @@ our $OBJECT_SELECTION_CHANGED_EVENT = Wx::NewEventType; our $OBJECT_SETTINGS_CHANGED_EVENT = Wx::NewEventType; # 5) To inform about a remove of object our $OBJECT_REMOVE_EVENT = Wx::NewEventType; +# 6) To inform about a update of the scene +our $UPDATE_SCENE_EVENT = Wx::NewEventType; sub new { my ($class, %params) = @_; @@ -125,6 +127,7 @@ sub _init_tabpanel { event_object_selection_changed => $OBJECT_SELECTION_CHANGED_EVENT, event_object_settings_changed => $OBJECT_SETTINGS_CHANGED_EVENT, event_remove_object => $OBJECT_REMOVE_EVENT, + event_update_scene => $UPDATE_SCENE_EVENT, ), L("Plater")); if (!$self->{no_controller}) { $panel->AddPage($self->{controller} = Slic3r::GUI::Controller->new($panel), L("Controller")); @@ -191,7 +194,7 @@ sub _init_tabpanel { $self->{plater}->item_changed_selection($obj_idx); }); - # The following event is emited by the C++ Tab implementation on object settings change. + # The following event is emited by the C++ GUI implementation on object settings change. EVT_COMMAND($self, -1, $OBJECT_SETTINGS_CHANGED_EVENT, sub { my ($self, $event) = @_; @@ -201,11 +204,17 @@ sub _init_tabpanel { $self->{plater}->changed_object_settings($obj_idx, $parts_changed, $part_settings_changed); }); - # The following event is emited by the C++ Tab implementation on object settings change. + # The following event is emited by the C++ GUI implementation on object remove. EVT_COMMAND($self, -1, $OBJECT_REMOVE_EVENT, sub { my ($self, $event) = @_; $self->{plater}->remove(); }); + + # The following event is emited by the C++ GUI implementation on extruder change for object. + EVT_COMMAND($self, -1, $UPDATE_SCENE_EVENT, sub { + my ($self, $event) = @_; + $self->{plater}->update(); + }); Slic3r::GUI::create_preset_tabs($self->{no_controller}, $VALUE_CHANGE_EVENT, $PRESETS_CHANGED_EVENT); diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index ac54e67d8..ac4b9f78f 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -58,6 +58,7 @@ sub new { $self->{event_object_selection_changed} = $params{event_object_selection_changed}; $self->{event_object_settings_changed} = $params{event_object_settings_changed}; $self->{event_remove_object} = $params{event_remove_object}; + $self->{event_update_scene} = $params{event_update_scene}; # C++ Slic3r::Model with Perl extensions in Slic3r/Model.pm $self->{model} = Slic3r::Model->new; @@ -452,7 +453,8 @@ sub new { $self->{model}, $self->{event_object_selection_changed}, $self->{event_object_settings_changed}, - $self->{event_remove_object}); + $self->{event_remove_object}, + $self->{event_update_scene}); # if ($expert_mode_part_sizer->IsShown(2)==1) # { # $expert_mode_part_sizer->Layout; diff --git a/resources/icons/erase.png b/resources/icons/erase.png new file mode 100644 index 0000000000000000000000000000000000000000..4c4cfd755c17deb467a6b7724e3c99f2cdd36912 GIT binary patch literal 488 zcmVP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGmbN~PnbOGLGA9w%&0ewkCK~y+T)ssC- zLSYog&-IdXsNfYUj`4; z6zA{jH7rUcSe+aT-+?t?jQt*;s#TmOlQ_#{P|0R-Z=F3i8u%EG<8Cssc3d10d6H=8 zstSur1q@9CITQj@*Fio!griPJ+ySb{=W{!E1CTN4P?BZQ*Q8K@4@Ci_z2s;F+z1-n z6o5>3Y`%%e8?#ysw)E&Am4dg;2Bzh*b5WAGP7hoGL)nFWARPwLDBk7s!habK@zU?d zWw$H*J!$2|3Bb%-Exd|E@H&wYz9DABWv_>QSr)#%XXAba8vS4pFT!D5QC5bt*%|Na zb-XPW#oCJ#KyA12ED*p!E+>5Zu{X$hEQYU|Ce}7ifSs!1DM_*=%W8ZLz!mQ3@r|X8 e&AQL70(Y)*K0-;2lpF#}Etur4tTv9Wvl)`~5}E=9h?Fv-$dY zdpKWt3aT?pS}i}fY;&eZ&NaT4T7igvX7_K+%2SDK{LC7>IIAP2wLN#|vIEKfrzbp& zl2>KW`IB6{P=RSxY?u<0WL`Fx&BFe+1$OF_6doi#|Iqzl^#LFL1HYH4xS0j5=h(U4 zE+KxB^becOvnMDreiFV>Hm5=Qxoho*sE>aoGrV*klo$MKlsNOI#ZSQdLEV%@mwhgu zG&DXW$mh4ccKh1#$|dNnX2*u3T9R&)T2u=nPF#FjHc!@V(@Kv;Qb`q0^>@AFR*T;1 U>+j7O3iKy~r>mdKI;Vst05X$(rvLx| literal 0 HcmV?d00001 diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index 72efd7f29..cef9d95ed 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -896,11 +896,13 @@ void add_expert_mode_part( wxWindow* parent, wxBoxSizer* sizer, Model &model, int event_object_selection_changed, int event_object_settings_changed, - int event_remove_object) + int event_remove_object, + int event_update_scene) { set_event_object_selection_changed(event_object_selection_changed); set_event_object_settings_changed(event_object_settings_changed); set_event_remove_object(event_remove_object); + set_event_update_scene(event_update_scene); set_objects_from_model(model); init_mesh_icons(); diff --git a/xs/src/slic3r/GUI/GUI.hpp b/xs/src/slic3r/GUI/GUI.hpp index 8199a1349..7b9d3c398 100644 --- a/xs/src/slic3r/GUI/GUI.hpp +++ b/xs/src/slic3r/GUI/GUI.hpp @@ -191,7 +191,8 @@ void add_expert_mode_part( wxWindow* parent, wxBoxSizer* sizer, Model &model, int event_object_selection_changed, int event_object_settings_changed, - int event_remove_object); + int event_remove_object, + int event_update_scene); void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFlexGridSizer* preset_sizer); // Update view mode according to selected menu void update_mode(); diff --git a/xs/src/slic3r/GUI/GUI_ObjectParts.cpp b/xs/src/slic3r/GUI/GUI_ObjectParts.cpp index 252dcec26..705d72643 100644 --- a/xs/src/slic3r/GUI/GUI_ObjectParts.cpp +++ b/xs/src/slic3r/GUI/GUI_ObjectParts.cpp @@ -51,6 +51,7 @@ std::vector > m_og_settings; int m_event_object_selection_changed = 0; int m_event_object_settings_changed = 0; int m_event_remove_object = 0; +int m_event_update_scene = 0; bool m_parts_changed = false; bool m_part_settings_changed = false; @@ -116,6 +117,9 @@ void set_event_object_settings_changed(const int& event){ void set_event_remove_object(const int& event){ m_event_remove_object = event; } +void set_event_update_scene(const int& event){ + m_event_update_scene = event; +} void set_objects_from_model(Model &model) { m_objects = &(model.objects); @@ -126,7 +130,7 @@ void init_mesh_icons(){ m_icon_solidmesh = wxIcon(Slic3r::GUI::from_u8(Slic3r::var("object.png")), wxBITMAP_TYPE_PNG);//(Slic3r::var("package.png")), wxBITMAP_TYPE_PNG); // init icon for manifold warning - m_icon_manifold_warning = wxIcon(Slic3r::GUI::from_u8(Slic3r::var("error.png")), wxBITMAP_TYPE_PNG); + m_icon_manifold_warning = wxIcon(Slic3r::GUI::from_u8(Slic3r::var("exclamation_mark_.png")), wxBITMAP_TYPE_PNG);//(Slic3r::var("error.png")), wxBITMAP_TYPE_PNG); // init bitmap for "Add Settings" context menu m_bmp_cog = wxBitmap(Slic3r::GUI::from_u8(Slic3r::var("cog.png")), wxBITMAP_TYPE_PNG); @@ -208,20 +212,19 @@ wxBoxSizer* content_objects_list(wxWindow *win) event.Skip(); }); - m_objects_ctrl->Bind(wxEVT_DATAVIEW_ITEM_VALUE_CHANGED, [](wxDataViewEvent& event) + m_objects_ctrl->Bind(wxEVT_CHOICE, [](wxCommandEvent& event) { - if (event.GetColumn() == 3) - { - if (!*m_config) - return; - wxVariant variant; - m_objects_model->GetValue(variant, event.GetItem(), 3); - auto str = variant.GetString(); - int extruder = str.size() > 1 ? 0 : atoi(str.c_str()); + if (!*m_config) + return; + auto config = m_config; -// if ((*m_config)->has("extruder")) - auto config = m_config; - (*m_config)->set_key_value("extruder", new ConfigOptionInt(extruder)); + wxString str = event.GetString(); + int extruder = str.size() > 1 ? 0 : atoi(str.c_str()); + (*m_config)->set_key_value("extruder", new ConfigOptionInt(extruder)); + + if (m_event_update_scene > 0) { + wxCommandEvent e(m_event_update_scene); + get_main_frame()->ProcessWindowEvent(e); } }); @@ -666,7 +669,7 @@ void update_settings_list() // The issue apparently manifests when Show()ing a window with overlay scrollbars while the UI is frozen. For this reason, // we will Thaw the UI prematurely on Linux. This means destroing the no_updates object prematurely. #ifdef __linux__ - std::unique_ptr no_updates(new wxWindowUpdateLocker(this)); + std::unique_ptr no_updates(new wxWindowUpdateLocker(parent)); #else wxWindowUpdateLocker noUpdates(parent); #endif diff --git a/xs/src/slic3r/GUI/GUI_ObjectParts.hpp b/xs/src/slic3r/GUI/GUI_ObjectParts.hpp index 4f1c15e3a..aaeff7a43 100644 --- a/xs/src/slic3r/GUI/GUI_ObjectParts.hpp +++ b/xs/src/slic3r/GUI/GUI_ObjectParts.hpp @@ -74,6 +74,7 @@ void init_mesh_icons(); void set_event_object_selection_changed(const int& event); void set_event_object_settings_changed(const int& event); void set_event_remove_object(const int& event); +void set_event_update_scene(const int& event); void set_objects_from_model(Model &model); bool is_parts_changed(); diff --git a/xs/xsp/GUI.xsp b/xs/xsp/GUI.xsp index 98d3169bd..8ad8c8184 100644 --- a/xs/xsp/GUI.xsp +++ b/xs/xsp/GUI.xsp @@ -91,13 +91,15 @@ void add_expert_mode_part( SV *ui_parent, SV *ui_sizer, Model *model, int event_object_selection_changed, int event_object_settings_changed, - int event_remove_object) + int event_remove_object, + int event_update_scene) %code%{ Slic3r::GUI::add_expert_mode_part( (wxWindow*)wxPli_sv_2_object(aTHX_ ui_parent, "Wx::Window"), (wxBoxSizer*)wxPli_sv_2_object(aTHX_ ui_sizer, "Wx::BoxSizer"), *model, event_object_selection_changed, event_object_settings_changed, - event_remove_object); %}; + event_remove_object, + event_update_scene); %}; void set_objects_from_perl( SV *ui_parent, SV *frequently_changed_parameters_sizer,