From 9883cee7c1ad38d866208b3f6e093925b5f1645f Mon Sep 17 00:00:00 2001 From: thewildmage Date: Mon, 10 Jul 2023 21:56:34 -0600 Subject: [PATCH] Make pattern actually move with handle --- src/libslic3r/calib.cpp | 25 +++++++++++++++++-------- src/libslic3r/calib.hpp | 9 ++------- src/slic3r/GUI/Plater.cpp | 8 -------- src/slic3r/GUI/Selection.cpp | 4 ---- 4 files changed, 19 insertions(+), 27 deletions(-) diff --git a/src/libslic3r/calib.cpp b/src/libslic3r/calib.cpp index 133cbefee0..23ece4f587 100644 --- a/src/libslic3r/calib.cpp +++ b/src/libslic3r/calib.cpp @@ -1,4 +1,5 @@ #include "calib.hpp" +#include "BoundingBox.hpp" #include "Model.hpp" namespace Slic3r { @@ -376,11 +377,21 @@ CalibPressureAdvancePattern::CalibPressureAdvancePattern( this->m_draw_digit_mode = DrawDigitMode::Bottom_To_Top; }; -void CalibPressureAdvancePattern::starting_point(Vec3d pt, Model& model) +void CalibPressureAdvancePattern::starting_point(const Model& model) { + ModelObject* obj = model.objects.front(); + BoundingBoxf3 bbox = + obj->instance_bounding_box( + *obj->instances.front(), + false + ) + ; + + Vec3d pt(bbox.min.x(), bbox.max.y(), 0); + m_starting_point = pt; - if (is_delta(model)) { + if (m_is_delta) { m_starting_point.x() *= -1; m_starting_point.y() -= (frame_size_y() / 2); } @@ -388,12 +399,6 @@ void CalibPressureAdvancePattern::starting_point(Vec3d pt, Model& model) m_last_pos = m_starting_point; } -void CalibPressureAdvancePattern::translate_starting_point(const Vec3d displacement) -{ - m_starting_point += displacement; - m_last_pos = m_starting_point; -}; - void CalibPressureAdvancePattern::generate_gcodes(Model& model) { std::stringstream gcode; @@ -558,6 +563,10 @@ DynamicPrintConfig CalibPressureAdvancePattern::pattern_config(const Model& mode updated_config.apply(model.objects.front()->config.get(), true); updated_config.apply(model.objects.front()->volumes.front()->config.get(), true); + m_is_delta = (updated_config.option("printable_area")->values.size() > 4); + + starting_point(model); + m_nozzle_diameter = updated_config.option("nozzle_diameter")->values[0]; m_line_width = line_width(); m_pattern_settings = PatternSettings(*this); diff --git a/src/libslic3r/calib.hpp b/src/libslic3r/calib.hpp index 1b8c9953eb..05278d1d3a 100644 --- a/src/libslic3r/calib.hpp +++ b/src/libslic3r/calib.hpp @@ -178,8 +178,7 @@ public: double height_layer() const { return m_height_layer; }; double max_layer_z() const { return m_height_first_layer + ((m_num_layers - 1) * m_height_layer); }; - void starting_point(Vec3d pt, Model& model); - void translate_starting_point(Vec3d displacement); + void starting_point(const Model& model); void generate_gcodes(Model& model); protected: @@ -191,11 +190,6 @@ protected: int anchor_perimeters() const { return m_anchor_perimeters; }; double encroachment() const { return m_encroachment; }; private: - bool is_delta(Model& model) - { - return pattern_config(model).option("printable_area")->values.size() > 4; - } - DynamicPrintConfig pattern_config(const Model& model); GCodeWriter pattern_writer(const Model& model); // travel_to and extrude_to require a non-const GCodeWriter @@ -245,6 +239,7 @@ private: const bool& m_is_bbl_machine; const Vec3d& m_origin; + bool m_is_delta; Vec3d m_starting_point; PatternSettings m_pattern_settings; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 51bbabac1f..bfff95e02e 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -8155,14 +8155,6 @@ void Plater::_calib_pa_pattern(const Calib_Params& params) ); center_selection(); - BoundingBoxf3 bbox; - for (const ModelObject* obj : model().objects) { - for (size_t i = 0; i < obj->instances.size(); ++i) { - bbox.merge(obj->instance_bounding_box(i, false)); - } - } - pa_pattern.starting_point(Vec3d(bbox.min.x(), bbox.max.y(), 0), model()); - DynamicPrintConfig* print_config = &wxGetApp().preset_bundle->prints.get_edited_preset().config; DynamicPrintConfig* printerConfig = &wxGetApp().preset_bundle->printers.get_edited_preset().config; DynamicPrintConfig* filament_config = &wxGetApp().preset_bundle->filaments.get_edited_preset().config; diff --git a/src/slic3r/GUI/Selection.cpp b/src/slic3r/GUI/Selection.cpp index 106194d763..d82834e2c8 100644 --- a/src/slic3r/GUI/Selection.cpp +++ b/src/slic3r/GUI/Selection.cpp @@ -916,10 +916,6 @@ void Selection::translate(const Vec3d& displacement, bool local) synchronize_unselected_volumes(); #endif // !DISABLE_INSTANCES_SYNCH - if (m_model->calib_pa_pattern) { - m_model->calib_pa_pattern->translate_starting_point(displacement); - } - ensure_not_below_bed(); set_bounding_boxes_dirty(); wxGetApp().plater()->canvas3D()->requires_check_outside_state();