Refactoring to allow to quickly build the various options to show the estimated printing time in gcode viewer scene
This commit is contained in:
parent
510e787bc7
commit
8fc5be7e4f
15 changed files with 125 additions and 174 deletions
|
@ -779,8 +779,7 @@ void GCode::do_export(Print* print, const char* path, GCodePreviewData* preview_
|
|||
m_processor.process_file(path_tmp);
|
||||
if (result != nullptr)
|
||||
*result = std::move(m_processor.extract_result());
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
|
||||
#else
|
||||
GCodeTimeEstimator::PostProcessData normal_data = m_normal_time_estimator.get_post_process_data();
|
||||
GCodeTimeEstimator::PostProcessData silent_data = m_silent_time_estimator.get_post_process_data();
|
||||
|
||||
|
@ -789,21 +788,19 @@ void GCode::do_export(Print* print, const char* path, GCodePreviewData* preview_
|
|||
BOOST_LOG_TRIVIAL(debug) << "Time estimator post processing" << log_memory_info();
|
||||
GCodeTimeEstimator::post_process(path_tmp, 60.0f, remaining_times_enabled ? &normal_data : nullptr, (remaining_times_enabled && m_silent_time_estimator_enabled) ? &silent_data : nullptr);
|
||||
|
||||
if (remaining_times_enabled)
|
||||
{
|
||||
if (remaining_times_enabled) {
|
||||
m_normal_time_estimator.reset();
|
||||
if (m_silent_time_estimator_enabled)
|
||||
m_silent_time_estimator.reset();
|
||||
}
|
||||
|
||||
#if !ENABLE_GCODE_VIEWER
|
||||
// starts analyzer calculations
|
||||
if (m_enable_analyzer) {
|
||||
BOOST_LOG_TRIVIAL(debug) << "Preparing G-code preview data" << log_memory_info();
|
||||
m_analyzer.calc_gcode_preview_data(*preview_data, [print]() { print->throw_if_canceled(); });
|
||||
m_analyzer.reset();
|
||||
}
|
||||
#endif // !ENABLE_GCODE_VIEWER
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
|
||||
if (rename_file(path_tmp, path))
|
||||
throw std::runtime_error(
|
||||
|
@ -820,7 +817,8 @@ void GCode::do_export(Print* print, const char* path, GCodePreviewData* preview_
|
|||
|
||||
// free functions called by GCode::_do_export()
|
||||
namespace DoExport {
|
||||
static void init_time_estimators(const PrintConfig &config, GCodeTimeEstimator &normal_time_estimator, GCodeTimeEstimator &silent_time_estimator, bool &silent_time_estimator_enabled)
|
||||
#if !ENABLE_GCODE_VIEWER
|
||||
static void init_time_estimators(const PrintConfig &config, GCodeTimeEstimator &normal_time_estimator, GCodeTimeEstimator &silent_time_estimator, bool &silent_time_estimator_enabled)
|
||||
{
|
||||
// resets time estimators
|
||||
normal_time_estimator.reset();
|
||||
|
@ -892,10 +890,12 @@ namespace DoExport {
|
|||
normal_time_estimator.set_filament_unload_times(config.filament_unload_time.values);
|
||||
}
|
||||
}
|
||||
#endif // !ENABLE_GCODE_VIEWER
|
||||
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
static void init_gcode_processor(const PrintConfig& config, GCodeProcessor& processor, bool silent_time_estimator_enabled)
|
||||
static void init_gcode_processor(const PrintConfig& config, GCodeProcessor& processor, bool& silent_time_estimator_enabled)
|
||||
{
|
||||
silent_time_estimator_enabled = (config.gcode_flavor == gcfMarlin) && config.silent_mode;
|
||||
processor.reset();
|
||||
processor.apply_config(config);
|
||||
processor.enable_stealth_time_estimator(silent_time_estimator_enabled);
|
||||
|
@ -1049,10 +1049,12 @@ namespace DoExport {
|
|||
|
||||
// Fill in print_statistics and return formatted string containing filament statistics to be inserted into G-code comment section.
|
||||
static std::string update_print_stats_and_format_filament_stats(
|
||||
const GCodeTimeEstimator &normal_time_estimator,
|
||||
#if !ENABLE_GCODE_VIEWER
|
||||
const GCodeTimeEstimator &normal_time_estimator,
|
||||
const GCodeTimeEstimator &silent_time_estimator,
|
||||
const bool silent_time_estimator_enabled,
|
||||
const bool has_wipe_tower,
|
||||
#endif // !ENABLE_GCODE_VIEWER
|
||||
const bool has_wipe_tower,
|
||||
const WipeTowerData &wipe_tower_data,
|
||||
const std::vector<Extruder> &extruders,
|
||||
PrintStatistics &print_statistics)
|
||||
|
@ -1060,21 +1062,13 @@ namespace DoExport {
|
|||
std::string filament_stats_string_out;
|
||||
|
||||
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
|
||||
#if !ENABLE_GCODE_VIEWER
|
||||
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";
|
||||
print_statistics.estimated_normal_custom_gcode_print_times = normal_time_estimator.get_custom_gcode_times_dhm(true);
|
||||
if (silent_time_estimator_enabled)
|
||||
print_statistics.estimated_silent_custom_gcode_print_times = silent_time_estimator.get_custom_gcode_times_dhm(true);
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
#endif // !ENABLE_GCODE_VIEWER
|
||||
print_statistics.total_toolchanges = std::max(0, wipe_tower_data.number_of_toolchanges);
|
||||
if (! extruders.empty()) {
|
||||
std::pair<std::string, unsigned int> out_filament_used_mm ("; filament used [mm] = ", 0);
|
||||
|
@ -1165,12 +1159,13 @@ void GCode::_do_export(Print& print, FILE* file, ThumbnailsGeneratorCallback thu
|
|||
{
|
||||
PROFILE_FUNC();
|
||||
|
||||
DoExport::init_time_estimators(print.config(),
|
||||
// modifies the following:
|
||||
m_normal_time_estimator, m_silent_time_estimator, m_silent_time_estimator_enabled);
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
// modifies m_silent_time_estimator_enabled
|
||||
DoExport::init_gcode_processor(print.config(), m_processor, m_silent_time_estimator_enabled);
|
||||
#else
|
||||
DoExport::init_time_estimators(print.config(),
|
||||
// modifies the following:
|
||||
m_normal_time_estimator, m_silent_time_estimator, m_silent_time_estimator_enabled);
|
||||
DoExport::init_gcode_analyzer(print.config(), m_analyzer);
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
|
||||
|
@ -1274,12 +1269,13 @@ void GCode::_do_export(Print& print, FILE* file, ThumbnailsGeneratorCallback thu
|
|||
print.throw_if_canceled();
|
||||
|
||||
// adds tags for time estimators
|
||||
if (print.config().remaining_times.value)
|
||||
{
|
||||
#if !ENABLE_GCODE_VIEWER
|
||||
if (print.config().remaining_times.value) {
|
||||
_writeln(file, GCodeTimeEstimator::Normal_First_M73_Output_Placeholder_Tag);
|
||||
if (m_silent_time_estimator_enabled)
|
||||
_writeln(file, GCodeTimeEstimator::Silent_First_M73_Output_Placeholder_Tag);
|
||||
}
|
||||
#endif // !ENABLE_GCODE_VIEWER
|
||||
|
||||
// Prepare the helper object for replacing placeholders in custom G-code and output filename.
|
||||
m_placeholder_parser = print.placeholder_parser();
|
||||
|
@ -1574,25 +1570,31 @@ void GCode::_do_export(Print& print, FILE* file, ThumbnailsGeneratorCallback thu
|
|||
_write(file, m_writer.postamble());
|
||||
|
||||
// adds tags for time estimators
|
||||
#if !ENABLE_GCODE_VIEWER
|
||||
if (print.config().remaining_times.value)
|
||||
{
|
||||
_writeln(file, GCodeTimeEstimator::Normal_Last_M73_Output_Placeholder_Tag);
|
||||
if (m_silent_time_estimator_enabled)
|
||||
_writeln(file, GCodeTimeEstimator::Silent_Last_M73_Output_Placeholder_Tag);
|
||||
}
|
||||
#endif // !ENABLE_GCODE_VIEWER
|
||||
|
||||
print.throw_if_canceled();
|
||||
|
||||
// calculates estimated printing time
|
||||
#if !ENABLE_GCODE_VIEWER
|
||||
m_normal_time_estimator.calculate_time(false);
|
||||
if (m_silent_time_estimator_enabled)
|
||||
m_silent_time_estimator.calculate_time(false);
|
||||
#endif // !ENABLE_GCODE_VIEWER
|
||||
|
||||
// Get filament stats.
|
||||
_write(file, DoExport::update_print_stats_and_format_filament_stats(
|
||||
// Const inputs
|
||||
m_normal_time_estimator, m_silent_time_estimator, m_silent_time_estimator_enabled,
|
||||
has_wipe_tower, print.wipe_tower_data(),
|
||||
#if !ENABLE_GCODE_VIEWER
|
||||
m_normal_time_estimator, m_silent_time_estimator, m_silent_time_estimator_enabled,
|
||||
#endif // !ENABLE_GCODE_VIEWER
|
||||
has_wipe_tower, print.wipe_tower_data(),
|
||||
m_writer.extruders(),
|
||||
// Modifies
|
||||
print.m_print_statistics));
|
||||
|
@ -1601,9 +1603,11 @@ void GCode::_do_export(Print& print, FILE* file, ThumbnailsGeneratorCallback thu
|
|||
_write_format(file, "; total filament cost = %.1lf\n", print.m_print_statistics.total_cost);
|
||||
if (print.m_print_statistics.total_toolchanges > 0)
|
||||
_write_format(file, "; total toolchanges = %i\n", print.m_print_statistics.total_toolchanges);
|
||||
#if !ENABLE_GCODE_VIEWER
|
||||
_write_format(file, "; estimated printing time (normal mode) = %s\n", m_normal_time_estimator.get_time_dhms().c_str());
|
||||
if (m_silent_time_estimator_enabled)
|
||||
_write_format(file, "; estimated printing time (silent mode) = %s\n", m_silent_time_estimator.get_time_dhms().c_str());
|
||||
#endif // !ENABLE_GCODE_VIEWER
|
||||
|
||||
// Append full config.
|
||||
_write(file, "\n");
|
||||
|
@ -1879,9 +1883,9 @@ namespace ProcessLayer
|
|||
#else
|
||||
// add tag for analyzer
|
||||
gcode += "; " + GCodeAnalyzer::Color_Change_Tag + ",T" + std::to_string(m600_extruder_before_layer) + "\n";
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
// add tag for time estimator
|
||||
gcode += "; " + GCodeTimeEstimator::Color_Change_Tag + "\n";
|
||||
gcode += "; " + GCodeTimeEstimator::Color_Change_Tag + "\n";
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
|
||||
if (!single_extruder_printer && m600_extruder_before_layer >= 0 && first_extruder_id != (unsigned)m600_extruder_before_layer
|
||||
// && !MMU1
|
||||
|
@ -1910,10 +1914,12 @@ namespace ProcessLayer
|
|||
//! FIXME_in_fw show message during print pause
|
||||
if (!pause_print_msg.empty())
|
||||
gcode += "M117 " + pause_print_msg + "\n";
|
||||
// add tag for time estimator
|
||||
#if !ENABLE_GCODE_VIEWER
|
||||
// add tag for time estimator
|
||||
gcode += "; " + GCodeTimeEstimator::Pause_Print_Tag + "\n";
|
||||
gcode += config.pause_print_gcode;
|
||||
}
|
||||
#endif // !ENABLE_GCODE_VIEWER
|
||||
}
|
||||
else
|
||||
{
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
|
@ -2422,14 +2428,14 @@ void GCode::process_layer(
|
|||
#endif /* HAS_PRESSURE_EQUALIZER */
|
||||
|
||||
_write(file, gcode);
|
||||
BOOST_LOG_TRIVIAL(trace) << "Exported layer " << layer.id() << " print_z " << print_z <<
|
||||
#if !ENABLE_GCODE_VIEWER
|
||||
BOOST_LOG_TRIVIAL(trace) << "Exported layer " << layer.id() << " print_z " << print_z <<
|
||||
", time estimator memory: " <<
|
||||
format_memsize_MB(m_normal_time_estimator.memory_used() + (m_silent_time_estimator_enabled ? m_silent_time_estimator.memory_used() : 0)) <<
|
||||
#if !ENABLE_GCODE_VIEWER
|
||||
", analyzer memory: " <<
|
||||
format_memsize_MB(m_analyzer.memory_used()) <<
|
||||
#endif // !ENABLE_GCODE_VIEWER
|
||||
log_memory_info();
|
||||
#endif // !ENABLE_GCODE_VIEWER
|
||||
}
|
||||
|
||||
void GCode::apply_print_config(const PrintConfig &print_config)
|
||||
|
@ -3078,10 +3084,12 @@ void GCode::_write(FILE* file, const char *what)
|
|||
|
||||
// writes string to file
|
||||
fwrite(gcode, 1, ::strlen(gcode), file);
|
||||
#if !ENABLE_GCODE_VIEWER
|
||||
// updates time estimator and gcode lines vector
|
||||
m_normal_time_estimator.add_gcode_block(gcode);
|
||||
if (m_silent_time_estimator_enabled)
|
||||
m_silent_time_estimator.add_gcode_block(gcode);
|
||||
#endif // !ENABLE_GCODE_VIEWER
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
#include "GCode/GCodeProcessor.hpp"
|
||||
#else
|
||||
#include "GCode/Analyzer.hpp"
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
#include "GCodeTimeEstimator.hpp"
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
#include "EdgeGrid.hpp"
|
||||
#include "GCode/ThumbnailData.hpp"
|
||||
|
||||
|
@ -179,8 +179,10 @@ public:
|
|||
#endif // !ENABLE_GCODE_VIEWER
|
||||
m_brim_done(false),
|
||||
m_second_layer_things_done(false),
|
||||
#if !ENABLE_GCODE_VIEWER
|
||||
m_normal_time_estimator(GCodeTimeEstimator::Normal),
|
||||
m_silent_time_estimator(GCodeTimeEstimator::Silent),
|
||||
#endif // !ENABLE_GCODE_VIEWER
|
||||
m_silent_time_estimator_enabled(false),
|
||||
m_last_obj_copy(nullptr, Point(std::numeric_limits<coord_t>::max(), std::numeric_limits<coord_t>::max()))
|
||||
{}
|
||||
|
@ -405,9 +407,11 @@ private:
|
|||
// Index of a last object copy extruded.
|
||||
std::pair<const PrintObject*, Point> m_last_obj_copy;
|
||||
|
||||
#if !ENABLE_GCODE_VIEWER
|
||||
// Time estimators
|
||||
GCodeTimeEstimator m_normal_time_estimator;
|
||||
GCodeTimeEstimator m_silent_time_estimator;
|
||||
#endif // !ENABLE_GCODE_VIEWER
|
||||
bool m_silent_time_estimator_enabled;
|
||||
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include <boost/nowide/cstdio.hpp>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
|
||||
#if !ENABLE_GCODE_VIEWER
|
||||
|
||||
static const float MMMIN_TO_MMSEC = 1.0f / 60.0f;
|
||||
static const float MILLISEC_TO_SEC = 0.001f;
|
||||
static const float INCHES_TO_MM = 25.4f;
|
||||
|
@ -722,24 +724,6 @@ namespace Slic3r {
|
|||
return ret;
|
||||
}
|
||||
|
||||
#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;
|
||||
|
||||
float total_time = 0.0f;
|
||||
for (const auto& [type, time] : m_custom_gcode_times) {
|
||||
std::string duration = _get_time_dhm(time);
|
||||
std::string remaining = include_remaining ? _get_time_dhm(m_time - total_time) : "";
|
||||
ret.push_back({ type, { duration, remaining } });
|
||||
total_time += time;
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
std::vector<std::pair<CustomGCode::Type, std::string>> ret;
|
||||
|
@ -760,7 +744,6 @@ namespace Slic3r {
|
|||
|
||||
return ret;
|
||||
}
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
|
||||
// Return an estimate of the memory consumed by the time estimator.
|
||||
size_t GCodeTimeEstimator::memory_used() const
|
||||
|
@ -1690,3 +1673,5 @@ namespace Slic3r {
|
|||
}
|
||||
#endif // ENABLE_MOVE_STATS
|
||||
}
|
||||
|
||||
#endif // !ENABLE_GCODE_VIEWER
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
#include "GCodeReader.hpp"
|
||||
#include "CustomGCode.hpp"
|
||||
|
||||
#if !ENABLE_GCODE_VIEWER
|
||||
|
||||
#define ENABLE_MOVE_STATS 0
|
||||
|
||||
namespace Slic3r {
|
||||
|
@ -370,13 +372,7 @@ 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
|
||||
|
||||
// Return an estimate of the memory consumed by the time estimator.
|
||||
size_t memory_used() const;
|
||||
|
@ -487,4 +483,6 @@ namespace Slic3r {
|
|||
|
||||
} /* namespace Slic3r */
|
||||
|
||||
#endif // !ENABLE_GCODE_VIEWER
|
||||
|
||||
#endif /* slic3r_GCodeTimeEstimator_hpp_ */
|
||||
|
|
|
@ -2190,23 +2190,13 @@ std::string Print::output_filename(const std::string &filename_base) const
|
|||
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
|
||||
#if !ENABLE_GCODE_VIEWER
|
||||
std::string normal_print_time = short_time(this->estimated_normal_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("normal_print_time", new ConfigOptionString(normal_print_time));
|
||||
config.set_key_value("silent_print_time", new ConfigOptionString(silent_print_time));
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
#endif // !ENABLE_GCODE_VIEWER
|
||||
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("total_cost", new ConfigOptionFloat(this->total_cost));
|
||||
|
|
|
@ -303,19 +303,12 @@ private:
|
|||
struct PrintStatistics
|
||||
{
|
||||
PrintStatistics() { clear(); }
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
#if ENABLE_GCODE_VIEWER_USE_OLD_TIME_ESTIMATOR
|
||||
std::string estimated_normal_print_time_str;
|
||||
std::string estimated_silent_print_time_str;
|
||||
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
|
||||
#else
|
||||
#if !ENABLE_GCODE_VIEWER
|
||||
std::string estimated_normal_print_time;
|
||||
std::string estimated_silent_print_time;
|
||||
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;
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
#endif // !ENABLE_GCODE_VIEWER
|
||||
double total_used_filament;
|
||||
double total_extruded_volume;
|
||||
double total_cost;
|
||||
|
@ -333,19 +326,12 @@ struct PrintStatistics
|
|||
std::string finalize_output_path(const std::string &path_in) const;
|
||||
|
||||
void clear() {
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
#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
|
||||
#if !ENABLE_GCODE_VIEWER
|
||||
estimated_normal_print_time.clear();
|
||||
estimated_silent_print_time.clear();
|
||||
estimated_normal_custom_gcode_print_times.clear();
|
||||
estimated_silent_custom_gcode_print_times.clear();
|
||||
#endif //ENABLE_GCODE_VIEWER
|
||||
#endif // !ENABLE_GCODE_VIEWER
|
||||
total_used_filament = 0.;
|
||||
total_extruded_volume = 0.;
|
||||
total_cost = 0.;
|
||||
|
|
|
@ -58,7 +58,11 @@
|
|||
#define ENABLE_GCODE_VIEWER (1 && ENABLE_2_3_0_ALPHA1)
|
||||
#define ENABLE_GCODE_VIEWER_STATISTICS (0 && ENABLE_GCODE_VIEWER)
|
||||
#define ENABLE_GCODE_VIEWER_SHADERS_EDITOR (0 && ENABLE_GCODE_VIEWER)
|
||||
#define ENABLE_GCODE_VIEWER_USE_OLD_TIME_ESTIMATOR (1 && ENABLE_GCODE_VIEWER)
|
||||
#define ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG (1 && ENABLE_GCODE_VIEWER)
|
||||
|
||||
#define TIME_ESTIMATE_NONE 0
|
||||
#define TIME_ESTIMATE_DEFAULT 1
|
||||
#define TIME_ESTIMATE_MODAL 2
|
||||
#define TIME_ESTIMATE_LEGEND 3
|
||||
#define GCODE_VIEWER_TIME_ESTIMATE TIME_ESTIMATE_MODAL
|
||||
|
||||
#endif // _prusaslicer_technologies_h_
|
||||
|
|
|
@ -332,7 +332,9 @@ void GCodeViewer::load(const GCodeProcessor::Result& gcode_result, const Print&
|
|||
wxGetApp().plater()->set_bed_shape(bed_shape, "", "", true);
|
||||
}
|
||||
|
||||
#if GCODE_VIEWER_TIME_ESTIMATE != TIME_ESTIMATE_NONE
|
||||
m_time_statistics = gcode_result.time_statistics;
|
||||
#endif // GCODE_VIEWER_TIME_ESTIMATE
|
||||
}
|
||||
|
||||
void GCodeViewer::refresh(const GCodeProcessor::Result& gcode_result, const std::vector<std::string>& str_tool_colors)
|
||||
|
@ -406,7 +408,9 @@ void GCodeViewer::reset()
|
|||
m_layers_zs = std::vector<double>();
|
||||
m_layers_z_range = { 0.0, 0.0 };
|
||||
m_roles = std::vector<ExtrusionRole>();
|
||||
#if GCODE_VIEWER_TIME_ESTIMATE != TIME_ESTIMATE_NONE
|
||||
m_time_statistics.reset();
|
||||
#endif // GCODE_VIEWER_TIME_ESTIMATE
|
||||
|
||||
#if ENABLE_GCODE_VIEWER_STATISTICS
|
||||
m_statistics.reset_all();
|
||||
|
@ -419,7 +423,7 @@ void GCodeViewer::render() const
|
|||
m_statistics.reset_opengl();
|
||||
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
||||
|
||||
#if ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
#if GCODE_VIEWER_TIME_ESTIMATE == TIME_ESTIMATE_MODAL
|
||||
if (m_roles.empty()) {
|
||||
m_time_estimate_frames_count = 0;
|
||||
return;
|
||||
|
@ -427,7 +431,7 @@ void GCodeViewer::render() const
|
|||
#else
|
||||
if (m_roles.empty())
|
||||
return;
|
||||
#endif // ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
#endif // GCODE_VIEWER_TIME_ESTIMATE
|
||||
|
||||
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||
render_toolpaths();
|
||||
|
@ -435,7 +439,9 @@ void GCodeViewer::render() const
|
|||
m_sequential_view.marker.render();
|
||||
render_shells();
|
||||
render_legend();
|
||||
#if GCODE_VIEWER_TIME_ESTIMATE != TIME_ESTIMATE_NONE
|
||||
render_time_estimate();
|
||||
#endif // GCODE_VIEWER_TIME_ESTIMATE
|
||||
#if ENABLE_GCODE_VIEWER_STATISTICS
|
||||
render_statistics();
|
||||
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
||||
|
@ -474,9 +480,9 @@ unsigned int GCodeViewer::get_options_visibility_flags() const
|
|||
flags = set_flag(flags, static_cast<unsigned int>(Preview::OptionType::Shells), m_shells.visible);
|
||||
flags = set_flag(flags, static_cast<unsigned int>(Preview::OptionType::ToolMarker), m_sequential_view.marker.is_visible());
|
||||
flags = set_flag(flags, static_cast<unsigned int>(Preview::OptionType::Legend), is_legend_enabled());
|
||||
#if !ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
#if GCODE_VIEWER_TIME_ESTIMATE == TIME_ESTIMATE_DEFAULT
|
||||
flags = set_flag(flags, static_cast<unsigned int>(Preview::OptionType::TimeEstimate), is_time_estimate_enabled());
|
||||
#endif // !ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
#endif // GCODE_VIEWER_TIME_ESTIMATE
|
||||
return flags;
|
||||
}
|
||||
|
||||
|
@ -496,9 +502,9 @@ void GCodeViewer::set_options_visibility_from_flags(unsigned int flags)
|
|||
m_shells.visible = is_flag_set(static_cast<unsigned int>(Preview::OptionType::Shells));
|
||||
m_sequential_view.marker.set_visible(is_flag_set(static_cast<unsigned int>(Preview::OptionType::ToolMarker)));
|
||||
enable_legend(is_flag_set(static_cast<unsigned int>(Preview::OptionType::Legend)));
|
||||
#if !ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
#if GCODE_VIEWER_TIME_ESTIMATE == TIME_ESTIMATE_DEFAULT
|
||||
enable_time_estimate(is_flag_set(static_cast<unsigned int>(Preview::OptionType::TimeEstimate)));
|
||||
#endif // !ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
#endif // GCODE_VIEWER_TIME_ESTIMATE
|
||||
}
|
||||
|
||||
void GCodeViewer::set_layers_z_range(const std::array<double, 2>& layers_z_range)
|
||||
|
@ -510,6 +516,7 @@ void GCodeViewer::set_layers_z_range(const std::array<double, 2>& layers_z_range
|
|||
wxGetApp().plater()->update_preview_moves_slider();
|
||||
}
|
||||
|
||||
#if GCODE_VIEWER_TIME_ESTIMATE != TIME_ESTIMATE_NONE
|
||||
void GCodeViewer::enable_time_estimate(bool enable)
|
||||
{
|
||||
m_time_estimate_enabled = enable;
|
||||
|
@ -517,6 +524,7 @@ void GCodeViewer::enable_time_estimate(bool enable)
|
|||
wxGetApp().plater()->get_current_canvas3D()->set_as_dirty();
|
||||
wxGetApp().plater()->get_current_canvas3D()->request_extra_frame();
|
||||
}
|
||||
#endif // GCODE_VIEWER_TIME_ESTIMATE
|
||||
|
||||
void GCodeViewer::export_toolpaths_to_obj(const char* filename) const
|
||||
{
|
||||
|
@ -1682,24 +1690,25 @@ void GCodeViewer::render_legend() const
|
|||
ImGui::PopStyleVar();
|
||||
}
|
||||
|
||||
#if GCODE_VIEWER_TIME_ESTIMATE != TIME_ESTIMATE_NONE
|
||||
void GCodeViewer::render_time_estimate() const
|
||||
{
|
||||
if (!m_time_estimate_enabled) {
|
||||
#if ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
#if GCODE_VIEWER_TIME_ESTIMATE == TIME_ESTIMATE_MODAL
|
||||
m_time_estimate_frames_count = 0;
|
||||
#endif // ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
#endif // GCODE_VIEWER_TIME_ESTIMATE
|
||||
return;
|
||||
}
|
||||
|
||||
ImGuiWrapper& imgui = *wxGetApp().imgui();
|
||||
|
||||
#if ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
#if GCODE_VIEWER_TIME_ESTIMATE == TIME_ESTIMATE_MODAL
|
||||
// esc
|
||||
if (ImGui::GetIO().KeysDown[27]) {
|
||||
m_time_estimate_enabled = false;
|
||||
return;
|
||||
}
|
||||
#endif // ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
#endif // GCODE_VIEWER_TIME_ESTIMATE
|
||||
|
||||
using Times = std::pair<float, float>;
|
||||
using TimesList = std::vector<std::pair<CustomGCode::Type, Times>>;
|
||||
|
@ -1833,7 +1842,7 @@ void GCodeViewer::render_time_estimate() const
|
|||
imgui.text(short_time(get_time_dhms(time)));
|
||||
ImGui::SameLine(offsets[1]);
|
||||
char buf[64];
|
||||
::sprintf(buf, "%.2f%%", 100.0f * percentage);
|
||||
::sprintf(buf, "%.1f%%", 100.0f * percentage);
|
||||
ImGuiWindow* window = ImGui::GetCurrentWindow();
|
||||
ImRect frame_bb;
|
||||
frame_bb.Min = { ImGui::GetCursorScreenPos().x, window->DC.CursorPos.y };
|
||||
|
@ -1978,7 +1987,7 @@ void GCodeViewer::render_time_estimate() const
|
|||
};
|
||||
|
||||
Size cnv_size = wxGetApp().plater()->get_current_canvas3D()->get_canvas_size();
|
||||
#if ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
#if GCODE_VIEWER_TIME_ESTIMATE == TIME_ESTIMATE_MODAL
|
||||
std::string title = _u8L("Estimated printing time");
|
||||
ImGui::OpenPopup(title.c_str());
|
||||
|
||||
|
@ -1996,14 +2005,14 @@ void GCodeViewer::render_time_estimate() const
|
|||
}
|
||||
#else
|
||||
imgui.set_next_window_pos(static_cast<float>(cnv_size.get_width()), static_cast<float>(cnv_size.get_height()), ImGuiCond_Always, 1.0f, 1.0f);
|
||||
ImGui::SetNextWindowSizeConstraints({ 0.0f, 0.0f }, { -1.0f, 0.5f * static_cast<float>(cnv_size.get_height() }));
|
||||
ImGui::SetNextWindowSizeConstraints({ 0.0f, 0.0f }, { -1.0f, 0.5f * static_cast<float>(cnv_size.get_height()) });
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
||||
ImGui::SetNextWindowBgAlpha(0.6f);
|
||||
imgui.begin(std::string("Time_estimate"), ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove);
|
||||
|
||||
// title
|
||||
imgui.title(_u8L("Estimated printing time"));
|
||||
#endif // ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
#endif // GCODE_VIEWER_TIME_ESTIMATE
|
||||
|
||||
// mode tabs
|
||||
ImGui::BeginTabBar("mode_tabs");
|
||||
|
@ -2029,7 +2038,7 @@ void GCodeViewer::render_time_estimate() const
|
|||
}
|
||||
ImGui::EndTabBar();
|
||||
|
||||
#if ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
#if GCODE_VIEWER_TIME_ESTIMATE == TIME_ESTIMATE_MODAL
|
||||
// this is ugly, but it is the only way to ensure that the dialog is large
|
||||
// enough to show enterely the title
|
||||
// see: https://github.com/ocornut/imgui/issues/3239
|
||||
|
@ -2044,9 +2053,10 @@ void GCodeViewer::render_time_estimate() const
|
|||
}
|
||||
#else
|
||||
imgui.end();
|
||||
#endif // ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
#endif // GCODE_VIEWER_TIME_ESTIMATE
|
||||
ImGui::PopStyleVar();
|
||||
}
|
||||
#endif // GCODE_VIEWER_TIME_ESTIMATE
|
||||
|
||||
#if ENABLE_GCODE_VIEWER_STATISTICS
|
||||
void GCodeViewer::render_statistics() const
|
||||
|
|
|
@ -341,13 +341,15 @@ private:
|
|||
Shells m_shells;
|
||||
EViewType m_view_type{ EViewType::FeatureType };
|
||||
bool m_legend_enabled{ true };
|
||||
#if GCODE_VIEWER_TIME_ESTIMATE != TIME_ESTIMATE_NONE
|
||||
PrintEstimatedTimeStatistics m_time_statistics;
|
||||
#if ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
#if GCODE_VIEWER_TIME_ESTIMATE == TIME_ESTIMATE_MODAL
|
||||
mutable bool m_time_estimate_enabled{ false };
|
||||
mutable unsigned int m_time_estimate_frames_count{ 0 };
|
||||
#else
|
||||
bool m_time_estimate_enabled{ false };
|
||||
#endif // ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
#endif // GCODE_VIEWER_TIME_ESTIMATE == TIME_ESTIMATE_MODAL
|
||||
#endif // GCODE_VIEWER_TIME_ESTIMATE != TIME_ESTIMATE_NONE
|
||||
#if ENABLE_GCODE_VIEWER_STATISTICS
|
||||
mutable Statistics m_statistics;
|
||||
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
||||
|
@ -403,8 +405,10 @@ public:
|
|||
bool is_legend_enabled() const { return m_legend_enabled; }
|
||||
void enable_legend(bool enable) { m_legend_enabled = enable; }
|
||||
|
||||
#if GCODE_VIEWER_TIME_ESTIMATE != TIME_ESTIMATE_NONE
|
||||
bool is_time_estimate_enabled() const { return m_time_estimate_enabled; }
|
||||
void enable_time_estimate(bool enable);
|
||||
#endif // GCODE_VIEWER_TIME_ESTIMATE
|
||||
|
||||
void export_toolpaths_to_obj(const char* filename) const;
|
||||
|
||||
|
@ -416,7 +420,9 @@ private:
|
|||
void render_toolpaths() const;
|
||||
void render_shells() const;
|
||||
void render_legend() const;
|
||||
#if GCODE_VIEWER_TIME_ESTIMATE != TIME_ESTIMATE_NONE
|
||||
void render_time_estimate() const;
|
||||
#endif // GCODE_VIEWER_TIME_ESTIMATE
|
||||
#if ENABLE_GCODE_VIEWER_STATISTICS
|
||||
void render_statistics() const;
|
||||
#endif // ENABLE_GCODE_VIEWER_STATISTICS
|
||||
|
|
|
@ -3109,17 +3109,18 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
|
|||
break;
|
||||
}
|
||||
#endif // ENABLE_RENDER_PICKING_PASS
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
#if GCODE_VIEWER_TIME_ESTIMATE == TIME_ESTIMATE_DEFAULT || GCODE_VIEWER_TIME_ESTIMATE == TIME_ESTIMATE_MODAL
|
||||
case 'T':
|
||||
case 't': {
|
||||
case 't':
|
||||
{
|
||||
if (!m_main_toolbar.is_enabled()) {
|
||||
m_gcode_viewer.enable_time_estimate(!m_gcode_viewer.is_time_estimate_enabled());
|
||||
m_dirty = true;
|
||||
wxGetApp().plater()->update_preview_bottom_toolbar();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
}
|
||||
#endif // GCODE_VIEWER_TIME_ESTIMATE
|
||||
case 'Z':
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
case 'z':
|
||||
|
|
|
@ -558,7 +558,9 @@ public:
|
|||
void reset_gcode_toolpaths() { m_gcode_viewer.reset(); }
|
||||
const GCodeViewer::SequentialView& get_gcode_sequential_view() const { return m_gcode_viewer.get_sequential_view(); }
|
||||
void update_gcode_sequential_view_current(unsigned int first, unsigned int last) { m_gcode_viewer.update_sequential_view_current(first, last); }
|
||||
#if GCODE_VIEWER_TIME_ESTIMATE != TIME_ESTIMATE_NONE
|
||||
bool is_time_estimate_enabled() const { return m_gcode_viewer.is_time_estimate_enabled(); }
|
||||
#endif // GCODE_VIEWER_TIME_ESTIMATE
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
|
||||
void toggle_sla_auxiliaries_visibility(bool visible, const ModelObject* mo = nullptr, int instance_idx = -1);
|
||||
|
|
|
@ -323,12 +323,12 @@ bool Preview::init(wxWindow* parent, Model* model)
|
|||
get_option_type_string(OptionType::CustomGCodes) + "|0|" +
|
||||
get_option_type_string(OptionType::Shells) + "|0|" +
|
||||
get_option_type_string(OptionType::ToolMarker) + "|0|" +
|
||||
#if ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
get_option_type_string(OptionType::Legend) + "|1"
|
||||
#else
|
||||
#if GCODE_VIEWER_TIME_ESTIMATE == TIME_ESTIMATE_DEFAULT
|
||||
get_option_type_string(OptionType::Legend) + "|1|" +
|
||||
get_option_type_string(OptionType::TimeEstimate) + "|1"
|
||||
#endif // ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
#else
|
||||
get_option_type_string(OptionType::Legend) + "|1"
|
||||
#endif // GCODE_VIEWER_TIME_ESTIMATE
|
||||
);
|
||||
Slic3r::GUI::create_combochecklist(m_combochecklist_options, GUI::into_u8(_L("Options")), options_items);
|
||||
#else
|
||||
|
@ -1459,7 +1459,9 @@ wxString Preview::get_option_type_string(OptionType type) const
|
|||
case OptionType::Shells: { return _L("Shells"); }
|
||||
case OptionType::ToolMarker: { return _L("Tool marker"); }
|
||||
case OptionType::Legend: { return _L("Legend"); }
|
||||
#if GCODE_VIEWER_TIME_ESTIMATE != TIME_ESTIMATE_NONE
|
||||
case OptionType::TimeEstimate: { return _L("Estimated printing time"); }
|
||||
#endif // GCODE_VIEWER_TIME_ESTIMATE != TIME_ESTIMATE_NONE
|
||||
default: { return ""; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -150,7 +150,9 @@ public:
|
|||
Shells,
|
||||
ToolMarker,
|
||||
Legend,
|
||||
#if GCODE_VIEWER_TIME_ESTIMATE != TIME_ESTIMATE_NONE
|
||||
TimeEstimate
|
||||
#endif // GCODE_VIEWER_TIME_ESTIMATE
|
||||
};
|
||||
|
||||
Preview(wxWindow* parent, Model* model, DynamicPrintConfig* config, BackgroundSlicingProcess* process,
|
||||
|
|
|
@ -204,13 +204,11 @@ void KBShortcutsDialog::fill_shortcuts()
|
|||
{ "U", L("Upper Layer") },
|
||||
{ "D", L("Lower Layer") },
|
||||
{ "L", L("Show/Hide Legend") },
|
||||
#if ENABLE_GCODE_VIEWER
|
||||
#if ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
{ "T", L("Show Estimated printing time") }
|
||||
#else
|
||||
#if GCODE_VIEWER_TIME_ESTIMATE == TIME_ESTIMATE_DEFAULT
|
||||
{ "T", L("Show/Hide Estimated printing time") }
|
||||
#endif // ENABLE_GCODE_VIEWER_MODAL_TIME_ESTIMATE_DIALOG
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
#elif GCODE_VIEWER_TIME_ESTIMATE == TIME_ESTIMATE_MODAL
|
||||
{ "T", L("Show Estimated printing time") }
|
||||
#endif // GCODE_VIEWER_TIME_ESTIMATE
|
||||
};
|
||||
|
||||
m_full_shortcuts.push_back(std::make_pair(_L("Preview"), preview_shortcuts));
|
||||
|
|
|
@ -1324,15 +1324,10 @@ 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"))
|
||||
// hide the estimate time
|
||||
p->sliced_info->SetTextAndShow(siEstimatedTime, "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")
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
p->sliced_info->SetTextAndShow(siEstimatedTime, "N/A");
|
||||
else {
|
||||
new_label = _L("Estimated printing time") + ":";
|
||||
|
@ -1340,15 +1335,7 @@ void Sidebar::update_sliced_info_sizer()
|
|||
wxString str_color = _L("Color");
|
||||
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
|
||||
wxString& new_label, wxString& info_text)
|
||||
{
|
||||
int color_change_count = 0;
|
||||
|
@ -1366,41 +1353,10 @@ void Sidebar::update_sliced_info_sizer()
|
|||
if (i != (int)times.size() - 1 && times[i].first == CustomGCode::PausePrint)
|
||||
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
|
||||
}
|
||||
};
|
||||
|
||||
#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);
|
||||
fill_labels(ps.estimated_normal_custom_gcode_print_times_str, new_label, info_text);
|
||||
}
|
||||
if (ps.estimated_silent_print_time_str != "N/A") {
|
||||
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"));
|
||||
info_text += format_wxstr("\n%1%", ps.estimated_normal_print_time);
|
||||
|
@ -1416,10 +1372,10 @@ 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);
|
||||
fill_labels(ps.estimated_silent_custom_gcode_print_times, new_label, info_text);
|
||||
#endif // ENABLE_GCODE_VIEWER
|
||||
}
|
||||
p->sliced_info->SetTextAndShow(siEstimatedTime, info_text, new_label);
|
||||
}
|
||||
#endif // !ENABLE_GCODE_VIEWER
|
||||
|
||||
// if there is a wipe tower, insert number of toolchanges info into the array:
|
||||
p->sliced_info->SetTextAndShow(siWTNumbetOfToolchanges, is_wipe_tower ? wxString::Format("%.d", ps.total_toolchanges) : "N/A");
|
||||
|
@ -1428,9 +1384,8 @@ 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