From feffb66085e509db244b09ec196d19b5bfe0bba2 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Mon, 16 Nov 2020 22:48:13 +0100 Subject: [PATCH] Ruler for DoubleSlider: Added estimated print time --- src/libslic3r/GCode.cpp | 2 +- src/libslic3r/GCode/GCodeProcessor.cpp | 2 +- src/slic3r/GUI/DoubleSlider.cpp | 15 ++++++++++++--- src/slic3r/GUI/DoubleSlider.hpp | 6 ++++-- src/slic3r/GUI/GUI_Preview.cpp | 1 + 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 61ef9a1bd..e592466c7 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1858,7 +1858,7 @@ void GCode::process_layer( std::string gcode; // add tag for processor - gcode += "; " + GCodeProcessor::Layer_Change_Tag + "\n"; + gcode += ";" + GCodeProcessor::Layer_Change_Tag + "\n"; // export layer z char buf[64]; sprintf(buf, ";Z:%g\n", print_z); diff --git a/src/libslic3r/GCode/GCodeProcessor.cpp b/src/libslic3r/GCode/GCodeProcessor.cpp index 14bd38a33..4d3e16b47 100644 --- a/src/libslic3r/GCode/GCodeProcessor.cpp +++ b/src/libslic3r/GCode/GCodeProcessor.cpp @@ -393,7 +393,7 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename) auto is_temporary_decoration = [](const std::string& gcode_line) { // remove trailing '\n' std::string line = gcode_line.substr(0, gcode_line.length() - 1); - if (line == "; " + Layer_Change_Tag) + if (line == ";" + Layer_Change_Tag) return true; else return false; diff --git a/src/slic3r/GUI/DoubleSlider.cpp b/src/slic3r/GUI/DoubleSlider.cpp index 40463288e..3f988acf1 100644 --- a/src/slic3r/GUI/DoubleSlider.cpp +++ b/src/slic3r/GUI/DoubleSlider.cpp @@ -380,6 +380,13 @@ void Control::SetTicksValues(const Info& custom_gcode_per_print_z) Update(); } +void Control::SetLayersTimes(const std::vector& layers_times) +{ + m_layers_times = layers_times; + for (int i = 1; i < m_layers_times.size(); i++) + m_layers_times[i] += m_layers_times[i - 1]; +} + void Control::SetDrawMode(bool is_sla_print, bool is_sequential_print) { m_draw_mode = is_sla_print ? dmSlaPrint : @@ -603,9 +610,11 @@ wxString Control::get_label(int tick, LabelType label_type/* = ltHeightWithLayer if (m_draw_mode == dmSequentialGCodeView) return wxString::Format("%d", static_cast(m_values[value])); else { - if (label_type == ltEstimatedTime) - // ysFIXME get estimated time for the current tick - return "time"; + if (label_type == ltEstimatedTime) { + if (m_values.size() != m_layers_times.size()) + return "time"; + return Slic3r::short_time(get_time_dhms(m_layers_times[value])); + } wxString str = m_values.empty() ? wxString::Format("%.*f", 2, m_label_koef * value) : wxString::Format("%.*f", 2, m_values[value]); diff --git a/src/slic3r/GUI/DoubleSlider.hpp b/src/slic3r/GUI/DoubleSlider.hpp index f6e555934..509f6ce1e 100644 --- a/src/slic3r/GUI/DoubleSlider.hpp +++ b/src/slic3r/GUI/DoubleSlider.hpp @@ -222,8 +222,9 @@ public: void SetSliderValues(const std::vector& values); void ChangeOneLayerLock(); - Info GetTicksValues() const; - void SetTicksValues(const Info &custom_gcode_per_print_z); + Info GetTicksValues() const; + void SetTicksValues(const Info &custom_gcode_per_print_z); + void SetLayersTimes(const std::vector& layers_times); void SetDrawMode(bool is_sla_print, bool is_sequential_print); #if ENABLE_GCODE_VIEWER @@ -401,6 +402,7 @@ private: std::vector m_values; TickCodeInfo m_ticks; + std::vector m_layers_times; std::vector m_extruder_colors; diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index c108f6946..637231aae 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -999,6 +999,7 @@ void Preview::update_layers_slider(const std::vector& layers_z, bool kee } m_layers_slider->SetSelectionSpan(idx_low, idx_high); m_layers_slider->SetTicksValues(ticks_info_from_model); + m_layers_slider->SetLayersTimes(m_gcode_result->time_statistics.modes[0].layers_times); bool sla_print_technology = wxGetApp().plater()->printer_technology() == ptSLA; bool sequential_print = wxGetApp().preset_bundle->prints.get_edited_preset().config.opt_bool("complete_objects");