Slightly faster time estimation

This commit is contained in:
Enrico Turri 2018-07-20 12:05:08 +02:00
parent c1d1721dae
commit 4b8e10a05c
3 changed files with 12 additions and 6 deletions

View file

@ -863,9 +863,9 @@ void GCode::_do_export(Print &print, FILE *file, GCodePreviewData *preview_data)
_write(file, m_writer.postamble());
// calculates estimated printing time
m_normal_time_estimator.calculate_time();
m_normal_time_estimator.calculate_time(false);
if (m_silent_time_estimator_enabled)
m_silent_time_estimator.calculate_time();
m_silent_time_estimator.calculate_time(false);
// Get filament stats.
print.filament_stats.clear();

View file

@ -196,11 +196,14 @@ namespace Slic3r {
}
}
void GCodeTimeEstimator::calculate_time()
void GCodeTimeEstimator::calculate_time(bool start_from_beginning)
{
PROFILE_FUNC();
_reset_time();
_set_blocks_st_synchronize(false);
if (start_from_beginning)
{
_reset_time();
_set_blocks_st_synchronize(false);
}
_calculate_time();
#if ENABLE_MOVE_STATS

View file

@ -227,7 +227,10 @@ namespace Slic3r {
void add_gcode_block(const std::string &str) { this->add_gcode_block(str.c_str()); }
// Calculates the time estimate from the gcode lines added using add_gcode_line() or add_gcode_block()
void calculate_time();
// start_from_beginning:
// if set to true all blocks will be used to calculate the time estimate,
// if set to false only the blocks not yet processed will be used and the calculated time will be added to the current calculated time
void calculate_time(bool start_from_beginning);
// Calculates the time estimate from the given gcode in string format
void calculate_time_from_text(const std::string& gcode);