Browse Source

Merge remote-tracking branch 'remotes/prusa/master' into supermerill-dev

# Resolved:
#	xs/src/slic3r/GUI/Preset.cpp
#	xs/src/slic3r/GUI/Tab.cpp
Merill 7 years ago
parent
commit
700a9ad669

+ 1 - 0
lib/Slic3r.pm

@@ -162,6 +162,7 @@ sub thread_cleanup {
     *Slic3r::TriangleMesh::DESTROY          = sub {};
     *Slic3r::GUI::AppConfig::DESTROY        = sub {};
     *Slic3r::GUI::PresetBundle::DESTROY     = sub {};
+    *Slic3r::GUI::Tab::DESTROY              = sub {};
     return undef;  # this prevents a "Scalars leaked" warning
 }
 

+ 34 - 46
lib/Slic3r/GUI/3DScene.pm

@@ -1281,10 +1281,7 @@ sub Render {
         # disable depth testing so that axes are not covered by ground
         glDisable(GL_DEPTH_TEST);
         my $origin = $self->origin;
-        my $axis_len = max(
-            0.3 * max(@{ $self->bed_bounding_box->size }),
-              2 * max(@{ $volumes_bb->size }),
-        );
+        my $axis_len = $self->use_plain_shader ? 0.3 * max(@{ $self->bed_bounding_box->size }) : 2 * max(@{ $volumes_bb->size });
         glLineWidth(2);
         glBegin(GL_LINES);
         # draw line for x axis
@@ -1330,8 +1327,8 @@ sub Render {
         glEnable(GL_CULL_FACE) if ($self->enable_picking);
     }
 
-    # draw cutting plane
     if (defined $self->cutting_plane_z) {
+        # draw cutting plane
         my $plane_z = $self->cutting_plane_z;
         my $bb = $volumes_bb;
         glDisable(GL_CULL_FACE);
@@ -1347,6 +1344,15 @@ sub Render {
         glEnd();
         glEnable(GL_CULL_FACE);
         glDisable(GL_BLEND);
+        
+        # draw cutting contours
+        glEnableClientState(GL_VERTEX_ARRAY);
+        glLineWidth(2);
+        glColor3f(0, 0, 0);
+        glVertexPointer_c(3, GL_FLOAT, 0, $self->cut_lines_vertices->ptr());
+        glDrawArrays(GL_LINES, 0, $self->cut_lines_vertices->elements / 3);
+        glVertexPointer_c(3, GL_FLOAT, 0, 0);
+        glDisableClientState(GL_VERTEX_ARRAY);
     }
 
     # draw warning message
@@ -1393,18 +1399,10 @@ sub draw_volumes {
         $volume->render;
     }
     glDisableClientState(GL_NORMAL_ARRAY);
-    glDisable(GL_BLEND);
-
-    glEnable(GL_CULL_FACE);
-    
-    if (defined $self->cutting_plane_z) {
-        glLineWidth(2);
-        glColor3f(0, 0, 0);
-        glVertexPointer_c(3, GL_FLOAT, 0, $self->cut_lines_vertices->ptr());
-        glDrawArrays(GL_LINES, 0, $self->cut_lines_vertices->elements / 3);
-        glVertexPointer_c(3, GL_FLOAT, 0, 0);
-    }
     glDisableClientState(GL_VERTEX_ARRAY);
+    
+    glDisable(GL_BLEND);
+    glEnable(GL_CULL_FACE);    
 }
 
 sub mark_volumes_for_layer_height {
@@ -1527,10 +1525,13 @@ sub draw_active_object_annotations {
     my ($reset_left, $reset_bottom, $reset_right, $reset_top) = $self->_variable_layer_thickness_reset_rect_viewport;
     my $z_cursor_relative = $self->_variable_layer_thickness_bar_mouse_cursor_z_relative;
 
+    my $print_object = $self->{print}->get_object($object_idx);
+    my $z_max = $print_object->model_object->bounding_box->z_max;
+    
     $self->{layer_height_edit_shader}->enable;
     $self->{layer_height_edit_shader}->set_uniform('z_to_texture_row',            $volume->layer_height_texture_z_to_row_id);
     $self->{layer_height_edit_shader}->set_uniform('z_texture_row_to_normalized', 1. / $volume->layer_height_texture_height);
-    $self->{layer_height_edit_shader}->set_uniform('z_cursor',                    $volume->bounding_box->z_max * $z_cursor_relative);
+    $self->{layer_height_edit_shader}->set_uniform('z_cursor',                    $z_max * $z_cursor_relative);
     $self->{layer_height_edit_shader}->set_uniform('z_cursor_band_width',         $self->{layer_height_edit_band_width});
     glBindTexture(GL_TEXTURE_2D, $self->{layer_preview_z_texture_id});
     glTexImage2D_c(GL_TEXTURE_2D, 0, GL_RGBA8, $volume->layer_height_texture_width, $volume->layer_height_texture_height, 
@@ -1552,8 +1553,8 @@ sub draw_active_object_annotations {
     glBegin(GL_QUADS);
     glVertex3f($bar_left,  $bar_bottom, 0);
     glVertex3f($bar_right, $bar_bottom, 0);
-    glVertex3f($bar_right, $bar_top, $volume->bounding_box->z_max);
-    glVertex3f($bar_left,  $bar_top, $volume->bounding_box->z_max);
+    glVertex3f($bar_right, $bar_top, $z_max);
+    glVertex3f($bar_left,  $bar_top, $z_max);
     glEnd();
     glBindTexture(GL_TEXTURE_2D, 0);
     $self->{layer_height_edit_shader}->disable;
@@ -1572,7 +1573,6 @@ sub draw_active_object_annotations {
 
     # Paint the graph.
     #FIXME show some kind of legend.
-    my $print_object = $self->{print}->get_object($object_idx);
     my $max_z = unscale($print_object->size->z);
     my $profile = $print_object->model_object->layer_height_profile;
     my $layer_height = $print_object->config->get('layer_height');
@@ -1677,6 +1677,11 @@ sub draw_warning {
     }
 }
 
+sub update_volumes_colors_by_extruder {
+    my ($self, $config) = @_;    
+    $self->volumes->update_colors_by_extruder($config);
+}
+
 sub opengl_info
 {
     my ($self, %params) = @_;
@@ -1746,8 +1751,8 @@ sub _vertex_shader_Gouraud {
 // normalized values for (-0.6/1.31, 0.6/1.31, 1./1.31)
 const vec3 LIGHT_TOP_DIR = vec3(-0.4574957, 0.4574957, 0.7624929);
 #define LIGHT_TOP_DIFFUSE    (0.8 * INTENSITY_CORRECTION)
-#define LIGHT_TOP_SPECULAR   (0.25 * INTENSITY_CORRECTION)
-#define LIGHT_TOP_SHININESS  200.0
+#define LIGHT_TOP_SPECULAR   (0.125 * INTENSITY_CORRECTION)
+#define LIGHT_TOP_SHININESS  20.0
 
 // normalized values for (1./1.43, 0.2/1.43, 1./1.43)
 const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074);
@@ -1777,15 +1782,9 @@ varying vec3 delta_box_max;
 
 void main()
 {
-    vec3 eye = -normalize((gl_ModelViewMatrix * gl_Vertex).xyz);
-
     // First transform the normal into camera space and normalize the result.
     vec3 normal = normalize(gl_NormalMatrix * gl_Normal);
     
-    // Now normalize the light's direction. Note that according to the OpenGL specification, the light is stored in eye space. 
-    // Also since we're talking about a directional light, the position field is actually direction.
-    vec3 halfVector = normalize(LIGHT_TOP_DIR + eye);
-    
     // Compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex.
     // Since these two are normalized the cosine is the dot product. We also need to clamp the result to the [0,1] range.
     float NdotL = max(dot(normal, LIGHT_TOP_DIR), 0.0);
@@ -1794,7 +1793,7 @@ void main()
     intensity.y = 0.0;
 
     if (NdotL > 0.0)
-        intensity.y += LIGHT_TOP_SPECULAR * pow(max(dot(normal, halfVector), 0.0), LIGHT_TOP_SHININESS);
+        intensity.y += LIGHT_TOP_SPECULAR * pow(max(dot(normal, reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS);
 
     // Perform the same lighting calculation for the 2nd light source (no specular applied).
     NdotL = max(dot(normal, LIGHT_FRONT_DIR), 0.0);
@@ -1823,7 +1822,6 @@ sub _fragment_shader_Gouraud {
     return <<'FRAGMENT';
 #version 110
 
-const vec4 OUTSIDE_COLOR = vec4(0.24, 0.42, 0.62, 1.0);
 const vec3 ZERO = vec3(0.0, 0.0, 0.0);
 
 // x = tainted, y = specular;
@@ -1836,11 +1834,9 @@ uniform vec4 uniform_color;
 
 void main()
 {
-    // if the fragment is outside the print volume use predefined color
-    vec4 color = (any(lessThan(delta_box_min, ZERO)) || any(greaterThan(delta_box_max, ZERO))) ? OUTSIDE_COLOR : uniform_color;
-
-    gl_FragColor = vec4(intensity.y, intensity.y, intensity.y, 0.0) + color * intensity.x;
-    gl_FragColor.a = color.a;
+    // if the fragment is outside the print volume -> use darker color
+    vec3 color = (any(lessThan(delta_box_min, ZERO)) || any(greaterThan(delta_box_max, ZERO))) ? mix(uniform_color.rgb, ZERO, 0.3333) : uniform_color.rgb;
+    gl_FragColor = vec4(vec3(intensity.y, intensity.y, intensity.y) + color * intensity.x, uniform_color.a);
 }
 
 FRAGMENT
@@ -1922,8 +1918,8 @@ sub _vertex_shader_variable_layer_height {
 
 const vec3 LIGHT_TOP_DIR = vec3(-0.4574957, 0.4574957, 0.7624929);
 #define LIGHT_TOP_DIFFUSE    (0.8 * INTENSITY_CORRECTION)
-#define LIGHT_TOP_SPECULAR   (0.25 * INTENSITY_CORRECTION)
-#define LIGHT_TOP_SHININESS  200.0
+#define LIGHT_TOP_SPECULAR   (0.125 * INTENSITY_CORRECTION)
+#define LIGHT_TOP_SHININESS  20.0
 
 const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074);
 #define LIGHT_FRONT_DIFFUSE  (0.3 * INTENSITY_CORRECTION)
@@ -1932,8 +1928,6 @@ const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074);
 
 #define INTENSITY_AMBIENT    0.3
 
-uniform float z_to_texture_row;
-
 // x = tainted, y = specular;
 varying vec2 intensity;
 
@@ -1941,15 +1935,9 @@ varying float object_z;
 
 void main()
 {
-    vec3 eye = -normalize((gl_ModelViewMatrix * gl_Vertex).xyz);
-
     // First transform the normal into camera space and normalize the result.
     vec3 normal = normalize(gl_NormalMatrix * gl_Normal);
     
-    // Now normalize the light's direction. Note that according to the OpenGL specification, the light is stored in eye space. 
-    // Also since we're talking about a directional light, the position field is actually direction.
-    vec3 halfVector = normalize(LIGHT_TOP_DIR + eye);
-    
     // Compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex.
     // Since these two are normalized the cosine is the dot product. We also need to clamp the result to the [0,1] range.
     float NdotL = max(dot(normal, LIGHT_TOP_DIR), 0.0);
@@ -1958,7 +1946,7 @@ void main()
     intensity.y = 0.0;
 
     if (NdotL > 0.0)
-        intensity.y += LIGHT_TOP_SPECULAR * pow(max(dot(normal, halfVector), 0.0), LIGHT_TOP_SHININESS);
+        intensity.y += LIGHT_TOP_SPECULAR * pow(max(dot(normal, reflect(-LIGHT_TOP_DIR, normal)), 0.0), LIGHT_TOP_SHININESS);
 
     // Perform the same lighting calculation for the 2nd light source (no specular)
     NdotL = max(dot(normal, LIGHT_FRONT_DIR), 0.0);

+ 12 - 7
lib/Slic3r/GUI/Plater.pm

@@ -52,9 +52,8 @@ sub new {
     $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 octoprint_cafile
-        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
-        max_print_height
+        nozzle_diameter single_extruder_multi_material wipe_tower wipe_tower_x wipe_tower_y wipe_tower_width
+	wipe_tower_rotation_angle extruder_colour filament_colour max_print_height
     )]);
     # C++ Slic3r::Model with Perl extensions in Slic3r/Model.pm
     $self->{model} = Slic3r::Model->new;
@@ -105,7 +104,6 @@ sub new {
         $self->{btn_reslice}->Enable($enable);
         $self->{btn_print}->Enable($enable);
         $self->{btn_send_gcode}->Enable($enable);
-        $self->{btn_export_stl}->Enable($enable);    
     };
     
     # Initialize 3D plater
@@ -738,8 +736,14 @@ sub load_model_objects {
         {
             # if the object is too large (more than 5 times the bed), scale it down
             my $size = $o->bounding_box->size;
-            my $ratio = max(@$size[X,Y]) / unscale(max(@$bed_size[X,Y]));
-            if ($ratio > 5) {
+            my $ratio = max($size->x / unscale($bed_size->x), $size->y / unscale($bed_size->y));
+            if ($ratio > 10000) {
+                # the size of the object is too big -> this could lead to overflow when moving to clipper coordinates,
+                # so scale down the mesh
+                $o->scale_xyz(Slic3r::Pointf3->new(1/$ratio, 1/$ratio, 1/$ratio));
+                $scaled_down = 1;
+            }
+            elsif ($ratio > 5) {
                 $_->set_scaling_factor(1/$ratio) for @{$o->instances};
                 $scaled_down = 1;
             }
@@ -1915,7 +1919,8 @@ sub object_list_changed {
     }
 
     my $export_in_progress = $self->{export_gcode_output_file} || $self->{send_gcode_file};
-    my $method = ($have_objects && ! $export_in_progress) ? 'Enable' : 'Disable';
+    my $model_fits = $self->{model}->fits_print_volume($self->{config});
+    my $method = ($have_objects && ! $export_in_progress && $model_fits) ? 'Enable' : 'Disable';
     $self->{"btn_$_"}->$method
         for grep $self->{"btn_$_"}, qw(reslice export_gcode print send_gcode);
 }

+ 9 - 3
lib/Slic3r/GUI/Plater/3D.pm

@@ -210,12 +210,15 @@ sub reload_scene {
         if ($extruders_count > 1 && $self->{config}->single_extruder_multi_material && $self->{config}->wipe_tower &&
             ! $self->{config}->complete_objects) {
             $self->volumes->load_wipe_tower_preview(1000, 
-                $self->{config}->wipe_tower_x, $self->{config}->wipe_tower_y, 
-                $self->{config}->wipe_tower_width, $self->{config}->wipe_tower_per_color_wipe * ($extruders_count - 1),
-                $self->{model}->bounding_box->z_max, $self->UseVBOs);
+                $self->{config}->wipe_tower_x, $self->{config}->wipe_tower_y, $self->{config}->wipe_tower_width,
+		#$self->{config}->wipe_tower_per_color_wipe# 15 * ($extruders_count - 1), # this is just a hack when the config parameter became obsolete
+		15 * ($extruders_count - 1),
+                $self->{model}->bounding_box->z_max, $self->{config}->wipe_tower_rotation_angle, $self->UseVBOs);
         }
     }
     
+    $self->update_volumes_colors_by_extruder($self->{config});
+    
     # checks for geometry outside the print volume to render it accordingly
     if (scalar @{$self->volumes} > 0)
     {
@@ -229,6 +232,9 @@ sub reload_scene {
             Slic3r::GUI::_3DScene::reset_warning_texture();
             $self->on_enable_action_buttons->(1) if ($self->on_enable_action_buttons);
         }
+    } else {
+        $self->set_warning_enabled(0);
+        Slic3r::GUI::_3DScene::reset_warning_texture();
     }
 }
 

+ 2 - 1
lib/Slic3r/GUI/Plater/ObjectCutDialog.pm

@@ -60,7 +60,7 @@ sub new {
         label       => 'Z',
         default     => $self->{cut_options}{z},
         min         => 0,
-        max         => $self->{model_object}->bounding_box->size->z * $self->{model_object}->instances->[0]->scaling_factor,
+        max         => $self->{model_object}->bounding_box->size->z,
         full_width  => 1,
     ));
     {
@@ -247,6 +247,7 @@ sub _update {
                 $self->{cut_options}{z},
                 [@expolygons],
             );
+            $self->{canvas}->update_volumes_colors_by_extruder($self->GetParent->{config});
             $self->{canvas}->Render;
         }
     }

+ 43 - 10
lib/Slic3r/GUI/Plater/ObjectPartsPanel.pm

@@ -9,7 +9,7 @@ use utf8;
 use File::Basename qw(basename);
 use Wx qw(:misc :sizer :treectrl :button :keycode wxTAB_TRAVERSAL wxSUNKEN_BORDER wxBITMAP_TYPE_PNG wxID_CANCEL wxMOD_CONTROL
     wxTheApp);
-use Wx::Event qw(EVT_BUTTON EVT_TREE_ITEM_COLLAPSING EVT_TREE_SEL_CHANGED EVT_TREE_KEY_DOWN);
+use Wx::Event qw(EVT_BUTTON EVT_TREE_ITEM_COLLAPSING EVT_TREE_SEL_CHANGED EVT_TREE_KEY_DOWN EVT_KEY_DOWN);
 use base 'Wx::Panel';
 
 use constant ICON_OBJECT        => 0;
@@ -88,7 +88,7 @@ sub new {
     $self->{btn_move_down}->SetFont($Slic3r::GUI::small_font);
     
     # part settings panel
-    $self->{settings_panel} = Slic3r::GUI::Plater::OverrideSettingsPanel->new($self, on_change => sub { $self->{part_settings_changed} = 1; });
+    $self->{settings_panel} = Slic3r::GUI::Plater::OverrideSettingsPanel->new($self, on_change => sub { $self->{part_settings_changed} = 1; $self->_update_canvas; });
     my $settings_sizer = Wx::StaticBoxSizer->new($self->{staticbox} = Wx::StaticBox->new($self, -1, "Part Settings"), wxVERTICAL);
     $settings_sizer->Add($self->{settings_panel}, 1, wxEXPAND | wxALL, 0);
 
@@ -162,6 +162,7 @@ sub new {
         $canvas->load_object($self->{model_object}, undef, undef, [0]);
         $canvas->set_auto_bed_shape;
         $canvas->SetSize([500,700]);
+        $canvas->update_volumes_colors_by_extruder($self->GetParent->GetParent->GetParent->{config});
         $canvas->zoom_to_volumes;
     }
     
@@ -190,6 +191,14 @@ sub new {
     EVT_BUTTON($self, $self->{btn_split}, \&on_btn_split);
     EVT_BUTTON($self, $self->{btn_move_up}, \&on_btn_move_up);
     EVT_BUTTON($self, $self->{btn_move_down}, \&on_btn_move_down);
+    EVT_KEY_DOWN($canvas, sub {
+        my ($canvas, $event) = @_;
+        if ($event->GetKeyCode == WXK_DELETE) {
+            $canvas->GetParent->on_btn_delete;
+        } else {
+            $event->Skip;
+        }
+    });
     
     $self->reload_tree;
     
@@ -400,14 +409,17 @@ sub on_tree_key_down {
     my ($self, $event) = @_;
     my $keycode = $event->GetKeyCode;    
     # Wx >= 0.9911
-    if (defined(&Wx::TreeEvent::GetKeyEvent) && 
-        ($event->GetKeyEvent->GetModifiers & wxMOD_CONTROL)) {
-        if ($keycode == WXK_UP) {
-            $event->Skip;
-            $self->on_btn_move_up;
-        } elsif ($keycode == WXK_DOWN) {
-            $event->Skip;
-            $self->on_btn_move_down;
+    if (defined(&Wx::TreeEvent::GetKeyEvent)) { 
+        if ($event->GetKeyEvent->GetModifiers & wxMOD_CONTROL) {
+            if ($keycode == WXK_UP) {
+                $event->Skip;
+                $self->on_btn_move_up;
+            } elsif ($keycode == WXK_DOWN) {
+                $event->Skip;
+                $self->on_btn_move_down;
+            }
+        } elsif ($keycode == WXK_DELETE) {
+            $self->on_btn_delete;
         }
     }
 }
@@ -478,6 +490,7 @@ sub _parts_changed {
         $self->{canvas}->reset_objects;
         $self->{canvas}->load_object($self->{model_object});
         $self->{canvas}->zoom_to_volumes;
+        $self->{canvas}->update_volumes_colors_by_extruder($self->GetParent->GetParent->GetParent->{config});
         $self->{canvas}->Render;
     }
 }
@@ -508,6 +521,25 @@ sub PartSettingsChanged {
     return $self->{part_settings_changed};
 }
 
+sub _update_canvas {
+    my ($self) = @_;
+    
+    if ($self->{canvas}) {
+        $self->{canvas}->reset_objects;
+        $self->{canvas}->load_object($self->{model_object});
+
+        # restore selection, if any
+        if (my $itemData = $self->get_selection) {
+            if ($itemData->{type} eq 'volume') {
+                $self->{canvas}->volumes->[ $itemData->{volume_id} ]->set_selected(1);
+            }
+        }
+                
+        $self->{canvas}->update_volumes_colors_by_extruder($self->GetParent->GetParent->GetParent->{config});
+        $self->{canvas}->Render;
+    }
+}
+
 sub _update {
     my ($self) = @_;
     my ($m_x, $m_y, $m_z) = ($self->{move_options}{x}, $self->{move_options}{y}, $self->{move_options}{z});
@@ -528,6 +560,7 @@ sub _update {
     push @objects, $self->{model_object};
     $self->{canvas}->reset_objects;
     $self->{canvas}->load_object($_, undef, [0]) for @objects;
+    $self->{canvas}->update_volumes_colors_by_extruder($self->GetParent->GetParent->GetParent->{config});
     $self->{canvas}->Render;
 }
 

BIN
resources/icons/action_undo.png


BIN
resources/icons/sys_lock.png


BIN
resources/icons/sys_unlock.png


+ 4 - 0
resources/profiles/PrusaResearch.ini

@@ -600,6 +600,7 @@ temperature = 255
 
 [filament:*FLEX*]
 inherits = *common*
+bed_temperature = 50
 bridge_fan_speed = 100
 compatible_printers_condition = nozzle_diameter[0]>0.35 and num_extruders==1
 cooling = 0
@@ -950,6 +951,7 @@ variable_layer_height = 0
 
 [printer:Original Prusa i3 MK2]
 inherits = *common*
+default_print_profile = 0.15mm OPTIMAL
 
 [printer:Original Prusa i3 MK2 0.25 nozzle]
 inherits = *common*
@@ -968,6 +970,7 @@ max_layer_height = 0.35
 min_layer_height = 0.1
 nozzle_diameter = 0.6
 printer_variant = 0.6
+default_print_profile = 0.20mm NORMAL 0.6 nozzle
 
 [printer:Original Prusa i3 MK2 MM Single Mode]
 inherits = *mm-single*
@@ -976,6 +979,7 @@ inherits = *mm-single*
 inherits = *mm-single*
 nozzle_diameter = 0.6
 printer_variant = 0.6
+default_print_profile = 0.20mm NORMAL 0.6 nozzle
 
 [printer:Original Prusa i3 MK2 MultiMaterial]
 inherits = *mm-multi*

Some files were not shown because too many files changed in this diff