diff --git a/src/libslic3r/GCode/GCodeProcessor.cpp b/src/libslic3r/GCode/GCodeProcessor.cpp index a7dc0c369..ca2111d91 100644 --- a/src/libslic3r/GCode/GCodeProcessor.cpp +++ b/src/libslic3r/GCode/GCodeProcessor.cpp @@ -1192,6 +1192,7 @@ void GCodeProcessor::reset() } m_extruded_last_z = 0.0f; + m_zero_layer_height = 0.0f; m_first_layer_height = 0.0f; m_processing_start_custom_gcode = false; m_g1_line_id = 0; @@ -3694,7 +3695,7 @@ void GCodeProcessor::store_move_vertex(EMoveType type, EMovePathType path_type) m_extruder_id, m_cp_color.current, //BBS: add plate's offset to the rendering vertices - Vec3f(m_end_position[X] + m_x_offset, m_end_position[Y] + m_y_offset, m_processing_start_custom_gcode ? m_first_layer_height : m_end_position[Z]) + m_extruder_offsets[m_extruder_id], + Vec3f(m_end_position[X] + m_x_offset, m_end_position[Y] + m_y_offset, m_processing_start_custom_gcode ? m_zero_layer_height : m_end_position[Z]) + m_extruder_offsets[m_extruder_id], static_cast(m_end_position[E] - m_start_position[E]), m_feedrate, m_width, diff --git a/src/libslic3r/GCode/GCodeProcessor.hpp b/src/libslic3r/GCode/GCodeProcessor.hpp index 52bcf66ca..686c86160 100644 --- a/src/libslic3r/GCode/GCodeProcessor.hpp +++ b/src/libslic3r/GCode/GCodeProcessor.hpp @@ -595,6 +595,7 @@ namespace Slic3r { ExtruderTemps m_extruder_temps; float m_extruded_last_z; float m_first_layer_height; // mm + float m_zero_layer_height; // mm bool m_processing_start_custom_gcode; unsigned int m_g1_line_id; unsigned int m_layer_id; diff --git a/src/slic3r/GUI/IMSlider.cpp b/src/slic3r/GUI/IMSlider.cpp index 7bda99eb8..b9aab59c1 100644 --- a/src/slic3r/GUI/IMSlider.cpp +++ b/src/slic3r/GUI/IMSlider.cpp @@ -824,12 +824,14 @@ void IMSlider::draw_colored_band(const ImRect& groove, const ImRect& slideable_r //cover round corner ImGui::RenderFrame(ImVec2(band_rc.Min.x, band_rc.Max.y - band_rc.GetWidth() * 0.5), band_rc.Max, clr, false); }; - //draw colored band - ImRect band_rect(main_band); + auto draw_main_band = [&main_band, this](const ImU32& clr) { + ImGui::RenderFrame(main_band.Min, main_band.Max, clr, false, main_band.GetWidth() * 0.5); + }; + //draw main colored band const int default_color_idx = m_mode == MultiAsSingle ? std::max(m_only_extruder - 1, 0) : 0; std::arrayrgba = decode_color_to_float_array(m_extruder_colors[default_color_idx]); ImU32 band_clr = IM_COL32(rgba[0] * 255.0f, rgba[1] * 255.0f, rgba[2] * 255.0f, rgba[3] * 255.0f); - ImGui::RenderFrame(band_rect.Min, band_rect.Max, band_clr, false, band_rect.GetWidth() * 0.5); + draw_main_band(band_clr); static float tick_pos; std::set::const_iterator tick_it = m_ticks.ticks.begin(); @@ -841,15 +843,17 @@ void IMSlider::draw_colored_band(const ImRect& groove, const ImRect& slideable_r if (tick_it->type == ToolChange) { if ((m_mode == SingleExtruder) || (m_mode == MultiAsSingle)) { - //TODO:band_rect width need to be ajusted - band_rect = ImRect(main_band.Min, ImVec2(main_band.Max.x, tick_pos)); + ImRect band_rect = ImRect(main_band.Min, ImVec2(main_band.Max.x, tick_pos)); const std::string clr_str = m_mode == SingleExtruder ? tick_it->color : get_color_for_tool_change_tick(tick_it); if (!clr_str.empty()) { std::arrayrgba = decode_color_to_float_array(clr_str); ImU32 band_clr = IM_COL32(rgba[0] * 255.0f, rgba[1] * 255.0f, rgba[2] * 255.0f, rgba[3] * 255.0f); - draw_band(band_clr, band_rect); + if (tick_it->tick == 0) + draw_main_band(band_clr); + else + draw_band(band_clr, band_rect); } } } @@ -1255,7 +1259,15 @@ void IMSlider::render_menu() ImGui::PushStyleVar(ImGuiStyleVar_::ImGuiStyleVar_ChildRounding, 4.0f * m_scale); if (ImGui::BeginPopup("slider_menu_popup")) { - if(menu_item_with_icon(_u8L("Add Pause").c_str(), "")) { add_code_as_tick(PausePrint); } + if ((m_selection == ssLower && GetLowerValueD() == m_zero_layer_height) || (m_selection == ssHigher && GetHigherValueD() == m_zero_layer_height)) + { + menu_item_with_icon(_u8L("Add Pause").c_str(), "", ImVec2(0, 0), 0, false, false); + }else + { + if (menu_item_with_icon(_u8L("Add Pause").c_str(), "")) { + add_code_as_tick(PausePrint); + } + } //BBS render this menu item only when extruder_num > 1 if (extruder_num > 1) { @@ -1348,12 +1360,23 @@ std::string IMSlider::get_label(int tick, LabelType label_type) } char layer_height[64]; - ::sprintf(layer_height, "%.2f", m_values.empty() ? m_label_koef * value : m_values[value]); + m_values[value] == m_zero_layer_height ? + ::sprintf(layer_height, "") : + ::sprintf(layer_height, "%.2f", m_values.empty() ? m_label_koef * value : m_values[value]); if (label_type == ltHeight) return std::string(layer_height); if (label_type == ltHeightWithLayer) { - size_t layer_number = m_is_wipe_tower ? get_layer_number(value, label_type) + 1 : (m_values.empty() ? value : value + 1); char buffer[64]; - ::sprintf(buffer, "%5s\n%5s", std::to_string(layer_number).c_str(), layer_height); + size_t layer_number; + if (m_values[GetMinValueD()] == m_zero_layer_height) { + layer_number = m_is_wipe_tower ? get_layer_number(value, label_type): (m_values.empty() ? value : value); + m_values[value] == m_zero_layer_height ? + ::sprintf(buffer, "%5s", std::to_string(layer_number).c_str()) : + ::sprintf(buffer, "%5s\n%5s", std::to_string(layer_number).c_str(), layer_height); + } + else { + layer_number = m_is_wipe_tower ? get_layer_number(value, label_type) + 1 : (m_values.empty() ? value : value + 1); + ::sprintf(buffer, "%5s\n%5s", std::to_string(layer_number).c_str(), layer_height); + } return std::string(buffer); } } diff --git a/src/slic3r/GUI/IMSlider.hpp b/src/slic3r/GUI/IMSlider.hpp index c30c7451c..0fffbb2a6 100644 --- a/src/slic3r/GUI/IMSlider.hpp +++ b/src/slic3r/GUI/IMSlider.hpp @@ -355,6 +355,7 @@ private: long m_extra_style; float m_label_koef{1.0}; + float m_zero_layer_height = 0.0f; std::vector m_values; TickCodeInfo m_ticks; std::vector m_layers_times;