GCodeProcessor -> Fixed export of estimated time to gcode filename
This commit is contained in:
parent
bcd998f9f1
commit
64001c0fe5
6 changed files with 40 additions and 6 deletions
|
@ -715,6 +715,17 @@ std::vector<std::pair<coordf_t, std::vector<GCode::LayerToPrint>>> GCode::collec
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER
|
#if ENABLE_GCODE_VIEWER
|
||||||
|
// free functions called by GCode::do_export()
|
||||||
|
namespace DoExport {
|
||||||
|
static void update_print_estimated_times_stats(const GCodeProcessor& processor, PrintStatistics& print_statistics)
|
||||||
|
{
|
||||||
|
const GCodeProcessor::Result& result = processor.get_result();
|
||||||
|
print_statistics.estimated_normal_print_time = get_time_dhm(result.time_statistics.modes[static_cast<size_t>(PrintEstimatedTimeStatistics::ETimeMode::Normal)].time);
|
||||||
|
print_statistics.estimated_silent_print_time = processor.is_stealth_time_estimator_enabled() ?
|
||||||
|
get_time_dhm(result.time_statistics.modes[static_cast<size_t>(PrintEstimatedTimeStatistics::ETimeMode::Stealth)].time) : "N/A";
|
||||||
|
}
|
||||||
|
} // namespace DoExport
|
||||||
|
|
||||||
void GCode::do_export(Print* print, const char* path, GCodeProcessor::Result* result, ThumbnailsGeneratorCallback thumbnail_cb)
|
void GCode::do_export(Print* print, const char* path, GCodeProcessor::Result* result, ThumbnailsGeneratorCallback thumbnail_cb)
|
||||||
#else
|
#else
|
||||||
void GCode::do_export(Print* print, const char* path, GCodePreviewData* preview_data, ThumbnailsGeneratorCallback thumbnail_cb)
|
void GCode::do_export(Print* print, const char* path, GCodePreviewData* preview_data, ThumbnailsGeneratorCallback thumbnail_cb)
|
||||||
|
@ -777,6 +788,7 @@ void GCode::do_export(Print* print, const char* path, GCodePreviewData* preview_
|
||||||
|
|
||||||
#if ENABLE_GCODE_VIEWER
|
#if ENABLE_GCODE_VIEWER
|
||||||
m_processor.process_file(path_tmp);
|
m_processor.process_file(path_tmp);
|
||||||
|
DoExport::update_print_estimated_times_stats(m_processor, print->m_print_statistics);
|
||||||
if (result != nullptr)
|
if (result != nullptr)
|
||||||
*result = std::move(m_processor.extract_result());
|
*result = std::move(m_processor.extract_result());
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -317,6 +317,9 @@ namespace Slic3r {
|
||||||
void apply_config(const PrintConfig& config);
|
void apply_config(const PrintConfig& config);
|
||||||
void apply_config(const DynamicPrintConfig& config);
|
void apply_config(const DynamicPrintConfig& config);
|
||||||
void enable_stealth_time_estimator(bool enabled);
|
void enable_stealth_time_estimator(bool enabled);
|
||||||
|
bool is_stealth_time_estimator_enabled() const {
|
||||||
|
return m_time_processor.machines[static_cast<size_t>(ETimeMode::Stealth)].enabled;
|
||||||
|
}
|
||||||
void enable_producers(bool enabled) { m_producers_enabled = enabled; }
|
void enable_producers(bool enabled) { m_producers_enabled = enabled; }
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
|
|
|
@ -2190,13 +2190,11 @@ std::string Print::output_filename(const std::string &filename_base) const
|
||||||
DynamicConfig PrintStatistics::config() const
|
DynamicConfig PrintStatistics::config() const
|
||||||
{
|
{
|
||||||
DynamicConfig config;
|
DynamicConfig config;
|
||||||
#if !ENABLE_GCODE_VIEWER
|
|
||||||
std::string normal_print_time = short_time(this->estimated_normal_print_time);
|
std::string normal_print_time = short_time(this->estimated_normal_print_time);
|
||||||
std::string silent_print_time = short_time(this->estimated_silent_print_time);
|
std::string silent_print_time = short_time(this->estimated_silent_print_time);
|
||||||
config.set_key_value("print_time", new ConfigOptionString(normal_print_time));
|
config.set_key_value("print_time", new ConfigOptionString(normal_print_time));
|
||||||
config.set_key_value("normal_print_time", new ConfigOptionString(normal_print_time));
|
config.set_key_value("normal_print_time", new ConfigOptionString(normal_print_time));
|
||||||
config.set_key_value("silent_print_time", new ConfigOptionString(silent_print_time));
|
config.set_key_value("silent_print_time", new ConfigOptionString(silent_print_time));
|
||||||
#endif // !ENABLE_GCODE_VIEWER
|
|
||||||
config.set_key_value("used_filament", new ConfigOptionFloat(this->total_used_filament / 1000.));
|
config.set_key_value("used_filament", new ConfigOptionFloat(this->total_used_filament / 1000.));
|
||||||
config.set_key_value("extruded_volume", new ConfigOptionFloat(this->total_extruded_volume));
|
config.set_key_value("extruded_volume", new ConfigOptionFloat(this->total_extruded_volume));
|
||||||
config.set_key_value("total_cost", new ConfigOptionFloat(this->total_cost));
|
config.set_key_value("total_cost", new ConfigOptionFloat(this->total_cost));
|
||||||
|
|
|
@ -303,9 +303,9 @@ private:
|
||||||
struct PrintStatistics
|
struct PrintStatistics
|
||||||
{
|
{
|
||||||
PrintStatistics() { clear(); }
|
PrintStatistics() { clear(); }
|
||||||
#if !ENABLE_GCODE_VIEWER
|
|
||||||
std::string estimated_normal_print_time;
|
std::string estimated_normal_print_time;
|
||||||
std::string estimated_silent_print_time;
|
std::string estimated_silent_print_time;
|
||||||
|
#if !ENABLE_GCODE_VIEWER
|
||||||
std::vector<std::pair<CustomGCode::Type, std::string>> estimated_normal_custom_gcode_print_times;
|
std::vector<std::pair<CustomGCode::Type, std::string>> estimated_normal_custom_gcode_print_times;
|
||||||
std::vector<std::pair<CustomGCode::Type, std::string>> estimated_silent_custom_gcode_print_times;
|
std::vector<std::pair<CustomGCode::Type, std::string>> estimated_silent_custom_gcode_print_times;
|
||||||
#endif // !ENABLE_GCODE_VIEWER
|
#endif // !ENABLE_GCODE_VIEWER
|
||||||
|
|
|
@ -337,6 +337,25 @@ inline std::string get_time_dhms(float time_in_secs)
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline std::string get_time_dhm(float time_in_secs)
|
||||||
|
{
|
||||||
|
int days = (int)(time_in_secs / 86400.0f);
|
||||||
|
time_in_secs -= (float)days * 86400.0f;
|
||||||
|
int hours = (int)(time_in_secs / 3600.0f);
|
||||||
|
time_in_secs -= (float)hours * 3600.0f;
|
||||||
|
int minutes = (int)(time_in_secs / 60.0f);
|
||||||
|
|
||||||
|
char buffer[64];
|
||||||
|
if (days > 0)
|
||||||
|
::sprintf(buffer, "%dd %dh %dm %ds", days, hours, minutes, (int)time_in_secs);
|
||||||
|
else if (hours > 0)
|
||||||
|
::sprintf(buffer, "%dh %dm %ds", hours, minutes, (int)time_in_secs);
|
||||||
|
else if (minutes > 0)
|
||||||
|
::sprintf(buffer, "%dm %ds", minutes, (int)time_in_secs);
|
||||||
|
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Slic3r
|
} // namespace Slic3r
|
||||||
|
|
||||||
#if WIN32
|
#if WIN32
|
||||||
|
|
|
@ -147,6 +147,8 @@ void Bed3D::Axes::set_stem_length(float length)
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
Bed3D::Axes::Axes()
|
Bed3D::Axes::Axes()
|
||||||
|
: origin(Vec3d::Zero())
|
||||||
|
, length(25.0 * Vec3d::Ones())
|
||||||
{
|
{
|
||||||
m_quadric = ::gluNewQuadric();
|
m_quadric = ::gluNewQuadric();
|
||||||
if (m_quadric != nullptr)
|
if (m_quadric != nullptr)
|
||||||
|
|
Loading…
Reference in a new issue