Make the progress bar determinate and output status description. #31

This commit is contained in:
Alessandro Ranellucci 2011-11-26 16:19:30 +01:00
parent 951778439a
commit bed502af3c
2 changed files with 25 additions and 4 deletions

View File

@ -143,13 +143,20 @@ sub do_slice {
my $skein = Slic3r::Skein->new( my $skein = Slic3r::Skein->new(
input_file => $input_file, input_file => $input_file,
output_file => $main::opt{output}, output_file => $main::opt{output},
status_cb => sub {
my ($percent, $message) = @_;
$process_dialog->Update($percent, $message);
},
); );
$skein->go; $skein->go;
$process_dialog->Destroy; $process_dialog->Destroy;
undef $process_dialog; undef $process_dialog;
if (!$main::opt{close_after_slicing}) { if (!$main::opt{close_after_slicing}) {
Wx::MessageDialog->new($self, "$input_file_basename was successfully sliced.", 'Done!', my $message = sprintf "%s was successfully sliced in %d minutes and %.3f seconds.",
$input_file_basename, int($skein->processing_time/60),
$skein->processing_time - int($skein->processing_time/60)*60;
Wx::MessageDialog->new($self, $message, 'Done!',
wxOK | wxICON_INFORMATION)->ShowModal; wxOK | wxICON_INFORMATION)->ShowModal;
} else { } else {
$self->GetParent->Destroy(); # quit $self->GetParent->Destroy(); # quit

View File

@ -6,6 +6,8 @@ use XXX;
has 'input_file' => (is => 'ro', required => 1); has 'input_file' => (is => 'ro', required => 1);
has 'output_file' => (is => 'rw', required => 0); has 'output_file' => (is => 'rw', required => 0);
has 'status_cb' => (is => 'rw', required => 0, default => sub { sub {} });
has 'processing_time' => (is => 'rw', required => 0);
sub go { sub go {
my $self = shift; my $self = shift;
@ -17,14 +19,17 @@ sub go {
# skein the STL into layers # skein the STL into layers
# each layer has surfaces with holes # each layer has surfaces with holes
$self->status_cb->(10, "Processing triangulated mesh...");
my $print = Slic3r::Print->new_from_stl($self->input_file); my $print = Slic3r::Print->new_from_stl($self->input_file);
# make skirt # make skirt
$self->status_cb->(15, "Generating skirt...");
$print->extrude_skirt; $print->extrude_skirt;
# make perimeters # make perimeters
# this will add a set of extrusion loops to each layer # this will add a set of extrusion loops to each layer
# as well as generate infill boundaries # as well as generate infill boundaries
$self->status_cb->(20, "Generating perimeters...");
{ {
my $perimeter_maker = Slic3r::Perimeter->new; my $perimeter_maker = Slic3r::Perimeter->new;
$perimeter_maker->make_perimeter($_) for @{$print->layers}; $perimeter_maker->make_perimeter($_) for @{$print->layers};
@ -32,35 +37,43 @@ sub go {
# this will prepare surfaces for perimeters by merging all # this will prepare surfaces for perimeters by merging all
# surfaces in each layer; it will also clip $layer->surfaces # surfaces in each layer; it will also clip $layer->surfaces
# to infill boundaries and split them in top/bottom/internal surfaces # to the infill boundaries and split them in top/bottom/internal surfaces
$self->status_cb->(30, "Detecting solid surfaces...");
$print->detect_surfaces_type; $print->detect_surfaces_type;
# this will remove unprintable surfaces # this will remove unprintable surfaces
# (those that are too tight for extrusion) # (those that are too tight for extrusion)
$self->status_cb->(40, "Cleaning up...");
$_->remove_small_surfaces for @{$print->layers}; $_->remove_small_surfaces for @{$print->layers};
# this will detect bridges and reverse bridges # this will detect bridges and reverse bridges
# and rearrange top/bottom/internal surfaces # and rearrange top/bottom/internal surfaces
$self->status_cb->(45, "Detect bridges...");
$_->process_bridges for @{$print->layers}; $_->process_bridges for @{$print->layers};
# this will remove unprintable perimeter loops # this will remove unprintable perimeter loops
# (those that are too tight for extrusion) # (those that are too tight for extrusion)
$self->status_cb->(50, "Cleaning up the perimeters...");
$_->remove_small_perimeters for @{$print->layers}; $_->remove_small_perimeters for @{$print->layers};
# detect which fill surfaces are near external layers # detect which fill surfaces are near external layers
# they will be split in internal and internal-solid surfaces # they will be split in internal and internal-solid surfaces
$self->status_cb->(60, "Generating horizontal shells...");
$print->discover_horizontal_shells; $print->discover_horizontal_shells;
# combine fill surfaces to honor the "infill every N layers" option # combine fill surfaces to honor the "infill every N layers" option
$self->status_cb->(70, "Combining infill...");
$print->infill_every_layers; $print->infill_every_layers;
# this will generate extrusion paths for each layer # this will generate extrusion paths for each layer
$self->status_cb->(80, "Infilling layers...");
{ {
my $fill_maker = Slic3r::Fill->new('print' => $print); my $fill_maker = Slic3r::Fill->new('print' => $print);
$fill_maker->make_fill($_) for @{$print->layers}; $fill_maker->make_fill($_) for @{$print->layers};
} }
# output everything to a GCODE file # output everything to a GCODE file
$self->status_cb->(90, "Exporting GCODE...");
if (!$self->output_file) { if (!$self->output_file) {
my $output_file = $self->input_file; my $output_file = $self->input_file;
$output_file =~ s/\.stl$/.gcode/i; $output_file =~ s/\.stl$/.gcode/i;
@ -69,9 +82,10 @@ sub go {
$print->export_gcode($self->output_file); $print->export_gcode($self->output_file);
# output some statistics # output some statistics
my $processing_time = tv_interval($t0); $self->processing_time(tv_interval($t0));
printf "Done. Process took %d minutes and %.3f seconds\n", printf "Done. Process took %d minutes and %.3f seconds\n",
int($processing_time/60), $processing_time - int($processing_time/60)*60; int($self->processing_time/60),
$self->processing_time - int($self->processing_time/60)*60;
# TODO: more statistics! # TODO: more statistics!
} }