From f5d3866847b6a292709a0c6fba9d05b09fc4eaa4 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Mon, 22 Mar 2021 11:40:46 +0100 Subject: [PATCH] Follow-up https://github.com/prusa3d/PrusaSlicer/commit/995512f2807d1e026533c814f6fabf655a7610ab DoubleSlider improvements: Fixed a case when wipe tower is used to the end of print and there is one layer which is not marked in layers_times statistics --- src/slic3r/GUI/DoubleSlider.cpp | 9 ++++++++- src/slic3r/GUI/DoubleSlider.hpp | 2 +- src/slic3r/GUI/GUI_Preview.cpp | 6 ++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/slic3r/GUI/DoubleSlider.cpp b/src/slic3r/GUI/DoubleSlider.cpp index de7a944f2..26a4f75a1 100644 --- a/src/slic3r/GUI/DoubleSlider.cpp +++ b/src/slic3r/GUI/DoubleSlider.cpp @@ -387,7 +387,7 @@ void Control::SetTicksValues(const Info& custom_gcode_per_print_z) Update(); } -void Control::SetLayersTimes(const std::vector& layers_times) +void Control::SetLayersTimes(const std::vector& layers_times, float total_time) { m_layers_times.clear(); if (layers_times.empty()) @@ -405,11 +405,18 @@ void Control::SetLayersTimes(const std::vector& layers_times) m_layers_values = m_values; sort(m_layers_values.begin(), m_layers_values.end()); m_layers_values.erase(unique(m_layers_values.begin(), m_layers_values.end()), m_layers_values.end()); + + // When whipe tower is used to the end of print, there is one layer which is not marked in layers_times + // So, add this value from the total print time value + if (m_layers_values.size() != m_layers_times.size()) + for (size_t i = m_layers_times.size(); i < m_layers_values.size(); i++) + m_layers_times.push_back(total_time); } } void Control::SetLayersTimes(const std::vector& layers_times) { + m_is_smart_wipe_tower = false; m_layers_times = layers_times; for (size_t i = 1; i < m_layers_times.size(); i++) m_layers_times[i] += m_layers_times[i - 1]; diff --git a/src/slic3r/GUI/DoubleSlider.hpp b/src/slic3r/GUI/DoubleSlider.hpp index de50bb0a2..24199b7ff 100644 --- a/src/slic3r/GUI/DoubleSlider.hpp +++ b/src/slic3r/GUI/DoubleSlider.hpp @@ -223,7 +223,7 @@ public: Info GetTicksValues() const; void SetTicksValues(const Info &custom_gcode_per_print_z); - void SetLayersTimes(const std::vector& layers_times); + void SetLayersTimes(const std::vector& layers_times, float total_time); void SetLayersTimes(const std::vector& layers_times); void SetDrawMode(bool is_sla_print, bool is_sequential_print); diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index 0042c0702..5e2f8e8ed 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -639,8 +639,10 @@ void Preview::update_layers_slider(const std::vector& layers_z, bool kee m_layers_slider->SetDrawMode(sla_print_technology, sequential_print); if (sla_print_technology) m_layers_slider->SetLayersTimes(plater->sla_print().print_statistics().layers_times); - else - m_layers_slider->SetLayersTimes(m_gcode_result->time_statistics.modes.front().layers_times); + else { + auto print_mode_stat = m_gcode_result->time_statistics.modes.front(); + m_layers_slider->SetLayersTimes(print_mode_stat.layers_times, print_mode_stat.time); + } // Suggest the auto color change, if model looks like sign if (m_layers_slider->IsNewPrint())