diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 1a4d58edc..f3fe802cc 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1685,8 +1685,11 @@ void GCode::process_layer( // colorprint_change = true; // } std::string custom_code = ""; + int m600_before_extruder = -1; while (!m_custom_g_code_heights.empty() && m_custom_g_code_heights.front().height-EPSILON < layer.print_z) { custom_code = m_custom_g_code_heights.front().gcode; + if (custom_code == "M600" && m_custom_g_code_heights.front().extruder > 0) + m600_before_extruder = m_custom_g_code_heights.front().extruder - 1; m_custom_g_code_heights.erase(m_custom_g_code_heights.begin()); colorprint_change = true; } @@ -1711,8 +1714,17 @@ void GCode::process_layer( // add tag for time estimator gcode += "; " + GCodeTimeEstimator::Color_Change_Tag + "\n"; if (single_material_print && custom_code == "tool_change") - custom_code = "M600"; - gcode += custom_code + "\n"; + custom_code = "M600"; + + if (!single_material_print && custom_code == "M600" && + m600_before_extruder >= 0 && first_extruder_id != m600_before_extruder + // && !MMU1 + ) { + gcode += "M601\n"; // pause print + gcode += "M117 Change filament for Extruder " + std::to_string(m600_before_extruder) + "\n"; + } + else + gcode += custom_code + "\n"; } } diff --git a/src/libslic3r/Model.hpp b/src/libslic3r/Model.hpp index aac6cde06..47f735508 100644 --- a/src/libslic3r/Model.hpp +++ b/src/libslic3r/Model.hpp @@ -768,7 +768,8 @@ public: double height; std::string gcode; - int extruder; + int extruder; // 0 - "gcode" will be applied for whole print + // else - "gcode" will be applied only for "extruder" print }; std::vector custom_gcode_per_height; diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index d4397c449..e50a4099b 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -622,9 +622,7 @@ void Preview::create_double_slider() m_extruder_selector->Bind(wxEVT_COMBOBOX, [this](wxCommandEvent& evt) { m_selected_extruder = m_extruder_selector->GetSelection(); - m_slider->SetManipulationState(m_selected_extruder == 0 ? - DoubleSlider::msMultiExtruderWholePrint : - DoubleSlider::msMultiExtruder); + m_slider->SetExtruderID(m_selected_extruder); int type = m_choice_view_type->FindString(_(L("Color Print"))); @@ -767,11 +765,10 @@ void Preview::update_double_slider(const std::vector& layers_z, bool kee m_slider->EnableTickManipulation(color_print_enable); if (color_print_enable && wxGetApp().extruders_edited_cnt() > 1) { //bool is_detected_full_print = //wxGetApp().plater()->fff_print().extruders().size() == 1; - m_slider->SetManipulationState(m_extruder_selector->GetSelection()==0 ? - DoubleSlider::msMultiExtruderWholePrint : DoubleSlider::msMultiExtruder); + m_slider->SetExtruderID(m_extruder_selector->GetSelection()); } else - m_slider->SetManipulationState(DoubleSlider::msSingleExtruder); + m_slider->SetExtruderID(-1); } // #ys_FIXME_COLOR diff --git a/src/slic3r/GUI/wxExtensions.cpp b/src/slic3r/GUI/wxExtensions.cpp index 10aecb5c5..217c4b672 100644 --- a/src/slic3r/GUI/wxExtensions.cpp +++ b/src/slic3r/GUI/wxExtensions.cpp @@ -3461,11 +3461,12 @@ void DoubleSlider::OnRightUp(wxMouseEvent& event) menu.AppendSubMenu(change_extruder_menu, name, _(L("Use another extruder"))); } } - else - append_menu_item(&menu, wxID_ANY, _(L("Add color change")) + " (M600)", "", + + append_menu_item(&menu, wxID_ANY, _(L("Add color change")) + " (M600)", "", [this](wxCommandEvent&) { add_code("M600"); }, "colorchange_add_off.png", &menu); - - append_menu_item(&menu, wxID_ANY, _(L("Add pause SD print")) + " (M601)", "", + + if (m_state != msMultiExtruder) + append_menu_item(&menu, wxID_ANY, _(L("Add pause print")) + " (M601)", "", [this](wxCommandEvent&) { add_code("M601"); }, "pause_add.png", &menu); append_menu_item(&menu, wxID_ANY, _(L("Add custom G-code")), "", @@ -3503,8 +3504,10 @@ void DoubleSlider::add_code(std::string code) } int extruder = 0; - if (m_state == msMultiExtruderWholePrint) + if (m_state == msMultiExtruderWholePrint && m_custom_gcode != "M600" ) extruder = get_extruder_for_tick(m_selection == ssLower ? m_lower_value : m_higher_value); + else if (m_state == msMultiExtruder && m_current_extruder > 0) + extruder = m_current_extruder; m_ticks_.insert(TICK_CODE(tick, code, extruder)); diff --git a/src/slic3r/GUI/wxExtensions.hpp b/src/slic3r/GUI/wxExtensions.hpp index 0fedaee09..a4ac16d4d 100644 --- a/src/slic3r/GUI/wxExtensions.hpp +++ b/src/slic3r/GUI/wxExtensions.hpp @@ -828,6 +828,11 @@ public: m_state = state; } ManipulationState GetManipulationState() const { return m_state; } + void SetExtruderID(int extruder) { + m_current_extruder = extruder; + m_state = extruder < 0 ? msSingleExtruder : + extruder > 0 ? msMultiExtruder : msMultiExtruderWholePrint; + } bool is_horizontal() const { return m_style == wxSL_HORIZONTAL; } bool is_one_layer() const { return m_is_one_layer; } @@ -919,6 +924,7 @@ private: bool m_show_context_menu = false; ManipulationState m_state = msSingleExtruder; wxString m_custom_gcode = wxEmptyString; + int m_current_extruder = -1; wxRect m_rect_lower_thumb; wxRect m_rect_higher_thumb;