diff --git a/src/slic3r/GUI/GCodeViewer.cpp b/src/slic3r/GUI/GCodeViewer.cpp index 6aa6c145f..9c653813c 100644 --- a/src/slic3r/GUI/GCodeViewer.cpp +++ b/src/slic3r/GUI/GCodeViewer.cpp @@ -302,6 +302,9 @@ void GCodeViewer::load(const GCodeProcessor::Result& gcode_result, const Print& reset(); load_toolpaths(gcode_result); + if (m_layers_zs.empty()) + return; + if (wxGetApp().is_editor()) load_shells(print, initialized); else { @@ -1477,6 +1480,11 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result) } } + if (progress_dialog != nullptr) { + progress_dialog->Update(100, ""); + progress_dialog->Fit(); + } + log_memory_usage("Loaded G-code generated indices buffers, ", vertices, indices); // toolpaths data -> send indices data to gpu @@ -1550,7 +1558,8 @@ void GCodeViewer::load_toolpaths(const GCodeProcessor::Result& gcode_result) } // set layers z range - m_layers_z_range = { m_layers_zs.front(), m_layers_zs.back() }; + if (!m_layers_zs.empty()) + m_layers_z_range = { m_layers_zs.front(), m_layers_zs.back() }; // roles -> remove duplicates std::sort(m_roles.begin(), m_roles.end()); diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index ff7d21e0c..69be62ca0 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -1256,7 +1256,7 @@ void Preview::load_print_as_fff(bool keep_z_range) // It is left to Slic3r to decide whether the print shall be colored by the tool or by the feature. // Color by feature if it is a single extruder print. unsigned int number_extruders = (unsigned int)print->extruders().size(); - int tool_idx = m_choice_view_type->FindString(_(L("Tool"))); + int tool_idx = m_choice_view_type->FindString(_L("Tool")); int type = (number_extruders > 1) ? tool_idx /* color by a tool number */ : 0; // color by a feature type m_choice_view_type->SetSelection(type); #if ENABLE_GCODE_VIEWER diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 791630bd1..5e8e06625 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1407,8 +1407,8 @@ bool PlaterDropTarget::OnDropFiles(wxCoord x, wxCoord y, const wxArrayString &fi return false; } else if (paths.size() == 1) { - plater->load_gcode(from_path(paths.front())); - return true; + plater->load_gcode(from_path(paths.front())); + return true; } return false; } @@ -4728,6 +4728,10 @@ void Plater::load_gcode(const wxString& filename) // show results p->preview->reload_print(false); p->preview->get_canvas3d()->zoom_to_gcode(); + + if (p->preview->get_canvas3d()->get_gcode_layers_zs().empty()) + wxMessageDialog(this, _L("The selected file") + ":\n" + filename + "\n" + _L("does not contain valid gcode."), + wxString(GCODEVIEWER_APP_NAME) + " - " + _L("Error while loading .gcode file"), wxCLOSE | wxICON_WARNING | wxCENTRE).ShowModal(); } void Plater::refresh_print()