OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::CalibPressureAdvancePattern Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/calib.hpp>

Inheritance diagram for Slic3r::CalibPressureAdvancePattern:
Collaboration diagram for Slic3r::CalibPressureAdvancePattern:

Public Member Functions

 CalibPressureAdvancePattern (const Calib_Params &params, const DynamicPrintConfig &config, bool is_bbl_machine, const ModelObject &object, const Vec3d &origin)
double handle_xy_size () const
double handle_spacing () const
Vec3d handle_pos_offset () const
double print_size_x () const
double print_size_y () const
double max_layer_z () const
double flow_val () const
CustomGCode::Info generate_custom_gcodes (const DynamicPrintConfig &config, bool is_bbl_machine, const ModelObject &object, const Vec3d &origin)
void set_start_offset (const Vec3d &offset)
Vec3d get_start_offset ()

Static Public Member Functions

static float find_optimal_PA_speed (const DynamicPrintConfig &config, double line_width, double layer_height, int extruder_id=0, int filament_idx=0)

Protected Types

enum class  DrawDigitMode { Left_To_Right , Bottom_To_Top }

Protected Member Functions

double speed_first_layer () const
double speed_perimeter () const
double accel_perimeter () const
double line_width_first_layer () const
double line_width () const
int wall_count () const
void delta_scale_bed_ext (BoundingBoxf &bed_ext) const
std::string move_to (Vec2d pt, GCodeWriter &writer, std::string comment=std::string(), double z=0, double layer_height=-1)
double e_per_mm (double line_width, double layer_height, float nozzle_diameter, float filament_diameter, float print_flow_ratio) const
double speed_adjust (int speed) const
std::string convert_number_to_string (double num, unsigned precision=0) const
double number_spacing () const
std::string draw_digit (double startx, double starty, char c, CalibPressureAdvance::DrawDigitMode mode, double line_width, double e_per_mm, GCodeWriter &writer)
std::string draw_number (double startx, double starty, double value, CalibPressureAdvance::DrawDigitMode mode, double line_width, double e_per_mm, double speed, GCodeWriter &writer)
std::string draw_line (GCodeWriter &writer, Vec2d to_pt, double line_width, double layer_height, double speed, const std::string &comment=std::string())
std::string draw_box (GCodeWriter &writer, double min_x, double min_y, double size_x, double size_y, DrawBoxOptArgs opt_args)
double to_radians (double degrees) const
double get_distance (Vec2d from, Vec2d to) const

Protected Attributes

Vec3d m_last_pos
DynamicPrintConfig m_config
const double m_encroachment {1. / 3.}
DrawDigitMode m_draw_digit_mode {DrawDigitMode::Left_To_Right}
const double m_digit_segment_len {2}
const double m_digit_gap_len {1}
const std::string::size_type m_max_number_len {5}
std::string::size_type m_number_len {m_max_number_len}

Private Member Functions

void refresh_setup (const DynamicPrintConfig &config, bool is_bbl_machine, const ModelObject &object, const Vec3d &origin)
void _refresh_starting_point (const ModelObject &object)
void _refresh_writer (bool is_bbl_machine, const ModelObject &object, const Vec3d &origin)
double height_first_layer () const
double height_z_offset () const
double height_layer () const
const int get_num_patterns () const
double line_spacing () const
double line_spacing_first_layer () const
double line_spacing_angle () const
double object_size_x () const
double object_size_y () const
double frame_size_y () const
double glyph_start_x (int pattern_i=0) const
double glyph_length_x () const
double glyph_tab_max_x () const
double max_numbering_height () const
size_t max_numbering_length () const
double pattern_shift () const

Private Attributes

const Calib_Params & m_params
std::shared_ptr< GCodeWriter > m_writer {std::make_shared<GCodeWriter>()}
Vec3d m_starting_point
bool m_is_start_point_fixed = false
const double m_handle_xy_size {5}
const double m_handle_spacing {1.2}
const int m_num_layers {4}
const double m_wall_side_length {30.0}
const int m_corner_angle {90}
const int m_pattern_spacing {2}
const double m_glyph_padding_horizontal {1}
const double m_glyph_padding_vertical {1}

Friends

struct DrawBoxOptArgs

Detailed Description

Member Enumeration Documentation

◆ DrawDigitMode

enum class Slic3r::CalibPressureAdvance::DrawDigitMode
strongprotectedinherited
Enumerator
Left_To_Right 
Bottom_To_Top 
213{ Left_To_Right, Bottom_To_Top };

Constructor & Destructor Documentation

◆ CalibPressureAdvancePattern()

Slic3r::CalibPressureAdvancePattern::CalibPressureAdvancePattern ( const Calib_Params & params,
const DynamicPrintConfig & config,
bool is_bbl_machine,
const ModelObject & object,
const Vec3d & origin )
617 : m_params(params),CalibPressureAdvance(config)
618{
620
621 refresh_setup(config, is_bbl_machine, object, origin);
622}
void refresh_setup(const DynamicPrintConfig &config, bool is_bbl_machine, const ModelObject &object, const Vec3d &origin)
Definition calib.cpp:851
const Calib_Params & m_params
Definition calib.hpp:371
DrawDigitMode m_draw_digit_mode
Definition calib.hpp:250
@ Bottom_To_Top
Definition calib.hpp:213

References Slic3r::CalibPressureAdvance::CalibPressureAdvance(), Slic3r::CalibPressureAdvance::Bottom_To_Top, Slic3r::CalibPressureAdvance::m_draw_digit_mode, m_params, and refresh_setup().

Here is the call graph for this function:

Member Function Documentation

◆ _refresh_starting_point()

void Slic3r::CalibPressureAdvancePattern::_refresh_starting_point ( const ModelObject & object)
private
865{
867 return;
868
869 BoundingBoxf3 bbox = object.instance_bounding_box(*object.instances.front(), false);
870
871 m_starting_point = Vec3d(bbox.min.x(), bbox.max.y(), 0);
873 m_starting_point.y() -= std::sin(to_radians(m_corner_angle) / 2) * m_wall_side_length + (bbox.max.y() - bbox.min.y()) / 2;
874}
bool m_is_start_point_fixed
Definition calib.hpp:378
Vec3d m_starting_point
Definition calib.hpp:377
const int m_corner_angle
Definition calib.hpp:385
const double m_handle_spacing
Definition calib.hpp:381
const double m_wall_side_length
Definition calib.hpp:384
double to_radians(double degrees) const
Definition calib.hpp:243
Eigen::Matrix< double, 3, 1, Eigen::DontAlign > Vec3d
Definition Point.hpp:68

References m_corner_angle, m_handle_spacing, m_is_start_point_fixed, m_starting_point, m_wall_side_length, Slic3r::BoundingBoxBase< PointType, std::vector< PointType > >::max, Slic3r::BoundingBoxBase< PointType, std::vector< PointType > >::min, and Slic3r::CalibPressureAdvance::to_radians().

Referenced by refresh_setup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _refresh_writer()

void Slic3r::CalibPressureAdvancePattern::_refresh_writer ( bool is_bbl_machine,
const ModelObject & object,
const Vec3d & origin )
private
877{
878 PrintConfig print_config;
879 print_config.apply(m_config, true);
880
881 // ORCA-Belt: the pattern is drawn in logical bed coordinates directly on
882 // the build surface — on a belt printer that means the belt plane, which
883 // needs the machine kinematics (axis remap + frame shear/scale) with the
884 // coordinates interpreted as world points (see set_world_coordinates).
885 if (print_config.belt_printer.value) {
886 auto belt_writer = std::make_shared<GCodeWriter>();
887 install_belt_kinematics(*belt_writer, print_config, /*world_coordinates=*/true);
888 const int rx = int(print_config.gcode_remap_x.value);
889 const int ry = int(print_config.gcode_remap_y.value);
890 const int rz = int(print_config.gcode_remap_z.value);
891 if (rx != 0 || ry != 1 || rz != 2) {
892 belt_writer->set_axis_remap(rx, ry, rz);
893 BoundingBoxf bbox_bed(print_config.printable_area.values);
894 belt_writer->set_build_volume_max(Vec3d(bbox_bed.max.x(), bbox_bed.max.y(),
895 print_config.printable_height.value));
896 }
897 m_writer = std::move(belt_writer);
898 } else if (m_writer && dynamic_cast<const BeltKinematics *>(&m_writer->kinematics()) != nullptr) {
899 // Previously configured for a belt printer; drop back to a plain writer.
900 m_writer = std::make_shared<GCodeWriter>();
901 }
902
903 m_writer->apply_print_config(print_config);
904 m_writer->set_xy_offset(origin(0), origin(1));
905 m_writer->set_is_bbl_machine(is_bbl_machine);
906
907 const unsigned int extruder_id = object.volumes.front()->extruder_id();
908 m_writer->set_extruders({extruder_id});
909 m_writer->set_extruder(extruder_id);
910}
std::shared_ptr< GCodeWriter > m_writer
Definition calib.hpp:376
DynamicPrintConfig m_config
Definition calib.hpp:247
void install_belt_kinematics(GCodeWriter &writer, const PrintConfig &config, bool world_coordinates)
Definition BeltKinematics.cpp:24

