From a76bd40c628c38ae80a11d709f834b4044728a60 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 27 Feb 2019 13:37:16 +0100 Subject: [PATCH] Fixed a preview mode selection after updating of a PrusaDoubleSlider --- src/slic3r/GUI/GUI_Preview.cpp | 20 ++++++-------------- src/slic3r/GUI/wxExtensions.cpp | 7 ++++++- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index 0dec0976d..549dbd7e6 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -563,8 +563,12 @@ void Preview::create_double_slider() auto& config = wxGetApp().preset_bundle->project_config; ((config.option("colorprint_heights"))->values) = (m_slider->GetTicksValues()); m_schedule_background_process(); - bool color_print = !config.option("colorprint_heights")->values.empty(); - int type = m_choice_view_type->FindString(color_print ? _(L("Color Print")) : _(L("Feature type")) ); + + const wxString& choise = !config.option("colorprint_heights")->values.empty() ? _(L("Color Print")) : + config.option("wiping_volumes_matrix")->values.size() > 1 ? + _(L("Tool")) : _(L("Feature type")); + + int type = m_choice_view_type->FindString(choise); if (m_choice_view_type->GetSelection() != type) { m_choice_view_type->SetSelection(type); if ((0 <= type) && (type < (int)GCodePreviewData::Extrusion::Num_View_Types)) @@ -638,18 +642,6 @@ void Preview::update_double_slider(const std::vector& layers_z, bool for const auto& config = wxGetApp().preset_bundle->project_config; const std::vector &ticks_from_config = (config.option("colorprint_heights"))->values; - // Switch to the "Feature type" from the very beginning of a new object slicing after deleting of the old one - if (ticks_from_config.empty()) - { - const int& type = m_choice_view_type->FindString(_(L("Feature type"))); - if (m_choice_view_type->GetSelection() != type) { - m_choice_view_type->SetSelection(type); - if (0 <= type && type < int(GCodePreviewData::Extrusion::Num_View_Types)) - m_gcode_preview_data->extrusion.view_type = GCodePreviewData::Extrusion::EViewType(type); - m_preferred_color_mode = "feature"; - reload_print(); - } - } m_slider->SetTicksValues(ticks_from_config); bool color_print_enable = (wxGetApp().plater()->printer_technology() == ptFFF); diff --git a/src/slic3r/GUI/wxExtensions.cpp b/src/slic3r/GUI/wxExtensions.cpp index eb09e0ef3..e83101d22 100644 --- a/src/slic3r/GUI/wxExtensions.cpp +++ b/src/slic3r/GUI/wxExtensions.cpp @@ -1640,6 +1640,8 @@ void PrusaDoubleSlider::SetTicksValues(const std::vector& heights) if (m_values.empty()) return; + const bool was_empty = m_ticks.empty(); + m_ticks.clear(); unsigned int i = 0; for (auto h : heights) { @@ -1649,7 +1651,10 @@ void PrusaDoubleSlider::SetTicksValues(const std::vector& heights) return; m_ticks.insert(i-1); } - + + if (!was_empty && m_ticks.empty()) + // Switch to the "Feature type"/"Tool" from the very beginning of a new object slicing after deleting of the old one + wxPostEvent(this->GetParent(), wxCommandEvent(wxCUSTOMEVT_TICKSCHANGED)); } void PrusaDoubleSlider::get_lower_and_higher_position(int& lower_pos, int& higher_pos)