GCodeViewer will now always show the estimations (#10333)

Co-authored-by: SoftFever <softfeverever@gmail.com>
This commit is contained in:
niklasb
2025-08-24 14:13:34 +02:00
committed by GitHub
parent 09034d87b7
commit 586921fa4d

View File

@@ -5573,7 +5573,6 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
// total estimated printing time section // total estimated printing time section
if (show_estimated) {
ImGui::Spacing(); ImGui::Spacing();
std::string time_title = m_view_type == EViewType::FeatureType ? _u8L("Total Estimation") : _u8L("Time Estimation"); std::string time_title = m_view_type == EViewType::FeatureType ? _u8L("Total Estimation") : _u8L("Time Estimation");
auto can_show_mode_button = [this](PrintEstimatedStatistics::ETimeMode mode) { auto can_show_mode_button = [this](PrintEstimatedStatistics::ETimeMode mode) {
@@ -5590,7 +5589,6 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
} }
return show; return show;
}; };
if (can_show_mode_button(m_time_estimate_mode)) { if (can_show_mode_button(m_time_estimate_mode)) {
switch (m_time_estimate_mode) switch (m_time_estimate_mode)
{ {
@@ -5608,7 +5606,6 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
std::string prepare_str = _u8L("Prepare time"); std::string prepare_str = _u8L("Prepare time");
std::string print_str = _u8L("Model printing time"); std::string print_str = _u8L("Model printing time");
std::string total_str = _u8L("Total time"); std::string total_str = _u8L("Total time");
float max_len = window_padding + 2 * ImGui::GetStyle().ItemSpacing.x; float max_len = window_padding + 2 * ImGui::GetStyle().ItemSpacing.x;
if (time_mode.layers_times.empty()) if (time_mode.layers_times.empty())
max_len += ImGui::CalcTextSize(total_str.c_str()).x; max_len += ImGui::CalcTextSize(total_str.c_str()).x;
@@ -5622,7 +5619,6 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
max_len += std::max(ImGui::CalcTextSize(print_str.c_str()).x, max_len += std::max(ImGui::CalcTextSize(print_str.c_str()).x,
(std::max(ImGui::CalcTextSize(prepare_str.c_str()).x, ImGui::CalcTextSize(total_str.c_str()).x))); (std::max(ImGui::CalcTextSize(prepare_str.c_str()).x, ImGui::CalcTextSize(total_str.c_str()).x)));
} }
if (m_view_type == EViewType::FeatureType) { if (m_view_type == EViewType::FeatureType) {
//BBS display filament cost //BBS display filament cost
ImGui::Dummy({ window_padding, window_padding }); ImGui::Dummy({ window_padding, window_padding });
@@ -5637,7 +5633,6 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
ImGui::SameLine(); ImGui::SameLine();
::sprintf(buf, imperial_units ? " %.2f oz" : " %.2f g", ps.total_weight / unit_conver); ::sprintf(buf, imperial_units ? " %.2f oz" : " %.2f g", ps.total_weight / unit_conver);
imgui.text(buf); imgui.text(buf);
ImGui::Dummy({ window_padding, window_padding }); ImGui::Dummy({ window_padding, window_padding });
ImGui::SameLine(); ImGui::SameLine();
imgui.text(model_filament_str + ":"); imgui.text(model_filament_str + ":");
@@ -5649,7 +5644,6 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
ImGui::SameLine(); ImGui::SameLine();
::sprintf(buf, imperial_units ? " %.2f oz" : " %.2f g", (ps.total_weight - exlude_g) / unit_conver); ::sprintf(buf, imperial_units ? " %.2f oz" : " %.2f g", (ps.total_weight - exlude_g) / unit_conver);
imgui.text(buf); imgui.text(buf);
//BBS: display cost of filaments //BBS: display cost of filaments
ImGui::Dummy({ window_padding, window_padding }); ImGui::Dummy({ window_padding, window_padding });
ImGui::SameLine(); ImGui::SameLine();
@@ -5658,7 +5652,6 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
::sprintf(buf, "%.2f", ps.total_cost); ::sprintf(buf, "%.2f", ps.total_cost);
imgui.text(buf); imgui.text(buf);
} }
auto role_time = [time_mode](ExtrusionRole role) { auto role_time = [time_mode](ExtrusionRole role) {
auto it = std::find_if(time_mode.roles_times.begin(), time_mode.roles_times.end(), [role](const std::pair<ExtrusionRole, float>& item) { return role == item.first; }); auto it = std::find_if(time_mode.roles_times.begin(), time_mode.roles_times.end(), [role](const std::pair<ExtrusionRole, float>& item) { return role == item.first; });
return (it != time_mode.roles_times.end()) ? it->second : 0.0f; return (it != time_mode.roles_times.end()) ? it->second : 0.0f;
@@ -5707,7 +5700,6 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
} }
default : { assert(false); break; } default : { assert(false); break; }
} }
}
if (m_view_type == EViewType::ColorPrint) { if (m_view_type == EViewType::ColorPrint) {
ImGui::Spacing(); ImGui::Spacing();