diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp b/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp index 6e7e9a48d..13c27ef5a 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp @@ -711,6 +711,17 @@ void GLGizmoMmuSegmentation::on_render_input_window(float x, float y, float bott ImGui::PushItemWidth(1.5 * slider_icon_width); ImGui::BBLDragFloat("##gap_area_input", &TriangleSelectorPatch::gap_area, 0.05f, 0.0f, 0.0f, "%.2f"); } + ImGui::Separator(); + if (m_imgui->bbl_checkbox(_L("Vertical"), m_vertical_only)) { + if (m_vertical_only) { + m_horizontal_only = false; + } + } + if (m_imgui->bbl_checkbox(_L("Horizontal"), m_horizontal_only)) { + if (m_horizontal_only) { + m_vertical_only = false; + } + } ImGui::Separator(); ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(6.0f, 10.0f)); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp index 02a957d01..8f0dfa3a9 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp @@ -28,6 +28,8 @@ GLGizmoPainterBase::GLGizmoPainterBase(GLCanvas3D& parent, const std::string& ic // Make sphere and save it into a vertex buffer. m_vbo_sphere.load_its_flat_shading(its_make_sphere(1., (2*M_PI)/24.)); m_vbo_sphere.finalize_geometry(true); + m_vertical_only = false; + m_horizontal_only = false; } void GLGizmoPainterBase::set_painter_gizmo_data(const Selection& selection) @@ -652,6 +654,7 @@ std::vector GLGizmoPainterBase::get_pr // concludes that the event was not intended for it, it should return false. bool GLGizmoPainterBase::gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down, bool alt_down, bool control_down) { + Vec2d _mouse_position = mouse_position; if (action == SLAGizmoEventType::MouseWheelUp || action == SLAGizmoEventType::MouseWheelDown) { if (control_down) { @@ -773,7 +776,7 @@ bool GLGizmoPainterBase::gizmo_event(SLAGizmoEventType action, const Vec2d& mous // BBS if (m_tool_type == ToolType::BRUSH && m_cursor_type == TriangleSelector::CursorType::HEIGHT_RANGE) { - std::vector projected_height_range_by_mesh = get_projected_height_range(mouse_position, 1., part_volumes, trafo_matrices); + std::vector projected_height_range_by_mesh = get_projected_height_range(_mouse_position, 1., part_volumes, trafo_matrices); m_last_mouse_click = Vec2d::Zero(); for (int i = 0; i < projected_height_range_by_mesh.size(); i++) { @@ -800,13 +803,20 @@ bool GLGizmoPainterBase::gizmo_event(SLAGizmoEventType action, const Vec2d& mous m_triangle_splitting_enabled, m_paint_on_overhangs_only ? m_highlight_by_angle_threshold_deg : 0.f); m_triangle_selectors[mesh_idx]->request_update_render_data(true); - m_last_mouse_click = mouse_position; + m_last_mouse_click = _mouse_position; } return true; } - std::vector> projected_mouse_positions_by_mesh = get_projected_mouse_positions(mouse_position, 1., trafo_matrices); + if (action == SLAGizmoEventType::Dragging && m_tool_type == ToolType::BRUSH) { + if (m_vertical_only) + _mouse_position.x() = m_last_mouse_click.x(); + else if (m_horizontal_only) + _mouse_position.y() = m_last_mouse_click.y(); + } + + std::vector> projected_mouse_positions_by_mesh = get_projected_mouse_positions(_mouse_position, 1., trafo_matrices); m_last_mouse_click = Vec2d::Zero(); // only actual hits should be saved for (const std::vector &projected_mouse_positions : projected_mouse_positions_by_mesh) { @@ -874,7 +884,7 @@ bool GLGizmoPainterBase::gizmo_event(SLAGizmoEventType action, const Vec2d& mous m_triangle_selectors[mesh_idx]->request_update_render_data(true); - m_last_mouse_click = mouse_position; + m_last_mouse_click = _mouse_position; } return true; @@ -912,7 +922,7 @@ bool GLGizmoPainterBase::gizmo_event(SLAGizmoEventType action, const Vec2d& mous } // Now "click" into all the prepared points and spill paint around them. - update_raycast_cache(mouse_position, camera, trafo_matrices); + update_raycast_cache(_mouse_position, camera, trafo_matrices); auto seed_fill_unselect_all = [this]() { for (auto &triangle_selector : m_triangle_selectors) { diff --git a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.hpp b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.hpp index b4f14b490..ff1297b4e 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.hpp @@ -304,6 +304,10 @@ protected: static constexpr float SmartFillAngleMax = 90.f; static constexpr float SmartFillAngleStep = 1.f; + // BBL: paint behavior enchancement + bool m_vertical_only = false; + bool m_horizontal_only = false; + // It stores the value of the previous mesh_id to which the seed fill was applied. // It is used to detect when the mouse has moved from one volume to another one. int m_seed_fill_last_mesh_id = -1; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSeam.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSeam.cpp index 6729de614..e28066067 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSeam.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSeam.cpp @@ -313,7 +313,9 @@ void GLGizmoSeam::on_render_input_window(float x, float y, float bottom_limit) if (slider_clp_dist || b_clp_dist_input) { m_c->object_clipper()->set_position(clp_dist, true); } ImGui::Separator(); + m_imgui->bbl_checkbox(_L("Vertical"), m_vertical_only); + ImGui::Separator(); ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(6.0f, 10.0f)); float get_cur_y = ImGui::GetContentRegionMax().y + ImGui::GetFrameHeight() + y; show_tooltip_information(caption_max, x, get_cur_y);