Просмотр исходного кода

Merge branch 'master' into sender

Alessandro Ranellucci 10 лет назад
Родитель
Сommit
d2172b4383

+ 1 - 1
.travis.yml

@@ -2,9 +2,9 @@ language: perl
 install: true
 script: perl ./Build.PL
 perl:
-  - "5.12"
   - "5.14"
   - "5.18"
+  - "5.20"
 branches:
   only:
     - master

+ 5 - 3
README.md

@@ -8,7 +8,7 @@ Slic3r [![Build Status](https://travis-ci.org/alexrj/Slic3r.png?branch=master)](
 Slic3r takes 3D models (STL, OBJ, AMF) and converts them into G-code instructions for 
 3D printers. It's compatible with any modern printer based on the RepRap toolchain,
 including all those based on the Marlin, Sprinter and Repetier firmware. It also works
-with Mach3 and LinuxCNC controllers.
+with Mach3, LinuxCNC and Machinekit controllers.
 
 See the [project homepage](http://slic3r.org/) at slic3r.org and the
 [manual](http://manual.slic3r.org/) for more information.
@@ -30,7 +30,7 @@ Key features are:
 * **multi-platform** (Linux/Mac/Win) and packaged as standalone-app with no dependencies required
 * complete **command-line interface** to use it with no GUI
 * multi-material **(multiple extruders)** object printing
-* multiple G-code flavors supported (RepRap, Makerbot, Mach3 etc.)
+* multiple G-code flavors supported (RepRap, Makerbot, Mach3, Machinekit etc.)
 * ability to plate **multiple objects having distinct print settings**
 * **multithread** processing
 * **STL auto-repair** (tolerance for broken models)
@@ -109,6 +109,8 @@ The author of the Silk icon set is Mark James.
         -j, --threads <num> Number of threads to use (1+, default: 2)
     
       GUI options:
+        --gui               Forces the GUI launch instead of command line slicing (if you
+                            supply a model file, it will be loaded into the plater)
         --no-plater         Disable the plater tab
         --gui-mode          Overrides the configured mode (simple/expert)
         --autosave <file>   Automatically export current configuration to the specified file
@@ -130,7 +132,7 @@ The author of the Silk icon set is Mark James.
                             (default: 100,100)
         --z-offset          Additional height in mm to add to vertical coordinates
                             (+/-, default: 0)
-        --gcode-flavor      The type of G-code to generate (reprap/teacup/makerware/sailfish/mach3/no-extrusion,
+        --gcode-flavor      The type of G-code to generate (reprap/teacup/makerware/sailfish/mach3/machinekit/no-extrusion,
                             default: reprap)
         --use-relative-e-distances Enable this to get relative E values (default: no)
         --use-firmware-retraction  Enable firmware-controlled retraction using G10/G11 (default: no)

+ 1 - 1
lib/Slic3r/Config.pm

@@ -243,7 +243,7 @@ sub validate {
         if !first { $_ eq $self->gcode_flavor } @{$Options->{gcode_flavor}{values}};
     
     die "--use-firmware-retraction is only supported by Marlin firmware\n"
-        if $self->use_firmware_retraction && $self->gcode_flavor ne 'reprap';
+        if $self->use_firmware_retraction && $self->gcode_flavor ne 'reprap' && $self->gcode_flavor ne 'machinekit';
     
     die "--use-firmware-retraction is not compatible with --wipe\n"
         if $self->use_firmware_retraction && first {$_} @{$self->wipe};

+ 5 - 4
lib/Slic3r/Fill.pm

@@ -49,9 +49,10 @@ sub make_fill {
     
     Slic3r::debugf "Filling layer %d:\n", $layerm->id;
     
-    my $fill_density        = $layerm->config->fill_density;
-    my $infill_flow         = $layerm->flow(FLOW_ROLE_INFILL);
-    my $solid_infill_flow   = $layerm->flow(FLOW_ROLE_SOLID_INFILL);
+    my $fill_density            = $layerm->config->fill_density;
+    my $infill_flow             = $layerm->flow(FLOW_ROLE_INFILL);
+    my $solid_infill_flow       = $layerm->flow(FLOW_ROLE_SOLID_INFILL);
+    my $top_solid_infill_flow   = $layerm->flow(FLOW_ROLE_TOP_SOLID_INFILL);
     
     my @surfaces = ();
     
@@ -75,7 +76,7 @@ sub make_fill {
                 if ($groups[$i][0]->is_solid && (!$groups[$i][0]->is_bridge || $layerm->id == 0)) {
                     $is_solid[$i] = 1;
                     $fw[$i] = ($groups[$i][0]->surface_type == S_TYPE_TOP)
-                        ? $layerm->flow(FLOW_ROLE_TOP_SOLID_INFILL)->width
+                        ? $top_solid_infill_flow->width
                         : $solid_infill_flow->width;
                     $pattern[$i] = $groups[$i][0]->is_external
                         ? $layerm->config->external_fill_pattern

+ 4 - 1
lib/Slic3r/GCode.pm

@@ -584,11 +584,14 @@ sub wipe {
             $gcode .= $gcodegen->writer->extrude_to_xy(
                 $gcodegen->point_to_gcode($line->b),
                 -$dE,
-                'retract' . ($gcodegen->enable_cooling_markers ? ';_WIPE' : ''),
+                'wipe and retract' . ($gcodegen->enable_cooling_markers ? ';_WIPE' : ''),
             );
             $retracted += $dE;
         }
         $gcodegen->writer->extruder->set_retracted($gcodegen->writer->extruder->retracted + $retracted);
+        
+        # prevent wiping again on same path
+        $self->path(undef);
     }
     
     return $gcode;

+ 26 - 15
lib/Slic3r/GUI.pm

@@ -34,7 +34,7 @@ our $have_LWP    = eval "use LWP::UserAgent; 1";
 
 use Wx 0.9901 qw(:bitmap :dialog :icon :id :misc :systemsettings :toplevelwindow
     :filedialog);
-use Wx::Event qw(EVT_IDLE);
+use Wx::Event qw(EVT_IDLE EVT_COMMAND);
 use base 'Wx::App';
 
 use constant FILE_WILDCARDS => {
@@ -70,6 +70,8 @@ our $medium_font = Wx::SystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
 $medium_font->SetPointSize(12);
 our $grey = Wx::Colour->new(200,200,200);
 
+our $VERSION_CHECK_EVENT : shared = Wx::NewEventType;
+
 sub OnInit {
     my ($self) = @_;
     
@@ -143,6 +145,25 @@ sub OnInit {
         }
     });
     
+    EVT_COMMAND($self, -1, $VERSION_CHECK_EVENT, sub {
+        my ($self, $event) = @_;
+        my ($success, $response, $manual_check) = @{$event->GetData};
+        
+        if ($success) {
+            if ($response =~ /^obsolete ?= ?([a-z0-9.-]+,)*\Q$Slic3r::VERSION\E(?:,|$)/) {
+                my $res = Wx::MessageDialog->new(undef, "A new version is available. Do you want to open the Slic3r website now?",
+                    'Update', wxYES_NO | wxCANCEL | wxYES_DEFAULT | wxICON_INFORMATION | wxICON_ERROR)->ShowModal;
+                Wx::LaunchDefaultBrowser('http://slic3r.org/') if $res == wxID_YES;
+            } else {
+                Slic3r::GUI::show_info(undef, "You're using the latest version. No updates are available.") if $manual_check;
+            }
+            $Settings->{_}{last_version_check} = time();
+            $self->save_settings;
+        } else {
+            Slic3r::GUI::show_error(undef, "Failed to check for updates. Try later.") if $manual_check;
+        }
+    });
+    
     return 1;
 }
 
@@ -239,7 +260,7 @@ sub have_version_check {
 }
 
 sub check_version {
-    my ($self, %p) = @_;
+    my ($self, $manual_check) = @_;
     
     Slic3r::debugf "Checking for updates...\n";
     
@@ -248,19 +269,9 @@ sub check_version {
         my $ua = LWP::UserAgent->new;
         $ua->timeout(10);
         my $response = $ua->get('http://slic3r.org/updatecheck');
-        if ($response->is_success) {
-            if ($response->decoded_content =~ /^obsolete ?= ?([a-z0-9.-]+,)*\Q$Slic3r::VERSION\E(?:,|$)/) {
-                my $res = Wx::MessageDialog->new(undef, "A new version is available. Do you want to open the Slic3r website now?",
-                    'Update', wxYES_NO | wxCANCEL | wxYES_DEFAULT | wxICON_INFORMATION | wxICON_ERROR)->ShowModal;
-                Wx::LaunchDefaultBrowser('http://slic3r.org/') if $res == wxID_YES;
-            } else {
-                Slic3r::GUI::show_info(undef, "You're using the latest version. No updates are available.") if $p{manual};
-            }
-            $Settings->{_}{last_version_check} = time();
-            $self->save_settings;
-        } else {
-            Slic3r::GUI::show_error(undef, "Failed to check for updates. Try later.") if $p{manual};
-        }
+        Wx::PostEvent($self, Wx::PlThreadEvent->new(-1, $VERSION_CHECK_EVENT,
+            threads::shared::shared_clone([ $response->is_success, $response->decoded_content, $manual_check ])));
+        
         Slic3r::thread_cleanup();
     })->detach;
 }

+ 27 - 10
lib/Slic3r/GUI/3DScene.pm

@@ -16,6 +16,7 @@ __PACKAGE__->mk_accessors( qw(_quat _dirty init
                               enable_cutting
                               enable_picking
                               enable_moving
+                              on_viewport_changed
                               on_hover
                               on_select
                               on_double_click
@@ -108,6 +109,7 @@ sub new {
             -($pos->y - $size->y/2) * ($zoom) / $self->_zoom,
             0,
         ) if 0;
+        $self->on_viewport_changed->() if $self->on_viewport_changed;
         $self->_dirty(1);
         $self->Refresh;
     });
@@ -207,6 +209,7 @@ sub mouse_event {
                     );
                     $self->_quat(mulquats($self->_quat, \@quat));
                 }
+                $self->on_viewport_changed->() if $self->on_viewport_changed;
                 $self->Refresh;
             }
             $self->_drag_start_pos($pos);
@@ -220,6 +223,7 @@ sub mouse_event {
                 $self->_camera_target->translate(
                     @{$orig->vector_to($cur_pos)->negative},
                 );
+                $self->on_viewport_changed->() if $self->on_viewport_changed;
                 $self->Refresh;
             }
             $self->_drag_start_xy($pos);
@@ -256,6 +260,17 @@ sub reset_objects {
     $self->_dirty(1);
 }
 
+sub set_viewport_from_scene {
+    my ($self, $scene) = @_;
+    
+    $self->_sphi($scene->_sphi);
+    $self->_stheta($scene->_stheta);
+    $self->_camera_target($scene->_camera_target);
+    $self->_zoom($scene->_zoom);
+    $self->_quat($scene->_quat);
+    $self->_dirty(1);
+}
+
 sub zoom_to_bounding_box {
     my ($self, $bb) = @_;
     
@@ -267,6 +282,8 @@ sub zoom_to_bounding_box {
     
     # center view around bounding box center
     $self->_camera_target($bb->center);
+    
+    $self->on_viewport_changed->() if $self->on_viewport_changed;
 }
 
 sub zoom_to_bed {
@@ -347,25 +364,24 @@ sub set_bed_shape {
     }
     
     {
-        my @lines = ();
+        my @polylines = ();
         for (my $x = $bed_bb->x_min; $x <= $bed_bb->x_max; $x += scale 10) {
-            push @lines, Slic3r::Polyline->new([$x,$bed_bb->y_min], [$x,$bed_bb->y_max]);
+            push @polylines, Slic3r::Polyline->new([$x,$bed_bb->y_min], [$x,$bed_bb->y_max]);
         }
         for (my $y = $bed_bb->y_min; $y <= $bed_bb->y_max; $y += scale 10) {
-            push @lines, Slic3r::Polyline->new([$bed_bb->x_min,$y], [$bed_bb->x_max,$y]);
+            push @polylines, Slic3r::Polyline->new([$bed_bb->x_min,$y], [$bed_bb->x_max,$y]);
         }
         # clip with a slightly grown expolygon because our lines lay on the contours and
         # may get erroneously clipped
-        @lines = @{intersection_pl(\@lines, [ @{$expolygon->offset(+scaled_epsilon)} ])};
+        my @lines = map Slic3r::Line->new(@$_[0,-1]),
+            @{intersection_pl(\@polylines, [ @{$expolygon->offset(+scaled_epsilon)} ])};
         
         # append bed contours
-        foreach my $line (map @{$_->lines}, @$expolygon) {
-            push @lines, $line->as_polyline;
-        }
+        push @lines, map @{$_->lines}, @$expolygon;
         
         my @points = ();
-        foreach my $polyline (@lines) {
-            push @points, map {+ unscale($_->x), unscale($_->y), GROUND_Z } @$polyline;  #))
+        foreach my $line (@lines) {
+            push @points, map {+ unscale($_->x), unscale($_->y), GROUND_Z } @$line;  #))
         }
         $self->bed_grid_lines(OpenGL::Array->new_list(GL_FLOAT, @points));
     }
@@ -572,9 +588,10 @@ sub Resize {
     
     glMatrixMode(GL_PROJECTION);
     glLoadIdentity();
+    my $depth = 10 * max(@{ $self->max_bounding_box->size });
     glOrtho(
         -$x/2, $x/2, -$y/2, $y/2,
-        -200, 10 * max(@{ $self->max_bounding_box->size }),
+        -$depth, 2*$depth,
     );
  
     glMatrixMode(GL_MODELVIEW);

+ 1 - 1
lib/Slic3r/GUI/BedShapeDialog.pm

@@ -307,7 +307,7 @@ sub _repaint_canvas {
         @polylines = @{intersection_pl(\@polylines, [$bed_polygon])};
         
         $dc->SetPen(Wx::Pen->new(Wx::Colour->new(230,230,230), 1, wxSOLID));
-        $dc->DrawLine(map @{$to_pixel->([map unscale($_), @$_])}, @$_) for @polylines;
+        $dc->DrawLine(map @{$to_pixel->([map unscale($_), @$_])}, @$_[0,-1]) for @polylines;
     }
     
     # draw bed contour

+ 2 - 2
lib/Slic3r/GUI/MainFrame.pm

@@ -255,7 +255,7 @@ sub _init_menubar {
             Wx::LaunchDefaultBrowser('http://slic3r.org/');
         });
         my $versioncheck = $self->_append_menu_item($helpMenu, "Check for &Updates...", 'Check for new Slic3r versions', sub {
-            wxTheApp->check_version(manual => 1);
+            wxTheApp->check_version(1);
         });
         $versioncheck->Enable(wxTheApp->have_version_check);
         $self->_append_menu_item($helpMenu, "Slic3r &Manual", 'Open the Slic3r manual in your browser', sub {
@@ -678,7 +678,7 @@ sub config {
     } else {
         my $extruders_count = $self->{options_tabs}{printer}{extruders_count};
         $config->set("${_}_extruder", min($config->get("${_}_extruder"), $extruders_count))
-            for qw(perimeter infill support_material support_material_interface);
+            for qw(perimeter infill solid_infill support_material support_material_interface);
     }
     
     return $config;

+ 17 - 8
lib/Slic3r/GUI/Plater.pm

@@ -96,6 +96,9 @@ sub new {
         $self->{canvas3D}->set_on_double_click($on_double_click);
         $self->{canvas3D}->set_on_right_click(sub { $on_right_click->($self->{canvas3D}, @_); });
         $self->{canvas3D}->set_on_instances_moved($on_instances_moved);
+        $self->{canvas3D}->on_viewport_changed(sub {
+            $self->{preview3D}->canvas->set_viewport_from_scene($self->{canvas3D});
+        });
     }
     
     # Initialize 2D preview canvas
@@ -109,6 +112,9 @@ sub new {
     # Initialize 3D toolpaths preview
     if ($Slic3r::GUI::have_OpenGL) {
         $self->{preview3D} = Slic3r::GUI::Plater::3DPreview->new($self->{preview_notebook}, $self->{print});
+        $self->{preview3D}->canvas->on_viewport_changed(sub {
+            $self->{canvas3D}->set_viewport_from_scene($self->{preview3D}->canvas);
+        });
         $self->{preview_notebook}->AddPage($self->{preview3D}, 'Preview');
         $self->{preview3D_page_idx} = $self->{preview_notebook}->GetPageCount-1;
     }
@@ -988,9 +994,13 @@ sub pause_background_process {
     
     if ($self->{process_thread} || $self->{export_thread}) {
         Slic3r::pause_all_threads();
+        return 1;
     } elsif (defined $self->{apply_config_timer} && $self->{apply_config_timer}->IsRunning) {
         $self->{apply_config_timer}->Stop;
+        return 1;
     }
+    
+    return 0;
 }
 
 sub resume_background_process {
@@ -1312,9 +1322,14 @@ sub update {
         $self->{model}->center_instances_around_point($self->bed_centerf);
     }
     
-    $self->pause_background_process;
+    my $running = $self->pause_background_process;
     my $invalidated = $self->{print}->reload_model_instances();
-    if ($invalidated) {
+    
+    # The mere fact that no steps were invalidated when reloading model instances 
+    # doesn't mean that all steps were done: for example, validation might have 
+    # failed upon previous instance move, so we have no running thread and no steps
+    # are invalidated on this move, thus we need to schedule a new run.
+    if ($invalidated || !$running) {
         $self->schedule_background_process;
     } else {
         $self->resume_background_process;
@@ -1323,12 +1338,6 @@ sub update {
     $self->refresh_canvases;
 }
 
-sub on_model_instances_changed {
-    my ($self) = @_;
-    
-    
-}
-
 sub on_extruders_change {
     my ($self, $num_extruders) = @_;
     

Некоторые файлы не были показаны из-за большого количества измененных файлов