From c74a769c14d702dbb78d479e49be927028502037 Mon Sep 17 00:00:00 2001 From: "zhou.xu" Date: Wed, 16 Oct 2024 10:49:49 +0800 Subject: [PATCH] NEW:add "extruder_only_area" textures for double extruder machine jira:none Change-Id: Iaf4118fb00641537838dae7cc5fdaaf07ccc9851 (cherry picked from commit a8d6c9fe8976dbcb79c1f89efb7107073cb17856) --- resources/images/left_extruder_only_area.svg | 29 ++++++ .../images/left_extruder_only_area_ch.svg | 19 ++++ resources/images/right_extruder_only_area.svg | 30 ++++++ .../images/right_extruder_only_area_ch.svg | 19 ++++ src/libslic3r/PrintConfig.hpp | 7 ++ src/slic3r/GUI/PartPlate.cpp | 97 ++++++++++++++++++- src/slic3r/GUI/PartPlate.hpp | 4 + 7 files changed, 202 insertions(+), 3 deletions(-) create mode 100644 resources/images/left_extruder_only_area.svg create mode 100644 resources/images/left_extruder_only_area_ch.svg create mode 100644 resources/images/right_extruder_only_area.svg create mode 100644 resources/images/right_extruder_only_area_ch.svg diff --git a/resources/images/left_extruder_only_area.svg b/resources/images/left_extruder_only_area.svg new file mode 100644 index 000000000..00eae9589 --- /dev/null +++ b/resources/images/left_extruder_only_area.svg @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/images/left_extruder_only_area_ch.svg b/resources/images/left_extruder_only_area_ch.svg new file mode 100644 index 000000000..a5f2eb2c0 --- /dev/null +++ b/resources/images/left_extruder_only_area_ch.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/resources/images/right_extruder_only_area.svg b/resources/images/right_extruder_only_area.svg new file mode 100644 index 000000000..32d7a3645 --- /dev/null +++ b/resources/images/right_extruder_only_area.svg @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/images/right_extruder_only_area_ch.svg b/resources/images/right_extruder_only_area_ch.svg new file mode 100644 index 000000000..5d9a619db --- /dev/null +++ b/resources/images/right_extruder_only_area_ch.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 228154e22..cec3eed19 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -234,6 +234,13 @@ enum BedType { btCount }; +enum class ExtruderOnlyAreaType:unsigned char { + btNoArea= 0, + Engilish, + Chinese, + btAreaCount +}; + // BBS enum LayerSeq { flsAuto, diff --git a/src/slic3r/GUI/PartPlate.cpp b/src/slic3r/GUI/PartPlate.cpp index e0853cb9f..a05a34326 100644 --- a/src/slic3r/GUI/PartPlate.cpp +++ b/src/slic3r/GUI/PartPlate.cpp @@ -564,7 +564,7 @@ void PartPlate::render_logo(bool bottom, bool render_cali) m_partplate_list->load_bedtype_textures(); m_partplate_list->load_cali_textures(); - + m_partplate_list->load_extruder_only_area_textures(); // btDefault should be skipped auto curr_bed_type = get_bed_type(); if (curr_bed_type == btDefault) { @@ -573,6 +573,10 @@ void PartPlate::render_logo(bool bottom, bool render_cali) curr_bed_type = proj_cfg.opt_enum(std::string("curr_bed_type")); } int bed_type_idx = (int)curr_bed_type; + bool is_single_extruder = m_print->config().nozzle_diameter.size() == 1; + if (!is_single_extruder) { + bed_type_idx = 0; + } // render bed textures for (auto &part : m_partplate_list->bed_texture_info[bed_type_idx].parts) { if (part.texture) { @@ -606,6 +610,22 @@ void PartPlate::render_logo(bool bottom, bool render_cali) } } } + + //render extruder_only_area_info + bool is_zh = wxGetApp().app_config->get("language") == "zh_CN"; + int language_idx = (int) (is_zh ? ExtruderOnlyAreaType::Chinese:ExtruderOnlyAreaType::Engilish); + if (!is_single_extruder) { + for (auto &part : m_partplate_list->extruder_only_area_info[language_idx].parts) { + if (part.texture) { + if (part.buffer && part.buffer->is_initialized()) { + if (part.offset.x() != m_origin.x() || part.offset.y() != m_origin.y()) { + part.offset = Vec2d(m_origin.x(), m_origin.y()); + } + render_logo_texture(*(part.texture), *(part.buffer), bottom); + } + } + } + } } void PartPlate::render_height_limit(PartPlate::HeightLimitMode mode) @@ -3338,6 +3358,7 @@ void PartPlateList::release_icon_textures() } //reset PartPlateList::is_load_bedtype_textures = false; + PartPlateList::is_load_extruder_only_area_textures = false; PartPlateList::is_load_cali_texture = false; for (int i = 0; i < btCount; i++) { for (auto& part: bed_texture_info[i].parts) { @@ -3354,6 +3375,19 @@ void PartPlateList::release_icon_textures() } } } + for (int i = 0; i < (unsigned char)ExtruderOnlyAreaType::btAreaCount; i++) { + for (auto &part : extruder_only_area_info[i].parts) { + if (part.texture) { + part.texture->reset(); + delete part.texture; + } + if (part.vbo_id != 0) { + glsafe(::glDeleteBuffers(1, &part.vbo_id)); + part.vbo_id = 0; + } + if (part.buffer) { delete part.buffer; } + } + } } void PartPlateList::set_default_wipe_tower_pos_for_plate(int plate_idx) @@ -5011,7 +5045,7 @@ bool PartPlateList::set_shapes(const Pointfs& shape, const Pointfs& exclude_area pos = compute_shape_position(i, m_plate_cols); plate->set_shape(shape, exclude_areas, pos, height_to_lid, height_to_rod); } - is_load_bedtype_textures = false;//reload textures + is_load_bedtype_textures = false; //reload textures calc_bounding_boxes(); update_logo_texture_filename(texture_filename); @@ -5568,7 +5602,8 @@ void PartPlateList::print() const } bool PartPlateList::is_load_bedtype_textures = false; -bool PartPlateList::is_load_cali_texture = false; +bool PartPlateList::is_load_extruder_only_area_textures = false; +bool PartPlateList::is_load_cali_texture = false; void PartPlateList::BedTextureInfo::TexturePart::update_buffer() { @@ -5675,6 +5710,40 @@ void PartPlateList::init_bed_type_info() } } +void PartPlateList::init_extruder_only_area_info() +{ + BedTextureInfo::TexturePart left_part(2.5, 75.6, 10, 100, "left_extruder_only_area.svg"); + BedTextureInfo::TexturePart left_ch_part(2.5, 75.6, 10, 100, "left_extruder_only_area_ch.svg"); + BedTextureInfo::TexturePart right_part(243.5, 74.5, 10, 100, "right_extruder_only_area.svg"); + BedTextureInfo::TexturePart right_ch_part(243.5, 75.6, 10, 100, "right_extruder_only_area_ch.svg"); + + for (size_t i = 0; i < (unsigned char) ExtruderOnlyAreaType::btAreaCount; i++) { + extruder_only_area_info[i].reset(); + extruder_only_area_info[i].parts.clear(); + } + extruder_only_area_info[(unsigned char) ExtruderOnlyAreaType::Engilish].parts.push_back(left_part); + extruder_only_area_info[(unsigned char) ExtruderOnlyAreaType::Engilish].parts.push_back(right_part); + extruder_only_area_info[(unsigned char) ExtruderOnlyAreaType::Chinese].parts.push_back(left_ch_part); + extruder_only_area_info[(unsigned char) ExtruderOnlyAreaType::Chinese].parts.push_back(right_ch_part); + + auto bed_ext = get_extents(m_shape); + int bed_width = bed_ext.size()(0); + int bed_height = bed_ext.size()(1); + float base_width = 256; + float base_height = 256; + float x_rate = bed_width / base_width; + float y_rate = bed_height / base_height; + for (int i = 0; i < (unsigned char) ExtruderOnlyAreaType::btAreaCount; i++) { + for (int j = 0; j < extruder_only_area_info[i].parts.size(); j++) { + extruder_only_area_info[i].parts[j].x *= x_rate; + extruder_only_area_info[i].parts[j].y *= y_rate; + extruder_only_area_info[i].parts[j].w *= x_rate; + extruder_only_area_info[i].parts[j].h *= y_rate; + extruder_only_area_info[i].parts[j].update_buffer(); + } + } +} + void PartPlateList::load_bedtype_textures() { if (PartPlateList::is_load_bedtype_textures) return; @@ -5698,6 +5767,28 @@ void PartPlateList::load_bedtype_textures() PartPlateList::is_load_bedtype_textures = true; } +void PartPlateList::load_extruder_only_area_textures() { + if (PartPlateList::is_load_extruder_only_area_textures) return; + + init_extruder_only_area_info(); + GLint max_tex_size = OpenGLManager::get_gl_info().get_max_tex_size(); + GLint logo_tex_size = (max_tex_size < 2048) ? max_tex_size : 2048; + for (int i = 0; i < (unsigned int) ExtruderOnlyAreaType::btAreaCount; ++i) { + for (int j = 0; j < extruder_only_area_info[i].parts.size(); j++) { + std::string filename = resources_dir() + "/images/" + extruder_only_area_info[i].parts[j].filename; + if (boost::filesystem::exists(filename)) { + PartPlateList::extruder_only_area_info[i].parts[j].texture = new GLTexture(); + if (!PartPlateList::extruder_only_area_info[i].parts[j].texture->load_from_svg_file(filename, true, false, false, logo_tex_size)) { + BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": load logo texture from %1% failed!") % filename; + } + } else { + BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": load logo texture from %1% failed!") % filename; + } + } + } + PartPlateList::is_load_extruder_only_area_textures = true; +} + void PartPlateList::init_cali_texture_info() { BedTextureInfo::TexturePart cali_line(18, 2, 224, 16, "bbl_cali_lines.svg"); diff --git a/src/slic3r/GUI/PartPlate.hpp b/src/slic3r/GUI/PartPlate.hpp index 105fa7700..746e351bf 100644 --- a/src/slic3r/GUI/PartPlate.hpp +++ b/src/slic3r/GUI/PartPlate.hpp @@ -666,6 +666,7 @@ public: static GLTexture bed_textures[(unsigned int)btCount]; static bool is_load_bedtype_textures; static bool is_load_cali_texture; + static bool is_load_extruder_only_area_textures; PartPlateList(int width, int depth, int height, Plater* platerObj, Model* modelObj, PrinterTechnology tech = ptFFF); PartPlateList(Plater* platerObj, Model* modelObj, PrinterTechnology tech = ptFFF); @@ -892,7 +893,9 @@ public: } void init_bed_type_info(); + void init_extruder_only_area_info(); void load_bedtype_textures(); + void load_extruder_only_area_textures(); void show_cali_texture(bool show = true); void init_cali_texture_info(); @@ -900,6 +903,7 @@ public: BedTextureInfo bed_texture_info[btCount]; BedTextureInfo cali_texture_info; + BedTextureInfo extruder_only_area_info[(unsigned char) ExtruderOnlyAreaType::btAreaCount]; }; } // namespace GUI