diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 4d33b0134..3a9c6294d 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1070,9 +1070,9 @@ namespace DoExport { print_statistics.clear(); print_statistics.estimated_normal_print_time = normal_time_estimator.get_time_dhm/*s*/(); print_statistics.estimated_silent_print_time = silent_time_estimator_enabled ? silent_time_estimator.get_time_dhm/*s*/() : "N/A"; - print_statistics.estimated_normal_custom_gcode_print_times = normal_time_estimator.get_custom_gcode_times_dhm(true); + print_statistics.estimated_normal_custom_gcode_print_times = normal_time_estimator.get_custom_gcode_times(); if (silent_time_estimator_enabled) - print_statistics.estimated_silent_custom_gcode_print_times = silent_time_estimator.get_custom_gcode_times_dhm(true); + print_statistics.estimated_silent_custom_gcode_print_times = silent_time_estimator.get_custom_gcode_times(); print_statistics.total_toolchanges = std::max(0, wipe_tower_data.number_of_toolchanges); if (! extruders.empty()) { std::pair out_filament_used_mm ("; filament used [mm] = ", 0); diff --git a/src/libslic3r/GCodeTimeEstimator.cpp b/src/libslic3r/GCodeTimeEstimator.cpp index 229441b6c..f01300d4f 100644 --- a/src/libslic3r/GCodeTimeEstimator.cpp +++ b/src/libslic3r/GCodeTimeEstimator.cpp @@ -794,27 +794,6 @@ namespace Slic3r { return ret; } - std::vector> GCodeTimeEstimator::get_custom_gcode_times_dhm(bool include_remaining) const - { - std::vector> ret; - - float total_time = 0.0f; - for (const std::pair &t : m_custom_gcode_times) - { - std::string time = _get_time_dhm(t.second); - if (include_remaining) - { - time += " ("; - time += _get_time_dhm(m_time - total_time); - time += ")"; - } - total_time += t.second; - ret.push_back({t.first, time}); - } - - return ret; - } - // Return an estimate of the memory consumed by the time estimator. size_t GCodeTimeEstimator::memory_used() const { diff --git a/src/libslic3r/GCodeTimeEstimator.hpp b/src/libslic3r/GCodeTimeEstimator.hpp index a2ad52aa3..0bf03e4c3 100644 --- a/src/libslic3r/GCodeTimeEstimator.hpp +++ b/src/libslic3r/GCodeTimeEstimator.hpp @@ -417,10 +417,6 @@ namespace Slic3r { // If include_remaining==true the strings will be formatted as: "time for color (remaining time at color start)" std::vector get_color_times_minutes(bool include_remaining) const; - // Returns the estimated time, in format DDd HHh MMm, for each custom_gcode - // If include_remaining==true the strings will be formatted as: "time for custom_gcode (remaining time at color start)" - std::vector> get_custom_gcode_times_dhm(bool include_remaining) const; - // Return an estimate of the memory consumed by the time estimator. size_t memory_used() const; diff --git a/src/libslic3r/Print.hpp b/src/libslic3r/Print.hpp index a9cee4fb1..58b53edb9 100644 --- a/src/libslic3r/Print.hpp +++ b/src/libslic3r/Print.hpp @@ -319,8 +319,8 @@ struct PrintStatistics PrintStatistics() { clear(); } std::string estimated_normal_print_time; std::string estimated_silent_print_time; - std::vector> estimated_normal_custom_gcode_print_times; - std::vector> estimated_silent_custom_gcode_print_times; + std::vector> estimated_normal_custom_gcode_print_times; + std::vector> estimated_silent_custom_gcode_print_times; double total_used_filament; std::vector> color_extruderid_to_used_filament; double total_extruded_volume; diff --git a/src/libslic3r/Utils.hpp b/src/libslic3r/Utils.hpp index 5cdf75037..283741a86 100644 --- a/src/libslic3r/Utils.hpp +++ b/src/libslic3r/Utils.hpp @@ -337,6 +337,30 @@ inline std::string get_time_dhms(float time_in_secs) return buffer; } +// Returns the given time is seconds in format DDd HHh MMm +inline std::string get_time_dhm(float time_in_secs) +{ + char buffer[64]; + + int minutes = std::round(time_in_secs / 60.); + if (minutes <= 0) { + ::sprintf(buffer, "%ds", (int)time_in_secs); + } else { + int days = minutes / 1440; + minutes -= days * 1440; + int hours = minutes / 60; + minutes -= hours * 60; + if (days > 0) + ::sprintf(buffer, "%dd %dh %dm", days, hours, minutes); + else if (hours > 0) + ::sprintf(buffer, "%dh %dm", hours, minutes); + else + ::sprintf(buffer, "%dm", minutes); + } + + return buffer; +} + } // namespace Slic3r #if WIN32 diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 1d8276d95..a26f4083c 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1244,7 +1244,7 @@ void Sidebar::update_sliced_info_sizer() if (ps.color_extruderid_to_used_filament.size() > 0) { double total_length = 0; for (int i = 0; i < ps.color_extruderid_to_used_filament.size(); i++) { - new_label+= from_u8((boost::format("\n - %1% %2%") % _utf8(L("Color")) % i ).str()); + new_label+= from_u8((boost::format("\n - %1% %2%") % _utf8(L("Color")) % (i+1) ).str()); total_length += ps.color_extruderid_to_used_filament[i].second; info_text += wxString::Format("\n%.2f (%.2f)", ps.color_extruderid_to_used_filament[i].second / 1000, total_length / 1000); } @@ -1260,7 +1260,7 @@ void Sidebar::update_sliced_info_sizer() info_text = wxString::Format("%.2f", ps.total_weight); double total_weight = 0; for (int i = 0; i < ps.color_extruderid_to_used_weight.size(); i++) { - new_label += from_u8((boost::format("\n - %1% %2%") % _utf8(L("Color")) % i).str()); + new_label += from_u8((boost::format("\n - %1% %2%") % _utf8(L("Color")) % (i + 1)).str()); total_weight += ps.color_extruderid_to_used_weight[i].second; info_text += (ps.color_extruderid_to_used_weight[i].second == 0 ? "\nN/A": wxString::Format("\n%.2f", ps.color_extruderid_to_used_weight[i].second / 1000)) + (total_weight == 0 ? " (N/A)" : wxString::Format(" (%.2f)", total_weight / 1000)); @@ -1292,25 +1292,23 @@ void Sidebar::update_sliced_info_sizer() wxString str_color = _(L("Color")); wxString str_pause = _(L("Pause")); - auto fill_labels = [str_color, str_pause](const std::vector>& times, + auto fill_labels = [str_color, str_pause](const std::vector>& times, wxString& new_label, wxString& info_text) { - int color_change_count = 0; - for (auto time : times) - if (time.first == cgtColorChange) - color_change_count++; - - for (int i = (int)times.size() - 1; i >= 0; --i) + int color_change_count = 1; + float time_from_beginning = 0; + for (size_t i = 0; i < times.size(); ++i) { - if (i == 0 || times[i - 1].first == cgtPausePrint) + if (times[i].first == cgtPausePrint) new_label += from_u8((boost::format("\n - %1%%2%") % (std::string(str_color.ToUTF8()) + " ") % color_change_count).str()); - else if (times[i - 1].first == cgtColorChange) - new_label += from_u8((boost::format("\n - %1%%2%") % (std::string(str_color.ToUTF8()) + " ") % color_change_count--).str()); + else if (times[i].first == cgtColorChange) + new_label += from_u8((boost::format("\n - %1%%2%") % (std::string(str_color.ToUTF8()) + " ") % color_change_count++).str()); if (i != (int)times.size() - 1 && times[i].first == cgtPausePrint) new_label += from_u8((boost::format(" -> %1%") % std::string(str_pause.ToUTF8())).str()); - info_text += from_u8((boost::format("\n%1%") % times[i].second).str()); + time_from_beginning += times[i].second; + info_text += from_u8((boost::format("\n%1% (%2%)") % get_time_dhm(times[i].second) % get_time_dhm(time_from_beginning)).str()); } };