ENABLE_GCODE_VIEWER -> Partial refactoring in preparation for removal of old time estimator

This commit is contained in:
enricoturri1966 2020-07-21 09:34:54 +02:00
parent 4700579589
commit dc59e86d2c
7 changed files with 46 additions and 0 deletions

View file

@ -1065,11 +1065,13 @@ namespace DoExport {
print_statistics.clear();
#if ENABLE_GCODE_VIEWER
#if ENABLE_GCODE_VIEWER_USE_OLD_TIME_ESTIMATOR
print_statistics.estimated_normal_print_time_str = normal_time_estimator.get_time_dhm/*s*/();
print_statistics.estimated_silent_print_time_str = silent_time_estimator_enabled ? silent_time_estimator.get_time_dhm/*s*/() : "N/A";
print_statistics.estimated_normal_custom_gcode_print_times_str = normal_time_estimator.get_custom_gcode_times_dhm(true);
if (silent_time_estimator_enabled)
print_statistics.estimated_silent_custom_gcode_print_times_str = silent_time_estimator.get_custom_gcode_times_dhm(true);
#endif // ENABLE_GCODE_VIEWER_USE_OLD_TIME_ESTIMATOR
#else
print_statistics.estimated_normal_print_time = normal_time_estimator.get_time_dhm/*s*/();
print_statistics.estimated_silent_print_time = silent_time_estimator_enabled ? silent_time_estimator.get_time_dhm/*s*/() : "N/A";

View file

@ -723,6 +723,7 @@ namespace Slic3r {
}
#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;
@ -737,6 +738,7 @@ namespace Slic3r {
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
{

View file

@ -371,7 +371,9 @@ namespace Slic3r {
// Returns the estimated time, in format DDd HHh MMm, for each custom_gcode
// If include_remaining==true the strings will be formatted as: "time for custom_gcode (remaining time at color start)"
#if ENABLE_GCODE_VIEWER
#if ENABLE_GCODE_VIEWER_USE_OLD_TIME_ESTIMATOR
std::vector<std::pair<CustomGCode::Type, std::pair<std::string, std::string>>> get_custom_gcode_times_dhm(bool include_remaining) const;
#endif // ENABLE_GCODE_VIEWER_USE_OLD_TIME_ESTIMATOR
#else
std::vector<std::pair<CustomGCode::Type, std::string>> get_custom_gcode_times_dhm(bool include_remaining) const;
#endif // ENABLE_GCODE_VIEWER

View file

@ -2191,9 +2191,15 @@ DynamicConfig PrintStatistics::config() const
{
DynamicConfig config;
#if ENABLE_GCODE_VIEWER
#if ENABLE_GCODE_VIEWER_USE_OLD_TIME_ESTIMATOR
config.set_key_value("print_time", new ConfigOptionString(this->estimated_normal_print_time_str));
config.set_key_value("normal_print_time", new ConfigOptionString(this->estimated_normal_print_time_str));
config.set_key_value("silent_print_time", new ConfigOptionString(this->estimated_silent_print_time_str));
#else
config.set_key_value("print_time", new ConfigOptionString(short_time(get_time_dhms(this->estimated_normal_print_time))));
config.set_key_value("normal_print_time", new ConfigOptionString(short_time(get_time_dhms(this->estimated_normal_print_time))));
config.set_key_value("silent_print_time", new ConfigOptionString(short_time(get_time_dhms(this->estimated_silent_print_time))));
#endif // ENABLE_GCODE_VIEWER_USE_OLD_TIME_ESTIMATOR
#else
std::string normal_print_time = short_time(this->estimated_normal_print_time);
std::string silent_print_time = short_time(this->estimated_silent_print_time);

View file

@ -306,12 +306,16 @@ struct PrintStatistics
#if ENABLE_GCODE_VIEWER
float estimated_normal_print_time;
float estimated_silent_print_time;
#if ENABLE_GCODE_VIEWER_USE_OLD_TIME_ESTIMATOR
std::string estimated_normal_print_time_str;
std::string estimated_silent_print_time_str;
#endif // ENABLE_GCODE_VIEWER_USE_OLD_TIME_ESTIMATOR
std::vector<std::pair<CustomGCode::Type, std::pair<float, float>>> estimated_normal_custom_gcode_print_times;
std::vector<std::pair<CustomGCode::Type, std::pair<float, float>>> estimated_silent_custom_gcode_print_times;
#if ENABLE_GCODE_VIEWER_USE_OLD_TIME_ESTIMATOR
std::vector<std::pair<CustomGCode::Type, std::pair<std::string, std::string>>> estimated_normal_custom_gcode_print_times_str;
std::vector<std::pair<CustomGCode::Type, std::pair<std::string, std::string>>> estimated_silent_custom_gcode_print_times_str;
#endif // ENABLE_GCODE_VIEWER_USE_OLD_TIME_ESTIMATOR
std::vector<std::pair<GCodeProcessor::EMoveType, float>> estimated_normal_moves_times;
std::vector<std::pair<GCodeProcessor::EMoveType, float>> estimated_silent_moves_times;
std::vector<std::pair<ExtrusionRole, float>> estimated_normal_roles_times;
@ -341,10 +345,12 @@ struct PrintStatistics
void clear() {
#if ENABLE_GCODE_VIEWER
clear_time_estimates();
#if ENABLE_GCODE_VIEWER_USE_OLD_TIME_ESTIMATOR
estimated_normal_print_time_str.clear();
estimated_silent_print_time_str.clear();
estimated_normal_custom_gcode_print_times_str.clear();
estimated_silent_custom_gcode_print_times_str.clear();
#endif // ENABLE_GCODE_VIEWER_USE_OLD_TIME_ESTIMATOR
#else
estimated_normal_print_time.clear();
estimated_silent_print_time.clear();

View file

@ -62,6 +62,7 @@
#define ENABLE_GCODE_VIEWER_STATISTICS (0 && ENABLE_GCODE_VIEWER)
#define ENABLE_GCODE_VIEWER_SHADERS_EDITOR (0 && ENABLE_GCODE_VIEWER)
#define ENABLE_GCODE_VIEWER_AS_STATE (1 && ENABLE_GCODE_VIEWER)
#define ENABLE_GCODE_VIEWER_USE_OLD_TIME_ESTIMATOR (1 && ENABLE_GCODE_VIEWER)
#endif // _prusaslicer_technologies_h_