mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-09 10:16:50 +00:00
Move logic to Plater
Modifications to model in GCode cancelled _do_export from within itself
This commit is contained in:
@@ -11,7 +11,6 @@
|
|||||||
#include "Print.hpp"
|
#include "Print.hpp"
|
||||||
#include "Utils.hpp"
|
#include "Utils.hpp"
|
||||||
#include "ClipperUtils.hpp"
|
#include "ClipperUtils.hpp"
|
||||||
#include "libslic3r.h"
|
|
||||||
#include "LocalesUtils.hpp"
|
#include "LocalesUtils.hpp"
|
||||||
#include "libslic3r/format.hpp"
|
#include "libslic3r/format.hpp"
|
||||||
#include "Time.hpp"
|
#include "Time.hpp"
|
||||||
@@ -1868,23 +1867,6 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
|
|||||||
}
|
}
|
||||||
if (this->m_objsWithBrim.empty() && this->m_objSupportsWithBrim.empty()) m_brim_done = true;
|
if (this->m_objsWithBrim.empty() && this->m_objSupportsWithBrim.empty()) m_brim_done = true;
|
||||||
|
|
||||||
if (print.calib_params().mode == CalibMode::Calib_PA_Pattern) {
|
|
||||||
const double max_layer_z = CalibPressureAdvancePatternPlate(print.calib_params()).max_layer_z();
|
|
||||||
BoundingBoxf bbox_print;
|
|
||||||
for (const PrintObject* obj : print.objects()) {
|
|
||||||
bbox_print.merge(get_print_object_extrusions_extents(*obj, max_layer_z));
|
|
||||||
}
|
|
||||||
const Vec2d starting_point(bbox_print.min.x(), bbox_print.max.y());
|
|
||||||
|
|
||||||
CalibPressureAdvancePattern pa_pattern(print.calib_params(), this, starting_point);
|
|
||||||
|
|
||||||
Model updated_model = print.model();
|
|
||||||
updated_model.plates_custom_gcodes[print.model().curr_plate_index] = pa_pattern.generate_gcodes();
|
|
||||||
print.set_model(updated_model);
|
|
||||||
|
|
||||||
tool_ordering.assign_custom_gcodes(print);
|
|
||||||
}
|
|
||||||
|
|
||||||
// SoftFever: calib
|
// SoftFever: calib
|
||||||
if (print.calib_params().mode == CalibMode::Calib_PA_Line) {
|
if (print.calib_params().mode == CalibMode::Calib_PA_Line) {
|
||||||
std::string gcode;
|
std::string gcode;
|
||||||
|
|||||||
@@ -692,7 +692,6 @@ public:
|
|||||||
std::vector<ObjectID> print_object_ids() const override;
|
std::vector<ObjectID> print_object_ids() const override;
|
||||||
|
|
||||||
ApplyStatus apply(const Model &model, DynamicPrintConfig config) override;
|
ApplyStatus apply(const Model &model, DynamicPrintConfig config) override;
|
||||||
void set_model(Model m) { m_model = m; }
|
|
||||||
|
|
||||||
void process(bool use_cache = false) override;
|
void process(bool use_cache = false) override;
|
||||||
// Exports G-code into a file name based on the path_template, returns the file path of the generated G-code file.
|
// Exports G-code into a file name based on the path_template, returns the file path of the generated G-code file.
|
||||||
|
|||||||
@@ -10,20 +10,16 @@ CalibPressureAdvance::CalibPressureAdvance(GCode* gcodegen) :
|
|||||||
m_nozzle_diameter(gcodegen->config().nozzle_diameter.get_at(0))
|
m_nozzle_diameter(gcodegen->config().nozzle_diameter.get_at(0))
|
||||||
{ };
|
{ };
|
||||||
|
|
||||||
bool CalibPressureAdvance::is_delta() const
|
std::string CalibPressureAdvance::move_to(Vec2d pt, GCodeWriter& writer, std::string comment)
|
||||||
{
|
|
||||||
return mp_gcodegen->config().printable_area.values.size() > 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string CalibPressureAdvance::move_to(Vec2d pt, std::string comment)
|
|
||||||
{
|
{
|
||||||
std::stringstream gcode;
|
std::stringstream gcode;
|
||||||
GCodeWriter& writer = mp_gcodegen->writer();
|
|
||||||
|
|
||||||
gcode << writer.retract();
|
gcode << writer.retract();
|
||||||
gcode << writer.travel_to_xy(pt, comment);
|
gcode << writer.travel_to_xy(pt, comment);
|
||||||
gcode << writer.unretract();
|
gcode << writer.unretract();
|
||||||
|
|
||||||
|
m_last_pos = pt;
|
||||||
|
|
||||||
return gcode.str();
|
return gcode.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,7 +50,8 @@ std::string CalibPressureAdvance::draw_digit(
|
|||||||
char c,
|
char c,
|
||||||
CalibPressureAdvance::DrawDigitMode mode,
|
CalibPressureAdvance::DrawDigitMode mode,
|
||||||
double line_width,
|
double line_width,
|
||||||
double e_per_mm
|
double e_per_mm,
|
||||||
|
GCodeWriter& writer
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const double len = m_digit_segment_len;
|
const double len = m_digit_segment_len;
|
||||||
@@ -108,22 +105,21 @@ std::string CalibPressureAdvance::draw_digit(
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::stringstream gcode;
|
std::stringstream gcode;
|
||||||
GCodeWriter& writer = mp_gcodegen->writer();
|
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '0':
|
case '0':
|
||||||
gcode << move_to(p0);
|
gcode << move_to(p0, writer);
|
||||||
gcode << writer.extrude_to_xy(p1, dE);
|
gcode << writer.extrude_to_xy(p1, dE);
|
||||||
gcode << writer.extrude_to_xy(p5, two_dE);
|
gcode << writer.extrude_to_xy(p5, two_dE);
|
||||||
gcode << writer.extrude_to_xy(p4, dE);
|
gcode << writer.extrude_to_xy(p4, dE);
|
||||||
gcode << writer.extrude_to_xy(gap_p0_toward_p3, two_dE);
|
gcode << writer.extrude_to_xy(gap_p0_toward_p3, two_dE);
|
||||||
break;
|
break;
|
||||||
case '1':
|
case '1':
|
||||||
gcode << move_to(p0_5);
|
gcode << move_to(p0_5, writer);
|
||||||
gcode << writer.extrude_to_xy(p4_5, two_dE);
|
gcode << writer.extrude_to_xy(p4_5, two_dE);
|
||||||
break;
|
break;
|
||||||
case '2':
|
case '2':
|
||||||
gcode << move_to(p0);
|
gcode << move_to(p0, writer);
|
||||||
gcode << writer.extrude_to_xy(p1, dE);
|
gcode << writer.extrude_to_xy(p1, dE);
|
||||||
gcode << writer.extrude_to_xy(p2, dE);
|
gcode << writer.extrude_to_xy(p2, dE);
|
||||||
gcode << writer.extrude_to_xy(p3, dE);
|
gcode << writer.extrude_to_xy(p3, dE);
|
||||||
@@ -131,22 +127,22 @@ std::string CalibPressureAdvance::draw_digit(
|
|||||||
gcode << writer.extrude_to_xy(p5, dE);
|
gcode << writer.extrude_to_xy(p5, dE);
|
||||||
break;
|
break;
|
||||||
case '3':
|
case '3':
|
||||||
gcode << move_to(p0);
|
gcode << move_to(p0, writer);
|
||||||
gcode << writer.extrude_to_xy(p1, dE);
|
gcode << writer.extrude_to_xy(p1, dE);
|
||||||
gcode << writer.extrude_to_xy(p5, two_dE);
|
gcode << writer.extrude_to_xy(p5, two_dE);
|
||||||
gcode << writer.extrude_to_xy(p4, dE);
|
gcode << writer.extrude_to_xy(p4, dE);
|
||||||
gcode << move_to(gap_p2_toward_p3);
|
gcode << move_to(gap_p2_toward_p3, writer);
|
||||||
gcode << writer.extrude_to_xy(p3, dE);
|
gcode << writer.extrude_to_xy(p3, dE);
|
||||||
break;
|
break;
|
||||||
case '4':
|
case '4':
|
||||||
gcode << move_to(p0);
|
gcode << move_to(p0, writer);
|
||||||
gcode << writer.extrude_to_xy(p3, dE);
|
gcode << writer.extrude_to_xy(p3, dE);
|
||||||
gcode << writer.extrude_to_xy(p2, dE);
|
gcode << writer.extrude_to_xy(p2, dE);
|
||||||
gcode << move_to(p1);
|
gcode << move_to(p1, writer);
|
||||||
gcode << writer.extrude_to_xy(p5, two_dE);
|
gcode << writer.extrude_to_xy(p5, two_dE);
|
||||||
break;
|
break;
|
||||||
case '5':
|
case '5':
|
||||||
gcode << move_to(p1);
|
gcode << move_to(p1, writer);
|
||||||
gcode << writer.extrude_to_xy(p0, dE);
|
gcode << writer.extrude_to_xy(p0, dE);
|
||||||
gcode << writer.extrude_to_xy(p3, dE);
|
gcode << writer.extrude_to_xy(p3, dE);
|
||||||
gcode << writer.extrude_to_xy(p2, dE);
|
gcode << writer.extrude_to_xy(p2, dE);
|
||||||
@@ -154,7 +150,7 @@ std::string CalibPressureAdvance::draw_digit(
|
|||||||
gcode << writer.extrude_to_xy(p4, dE);
|
gcode << writer.extrude_to_xy(p4, dE);
|
||||||
break;
|
break;
|
||||||
case '6':
|
case '6':
|
||||||
gcode << move_to(p1);
|
gcode << move_to(p1, writer);
|
||||||
gcode << writer.extrude_to_xy(p0, dE);
|
gcode << writer.extrude_to_xy(p0, dE);
|
||||||
gcode << writer.extrude_to_xy(p4, two_dE);
|
gcode << writer.extrude_to_xy(p4, two_dE);
|
||||||
gcode << writer.extrude_to_xy(p5, dE);
|
gcode << writer.extrude_to_xy(p5, dE);
|
||||||
@@ -162,12 +158,12 @@ std::string CalibPressureAdvance::draw_digit(
|
|||||||
gcode << writer.extrude_to_xy(p3, dE);
|
gcode << writer.extrude_to_xy(p3, dE);
|
||||||
break;
|
break;
|
||||||
case '7':
|
case '7':
|
||||||
gcode << move_to(p0);
|
gcode << move_to(p0, writer);
|
||||||
gcode << writer.extrude_to_xy(p1, dE);
|
gcode << writer.extrude_to_xy(p1, dE);
|
||||||
gcode << writer.extrude_to_xy(p5, two_dE);
|
gcode << writer.extrude_to_xy(p5, two_dE);
|
||||||
break;
|
break;
|
||||||
case '8':
|
case '8':
|
||||||
gcode << move_to(p2);
|
gcode << move_to(p2, writer);
|
||||||
gcode << writer.extrude_to_xy(p3, dE);
|
gcode << writer.extrude_to_xy(p3, dE);
|
||||||
gcode << writer.extrude_to_xy(p4, dE);
|
gcode << writer.extrude_to_xy(p4, dE);
|
||||||
gcode << writer.extrude_to_xy(p5, dE);
|
gcode << writer.extrude_to_xy(p5, dE);
|
||||||
@@ -176,14 +172,14 @@ std::string CalibPressureAdvance::draw_digit(
|
|||||||
gcode << writer.extrude_to_xy(p3, dE);
|
gcode << writer.extrude_to_xy(p3, dE);
|
||||||
break;
|
break;
|
||||||
case '9':
|
case '9':
|
||||||
gcode << move_to(p5);
|
gcode << move_to(p5, writer);
|
||||||
gcode << writer.extrude_to_xy(p1, two_dE);
|
gcode << writer.extrude_to_xy(p1, two_dE);
|
||||||
gcode << writer.extrude_to_xy(p0, dE);
|
gcode << writer.extrude_to_xy(p0, dE);
|
||||||
gcode << writer.extrude_to_xy(p3, dE);
|
gcode << writer.extrude_to_xy(p3, dE);
|
||||||
gcode << writer.extrude_to_xy(p2, dE);
|
gcode << writer.extrude_to_xy(p2, dE);
|
||||||
break;
|
break;
|
||||||
case '.':
|
case '.':
|
||||||
gcode << move_to(p4_5);
|
gcode << move_to(p4_5, writer);
|
||||||
gcode << writer.extrude_to_xy(p4_5 + dot_direction, dE);
|
gcode << writer.extrude_to_xy(p4_5 + dot_direction, dE);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -199,12 +195,13 @@ std::string CalibPressureAdvance::draw_number(
|
|||||||
double value,
|
double value,
|
||||||
CalibPressureAdvance::DrawDigitMode mode,
|
CalibPressureAdvance::DrawDigitMode mode,
|
||||||
double line_width,
|
double line_width,
|
||||||
double e_per_mm
|
double e_per_mm,
|
||||||
|
GCodeWriter& writer
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
auto sNumber = convert_number_to_string(value);
|
auto sNumber = convert_number_to_string(value);
|
||||||
std::stringstream gcode;
|
std::stringstream gcode;
|
||||||
gcode << mp_gcodegen->writer().set_speed(3600);
|
gcode << writer.set_speed(3600);
|
||||||
|
|
||||||
for (std::string::size_type i = 0; i < sNumber.length(); ++i) {
|
for (std::string::size_type i = 0; i < sNumber.length(); ++i) {
|
||||||
if (i > m_max_number_len) {
|
if (i > m_max_number_len) {
|
||||||
@@ -212,10 +209,10 @@ std::string CalibPressureAdvance::draw_number(
|
|||||||
}
|
}
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case DrawDigitMode::Bottom_To_Top:
|
case DrawDigitMode::Bottom_To_Top:
|
||||||
gcode << draw_digit(startx, starty + i * number_spacing(), sNumber[i], mode, line_width, e_per_mm);
|
gcode << draw_digit(startx, starty + i * number_spacing(), sNumber[i], mode, line_width, e_per_mm, writer);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
gcode << draw_digit(startx + i * number_spacing(), starty, sNumber[i], mode, line_width, e_per_mm);
|
gcode << draw_digit(startx + i * number_spacing(), starty, sNumber[i], mode, line_width, e_per_mm, writer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,6 +256,11 @@ std::string CalibPressureAdvanceLine::generate_test(double start_pa /*= 0*/, dou
|
|||||||
return print_pa_lines(startx, starty, start_pa, step_pa, count);
|
return print_pa_lines(startx, starty, start_pa, step_pa, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CalibPressureAdvanceLine::is_delta() const
|
||||||
|
{
|
||||||
|
return mp_gcodegen->config().printable_area.values.size() > 4;
|
||||||
|
}
|
||||||
|
|
||||||
std::string CalibPressureAdvanceLine::print_pa_lines(double start_x, double start_y, double start_pa, double step_pa, int num)
|
std::string CalibPressureAdvanceLine::print_pa_lines(double start_x, double start_y, double start_pa, double step_pa, int num)
|
||||||
{
|
{
|
||||||
auto& writer = mp_gcodegen->writer();
|
auto& writer = mp_gcodegen->writer();
|
||||||
@@ -288,13 +290,13 @@ std::string CalibPressureAdvanceLine::print_pa_lines(double start_x, double star
|
|||||||
|
|
||||||
// prime line
|
// prime line
|
||||||
auto prime_x = start_x - 2;
|
auto prime_x = start_x - 2;
|
||||||
gcode << move_to(Vec2d(prime_x, y_pos + (num - 4) * m_space_y));
|
gcode << move_to(Vec2d(prime_x, y_pos + (num - 4) * m_space_y), writer);
|
||||||
gcode << writer.set_speed(slow);
|
gcode << writer.set_speed(slow);
|
||||||
gcode << writer.extrude_to_xy(Vec2d(prime_x, y_pos + 3 * m_space_y), e_per_mm * m_space_y * num * 1.1);
|
gcode << writer.extrude_to_xy(Vec2d(prime_x, y_pos + 3 * m_space_y), e_per_mm * m_space_y * num * 1.1);
|
||||||
|
|
||||||
for (int i = 0; i < num; ++i) {
|
for (int i = 0; i < num; ++i) {
|
||||||
gcode << writer.set_pressure_advance(start_pa + i * step_pa);
|
gcode << writer.set_pressure_advance(start_pa + i * step_pa);
|
||||||
gcode << move_to(Vec2d(start_x, y_pos + i * m_space_y));
|
gcode << move_to(Vec2d(start_x, y_pos + i * m_space_y), writer);
|
||||||
gcode << writer.set_speed(slow);
|
gcode << writer.set_speed(slow);
|
||||||
gcode << writer.extrude_to_xy(Vec2d(start_x + m_length_short, y_pos + i * m_space_y), e_per_mm * m_length_short);
|
gcode << writer.extrude_to_xy(Vec2d(start_x + m_length_short, y_pos + i * m_space_y), e_per_mm * m_length_short);
|
||||||
gcode << writer.set_speed(fast);
|
gcode << writer.set_speed(fast);
|
||||||
@@ -307,9 +309,9 @@ std::string CalibPressureAdvanceLine::print_pa_lines(double start_x, double star
|
|||||||
if (m_draw_numbers) {
|
if (m_draw_numbers) {
|
||||||
// draw indicator lines
|
// draw indicator lines
|
||||||
gcode << writer.set_speed(fast);
|
gcode << writer.set_speed(fast);
|
||||||
gcode << move_to(Vec2d(start_x + m_length_short, y_pos + (num - 1) * m_space_y + 2));
|
gcode << move_to(Vec2d(start_x + m_length_short, y_pos + (num - 1) * m_space_y + 2), writer);
|
||||||
gcode << writer.extrude_to_xy(Vec2d(start_x + m_length_short, y_pos + (num - 1) * m_space_y + 7), thin_e_per_mm * 7);
|
gcode << writer.extrude_to_xy(Vec2d(start_x + m_length_short, y_pos + (num - 1) * m_space_y + 7), thin_e_per_mm * 7);
|
||||||
gcode << move_to(Vec2d(start_x + m_length_short + m_length_long, y_pos + (num - 1) * m_space_y + 7));
|
gcode << move_to(Vec2d(start_x + m_length_short + m_length_long, y_pos + (num - 1) * m_space_y + 7), writer);
|
||||||
gcode << writer.extrude_to_xy(Vec2d(start_x + m_length_short + m_length_long, y_pos + (num - 1) * m_space_y + 2), thin_e_per_mm * 7);
|
gcode << writer.extrude_to_xy(Vec2d(start_x + m_length_short + m_length_long, y_pos + (num - 1) * m_space_y + 2), thin_e_per_mm * 7);
|
||||||
|
|
||||||
for (int i = 0; i < num; i += 2) {
|
for (int i = 0; i < num; i += 2) {
|
||||||
@@ -319,7 +321,8 @@ std::string CalibPressureAdvanceLine::print_pa_lines(double start_x, double star
|
|||||||
start_pa + i * step_pa,
|
start_pa + i * step_pa,
|
||||||
DrawDigitMode::Left_To_Right,
|
DrawDigitMode::Left_To_Right,
|
||||||
m_number_line_width,
|
m_number_line_width,
|
||||||
m_height_layer
|
m_height_layer,
|
||||||
|
writer
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -345,16 +348,13 @@ PatternSettings::PatternSettings(const CalibPressureAdvancePattern* cpap) :
|
|||||||
|
|
||||||
CustomGCode::Info CalibPressureAdvancePattern::generate_gcodes()
|
CustomGCode::Info CalibPressureAdvancePattern::generate_gcodes()
|
||||||
{
|
{
|
||||||
assert(mp_gcodegen != nullptr);
|
|
||||||
|
|
||||||
std::stringstream gcode;
|
std::stringstream gcode;
|
||||||
GCodeWriter& writer = mp_gcodegen->writer();
|
|
||||||
|
|
||||||
gcode << "; start pressure advance pattern for layer\n";
|
gcode << "; start pressure advance pattern for layer\n";
|
||||||
|
|
||||||
gcode << move_to(Vec2d(pattern_start_x(), pattern_start_y()), "Move to start XY position");
|
gcode << move_to(Vec2d(pattern_start_x(), pattern_start_y()), m_writer, "Move to start XY position");
|
||||||
gcode << writer.travel_to_z(m_height_first_layer, "Move to start Z position");
|
gcode << m_writer.travel_to_z(m_height_first_layer, "Move to start Z position");
|
||||||
gcode << writer.set_pressure_advance(m_start_pa);
|
gcode << m_writer.set_pressure_advance(m_params.start);
|
||||||
|
|
||||||
const DrawBoxOptArgs default_box_opt_args(m_pattern_settings);
|
const DrawBoxOptArgs default_box_opt_args(m_pattern_settings);
|
||||||
|
|
||||||
@@ -399,7 +399,7 @@ CustomGCode::Info CalibPressureAdvancePattern::generate_gcodes()
|
|||||||
|
|
||||||
// // line numbering
|
// // line numbering
|
||||||
if (i == 1) {
|
if (i == 1) {
|
||||||
gcode << writer.set_pressure_advance(m_start_pa);
|
gcode << m_writer.set_pressure_advance(m_params.start);
|
||||||
|
|
||||||
// glyph on every other line
|
// glyph on every other line
|
||||||
for (int j = 0; j < num_patterns; j += 2) {
|
for (int j = 0; j < num_patterns; j += 2) {
|
||||||
@@ -417,10 +417,11 @@ CustomGCode::Info CalibPressureAdvancePattern::generate_gcodes()
|
|||||||
gcode << draw_number(
|
gcode << draw_number(
|
||||||
current_glyph_start_x,
|
current_glyph_start_x,
|
||||||
pattern_start_y() + frame_size_y() + m_glyph_padding_vertical + line_width(),
|
pattern_start_y() + frame_size_y() + m_glyph_padding_vertical + line_width(),
|
||||||
m_start_pa + (j * m_step_pa),
|
m_params.start + (j * m_params.step),
|
||||||
DrawDigitMode::Bottom_To_Top,
|
DrawDigitMode::Bottom_To_Top,
|
||||||
m_line_width,
|
m_line_width,
|
||||||
m_height_layer
|
m_height_layer,
|
||||||
|
m_writer
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -450,11 +451,11 @@ CustomGCode::Info CalibPressureAdvancePattern::generate_gcodes()
|
|||||||
double initial_x = to_x;
|
double initial_x = to_x;
|
||||||
double initial_y = to_y;
|
double initial_y = to_y;
|
||||||
|
|
||||||
gcode << move_to(Vec2d(to_x, to_y), "Move to pattern start");
|
gcode << move_to(Vec2d(to_x, to_y), m_writer, "Move to pattern start");
|
||||||
|
|
||||||
for (int j = 0; j < num_patterns; ++j) {
|
for (int j = 0; j < num_patterns; ++j) {
|
||||||
// increment pressure advance
|
// increment pressure advance
|
||||||
gcode << writer.set_pressure_advance(m_start_pa + (j * m_step_pa));
|
gcode << m_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 < m_wall_count; ++k) {
|
||||||
to_x += std::cos(to_radians(m_corner_angle) / 2) * side_length;
|
to_x += std::cos(to_radians(m_corner_angle) / 2) * side_length;
|
||||||
@@ -464,26 +465,26 @@ CustomGCode::Info CalibPressureAdvancePattern::generate_gcodes()
|
|||||||
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);
|
gcode << draw_line(Vec2d(to_x, to_y), draw_line_opt_args);
|
||||||
|
|
||||||
to_x -= std::cos(to_radians(m_corner_angle) / 2) * side_length;
|
to_x -= std::cos(to_radians(m_corner_angle) / 2) * side_length;
|
||||||
to_y += std::sin(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(Vec2d(to_x, to_y), draw_line_opt_args);
|
||||||
|
|
||||||
to_y = initial_y;
|
to_y = initial_y;
|
||||||
if (k != m_wall_count - 1) {
|
if (k != m_wall_count - 1) {
|
||||||
// perimeters not done yet. move to next perimeter
|
// perimeters not done yet. move to next perimeter
|
||||||
to_x += line_spacing_angle();
|
to_x += line_spacing_angle();
|
||||||
gcode << move_to(Vec2d(to_x, to_y), "Move to start next pattern wall");
|
gcode << move_to(Vec2d(to_x, to_y), m_writer, "Move to start next pattern wall");
|
||||||
} else if (j != num_patterns - 1) {
|
} else if (j != num_patterns - 1) {
|
||||||
// patterns not done yet. move to next pattern
|
// patterns not done yet. move to next pattern
|
||||||
to_x += m_pattern_spacing + line_width();
|
to_x += m_pattern_spacing + line_width();
|
||||||
gcode << move_to(Vec2d(to_x, to_y), "Move to next pattern");
|
gcode << move_to(Vec2d(to_x, to_y), m_writer, "Move to next pattern");
|
||||||
} else if (i != m_num_layers - 1) {
|
} else if (i != m_num_layers - 1) {
|
||||||
// layers not done yet. move back to start
|
// layers not done yet. move back to start
|
||||||
to_x = initial_x;
|
to_x = initial_x;
|
||||||
gcode << move_to(Vec2d(to_x, to_y), "Move back to start position");
|
gcode << move_to(Vec2d(to_x, to_y), m_writer, "Move back to start position");
|
||||||
} else {
|
} else {
|
||||||
// everything done
|
// everything done
|
||||||
}
|
}
|
||||||
@@ -491,7 +492,7 @@ CustomGCode::Info CalibPressureAdvancePattern::generate_gcodes()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gcode << writer.set_pressure_advance(m_start_pa);
|
gcode << m_writer.set_pressure_advance(m_params.start);
|
||||||
gcode << "; end pressure advance pattern for layer\n";
|
gcode << "; end pressure advance pattern for layer\n";
|
||||||
|
|
||||||
CustomGCode::Item item;
|
CustomGCode::Item item;
|
||||||
@@ -507,25 +508,22 @@ CustomGCode::Info CalibPressureAdvancePattern::generate_gcodes()
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CalibPressureAdvancePattern::draw_line(double to_x, double to_y, DrawLineOptArgs opt_args)
|
std::string CalibPressureAdvancePattern::draw_line(Vec2d to_pt, DrawLineOptArgs opt_args)
|
||||||
{
|
{
|
||||||
assert(mp_gcodegen != nullptr);
|
|
||||||
|
|
||||||
std::stringstream gcode;
|
std::stringstream gcode;
|
||||||
|
|
||||||
const double e_per_mm = CalibPressureAdvance::e_per_mm(
|
const double e_per_mm = CalibPressureAdvance::e_per_mm(
|
||||||
opt_args.line_width,
|
opt_args.line_width,
|
||||||
opt_args.height,
|
opt_args.height,
|
||||||
mp_gcodegen->config().filament_diameter.get_at(0),
|
m_config.filament_diameter.get_at(0),
|
||||||
mp_gcodegen->config().filament_flow_ratio.get_at(0)
|
m_config.filament_flow_ratio.get_at(0)
|
||||||
);
|
);
|
||||||
|
|
||||||
// TODO: this seems to always be (0, 0)
|
const double length = get_distance(m_last_pos, to_pt);
|
||||||
const Point last_pos = mp_gcodegen->last_pos();
|
|
||||||
const double length = get_distance(last_pos.x(), last_pos.y(), to_x, to_y);
|
|
||||||
auto dE = e_per_mm * length;
|
auto dE = e_per_mm * length;
|
||||||
|
|
||||||
gcode << mp_gcodegen->writer().extrude_to_xy(Vec2d(to_x, to_y), dE, opt_args.comment);
|
gcode << m_writer.extrude_to_xy(to_pt, dE, opt_args.comment);
|
||||||
|
m_last_pos = to_pt;
|
||||||
|
|
||||||
return gcode.str();
|
return gcode.str();
|
||||||
}
|
}
|
||||||
@@ -552,7 +550,7 @@ std::string CalibPressureAdvancePattern::draw_box(double min_x, double min_y, do
|
|||||||
|
|
||||||
opt_args.num_perimeters = std::min(opt_args.num_perimeters, max_perimeters);
|
opt_args.num_perimeters = std::min(opt_args.num_perimeters, max_perimeters);
|
||||||
|
|
||||||
gcode << move_to(Vec2d(min_x, min_y), "Move to box start");
|
gcode << move_to(Vec2d(min_x, min_y), m_writer, "Move to box start");
|
||||||
|
|
||||||
DrawLineOptArgs line_opt_args(m_pattern_settings);
|
DrawLineOptArgs line_opt_args(m_pattern_settings);
|
||||||
line_opt_args.height = opt_args.height;
|
line_opt_args.height = opt_args.height;
|
||||||
@@ -563,24 +561,24 @@ std::string CalibPressureAdvancePattern::draw_box(double min_x, double min_y, do
|
|||||||
if (i != 0) { // after first perimeter, step inwards to start next perimeter
|
if (i != 0) { // after first perimeter, step inwards to start next perimeter
|
||||||
x += spacing;
|
x += spacing;
|
||||||
y += spacing;
|
y += spacing;
|
||||||
gcode << move_to(Vec2d(x, y), "Step inwards to print next perimeter");
|
gcode << move_to(Vec2d(x, y), m_writer, "Step inwards to print next perimeter");
|
||||||
}
|
}
|
||||||
|
|
||||||
y += size_y - i * spacing * 2;
|
y += size_y - i * spacing * 2;
|
||||||
line_opt_args.comment = "Draw perimeter (up)";
|
line_opt_args.comment = "Draw perimeter (up)";
|
||||||
gcode << draw_line(x, y, line_opt_args);
|
gcode << draw_line(Vec2d(x, y), line_opt_args);
|
||||||
|
|
||||||
x += size_x - i * spacing * 2;
|
x += size_x - i * spacing * 2;
|
||||||
line_opt_args.comment = "Draw perimeter (right)";
|
line_opt_args.comment = "Draw perimeter (right)";
|
||||||
gcode << draw_line(x, y, line_opt_args);
|
gcode << draw_line(Vec2d(x, y), line_opt_args);
|
||||||
|
|
||||||
y -= size_y - i * spacing * 2;
|
y -= size_y - i * spacing * 2;
|
||||||
line_opt_args.comment = "Draw perimeter (down)";
|
line_opt_args.comment = "Draw perimeter (down)";
|
||||||
gcode << draw_line(x, y, line_opt_args);
|
gcode << draw_line(Vec2d(x, y), line_opt_args);
|
||||||
|
|
||||||
x -= size_x - i * spacing * 2;
|
x -= size_x - i * spacing * 2;
|
||||||
line_opt_args.comment = "Draw perimeter (left)";
|
line_opt_args.comment = "Draw perimeter (left)";
|
||||||
gcode << draw_line(x, y, line_opt_args);
|
gcode << draw_line(Vec2d(x, y), line_opt_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!opt_args.is_filled) {
|
if (!opt_args.is_filled) {
|
||||||
@@ -607,28 +605,28 @@ std::string CalibPressureAdvancePattern::draw_box(double min_x, double min_y, do
|
|||||||
x = x_min_bound;
|
x = x_min_bound;
|
||||||
y = y_min_bound;
|
y = y_min_bound;
|
||||||
|
|
||||||
gcode << move_to(Vec2d(x, y), "Move to fill start");
|
gcode << move_to(Vec2d(x, y), m_writer, "Move to fill start");
|
||||||
|
|
||||||
for (int i = 0; i < x_count + y_count + (x_remainder + y_remainder >= spacing_45 ? 1 : 0); ++i) { // this isn't the most robust way, but less expensive than finding line intersections
|
for (int i = 0; i < x_count + y_count + (x_remainder + y_remainder >= spacing_45 ? 1 : 0); ++i) { // this isn't the most robust way, but less expensive than finding line intersections
|
||||||
if (i < std::min(x_count, y_count)) {
|
if (i < std::min(x_count, y_count)) {
|
||||||
if (i % 2 == 0) {
|
if (i % 2 == 0) {
|
||||||
x += spacing_45;
|
x += spacing_45;
|
||||||
y = y_min_bound;
|
y = y_min_bound;
|
||||||
gcode << move_to(Vec2d(x, y), "Fill: Step right");
|
gcode << move_to(Vec2d(x, y), m_writer, "Fill: Step right");
|
||||||
|
|
||||||
y += x - x_min_bound;
|
y += x - x_min_bound;
|
||||||
x = x_min_bound;
|
x = x_min_bound;
|
||||||
line_opt_args.comment = "Fill: Print up/left";
|
line_opt_args.comment = "Fill: Print up/left";
|
||||||
gcode << draw_line(x, y, line_opt_args);
|
gcode << draw_line(Vec2d(x, y), line_opt_args);
|
||||||
} else {
|
} else {
|
||||||
y += spacing_45;
|
y += spacing_45;
|
||||||
x = x_min_bound;
|
x = x_min_bound;
|
||||||
gcode << move_to(Vec2d(x, y), "Fill: Step up");
|
gcode << move_to(Vec2d(x, y), m_writer, "Fill: Step up");
|
||||||
|
|
||||||
x += y - y_min_bound;
|
x += y - y_min_bound;
|
||||||
y = y_min_bound;
|
y = y_min_bound;
|
||||||
line_opt_args.comment = "Fill: Print down/right";
|
line_opt_args.comment = "Fill: Print down/right";
|
||||||
gcode << draw_line(x, y, line_opt_args);
|
gcode << draw_line(Vec2d(x, y), line_opt_args);
|
||||||
}
|
}
|
||||||
} else if (i < std::max(x_count, y_count)) {
|
} else if (i < std::max(x_count, y_count)) {
|
||||||
if (x_count > y_count) {
|
if (x_count > y_count) {
|
||||||
@@ -636,12 +634,12 @@ std::string CalibPressureAdvancePattern::draw_box(double min_x, double min_y, do
|
|||||||
if (i % 2 == 0) {
|
if (i % 2 == 0) {
|
||||||
x += spacing_45;
|
x += spacing_45;
|
||||||
y = y_min_bound;
|
y = y_min_bound;
|
||||||
gcode << move_to(Vec2d(x, y), "Fill: Step right");
|
gcode << move_to(Vec2d(x, y), m_writer, "Fill: Step right");
|
||||||
|
|
||||||
x -= y_max_bound - y_min_bound;
|
x -= y_max_bound - y_min_bound;
|
||||||
y = y_max_bound;
|
y = y_max_bound;
|
||||||
line_opt_args.comment = "Fill: Print up/left";
|
line_opt_args.comment = "Fill: Print up/left";
|
||||||
gcode << draw_line(x, y, line_opt_args);
|
gcode << draw_line(Vec2d(x, y), line_opt_args);
|
||||||
} else {
|
} else {
|
||||||
if (i == y_count) {
|
if (i == y_count) {
|
||||||
x += spacing_45 - y_remainder;
|
x += spacing_45 - y_remainder;
|
||||||
@@ -650,12 +648,12 @@ std::string CalibPressureAdvancePattern::draw_box(double min_x, double min_y, do
|
|||||||
x += spacing_45;
|
x += spacing_45;
|
||||||
}
|
}
|
||||||
y = y_max_bound;
|
y = y_max_bound;
|
||||||
gcode << move_to(Vec2d(x, y), "Fill: Step right");
|
gcode << move_to(Vec2d(x, y), m_writer, "Fill: Step right");
|
||||||
|
|
||||||
x += y_max_bound - y_min_bound;
|
x += y_max_bound - y_min_bound;
|
||||||
y = y_min_bound;
|
y = y_min_bound;
|
||||||
line_opt_args.comment = "Fill: Print down/right";
|
line_opt_args.comment = "Fill: Print down/right";
|
||||||
gcode << draw_line(x, y, line_opt_args);
|
gcode << draw_line(Vec2d(x, y), line_opt_args);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// box is taller than wide
|
// box is taller than wide
|
||||||
@@ -667,21 +665,21 @@ std::string CalibPressureAdvancePattern::draw_box(double min_x, double min_y, do
|
|||||||
} else {
|
} else {
|
||||||
y += spacing_45;
|
y += spacing_45;
|
||||||
}
|
}
|
||||||
gcode << move_to(Vec2d(x, y), "Fill: Step up");
|
gcode << move_to(Vec2d(x, y), m_writer, "Fill: Step up");
|
||||||
|
|
||||||
x = x_min_bound;
|
x = x_min_bound;
|
||||||
y += x_max_bound - x_min_bound;
|
y += x_max_bound - x_min_bound;
|
||||||
line_opt_args.comment = "Fill: Print up/left";
|
line_opt_args.comment = "Fill: Print up/left";
|
||||||
gcode << draw_line(x, y, line_opt_args);
|
gcode << draw_line(Vec2d(x, y), line_opt_args);
|
||||||
} else {
|
} else {
|
||||||
x = x_min_bound;
|
x = x_min_bound;
|
||||||
y += spacing_45;
|
y += spacing_45;
|
||||||
gcode << move_to(Vec2d(x, y), "Fill: Step up");
|
gcode << move_to(Vec2d(x, y), m_writer, "Fill: Step up");
|
||||||
|
|
||||||
x = x_max_bound;
|
x = x_max_bound;
|
||||||
y -= x_max_bound - x_min_bound;
|
y -= x_max_bound - x_min_bound;
|
||||||
line_opt_args.comment = "Fill: Print down/right";
|
line_opt_args.comment = "Fill: Print down/right";
|
||||||
gcode << draw_line(x, y, line_opt_args);
|
gcode << draw_line(Vec2d(x, y), line_opt_args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -692,12 +690,12 @@ std::string CalibPressureAdvancePattern::draw_box(double min_x, double min_y, do
|
|||||||
} else {
|
} else {
|
||||||
y += spacing_45;
|
y += spacing_45;
|
||||||
}
|
}
|
||||||
gcode << move_to(Vec2d(x, y), "Fill: Step up");
|
gcode << move_to(Vec2d(x, y), m_writer, "Fill: Step up");
|
||||||
|
|
||||||
x -= y_max_bound - y;
|
x -= y_max_bound - y;
|
||||||
y = y_max_bound;
|
y = y_max_bound;
|
||||||
line_opt_args.comment = "Fill: Print up/left";
|
line_opt_args.comment = "Fill: Print up/left";
|
||||||
gcode << draw_line(x, y, line_opt_args);
|
gcode << draw_line(Vec2d(x, y), line_opt_args);
|
||||||
} else {
|
} else {
|
||||||
if (i == y_count) {
|
if (i == y_count) {
|
||||||
x += spacing_45 - y_remainder;
|
x += spacing_45 - y_remainder;
|
||||||
@@ -705,12 +703,12 @@ std::string CalibPressureAdvancePattern::draw_box(double min_x, double min_y, do
|
|||||||
x += spacing_45;
|
x += spacing_45;
|
||||||
}
|
}
|
||||||
y = y_max_bound;
|
y = y_max_bound;
|
||||||
gcode << move_to(Vec2d(x, y), "Fill: Step right");
|
gcode << move_to(Vec2d(x, y), m_writer, "Fill: Step right");
|
||||||
|
|
||||||
y -= x_max_bound - x;
|
y -= x_max_bound - x;
|
||||||
x = x_max_bound;
|
x = x_max_bound;
|
||||||
line_opt_args.comment = "Fill: Print down/right";
|
line_opt_args.comment = "Fill: Print down/right";
|
||||||
gcode << draw_line(x, y, line_opt_args);
|
gcode << draw_line(Vec2d(x, y), line_opt_args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -718,15 +716,14 @@ std::string CalibPressureAdvancePattern::draw_box(double min_x, double min_y, do
|
|||||||
return gcode.str();
|
return gcode.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
double CalibPressureAdvancePattern::get_distance(double cur_x, double cur_y, double to_x, double to_y)
|
double CalibPressureAdvancePattern::get_distance(Vec2d from, Vec2d to)
|
||||||
{
|
{
|
||||||
return std::hypot((to_x - cur_x), (to_y - cur_y));
|
return std::hypot((to.x() - from.x()), (to.y() - from.y()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Point CalibPressureAdvancePattern::bed_center()
|
Vec2d CalibPressureAdvancePattern::bed_center()
|
||||||
{
|
{
|
||||||
assert(mp_gcodegen != nullptr);
|
BoundingBoxf bed_ext = get_extents(m_config.printable_area.values);
|
||||||
BoundingBoxf bed_ext = get_extents(mp_gcodegen->config().printable_area.values);
|
|
||||||
|
|
||||||
if (is_delta()) {
|
if (is_delta()) {
|
||||||
delta_scale_bed_ext(bed_ext);
|
delta_scale_bed_ext(bed_ext);
|
||||||
@@ -735,7 +732,7 @@ Point CalibPressureAdvancePattern::bed_center()
|
|||||||
double center_x = bed_ext.size().x() / 2;
|
double center_x = bed_ext.size().x() / 2;
|
||||||
double center_y = bed_ext.size().y() / 2;
|
double center_y = bed_ext.size().y() / 2;
|
||||||
|
|
||||||
return Point(center_x, center_y);
|
return Vec2d(center_x, center_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
double CalibPressureAdvancePattern::object_size_x()
|
double CalibPressureAdvancePattern::object_size_x()
|
||||||
@@ -791,7 +788,7 @@ double CalibPressureAdvancePattern::max_numbering_height()
|
|||||||
|
|
||||||
// note: only every other number is printed
|
// note: only every other number is printed
|
||||||
for (std::string::size_type i = 0; i < num_patterns; i += 2) {
|
for (std::string::size_type i = 0; i < num_patterns; i += 2) {
|
||||||
std::string sNumber = convert_number_to_string(m_start_pa + (i * m_step_pa));
|
std::string sNumber = convert_number_to_string(m_params.start + (i * m_params.step));
|
||||||
|
|
||||||
if (sNumber.length() > most_characters) {
|
if (sNumber.length() > most_characters) {
|
||||||
most_characters = sNumber.length();
|
most_characters = sNumber.length();
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "CustomGCode.hpp"
|
#include "CustomGCode.hpp"
|
||||||
#include "GCodeWriter.hpp"
|
#include "GCodeWriter.hpp"
|
||||||
#include "Point.hpp"
|
|
||||||
#include "PrintConfig.hpp"
|
#include "PrintConfig.hpp"
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
|
|
||||||
@@ -39,10 +38,10 @@ protected:
|
|||||||
Bottom_To_Top
|
Bottom_To_Top
|
||||||
};
|
};
|
||||||
|
|
||||||
bool is_delta() const;
|
virtual bool is_delta() const =0;
|
||||||
void delta_scale_bed_ext(BoundingBoxf& bed_ext) { bed_ext.scale(1.0f / 1.41421f); }
|
void delta_scale_bed_ext(BoundingBoxf& bed_ext) { bed_ext.scale(1.0f / 1.41421f); }
|
||||||
|
|
||||||
std::string move_to(Vec2d pt, std::string comment = std::string());
|
std::string move_to(Vec2d pt, GCodeWriter& writer, std::string comment = std::string());
|
||||||
double e_per_mm(
|
double e_per_mm(
|
||||||
double line_width,
|
double line_width,
|
||||||
double layer_height,
|
double layer_height,
|
||||||
@@ -59,7 +58,8 @@ protected:
|
|||||||
char c,
|
char c,
|
||||||
CalibPressureAdvance::DrawDigitMode mode,
|
CalibPressureAdvance::DrawDigitMode mode,
|
||||||
double line_width,
|
double line_width,
|
||||||
double e_per_mm
|
double e_per_mm,
|
||||||
|
GCodeWriter& writer
|
||||||
);
|
);
|
||||||
std::string draw_number(
|
std::string draw_number(
|
||||||
double startx,
|
double startx,
|
||||||
@@ -67,10 +67,12 @@ protected:
|
|||||||
double value,
|
double value,
|
||||||
CalibPressureAdvance::DrawDigitMode mode,
|
CalibPressureAdvance::DrawDigitMode mode,
|
||||||
double line_width,
|
double line_width,
|
||||||
double layer_height
|
double layer_height,
|
||||||
|
GCodeWriter& writer
|
||||||
);
|
);
|
||||||
|
|
||||||
GCode* mp_gcodegen {nullptr};
|
GCode* mp_gcodegen {nullptr};
|
||||||
|
Vec2d m_last_pos;
|
||||||
|
|
||||||
DrawDigitMode m_draw_digit_mode {DrawDigitMode::Left_To_Right};
|
DrawDigitMode m_draw_digit_mode {DrawDigitMode::Left_To_Right};
|
||||||
const double m_digit_segment_len {2};
|
const double m_digit_segment_len {2};
|
||||||
@@ -88,13 +90,14 @@ public:
|
|||||||
~CalibPressureAdvanceLine() { };
|
~CalibPressureAdvanceLine() { };
|
||||||
|
|
||||||
std::string generate_test(double start_pa = 0, double step_pa = 0.002, int count = 50);
|
std::string generate_test(double start_pa = 0, double step_pa = 0.002, int count = 50);
|
||||||
|
|
||||||
void set_speed(double fast = 100.0, double slow = 20.0) {
|
void set_speed(double fast = 100.0, double slow = 20.0) {
|
||||||
m_slow_speed = slow;
|
m_slow_speed = slow;
|
||||||
m_fast_speed = fast;
|
m_fast_speed = fast;
|
||||||
}
|
}
|
||||||
|
|
||||||
double& line_width() { return m_line_width; };
|
double& line_width() { return m_line_width; };
|
||||||
|
bool is_delta() const;
|
||||||
bool& draw_numbers() { return m_draw_numbers; }
|
bool& draw_numbers() { return m_draw_numbers; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -164,64 +167,40 @@ private:
|
|||||||
double speed;
|
double speed;
|
||||||
};
|
};
|
||||||
|
|
||||||
// the bare minimum needed to plate this calibration test
|
class CalibPressureAdvancePattern : public CalibPressureAdvance {
|
||||||
class CalibPressureAdvancePatternPlate : public CalibPressureAdvance {
|
|
||||||
public:
|
|
||||||
CalibPressureAdvancePatternPlate(const Calib_Params& params) :
|
|
||||||
CalibPressureAdvance(),
|
|
||||||
m_start_pa(params.start),
|
|
||||||
m_end_pa(params.end),
|
|
||||||
m_step_pa(params.step)
|
|
||||||
{
|
|
||||||
this->m_height_layer = 0.2;
|
|
||||||
};
|
|
||||||
CalibPressureAdvancePatternPlate(
|
|
||||||
const Calib_Params& params,
|
|
||||||
GCode* gcodegen
|
|
||||||
) :
|
|
||||||
CalibPressureAdvance(gcodegen),
|
|
||||||
m_start_pa(params.start),
|
|
||||||
m_end_pa(params.end),
|
|
||||||
m_step_pa(params.step)
|
|
||||||
{
|
|
||||||
this->m_height_layer = 0.2;
|
|
||||||
};
|
|
||||||
|
|
||||||
double height_first_layer() const { return m_height_first_layer; };
|
|
||||||
double height_layer() const { return m_height_layer; };
|
|
||||||
double max_layer_z() { return m_height_first_layer + ((m_num_layers - 1) * m_height_layer); };
|
|
||||||
|
|
||||||
double handle_xy_size() { return m_handle_xy_size; };
|
|
||||||
protected:
|
|
||||||
const double m_start_pa;
|
|
||||||
const double m_end_pa;
|
|
||||||
const double m_step_pa;
|
|
||||||
|
|
||||||
const double m_handle_xy_size {5};
|
|
||||||
|
|
||||||
const int m_num_layers {4};
|
|
||||||
const double m_height_first_layer {0.25};
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Remaining definition. Separated because it requires fully setup GCode object,
|
|
||||||
which is not available at the time of plating */
|
|
||||||
class CalibPressureAdvancePattern : public CalibPressureAdvancePatternPlate {
|
|
||||||
friend struct PatternSettings;
|
friend struct PatternSettings;
|
||||||
public:
|
public:
|
||||||
CalibPressureAdvancePattern(
|
CalibPressureAdvancePattern(
|
||||||
const Calib_Params& params,
|
const Calib_Params& params,
|
||||||
GCode* gcodegen,
|
const PrintConfig& config,
|
||||||
const Vec2d starting_point
|
GCodeWriter& writer
|
||||||
) :
|
) :
|
||||||
CalibPressureAdvancePatternPlate(params, gcodegen),
|
CalibPressureAdvance(),
|
||||||
m_starting_point(starting_point)
|
m_params(params),
|
||||||
|
m_config(config),
|
||||||
|
m_writer(writer)
|
||||||
{
|
{
|
||||||
|
this->m_nozzle_diameter = config.nozzle_diameter.get_at(0);
|
||||||
|
this->m_height_layer = 0.2;
|
||||||
this->m_draw_digit_mode = DrawDigitMode::Bottom_To_Top;
|
this->m_draw_digit_mode = DrawDigitMode::Bottom_To_Top;
|
||||||
this->m_line_width = line_width();
|
this->m_line_width = line_width();
|
||||||
|
|
||||||
this->m_pattern_settings = PatternSettings(this);
|
this->m_pattern_settings = PatternSettings(this);
|
||||||
};
|
};
|
||||||
~CalibPressureAdvancePattern() { };
|
// ~CalibPressureAdvancePattern() { }; TODO
|
||||||
|
|
||||||
|
bool is_delta() const
|
||||||
|
{
|
||||||
|
return m_config.printable_area.values.size() > 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
double handle_xy_size() { 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() { return m_height_first_layer + ((m_num_layers - 1) * m_height_layer); };
|
||||||
|
|
||||||
|
void set_starting_point(Vec2d pt) { m_starting_point = pt; };
|
||||||
|
|
||||||
CustomGCode::Info generate_gcodes();
|
CustomGCode::Info generate_gcodes();
|
||||||
protected:
|
protected:
|
||||||
@@ -235,21 +214,21 @@ protected:
|
|||||||
private:
|
private:
|
||||||
int get_num_patterns() const
|
int get_num_patterns() const
|
||||||
{
|
{
|
||||||
return std::ceil((m_end_pa - m_start_pa) / m_step_pa + 1);
|
return std::ceil((m_params.end - m_params.start) / m_params.step + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string draw_line(double to_x, double to_y, DrawLineOptArgs opt_args);
|
std::string draw_line(Vec2d to_pt, DrawLineOptArgs opt_args);
|
||||||
std::string draw_box(double min_x, double min_y, double size_x, double size_y, DrawBoxOptArgs opt_args);
|
std::string draw_box(double min_x, double min_y, double size_x, double size_y, DrawBoxOptArgs opt_args);
|
||||||
|
|
||||||
double to_radians(double degrees) const { return degrees * M_PI / 180; };
|
double to_radians(double degrees) const { return degrees * M_PI / 180; };
|
||||||
double get_distance(double cur_x, double cur_y, double to_x, double to_y);
|
double get_distance(Vec2d from, Vec2d to);
|
||||||
|
|
||||||
// from slic3r documentation: spacing = extrusion_width - layer_height * (1 - PI/4)
|
// from slic3r documentation: spacing = extrusion_width - layer_height * (1 - PI/4)
|
||||||
double line_spacing() { return line_width() - m_height_layer * (1 - M_PI / 4); };
|
double line_spacing() { return line_width() - m_height_layer * (1 - M_PI / 4); };
|
||||||
double line_spacing_anchor() { return line_width_anchor() - m_height_first_layer * (1 - M_PI / 4); };
|
double line_spacing_anchor() { return line_width_anchor() - m_height_first_layer * (1 - M_PI / 4); };
|
||||||
double line_spacing_angle() { return line_spacing() / std::sin(to_radians(m_corner_angle) / 2); };
|
double line_spacing_angle() { return line_spacing() / std::sin(to_radians(m_corner_angle) / 2); };
|
||||||
|
|
||||||
Point bed_center();
|
Vec2d bed_center();
|
||||||
double object_size_x();
|
double object_size_x();
|
||||||
double object_size_y();
|
double object_size_y();
|
||||||
double frame_size_y() { return std::sin(to_radians(double(m_corner_angle) / 2)) * m_wall_side_length * 2; };
|
double frame_size_y() { return std::sin(to_radians(double(m_corner_angle) / 2)) * m_wall_side_length * 2; };
|
||||||
@@ -266,8 +245,16 @@ private:
|
|||||||
double pattern_start_x();
|
double pattern_start_x();
|
||||||
double pattern_start_y();
|
double pattern_start_y();
|
||||||
|
|
||||||
|
const Calib_Params& m_params;
|
||||||
|
const PrintConfig& m_config;
|
||||||
|
GCodeWriter& m_writer;
|
||||||
|
Vec2d m_starting_point;
|
||||||
PatternSettings m_pattern_settings;
|
PatternSettings m_pattern_settings;
|
||||||
const Vec2d m_starting_point;
|
|
||||||
|
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 double m_line_ratio {112.5};
|
||||||
const int m_anchor_layer_line_ratio {140};
|
const int m_anchor_layer_line_ratio {140};
|
||||||
|
|||||||
@@ -8103,7 +8103,7 @@ std::array<Vec3d, 4> get_cut_plane(const BoundingBoxf3& bbox, const double& cut_
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Plater::calib_pa(const Calib_Params& params)
|
void Plater::calib_pa(const Calib_Params& params)
|
||||||
{
|
{
|
||||||
const auto calib_pa_name = wxString::Format(L"Pressure Advance Test");
|
const auto calib_pa_name = wxString::Format(L"Pressure Advance Test");
|
||||||
new_project(false, false, calib_pa_name);
|
new_project(false, false, calib_pa_name);
|
||||||
wxGetApp().mainframe->select_tab(size_t(MainFrame::tp3DEditor));
|
wxGetApp().mainframe->select_tab(size_t(MainFrame::tp3DEditor));
|
||||||
@@ -8124,30 +8124,31 @@ void Plater::calib_pa(const Calib_Params& params)
|
|||||||
p->background_process.fff_print()->set_calib_params(params);
|
p->background_process.fff_print()->set_calib_params(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Plater::_calib_pa_pattern(const Calib_Params& params) {
|
void Plater::_calib_pa_pattern(const Calib_Params& params)
|
||||||
|
{
|
||||||
sidebar().obj_list()->load_generic_subobject("Cube", ModelVolumeType::INVALID);
|
sidebar().obj_list()->load_generic_subobject("Cube", ModelVolumeType::INVALID);
|
||||||
orient();
|
orient();
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
CalibPressureAdvancePatternPlate pa_pattern(params);
|
|
||||||
|
|
||||||
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()));
|
|
||||||
|
|
||||||
changed_objects({ 0 });
|
changed_objects({ 0 });
|
||||||
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();
|
|
||||||
|
|
||||||
_calib_pa_select_added_objects();
|
_calib_pa_select_added_objects();
|
||||||
|
|
||||||
|
Print* print = p->background_process.fff_print();
|
||||||
|
print->apply(this->model(), wxGetApp().preset_bundle->full_config());
|
||||||
|
|
||||||
|
GCodeWriter writer;
|
||||||
|
const Vec3d origin = print->get_plate_origin();
|
||||||
|
writer.set_xy_offset(origin(0), origin(1));
|
||||||
|
writer.set_is_bbl_machine(print->is_BBL_printer());
|
||||||
|
writer.apply_print_config(print->config());
|
||||||
|
|
||||||
|
writer.set_extruders({0});
|
||||||
|
writer.set_extruder(0);
|
||||||
|
|
||||||
|
CalibPressureAdvancePattern pa_pattern(
|
||||||
|
params,
|
||||||
|
print->config(),
|
||||||
|
writer
|
||||||
|
);
|
||||||
|
|
||||||
GizmoObjectManipulation& giz_obj_manip = p->view3D->get_canvas3d()->
|
GizmoObjectManipulation& giz_obj_manip = p->view3D->get_canvas3d()->
|
||||||
get_gizmos_manager().get_object_manipulation();
|
get_gizmos_manager().get_object_manipulation();
|
||||||
giz_obj_manip.set_uniform_scaling(true);
|
giz_obj_manip.set_uniform_scaling(true);
|
||||||
@@ -8155,6 +8156,31 @@ void Plater::_calib_pa_pattern(const Calib_Params& params) {
|
|||||||
giz_obj_manip.set_uniform_scaling(false);
|
giz_obj_manip.set_uniform_scaling(false);
|
||||||
giz_obj_manip.on_change("size", 2, pa_pattern.max_layer_z());
|
giz_obj_manip.on_change("size", 2, pa_pattern.max_layer_z());
|
||||||
center_selection();
|
center_selection();
|
||||||
|
|
||||||
|
BoundingBoxf3 bbox;
|
||||||
|
for (const ModelObject* obj : print->model().objects) {
|
||||||
|
for (size_t i = 0; i < obj->instances.size(); ++i) {
|
||||||
|
bbox.merge(obj->instance_bounding_box(i, false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pa_pattern.set_starting_point(Vec2d(bbox.min.x(), bbox.max.y()));
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
|
model().plates_custom_gcodes[model().curr_plate_index] = pa_pattern.generate_gcodes();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Plater::_calib_pa_tower(const Calib_Params& params) {
|
void Plater::_calib_pa_tower(const Calib_Params& params) {
|
||||||
|
|||||||
Reference in New Issue
Block a user