Improved handling of loading invalid .gcode files
This commit is contained in:
parent
38e883a66e
commit
516db43b20
3 changed files with 17 additions and 4 deletions
|
@ -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());
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue