Ruler for DoubleSlider: Added estimated print time

This commit is contained in:
YuSanka 2020-11-16 22:48:13 +01:00 committed by Oleksandra Yushchenko
parent cb844a4034
commit feffb66085
5 changed files with 19 additions and 7 deletions

View file

@ -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);

View file

@ -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;

View file

@ -380,6 +380,13 @@ void Control::SetTicksValues(const Info& custom_gcode_per_print_z)
Update();
}
void Control::SetLayersTimes(const std::vector<float>& 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<unsigned int>(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]);

View file

@ -222,8 +222,9 @@ public:
void SetSliderValues(const std::vector<double>& 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<float>& layers_times);
void SetDrawMode(bool is_sla_print, bool is_sequential_print);
#if ENABLE_GCODE_VIEWER
@ -401,6 +402,7 @@ private:
std::vector<double> m_values;
TickCodeInfo m_ticks;
std::vector<float> m_layers_times;
std::vector<std::string> m_extruder_colors;

View file

@ -999,6 +999,7 @@ void Preview::update_layers_slider(const std::vector<double>& 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");