diff --git a/src/slic3r/GUI/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp index c25308fff..fc81fba1d 100644 --- a/src/slic3r/GUI/3DScene.cpp +++ b/src/slic3r/GUI/3DScene.cpp @@ -70,25 +70,6 @@ void glAssertRecentCallImpl(const char* file_name, unsigned int line, const char } #endif // HAS_GLSAFE -// BBS -std::vector> get_extruders_colors() -{ - unsigned char rgba_color[4] = {}; - std::vector colors = Slic3r::GUI::wxGetApp().plater()->get_extruder_colors_from_plater_config(); - std::vector> colors_out(colors.size()); - for (const std::string &color : colors) { - Slic3r::GUI::BitmapCache::parse_color4(color, rgba_color); - size_t color_idx = &color - &colors.front(); - colors_out[color_idx] = { - float(rgba_color[0]) / 255.f, - float(rgba_color[1]) / 255.f, - float(rgba_color[2]) / 255.f, - float(rgba_color[3]) / 255.f, - }; - } - - return colors_out; -} float FullyTransparentMaterialThreshold = 0.1f; float FullTransparentModdifiedToFixAlpha = 0.3f; const float BlackThreshold = 0.2f; @@ -838,7 +819,7 @@ void GLVolume::render(bool with_outline, const std::array& body_color) if (mv->mmu_segmentation_facets.empty()) break; - std::vector> colors = get_extruders_colors(); + std::vector> colors = GUI::wxGetApp().plater()->get_extruders_colors(); if (colors.size() == 1) { break; } @@ -866,7 +847,7 @@ void GLVolume::render(bool with_outline, const std::array& body_color) if (color_volume) { GLShaderProgram* shader = GUI::wxGetApp().get_current_shader(); - std::vector> colors = get_extruders_colors(); + std::vector> colors = GUI::wxGetApp().plater()->get_extruders_colors(); //when force_transparent, we need to keep the alpha if (force_native_color && (render_color[3] < 1.0)) { @@ -1448,7 +1429,7 @@ int GLVolumeCollection::load_wipe_tower_preview( if (height == 0.0f) height = 0.1f; - std::vector> extruder_colors = get_extruders_colors(); + std::vector> extruder_colors = GUI::wxGetApp().plater()->get_extruders_colors(); std::vector> colors; GUI::PartPlateList& ppl = GUI::wxGetApp().plater()->get_partplate_list(); std::vector plate_extruders = ppl.get_plate(plate_idx)->get_extruders(true); diff --git a/src/slic3r/GUI/3DScene.hpp b/src/slic3r/GUI/3DScene.hpp index 2aa36d4b7..6d8042b81 100644 --- a/src/slic3r/GUI/3DScene.hpp +++ b/src/slic3r/GUI/3DScene.hpp @@ -31,7 +31,6 @@ #define glsafe(cmd) cmd #define glcheck() #endif // HAS_GLSAFE -extern std::vector> get_extruders_colors(); extern float FullyTransparentMaterialThreshold; extern float FullTransparentModdifiedToFixAlpha; extern std::array adjust_color_for_rendering(const std::array &colors); diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 72042abca..aa676e565 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -2203,7 +2203,7 @@ void GLCanvas3D::render_thumbnail(ThumbnailData & thumbnail_data, bool ban_light) { GLShaderProgram* shader = wxGetApp().get_shader("thumbnail"); - std::vector> colors = ::get_extruders_colors(); + std::vector> colors = wxGetApp().plater()->get_extruders_colors(); const auto fb_type = Slic3r::GUI::OpenGLManager::get_framebuffers_type(); BOOST_LOG_TRIVIAL(info) << boost::format("framebuffer_type: %1%") % Slic3r::GUI::OpenGLManager::framebuffer_type_to_string(fb_type).c_str(); switch (fb_type) diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp b/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp index 8e70fa596..fc579ff84 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp @@ -62,21 +62,6 @@ bool GLGizmoMmuSegmentation::on_is_activable() const return !selection.is_empty() && (selection.is_single_full_instance() || selection.is_any_volume()); } -//BBS: use the global one in 3DScene.cpp -/*static std::vector> get_extruders_colors() -{ - unsigned char rgb_color[3] = {}; - std::vector colors = Slic3r::GUI::wxGetApp().plater()->get_extruder_colors_from_plater_config(); - std::vector> colors_out(colors.size()); - for (const std::string &color : colors) { - Slic3r::GUI::BitmapCache::parse_color(color, rgb_color); - size_t color_idx = &color - &colors.front(); - colors_out[color_idx] = {float(rgb_color[0]) / 255.f, float(rgb_color[1]) / 255.f, float(rgb_color[2]) / 255.f, 1.f}; - } - - return colors_out; -}*/ - static std::vector get_extruder_id_for_volumes(const ModelObject &model_object) { std::vector extruders_idx; @@ -93,7 +78,7 @@ static std::vector get_extruder_id_for_volumes(const ModelObject &model_obj void GLGizmoMmuSegmentation::init_extruders_data() { - m_extruders_colors = get_extruders_colors(); + m_extruders_colors = wxGetApp().plater()->get_extruders_colors(); size_t n_extruder_colors = std::min((size_t) EnforcerBlockerType::ExtruderMax, m_extruders_colors.size()); if (n_extruder_colors == 2 || m_selected_extruder_idx >= n_extruder_colors) { m_selected_extruder_idx = n_extruder_colors - 1; @@ -236,8 +221,7 @@ void GLGizmoMmuSegmentation::set_painter_gizmo_data(const Selection &selection) // Reinitialize triangle selectors because of change of extruder count need also change the size of GLIndexedVertexArray if (prev_extruders_count != wxGetApp().filaments_cnt()) this->init_model_triangle_selectors(); - } - else if (get_extruders_colors() != m_extruders_colors) { + } else if (wxGetApp().plater()->get_extruders_colors() != m_extruders_colors) { this->init_extruders_data(); this->update_triangle_selectors_colors(); } @@ -976,7 +960,7 @@ void GLGizmoMmuSegmentation::update_from_model_object(bool first_update) // Extruder colors need to be reloaded before calling init_model_triangle_selectors to render painted triangles // using colors from loaded 3MF and not from printer profile in Slicer. if (int prev_extruders_count = int(m_extruders_colors.size()); - prev_extruders_count != wxGetApp().filaments_cnt() || get_extruders_colors() != m_extruders_colors) + prev_extruders_count != wxGetApp().filaments_cnt() || wxGetApp().plater()->get_extruders_colors() != m_extruders_colors) this->init_extruders_data(); this->init_model_triangle_selectors(); diff --git a/src/slic3r/GUI/ObjColorDialog.cpp b/src/slic3r/GUI/ObjColorDialog.cpp index d92173d52..e8fa9fbe2 100644 --- a/src/slic3r/GUI/ObjColorDialog.cpp +++ b/src/slic3r/GUI/ObjColorDialog.cpp @@ -801,7 +801,7 @@ void ObjColorPanel::generate_thumbnail() if (m_deal_thumbnail_flag && m_obj_in_out.model->objects.size() == 1) { auto mo = m_obj_in_out.model->objects[0]; mo->add_instance(); - std::vector> colors = ::get_extruders_colors(); + std::vector> colors = GUI::wxGetApp().plater()->get_extruders_colors(); for (size_t i = 0; i < m_new_add_final_colors.size(); i++) { std::array temp_color; temp_color[0] = m_new_add_final_colors[i].Red() /255.f; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 3071d8ce4..58262bdde 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -14253,7 +14253,25 @@ void Plater::on_filaments_delete(size_t num_filaments, size_t filament_id, int r } } -void Plater::on_bed_type_change(BedType bed_type, bool is_gcode_file) { +std::vector> Plater::get_extruders_colors() +{ + unsigned char rgba_color[4] = {}; + std::vector colors = get_extruder_colors_from_plater_config(); + std::vector> colors_out(colors.size()); + for (const std::string &color : colors) { + Slic3r::GUI::BitmapCache::parse_color4(color, rgba_color); + size_t color_idx = &color - &colors.front(); + colors_out[color_idx] = { + float(rgba_color[0]) / 255.f, + float(rgba_color[1]) / 255.f, + float(rgba_color[2]) / 255.f, + float(rgba_color[3]) / 255.f, + }; + } + return colors_out; +} + + void Plater::on_bed_type_change(BedType bed_type, bool is_gcode_file) { sidebar().set_is_gcode_file(is_gcode_file); sidebar().on_bed_type_change(bed_type); } diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 6b68cb9e8..582c62990 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -444,6 +444,7 @@ public: void on_filaments_change(size_t extruders_count); void on_filaments_delete(size_t extruders_count, size_t filament_id, int replace_filament_id = -1); + std::vector> get_extruders_colors(); // BBS void on_bed_type_change(BedType bed_type,bool is_gcode_file = false);