References Slic3r::install_belt_kinematics(), Slic3r::CalibPressureAdvance::m_config, m_writer, and Slic3r::BoundingBoxBase< PointType, APointsType >::max.

Referenced by refresh_setup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ accel_perimeter()

double Slic3r::CalibPressureAdvancePattern::accel_perimeter ( ) const
inlineprotected
334{ return m_config.get_abs_value_at("outer_wall_acceleration", m_params.extruder_id); }

References Slic3r::CalibPressureAdvance::m_config, and m_params.

Referenced by generate_custom_gcodes(), and max_numbering_length().

Here is the caller graph for this function:

◆ convert_number_to_string()

std::string Slic3r::CalibPressureAdvance::convert_number_to_string ( double num,
unsigned precision = 0 ) const
protectedinherited
83{
84 std::ostringstream stream;
85
86 if (precision) {
87 /* if number is > 1000 then there are no way we'll fit fractional part into 5 glyphs, so
88 * in this case we keep full precision.
89 * Otherwise we reduce precision by 1 to accomodate decimal separator */
90 stream << std::setprecision(num >= 1000 ? precision : precision - 1);
91 }
92
93 stream << num;
94
95 return stream.str();
96}

Referenced by draw_number(), and Slic3r::CalibPressureAdvancePattern::max_numbering_length().

Here is the caller graph for this function:

◆ delta_scale_bed_ext()

void Slic3r::CalibPressureAdvance::delta_scale_bed_ext ( BoundingBoxf & bed_ext) const
inlineprotectedinherited
215{ bed_ext.scale(1.0f / 1.41421f); }

References Slic3r::BoundingBoxBase< PointType, APointsType >::scale().

Referenced by Slic3r::CalibPressureAdvanceLine::generate_test(), and Slic3r::CalibPressureAdvanceLine::print_extents().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ draw_box()

std::string Slic3r::CalibPressureAdvance::draw_box ( GCodeWriter & writer,
double min_x,
double min_y,
double size_x,
double size_y,
DrawBoxOptArgs opt_args )
protectedinherited
291{
292 std::stringstream gcode;
293
294 double x = min_x;
295 double y = min_y;
296 const double max_x = min_x + size_x;
297 const double max_y = min_y + size_y;
298
299 const double spacing = opt_args.line_width - opt_args.height * (1 - M_PI / 4);
300
301 // if number of perims exceeds size of box, reduce it to max
302 const int max_perimeters = std::min(
303 // this is the equivalent of number of perims for concentric fill
304 std::floor(size_x * std::sin(to_radians(45))) / (spacing / std::sin(to_radians(45))),
305 std::floor(size_y * std::sin(to_radians(45))) / (spacing / std::sin(to_radians(45))));
306
307 opt_args.num_perimeters = std::min(opt_args.num_perimeters, max_perimeters);
308
309 gcode << move_to(Vec2d(min_x, min_y), writer, "Move to box start");
310
311 // DrawLineOptArgs line_opt_args(*this);
312 auto line_arg_height = opt_args.height;
313 auto line_arg_line_width = opt_args.line_width;
314 auto line_arg_speed = opt_args.speed;
315 std::string comment = "";
316
317 for (int i = 0; i < opt_args.num_perimeters; ++i) {
318 if (i != 0) { // after first perimeter, step inwards to start next perimeter
319 x += spacing;
320 y += spacing;
321 gcode << move_to(Vec2d(x, y), writer, "Step inwards to print next perimeter");
322 }
323
324 y += size_y - i * spacing * 2;
325 comment = "Draw perimeter (up)";
326 gcode << draw_line(writer, Vec2d(x, y), line_arg_line_width, line_arg_height, line_arg_speed, comment);
327
328 x += size_x - i * spacing * 2;
329 comment = "Draw perimeter (right)";
330 gcode << draw_line(writer, Vec2d(x, y), line_arg_line_width, line_arg_height, line_arg_speed, comment);
331
332 y -= size_y - i * spacing * 2;
333 comment = "Draw perimeter (down)";
334 gcode << draw_line(writer, Vec2d(x, y), line_arg_line_width, line_arg_height, line_arg_speed, comment);
335
336 x -= size_x - i * spacing * 2;
337 comment = "Draw perimeter (left)";
338 gcode << draw_line(writer, Vec2d(x, y), line_arg_line_width, line_arg_height, line_arg_speed, comment);
339 }
340
341 if (!opt_args.is_filled) {
342 return gcode.str();
343 }
344
345 // create box infill
346 const double spacing_45 = spacing / std::sin(to_radians(45));
347
348 const double bound_modifier = (spacing * (opt_args.num_perimeters - 1)) + (opt_args.line_width * (1 - m_encroachment));
349 const double x_min_bound = min_x + bound_modifier;
350 const double x_max_bound = max_x - bound_modifier;
351 const double y_min_bound = min_y + bound_modifier;
352 const double y_max_bound = max_y - bound_modifier;
353 const int x_count = std::floor((x_max_bound - x_min_bound) / spacing_45);
354 const int y_count = std::floor((y_max_bound - y_min_bound) / spacing_45);
355
356 double x_remainder = std::fmod((x_max_bound - x_min_bound), spacing_45);
357 double y_remainder = std::fmod((y_max_bound - y_min_bound), spacing_45);
358
359 x = x_min_bound;
360 y = y_min_bound;
361
362 gcode << move_to(Vec2d(x, y), writer, "Move to fill start");
363
364 for (int i = 0; i < x_count + y_count + (x_remainder + y_remainder >= spacing_45 ? 1 : 0);
365 ++i) { // this isn't the most robust way, but less expensive than finding line intersections
366 if (i < std::min(x_count, y_count)) {
367 if (i % 2 == 0) {
368 x += spacing_45;
369 y = y_min_bound;
370 gcode << move_to(Vec2d(x, y), writer, "Fill: Step right");
371
372 y += x - x_min_bound;
373 x = x_min_bound;
374 comment = "Fill: Print up/left";
375 gcode << draw_line(writer, Vec2d(x, y), line_arg_line_width, line_arg_height, line_arg_speed, comment);
376 } else {
377 y += spacing_45;
378 x = x_min_bound;
379 gcode << move_to(Vec2d(x, y), writer, "Fill: Step up");
380
381 x += y - y_min_bound;
382 y = y_min_bound;
383 comment = "Fill: Print down/right";
384 gcode << draw_line(writer, Vec2d(x, y), line_arg_line_width, line_arg_height, line_arg_speed, comment);
385 }
386 } else if (i < std::max(x_count, y_count)) {
387 if (x_count > y_count) {
388 // box is wider than tall
389 if (i % 2 == 0) {
390 x += spacing_45;
391 y = y_min_bound;
392 gcode << move_to(Vec2d(x, y), writer, "Fill: Step right");
393
394 x -= y_max_bound - y_min_bound;
395 y = y_max_bound;
396 comment = "Fill: Print up/left";
397 gcode << draw_line(writer, Vec2d(x, y), line_arg_line_width, line_arg_height, line_arg_speed, comment);
398 } else {
399 if (i == y_count) {
400 x += spacing_45 - y_remainder;
401 y_remainder = 0;
402 } else {
403 x += spacing_45;
404 }
405 y = y_max_bound;
406 gcode << move_to(Vec2d(x, y), writer, "Fill: Step right");
407
408 x += y_max_bound - y_min_bound;
409 y = y_min_bound;
410 comment = "Fill: Print down/right";
411 gcode << draw_line(writer, Vec2d(x, y), line_arg_line_width, line_arg_height, line_arg_speed, comment);
412 }
413 } else {
414 // box is taller than wide
415 if (i % 2 == 0) {
416 x = x_max_bound;
417 if (i == x_count) {
418 y += spacing_45 - x_remainder;
419 x_remainder = 0;
420 } else {
421 y += spacing_45;
422 }
423 gcode << move_to(Vec2d(x, y), writer, "Fill: Step up");
424
425 x = x_min_bound;
426 y += x_max_bound - x_min_bound;
427 comment = "Fill: Print up/left";
428 gcode << draw_line(writer, Vec2d(x, y), line_arg_line_width, line_arg_height, line_arg_speed, comment);
429 } else {
430 x = x_min_bound;
431 y += spacing_45;
432 gcode << move_to(Vec2d(x, y), writer, "Fill: Step up");
433
434 x = x_max_bound;
435 y -= x_max_bound - x_min_bound;
436 comment = "Fill: Print down/right";
437 gcode << draw_line(writer, Vec2d(x, y), line_arg_line_width, line_arg_height, line_arg_speed, comment);
438 }
439 }
440 } else {
441 if (i % 2 == 0) {
442 x = x_max_bound;
443 if (i == x_count) {
444 y += spacing_45 - x_remainder;
445 } else {
446 y += spacing_45;
447 }
448 gcode << move_to(Vec2d(x, y), writer, "Fill: Step up");
449
450 x -= y_max_bound - y;
451 y = y_max_bound;
452 comment = "Fill: Print up/left";
453 gcode << draw_line(writer, Vec2d(x, y), line_arg_line_width, line_arg_height, line_arg_speed, comment);
454 } else {
455 if (i == y_count) {
456 x += spacing_45 - y_remainder;
457 } else {
458 x += spacing_45;
459 }
460 y = y_max_bound;
461 gcode << move_to(Vec2d(x, y), writer, "Fill: Step right");
462
463 y -= x_max_bound - x;
464 x = x_max_bound;
465 comment = "Fill: Print down/right";
466 gcode << draw_line(writer, Vec2d(x, y), line_arg_line_width, line_arg_height, line_arg_speed, comment);
467 }
468 }
469 }
470
471 return gcode.str();
472}
#define M_PI
Definition ExtrusionSimulator.cpp:31
const double m_encroachment
Definition calib.hpp:249
std::string move_to(Vec2d pt, GCodeWriter &writer, std::string comment=std::string(), double z=0, double layer_height=-1)
Definition calib.cpp:54
std::string draw_line(GCodeWriter &writer, Vec2d to_pt, double line_width, double layer_height, double speed, const std::string &comment=std::string())
Definition calib.cpp:269
@ gcode
Definition Time.hpp:14
Eigen::Matrix< double, 2, 1, Eigen::DontAlign > Vec2d
Definition Point.hpp:67

References draw_line(), Slic3r::DrawBoxOptArgs::height, Slic3r::DrawBoxOptArgs::is_filled, Slic3r::DrawBoxOptArgs::line_width, m_encroachment, M_PI, move_to(), Slic3r::DrawBoxOptArgs::num_perimeters, Slic3r::DrawBoxOptArgs::speed, and to_radians().

Referenced by Slic3r::CalibPressureAdvancePattern::generate_custom_gcodes(), and Slic3r::CalibPressureAdvanceLine::print_pa_lines().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ draw_digit()

std::string Slic3r::CalibPressureAdvance::draw_digit ( double startx,
double starty,
char c,
CalibPressureAdvance::DrawDigitMode mode,
double line_width,
double e_per_mm,
GCodeWriter & writer )
protectedinherited
100{
101 const double len = m_digit_segment_len;
102 const double gap = line_width / 2.0;
103
104 const auto dE = e_per_mm * len;
105 const auto two_dE = dE * 2;
106
107 Vec2d p0, p1, p2, p3, p4, p5;
108 Vec2d p0_5, p4_5;
109 Vec2d gap_p0_toward_p3, gap_p2_toward_p3;
110 Vec2d dot_direction;
111
113 // 1-------2-------5
114 // | | |
115 // | | |
116 // 0-------3-------4
117 p0 = Vec2d(startx, starty);
118 p0_5 = Vec2d(startx, starty + len / 2);
119 p1 = Vec2d(startx, starty + len);
120 p2 = Vec2d(startx + len, starty + len);
121 p3 = Vec2d(startx + len, starty);
122 p4 = Vec2d(startx + len * 2, starty);
123 p4_5 = Vec2d(startx + len * 2, starty + len / 2);
124 p5 = Vec2d(startx + len * 2, starty + len);
125
126 gap_p0_toward_p3 = p0 + Vec2d(gap, 0);
127 gap_p2_toward_p3 = p2 + Vec2d(0, gap);
128
129 dot_direction = Vec2d(-len / 2, 0);
130 } else {
131 // 0-------1
132 // | |
133 // 3-------2
134 // | |
135 // 4-------5
136 p0 = Vec2d(startx, starty);
137 p0_5 = Vec2d(startx + len / 2, starty);
138 p1 = Vec2d(startx + len, starty);
139 p2 = Vec2d(startx + len, starty - len);
140 p3 = Vec2d(startx, starty - len);
141 p4 = Vec2d(startx, starty - len * 2);
142 p4_5 = Vec2d(startx + len / 2, starty - len * 2);
143 p5 = Vec2d(startx + len, starty - len * 2);
144
145 gap_p0_toward_p3 = p0 - Vec2d(0, gap);
146 gap_p2_toward_p3 = p2 - Vec2d(gap, 0);
147
148 dot_direction = Vec2d(0, len / 2);
149 }
150
151 std::stringstream gcode;
152
153 switch (c) {
154 case '0':
155 gcode << move_to(p0, writer, "Glyph: 0");
156 gcode << writer.extrude_to_xy(p1, dE);
157 gcode << writer.extrude_to_xy(p5, two_dE);
158 gcode << writer.extrude_to_xy(p4, dE);
159 gcode << writer.extrude_to_xy(gap_p0_toward_p3, two_dE);
160 break;
161 case '1':
162 gcode << move_to(p0_5, writer, "Glyph: 1");
163 gcode << writer.extrude_to_xy(p4_5, two_dE);
164 break;
165 case '2':
166 gcode << move_to(p0, writer, "Glyph: 2");
167 gcode << writer.extrude_to_xy(p1, dE);
168 gcode << writer.extrude_to_xy(p2, dE);
169 gcode << writer.extrude_to_xy(p3, dE);
170 gcode << writer.extrude_to_xy(p4, dE);
171 gcode << writer.extrude_to_xy(p5, dE);
172 break;
173 case '3':
174 gcode << move_to(p0, writer, "Glyph: 3");
175 gcode << writer.extrude_to_xy(p1, dE);
176 gcode << writer.extrude_to_xy(p5, two_dE);
177 gcode << writer.extrude_to_xy(p4, dE);
178 gcode << move_to(gap_p2_toward_p3, writer);
179 gcode << writer.extrude_to_xy(p3, dE);
180 break;
181 case '4':
182 gcode << move_to(p0, writer, "Glyph: 4");
183 gcode << writer.extrude_to_xy(p3, dE);
184 gcode << writer.extrude_to_xy(p2, dE);
185 gcode << move_to(p1, writer);
186 gcode << writer.extrude_to_xy(p5, two_dE);
187 break;
188 case '5':
189 gcode << move_to(p1, writer, "Glyph: 5");
190 gcode << writer.extrude_to_xy(p0, dE);
191 gcode << writer.extrude_to_xy(p3, dE);
192 gcode << writer.extrude_to_xy(p2, dE);
193 gcode << writer.extrude_to_xy(p5, dE);
194 gcode << writer.extrude_to_xy(p4, dE);
195 break;
196 case '6':
197 gcode << move_to(p1, writer, "Glyph: 6");
198 gcode << writer.extrude_to_xy(p0, dE);
199 gcode << writer.extrude_to_xy(p4, two_dE);
200 gcode << writer.extrude_to_xy(p5, dE);
201 gcode << writer.extrude_to_xy(p2, dE);
202 gcode << writer.extrude_to_xy(p3, dE);
203 break;
204 case '7':
205 gcode << move_to(p0, writer, "Glyph: 7");
206 gcode << writer.extrude_to_xy(p1, dE);
207 gcode << writer.extrude_to_xy(p5, two_dE);
208 break;
209 case '8':
210 gcode << move_to(p2, writer, "Glyph: 8");
211 gcode << writer.extrude_to_xy(p3, dE);
212 gcode << writer.extrude_to_xy(p4, dE);
213 gcode << writer.extrude_to_xy(p5, dE);
214 gcode << writer.extrude_to_xy(p1, two_dE);
215 gcode << writer.extrude_to_xy(p0, dE);
216 gcode << writer.extrude_to_xy(p3, dE);
217 break;
218 case '9':
219 gcode << move_to(p5, writer, "Glyph: 9");
220 gcode << writer.extrude_to_xy(p1, two_dE);
221 gcode << writer.extrude_to_xy(p0, dE);
222 gcode << writer.extrude_to_xy(p3, dE);
223 gcode << writer.extrude_to_xy(p2, dE);
224 break;
225 case '.':
226 gcode << move_to(p4_5, writer, "Glyph: .");
227 gcode << writer.extrude_to_xy(p4_5 + dot_direction, dE);
228 break;
229 default: break;
230 }
231
232 return gcode.str();
233}
const double m_digit_segment_len
Definition calib.hpp:251
double e_per_mm(double line_width, double layer_height, float nozzle_diameter, float filament_diameter, float print_flow_ratio) const
Definition calib.cpp:73

