diff --git a/src/libslic3r/Preset.hpp b/src/libslic3r/Preset.hpp index b9b181c36e..2c9da0b4dd 100644 --- a/src/libslic3r/Preset.hpp +++ b/src/libslic3r/Preset.hpp @@ -61,6 +61,10 @@ #define BBL_JSON_KEY_BED_MODEL "bed_model" #define BBL_JSON_KEY_BED_TEXTURE "bed_texture" #define BBL_JSON_KEY_IMAGE_BED_TYPE "image_bed_type" +#define BBL_JSON_KEY_BOTTOM_TEXTURE_END_NAME "bottom_texture_end_name" +#define BBL_JSON_KEY_BOTTOM_TEXTURE_RECT "bottom_texture_rect" +#define BBL_JSON_KEY_MIDDLE_TEXTURE_RECT "middle_texture_rect" + #define BBL_JSON_KEY_HOTEND_MODEL "hotend_model" #define BBL_JSON_KEY_DEFAULT_MATERIALS "default_materials" #define BBL_JSON_KEY_NOT_SUPPORT_BED_TYPE "not_support_bed_type" @@ -122,6 +126,9 @@ public: std::string bed_model; std::string bed_texture; std::string image_bed_type; + std::string bottom_texture_end_name; + std::string bottom_texture_rect; + std::string middle_texture_rect; std::string hotend_model; PrinterVariant* variant(const std::string &name) { for (auto &v : this->variants) diff --git a/src/libslic3r/PresetBundle.cpp b/src/libslic3r/PresetBundle.cpp index 499f43c1c2..bdefe9bacc 100644 --- a/src/libslic3r/PresetBundle.cpp +++ b/src/libslic3r/PresetBundle.cpp @@ -3370,7 +3370,14 @@ std::pair PresetBundle::load_vendor_configs_ else if (boost::iequals(it.key(), BBL_JSON_KEY_BED_MODEL)) { //get bed model model.bed_model = it.value(); - } else if (boost::iequals(it.key(), BBL_JSON_KEY_IMAGE_BED_TYPE)) { + } else if (boost::iequals(it.key(), BBL_JSON_KEY_BOTTOM_TEXTURE_END_NAME)) { + model.bottom_texture_end_name = it.value(); + } else if (boost::iequals(it.key(), BBL_JSON_KEY_BOTTOM_TEXTURE_RECT)) { + model.bottom_texture_rect = it.value(); + } else if (boost::iequals(it.key(), BBL_JSON_KEY_MIDDLE_TEXTURE_RECT)) { + model.middle_texture_rect = it.value(); + } + else if (boost::iequals(it.key(), BBL_JSON_KEY_IMAGE_BED_TYPE)) { model.image_bed_type = it.value(); } else if (boost::iequals(it.key(), BBL_JSON_KEY_BED_TEXTURE)) { diff --git a/src/slic3r/GUI/GLTexture.cpp b/src/slic3r/GUI/GLTexture.cpp index be0b402653..bb3693e32a 100644 --- a/src/slic3r/GUI/GLTexture.cpp +++ b/src/slic3r/GUI/GLTexture.cpp @@ -20,7 +20,7 @@ #include #include #include - +#include "FileHelp.hpp" #define STB_DXT_IMPLEMENTATION #include "stb_dxt/stb_dxt.h" @@ -153,12 +153,13 @@ bool GLTexture::load_from_file(const std::string& filename, bool use_mipmaps, EC bool GLTexture::load_from_svg_file(const std::string& filename, bool use_mipmaps, bool compress, bool apply_anisotropy, unsigned int max_size_px) { reset(); - - if (!boost::filesystem::exists(filename)) + auto svg_file = filename; + Utils::slash_to_back_slash(svg_file); + if (!boost::filesystem::exists(svg_file)) return false; - if (boost::algorithm::iends_with(filename, ".svg")) - return load_from_svg(filename, use_mipmaps, compress, apply_anisotropy, max_size_px); + if (boost::algorithm::iends_with(svg_file, ".svg")) + return load_from_svg(svg_file, use_mipmaps, compress, apply_anisotropy, max_size_px); else return false; } diff --git a/src/slic3r/GUI/PartPlate.cpp b/src/slic3r/GUI/PartPlate.cpp index 29f94f59a0..f652f4b7af 100644 --- a/src/slic3r/GUI/PartPlate.cpp +++ b/src/slic3r/GUI/PartPlate.cpp @@ -5933,14 +5933,54 @@ void PartPlateList::init_bed_type_info() BedTextureInfo::TexturePart pei_part2(74, -10, 148, 12, "bbl_bed_pei_bottom.svg"); BedTextureInfo::TexturePart pte_part1(10, 80, 10, 160, "bbl_bed_pte_left.svg"); BedTextureInfo::TexturePart pte_part2(74, -10, 148, 12, "bbl_bed_pte_bottom.svg"); + auto bed_texture_maps = wxGetApp().plater()->get_bed_texture_maps(); + std::string bottom_texture_end_name = bed_texture_maps.find("bottom_texture_end_name") != bed_texture_maps.end() ? bed_texture_maps["bottom_texture_end_name"] : ""; + std::string bottom_texture_rect_str = bed_texture_maps.find("bottom_texture_rect") != bed_texture_maps.end() ? bed_texture_maps["bottom_texture_rect"] : ""; + std::string middle_texture_rect_str = bed_texture_maps.find("middle_texture_rect") != bed_texture_maps.end() ? bed_texture_maps["middle_texture_rect"] : ""; + std::array bottom_texture_rect = {0, 0, 0, 0}, middle_texture_rect = {0, 0, 0, 0}; + if (bottom_texture_rect_str.size() > 0) { + std::vector items; + boost::algorithm::erase_all(bottom_texture_rect_str, " "); + boost::split(items, bottom_texture_rect_str, boost::is_any_of(",")); + if (items.size() == 4) { + for (int i = 0; i < items.size(); i++) { + bottom_texture_rect[i] = std::atof(items[i].c_str()); + } + } + } + if (middle_texture_rect_str.size() > 0) { + std::vector items; + boost::algorithm::erase_all(middle_texture_rect_str, " "); + boost::split(items, middle_texture_rect_str, boost::is_any_of(",")); + if (items.size() == 4) { + for (int i = 0; i < items.size(); i++) { + middle_texture_rect[i] = std::atof(items[i].c_str()); + } + } + } auto is_single_extruder = wxGetApp().preset_bundle->get_printer_extruder_count() == 1; if (!is_single_extruder) { m_allow_bed_type_in_double_nozzle.clear(); pte_part1 = BedTextureInfo::TexturePart(57, 300, 236.12f, 10.f, "bbl_bed_pte_middle.svg"); + auto &middle_rect = middle_texture_rect; + if (middle_rect[2] > 0.f) { + pte_part1 = BedTextureInfo::TexturePart(middle_rect[0], middle_rect[1], middle_rect[2], middle_rect[3], "bbl_bed_pte_middle.svg"); + } pte_part2 = BedTextureInfo::TexturePart(45, -14.5, 70, 8, "bbl_bed_pte_left_bottom.svg"); - + auto &bottom_rect = bottom_texture_rect; + if (bottom_texture_end_name.size() > 0 && bottom_rect[2] > 0.f) { + std::string pte_part2_name = "bbl_bed_pte_bottom_" + bottom_texture_end_name + ".svg"; + pte_part2 = BedTextureInfo::TexturePart(bottom_rect[0], bottom_rect[1], bottom_rect[2], bottom_rect[3], pte_part2_name); + } pei_part1 = BedTextureInfo::TexturePart(57, 300, 236.12f, 10.f, "bbl_bed_pei_middle.svg"); + if (middle_rect[2] > 0.f) { + pei_part1 = BedTextureInfo::TexturePart(middle_rect[0], middle_rect[1], middle_rect[2], middle_rect[3], "bbl_bed_pte_middle.svg"); + } pei_part2 = BedTextureInfo::TexturePart(45, -14.5, 70, 8, "bbl_bed_pei_left_bottom.svg"); + if (bottom_texture_end_name.size() > 0 && bottom_rect[2] > 0.f) { + std::string pei_part2_name = "bbl_bed_pei_bottom_" + bottom_texture_end_name + ".svg"; + pei_part2 = BedTextureInfo::TexturePart(bottom_rect[0], bottom_rect[1], bottom_rect[2], bottom_rect[3], pei_part2_name); + } m_allow_bed_type_in_double_nozzle[(int) btPEI] = true; m_allow_bed_type_in_double_nozzle[(int) btPTE] = true; } @@ -5968,8 +6008,8 @@ void PartPlateList::init_bed_type_info() float base_width = 256;//standard 256*256 for single_extruder float base_height = 256; if (!is_single_extruder) {//standard 350*325 for double_extruder - base_width = 350; - base_height = 320; + base_width = bed_width; + base_height = bed_height; } float x_rate = bed_width / base_width; float y_rate = bed_height / base_height; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 42731f3d41..8eb2ca0d0f 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -4916,6 +4916,25 @@ const VendorProfile::PrinterModel *Plater::get_curr_printer_model() return nullptr; } +std::map Plater::get_bed_texture_maps() +{ + auto pm = get_curr_printer_model(); + if (pm) { + std::map maps; + if (pm->bottom_texture_end_name.size() > 0) { + maps["bottom_texture_end_name"] = pm->bottom_texture_end_name; + } + if (pm->bottom_texture_rect.size() > 0) { + maps["bottom_texture_rect"] = pm->bottom_texture_rect; + } + if (pm->middle_texture_rect.size() > 0) { + maps["middle_texture_rect"] = pm->middle_texture_rect; + } + return maps; + } + return {}; +} + wxColour Plater::get_next_color_for_filament() { static int curr_color_filamenet = 0; diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 540ac6a879..5174929def 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -355,7 +355,8 @@ public: void invalid_all_plate_thumbnails(); void force_update_all_plate_thumbnails(); - const VendorProfile::PrinterModel *get_curr_printer_model(); + const VendorProfile::PrinterModel * get_curr_printer_model(); + std::map get_bed_texture_maps(); static wxColour get_next_color_for_filament(); static wxString get_slice_warning_string(GCodeProcessorResult::SliceWarning& warning);