ENABLE_GCODE_VIEWER -> Partial refactoring in preparation for removal of old time estimator
This commit is contained in:
parent
4700579589
commit
dc59e86d2c
7 changed files with 46 additions and 0 deletions
|
@ -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";
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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_
|
||||
|
|
|
@ -1323,7 +1323,11 @@ void Sidebar::update_sliced_info_sizer()
|
|||
p->sliced_info->SetTextAndShow(siCost, info_text, new_label);
|
||||
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
#if ENABLE_GCODE_VIEWER_USE_OLD_TIME_ESTIMATOR
|
||||
if (p->plater->get_current_canvas3D()->is_time_estimate_enabled() || (ps.estimated_normal_print_time_str == "N/A" && ps.estimated_silent_print_time_str == "N/A"))
|
||||
#else
|
||||
if (p->plater->get_current_canvas3D()->is_time_estimate_enabled() || (ps.estimated_normal_print_time <= 0.0f && ps.estimated_silent_print_time <= 0.0f))
|
||||
#endif // ENABLE_GCODE_VIEWER_USE_OLD_TIME_ESTIMATOR
|
||||
#else
|
||||
|
||||
if (ps.estimated_normal_print_time == "N/A" && ps.estimated_silent_print_time == "N/A")
|
||||
|
@ -1336,7 +1340,11 @@ void Sidebar::update_sliced_info_sizer()
|
|||
wxString str_pause = _L("Pause");
|
||||
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
#if ENABLE_GCODE_VIEWER_USE_OLD_TIME_ESTIMATOR
|
||||
auto fill_labels = [str_color, str_pause](const std::vector<std::pair<CustomGCode::Type, std::pair<std::string, std::string>>>& times,
|
||||
#else
|
||||
auto fill_labels = [str_color, str_pause](const std::vector<std::pair<CustomGCode::Type, std::pair<float, float>>>& times,
|
||||
#endif // ENABLE_GCODE_VIEWER_USE_OLD_TIME_ESTIMATOR
|
||||
#else
|
||||
auto fill_labels = [str_color, str_pause](const std::vector<std::pair<CustomGCode::Type, std::string>>& times,
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
|
@ -1358,7 +1366,11 @@ void Sidebar::update_sliced_info_sizer()
|
|||
new_label += format_wxstr(" -> %1%", str_pause);
|
||||
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
#if ENABLE_GCODE_VIEWER_USE_OLD_TIME_ESTIMATOR
|
||||
info_text += format_wxstr("\n%1% (%2%)", times[i].second.first, times[i].second.second);
|
||||
#else
|
||||
info_text += format_wxstr("\n%1% (%2%)", short_time(get_time_dhms(times[i].second.first)), short_time(get_time_dhms(times[i].second.second)));
|
||||
#endif // ENABLE_GCODE_VIEWER_USE_OLD_TIME_ESTIMATOR
|
||||
#else
|
||||
info_text += format_wxstr("\n%1%", times[i].second);
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
|
@ -1366,6 +1378,7 @@ void Sidebar::update_sliced_info_sizer()
|
|||
};
|
||||
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
#if ENABLE_GCODE_VIEWER_USE_OLD_TIME_ESTIMATOR
|
||||
if (ps.estimated_normal_print_time_str != "N/A") {
|
||||
new_label += format_wxstr("\n - %1%", _L("normal mode"));
|
||||
info_text += format_wxstr("\n%1%", ps.estimated_normal_print_time_str);
|
||||
|
@ -1375,6 +1388,17 @@ void Sidebar::update_sliced_info_sizer()
|
|||
new_label += format_wxstr("\n - %1%", _L("stealth mode"));
|
||||
info_text += format_wxstr("\n%1%", ps.estimated_silent_print_time_str);
|
||||
fill_labels(ps.estimated_silent_custom_gcode_print_times_str, new_label, info_text);
|
||||
#else
|
||||
if (ps.estimated_normal_print_time > 0.0f) {
|
||||
new_label += format_wxstr("\n - %1%", _L("normal mode"));
|
||||
info_text += format_wxstr("\n%1%", short_time(get_time_dhms(ps.estimated_normal_print_time)));
|
||||
fill_labels(ps.estimated_normal_custom_gcode_print_times, new_label, info_text);
|
||||
}
|
||||
if (ps.estimated_silent_print_time > 0.0f) {
|
||||
new_label += format_wxstr("\n - %1%", _L("stealth mode"));
|
||||
info_text += format_wxstr("\n%1%", short_time(get_time_dhms(ps.estimated_silent_print_time)));
|
||||
fill_labels(ps.estimated_silent_custom_gcode_print_times, new_label, info_text);
|
||||
#endif // ENABLE_GCODE_VIEWER_USE_OLD_TIME_ESTIMATOR
|
||||
#else
|
||||
if (ps.estimated_normal_print_time != "N/A") {
|
||||
new_label += format_wxstr("\n - %1%", _L("normal mode"));
|
||||
|
@ -1397,6 +1421,9 @@ void Sidebar::update_sliced_info_sizer()
|
|||
p->sliced_info->SetTextAndShow(siMateril_unit, "N/A");
|
||||
}
|
||||
}
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
Layout();
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
}
|
||||
|
||||
void Sidebar::show_sliced_info_sizer(const bool show)
|
||||
|
|
Loading…
Reference in a new issue