From ebb2d457610d1dc67f17e1911198738a1bb756c7 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Wed, 21 Mar 2018 15:21:03 +0100 Subject: [PATCH] Out of bed detection - Disabled GUI buttons when object outside bed --- lib/Slic3r/GUI/Plater.pm | 11 +++++++++++ lib/Slic3r/GUI/Plater/3D.pm | 9 ++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index d3513897f..c63f8b8b7 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -98,6 +98,16 @@ sub new { $self->update; }; + # callback to enable/disable action buttons + my $enable_action_buttons = sub { + my ($enable) = @_; + $self->{btn_export_gcode}->Enable($enable); + $self->{btn_reslice}->Enable($enable); + $self->{btn_print}->Enable($enable); + $self->{btn_send_gcode}->Enable($enable); + $self->{btn_export_stl}->Enable($enable); + }; + # Initialize 3D plater if ($Slic3r::GUI::have_OpenGL) { $self->{canvas3D} = Slic3r::GUI::Plater::3D->new($self->{preview_notebook}, $self->{objects}, $self->{model}, $self->{print}, $self->{config}); @@ -113,6 +123,7 @@ sub new { $self->{canvas3D}->set_on_decrease_objects(sub { $self->decrease() }); $self->{canvas3D}->set_on_remove_object(sub { $self->remove() }); $self->{canvas3D}->set_on_instances_moved($on_instances_moved); + $self->{canvas3D}->set_on_enable_action_buttons($enable_action_buttons); $self->{canvas3D}->use_plain_shader(1); $self->{canvas3D}->set_on_wipe_tower_moved(sub { my ($new_pos_3f) = @_; diff --git a/lib/Slic3r/GUI/Plater/3D.pm b/lib/Slic3r/GUI/Plater/3D.pm index 37e1321ae..09cc02930 100644 --- a/lib/Slic3r/GUI/Plater/3D.pm +++ b/lib/Slic3r/GUI/Plater/3D.pm @@ -12,7 +12,7 @@ use Wx::Locale gettext => 'L'; __PACKAGE__->mk_accessors(qw( on_arrange on_rotate_object_left on_rotate_object_right on_scale_object_uniformly - on_remove_object on_increase_objects on_decrease_objects)); + on_remove_object on_increase_objects on_decrease_objects on_enable_action_buttons)); sub new { my $class = shift; @@ -176,6 +176,11 @@ sub set_on_model_update { $self->on_model_update($cb); } +sub set_on_enable_action_buttons { + my ($self, $cb) = @_; + $self->on_enable_action_buttons($cb); +} + sub reload_scene { my ($self, $force) = @_; @@ -217,10 +222,12 @@ sub reload_scene { if (!$self->{model}->fits_print_volume($self->{config})) { $self->set_warning_enabled(1); Slic3r::GUI::_3DScene::generate_warning_texture(L("Detected object outside print volume")); + $self->on_enable_action_buttons->(0) if ($self->on_enable_action_buttons); } else { $self->set_warning_enabled(0); $self->volumes->update_outside_state($self->{config}, 1); Slic3r::GUI::_3DScene::reset_warning_texture(); + $self->on_enable_action_buttons->(1) if ($self->on_enable_action_buttons); } } }