From 9ce7de10f4a5f1723439fbefea98595fcf678d69 Mon Sep 17 00:00:00 2001 From: "zhou.xu" Date: Wed, 22 Nov 2023 11:31:39 +0800 Subject: [PATCH] FIX:update custom_texture when new_shape=false Jira: STUDIO-5287 Change-Id: I3add95f9f9345c14a48cc7467513d1b3ce95f4c9 --- src/slic3r/GUI/PartPlate.cpp | 22 +++++++++++++--------- src/slic3r/GUI/PartPlate.hpp | 2 ++ src/slic3r/GUI/Plater.cpp | 3 +++ 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/slic3r/GUI/PartPlate.cpp b/src/slic3r/GUI/PartPlate.cpp index d97532039..abdd23aa4 100644 --- a/src/slic3r/GUI/PartPlate.cpp +++ b/src/slic3r/GUI/PartPlate.cpp @@ -4752,19 +4752,23 @@ bool PartPlateList::set_shapes(const Pointfs& shape, const Pointfs& exclude_area is_load_bedtype_textures = false;//reload textures calc_bounding_boxes(); - auto check_texture = [](const std::string& texture) { - boost::system::error_code ec; // so the exists call does not throw (e.g. after a permission problem) - return !texture.empty() && (boost::algorithm::iends_with(texture, ".png") || boost::algorithm::iends_with(texture, ".svg")) && boost::filesystem::exists(texture, ec); - }; - if (! texture_filename.empty() && ! check_texture(texture_filename)) { - BOOST_LOG_TRIVIAL(error) << "Unable to load bed texture: " << texture_filename; - } - else - m_logo_texture_filename = texture_filename; + update_logo_texture_filename(texture_filename); return true; } +void PartPlateList::update_logo_texture_filename(const std::string &texture_filename) +{ + auto check_texture = [](const std::string &texture) { + boost::system::error_code ec; // so the exists call does not throw (e.g. after a permission problem) + return !texture.empty() && (boost::algorithm::iends_with(texture, ".png") || boost::algorithm::iends_with(texture, ".svg")) && boost::filesystem::exists(texture, ec); + }; + if (!texture_filename.empty() && !check_texture(texture_filename)) { + BOOST_LOG_TRIVIAL(error) << "Unable to load bed texture: " << texture_filename; + } else + m_logo_texture_filename = texture_filename; +} + /*slice related functions*/ //update current slice context into backgroud slicing process void PartPlateList::update_slice_context_to_current_plate(BackgroundSlicingProcess& process) diff --git a/src/slic3r/GUI/PartPlate.hpp b/src/slic3r/GUI/PartPlate.hpp index cef1ed319..9d1f94f80 100644 --- a/src/slic3r/GUI/PartPlate.hpp +++ b/src/slic3r/GUI/PartPlate.hpp @@ -785,6 +785,8 @@ public: bool intersects(const BoundingBoxf3 &bb); bool contains(const BoundingBoxf3 &bb); + const std::string &get_logo_texture_filename() { return m_logo_texture_filename; } + void update_logo_texture_filename(const std::string &texture_filename); /*slice related functions*/ //update current slice context into backgroud slicing process void update_slice_context_to_current_plate(BackgroundSlicingProcess& process); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 9325426be..8841d2195 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -7399,6 +7399,9 @@ void Plater::priv::set_bed_shape(const Pointfs& shape, const Pointfs& exclude_ar Pointfs prev_exclude_areas = partplate_list.get_exclude_area(); new_shape |= (height_to_lid != prev_height_lid) || (height_to_rod != prev_height_rod) || (prev_exclude_areas != exclude_areas); + if (!new_shape && partplate_list.get_logo_texture_filename() != custom_texture) { + partplate_list.update_logo_texture_filename(custom_texture); + } if (new_shape) { if (view3D) view3D->bed_shape_changed(); if (preview) preview->bed_shape_changed();