Fix for f5d3866847
This commit is contained in:
parent
f5d3866847
commit
1c2d264570
1 changed files with 13 additions and 9 deletions
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -737,10 +741,10 @@ 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) :
|
||||
|
@ -748,7 +752,7 @@ wxString Control::get_label(int tick, LabelType label_type/* = ltHeightWithLayer
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue