A bit of refactoring and beautification.

This commit is contained in:
bubnikv 2017-09-18 10:01:37 +02:00
parent e16f827223
commit b58756f38b
6 changed files with 29 additions and 23 deletions

View File

@ -326,6 +326,7 @@ sub is_loaded {
return $self->{loaded};
}
# Selection of a 3D object changed on the platter.
sub on_plater_selection_changed {
my ($self, $have_selection) = @_;
@ -523,10 +524,9 @@ sub export_config {
$dlg->Destroy;
}
# Load a config file containing a Print, Filament & Printer preset.
sub load_config_file {
my $self = shift;
my ($file) = @_;
my ($self, $file) = @_;
if (!$file) {
return unless $self->check_unsaved_changes;
my $dir = $last_config ? dirname($last_config) : $Slic3r::GUI::Settings->{recent}{config_directory} || $Slic3r::GUI::Settings->{recent}{skein_directory} || '';
@ -638,6 +638,8 @@ sub load_configbundle {
Slic3r::GUI::show_info($self, $message);
}
# Load a provied DynamicConfig into the Print / Filament / Printer tabs, thus modifying the active preset.
# Also update the platter with the new presets.
sub load_config {
my $self = shift;
my ($config) = @_;

View File

@ -17,8 +17,7 @@ use constant ICON_SOLIDMESH => 1;
use constant ICON_MODIFIERMESH => 2;
sub new {
my $class = shift;
my ($parent, %params) = @_;
my ($class, $parent, %params) = @_;
my $self = $class->SUPER::new($parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
# C++ type Slic3r::ModelObject

View File

@ -15,8 +15,7 @@ use base 'Wx::Dialog';
# %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) = @_;
my ($class, $parent, %params) = @_;
my $self = $class->SUPER::new($parent, -1, "Settings for " . $params{object}->name, wxDefaultPosition, [700,500], wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
$self->{$_} = $params{$_} for keys %params;

View File

@ -29,8 +29,7 @@ my %icons = (
);
sub new {
my $class = shift;
my ($parent, %params) = @_;
my ($class, $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;

View File

@ -384,9 +384,10 @@ sub update_tree {
}
}
# Update the combo box label of the selected preset based on its "dirty" state,
# comparing the selected preset config with $self->{config}.
sub update_dirty {
my $self = shift;
my ($self) = @_;
my $list_updated;
foreach my $i ($self->{default_suppressed}..$#{$self->{presets}}) {
my $preset = $self->get_preset($i);
@ -401,20 +402,23 @@ sub update_dirty {
$self->_on_presets_changed;
}
# Has the selected preset been modified?
sub is_dirty {
my $self = shift;
my ($self) = @_;
return @{$self->dirty_options} > 0;
}
# Which options of the selected preset were modified?
sub dirty_options {
my $self = shift;
my ($self) = @_;
return [] if !defined $self->current_preset; # happens during initialization
return $self->get_preset_config($self->get_current_preset)->diff($self->{config});
}
# Search all ini files in the presets directory, add them into the list of $self->{presets} in the form of Slic3r::GUI::Tab::Preset.
# Initialize the drop down list box.
sub load_presets {
my $self = shift;
my ($self) = @_;
$self->{presets} = [
Slic3r::GUI::Tab::Preset->new(
@ -445,10 +449,9 @@ sub load_presets {
$self->_on_presets_changed;
}
# Load a config file containing a Print, Filament & Printer preset.
sub load_config_file {
my $self = shift;
my ($file) = @_;
my ($self, $file) = @_;
# look for the loaded config among the existing menu items
my $i = first { $self->{presets}[$_]{file} eq $file && $self->{presets}[$_]{external} } 1..$#{$self->{presets}};
if (!$i) {
@ -470,9 +473,10 @@ sub load_config_file {
return 1;
}
# Load a provied DynamicConfig into the tab, modifying the active preset.
# This could be used for example by setting a Wipe Tower position by interactive manipulation in the 3D view.
sub load_config {
my $self = shift;
my ($config) = @_;
my ($self, $config) = @_;
my %keys_modified = ();
foreach my $opt_key (@{$self->{config}->diff($config)}) {
@ -487,6 +491,7 @@ sub load_config {
}
}
# Load and return a config from the file associated with the $preset (Perl type Slic3r::GUI::Tab::Preset).
sub get_preset_config {
my ($self, $preset) = @_;
return $preset->config($self->{config}->get_keys);
@ -1705,6 +1710,7 @@ sub on_preset_loaded {
}
}
# Load a config file containing a Print, Filament & Printer preset.
sub load_config_file {
my $self = shift;
if ($self->SUPER::load_config_file(@_)) {
@ -1847,6 +1853,8 @@ has 'external' => (is => 'ro', default => sub { 0 });
has 'name' => (is => 'rw', required => 1);
has 'file' => (is => 'rw');
# Load a config file, return a C++ class Slic3r::DynamicPrintConfig with $keys initialized from the config file.
# In case of a "default" config item, return the default values.
sub config {
my ($self, $keys) = @_;

View File

@ -511,11 +511,10 @@ PerimeterGenerator::_variable_width(const ThickPolylines &polylines, ExtrusionRo
// append paths to collection
if (!paths.empty()) {
if (paths.front().first_point().coincides_with(paths.back().last_point())) {
if (paths.front().first_point().coincides_with(paths.back().last_point()))
coll.append(ExtrusionLoop(paths));
} else {
else
coll.append(paths);
}
}
}