Skip to content

Commit

Permalink
Fix for f5d3866
Browse files Browse the repository at this point in the history
  • Loading branch information
YuSanka committed Mar 22, 2021
1 parent f5d3866 commit 1c2d264
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/slic3r/GUI/DoubleSlider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ void Control::draw_tick_on_mouse_position(wxDC& dc)
}
}

static std::string short_and_splitted_time(const std::string& time)
static wxString short_and_splitted_time(const std::string& time)
{
// Parse the dhms time format.
int days = 0;
Expand Down Expand Up @@ -697,7 +697,7 @@ static std::string short_and_splitted_time(const std::string& time)
}
else
::sprintf(buffer, "%ds", seconds);
return buffer;
return wxString::FromUTF8(buffer);
}

wxString Control::get_label(int tick, LabelType label_type/* = ltHeightWithLayer*/) const
Expand All @@ -719,9 +719,13 @@ wxString Control::get_label(int tick, LabelType label_type/* = ltHeightWithLayer
auto get_layer_number = [this](int value) {
double layer_print_z = m_values[is_wipe_tower_layer(value) ? std::max<int>(value - 1, 0) : value];
auto it = std::lower_bound(m_layers_values.begin(), m_layers_values.end(), layer_print_z - epsilon());
if (it == m_layers_values.end())
return -1;
return int(it - m_layers_values.begin());
if (it == m_layers_values.end()) {
it = std::lower_bound(m_values.begin(), m_values.end(), layer_print_z - epsilon());
if (it == m_values.end())
return size_t(-1);
return m_layers_values.size();
}
return size_t(it - m_layers_values.begin());
};

#if ENABLE_GCODE_LINES_ID_IN_H_SLIDER
Expand All @@ -737,18 +741,18 @@ wxString Control::get_label(int tick, LabelType label_type/* = ltHeightWithLayer
else {
if (label_type == ltEstimatedTime) {
if (m_is_smart_wipe_tower) {
int layer_number = get_layer_number(value);
return layer_number < 0 ? "" : short_and_splitted_time(get_time_dhms(m_layers_times[layer_number]));
size_t layer_number = get_layer_number(value);
return layer_number == size_t(-1) ? wxEmptyString : short_and_splitted_time(get_time_dhms(m_layers_times[layer_number]));
}
return value < m_layers_times.size() ? short_and_splitted_time(get_time_dhms(m_layers_times[value])) : "";
return value < m_layers_times.size() ? short_and_splitted_time(get_time_dhms(m_layers_times[value])) : wxEmptyString;
}
wxString str = m_values.empty() ?
wxString::Format("%.*f", 2, m_label_koef * value) :
wxString::Format("%.*f", 2, m_values[value]);
if (label_type == ltHeight)
return str;
if (label_type == ltHeightWithLayer) {
size_t layer_number = m_is_smart_wipe_tower ? (size_t)get_layer_number(value) : (m_values.empty() ? value : value + 1);
size_t layer_number = m_is_smart_wipe_tower ? get_layer_number(value) : (m_values.empty() ? value : value + 1);
return format_wxstr("%1%\n(%2%)", str, layer_number);
}
}
Expand Down

0 comments on commit 1c2d264

Please sign in to comment.