From 76838703502be55a6cb67d72bf4990619a013ad6 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 1 Aug 2018 15:34:33 +0200 Subject: [PATCH] New perl callback to force reloading of 3d scene after Purging volumes are changed After the changes in previous commit, the 3D scene must be reloaded after the wipe tower is invalidated. This can mostly be done on the C++ side, but reloading after Purging volumes are changed required this C++ -> Perl call --- lib/Slic3r/GUI/Plater.pm | 7 +++++++ xs/src/slic3r/GUI/GUI.cpp | 5 +++++ xs/src/slic3r/GUI/GUI.hpp | 4 ++++ xs/xsp/GUI.xsp | 9 +++++++++ 4 files changed, 25 insertions(+) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 719f98a48..3bfd57bb3 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -144,6 +144,11 @@ sub new { my ($angle_z) = @_; $self->rotate(rad2deg($angle_z), Z, 'absolute'); }; + + # callback to call schedule_background_process + my $on_request_update = sub { + $self->schedule_background_process; + }; # callback to update object's geometry info while using gizmos my $on_update_geometry_info = sub { @@ -202,6 +207,8 @@ sub new { Slic3r::GUI::_3DScene::register_on_viewport_changed_callback($self->{canvas3D}, sub { Slic3r::GUI::_3DScene::set_viewport_from_scene($self->{preview3D}->canvas, $self->{canvas3D}); }); } + + Slic3r::_GUI::register_on_request_update_callback($on_request_update); # Initialize 2D preview canvas $self->{canvas} = Slic3r::GUI::Plater::2D->new($self->{preview_notebook}, wxDefaultSize, $self->{objects}, $self->{model}, $self->{config}); diff --git a/xs/src/slic3r/GUI/GUI.cpp b/xs/src/slic3r/GUI/GUI.cpp index af7022f2b..8e351b05f 100644 --- a/xs/src/slic3r/GUI/GUI.cpp +++ b/xs/src/slic3r/GUI/GUI.cpp @@ -901,6 +901,7 @@ void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFl std::vector extruders = dlg.get_extruders(); (config.option("wiping_volumes_matrix"))->values = std::vector(matrix.begin(),matrix.end()); (config.option("wiping_volumes_extruders"))->values = std::vector(extruders.begin(),extruders.end()); + g_on_request_update_callback.call(); } })); return sizer; @@ -917,6 +918,10 @@ ConfigOptionsGroup* get_optgroup() return m_optgroup.get(); } +void register_on_request_update_callback(void* callback) { + if (callback != nullptr) + g_on_request_update_callback.register_callback(callback); +} wxButton* get_wiping_dialog_button() { diff --git a/xs/src/slic3r/GUI/GUI.hpp b/xs/src/slic3r/GUI/GUI.hpp index efb11b7df..c41ba2521 100644 --- a/xs/src/slic3r/GUI/GUI.hpp +++ b/xs/src/slic3r/GUI/GUI.hpp @@ -4,6 +4,7 @@ #include #include #include "Config.hpp" +#include "../../libslic3r/Utils.hpp" #include #include @@ -171,6 +172,9 @@ wxString from_u8(const std::string &str); void add_frequently_changed_parameters(wxWindow* parent, wxBoxSizer* sizer, wxFlexGridSizer* preset_sizer); +static PerlCallback g_on_request_update_callback; +void register_on_request_update_callback(void* callback); + ConfigOptionsGroup* get_optgroup(); wxButton* get_wiping_dialog_button(); diff --git a/xs/xsp/GUI.xsp b/xs/xsp/GUI.xsp index 6b05e9a67..7872abc80 100644 --- a/xs/xsp/GUI.xsp +++ b/xs/xsp/GUI.xsp @@ -104,3 +104,12 @@ void fix_model_by_win10_sdk_gui(ModelObject *model_object_src, Print *print, Mod void set_3DScene(SV *scene) %code%{ Slic3r::GUI::set_3DScene((_3DScene *)wxPli_sv_2_object(aTHX_ scene, "Slic3r::Model::3DScene") ); %}; + +%package{Slic3r::_GUI}; +%{ +void +register_on_request_update_callback(callback) + SV *callback; + CODE: + Slic3r::GUI::register_on_request_update_callback((void*)callback); +%}