From 660acede9e42b513bd3f61cf31085306fd10d4d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hejl?= Date: Mon, 31 May 2021 14:22:00 +0200 Subject: [PATCH] Sphere brush color in MMU painting gizmo is now the same as color used for painting. --- src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp | 14 +++++++++++++- src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.hpp | 5 ++++- src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp | 8 ++++---- src/slic3r/GUI/Gizmos/GLGizmoPainterBase.hpp | 3 +++ 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp b/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp index 46607a9d7..62ff7c66b 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp @@ -299,7 +299,7 @@ void GLGizmoMmuSegmentation::set_painter_gizmo_data(const Selection &selection) if (m_state != On) return; - int prev_extruders_count = m_original_extruders_colors.size(); + int prev_extruders_count = int(m_original_extruders_colors.size()); if (prev_extruders_count != wxGetApp().extruders_edited_cnt() || get_extruders_colors() != m_original_extruders_colors) { this->init_extruders_data(); // Reinitialize triangle selectors because of change of extruder count need also change the size of GLIndexedVertexArray @@ -594,6 +594,18 @@ PainterGizmoType GLGizmoMmuSegmentation::get_painter_type() const return PainterGizmoType::MMU_SEGMENTATION; } +std::array GLGizmoMmuSegmentation::get_cursor_sphere_left_button_color() const +{ + const std::array &color = m_modified_extruders_colors[m_first_selected_extruder_idx]; + return {float(color[0]) / 255.0f, float(color[1]) / 255.0f, float(color[2]) / 255.0f, 0.25f}; +} + +std::array GLGizmoMmuSegmentation::get_cursor_sphere_right_button_color() const +{ + const std::array &color = m_modified_extruders_colors[m_second_selected_extruder_idx]; + return {float(color[0]) / 255.0f, float(color[1]) / 255.0f, float(color[2]) / 255.0f, 0.25f}; +} + void TriangleSelectorMmuGui::render(ImGuiWrapper *imgui) { std::vector color_cnt(m_iva_colors.size()); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.hpp b/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.hpp index 35ade52fb..72e09100e 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.hpp @@ -31,9 +31,12 @@ public: bool gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down, bool alt_down, bool control_down) override; - virtual void set_painter_gizmo_data(const Selection& selection) override; + void set_painter_gizmo_data(const Selection& selection) override; protected: + std::array get_cursor_sphere_left_button_color() const override; + std::array get_cursor_sphere_right_button_color() const override; + void on_render_input_window(float x, float y, float bottom_limit) override; std::string on_get_name() const override; diff --git a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp index 584f8a53f..4ba9eaf05 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp @@ -251,12 +251,12 @@ void GLGizmoPainterBase::render_cursor_sphere(const Transform3d& trafo) const if (is_left_handed) glFrontFace(GL_CW); - float render_color[4] = { 0.f, 0.f, 0.f, 0.25f }; + std::array render_color = {0.f, 0.f, 0.f, 0.25f}; if (m_button_down == Button::Left) - render_color[2] = 1.f; + render_color = this->get_cursor_sphere_left_button_color(); else if (m_button_down == Button::Right) - render_color[0] = 1.f; - glsafe(::glColor4fv(render_color)); + render_color = this->get_cursor_sphere_right_button_color(); + glsafe(::glColor4fv(render_color.data())); m_vbo_sphere.render(); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.hpp b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.hpp index 55e4df865..eb8a7e053 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.hpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.hpp @@ -87,6 +87,9 @@ protected: void activate_internal_undo_redo_stack(bool activate); void set_cursor_type(TriangleSelector::CursorType); + virtual std::array get_cursor_sphere_left_button_color() const { return {0.f, 0.f, 1.f, 0.25f}; } + virtual std::array get_cursor_sphere_right_button_color() const { return {1.f, 0.f, 0.f, 0.25f}; } + float m_cursor_radius = 2.f; static constexpr float CursorRadiusMin = 0.4f; // cannot be zero static constexpr float CursorRadiusMax = 8.f;