Removed "Slice to SVG" and "Quick Slice"
This commit is contained in:
parent
2c9dc4dbbf
commit
bb7f504296
@ -127,7 +127,6 @@ The author of the Silk icon set is Mark James.
|
||||
and [input_filename] (default: [input_filename_base].gcode)
|
||||
--post-process Generated G-code will be processed with the supplied script;
|
||||
call this more than once to process through multiple scripts.
|
||||
--export-svg Export a SVG file containing slices instead of G-code.
|
||||
--export-png Export zipped PNG files containing slices instead of G-code.
|
||||
-m, --merge If multiple files are supplied, they will be composed into a single
|
||||
print rather than processed individually.
|
||||
|
@ -28,7 +28,6 @@ use constant FILE_WILDCARDS => {
|
||||
prusa => 'Prusa Control files (*.prusa)|*.prusa;*.PRUSA',
|
||||
ini => 'INI files *.ini|*.ini;*.INI',
|
||||
gcode => 'G-code files (*.gcode, *.gco, *.g, *.ngc)|*.gcode;*.GCODE;*.gco;*.GCO;*.g;*.G;*.ngc;*.NGC',
|
||||
svg => 'SVG files *.svg|*.svg;*.SVG',
|
||||
};
|
||||
use constant MODEL_WILDCARD => join '|', @{&FILE_WILDCARDS}{qw(known stl obj amf threemf prusa)};
|
||||
|
||||
|
@ -305,31 +305,8 @@ sub _init_menubar {
|
||||
$self->export_configbundle;
|
||||
}, undef, 'lorry_go.png');
|
||||
$fileMenu->AppendSeparator();
|
||||
my $repeat;
|
||||
$self->_append_menu_item($fileMenu, L("Q&uick Slice…\tCtrl+U"), L('Slice a file into a G-code'), sub {
|
||||
wxTheApp->CallAfter(sub {
|
||||
$self->quick_slice;
|
||||
$repeat->Enable(defined $Slic3r::GUI::MainFrame::last_input_file);
|
||||
});
|
||||
}, undef, 'cog_go.png');
|
||||
$self->_append_menu_item($fileMenu, L("Quick Slice and Save &As…\tCtrl+Alt+U"), L('Slice a file into a G-code, save as'), sub {
|
||||
wxTheApp->CallAfter(sub {
|
||||
$self->quick_slice(save_as => 1);
|
||||
$repeat->Enable(defined $Slic3r::GUI::MainFrame::last_input_file);
|
||||
});
|
||||
}, undef, 'cog_go.png');
|
||||
$repeat = $self->_append_menu_item($fileMenu, L("&Repeat Last Quick Slice\tCtrl+Shift+U"), L('Repeat last quick slice'), sub {
|
||||
wxTheApp->CallAfter(sub {
|
||||
$self->quick_slice(reslice => 1);
|
||||
});
|
||||
}, undef, 'cog_go.png');
|
||||
$repeat->Enable(0);
|
||||
$fileMenu->AppendSeparator();
|
||||
$self->_append_menu_item($fileMenu, L("Slice to SV&G…\tCtrl+G"), L('Slice file to a multi-layer SVG'), sub {
|
||||
$self->quick_slice(save_as => 1, export_svg => 1);
|
||||
}, undef, 'shape_handles.png');
|
||||
$self->_append_menu_item($fileMenu, L("Slice to PNG…"), L('Slice file to a set of PNG files'), sub {
|
||||
$self->slice_to_png; #$self->quick_slice(save_as => 0, export_png => 1);
|
||||
$self->slice_to_png;
|
||||
}, undef, 'shape_handles.png');
|
||||
$self->{menu_item_reslice_now} = $self->_append_menu_item(
|
||||
$fileMenu, L("(&Re)Slice Now\tCtrl+S"), L('Start new slicing process'),
|
||||
@ -483,130 +460,6 @@ sub slice_to_png {
|
||||
$appController->print_ctl()->slice_to_png();
|
||||
}
|
||||
|
||||
# To perform the "Quck Slice", "Quick Slice and Save As", "Repeat last Quick Slice" and "Slice to SVG".
|
||||
sub quick_slice {
|
||||
my ($self, %params) = @_;
|
||||
|
||||
my $progress_dialog;
|
||||
eval {
|
||||
# validate configuration
|
||||
my $config = wxTheApp->{preset_bundle}->full_config();
|
||||
$config->validate;
|
||||
|
||||
# select input file
|
||||
my $input_file;
|
||||
if (!$params{reslice}) {
|
||||
my $dialog = Wx::FileDialog->new($self, L('Choose a file to slice (STL/OBJ/AMF/3MF/PRUSA):'),
|
||||
wxTheApp->{app_config}->get_last_dir, "",
|
||||
&Slic3r::GUI::MODEL_WILDCARD, wxFD_OPEN | wxFD_FILE_MUST_EXIST);
|
||||
if ($dialog->ShowModal != wxID_OK) {
|
||||
$dialog->Destroy;
|
||||
return;
|
||||
}
|
||||
$input_file = $dialog->GetPaths;
|
||||
$dialog->Destroy;
|
||||
$qs_last_input_file = $input_file unless $params{export_svg};
|
||||
} else {
|
||||
if (!defined $qs_last_input_file) {
|
||||
Wx::MessageDialog->new($self, L("No previously sliced file."),
|
||||
L('Error'), wxICON_ERROR | wxOK)->ShowModal();
|
||||
return;
|
||||
}
|
||||
if (! -e $qs_last_input_file) {
|
||||
Wx::MessageDialog->new($self, L("Previously sliced file (").$qs_last_input_file.L(") not found."),
|
||||
L('File Not Found'), wxICON_ERROR | wxOK)->ShowModal();
|
||||
return;
|
||||
}
|
||||
$input_file = $qs_last_input_file;
|
||||
}
|
||||
my $input_file_basename = basename($input_file);
|
||||
wxTheApp->{app_config}->update_skein_dir(dirname($input_file));
|
||||
|
||||
my $print_center;
|
||||
{
|
||||
my $bed_shape = Slic3r::Polygon->new_scale(@{$config->bed_shape});
|
||||
$print_center = Slic3r::Pointf->new_unscale(@{$bed_shape->bounding_box->center});
|
||||
}
|
||||
|
||||
my $sprint = Slic3r::Print::Simple->new(print_center => $print_center);
|
||||
# The C++ slicing core will post a wxCommand message to the main window.
|
||||
Slic3r::GUI::set_print_callback_event($sprint, $PROGRESS_BAR_EVENT);
|
||||
|
||||
# keep model around
|
||||
my $model = Slic3r::Model->read_from_file($input_file);
|
||||
|
||||
$sprint->apply_config($config);
|
||||
$sprint->set_model($model);
|
||||
|
||||
# Copy the names of active presets into the placeholder parser.
|
||||
wxTheApp->{preset_bundle}->export_selections_pp($sprint->placeholder_parser);
|
||||
|
||||
# select output file
|
||||
my $output_file;
|
||||
if ($params{reslice}) {
|
||||
$output_file = $qs_last_output_file if defined $qs_last_output_file;
|
||||
} elsif ($params{save_as}) {
|
||||
# The following line may die if the output_filename_format template substitution fails.
|
||||
$output_file = $sprint->output_filepath;
|
||||
$output_file =~ s/\.[gG][cC][oO][dD][eE]$/.svg/ if $params{export_svg};
|
||||
my $dlg = Wx::FileDialog->new($self, L('Save ') . ($params{export_svg} ? L('SVG') : L('G-code')) . L(' file as:'),
|
||||
wxTheApp->{app_config}->get_last_output_dir(dirname($output_file)),
|
||||
basename($output_file), $params{export_svg} ? &Slic3r::GUI::FILE_WILDCARDS->{svg} : &Slic3r::GUI::FILE_WILDCARDS->{gcode}, wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
||||
if ($dlg->ShowModal != wxID_OK) {
|
||||
$dlg->Destroy;
|
||||
return;
|
||||
}
|
||||
$output_file = $dlg->GetPath;
|
||||
$qs_last_output_file = $output_file unless $params{export_svg};
|
||||
wxTheApp->{app_config}->update_last_output_dir(dirname($output_file));
|
||||
$dlg->Destroy;
|
||||
} elsif($params{export_png}) {
|
||||
$output_file = $sprint->output_filepath;
|
||||
$output_file =~ s/\.[gG][cC][oO][dD][eE]$/.zip/;
|
||||
# my $dlg = Wx::DirDialog->new($self, L('Choose output directory'));
|
||||
my $dlg = Wx::FileDialog->new($self, L('Save zip file as:'),
|
||||
wxTheApp->{app_config}->get_last_output_dir(dirname($output_file)),
|
||||
basename($output_file), '*.zip', wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
||||
if ($dlg->ShowModal != wxID_OK) {
|
||||
$dlg->Destroy;
|
||||
return;
|
||||
}
|
||||
$output_file = $dlg->GetPath;
|
||||
$dlg->Destroy;
|
||||
}
|
||||
|
||||
# show processbar dialog
|
||||
$progress_dialog = Wx::ProgressDialog->new(L('Slicing…'), L("Processing ").$input_file_basename."…",
|
||||
100, $self, 4);
|
||||
$progress_dialog->Pulse;
|
||||
|
||||
{
|
||||
my @warnings = ();
|
||||
local $SIG{__WARN__} = sub { push @warnings, $_[0] };
|
||||
|
||||
$sprint->output_file($output_file);
|
||||
if ($params{export_svg}) {
|
||||
$sprint->export_svg;
|
||||
}
|
||||
elsif($params{export_png}) {
|
||||
$sprint->export_png;
|
||||
}
|
||||
else {
|
||||
$sprint->export_gcode;
|
||||
}
|
||||
Slic3r::GUI::warning_catcher($self)->($_) for @warnings;
|
||||
}
|
||||
$self->{progress_dialog}->Destroy;
|
||||
undef $self->{progress_dialog};
|
||||
|
||||
my $message = $input_file_basename.L(" was successfully sliced.");
|
||||
wxTheApp->notify($message);
|
||||
Wx::MessageDialog->new($self, $message, L('Slicing Done!'),
|
||||
wxOK | wxICON_INFORMATION)->ShowModal;
|
||||
};
|
||||
Slic3r::GUI::catch_error($self, sub { $self->{progress_dialog}->Destroy if $self->{progress_dialog} });
|
||||
}
|
||||
|
||||
sub reslice_now {
|
||||
my ($self) = @_;
|
||||
$self->{plater}->reslice if $self->{plater};
|
||||
|
@ -87,9 +87,6 @@ sub new {
|
||||
$self->item_changed_selection($obj_idx) if (defined($obj_idx));
|
||||
}
|
||||
};
|
||||
my $on_double_click = sub {
|
||||
$self->object_settings_dialog if $self->selected_object;
|
||||
};
|
||||
my $on_right_click = sub {
|
||||
my ($canvas, $click_pos_x, $click_pos_y) = @_;
|
||||
|
||||
@ -243,7 +240,7 @@ sub new {
|
||||
$self->{canvas3D} = Slic3r::GUI::Plater::3D->new($self->{preview_notebook}, $self->{objects}, $self->{model}, $self->{print}, $self->{config});
|
||||
$self->{preview_notebook}->AddPage($self->{canvas3D}, L('3D'));
|
||||
Slic3r::GUI::_3DScene::register_on_select_object_callback($self->{canvas3D}, $on_select_object);
|
||||
Slic3r::GUI::_3DScene::register_on_double_click_callback($self->{canvas3D}, $on_double_click);
|
||||
# Slic3r::GUI::_3DScene::register_on_double_click_callback($self->{canvas3D}, $on_double_click);
|
||||
Slic3r::GUI::_3DScene::register_on_right_click_callback($self->{canvas3D}, sub { $on_right_click->($self->{canvas3D}, @_); });
|
||||
Slic3r::GUI::_3DScene::register_on_arrange_callback($self->{canvas3D}, sub { $self->arrange });
|
||||
Slic3r::GUI::_3DScene::register_on_rotate_object_left_callback($self->{canvas3D}, sub { $self->rotate(-45, Z, 'relative') });
|
||||
@ -1988,14 +1985,6 @@ sub collect_selections {
|
||||
return $selections;
|
||||
}
|
||||
|
||||
# doesn't used now
|
||||
sub list_item_activated {
|
||||
my ($self, $event, $obj_idx) = @_;
|
||||
|
||||
$obj_idx //= $event->GetIndex;
|
||||
$self->object_settings_dialog($obj_idx);
|
||||
}
|
||||
|
||||
# Called when clicked on the filament preset combo box.
|
||||
# When clicked on the icon, show the color picker.
|
||||
sub filament_color_box_lmouse_down
|
||||
@ -2049,45 +2038,6 @@ sub filament_color_box_lmouse_down
|
||||
# }
|
||||
#}
|
||||
|
||||
sub object_settings_dialog {
|
||||
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
|
||||
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],
|
||||
model_object => $model_object,
|
||||
config => wxTheApp->{preset_bundle}->full_config,
|
||||
);
|
||||
$self->stop_background_process;
|
||||
$dlg->ShowModal;
|
||||
|
||||
# # update thumbnail since parts may have changed
|
||||
# if ($dlg->PartsChanged) {
|
||||
# # recenter and re-align to Z = 0
|
||||
# $model_object->center_around_origin;
|
||||
# $self->reset_thumbnail($obj_idx);
|
||||
# }
|
||||
|
||||
# update print
|
||||
if ($dlg->PartsChanged || $dlg->PartSettingsChanged) {
|
||||
$self->{print}->reload_object($obj_idx);
|
||||
$self->schedule_background_process;
|
||||
# $self->{canvas}->reload_scene if $self->{canvas};
|
||||
my $selections = $self->collect_selections;
|
||||
Slic3r::GUI::_3DScene::set_objects_selections($self->{canvas3D}, \@$selections);
|
||||
Slic3r::GUI::_3DScene::reload_scene($self->{canvas3D}, 0);
|
||||
} else {
|
||||
$self->resume_background_process;
|
||||
}
|
||||
}
|
||||
|
||||
sub changed_object_settings {
|
||||
my ($self, $obj_idx, $parts_changed, $part_settings_changed) = @_;
|
||||
|
||||
|
@ -66,106 +66,4 @@ sub export_png {
|
||||
$self->set_status(100, "Done.");
|
||||
}
|
||||
|
||||
# Export SVG slices for the offline SLA printing.
|
||||
# The export_svg is expected to be executed inside an eval block.
|
||||
sub export_svg {
|
||||
my $self = shift;
|
||||
my %params = @_;
|
||||
|
||||
my @sobjects = @{$self->objects};
|
||||
my $objnum = scalar @sobjects;
|
||||
for(my $oi = 0; $oi < $objnum; $oi++)
|
||||
{
|
||||
$sobjects[$oi]->slice;
|
||||
$self->set_status(($oi + 1)*100/$objnum - 1, "Slicing...");
|
||||
}
|
||||
|
||||
my $fh = $params{output_fh};
|
||||
if (!$fh) {
|
||||
# The following line may die if the output_filename_format template substitution fails.
|
||||
my $output_file = $self->output_filepath($params{output_file});
|
||||
$output_file =~ s/\.[gG][cC][oO][dD][eE]$/.svg/;
|
||||
Slic3r::open(\$fh, ">", $output_file) or die "Failed to open $output_file for writing\n";
|
||||
print "Exporting to $output_file..." unless $params{quiet};
|
||||
}
|
||||
|
||||
my $print_bb = $self->bounding_box;
|
||||
my $print_size = $print_bb->size;
|
||||
print $fh sprintf <<"EOF", unscale($print_size->[X]), unscale($print_size->[Y]);
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
|
||||
<svg width="%s" height="%s" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:slic3r="http://slic3r.org/namespaces/slic3r">
|
||||
<!--
|
||||
Generated using Slic3r $Slic3r::VERSION
|
||||
http://slic3r.org/
|
||||
-->
|
||||
EOF
|
||||
|
||||
my $print_polygon = sub {
|
||||
my ($polygon, $type) = @_;
|
||||
printf $fh qq{ <polygon slic3r:type="%s" points="%s" style="fill: %s" />\n},
|
||||
$type, (join ' ', map { join ',', map unscale $_, @$_ } @$polygon),
|
||||
($type eq 'contour' ? 'white' : 'black');
|
||||
};
|
||||
|
||||
my @layers = sort { $a->print_z <=> $b->print_z }
|
||||
map { @{$_->layers}, @{$_->support_layers} }
|
||||
@{$self->objects};
|
||||
|
||||
my $layer_id = -1;
|
||||
my @previous_layer_slices = ();
|
||||
for my $layer (@layers) {
|
||||
$layer_id++;
|
||||
if ($layer->slice_z == -1) {
|
||||
printf $fh qq{ <g id="layer%d">\n}, $layer_id;
|
||||
} else {
|
||||
printf $fh qq{ <g id="layer%d" slic3r:z="%s">\n}, $layer_id, unscale($layer->slice_z);
|
||||
}
|
||||
|
||||
my @current_layer_slices = ();
|
||||
# sort slices so that the outermost ones come first
|
||||
my @slices = sort { $a->contour->contains_point($b->contour->first_point) ? 0 : 1 } @{$layer->slices};
|
||||
foreach my $copy (@{$layer->object->_shifted_copies}) {
|
||||
foreach my $slice (@slices) {
|
||||
my $expolygon = $slice->clone;
|
||||
$expolygon->translate(@$copy);
|
||||
$expolygon->translate(-$print_bb->x_min, -$print_bb->y_min);
|
||||
$print_polygon->($expolygon->contour, 'contour');
|
||||
$print_polygon->($_, 'hole') for @{$expolygon->holes};
|
||||
push @current_layer_slices, $expolygon;
|
||||
}
|
||||
}
|
||||
# generate support material
|
||||
if ($self->has_support_material && $layer->id > 0) {
|
||||
my (@supported_slices, @unsupported_slices) = ();
|
||||
foreach my $expolygon (@current_layer_slices) {
|
||||
my $intersection = intersection_ex(
|
||||
[ map @$_, @previous_layer_slices ],
|
||||
[ @$expolygon ],
|
||||
);
|
||||
@$intersection
|
||||
? push @supported_slices, $expolygon
|
||||
: push @unsupported_slices, $expolygon;
|
||||
}
|
||||
my @supported_points = map @$_, @$_, @supported_slices;
|
||||
foreach my $expolygon (@unsupported_slices) {
|
||||
# look for the nearest point to this island among all
|
||||
# supported points
|
||||
my $contour = $expolygon->contour;
|
||||
my $support_point = $contour->first_point->nearest_point(\@supported_points)
|
||||
or next;
|
||||
my $anchor_point = $support_point->nearest_point([ @$contour ]);
|
||||
printf $fh qq{ <line x1="%s" y1="%s" x2="%s" y2="%s" style="stroke-width: 2; stroke: white" />\n},
|
||||
map @$_, $support_point, $anchor_point;
|
||||
}
|
||||
}
|
||||
print $fh qq{ </g>\n};
|
||||
@previous_layer_slices = @current_layer_slices;
|
||||
}
|
||||
|
||||
print $fh "</svg>\n";
|
||||
close $fh;
|
||||
print "Done.\n" unless $params{quiet};
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -91,12 +91,6 @@ sub export_gcode {
|
||||
$self->_print->export_gcode($self->output_file // '');
|
||||
}
|
||||
|
||||
sub export_svg {
|
||||
my ($self) = @_;
|
||||
$self->_print->validate;
|
||||
$self->_print->export_svg(output_file => $self->output_file);
|
||||
}
|
||||
|
||||
sub export_png {
|
||||
my ($self) = @_;
|
||||
|
||||
|
@ -42,7 +42,6 @@ my %cli_options = ();
|
||||
'no-plater' => \$opt{no_plater},
|
||||
'gui-mode=s' => \$opt{obsolete_ignore_this_option_gui_mode},
|
||||
'datadir=s' => \$opt{datadir},
|
||||
'export-svg' => \$opt{export_svg},
|
||||
'export-png' => \$opt{export_png},
|
||||
'merge|m' => \$opt{merge},
|
||||
'repair' => \$opt{repair},
|
||||
@ -212,9 +211,7 @@ if (@ARGV) { # slicing from command line
|
||||
# Do the apply_config once again to validate the layer height profiles at all the newly added PrintObjects.
|
||||
$sprint->apply_config($config);
|
||||
|
||||
if ($opt{export_svg}) {
|
||||
$sprint->export_svg;
|
||||
} elsif ($opt{export_png}) {
|
||||
if ($opt{export_png}) {
|
||||
$sprint->export_png;
|
||||
} else {
|
||||
my $t0 = [gettimeofday];
|
||||
@ -280,7 +277,6 @@ Usage: slic3r.pl [ OPTIONS ] [ file.stl ] [ file2.stl ] ...
|
||||
and [input_filename] (default: $config->{output_filename_format})
|
||||
--post-process Generated G-code will be processed with the supplied script;
|
||||
call this more than once to process through multiple scripts.
|
||||
--export-svg Export a SVG file containing slices instead of G-code.
|
||||
--export-png Export zipped PNG files containing slices instead of G-code.
|
||||
-m, --merge If multiple files are supplied, they will be composed into a single
|
||||
print rather than processed individually.
|
||||
|
37
t/svg.t
37
t/svg.t
@ -1,37 +0,0 @@
|
||||
use Test::More tests => 2;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
BEGIN {
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
use local::lib "$FindBin::Bin/../local-lib";
|
||||
}
|
||||
|
||||
use Slic3r;
|
||||
use Slic3r::Test;
|
||||
use IO::Scalar;
|
||||
|
||||
{
|
||||
my $print = Slic3r::Test::init_print('20mm_cube');
|
||||
eval {
|
||||
my $fh = IO::Scalar->new(\my $gcode);
|
||||
$print->print->export_svg(output_fh => $fh, quiet => 1);
|
||||
$fh->close;
|
||||
};
|
||||
die $@ if $@;
|
||||
ok !$@, 'successful SVG export';
|
||||
}
|
||||
|
||||
{
|
||||
my $print = Slic3r::Test::init_print('two_hollow_squares');
|
||||
eval {
|
||||
my $fh = IO::Scalar->new(\my $gcode);
|
||||
$print->print->export_svg(output_fh => $fh, quiet => 1);
|
||||
$fh->close;
|
||||
};
|
||||
die $@ if $@;
|
||||
ok !$@, 'successful SVG export of object with two islands';
|
||||
}
|
||||
|
||||
__END__
|
Loading…
Reference in New Issue
Block a user