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 000000000..4c4cfd755 Binary files /dev/null and b/resources/icons/erase.png differ diff --git a/resources/icons/exclamation_mark_.png b/resources/icons/exclamation_mark_.png new file mode 100644 index 000000000..886baf227 Binary files /dev/null and b/resources/icons/exclamation_mark_.png differ 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,