References Bottom_To_Top, e_per_mm(), Slic3r::GCodeWriter::extrude_to_xy(), m_digit_segment_len, and move_to().

Referenced by draw_number().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ draw_line()

std::string Slic3r::CalibPressureAdvance::draw_line ( GCodeWriter & writer,
Vec2d to_pt,
double line_width,
double layer_height,
double speed,
const std::string & comment = std::string() )
protectedinherited
271{
272 const double e_per_mm = CalibPressureAdvance::e_per_mm(line_width, layer_height,
273 m_config.option<ConfigOptionFloats>("nozzle_diameter")->get_at(0),
274 m_config.option<ConfigOptionFloats>("filament_diameter")->get_at(0),
275 m_config.option<ConfigOptionFloatsNullable>("filament_flow_ratio")->get_at(0));
276
277 const double length = get_distance(Vec2d(m_last_pos.x(), m_last_pos.y()), to_pt);
278 auto dE = e_per_mm * length;
279
280 std::stringstream gcode;
281
282 gcode << writer.set_speed(speed);
283 gcode << writer.extrude_to_xy(to_pt, dE, comment);
284
285 m_last_pos = Vec3d(to_pt.x(), to_pt.y(), 0);
286
287 return gcode.str();
288}
Vec3d m_last_pos
Definition calib.hpp:246
double get_distance(Vec2d from, Vec2d to) const
Definition calib.cpp:264
const double & get_at(size_t i) const
Definition Config.hpp:676
double length(const Points &pts)
Definition MultiPoint.hpp:181
layer_height((ConfigOptionInt, faded_layers))((ConfigOptionFloat
ConfigOptionFloatsTempl< true > ConfigOptionFloatsNullable
Definition Config.hpp:1016
ConfigOptionFloatsTempl< false > ConfigOptionFloats
Definition Config.hpp:1015

References e_per_mm(), Slic3r::GCodeWriter::extrude_to_xy(), get_distance(), Slic3r::layer_height(), Slic3r::length(), m_config, m_last_pos, and Slic3r::GCodeWriter::set_speed().

Referenced by draw_box(), and Slic3r::CalibPressureAdvancePattern::generate_custom_gcodes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ draw_number()

std::string Slic3r::CalibPressureAdvance::draw_number ( double startx,
double starty,
double value,
CalibPressureAdvance::DrawDigitMode mode,
double line_width,
double e_per_mm,
double speed,
GCodeWriter & writer )
protectedinherited
243{
244 auto sNumber = convert_number_to_string(value, m_number_len);
245 std::stringstream gcode;
246 gcode << writer.set_speed(speed);
247
248 for (std::string::size_type i = 0; i < sNumber.length(); ++i) {
249 if (i >= m_number_len) {
250 break;
251 }
252 switch (mode) {
254 gcode << draw_digit(startx, starty + i * number_spacing(), sNumber[i], mode, line_width, e_per_mm, writer);
255 break;
256 default: gcode << draw_digit(startx + i * number_spacing(), starty, sNumber[i], mode, line_width, e_per_mm, writer);
257 }
258 }
259
260 return gcode.str();
261}
std::string convert_number_to_string(double num, unsigned precision=0) const
Definition calib.cpp:82
std::string draw_digit(double startx, double starty, char c, CalibPressureAdvance::DrawDigitMode mode, double line_width, double e_per_mm, GCodeWriter &writer)
Definition calib.cpp:98
double number_spacing() const
Definition calib.hpp:222
std::string::size_type m_number_len
Definition calib.hpp:254

References Bottom_To_Top, convert_number_to_string(), draw_digit(), e_per_mm(), m_number_len, number_spacing(), and Slic3r::GCodeWriter::set_speed().

Referenced by Slic3r::CalibPressureAdvancePattern::generate_custom_gcodes(), and Slic3r::CalibPressureAdvanceLine::print_pa_lines().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ e_per_mm()

double Slic3r::CalibPressureAdvance::e_per_mm ( double line_width,
double layer_height,
float nozzle_diameter,
float filament_diameter,
float print_flow_ratio ) const
protectedinherited
75{
76 const Flow line_flow = Flow(line_width, layer_height, nozzle_diameter);
77 const double filament_area = M_PI * std::pow(filament_diameter / 2, 2);
78
79 return line_flow.mm3_per_mm() * print_flow_ratio / filament_area ;
80}
zaa_minimize_perimeter_height nozzle_diameter((ConfigOptionBool, reduce_infill_retraction))((ConfigOptionBool
print_flow_ratio((ConfigOptionFloatOrPercent, seam_gap))((ConfigOptionBool

References Slic3r::layer_height(), M_PI, Slic3r::Flow::mm3_per_mm(), Slic3r::nozzle_diameter(), and Slic3r::print_flow_ratio().

Referenced by draw_digit(), draw_line(), draw_number(), Slic3r::CalibPressureAdvancePattern::generate_custom_gcodes(), and Slic3r::CalibPressureAdvanceLine::print_pa_lines().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_optimal_PA_speed()

float Slic3r::CalibPressureAdvance::find_optimal_PA_speed ( const DynamicPrintConfig & config,
double line_width,
double layer_height,
int extruder_id = 0,
int filament_idx = 0 )
staticinherited
30{
31 const double general_suggested_min_speed = 100.0;
32 // Read defensively — CLI callers may hand us a config missing optional keys.
33 auto vector_at = [&config](const char *key, int idx) -> double {
34 if (const auto *o = config.option<ConfigOptionFloats>(key)) return o->get_at(idx);
35 const ConfigOptionDef *d = config.def() ? config.def()->get(key) : nullptr;
36 return (d && d->default_value) ? d->get_default_value<ConfigOptionFloats>()->get_at(idx) : 0.0;
37 };
38 auto nullable_at = [&config](const char *key, int idx) -> double {
39 if (const auto *o = config.option<ConfigOptionFloatsNullable>(key)) return o->get_at(idx);
40 const ConfigOptionDef *d = config.def() ? config.def()->get(key) : nullptr;
41 return (d && d->default_value) ? d->get_default_value<ConfigOptionFloatsNullable>()->get_at(idx) : 0.0;
42 };
43 double filament_max_volumetric_speed = vector_at("filament_max_volumetric_speed", filament_idx);
44 // todo multi_extruders:
45 const float nozzle_diameter = vector_at("nozzle_diameter", extruder_id);
46 if (line_width <= 0.) line_width = Flow::auto_extrusion_width(frPerimeter, nozzle_diameter);
47 Flow pattern_line = Flow(line_width, layer_height, nozzle_diameter);
48 auto pa_speed = std::min(std::max(general_suggested_min_speed, nullable_at("outer_wall_speed", extruder_id)),
49 filament_max_volumetric_speed / pattern_line.mm3_per_mm());
50
51 return std::floor(pa_speed);
52}
static float auto_extrusion_width(FlowRole role, float nozzle_diameter)
Definition Flow.cpp:27
@ frPerimeter
Definition Flow.hpp:20

References Slic3r::Flow::auto_extrusion_width(), Slic3r::DynamicPrintConfig::def(), Slic3r::ConfigOptionDef::default_value, Slic3r::frPerimeter, Slic3r::ConfigDef::get(), Slic3r::ConfigOptionDef::get_default_value(), Slic3r::layer_height(), Slic3r::Flow::mm3_per_mm(), Slic3r::nozzle_diameter(), and Slic3r::ConfigBase::option().

Referenced by Slic3r::GUI::Plater::_calib_pa_pattern(), Slic3r::GCode::_do_export(), Slic3r::GUI::CalibUtils::calib_pa_pattern(), and Slic3r::GUI::CalibUtils::set_for_auto_pa_model_and_config().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ flow_val()

double Slic3r::CalibPressureAdvancePattern::flow_val ( ) const
632{
633 double flow_mult = m_config.option<ConfigOptionFloats>("filament_flow_ratio")->get_at(0);
634 double nozzle_diameter = m_config.option<ConfigOptionFloats>("nozzle_diameter")->get_at(0);
635 double line_width = m_config.get_abs_value("line_width", nozzle_diameter);
637 double layer_height = m_config.get_abs_value("layer_height");
638 double speed = speed_perimeter();
639 Flow pattern_line = Flow(line_width, layer_height, nozzle_diameter);
640
641 return speed * pattern_line.mm3_per_mm() * flow_mult;
642};
double line_width() const
Definition calib.cpp:841
double speed_perimeter() const
Definition calib.hpp:333

References Slic3r::Flow::auto_extrusion_width(), Slic3r::frPerimeter, Slic3r::layer_height(), line_width(), Slic3r::CalibPressureAdvance::m_config, Slic3r::Flow::mm3_per_mm(), Slic3r::nozzle_diameter(), and speed_perimeter().

Referenced by generate_custom_gcodes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ frame_size_y()

double Slic3r::CalibPressureAdvancePattern::frame_size_y ( ) const
inlineprivate
361{ return std::sin(to_radians(double(m_corner_angle) / 2)) * m_wall_side_length * 2; };

References m_corner_angle, m_wall_side_length, and Slic3r::CalibPressureAdvance::to_radians().

Referenced by generate_custom_gcodes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ generate_custom_gcodes()

CustomGCode::Info Slic3r::CalibPressureAdvancePattern::generate_custom_gcodes ( const DynamicPrintConfig & config,
bool is_bbl_machine,
const ModelObject & object,
const Vec3d & origin )
648{
649 std::stringstream gcode;
650 gcode << "; start pressure advance pattern for layer\n";
651
652 refresh_setup(config, is_bbl_machine, object, origin);
653
654 gcode << move_to(Vec2d(m_starting_point.x(), m_starting_point.y()), *m_writer, "Move to start XY position");
655 gcode << m_writer->travel_to_z(height_first_layer() + height_z_offset(), "Move to start Z position");
656 gcode << m_writer->set_pressure_advance(m_params.start);
657
658 const DrawBoxOptArgs default_box_opt_args(wall_count(), height_first_layer(), line_width_first_layer(),
660
661 // create anchoring frame
662 //pattern uses outer wall speed/width
664 gcode << draw_box(*m_writer, m_starting_point.x(), m_starting_point.y(), print_size_x(), frame_size_y(), default_box_opt_args);
665
666 // create tab for numbers
667 DrawBoxOptArgs draw_box_opt_args = default_box_opt_args;
668 draw_box_opt_args.is_filled = true;
669 draw_box_opt_args.num_perimeters = wall_count();
670 //draw box as bottom surface, so numbers are clearly visible on top
671 gcode << ";" << GCodeProcessor::reserved_tag(GCodeProcessor::ETags::Role) << "Bottom surface\n";
673 print_size_x(),
675
676 std::vector<CustomGCode::Item> gcode_items;
677 const int num_patterns = get_num_patterns(); // "cache" for use in loops
678
679 const double zhop_config_value = m_config.option<ConfigOptionFloats>("z_hop")->get_at(0);
680 const auto accel = accel_perimeter();
681
682 // Draw pressure advance pattern
683 // pattern uses outer wall speed, label it as such
685 for (int i = 0; i < m_num_layers; ++i) {
686 const double layer_height = height_first_layer() + height_z_offset() + (i * height_layer());
687 const double zhop_height = layer_height + zhop_config_value;
688
689 if (i > 0) {
690 gcode << "; end pressure advance pattern for layer\n";
691 CustomGCode::Item item;
692 item.print_z = height_first_layer() + (i - 1) * height_layer();
693 item.type = CustomGCode::Type::Custom;
694 item.extra = gcode.str();
695 gcode_items.push_back(item);
696
697 gcode = std::stringstream(); // reset for next layer contents
698 gcode << "; start pressure advance pattern for layer\n";
699
700 gcode << m_writer->travel_to_z(layer_height, "Move to layer height");
701 gcode << m_writer->reset_e();
702 }
703
704 // line numbering
705 if (i == 1) {
707
708 gcode << m_writer->set_pressure_advance(m_params.start);
709
710 double number_e_per_mm = e_per_mm(line_width(), height_layer(),
711 m_config.option<ConfigOptionFloats>("nozzle_diameter")->get_at(0),
712 m_config.option<ConfigOptionFloats>("filament_diameter")->get_at(0),
713 m_config.option<ConfigOptionFloats>("filament_flow_ratio")->get_at(0));
714
715 // glyph on every other line
717 for (int j = 0; j < num_patterns; j += 2) {
719 m_params.start + (j * m_params.step), m_draw_digit_mode, line_width(), number_e_per_mm,
721 }
722
723 // flow value
724 int line_num = num_patterns + 2;
726 flow_val(), m_draw_digit_mode, line_width(), number_e_per_mm,
728
729 // acceleration
730 line_num = num_patterns + 4;
732 accel, m_draw_digit_mode, line_width(), number_e_per_mm,
734 }
735
736
737 double to_x = m_starting_point.x() + pattern_shift();
738 double to_y = m_starting_point.y();
739 double side_length = m_wall_side_length;
740
741 // shrink first layer to fit inside frame
742 if (i == 0) {
744 std::sin(to_radians(m_corner_angle) / 2);
745 side_length = m_wall_side_length - shrink;
746 to_x += shrink * std::sin(to_radians(90) - to_radians(m_corner_angle) / 2);
748 } else {
749 /* Draw a line at slightly slower accel and speed in order to trick gcode writer to force update acceleration and speed.
750 * We do this since several tests may be generated by their own gcode writers which are
751 * not aware about their neighbours updating acceleration/speed */
752 gcode << m_writer->set_print_acceleration(std::max<int>(1, accel - 1));
753 gcode << move_to(Vec2d(m_starting_point.x(), m_starting_point.y()), *m_writer, "Move to starting point", zhop_height, layer_height);
754 gcode << draw_line(*m_writer, Vec2d(m_starting_point.x(), m_starting_point.y() + frame_size_y()), line_width(), height_layer(), speed_adjust(std::max<int>(1, speed_perimeter() - 1)), "Accel/flow trick line");
755 gcode << m_writer->set_print_acceleration(accel);
756 }
757
758 double initial_x = to_x;
759 double initial_y = to_y;
760
761 gcode << move_to(Vec2d(to_x, to_y), *m_writer, "Move to pattern start",zhop_height,layer_height);
762
763 for (int j = 0; j < num_patterns; ++j) {
764 // increment pressure advance
765 gcode << m_writer->set_pressure_advance(m_params.start + (j * m_params.step));
767 for (int k = 0; k < wall_count(); ++k) {
768 to_x += std::cos(to_radians(m_corner_angle) / 2) * side_length;
769 to_y += std::sin(to_radians(m_corner_angle) / 2) * side_length;
770
771 auto draw_line_arg_height = i == 0 ? height_first_layer() : height_layer();
772 auto draw_line_arg_line_width = line_width(); // don't use line_width_first_layer so results are consistent across all layers
773 auto draw_line_arg_speed = i == 0 ? speed_adjust(speed_first_layer()) : speed_adjust(speed_perimeter());
774 auto draw_line_arg_comment = "Print pattern wall";
775 gcode << draw_line(*m_writer, Vec2d(to_x, to_y), draw_line_arg_line_width, draw_line_arg_height, draw_line_arg_speed, draw_line_arg_comment);
776
777 to_x -= std::cos(to_radians(m_corner_angle) / 2) * side_length;
778 to_y += std::sin(to_radians(m_corner_angle) / 2) * side_length;
779
780 gcode << draw_line(*m_writer, Vec2d(to_x, to_y), draw_line_arg_line_width, draw_line_arg_height, draw_line_arg_speed, draw_line_arg_comment);
781
782 to_y = initial_y;
783 if (k != wall_count() - 1) {
784 // perimeters not done yet. move to next perimeter
785 to_x += line_spacing_angle();
786 gcode << move_to(Vec2d(to_x, to_y), *m_writer, "Move to start next pattern wall", zhop_height, layer_height); // Call move to command with XY as well as z hop and layer height to invoke and undo z lift
787 } else if (j != num_patterns - 1) {
788 // patterns not done yet. move to next pattern
789 to_x += m_pattern_spacing + line_width();
790 gcode << move_to(Vec2d(to_x, to_y), *m_writer, "Move to next pattern", zhop_height, layer_height); // Call move to command with XY as well as z hop and layer height to invoke and undo z lift
791 } else if (i != m_num_layers - 1) {
792 // layers not done yet. move back to start
793 to_x = initial_x;
794 gcode << move_to(Vec2d(to_x, to_y), *m_writer, "Move back to start position", zhop_height, layer_height); // Call move to command with XY as well as z hop and layer height to invoke and undo z lift
795 gcode << m_writer->reset_e(); // reset extruder before printing placeholder cube to avoid over extrusion
796 } else {
797 // everything done
798 }
799 }
800 }
801 }
802
803 gcode << m_writer->reset_e();
804 gcode << m_writer->set_pressure_advance(m_params.start);
805 gcode << "; end pressure advance pattern for layer\n";
806
807 CustomGCode::Item item;
808 item.print_z = max_layer_z();
809 item.type = CustomGCode::Type::Custom;
810 item.extra = gcode.str();
811 gcode_items.push_back(item);
812
813 CustomGCode::Info info;
815 info.gcodes = gcode_items;
816
817 return info;
818}
double pattern_shift() const
Definition calib.cpp:997
const int get_num_patterns() const
Definition calib.hpp:347
double flow_val() const
Definition calib.cpp:631
double max_numbering_height() const
Definition calib.cpp:991
int wall_count() const
Definition calib.hpp:337
double speed_first_layer() const
Definition calib.hpp:332
double line_width_first_layer() const
Definition calib.cpp:831
double height_z_offset() const
Definition calib.hpp:345
double max_layer_z() const
Definition calib.hpp:322
double height_first_layer() const
Definition calib.hpp:344
friend struct DrawBoxOptArgs
Definition calib.hpp:311
double line_spacing_angle() const
Definition calib.hpp:357
double accel_perimeter() const
Definition calib.hpp:334
double print_size_x() const
Definition calib.hpp:320
const int m_num_layers
Definition calib.hpp:382
double line_spacing_first_layer() const
Definition calib.hpp:356
const double m_glyph_padding_vertical
Definition calib.hpp:389
double frame_size_y() const
Definition calib.hpp:361
size_t max_numbering_length() const
Definition calib.cpp:969
double height_layer() const
Definition calib.hpp:346
const int m_pattern_spacing
Definition calib.hpp:386
double glyph_start_x(int pattern_i=0) const
Definition calib.cpp:925
std::string draw_box(GCodeWriter &writer, double min_x, double min_y, double size_x, double size_y, DrawBoxOptArgs opt_args)
Definition calib.cpp:290
double speed_adjust(int speed) const
Definition calib.hpp:219
std::string draw_number(double startx, double starty, double value, CalibPressureAdvance::DrawDigitMode mode, double line_width, double e_per_mm, double speed, GCodeWriter &writer)
Definition calib.cpp:235
static const std::string & reserved_tag(ETags tag)
Definition GCodeProcessor.hpp:636
@ Role
Definition GCodeProcessor.hpp:604
@ SingleExtruder
Definition CustomGCode.hpp:56
@ Custom
Definition CustomGCode.hpp:23
Slic3r::Polygons shrink(const Slic3r::Polygons &polygons, const float delta, JoinType joinType=DefaultJoinType, double miterLimit=DefaultMiterLimit)
Definition ClipperUtils.hpp:406

References accel_perimeter(), Slic3r::CustomGCode::Custom, Slic3r::CalibPressureAdvance::draw_box(), Slic3r::CalibPressureAdvance::draw_line(), Slic3r::CalibPressureAdvance::draw_number(), DrawBoxOptArgs, Slic3r::CalibPressureAdvance::e_per_mm(), Slic3r::CustomGCode::Item::extra, flow_val(), frame_size_y(), Slic3r::CustomGCode::Info::gcodes, get_num_patterns(), glyph_start_x(), height_first_layer(), height_layer(), height_z_offset(), Slic3r::DrawBoxOptArgs::is_filled, Slic3r::layer_height(), line_spacing_angle(), line_spacing_first_layer(), line_width(), line_width_first_layer(), Slic3r::CalibPressureAdvance::m_config, m_corner_angle, Slic3r::CalibPressureAdvance::m_draw_digit_mode, Slic3r::CalibPressureAdvance::m_encroachment, m_glyph_padding_vertical, m_num_layers, Slic3r::CalibPressureAdvance::m_number_len, m_params, m_pattern_spacing, m_starting_point, m_wall_side_length, m_writer, max_layer_z(), max_numbering_height(), max_numbering_length(), Slic3r::CustomGCode::Info::mode, Slic3r::CalibPressureAdvance::move_to(), Slic3r::DrawBoxOptArgs::num_perimeters, pattern_shift(), print_size_x(), Slic3r::CustomGCode::Item::print_z, refresh_setup(), Slic3r::GCodeProcessor::reserved_tag(), Slic3r::GCodeProcessor::Role, Slic3r::shrink(), Slic3r::CustomGCode::SingleExtruder, Slic3r::CalibPressureAdvance::speed_adjust(), speed_first_layer(), speed_perimeter(), Slic3r::CalibPressureAdvance::to_radians(), Slic3r::CustomGCode::Item::type, and wall_count().

Referenced by Slic3r::GUI::CalibUtils::calib_pa_pattern().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_distance()

double Slic3r::CalibPressureAdvance::get_distance ( Vec2d from,
Vec2d to ) const
protectedinherited
265{
266 return std::hypot((to.x() - from.x()), (to.y() - from.y()));
267}

Referenced by draw_line().

Here is the caller graph for this function:

◆ get_num_patterns()

const int Slic3r::CalibPressureAdvancePattern::get_num_patterns ( ) const
inlineprivate
347{ return std::ceil((m_params.end - m_params.start) / m_params.step + 1); }

References m_params.

Referenced by generate_custom_gcodes(), glyph_tab_max_x(), max_numbering_length(), and object_size_x().

Here is the caller graph for this function:

◆ get_start_offset()

Vec3d Slic3r::CalibPressureAdvancePattern::get_start_offset ( )
827{
828 return m_starting_point;
829}

References m_starting_point.

◆ glyph_length_x()

double Slic3r::CalibPressureAdvancePattern::glyph_length_x ( ) const
private
951{
952 // half of line_width sticks out on each side
953 return line_width() + (2 * m_digit_segment_len);
954}

References line_width(), and Slic3r::CalibPressureAdvance::m_digit_segment_len.

Referenced by glyph_start_x(), and glyph_tab_max_x().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ glyph_start_x()

double Slic3r::CalibPressureAdvancePattern::glyph_start_x ( int pattern_i = 0) const
private
926{
927 // note that pattern_i is zero-based!
928 // align glyph's start with first perimeter of specified pattern
929 double x =
930 // starting offset
932
933 // width of pattern extrusions
934 pattern_i * (wall_count() - 1) * line_spacing_angle() + // center to center distance of extrusions
935 pattern_i * line_width() + // endcaps. center to end on either side = 1 line width
936
937 // space between each pattern
938 pattern_i * m_pattern_spacing;
939
940 // align to middle of pattern walls
941 x += wall_count() * line_spacing_angle() / 2;
942
943 // shift so glyph is centered on pattern
944 // m_digit_segment_len = half of X length of glyph
945 x -= (glyph_length_x() / 2);
946
947 return x;
948}
double glyph_length_x() const
Definition calib.cpp:950

References glyph_length_x(), line_spacing_angle(), line_width(), m_pattern_spacing, m_starting_point, pattern_shift(), and wall_count().

Referenced by generate_custom_gcodes(), and glyph_tab_max_x().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ glyph_tab_max_x()

double Slic3r::CalibPressureAdvancePattern::glyph_tab_max_x ( ) const
private
957{
958 // only every other glyph is shown, starting with 1
959 int num = get_num_patterns();
960 int max_num = (num % 2 == 0) ? num - 1 : num;
961
962 // padding at end should be same as padding at start
963 double padding = glyph_start_x(0) - m_starting_point.x();
964
965 return glyph_start_x(max_num - 1) + // glyph_start_x is zero-based
966 (glyph_length_x() - line_width() / 2) + padding;
967}

References get_num_patterns(), glyph_length_x(), glyph_start_x(), line_width(), and m_starting_point.

Here is the call graph for this function:

◆ handle_pos_offset()

Vec3d Slic3r::CalibPressureAdvancePattern::handle_pos_offset ( ) const
625{
626 return Vec3d{0 - print_size_x() / 2 + handle_xy_size() / 2 + handle_spacing(),
628 max_layer_z() / 2};
629}
double handle_spacing() const
Definition calib.hpp:318
double handle_xy_size() const
Definition calib.hpp:317

References handle_spacing(), handle_xy_size(), m_glyph_padding_vertical, max_layer_z(), max_numbering_height(), and print_size_x().

Referenced by Slic3r::GUI::Plater::_calib_pa_pattern().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ handle_spacing()

double Slic3r::CalibPressureAdvancePattern::handle_spacing ( ) const
inline
318{ return m_handle_spacing; };

References m_handle_spacing.

Referenced by handle_pos_offset().

Here is the caller graph for this function:

◆ handle_xy_size()

double Slic3r::CalibPressureAdvancePattern::handle_xy_size ( ) const
inline
317{ return m_handle_xy_size; };
const double m_handle_xy_size
Definition calib.hpp:380

References m_handle_xy_size.

Referenced by Slic3r::GUI::Plater::_calib_pa_pattern(), and handle_pos_offset().

Here is the caller graph for this function:

◆ height_first_layer()

double Slic3r::CalibPressureAdvancePattern::height_first_layer ( ) const
inlineprivate
344{ return m_config.option<ConfigOptionFloat>("initial_layer_print_height")->value; };
zaa_minimize_perimeter_height ConfigOptionFloat
Definition PrintConfig.hpp:1954

References Slic3r::CalibPressureAdvance::m_config.

Referenced by generate_custom_gcodes(), line_spacing_first_layer(), and max_layer_z().

Here is the caller graph for this function:

◆ height_layer()

double Slic3r::CalibPressureAdvancePattern::height_layer ( ) const
inlineprivate
346{ return m_config.option<ConfigOptionFloat>("layer_height")->value; };

References Slic3r::CalibPressureAdvance::m_config.

Referenced by generate_custom_gcodes(), line_spacing(), and max_layer_z().

Here is the caller graph for this function:

◆ height_z_offset()

double Slic3r::CalibPressureAdvancePattern::height_z_offset ( ) const
inlineprivate
345{ return m_config.option<ConfigOptionFloat>("z_offset")->value; };

References Slic3r::CalibPressureAdvance::m_config.

Referenced by generate_custom_gcodes().

Here is the caller graph for this function:

◆ line_spacing()

double Slic3r::CalibPressureAdvancePattern::line_spacing ( ) const
inlineprivate
355{ return line_width() - height_layer() * (1 - M_PI / 4); };

References height_layer(), line_width(), and M_PI.

Referenced by line_spacing_angle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ line_spacing_angle()

double Slic3r::CalibPressureAdvancePattern::line_spacing_angle ( ) const
inlineprivate
357{ return line_spacing() / std::sin(to_radians(m_corner_angle) / 2); };
double line_spacing() const
Definition calib.hpp:355

References line_spacing(), m_corner_angle, and Slic3r::CalibPressureAdvance::to_radians().

Referenced by generate_custom_gcodes(), glyph_start_x(), and object_size_x().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ line_spacing_first_layer()

double Slic3r::CalibPressureAdvancePattern::line_spacing_first_layer ( ) const
inlineprivate
356{ return line_width_first_layer() - height_first_layer() * (1 - M_PI / 4); };

References height_first_layer(), line_width_first_layer(), and M_PI.

Referenced by generate_custom_gcodes(), object_size_x(), and pattern_shift().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ line_width()

double Slic3r::CalibPressureAdvancePattern::line_width ( ) const
protected
842{
843 // TODO: FIXME: find out current filament/extruder?
844 const double nozzle_diameter = m_config.opt_float("nozzle_diameter", 0);
845 const double width = m_config.get_abs_value("line_width", nozzle_diameter);
846 if (width <= 0.)
848 return width;
849};
coord_t width(const BoundingBox &box)
Definition Arrange.cpp:1184
@ frExternalPerimeter
Definition Flow.hpp:19

References Slic3r::Flow::auto_extrusion_width(), Slic3r::frExternalPerimeter, Slic3r::CalibPressureAdvance::m_config, and Slic3r::nozzle_diameter().

Referenced by flow_val(), generate_custom_gcodes(), glyph_length_x(), glyph_start_x(), glyph_tab_max_x(), line_spacing(), and object_size_x().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ line_width_first_layer()

double Slic3r::CalibPressureAdvancePattern::line_width_first_layer ( ) const
protected
832{
833 // TODO: FIXME: find out current filament/extruder?
834 const double nozzle_diameter = m_config.opt_float("nozzle_diameter", m_params.extruder_id);
835 const double width = m_config.get_abs_value("initial_layer_line_width", nozzle_diameter);
836 if (width <= 0.)
838 return width;
839};

References Slic3r::Flow::auto_extrusion_width(), Slic3r::frExternalPerimeter, Slic3r::CalibPressureAdvance::m_config, m_params, and Slic3r::nozzle_diameter().

Referenced by generate_custom_gcodes(), line_spacing_first_layer(), object_size_y(), and pattern_shift().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ max_layer_z()

double Slic3r::CalibPressureAdvancePattern::max_layer_z ( ) const
inline
322{ return height_first_layer() + ((m_num_layers - 1) * height_layer()); };

References height_first_layer(), height_layer(), and m_num_layers.

Referenced by Slic3r::GUI::Plater::_calib_pa_pattern(), generate_custom_gcodes(), and handle_pos_offset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ max_numbering_height()

double Slic3r::CalibPressureAdvancePattern::max_numbering_height ( ) const
private
992{
993 std::string::size_type num_characters = max_numbering_length();
994 return (num_characters * m_digit_segment_len) + ((num_characters - 1) * m_digit_gap_len);
995}
const double m_digit_gap_len
Definition calib.hpp:252

References Slic3r::CalibPressureAdvance::m_digit_gap_len, Slic3r::CalibPressureAdvance::m_digit_segment_len, and max_numbering_length().

Referenced by generate_custom_gcodes(), handle_pos_offset(), and object_size_y().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ max_numbering_length()

size_t Slic3r::CalibPressureAdvancePattern::max_numbering_length ( ) const
private
970{
971 std::string::size_type most_characters = 0;
972 const int num_patterns = get_num_patterns();
973
974 // note: only every other number is printed
975 for (std::string::size_type i = 0; i < num_patterns; i += 2) {
976 std::string sNumber = convert_number_to_string(m_params.start + (i * m_params.step));
977
978 if (sNumber.length() > most_characters) {
979 most_characters = sNumber.length();
980 }
981 }
982
983 std::string sAccel = convert_number_to_string(accel_perimeter());
984 most_characters = std::max(most_characters, sAccel.length());
985
986 /* don't actually check flow value: we'll print as many fractional digits as fits */
987
988 return std::min(most_characters, m_max_number_len);
989}
const std::string::size_type m_max_number_len
Definition calib.hpp:253

References accel_perimeter(), Slic3r::CalibPressureAdvance::convert_number_to_string(), get_num_patterns(), Slic3r::CalibPressureAdvance::m_max_number_len, and m_params.

Referenced by generate_custom_gcodes(), and max_numbering_height().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ move_to()

std::string Slic3r::CalibPressureAdvance::move_to ( Vec2d pt,
GCodeWriter & writer,
std::string comment = std::string(),
double z = 0,
double layer_height = -1 )
protectedinherited
55{
56 std::stringstream gcode;
57
58 gcode << writer.retract(); // retract before z move or move
59 if(z > EPSILON && layer_height >= 0){
60 gcode << writer.travel_to_z(z, "Z-hop"); // Perform z hop
61 gcode << writer.travel_to_xy(pt, comment); // Travel with z move
62 gcode << writer.travel_to_z(layer_height, "undo Z-hop"); // Undo z hop
63 }else {
64 gcode << writer.travel_to_xy(pt, comment);
65 }
66 gcode << writer.unretract(); // unretract after z move is complete
67
68 m_last_pos = Vec3d(pt.x(), pt.y(), 0);
69
70 return gcode.str();
71}
#define EPSILON
Definition ColorUtils.cpp:64

References EPSILON, Slic3r::layer_height(), m_last_pos, Slic3r::GCodeWriter::retract(), Slic3r::GCodeWriter::travel_to_xy(), Slic3r::GCodeWriter::travel_to_z(), and Slic3r::GCodeWriter::unretract().

Referenced by draw_box(), draw_digit(), Slic3r::CalibPressureAdvancePattern::generate_custom_gcodes(), and Slic3r::CalibPressureAdvanceLine::print_pa_lines().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ number_spacing()

double Slic3r::CalibPressureAdvance::number_spacing ( ) const
inlineprotectedinherited

References m_digit_gap_len, and m_digit_segment_len.

Referenced by draw_number(), Slic3r::CalibPressureAdvanceLine::print_extents(), and Slic3r::CalibPressureAdvanceLine::print_pa_lines().

Here is the caller graph for this function:

◆ object_size_x()

double Slic3r::CalibPressureAdvancePattern::object_size_x ( ) const
private

References get_num_patterns(), line_spacing_angle(), line_spacing_first_layer(), line_width(), m_corner_angle, m_pattern_spacing, m_wall_side_length, Slic3r::CalibPressureAdvance::to_radians(), and wall_count().

Referenced by print_size_x().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ object_size_y()

double Slic3r::CalibPressureAdvancePattern::object_size_y ( ) const
private

References line_width_first_layer(), m_corner_angle, m_glyph_padding_vertical, m_wall_side_length, max_numbering_height(), and Slic3r::CalibPressureAdvance::to_radians().

Referenced by print_size_y().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pattern_shift()

double Slic3r::CalibPressureAdvancePattern::pattern_shift ( ) const
private
998{
1000}
const double m_glyph_padding_horizontal
Definition calib.hpp:388

References line_spacing_first_layer(), line_width_first_layer(), m_glyph_padding_horizontal, and wall_count().

Referenced by generate_custom_gcodes(), glyph_start_x(), and print_size_x().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_size_x()

double Slic3r::CalibPressureAdvancePattern::print_size_x ( ) const
inline
320{ return object_size_x() + pattern_shift(); };
double object_size_x() const
Definition calib.cpp:912

References object_size_x(), and pattern_shift().

Referenced by Slic3r::GUI::Plater::_calib_pa_pattern(), Slic3r::GUI::CalibUtils::calib_pa_pattern(), generate_custom_gcodes(), and handle_pos_offset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_size_y()

double Slic3r::CalibPressureAdvancePattern::print_size_y ( ) const
inline
321{ return object_size_y(); };
double object_size_y() const
Definition calib.cpp:919

References object_size_y().

Referenced by Slic3r::GUI::Plater::_calib_pa_pattern(), and Slic3r::GUI::CalibUtils::calib_pa_pattern().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ refresh_setup()

void Slic3r::CalibPressureAdvancePattern::refresh_setup ( const DynamicPrintConfig & config,
bool is_bbl_machine,
const ModelObject & object,
const Vec3d & origin )
private
855{
856 m_config = config;
857 m_config.apply(object.config.get(), true);
858 m_config.apply(object.volumes.front()->config.get(), true);
859
861 _refresh_writer(is_bbl_machine, object, origin);
862}
void _refresh_starting_point(const ModelObject &object)
Definition calib.cpp:864
void _refresh_writer(bool is_bbl_machine, const ModelObject &object, const Vec3d &origin)
Definition calib.cpp:876

References _refresh_starting_point(), _refresh_writer(), and Slic3r::CalibPressureAdvance::m_config.

Referenced by CalibPressureAdvancePattern(), and generate_custom_gcodes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_start_offset()

void Slic3r::CalibPressureAdvancePattern::set_start_offset ( const Vec3d & offset)
821{
824}
Slic3r::Polygons offset(const Slic3r::Polygon &polygon, const float delta, JoinType joinType, double miterLimit)
Definition ClipperUtils.cpp:582

References m_is_start_point_fixed, m_starting_point, and Slic3r::offset().

Referenced by Slic3r::GUI::CalibUtils::calib_pa_pattern().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ speed_adjust()

double Slic3r::CalibPressureAdvance::speed_adjust ( int speed) const
inlineprotectedinherited
219{ return speed * 60; };

Referenced by Slic3r::CalibPressureAdvancePattern::generate_custom_gcodes(), and Slic3r::CalibPressureAdvanceLine::print_pa_lines().

Here is the caller graph for this function:

◆ speed_first_layer()

double Slic3r::CalibPressureAdvancePattern::speed_first_layer ( ) const
inlineprotected
332{ return m_config.get_abs_value_at("initial_layer_speed", m_params.extruder_id); };

References Slic3r::CalibPressureAdvance::m_config, and m_params.

Referenced by generate_custom_gcodes().

Here is the caller graph for this function:

◆ speed_perimeter()

double Slic3r::CalibPressureAdvancePattern::speed_perimeter ( ) const
inlineprotected
333{ return m_config.get_abs_value_at("outer_wall_speed", m_params.extruder_id); };

References Slic3r::CalibPressureAdvance::m_config, and m_params.

Referenced by flow_val(), and generate_custom_gcodes().

Here is the caller graph for this function:

◆ to_radians()

double Slic3r::CalibPressureAdvance::to_radians ( double degrees) const
inlineprotectedinherited

◆ wall_count()

int Slic3r::CalibPressureAdvancePattern::wall_count ( ) const
inlineprotected
337{ return m_config.option<ConfigOptionInt>("wall_loops")->value; };

References Slic3r::CalibPressureAdvance::m_config.

Referenced by generate_custom_gcodes(), glyph_start_x(), object_size_x(), and pattern_shift().

Here is the caller graph for this function:

◆ DrawBoxOptArgs

friend struct DrawBoxOptArgs
friend

References DrawBoxOptArgs.

Referenced by DrawBoxOptArgs, and generate_custom_gcodes().

Member Data Documentation

◆ m_config

◆ m_corner_angle

const int Slic3r::CalibPressureAdvancePattern::m_corner_angle {90}
private

◆ m_digit_gap_len

const double Slic3r::CalibPressureAdvance::m_digit_gap_len {1}
protectedinherited

◆ m_digit_segment_len

const double Slic3r::CalibPressureAdvance::m_digit_segment_len {2}
protectedinherited

◆ m_draw_digit_mode

◆ m_encroachment

const double Slic3r::CalibPressureAdvance::m_encroachment {1. / 3.}
protectedinherited

◆ m_glyph_padding_horizontal

const double Slic3r::CalibPressureAdvancePattern::m_glyph_padding_horizontal {1}
private
388{1};

Referenced by pattern_shift().

◆ m_glyph_padding_vertical

const double Slic3r::CalibPressureAdvancePattern::m_glyph_padding_vertical {1}
private

◆ m_handle_spacing

const double Slic3r::CalibPressureAdvancePattern::m_handle_spacing {1.2}
private
381{1.2};

Referenced by _refresh_starting_point(), and handle_spacing().

◆ m_handle_xy_size

const double Slic3r::CalibPressureAdvancePattern::m_handle_xy_size {5}
private
380{5};

Referenced by handle_xy_size().

◆ m_is_start_point_fixed

bool Slic3r::CalibPressureAdvancePattern::m_is_start_point_fixed = false
private

◆ m_last_pos

Vec3d Slic3r::CalibPressureAdvance::m_last_pos
protectedinherited

Referenced by draw_line(), and move_to().

◆ m_max_number_len

const std::string::size_type Slic3r::CalibPressureAdvance::m_max_number_len {5}
protectedinherited

◆ m_num_layers

const int Slic3r::CalibPressureAdvancePattern::m_num_layers {4}
private
382{4};

Referenced by generate_custom_gcodes(), and max_layer_z().

◆ m_number_len

std::string::size_type Slic3r::CalibPressureAdvance::m_number_len {m_max_number_len}
protectedinherited
254{m_max_number_len}; /* Current length of number labels */

Referenced by draw_number(), and Slic3r::CalibPressureAdvancePattern::generate_custom_gcodes().

◆ m_params

◆ m_pattern_spacing

const int Slic3r::CalibPressureAdvancePattern::m_pattern_spacing {2}
private

◆ m_starting_point

Vec3d Slic3r::CalibPressureAdvancePattern::m_starting_point
private

◆ m_wall_side_length

const double Slic3r::CalibPressureAdvancePattern::m_wall_side_length {30.0}
private

◆ m_writer

std::shared_ptr<GCodeWriter> Slic3r::CalibPressureAdvancePattern::m_writer {std::make_shared<GCodeWriter>()}
private
376{std::make_shared<GCodeWriter>()};

Referenced by _refresh_writer(), and generate_custom_gcodes().


The documentation for this class was generated from the following files:
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/calib.hpp
  • /home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/calib.cpp