FIX:add bottom texture

jira: STUDIO-11342
Change-Id: I69fd573b4d7b05135d5f280cf42d367421664cff
(cherry picked from commit 645f93fac732b8794aa1e99301bfe179a74915a7)
(cherry picked from commit 803a1dffde0f66c3076ae4fc80d4b821f34b03fc)
This commit is contained in:
zhou.xu 2025-04-09 16:34:34 +08:00 committed by Noisyfox
parent bb3f59e18f
commit 2ba649d7ef
6 changed files with 85 additions and 10 deletions

View file

@ -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)

View file

@ -3370,7 +3370,14 @@ std::pair<PresetsConfigSubstitutions, size_t> 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)) {

View file

@ -20,7 +20,7 @@
#include <vector>
#include <algorithm>
#include <thread>
#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;
}

View file

@ -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<float, 4> bottom_texture_rect = {0, 0, 0, 0}, middle_texture_rect = {0, 0, 0, 0};
if (bottom_texture_rect_str.size() > 0) {
std::vector<std::string> 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<std::string> 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;

View file

@ -4916,6 +4916,25 @@ const VendorProfile::PrinterModel *Plater::get_curr_printer_model()
return nullptr;
}
std::map<std::string, std::string> Plater::get_bed_texture_maps()
{
auto pm = get_curr_printer_model();
if (pm) {
std::map<std::string, std::string> 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;

View file

@ -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<std::string, std::string> get_bed_texture_maps();
static wxColour get_next_color_for_filament();
static wxString get_slice_warning_string(GCodeProcessorResult::SliceWarning& warning);