Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorbubnikv <bubnikv@gmail.com>2017-10-27 23:49:59 +0300
committerbubnikv <bubnikv@gmail.com>2017-10-27 23:49:59 +0300
commit857b78ddcaa02b116c64e561cac9fb0d0901db23 (patch)
tree3adffc3ffa8bc5533c0153f6d29c02fb9c05300f /lib
parent21633bc0bafb7cc52fd7ab7c8ed1c9d0e84c5c00 (diff)
Fix of the previous commit: Slic3r::Config::new_from_defaults_keys
has to be provided with a reference to array of strings.
Diffstat (limited to 'lib')
-rw-r--r--lib/Slic3r/GUI/ConfigWizard.pm4
-rw-r--r--lib/Slic3r/GUI/MainFrame.pm30
-rw-r--r--lib/Slic3r/GUI/Plater.pm100
-rw-r--r--lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm2
4 files changed, 41 insertions, 95 deletions
diff --git a/lib/Slic3r/GUI/ConfigWizard.pm b/lib/Slic3r/GUI/ConfigWizard.pm
index 8cdcac052..e540f9ea7 100644
--- a/lib/Slic3r/GUI/ConfigWizard.pm
+++ b/lib/Slic3r/GUI/ConfigWizard.pm
@@ -202,7 +202,7 @@ sub append_option {
# populate repository with the factory default
my ($opt_key, $opt_index) = split /#/, $full_key, 2;
- $self->config->apply(Slic3r::Config::new_from_defaults_keys($opt_key));
+ $self->config->apply(Slic3r::Config::new_from_defaults_keys([$opt_key]));
# draw the control
my $optgroup = Slic3r::GUI::ConfigOptionsGroup->new(
@@ -300,7 +300,7 @@ sub new {
$self->append_text('Set the shape of your printer\'s bed, then click Next.');
- $self->config->apply(Slic3r::Config::new_from_defaults_keys('bed_shape'));
+ $self->config->apply(Slic3r::Config::new_from_defaults_keys(['bed_shape']));
$self->{bed_shape_panel} = my $panel = Slic3r::GUI::BedShapePanel->new($self, $self->config->bed_shape);
$self->{bed_shape_panel}->on_change(sub {
$self->config->set('bed_shape', $self->{bed_shape_panel}->GetValue);
diff --git a/lib/Slic3r/GUI/MainFrame.pm b/lib/Slic3r/GUI/MainFrame.pm
index 3847fe4c3..a0a47c547 100644
--- a/lib/Slic3r/GUI/MainFrame.pm
+++ b/lib/Slic3r/GUI/MainFrame.pm
@@ -70,15 +70,12 @@ sub new {
# declare events
EVT_CLOSE($self, sub {
my (undef, $event) = @_;
-
if ($event->CanVeto && !$self->check_unsaved_changes) {
$event->Veto;
return;
}
-
# save window size
wxTheApp->save_window_pos($self, "main_frame");
-
# propagate event
$event->Skip;
});
@@ -141,7 +138,6 @@ sub _init_tabpanel {
if ($self->{plater}) {
$self->{plater}->on_select_preset(sub {
my ($group, $name) = @_;
- print "MainFrame::on_select_preset callback, group: $group, name: $name\n";
$self->{options_tabs}{$group}->select_preset($name);
});
@@ -332,7 +328,6 @@ sub is_loaded {
# Selection of a 3D object changed on the platter.
sub on_plater_selection_changed {
my ($self, $have_selection) = @_;
-
return if !defined $self->{object_menu};
$self->{object_menu}->Enable($_->GetId, $have_selection)
for $self->{object_menu}->GetMenuItems;
@@ -340,8 +335,7 @@ sub on_plater_selection_changed {
# To perform the "Quck Slice", "Quick Slice and Save As", "Repeat last Quick Slice" and "Slice to SVG".
sub quick_slice {
- my $self = shift;
- my %params = @_;
+ my ($self, %params) = @_;
my $progress_dialog;
eval {
@@ -455,9 +449,7 @@ sub quick_slice {
sub reslice_now {
my ($self) = @_;
- if ($self->{plater}) {
- $self->{plater}->reslice;
- }
+ $self->{plater}->reslice if $self->{plater};
}
sub repair_stl {
@@ -495,6 +487,7 @@ sub repair_stl {
Slic3r::GUI::show_info($self, "Your file was repaired.", "Repair");
}
+# Extra variables for the placeholder parser generating a G-code.
sub extra_variables {
my $self = shift;
my %extra_variables = ();
@@ -518,13 +511,11 @@ sub export_config {
my $file = ($dlg->ShowModal == wxID_OK) ? $dlg->GetPath : undef;
$dlg->Destroy;
if (defined $file) {
- my $file = $dlg->GetPath;
$Slic3r::GUI::Settings->{recent}{config_directory} = dirname($file);
wxTheApp->save_settings;
$last_config = $file;
$config->save($file);
}
- $dlg->Destroy;
}
# Load a config file containing a Print, Filament & Printer preset.
@@ -600,15 +591,9 @@ sub load_configbundle {
# 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) = @_;
-
- foreach my $tab (values %{$self->{options_tabs}}) {
- $tab->load_config($config);
- }
- if ($self->{plater}) {
- $self->{plater}->on_config_change($config);
- }
+ my ($self, $config) = @_;
+ $_->load_config($config) foreach values %{$self->{options_tabs}};
+ $self->{plater}->on_config_change($config) if $self->{plater};
}
sub config_wizard {
@@ -662,18 +647,15 @@ sub select_view {
sub _append_menu_item {
my ($self, $menu, $string, $description, $cb, $id, $icon) = @_;
-
$id //= &Wx::NewId();
my $item = $menu->Append($id, $string, $description);
$self->_set_menu_item_icon($item, $icon);
-
EVT_MENU($self, $id, $cb);
return $item;
}
sub _set_menu_item_icon {
my ($self, $menuItem, $icon) = @_;
-
# SetBitmap was not available on OS X before Wx 0.9927
if ($icon && $menuItem->can('SetBitmap')) {
$menuItem->SetBitmap(Wx::Bitmap->new(Slic3r::var($icon), wxBITMAP_TYPE_PNG));
diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm
index c4b401cce..91329e45e 100644
--- a/lib/Slic3r/GUI/Plater.pm
+++ b/lib/Slic3r/GUI/Plater.pm
@@ -46,15 +46,14 @@ use constant PROCESS_DELAY => 0.5 * 1000; # milliseconds
my $PreventListEvents = 0;
sub new {
- my $class = shift;
- my ($parent) = @_;
+ my ($class, $parent) = @_;
my $self = $class->SUPER::new($parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
- $self->{config} = Slic3r::Config::new_from_defaults_keys(qw(
+ $self->{config} = Slic3r::Config::new_from_defaults_keys([qw(
bed_shape complete_objects extruder_clearance_radius skirts skirt_distance brim_width variable_layer_height
serial_port serial_speed octoprint_host octoprint_apikey
nozzle_diameter single_extruder_multi_material
wipe_tower wipe_tower_x wipe_tower_y wipe_tower_width wipe_tower_per_color_wipe extruder_colour filament_colour
- ));
+ )]);
# 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
@@ -567,7 +566,6 @@ sub update_presets {
# $group: one of qw(print filament printer)
# $presets: PresetCollection
my ($self, $group, $presets) = @_;
- print "Platter::update_presets\n";
my @choosers = @{$self->{preset_choosers}{$group}};
if ($group eq 'filament') {
my $choice_idx = 0;
@@ -592,7 +590,7 @@ sub update_presets {
}
sub add {
- my $self = shift;
+ my ($self) = @_;
my @input_files = wxTheApp->open_model($self);
$self->load_files(\@input_files);
}
@@ -1494,11 +1492,11 @@ sub send_gcode {
}
sub export_stl {
- my $self = shift;
-
+ my ($self) = @_;
return if !@{$self->{objects}};
-
+ # Ask user for a file name to write into.
my $output_file = $self->_get_export_file('STL') or return;
+ # Store a binary STL.
$self->{model}->store_stl($output_file, 1);
$self->statusbar->SetStatusText("STL file exported to $output_file");
}
@@ -1532,47 +1530,40 @@ sub reload_from_disk {
}
sub export_object_stl {
- my $self = shift;
-
+ my ($self) = @_;
my ($obj_idx, $object) = $self->selected_object;
return if !defined $obj_idx;
-
my $model_object = $self->{model}->objects->[$obj_idx];
-
+ # Ask user for a file name to write into.
my $output_file = $self->_get_export_file('STL') or return;
$model_object->mesh->write_binary($output_file);
$self->statusbar->SetStatusText("STL file exported to $output_file");
}
sub export_amf {
- my $self = shift;
-
+ my ($self) = @_;
return if !@{$self->{objects}};
-
+ # Ask user for a file name to write into.
my $output_file = $self->_get_export_file('AMF') or return;
$self->{model}->store_amf($output_file);
$self->statusbar->SetStatusText("AMF file exported to $output_file");
}
+# Ask user to select an output file for a given file format (STl, AMF, 3MF).
+# Propose a default file name based on the 'output_filename_format' configuration value.
sub _get_export_file {
- my $self = shift;
- my ($format) = @_;
-
+ my ($self, $format) = @_;
my $suffix = $format eq 'STL' ? '.stl' : '.amf.xml';
-
- my $output_file = $main::opt{output};
- {
- $output_file = $self->{print}->output_filepath($output_file);
- $output_file =~ s/\.[gG][cC][oO][dD][eE]$/$suffix/;
- my $dlg = Wx::FileDialog->new($self, "Save $format file as:", dirname($output_file),
- basename($output_file), &Slic3r::GUI::MODEL_WILDCARD, wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
- if ($dlg->ShowModal != wxID_OK) {
- $dlg->Destroy;
- return undef;
- }
- $output_file = $dlg->GetPath;
+ my $output_file = $self->{print}->output_filepath($main::opt{output});
+ $output_file =~ s/\.[gG][cC][oO][dD][eE]$/$suffix/;
+ my $dlg = Wx::FileDialog->new($self, "Save $format file as:", dirname($output_file),
+ basename($output_file), &Slic3r::GUI::MODEL_WILDCARD, wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
+ if ($dlg->ShowModal != wxID_OK) {
$dlg->Destroy;
+ return undef;
}
+ $output_file = $dlg->GetPath;
+ $dlg->Destroy;
return $output_file;
}
@@ -1615,12 +1606,9 @@ sub on_extruders_change {
my ($self, $num_extruders) = @_;
my $choices = $self->{preset_choosers}{filament};
- print "on_extruders_change1 $num_extruders, current choices: " . int(@$choices) . "\n";
wxTheApp->{preset_bundle}->update_multi_material_filament_presets;
- print "on_extruders_change2 $num_extruders, current choices: " . int(@$choices) . "\n";
while (int(@$choices) < $num_extruders) {
- print "Adding an extruder selection combo box\n";
# copy strings from first choice
my @presets = $choices->[0]->GetStrings;
@@ -1713,7 +1701,6 @@ sub on_config_change {
sub list_item_deselected {
my ($self, $event) = @_;
return if $PreventListEvents;
-
if ($self->{list}->GetFirstSelected == -1) {
$self->select_object(undef);
$self->{canvas}->Refresh;
@@ -1725,7 +1712,6 @@ sub list_item_deselected {
sub list_item_selected {
my ($self, $event) = @_;
return if $PreventListEvents;
-
my $obj_idx = $event->GetIndex;
$self->select_object($obj_idx);
$self->{canvas}->Refresh;
@@ -1768,8 +1754,7 @@ sub filament_color_box_lmouse_down
}
sub object_cut_dialog {
- my $self = shift;
- my ($obj_idx) = @_;
+ my ($self, $obj_idx) = @_;
if (!defined $obj_idx) {
($obj_idx, undef) = $self->selected_object;
@@ -1794,18 +1779,15 @@ sub object_cut_dialog {
}
sub object_settings_dialog {
- my $self = shift;
- my ($obj_idx) = @_;
-
- if (!defined $obj_idx) {
- ($obj_idx, undef) = $self->selected_object;
- }
+ my ($self, $obj_idx) = @_;
+ ($obj_idx, undef) = $self->selected_object if !defined $obj_idx;
my $model_object = $self->{model}->objects->[$obj_idx];
# validate config before opening the settings dialog because
# that dialog can't be closed if validation fails, but user
# can't fix any error which is outside that dialog
- return unless $self->validate_config;
+ eval { wxTheApp->{preset_bundle}->full_config->validate; };
+ return if Slic3r::GUI::catch_error($_[0]);
my $dlg = Slic3r::GUI::Plater::ObjectSettingsDialog->new($self,
object => $self->{objects}[$obj_idx],
@@ -1863,7 +1845,7 @@ sub object_list_changed {
# Selection of an active 3D object changed.
sub selection_changed {
- my $self = shift;
+ my ($self) = @_;
my ($obj_idx, $object) = $self->selected_object;
my $have_sel = defined $obj_idx;
@@ -1924,7 +1906,6 @@ sub select_object {
$_->selected(0) for @{ $self->{objects} };
if (defined $obj_idx) {
$self->{objects}->[$obj_idx]->selected(1);
-
# We use this flag to avoid circular event handling
# Select() happens to fire a wxEVT_LIST_ITEM_SELECTED on Windows,
# whose event handler calls this method again and again and again
@@ -1938,18 +1919,9 @@ sub select_object {
}
sub selected_object {
- my $self = shift;
-
+ my ($self) = @_;
my $obj_idx = first { $self->{objects}[$_]->selected } 0..$#{ $self->{objects} };
- return undef if !defined $obj_idx;
- return ($obj_idx, $self->{objects}[$obj_idx]),
-}
-
-sub validate_config {
- eval {
- wxTheApp->{preset_bundle}->full_config->validate;
- };
- return Slic3r::GUI::catch_error($_[0]) ? 0 : 1;
+ return defined $obj_idx ? ($obj_idx, $self->{objects}[$obj_idx]) : undef;
}
sub statusbar {
@@ -2079,24 +2051,19 @@ use Wx::DND;
use base 'Wx::FileDropTarget';
sub new {
- my $class = shift;
- my ($window) = @_;
+ my ($class, $window) = @_;
my $self = $class->SUPER::new;
$self->{window} = $window;
return $self;
}
sub OnDropFiles {
- my $self = shift;
- my ($x, $y, $filenames) = @_;
-
+ my ($self, $x, $y, $filenames) = @_;
# stop scalars leaking on older perl
# https://rt.perl.org/rt3/Public/Bug/Display.html?id=70602
@_ = ();
-
# only accept STL, OBJ and AMF files
return 0 if grep !/\.(?:[sS][tT][lL]|[oO][bB][jJ]|[aA][mM][fF](?:\.[xX][mM][lL])?|[pP][rR][uU][sS][aA])$/, @$filenames;
-
$self->{window}->load_files($filenames);
}
@@ -2112,10 +2079,8 @@ has 'selected' => (is => 'rw', default => sub { 0 });
sub make_thumbnail {
my ($self, $model, $obj_idx) = @_;
-
# make method idempotent
$self->thumbnail->clear;
-
# raw_mesh is the non-transformed (non-rotated, non-scaled, non-translated) sum of non-modifier object volumes.
my $mesh = $model->objects->[$obj_idx]->raw_mesh;
#FIXME The "correct" variant could be extremely slow.
@@ -2131,7 +2096,6 @@ sub make_thumbnail {
my $convex_hull = Slic3r::ExPolygon->new($mesh->convex_hull);
$self->thumbnail->append($convex_hull);
# }
-
return $self->thumbnail;
}
diff --git a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm
index 039c642c7..8a8e6064c 100644
--- a/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm
+++ b/lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm
@@ -312,7 +312,7 @@ sub selection_changed {
$config = $self->{model_object}->config;
}
# get default values
- my $default_config = Slic3r::Config::new_from_defaults_keys(@opt_keys);
+ my $default_config = Slic3r::Config::new_from_defaults_keys(\@opt_keys);
# append default extruder
push @opt_keys, 'extruder';