diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 062746e79..a0a6a560d 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -1674,6 +1674,7 @@ sub print_info_box_show { $sizer->Show(1, $show); $self->Layout; + Wx::GetTopLevelParent($self)->Refresh; # temporary workaround for DoubleSlider on right panel $panel->Refresh; } diff --git a/xs/src/slic3r/GUI/wxExtensions.cpp b/xs/src/slic3r/GUI/wxExtensions.cpp index 10ba4efb5..43628cb47 100644 --- a/xs/src/slic3r/GUI/wxExtensions.cpp +++ b/xs/src/slic3r/GUI/wxExtensions.cpp @@ -811,6 +811,13 @@ PrusaDoubleSlider::PrusaDoubleSlider( wxWindow *parent, segm_pens = { &DARK_ORANGE_PEN, &ORANGE_PEN, &LIGHT_ORANGE_PEN }; } +int PrusaDoubleSlider::GetActiveValue() const +{ + return m_selection == ssLower ? + m_lower_value : m_selection == ssHigher ? + m_higher_value : -1; +} + wxSize PrusaDoubleSlider::DoGetBestSize() const { const wxSize size = wxControl::DoGetBestSize(); @@ -834,6 +841,13 @@ void PrusaDoubleSlider::SetHigherValue(const int higher_val) Update(); } +void PrusaDoubleSlider::SetMaxValue(int max_value) +{ + m_max_value = max_value; + Refresh(); + Update(); +} + void PrusaDoubleSlider::draw_scroll_line(wxDC& dc, const int lower_pos, const int higher_pos) { int width; @@ -967,10 +981,12 @@ wxString PrusaDoubleSlider::get_label(const SelectedSlider& selection) const { const int value = selection == ssLower ? m_lower_value : m_higher_value; - if (m_label_koef == 1.0) + if (m_label_koef == 1.0 && m_values.empty()) return wxString::Format("%d", value); - const wxString str = wxNumberFormatter::ToString(m_label_koef*value, 2, wxNumberFormatter::Style_None); + const wxString str = m_values.empty() ? + wxNumberFormatter::ToString(m_label_koef*value, 2, wxNumberFormatter::Style_None) : + wxNumberFormatter::ToString(m_values[value], 2, wxNumberFormatter::Style_None); return wxString::Format("%s\n(%d)", str, value); } diff --git a/xs/src/slic3r/GUI/wxExtensions.hpp b/xs/src/slic3r/GUI/wxExtensions.hpp index ed029d800..1887db2b3 100644 --- a/xs/src/slic3r/GUI/wxExtensions.hpp +++ b/xs/src/slic3r/GUI/wxExtensions.hpp @@ -521,16 +521,23 @@ public: const wxValidator& val = wxDefaultValidator, const wxString& name = wxEmptyString); - int GetLowerValue() { + int GetLowerValue() const { return m_lower_value; } - int GetHigherValue() { + int GetHigherValue() const { return m_higher_value; } + int GetActiveValue() const; wxSize DoGetBestSize() const override; void SetLowerValue(int lower_val); void SetHigherValue(int higher_val); - void SetKoefForLabels(const double koef){ m_label_koef = koef;} + void SetMaxValue(int max_value); + void SetKoefForLabels(const double koef) { + m_label_koef = koef; + } + void SetSliderValues(const std::vector& values) { + m_values = values; + } void OnPaint(wxPaintEvent& ){ render();} void OnLeftDown(wxMouseEvent& event); @@ -545,8 +552,8 @@ public: protected: void render(); - void draw_action_icon(wxDC& dc, const wxPoint pt_beg, const wxPoint pt_end); void draw_focus_rect(); + void draw_action_icon(wxDC& dc, const wxPoint pt_beg, const wxPoint pt_end); void draw_scroll_line(wxDC& dc, const int lower_pos, const int higher_pos); void draw_thumb(wxDC& dc, const wxCoord& pos_coord, const SelectedSlider& selection); void draw_ticks(wxDC& dc); @@ -608,6 +615,7 @@ private: std::vector line_pens; std::vector segm_pens; std::set m_ticks; + std::vector m_values; }; // ******************************************************************************************