Refactoring to allow to quickly build the various options to show the estimated printing time in gcode viewer scene

This commit is contained in:
enricoturri1966 2020-08-05 15:43:46 +02:00
parent 510e787bc7
commit 8fc5be7e4f
15 changed files with 125 additions and 174 deletions

View file

@ -9,6 +9,8 @@
#include <boost/nowide/cstdio.hpp>
#include <boost/algorithm/string/predicate.hpp>
#if !ENABLE_GCODE_VIEWER
static const float MMMIN_TO_MMSEC = 1.0f / 60.0f;
static const float MILLISEC_TO_SEC = 0.001f;
static const float INCHES_TO_MM = 25.4f;
@ -722,24 +724,6 @@ namespace Slic3r {
return ret;
}
#if ENABLE_GCODE_VIEWER
#if ENABLE_GCODE_VIEWER_USE_OLD_TIME_ESTIMATOR
std::vector<std::pair<CustomGCode::Type, std::pair<std::string, std::string>>> GCodeTimeEstimator::get_custom_gcode_times_dhm(bool include_remaining) const
{
std::vector<std::pair<CustomGCode::Type, std::pair<std::string, std::string>>> ret;
float total_time = 0.0f;
for (const auto& [type, time] : m_custom_gcode_times) {
std::string duration = _get_time_dhm(time);
std::string remaining = include_remaining ? _get_time_dhm(m_time - total_time) : "";
ret.push_back({ type, { duration, remaining } });
total_time += time;
}
return ret;
}
#endif // ENABLE_GCODE_VIEWER_USE_OLD_TIME_ESTIMATOR
#else
std::vector<std::pair<CustomGCode::Type, std::string>> GCodeTimeEstimator::get_custom_gcode_times_dhm(bool include_remaining) const
{
std::vector<std::pair<CustomGCode::Type, std::string>> ret;
@ -760,7 +744,6 @@ namespace Slic3r {
return ret;
}
#endif // ENABLE_GCODE_VIEWER
// Return an estimate of the memory consumed by the time estimator.
size_t GCodeTimeEstimator::memory_used() const
@ -1690,3 +1673,5 @@ namespace Slic3r {
}
#endif // ENABLE_MOVE_STATS
}
#endif // !ENABLE_GCODE_VIEWER