Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEnrico Turri <enricoturri@seznam.cz>2017-12-14 11:18:28 +0300
committerEnrico Turri <enricoturri@seznam.cz>2017-12-14 11:18:28 +0300
commit0fe855cd6d12f067a6f14469c886a5091b421752 (patch)
treef7b6580dd0449584fe4db84adaa855858d115d35 /xs/src/libslic3r/GCodeTimeEstimator.cpp
parent20234c94eee03e7e361a91fafedf5c1a753baed5 (diff)
Time estimate shown in GUI as formatted string / Write to file made by class GCode's private methods
Diffstat (limited to 'xs/src/libslic3r/GCodeTimeEstimator.cpp')
-rw-r--r--xs/src/libslic3r/GCodeTimeEstimator.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/xs/src/libslic3r/GCodeTimeEstimator.cpp b/xs/src/libslic3r/GCodeTimeEstimator.cpp
index b6caaf79e..6d4652457 100644
--- a/xs/src/libslic3r/GCodeTimeEstimator.cpp
+++ b/xs/src/libslic3r/GCodeTimeEstimator.cpp
@@ -157,6 +157,16 @@ namespace Slic3r {
reset();
}
+ void GCodeTimeEstimator::calculate_time_from_lines(const std::vector<std::string>& gcode_lines)
+ {
+ for (const std::string& line : gcode_lines)
+ {
+ _parser.parse_line(line, boost::bind(&GCodeTimeEstimator::_process_gcode_line, this, _1, _2));
+ }
+ _calculate_time();
+ reset();
+ }
+
void GCodeTimeEstimator::add_gcode_line(const std::string& gcode_line)
{
_parser.parse_line(gcode_line, boost::bind(&GCodeTimeEstimator::_process_gcode_line, this, _1, _2));
@@ -354,8 +364,14 @@ namespace Slic3r {
int minutes = (int)(timeinsecs / 60.0f);
timeinsecs -= (float)minutes * 60.0f;
- char buffer[16];
- ::sprintf(buffer, "%02d:%02d:%02d", hours, minutes, (int)timeinsecs);
+ char buffer[64];
+ if (hours > 0)
+ ::sprintf(buffer, "%dh %dm %ds", hours, minutes, (int)timeinsecs);
+ else if (minutes > 0)
+ ::sprintf(buffer, "%dm %ds", minutes, (int)timeinsecs);
+ else
+ ::sprintf(buffer, "%ds", (int)timeinsecs);
+
return buffer;
}
@@ -393,7 +409,7 @@ namespace Slic3r {
{
if (line.cmd.length() > 1)
{
- switch (line.cmd[0])
+ switch (::toupper(line.cmd[0]))
{
case 'G':
{