Added DoubleSlider::epsilon() to get a permissible error for layer height
This commit is contained in:
parent
200ac4c35e
commit
aab3001b24
3 changed files with 9 additions and 6 deletions
|
@ -634,7 +634,7 @@ void Preview::update_double_slider(const std::vector<double>& layers_z, bool kee
|
|||
bool force_sliders_full_range = was_empty;
|
||||
if (!keep_z_range)
|
||||
{
|
||||
bool span_changed = layers_z.empty() || std::abs(layers_z.back() - m_slider->GetMaxValueD()) > 1e-6;
|
||||
bool span_changed = layers_z.empty() || std::abs(layers_z.back() - m_slider->GetMaxValueD()) > DoubleSlider::epsilon()/*1e-6*/;
|
||||
force_sliders_full_range |= span_changed;
|
||||
}
|
||||
bool snap_to_min = force_sliders_full_range || m_slider->is_lower_at_min();
|
||||
|
@ -650,12 +650,12 @@ void Preview::update_double_slider(const std::vector<double>& layers_z, bool kee
|
|||
int idx_high = m_slider->GetMaxValue();
|
||||
if (! layers_z.empty()) {
|
||||
if (! snap_to_min) {
|
||||
int idx_new = find_close_layer_idx(layers_z, z_low, 1e-6);
|
||||
int idx_new = find_close_layer_idx(layers_z, z_low, DoubleSlider::epsilon()/*1e-6*/);
|
||||
if (idx_new != -1)
|
||||
idx_low = idx_new;
|
||||
}
|
||||
if (! snap_to_max) {
|
||||
int idx_new = find_close_layer_idx(layers_z, z_high, 1e-6);
|
||||
int idx_new = find_close_layer_idx(layers_z, z_high, DoubleSlider::epsilon()/*1e-6*/);
|
||||
if (idx_new != -1)
|
||||
idx_high = idx_new;
|
||||
}
|
||||
|
@ -695,7 +695,7 @@ void Preview::fill_slider_values(std::vector<std::pair<int, double>> &values,
|
|||
{
|
||||
return (values.back().second < val &&
|
||||
// we can't ignore tick on last layer
|
||||
fabs(values.back().second - val) > EPSILON);
|
||||
fabs(values.back().second - val) > DoubleSlider::epsilon());
|
||||
}),
|
||||
ticks_from_config.end());
|
||||
if (ticks_from_config.size() != old_size)
|
||||
|
|
|
@ -2217,10 +2217,10 @@ void DoubleSlider::SetTicksValues(const std::vector<double>& heights)
|
|||
m_ticks.clear();
|
||||
unsigned int i = 0;
|
||||
for (auto h : heights) {
|
||||
while (i < m_values.size() && m_values[i].second - EPSILON/*1e-6*/ < h)
|
||||
while (i < m_values.size() && m_values[i].second - epsilon()/*1e-6*/ < h)
|
||||
++i;
|
||||
// don't miss last layer if it is
|
||||
if (i == m_values.size() && fabs(m_values[i-1].second - h) > EPSILON)
|
||||
if (i == m_values.size() && fabs(m_values[i-1].second - h) > epsilon())
|
||||
return;
|
||||
m_ticks.insert(i-1);
|
||||
}
|
||||
|
|
|
@ -720,6 +720,9 @@ public:
|
|||
const wxString& name = wxEmptyString);
|
||||
~DoubleSlider() {}
|
||||
|
||||
// permissible error for layer height
|
||||
static double epsilon() { return 0.0011;}
|
||||
|
||||
void msw_rescale();
|
||||
|
||||
int GetMinValue() const { return m_min_value; }
|
||||
|
|
Loading…
Reference in a new issue