Fix flow calibration overlapping objects with nozzle > 0.4mm (#9189)

* Make sure the objects are refreshed after scaling

* Scale the calib pattern using `selection.scale` so they won't overlap (SoftFever/OrcaSlicer#9085)
This commit is contained in:
Noisyfox 2025-04-13 17:36:51 +08:00 committed by GitHub
parent 74df3a450b
commit 0a3cbabae6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -10,6 +10,7 @@
#include <regex>
#include <future>
#include <boost/algorithm/string.hpp>
#include <boost/iterator/counting_iterator.hpp>
#include <boost/optional.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
@ -9851,16 +9852,19 @@ void adjust_settings_for_flowrate_calib(ModelObjectPtrs& objects, bool linear, i
double layer_height = nozzle_diameter / 2.0; // prefer 0.2 layer height for 0.4 nozzle
first_layer_height = std::max(first_layer_height, layer_height);
const auto canvas = wxGetApp().plater()->canvas3D();
auto& selection = canvas->get_selection();
selection.setup_cache();
TransformationType transformation_type;
transformation_type.set_relative();
float zscale = (first_layer_height + 9 * layer_height) / 2;
// only enlarge
if (xyScale > 1.2) {
for (auto _obj : objects)
_obj->scale(xyScale, xyScale, zscale);
}
else {
for (auto _obj : objects)
_obj->scale(1, 1, zscale);
selection.scale({xyScale, xyScale, zscale}, transformation_type);
} else {
selection.scale({1, 1, zscale}, transformation_type);
}
canvas->do_scale("");
auto cur_flowrate = filament_config->option<ConfigOptionFloats>("filament_flow_ratio")->get_at(0);
Flow infill_flow = Flow(nozzle_diameter * 1.2f, layer_height, nozzle_diameter);
@ -9978,6 +9982,10 @@ void Plater::calib_flowrate(bool is_linear, int pass) {
adjust_settings_for_flowrate_calib(model().objects, is_linear, pass);
wxGetApp().get_tab(Preset::TYPE_PRINTER)->reload_config();
// Refresh object after scaling
const std::vector<size_t> object_idx(boost::counting_iterator<size_t>(0), boost::counting_iterator<size_t>(model().objects.size()));
changed_objects(object_idx);
}