diff --git a/src/slic3r/GUI/3DScene.cpp b/src/slic3r/GUI/3DScene.cpp index cb2b6dad58..e71de5853f 100644 --- a/src/slic3r/GUI/3DScene.cpp +++ b/src/slic3r/GUI/3DScene.cpp @@ -63,25 +63,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; // Be careful changing this value because it could break thumbnail color due to rounding error! @@ -422,7 +403,7 @@ void GLVolume::render() return; ModelObjectPtrs &model_objects = GUI::wxGetApp().model().objects; - std::vector colors = get_extruders_colors(); + std::vector colors = GUI::wxGetApp().plater()->get_extruders_colors(); simple_render(shader, model_objects, colors); } @@ -438,7 +419,7 @@ void GLVolume::render_with_outline(const GUI::Size& cnv_size) return; ModelObjectPtrs &model_objects = GUI::wxGetApp().model().objects; - std::vector colors = get_extruders_colors(); + std::vector colors = GUI::wxGetApp().plater()->get_extruders_colors(); const GUI::OpenGLManager::EFramebufferType framebuffers_type = GUI::OpenGLManager::get_framebuffers_type(); if (framebuffers_type == GUI::OpenGLManager::EFramebufferType::Unknown) { @@ -799,7 +780,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 1099437fab..f71f3d3c45 100644 --- a/src/slic3r/GUI/3DScene.hpp +++ b/src/slic3r/GUI/3DScene.hpp @@ -32,7 +32,6 @@ #define glsafe(cmd) cmd #define glcheck() #endif // HAS_GLSAFE -extern std::vector get_extruders_colors(); extern float FullyTransparentMaterialThreshold; extern float FullTransparentModdifiedToFixAlpha; extern Slic3r::ColorRGBA adjust_color_for_rendering(const Slic3r::ColorRGBA &colors); diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index b0479dd9a0..2b44205eba 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -2165,7 +2165,7 @@ void GLCanvas3D::render_thumbnail(ThumbnailData& thumbnail_data, unsigned int w, else shader = wxGetApp().get_shader("thumbnail"); ModelObjectPtrs& model_objects = GUI::wxGetApp().model().objects; - std::vector colors = ::get_extruders_colors(); + std::vector colors = wxGetApp().plater()->get_extruders_colors(); switch (OpenGLManager::get_framebuffers_type()) { case OpenGLManager::EFramebufferType::Arb: diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp b/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp index 4e216bd81c..5496e44f1d 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMmuSegmentation.cpp @@ -58,21 +58,6 @@ bool GLGizmoMmuSegmentation::on_is_activable() const return !selection.is_empty() && (selection.is_single_full_instance() || selection.is_any_volume()) && wxGetApp().filaments_cnt() > 1; } -//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; @@ -89,7 +74,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(); m_selected_extruder_idx = 0; // keep remap table consistent with current extruder count @@ -189,8 +174,7 @@ void GLGizmoMmuSegmentation::data_changed(bool is_serializing) // 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(); } @@ -827,7 +811,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/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 668d8ed5c0..5f95aff1fa 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -14249,6 +14249,24 @@ void Plater::on_filaments_delete(size_t num_filaments, size_t filament_id, int r } } +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) { sidebar().on_bed_type_change(bed_type); diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 18d3295918..337df26945 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -492,6 +492,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);