mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-12 11:37:42 +00:00
Fix pattern drawing, minor misc. clean up
This commit is contained in:
@@ -1904,8 +1904,9 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
|
|||||||
coordf_t print_z;
|
coordf_t print_z;
|
||||||
bool first_layer;
|
bool first_layer;
|
||||||
|
|
||||||
for (int i = 0; i < gcode_layers.size(); ++i) {
|
for (auto i = 0; i < gcode_layers.size(); ++i) {
|
||||||
print_z = pa_test.layer_z()[i];
|
m_nominal_z = pa_test.layer_z()[i];
|
||||||
|
print_z = m_nominal_z;
|
||||||
|
|
||||||
first_layer = (i == 0);
|
first_layer = (i == 0);
|
||||||
m_writer.set_is_first_layer(first_layer);
|
m_writer.set_is_first_layer(first_layer);
|
||||||
@@ -1939,15 +1940,11 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
|
|||||||
}
|
}
|
||||||
|
|
||||||
gcode += m_writer.update_progress(++ m_layer_index, m_layer_count);
|
gcode += m_writer.update_progress(++ m_layer_index, m_layer_count);
|
||||||
m_nominal_z = print_z;
|
|
||||||
|
|
||||||
if (! print.config().layer_change_gcode.value.empty()) {
|
if (! print.config().layer_change_gcode.value.empty()) {
|
||||||
std::cout << "layer_change_gcode found" << std::endl;
|
|
||||||
|
|
||||||
DynamicConfig config;
|
DynamicConfig config;
|
||||||
config.set_key_value("layer_num", new ConfigOptionInt(m_layer_index));
|
config.set_key_value("layer_num", new ConfigOptionInt(m_layer_index));
|
||||||
config.set_key_value("layer_z", new ConfigOptionFloat(print_z));
|
config.set_key_value("layer_z", new ConfigOptionFloat(print_z));
|
||||||
std::cout << "DynamicConfig updated successfully" << std::endl;
|
|
||||||
|
|
||||||
gcode += this->placeholder_parser_process(
|
gcode += this->placeholder_parser_process(
|
||||||
"layer_change_gcode",
|
"layer_change_gcode",
|
||||||
@@ -1955,7 +1952,6 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
|
|||||||
m_writer.extruder()->id(),
|
m_writer.extruder()->id(),
|
||||||
&config
|
&config
|
||||||
) + "\n";
|
) + "\n";
|
||||||
std::cout << "returned from placeholder_parser_process" << std::endl;
|
|
||||||
|
|
||||||
config.set_key_value("max_layer_z", new ConfigOptionFloat(m_max_layer_z));
|
config.set_key_value("max_layer_z", new ConfigOptionFloat(m_max_layer_z));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -655,11 +655,6 @@ std::vector<std::string> CalibPressureAdvancePattern::print_pa_pattern(PatternCa
|
|||||||
std::stringstream gcode;
|
std::stringstream gcode;
|
||||||
std::vector<std::string> gcode_layers;
|
std::vector<std::string> gcode_layers;
|
||||||
|
|
||||||
const DrawLineOptArgs draw_line_basic_settings;
|
|
||||||
DrawLineOptArgs draw_line_opt_args;
|
|
||||||
const DrawBoxOptArgs draw_box_basic_settings;
|
|
||||||
DrawBoxOptArgs draw_box_opt_args;
|
|
||||||
|
|
||||||
gcode << writer.travel_to_xyz(
|
gcode << writer.travel_to_xyz(
|
||||||
Vec3d(calc.pattern_start_x, calc.pattern_start_y, m_height_first_layer),
|
Vec3d(calc.pattern_start_x, calc.pattern_start_y, m_height_first_layer),
|
||||||
"Move to start position"
|
"Move to start position"
|
||||||
@@ -667,7 +662,10 @@ std::vector<std::string> CalibPressureAdvancePattern::print_pa_pattern(PatternCa
|
|||||||
|
|
||||||
gcode << writer.set_pressure_advance(calc.start_pa);
|
gcode << writer.set_pressure_advance(calc.start_pa);
|
||||||
|
|
||||||
// create anchor and line numbering frame
|
const DrawBoxOptArgs draw_box_basic_settings;
|
||||||
|
DrawBoxOptArgs draw_box_opt_args;
|
||||||
|
|
||||||
|
// create anchor frame
|
||||||
gcode << draw_box(
|
gcode << draw_box(
|
||||||
calc.pattern_start_x,
|
calc.pattern_start_x,
|
||||||
calc.pattern_start_y,
|
calc.pattern_start_y,
|
||||||
@@ -679,6 +677,7 @@ std::vector<std::string> CalibPressureAdvancePattern::print_pa_pattern(PatternCa
|
|||||||
// create tab for numbers
|
// create tab for numbers
|
||||||
draw_box_opt_args = draw_box_basic_settings;
|
draw_box_opt_args = draw_box_basic_settings;
|
||||||
draw_box_opt_args.is_filled = true;
|
draw_box_opt_args.is_filled = true;
|
||||||
|
draw_box_opt_args.num_perimeters = m_anchor_perimeters;
|
||||||
gcode << draw_box(
|
gcode << draw_box(
|
||||||
calc.pattern_start_x,
|
calc.pattern_start_x,
|
||||||
calc.pattern_start_y + calc.frame_size_y + line_spacing_anchor(),
|
calc.pattern_start_y + calc.frame_size_y + line_spacing_anchor(),
|
||||||
@@ -696,7 +695,7 @@ std::vector<std::string> CalibPressureAdvancePattern::print_pa_pattern(PatternCa
|
|||||||
|
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
gcode_layers.push_back(gcode.str());
|
gcode_layers.push_back(gcode.str());
|
||||||
std::stringstream().swap(gcode); // reset for next layer contents
|
gcode = std::stringstream(); // reset for next layer contents
|
||||||
|
|
||||||
Point last_pos = mp_gcodegen->last_pos();
|
Point last_pos = mp_gcodegen->last_pos();
|
||||||
std::stringstream comment;
|
std::stringstream comment;
|
||||||
@@ -737,6 +736,9 @@ std::vector<std::string> CalibPressureAdvancePattern::print_pa_pattern(PatternCa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const DrawLineOptArgs draw_line_basic_settings;
|
||||||
|
DrawLineOptArgs draw_line_opt_args;
|
||||||
|
|
||||||
double to_x = calc.pattern_start_x + pattern_shift(calc.num_patterns, calc.center_x);
|
double to_x = calc.pattern_start_x + pattern_shift(calc.num_patterns, calc.center_x);
|
||||||
double to_y = calc.pattern_start_y;
|
double to_y = calc.pattern_start_y;
|
||||||
double side_length = m_wall_side_length;
|
double side_length = m_wall_side_length;
|
||||||
@@ -750,7 +752,7 @@ std::vector<std::string> CalibPressureAdvancePattern::print_pa_pattern(PatternCa
|
|||||||
) / std::sin(to_radians(m_corner_angle) / 2)
|
) / std::sin(to_radians(m_corner_angle) / 2)
|
||||||
;
|
;
|
||||||
side_length = m_wall_side_length - shrink;
|
side_length = m_wall_side_length - shrink;
|
||||||
to_x += shrink + std::sin(to_radians(90) - to_radians(m_corner_angle) / 2);
|
to_x += shrink * std::sin(to_radians(90) - to_radians(m_corner_angle) / 2);
|
||||||
to_y +=
|
to_y +=
|
||||||
line_spacing_anchor() * (m_anchor_perimeters - 1) +
|
line_spacing_anchor() * (m_anchor_perimeters - 1) +
|
||||||
(line_width_anchor() * (1 - m_encroachment))
|
(line_width_anchor() * (1 - m_encroachment))
|
||||||
@@ -774,7 +776,11 @@ std::vector<std::string> CalibPressureAdvancePattern::print_pa_pattern(PatternCa
|
|||||||
draw_line_opt_args.height = i == 0 ? m_height_first_layer : m_height_layer;
|
draw_line_opt_args.height = i == 0 ? m_height_first_layer : m_height_layer;
|
||||||
draw_line_opt_args.speed = i == 0 ? m_speed_first_layer : m_speed_perimeter;
|
draw_line_opt_args.speed = i == 0 ? m_speed_first_layer : m_speed_perimeter;
|
||||||
draw_line_opt_args.comment = "Print pattern wall";
|
draw_line_opt_args.comment = "Print pattern wall";
|
||||||
|
gcode << draw_line(to_x, to_y, draw_line_opt_args);
|
||||||
|
|
||||||
|
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(to_x, to_y, draw_line_opt_args);
|
gcode << draw_line(to_x, to_y, draw_line_opt_args);
|
||||||
|
|
||||||
to_y = initial_y;
|
to_y = initial_y;
|
||||||
|
|||||||
Reference in New Issue
Block a user