Added absolute time to estimated time for color print and fixed a bug in showing estimated times for print color for silent mode

This commit is contained in:
Enrico Turri 2019-08-02 12:05:02 +02:00
parent 28cc595350
commit c791ba776f
4 changed files with 29 additions and 11 deletions

View file

@ -1138,9 +1138,9 @@ void GCode::_do_export(Print &print, FILE *file)
print.m_print_statistics.clear();
print.m_print_statistics.estimated_normal_print_time = m_normal_time_estimator.get_time_dhms();
print.m_print_statistics.estimated_silent_print_time = m_silent_time_estimator_enabled ? m_silent_time_estimator.get_time_dhms() : "N/A";
print.m_print_statistics.estimated_normal_color_print_times = m_normal_time_estimator.get_color_times_dhms();
print.m_print_statistics.estimated_normal_color_print_times = m_normal_time_estimator.get_color_times_dhms(true);
if (m_silent_time_estimator_enabled)
print.m_print_statistics.estimated_silent_color_print_times = m_silent_time_estimator.get_color_times_dhms();
print.m_print_statistics.estimated_silent_color_print_times = m_silent_time_estimator.get_color_times_dhms(true);
std::vector<Extruder> extruders = m_writer.extruders();
if (! extruders.empty()) {

View file

@ -694,22 +694,38 @@ namespace Slic3r {
return m_color_times;
}
std::vector<std::string> GCodeTimeEstimator::get_color_times_dhms() const
std::vector<std::string> GCodeTimeEstimator::get_color_times_dhms(bool include_absolute) const
{
std::vector<std::string> ret;
float total_time = 0.0f;
for (float t : m_color_times)
{
ret.push_back(_get_time_dhms(t));
total_time += t;
std::string time = "";
if (include_absolute)
time += _get_time_dhms(total_time) + " (";
time += _get_time_dhms(t);
if (include_absolute)
time += ")";
ret.push_back(time);
}
return ret;
}
std::vector<std::string> GCodeTimeEstimator::get_color_times_minutes() const
std::vector<std::string> GCodeTimeEstimator::get_color_times_minutes(bool include_absolute) const
{
std::vector<std::string> ret;
float total_time = 0.0f;
for (float t : m_color_times)
{
ret.push_back(_get_time_minutes(t));
total_time += t;
std::string time = "";
if (include_absolute)
time += _get_time_minutes(total_time) + " (";
time += _get_time_minutes(t);
if (include_absolute)
time += ")";
ret.push_back(time);
}
return ret;
}

View file

@ -350,10 +350,12 @@ namespace Slic3r {
std::vector<float> get_color_times() const;
// Returns the estimated time, in format DDd HHh MMm SSs, for each color
std::vector<std::string> get_color_times_dhms() const;
// If include_absolute==true the strings will be formatted as: "absolute time (relative time)"
std::vector<std::string> get_color_times_dhms(bool include_absolute) const;
// Returns the estimated time, in minutes (integer), for each color
std::vector<std::string> get_color_times_minutes() const;
// If include_absolute==true the strings will be formatted as: "absolute time (relative time)"
std::vector<std::string> get_color_times_minutes(bool include_absolute) const;
// Return an estimate of the memory consumed by the time estimator.
size_t memory_used() const;

View file

@ -1175,10 +1175,10 @@ void Sidebar::show_sliced_info_sizer(const bool show)
if (ps.estimated_silent_print_time != "N/A") {
new_label += wxString::Format("\n - %s", _(L("stealth mode")));
info_text += wxString::Format("\n%s", ps.estimated_silent_print_time);
for (int i = (int)ps.estimated_normal_color_print_times.size() - 1; i >= 0; --i)
for (int i = (int)ps.estimated_silent_color_print_times.size() - 1; i >= 0; --i)
{
new_label += wxString::Format("\n - %s%d", _(L("Color ")), i + 1);
info_text += wxString::Format("\n%s", ps.estimated_normal_color_print_times[i]);
info_text += wxString::Format("\n%s", ps.estimated_silent_color_print_times[i]);
}
}
p->sliced_info->SetTextAndShow(siEstimatedTime, info_text, new_label);