diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 2212990d73..8dc8c56c8b 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1830,7 +1830,7 @@ void GLCanvas3D::update_volumes_colors_by_extruder() using PerBedStatistics = std::vector + std::optional> >>; PerBedStatistics get_statistics(){ @@ -1838,9 +1838,10 @@ PerBedStatistics get_statistics(){ for (int bed_index=0; bed_indexget_fff_prints()[bed_index].get(); if (print->empty() || !print->finished()) { - continue; + result.emplace_back(bed_index, std::nullopt); + } else { + result.emplace_back(bed_index, std::optional{std::ref(print->print_statistics())}); } - result.emplace_back(bed_index, std::ref(print->print_statistics())); } return result; } @@ -1856,11 +1857,14 @@ struct StatisticsSum { StatisticsSum get_statistics_sum() { StatisticsSum result; for (const auto &[_, statistics] : get_statistics()) { - result.cost += statistics.get().total_cost; - result.filement_weight += statistics.get().total_weight; - result.filament_length += statistics.get().total_used_filament; - result.normal_print_time += statistics.get().normal_print_time_seconds; - result.silent_print_time += statistics.get().silent_print_time_seconds; + if (!statistics) { + continue; + } + result.cost += statistics->get().total_cost; + result.filement_weight += statistics->get().total_weight; + result.filament_length += statistics->get().total_used_filament; + result.normal_print_time += statistics->get().normal_print_time_seconds; + result.silent_print_time += statistics->get().silent_print_time_seconds; } return result; @@ -1900,20 +1904,37 @@ float project_overview_table(float scale) { ); ImGui::TableHeadersRow(); - for (const auto &[bed_index, statistics] : get_statistics()) { - ImGui::TableNextRow(); - ImGui::TableNextColumn(); - ImGui::Text("%s", (_u8L("Plate") + wxString::Format(" %d", bed_index + 1)).ToStdString().c_str()); - ImGui::TableNextColumn(); - ImGui::Text("%s", wxString::Format("%.2f", statistics.get().total_cost).ToStdString().c_str()); - ImGui::TableNextColumn(); - ImGui::Text("%s", wxString::Format("%.2f", statistics.get().total_weight).ToStdString().c_str()); - ImGui::TableNextColumn(); - ImGui::Text("%s", wxString::Format("%.2f", statistics.get().total_used_filament / 1000).ToStdString().c_str()); - ImGui::TableNextColumn(); - ImGui::Text("%s", statistics.get().estimated_silent_print_time.c_str()); - ImGui::TableNextColumn(); - ImGui::Text("%s", statistics.get().estimated_normal_print_time.c_str()); + for (const auto &[bed_index, optional_statistics] : get_statistics()) { + if (optional_statistics) { + const std::reference_wrapper statistics{*optional_statistics}; + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::Text("%s", (_u8L("Bed") + wxString::Format(" %d", bed_index + 1)).ToStdString().c_str()); + ImGui::TableNextColumn(); + ImGui::Text("%s", wxString::Format("%.2f", statistics.get().total_cost).ToStdString().c_str()); + ImGui::TableNextColumn(); + ImGui::Text("%s", wxString::Format("%.2f", statistics.get().total_weight).ToStdString().c_str()); + ImGui::TableNextColumn(); + ImGui::Text("%s", wxString::Format("%.2f", statistics.get().total_used_filament / 1000).ToStdString().c_str()); + ImGui::TableNextColumn(); + ImGui::Text("%s", statistics.get().estimated_silent_print_time.c_str()); + ImGui::TableNextColumn(); + ImGui::Text("%s", statistics.get().estimated_normal_print_time.c_str()); + } else { + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + ImGui::Text("%s", (_u8L("Bed") + wxString::Format(" %d", bed_index + 1)).ToStdString().c_str()); + ImGui::TableNextColumn(); + ImGui::Text("-"); + ImGui::TableNextColumn(); + ImGui::Text("-"); + ImGui::TableNextColumn(); + ImGui::Text("-"); + ImGui::TableNextColumn(); + ImGui::Text("-"); + ImGui::TableNextColumn(); + ImGui::Text("-"); + } } ImGui::PushStyleColor(ImGuiCol_Text, ImGuiPureWrap::COL_ORANGE_LIGHT);