diff --git a/src/libslic3r/calib.cpp b/src/libslic3r/calib.cpp index 37f060be12..6bc0b3cda1 100644 --- a/src/libslic3r/calib.cpp +++ b/src/libslic3r/calib.cpp @@ -4,8 +4,7 @@ namespace Slic3r { CalibPressureAdvance::CalibPressureAdvance(GCode* gcodegen) : - mp_gcodegen(gcodegen), - m_nozzle_diameter(gcodegen->config().nozzle_diameter.get_at(0)) + mp_gcodegen(gcodegen) { }; std::string CalibPressureAdvance::move_to(Vec2d pt, GCodeWriter writer, std::string comment) @@ -24,11 +23,12 @@ std::string CalibPressureAdvance::move_to(Vec2d pt, GCodeWriter writer, std::str double CalibPressureAdvance::e_per_mm( double line_width, double layer_height, + float nozzle_diameter, float filament_diameter, float print_flow_ratio ) const { - const Flow line_flow = Flow(line_width, layer_height, m_nozzle_diameter); + const Flow line_flow = Flow(line_width, layer_height, nozzle_diameter); const double filament_area = M_PI * std::pow(filament_diameter / 2, 2); return line_flow.mm3_per_mm() / filament_area * print_flow_ratio; @@ -234,20 +234,6 @@ std::string CalibPressureAdvance::draw_number( return gcode.str(); } -CalibPressureAdvanceLine::CalibPressureAdvanceLine(GCode* gcodegen) : - CalibPressureAdvance(gcodegen), - m_thin_line_width(0.44), - m_length_short(20.0), - m_length_long(40.0), - m_space_y(3.5), - m_draw_numbers(true) - { - this->m_line_width = 0.6; - this->m_number_line_width = 0.48; - this->m_height_layer = 0.2; - } -; - std::string CalibPressureAdvanceLine::generate_test(double start_pa /*= 0*/, double step_pa /*= 0.002*/, int count /*= 10*/) { BoundingBoxf bed_ext = get_extents(mp_gcodegen->config().printable_area.values); @@ -287,12 +273,14 @@ std::string CalibPressureAdvanceLine::print_pa_lines(double start_x, double star const double e_per_mm = CalibPressureAdvance::e_per_mm( m_line_width, m_height_layer, + m_nozzle_diameter, filament_diameter, print_flow_ratio ); const double thin_e_per_mm = CalibPressureAdvance::e_per_mm( m_thin_line_width, m_height_layer, + m_nozzle_diameter, filament_diameter, print_flow_ratio ); @@ -352,7 +340,7 @@ void CalibPressureAdvanceLine::delta_modify_start(double& startx, double& starty PatternSettings::PatternSettings(const CalibPressureAdvancePattern& cpap) : anchor_line_width(cpap.line_width_anchor()), - anchor_perimeters(cpap.anchor_perimeters()), + anchor_perimeters(cpap.wall_count()), encroachment(cpap.encroachment()), first_layer_height(cpap.height_first_layer()), first_layer_speed(cpap.speed_adjust(cpap.speed_first_layer())), @@ -365,16 +353,16 @@ CalibPressureAdvancePattern::CalibPressureAdvancePattern( const Calib_Params& params, DynamicPrintConfig& config, const bool& is_bbl_machine, - const Vec3d& origin + Model& model ) : CalibPressureAdvance(), m_params(params), m_initial_config(config), - m_is_bbl_machine(is_bbl_machine), - m_origin(origin) + m_is_bbl_machine(is_bbl_machine) { - this->m_height_layer = 0.2; this->m_draw_digit_mode = DrawDigitMode::Bottom_To_Top; + + refresh_pattern_config(model); }; void CalibPressureAdvancePattern::set_starting_point(const Model& model) @@ -397,17 +385,17 @@ void CalibPressureAdvancePattern::set_starting_point(const Model& model) } } -void CalibPressureAdvancePattern::generate_custom_gcodes(Model& model) +void CalibPressureAdvancePattern::generate_custom_gcodes(Model& model, const Vec3d& origin) { std::stringstream gcode; gcode << "; start pressure advance pattern for layer\n"; refresh_pattern_config(model); - GCodeWriter writer = pattern_writer(model); + GCodeWriter writer = pattern_writer(model, origin); gcode << move_to(Vec2d(m_starting_point.x(), m_starting_point.y()), writer, "Move to start XY position"); - gcode << writer.travel_to_z(m_height_first_layer, "Move to start Z position"); + gcode << writer.travel_to_z(height_first_layer(), "Move to start Z position"); gcode << writer.set_pressure_advance(m_params.start); const DrawBoxOptArgs default_box_opt_args(m_pattern_settings); @@ -419,20 +407,22 @@ void CalibPressureAdvancePattern::generate_custom_gcodes(Model& model) print_size_x(), frame_size_y(), default_box_opt_args, - model + model, + origin ); // create tab for numbers DrawBoxOptArgs draw_box_opt_args = default_box_opt_args; draw_box_opt_args.is_filled = true; - draw_box_opt_args.num_perimeters = m_anchor_perimeters; + draw_box_opt_args.num_perimeters = wall_count(); gcode << draw_box( m_starting_point.x(), m_starting_point.y() + frame_size_y() + line_spacing_anchor(), glyph_tab_max_x() - m_starting_point.x(), max_numbering_height() + line_spacing_anchor() + m_glyph_padding_vertical * 2, draw_box_opt_args, - model + model, + origin ); std::vector gcode_items; @@ -444,7 +434,7 @@ void CalibPressureAdvancePattern::generate_custom_gcodes(Model& model) if (i > 0) { gcode << "; end pressure advance pattern for layer\n"; CustomGCode::Item item; - item.print_z = m_height_first_layer + (i - 1) * m_height_layer; + item.print_z = height_first_layer() + (i - 1) * height_layer(); item.type = CustomGCode::Type::Custom; item.extra = gcode.str(); gcode_items.push_back(item); @@ -452,7 +442,7 @@ void CalibPressureAdvancePattern::generate_custom_gcodes(Model& model) gcode = std::stringstream(); // reset for next layer contents gcode << "; start pressure advance pattern for layer\n"; - double layer_height = m_height_first_layer + (i * m_height_layer); + double layer_height = height_first_layer() + (i * height_layer()); gcode << writer.travel_to_z(layer_height, "Move to layer height"); } @@ -467,8 +457,8 @@ void CalibPressureAdvancePattern::generate_custom_gcodes(Model& model) m_starting_point.y() + frame_size_y() + m_glyph_padding_vertical + line_width(), m_params.start + (j * m_params.step), m_draw_digit_mode, - m_line_width, - m_height_layer, + line_width(), + height_layer(), writer ); } @@ -484,14 +474,14 @@ void CalibPressureAdvancePattern::generate_custom_gcodes(Model& model) if (i == 0) { double shrink = ( - line_spacing_anchor() * (m_anchor_perimeters - 1) + + line_spacing_anchor() * (wall_count() - 1) + (line_width_anchor() * (1 - m_encroachment)) ) / std::sin(to_radians(m_corner_angle) / 2) ; side_length = m_wall_side_length - shrink; to_x += shrink * std::sin(to_radians(90) - to_radians(m_corner_angle) / 2); to_y += - line_spacing_anchor() * (m_anchor_perimeters - 1) + + line_spacing_anchor() * (wall_count() - 1) + (line_width_anchor() * (1 - m_encroachment)) ; } @@ -505,23 +495,23 @@ void CalibPressureAdvancePattern::generate_custom_gcodes(Model& model) // increment pressure advance gcode << writer.set_pressure_advance(m_params.start + (j * m_params.step)); - for (int k = 0; k < m_wall_count; ++k) { + for (int k = 0; k < wall_count(); ++k) { to_x += std::cos(to_radians(m_corner_angle) / 2) * side_length; to_y += std::sin(to_radians(m_corner_angle) / 2) * side_length; draw_line_opt_args = default_line_opt_args; - draw_line_opt_args.height = i == 0 ? m_height_first_layer : m_height_layer; - draw_line_opt_args.speed = i == 0 ? speed_adjust(m_speed_first_layer) : speed_adjust(m_speed_perimeter); + draw_line_opt_args.height = i == 0 ? height_first_layer() : height_layer(); + draw_line_opt_args.speed = i == 0 ? speed_adjust(speed_first_layer()) : speed_adjust(speed_perimeter()); draw_line_opt_args.comment = "Print pattern wall"; - gcode << draw_line(Vec2d(to_x, to_y), draw_line_opt_args, model); + gcode << draw_line(Vec2d(to_x, to_y), draw_line_opt_args, model, origin); to_x -= std::cos(to_radians(m_corner_angle) / 2) * side_length; to_y += std::sin(to_radians(m_corner_angle) / 2) * side_length; - gcode << draw_line(Vec2d(to_x, to_y), draw_line_opt_args, model); + gcode << draw_line(Vec2d(to_x, to_y), draw_line_opt_args, model, origin); to_y = initial_y; - if (k != m_wall_count - 1) { + if (k != wall_count() - 1) { // perimeters not done yet. move to next perimeter to_x += line_spacing_angle(); gcode << move_to(Vec2d(to_x, to_y), writer, "Move to start next pattern wall"); @@ -561,28 +551,21 @@ void CalibPressureAdvancePattern::refresh_pattern_config(const Model& model) DynamicPrintConfig updated_config(m_initial_config); updated_config.apply(model.objects.front()->config.get(), true); updated_config.apply(model.objects.front()->volumes.front()->config.get(), true); + m_config = updated_config; m_is_delta = (updated_config.option("printable_area")->values.size() > 4); - set_starting_point(model); - - m_nozzle_diameter = updated_config.option("nozzle_diameter")->values[0]; - m_line_width = line_width(); m_pattern_settings = PatternSettings(*this); - - m_config = updated_config; } -GCodeWriter CalibPressureAdvancePattern::pattern_writer(const Model& model) +GCodeWriter CalibPressureAdvancePattern::pattern_writer(const Model& model, const Vec3d& origin) { PrintConfig print_config; print_config.apply(m_config, true); GCodeWriter writer; writer.apply_print_config(print_config); - - writer.set_xy_offset(m_origin(0), m_origin(1)); - + writer.set_xy_offset(origin(0), origin(1)); writer.set_is_bbl_machine(m_is_bbl_machine); const unsigned int extruder_id = model.objects.front()->volumes.front()->extruder_id(); @@ -595,12 +578,14 @@ GCodeWriter CalibPressureAdvancePattern::pattern_writer(const Model& model) std::string CalibPressureAdvancePattern::draw_line( Vec2d to_pt, DrawLineOptArgs opt_args, - Model& model + const Model& model, + const Vec3d& origin ) { const double e_per_mm = CalibPressureAdvance::e_per_mm( opt_args.line_width, opt_args.height, + m_config.option("nozzle_diameter")->get_at(0), m_config.option("filament_diameter")->get_at(0), m_config.option("filament_flow_ratio")->get_at(0) ); @@ -610,7 +595,7 @@ std::string CalibPressureAdvancePattern::draw_line( std::stringstream gcode; - gcode << pattern_writer(model).extrude_to_xy(to_pt, dE, opt_args.comment); + gcode << pattern_writer(model, origin).extrude_to_xy(to_pt, dE, opt_args.comment); m_last_pos = Vec3d(to_pt.x(), to_pt.y(), 0); @@ -623,7 +608,8 @@ std::string CalibPressureAdvancePattern::draw_box( double size_x, double size_y, DrawBoxOptArgs opt_args, - Model& model + const Model& model, + const Vec3d& origin ) { std::stringstream gcode; @@ -646,7 +632,7 @@ std::string CalibPressureAdvancePattern::draw_box( opt_args.num_perimeters = std::min(opt_args.num_perimeters, max_perimeters); - const GCodeWriter& writer = pattern_writer(model); + const GCodeWriter& writer = pattern_writer(model, origin); gcode << move_to(Vec2d(min_x, min_y), writer, "Move to box start"); @@ -664,19 +650,19 @@ std::string CalibPressureAdvancePattern::draw_box( y += size_y - i * spacing * 2; line_opt_args.comment = "Draw perimeter (up)"; - gcode << draw_line(Vec2d(x, y), line_opt_args, model); + gcode << draw_line(Vec2d(x, y), line_opt_args, model, origin); x += size_x - i * spacing * 2; line_opt_args.comment = "Draw perimeter (right)"; - gcode << draw_line(Vec2d(x, y), line_opt_args, model); + gcode << draw_line(Vec2d(x, y), line_opt_args, model, origin); y -= size_y - i * spacing * 2; line_opt_args.comment = "Draw perimeter (down)"; - gcode << draw_line(Vec2d(x, y), line_opt_args, model); + gcode << draw_line(Vec2d(x, y), line_opt_args, model, origin); x -= size_x - i * spacing * 2; line_opt_args.comment = "Draw perimeter (left)"; - gcode << draw_line(Vec2d(x, y), line_opt_args, model); + gcode << draw_line(Vec2d(x, y), line_opt_args, model, origin); } if (!opt_args.is_filled) { @@ -715,7 +701,7 @@ std::string CalibPressureAdvancePattern::draw_box( y += x - x_min_bound; x = x_min_bound; line_opt_args.comment = "Fill: Print up/left"; - gcode << draw_line(Vec2d(x, y), line_opt_args, model); + gcode << draw_line(Vec2d(x, y), line_opt_args, model, origin); } else { y += spacing_45; x = x_min_bound; @@ -724,7 +710,7 @@ std::string CalibPressureAdvancePattern::draw_box( x += y - y_min_bound; y = y_min_bound; line_opt_args.comment = "Fill: Print down/right"; - gcode << draw_line(Vec2d(x, y), line_opt_args, model); + gcode << draw_line(Vec2d(x, y), line_opt_args, model, origin); } } else if (i < std::max(x_count, y_count)) { if (x_count > y_count) { @@ -737,7 +723,7 @@ std::string CalibPressureAdvancePattern::draw_box( x -= y_max_bound - y_min_bound; y = y_max_bound; line_opt_args.comment = "Fill: Print up/left"; - gcode << draw_line(Vec2d(x, y), line_opt_args, model); + gcode << draw_line(Vec2d(x, y), line_opt_args, model, origin); } else { if (i == y_count) { x += spacing_45 - y_remainder; @@ -751,7 +737,7 @@ std::string CalibPressureAdvancePattern::draw_box( x += y_max_bound - y_min_bound; y = y_min_bound; line_opt_args.comment = "Fill: Print down/right"; - gcode << draw_line(Vec2d(x, y), line_opt_args, model); + gcode << draw_line(Vec2d(x, y), line_opt_args, model, origin); } } else { // box is taller than wide @@ -768,7 +754,7 @@ std::string CalibPressureAdvancePattern::draw_box( x = x_min_bound; y += x_max_bound - x_min_bound; line_opt_args.comment = "Fill: Print up/left"; - gcode << draw_line(Vec2d(x, y), line_opt_args, model); + gcode << draw_line(Vec2d(x, y), line_opt_args, model, origin); } else { x = x_min_bound; y += spacing_45; @@ -777,7 +763,7 @@ std::string CalibPressureAdvancePattern::draw_box( x = x_max_bound; y -= x_max_bound - x_min_bound; line_opt_args.comment = "Fill: Print down/right"; - gcode << draw_line(Vec2d(x, y), line_opt_args, model); + gcode << draw_line(Vec2d(x, y), line_opt_args, model, origin); } } } else { @@ -793,7 +779,7 @@ std::string CalibPressureAdvancePattern::draw_box( x -= y_max_bound - y; y = y_max_bound; line_opt_args.comment = "Fill: Print up/left"; - gcode << draw_line(Vec2d(x, y), line_opt_args, model); + gcode << draw_line(Vec2d(x, y), line_opt_args, model, origin); } else { if (i == y_count) { x += spacing_45 - y_remainder; @@ -806,7 +792,7 @@ std::string CalibPressureAdvancePattern::draw_box( y -= x_max_bound - x; x = x_max_bound; line_opt_args.comment = "Fill: Print down/right"; - gcode << draw_line(Vec2d(x, y), line_opt_args, model); + gcode << draw_line(Vec2d(x, y), line_opt_args, model, origin); } } } @@ -821,10 +807,10 @@ double CalibPressureAdvancePattern::get_distance(Vec2d from, Vec2d to) const double CalibPressureAdvancePattern::object_size_x() const { - return get_num_patterns() * ((m_wall_count - 1) * line_spacing_angle()) + + return get_num_patterns() * ((wall_count() - 1) * line_spacing_angle()) + (get_num_patterns() - 1) * (m_pattern_spacing + line_width()) + std::cos(to_radians(m_corner_angle) / 2) * m_wall_side_length + - line_spacing_anchor() * m_anchor_perimeters + line_spacing_anchor() * wall_count() ; } @@ -846,7 +832,7 @@ double CalibPressureAdvancePattern::glyph_start_x(int pattern_i) const pattern_shift() + // width of pattern extrusions - pattern_i * (m_wall_count - 1) * line_spacing_angle() + // center to center distance of extrusions + pattern_i * (wall_count() - 1) * line_spacing_angle() + // center to center distance of extrusions pattern_i * line_width() + // endcaps. center to end on either side = 1 line width // space between each pattern @@ -854,7 +840,7 @@ double CalibPressureAdvancePattern::glyph_start_x(int pattern_i) const ; // align to middle of pattern walls - x += m_wall_count * line_spacing_angle() / 2; + x += wall_count() * line_spacing_angle() / 2; // shift so glyph is centered on pattern // m_digit_segment_len = half of X length of glyph @@ -911,7 +897,7 @@ double CalibPressureAdvancePattern::max_numbering_height() const double CalibPressureAdvancePattern::pattern_shift() const { return - (m_anchor_perimeters - 1) * line_spacing_anchor() + + (wall_count() - 1) * line_spacing_anchor() + line_width_anchor() + m_glyph_padding_horizontal ; diff --git a/src/libslic3r/calib.hpp b/src/libslic3r/calib.hpp index 45562a2bd4..be284caaae 100644 --- a/src/libslic3r/calib.hpp +++ b/src/libslic3r/calib.hpp @@ -42,6 +42,7 @@ protected: double e_per_mm( double line_width, double layer_height, + float nozzle_diameter, float filament_diameter, float print_flow_ratio ) const; @@ -76,15 +77,14 @@ protected: const double m_digit_segment_len {2}; const double m_digit_gap_len {1}; const std::string::size_type m_max_number_len {5}; - - double m_nozzle_diameter {-1}; - double m_line_width {-1}; - double m_height_layer {-1}; }; class CalibPressureAdvanceLine : public CalibPressureAdvance { public: - CalibPressureAdvanceLine(GCode* gcodegen); + CalibPressureAdvanceLine(GCode* gcodegen) : + CalibPressureAdvance(gcodegen), + m_nozzle_diameter(gcodegen->config().nozzle_diameter.get_at(0)) + { }; ~CalibPressureAdvanceLine() { }; std::string generate_test(double start_pa = 0, double step_pa = 0.002, int count = 50); @@ -94,7 +94,7 @@ public: m_fast_speed = fast; } - double& line_width() { return m_line_width; }; + const double& line_width() { return m_line_width; }; bool is_delta() const; bool& draw_numbers() { return m_draw_numbers; } @@ -103,12 +103,17 @@ private: void delta_modify_start(double& startx, double& starty, int count); - double m_thin_line_width; - double m_number_line_width; - double m_length_short, m_length_long; - double m_space_y; + double m_nozzle_diameter; double m_slow_speed, m_fast_speed; - bool m_draw_numbers; + + const double m_height_layer {0.2}; + const double m_line_width {0.6}; + const double m_thin_line_width {0.44}; + const double m_number_line_width {0.48}; + const double m_space_y {3.5}; + + double m_length_short {20.0}, m_length_long {40.0}; + bool m_draw_numbers {true}; }; class CalibPressureAdvancePattern; @@ -163,6 +168,24 @@ private: double speed; }; +struct SuggestedCalibPressureAdvancePatternConfig { + const std::vector> float_pairs { + {"initial_layer_print_height", 0.25}, + {"layer_height", 0.2}, + {"initial_layer_speed", 30}, + {"outer_wall_speed", 100} + }; + + const std::vector> nozzle_ratio_pairs { + {"line_width", 112.5}, + {"initial_layer_line_width", 140} + }; + + const std::vector> int_pairs { + {"wall_loops", 3} + }; +}; + class CalibPressureAdvancePattern : public CalibPressureAdvance { friend struct PatternSettings; public: @@ -170,42 +193,51 @@ public: const Calib_Params& params, DynamicPrintConfig& config, const bool& is_bbl_machine, - const Vec3d& origin + Model& model ); double handle_xy_size() const { return m_handle_xy_size; }; - double height_first_layer() const { return m_height_first_layer; }; - 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); }; + double height_first_layer() const { return m_config.option("initial_layer_print_height")->value; }; + double height_layer() const { return m_config.option("layer_height")->value; }; + double max_layer_z() const { return height_first_layer() + ((m_num_layers - 1) * height_layer()); }; void set_starting_point(const Model& model); - void generate_custom_gcodes(Model& model); + void generate_custom_gcodes(Model& model, const Vec3d& origin); protected: - double line_width() const { return m_nozzle_diameter * m_line_ratio / 100; }; - double line_width_anchor() const { return m_nozzle_diameter * m_anchor_layer_line_ratio / 100; }; - - double speed_first_layer() const { return m_speed_first_layer; }; - double speed_perimeter() const { return m_speed_perimeter; }; - int anchor_perimeters() const { return m_anchor_perimeters; }; + double speed_first_layer() const { return m_config.option("initial_layer_speed")->value; }; + double speed_perimeter() const { return m_config.option("outer_wall_speed")->value; }; + double line_width() const { return m_config.option("line_width")->value; }; + double line_width_anchor() const { return m_config.option("initial_layer_line_width")->value; }; + int wall_count() const { return m_config.option("wall_loops")->value; }; + double encroachment() const { return m_encroachment; }; private: void refresh_pattern_config(const Model& model); - GCodeWriter pattern_writer(const Model& model); // travel_to and extrude_to require a non-const GCodeWriter + GCodeWriter pattern_writer( + const Model& model, + const Vec3d& origin + ); // would return const, but travel_to and extrude_to require a non-const GCodeWriter const int get_num_patterns() const { return std::ceil((m_params.end - m_params.start) / m_params.step + 1); } - std::string draw_line(Vec2d to_pt, DrawLineOptArgs opt_args, Model& model); + std::string draw_line( + Vec2d to_pt, + DrawLineOptArgs opt_args, + const Model& model, + const Vec3d& origin + ); std::string draw_box( double min_x, double min_y, double size_x, double size_y, DrawBoxOptArgs opt_args, - Model& model + const Model& model, + const Vec3d& origin ); double to_radians(double degrees) const { return degrees * M_PI / 180; }; @@ -217,8 +249,8 @@ private: https://manual.slic3r.org/advanced/flow-math https://ellis3dp.com/Print-Tuning-Guide/articles/misconceptions.html#two-04mm-perimeters--08mm */ - double line_spacing() const { return line_width() - m_height_layer * (1 - M_PI / 4); }; - double line_spacing_anchor() const { return line_width_anchor() - m_height_first_layer * (1 - M_PI / 4); }; + double line_spacing() const { return line_width() - height_layer() * (1 - M_PI / 4); }; + double line_spacing_anchor() const { return line_width_anchor() - height_first_layer() * (1 - M_PI / 4); }; double line_spacing_angle() const { return line_spacing() / std::sin(to_radians(m_corner_angle) / 2); }; double object_size_x() const; @@ -237,27 +269,15 @@ private: const Calib_Params& m_params; const DynamicPrintConfig m_initial_config; const bool& m_is_bbl_machine; - const Vec3d& m_origin; DynamicPrintConfig m_config; bool m_is_delta; Vec3d m_starting_point; - PatternSettings m_pattern_settings; const double m_handle_xy_size {5}; - const int m_num_layers {4}; - const double m_height_first_layer {0.25}; - - const double m_line_ratio {112.5}; - const int m_anchor_layer_line_ratio {140}; - const int m_anchor_perimeters {4}; - const double m_speed_first_layer {30}; - const double m_speed_perimeter {100}; - - const int m_wall_count {3}; const double m_wall_side_length {30.0}; const int m_corner_angle {90}; const int m_pattern_spacing {2}; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 5c227c1ac0..38217c7b5f 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -8131,13 +8131,47 @@ void Plater::_calib_pa_pattern(const Calib_Params& params) changed_objects({ 0 }); _calib_pa_select_added_objects(); + const DynamicPrintConfig& printer_config = wxGetApp().preset_bundle->printers.get_edited_preset().config; + // DynamicPrintConfig* filament_config = &wxGetApp().preset_bundle->filaments.get_edited_preset().config; + DynamicPrintConfig& print_config = wxGetApp().preset_bundle->prints.get_edited_preset().config; + + for (const auto opt : SuggestedCalibPressureAdvancePatternConfig().float_pairs) { + print_config.set_key_value( + opt.first, + new ConfigOptionFloat(opt.second) + ); + } + + for (const auto opt : SuggestedCalibPressureAdvancePatternConfig().nozzle_ratio_pairs) { + double nozzle_diameter = printer_config.option("nozzle_diameter")->get_at(0); + print_config.set_key_value( + opt.first, + new ConfigOptionFloat(nozzle_diameter * opt.second / 100) + ); + } + + for (const auto opt : SuggestedCalibPressureAdvancePatternConfig().int_pairs) { + print_config.set_key_value( + opt.first, + new ConfigOptionInt(opt.second) + ); + } + + // wxGetApp().get_tab(Preset::TYPE_PRINTER)->update_dirty(); + // wxGetApp().get_tab(Preset::TYPE_FILAMENT)->update_dirty(); + wxGetApp().get_tab(Preset::TYPE_PRINT)->update_dirty(); + + // wxGetApp().get_tab(Preset::TYPE_PRINTER)->reload_config(); + // wxGetApp().get_tab(Preset::TYPE_FILAMENT)->reload_config(); + wxGetApp().get_tab(Preset::TYPE_PRINT)->reload_config(); + DynamicPrintConfig full_config = wxGetApp().preset_bundle->full_config(); PresetBundle* preset_bundle = wxGetApp().preset_bundle; CalibPressureAdvancePattern pa_pattern( params, full_config, preset_bundle->printers.get_edited_preset().is_bbl_vendor_preset(preset_bundle), - fff_print().get_plate_origin() + model() ); GizmoObjectManipulation& giz_obj_manip = p->view3D->get_canvas3d()-> @@ -8155,28 +8189,7 @@ void Plater::_calib_pa_pattern(const Calib_Params& params) ); center_selection(); - 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; - - print_config->set_key_value( - "layer_height", - new ConfigOptionFloat(pa_pattern.height_layer()) - ); - print_config->set_key_value( - "initial_layer_print_height", - new ConfigOptionFloat(pa_pattern.height_first_layer()) - ); - - wxGetApp().get_tab(Preset::TYPE_PRINTER)->update_dirty(); - wxGetApp().get_tab(Preset::TYPE_PRINT)->update_dirty(); - wxGetApp().get_tab(Preset::TYPE_FILAMENT)->update_dirty(); - - wxGetApp().get_tab(Preset::TYPE_PRINTER)->reload_config(); - wxGetApp().get_tab(Preset::TYPE_PRINT)->reload_config(); - wxGetApp().get_tab(Preset::TYPE_FILAMENT)->reload_config(); - - pa_pattern.generate_custom_gcodes(model()); + pa_pattern.generate_custom_gcodes(model(), fff_print().get_plate_origin()); model().calib_pa_pattern = std::make_unique(pa_pattern); } @@ -10335,7 +10348,10 @@ void Plater::reslice() // regenerate CalibPressureAdvancePattern custom G-code to apply changes if (this->model().calib_pa_pattern) { - this->model().calib_pa_pattern->generate_custom_gcodes(this->model()); + this->model().calib_pa_pattern->generate_custom_gcodes( + this->model(), + this->fff_print().get_plate_origin() + ); } if (printer_technology() == ptSLA) {