From e386a2bf72603ecaa210bd99033565a1ca36f291 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Tue, 7 Feb 2017 18:28:53 +0100 Subject: [PATCH] Documentation of the UI config update functions, documented missing AMF support for the variable layer thickness. --- lib/Slic3r/Format/AMF.pm | 2 ++ lib/Slic3r/GUI/MainFrame.pm | 5 +++-- lib/Slic3r/GUI/OptionsGroup.pm | 1 + lib/Slic3r/GUI/OptionsGroup/Field.pm | 7 ++++++- lib/Slic3r/GUI/Plater.pm | 4 +++- lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm | 6 ++++-- lib/Slic3r/GUI/Plater/ObjectSettingsDialog.pm | 4 ++++ lib/Slic3r/GUI/Plater/OverrideSettingsPanel.pm | 2 ++ lib/Slic3r/Print.pm | 1 + 9 files changed, 26 insertions(+), 6 deletions(-) diff --git a/lib/Slic3r/Format/AMF.pm b/lib/Slic3r/Format/AMF.pm index 218b1c29d..9426fcb6d 100644 --- a/lib/Slic3r/Format/AMF.pm +++ b/lib/Slic3r/Format/AMF.pm @@ -61,6 +61,8 @@ sub write_file { if ($object->name) { printf $fh qq{ %s\n}, $object->name; } + #FIXME Store the layer height ranges (ModelObject::layer_height_ranges) + #FIXME Store the layer height profile. printf $fh qq{ \n}; printf $fh qq{ \n}; diff --git a/lib/Slic3r/GUI/MainFrame.pm b/lib/Slic3r/GUI/MainFrame.pm index f08adf672..4fea8f5cc 100644 --- a/lib/Slic3r/GUI/MainFrame.pm +++ b/lib/Slic3r/GUI/MainFrame.pm @@ -132,9 +132,9 @@ sub _init_tabpanel { $tab = $self->{options_tabs}{$tab_name} = ($class_prefix . ucfirst $tab_name)->new( $panel, no_controller => $self->{no_controller}); + # Callback to be executed after any of the configuration fields (Perl class Slic3r::GUI::OptionsGroup::Field) change their value. $tab->on_value_change(sub { - my ($opt_key, $value) = @_; - + my ($opt_key, $value) = @_; my $config = $tab->config; if ($self->{plater}) { $self->{plater}->on_config_change($config); # propagate config change events to the plater @@ -158,6 +158,7 @@ sub _init_tabpanel { # a preset changes at Slic3r::GUI::Tab. $tab->on_presets_changed(sub { if ($self->{plater}) { + # Update preset combo boxes (Print settings, Filament, Printer) from their respective tabs. $self->{plater}->update_presets($tab_name, @_); $self->{plater}->on_config_change($tab->config); if ($self->{controller}) { diff --git a/lib/Slic3r/GUI/OptionsGroup.pm b/lib/Slic3r/GUI/OptionsGroup.pm index 382dbc744..991982247 100644 --- a/lib/Slic3r/GUI/OptionsGroup.pm +++ b/lib/Slic3r/GUI/OptionsGroup.pm @@ -389,6 +389,7 @@ sub append_single_option_line { return $self->append_line($self->create_single_option_line($option, $opt_index)); } +# Initialize UI components with the config values. sub reload_config { my ($self) = @_; diff --git a/lib/Slic3r/GUI/OptionsGroup/Field.pm b/lib/Slic3r/GUI/OptionsGroup/Field.pm index fc17a65e7..bd3092f7c 100644 --- a/lib/Slic3r/GUI/OptionsGroup/Field.pm +++ b/lib/Slic3r/GUI/OptionsGroup/Field.pm @@ -1,12 +1,17 @@ +# An input field class prototype. package Slic3r::GUI::OptionsGroup::Field; use Moo; # This is a base class for option fields. has 'parent' => (is => 'ro', required => 1); -has 'option' => (is => 'ro', required => 1); # Slic3r::GUI::OptionsGroup::Option +# Slic3r::GUI::OptionsGroup::Option +has 'option' => (is => 'ro', required => 1); +# On change callback has 'on_change' => (is => 'rw', default => sub { sub {} }); has 'on_kill_focus' => (is => 'rw', default => sub { sub {} }); +# If set, the callback $self->on_change is not called. +# This is used to avoid recursive invocation of the field change/update by wxWidgets. has 'disable_change_event' => (is => 'rw', default => sub { 0 }); # This method should not fire the on_change event diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index b307d9312..01679b897 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -54,7 +54,9 @@ sub new { bed_shape complete_objects extruder_clearance_radius skirts skirt_distance brim_width serial_port serial_speed octoprint_host octoprint_apikey )); + # C++ Slic3r::Model with Perl extensions in Slic3r/Model.pm $self->{model} = Slic3r::Model->new; + # C++ Slic3r::Print with Perl extensions in Slic3r/Print.pm $self->{print} = Slic3r::Print->new; # List of Perl objects Slic3r::GUI::Plater::Object, representing a 2D preview of the platter. $self->{objects} = []; @@ -498,7 +500,7 @@ sub update_ui_from_settings } } -# Update presets (Print settings, Filament, Printer) from their respective tabs. +# Update preset combo boxes (Print settings, Filament, Printer) from their respective tabs. # Called by # Slic3r::GUI::Tab::Print::_on_presets_changed # Slic3r::GUI::Tab::Filament::_on_presets_changed diff --git a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm index 5c5ad9f2d..71e301081 100644 --- a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm +++ b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm @@ -21,8 +21,10 @@ sub new { my ($parent, %params) = @_; my $self = $class->SUPER::new($parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); - my $object = $self->{model_object} = $params{model_object}; - my $print_object = $self->{print_object} = $params{print_object}; + # C++ type Slic3r::ModelObject + $self->{model_object} = $params{model_object}; + # Not set, not used. + # $self->{print_object} = $params{print_object}; # create TreeCtrl my $tree = $self->{tree} = Wx::TreeCtrl->new($self, -1, wxDefaultPosition, [300, 100], diff --git a/lib/Slic3r/GUI/Plater/ObjectSettingsDialog.pm b/lib/Slic3r/GUI/Plater/ObjectSettingsDialog.pm index d7909816b..172a74273 100644 --- a/lib/Slic3r/GUI/Plater/ObjectSettingsDialog.pm +++ b/lib/Slic3r/GUI/Plater/ObjectSettingsDialog.pm @@ -11,6 +11,9 @@ use Wx qw(:dialog :id :misc :sizer :systemsettings :notebook wxTAB_TRAVERSAL); use Wx::Event qw(EVT_BUTTON); use base 'Wx::Dialog'; +# Called with +# %params{object} of a Perl type Slic3r::GUI::Plater::Object +# %params{model_object} of a C++ type Slic3r::ModelObject sub new { my $class = shift; my ($parent, %params) = @_; @@ -59,6 +62,7 @@ use base 'Wx::Panel'; sub model_object { my ($self) = @_; + # $self->GetParent->GetParent is of type Slic3r::GUI::Plater::ObjectSettingsDialog return $self->GetParent->GetParent->{model_object}; } diff --git a/lib/Slic3r/GUI/Plater/OverrideSettingsPanel.pm b/lib/Slic3r/GUI/Plater/OverrideSettingsPanel.pm index e848b7638..543e7fe40 100644 --- a/lib/Slic3r/GUI/Plater/OverrideSettingsPanel.pm +++ b/lib/Slic3r/GUI/Plater/OverrideSettingsPanel.pm @@ -20,8 +20,10 @@ sub new { my $class = shift; my ($parent, %params) = @_; my $self = $class->SUPER::new($parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL); + # C++ class Slic3r::DynamicPrintConfig, initially empty. $self->{default_config} = Slic3r::Config->new; $self->{config} = Slic3r::Config->new; + # On change callback. $self->{on_change} = $params{on_change}; $self->{fixed_options} = {}; diff --git a/lib/Slic3r/Print.pm b/lib/Slic3r/Print.pm index 47a58c3a0..84d9a4f70 100644 --- a/lib/Slic3r/Print.pm +++ b/lib/Slic3r/Print.pm @@ -38,6 +38,7 @@ sub size { return $self->bounding_box->size; } +# Slicing process, running at a background thread. sub process { my ($self) = @_;