mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-19 04:37:52 -06:00
pa calib: batch mode for pa pattern (#7199)
* pa calib: batch mode option
This commit is contained in:
parent
538db07127
commit
ecc16bfabf
13 changed files with 299 additions and 106 deletions
|
@ -538,12 +538,19 @@ void CalibPressureAdvanceLine::delta_modify_start(double &startx, double &starty
|
|||
}
|
||||
|
||||
CalibPressureAdvancePattern::CalibPressureAdvancePattern(
|
||||
const Calib_Params ¶ms, const DynamicPrintConfig &config, bool is_bbl_machine, Model &model, const Vec3d &origin)
|
||||
const Calib_Params ¶ms, const DynamicPrintConfig &config, bool is_bbl_machine, const ModelObject &object, const Vec3d &origin)
|
||||
: m_params(params),CalibPressureAdvance(config)
|
||||
{
|
||||
this->m_draw_digit_mode = DrawDigitMode::Bottom_To_Top;
|
||||
|
||||
refresh_setup(config, is_bbl_machine, model, origin);
|
||||
refresh_setup(config, is_bbl_machine, object, origin);
|
||||
}
|
||||
|
||||
Vec3d CalibPressureAdvancePattern::handle_pos_offset() const
|
||||
{
|
||||
return Vec3d{0 - print_size_x() / 2 + handle_xy_size() / 2 + handle_spacing(),
|
||||
0 - max_numbering_height() / 2 - m_glyph_padding_vertical,
|
||||
max_layer_z() / 2};
|
||||
}
|
||||
|
||||
double CalibPressureAdvancePattern::flow_val() const
|
||||
|
@ -552,21 +559,21 @@ double CalibPressureAdvancePattern::flow_val() const
|
|||
double nozzle_diameter = m_config.option<ConfigOptionFloats>("nozzle_diameter")->get_at(0);
|
||||
double line_width = m_config.get_abs_value("line_width", nozzle_diameter);
|
||||
double layer_height = m_config.get_abs_value("layer_height");
|
||||
double speed = m_config.opt_float("outer_wall_speed");
|
||||
double speed = speed_perimeter();
|
||||
Flow pattern_line = Flow(line_width, layer_height, m_config.option<ConfigOptionFloats>("nozzle_diameter")->get_at(0));
|
||||
|
||||
return speed * pattern_line.mm3_per_mm() * flow_mult;
|
||||
};
|
||||
|
||||
void CalibPressureAdvancePattern::generate_custom_gcodes(const DynamicPrintConfig &config,
|
||||
bool is_bbl_machine,
|
||||
Model &model,
|
||||
const Vec3d &origin)
|
||||
CustomGCode::Info CalibPressureAdvancePattern::generate_custom_gcodes(const DynamicPrintConfig &config,
|
||||
bool is_bbl_machine,
|
||||
const ModelObject &object,
|
||||
const Vec3d &origin)
|
||||
{
|
||||
std::stringstream gcode;
|
||||
gcode << "; start pressure advance pattern for layer\n";
|
||||
|
||||
refresh_setup(config, is_bbl_machine, model, origin);
|
||||
refresh_setup(config, is_bbl_machine, object, origin);
|
||||
|
||||
gcode << move_to(Vec2d(m_starting_point.x(), m_starting_point.y()), m_writer, "Move to start XY position");
|
||||
gcode << m_writer.travel_to_z(height_first_layer() + height_z_offset(), "Move to start Z position");
|
||||
|
@ -590,6 +597,8 @@ void CalibPressureAdvancePattern::generate_custom_gcodes(const DynamicPrintConfi
|
|||
const int num_patterns = get_num_patterns(); // "cache" for use in loops
|
||||
|
||||
const double zhop_config_value = m_config.option<ConfigOptionFloats>("z_hop")->get_at(0);
|
||||
const auto accel = accel_perimeter();
|
||||
|
||||
// draw pressure advance pattern
|
||||
for (int i = 0; i < m_num_layers; ++i) {
|
||||
const double layer_height = height_first_layer() + height_z_offset() + (i * height_layer());
|
||||
|
@ -637,7 +646,7 @@ void CalibPressureAdvancePattern::generate_custom_gcodes(const DynamicPrintConfi
|
|||
// acceleration
|
||||
line_num = num_patterns + 4;
|
||||
gcode << draw_number(glyph_start_x(line_num), m_starting_point.y() + frame_size_y() + m_glyph_padding_vertical + line_width(),
|
||||
m_config.opt_float("default_acceleration"), m_draw_digit_mode, line_width(), number_e_per_mm,
|
||||
accel, m_draw_digit_mode, line_width(), number_e_per_mm,
|
||||
speed_first_layer(), m_writer);
|
||||
}
|
||||
|
||||
|
@ -653,6 +662,14 @@ void CalibPressureAdvancePattern::generate_custom_gcodes(const DynamicPrintConfi
|
|||
side_length = m_wall_side_length - shrink;
|
||||
to_x += shrink * std::sin(to_radians(90) - to_radians(m_corner_angle) / 2);
|
||||
to_y += line_spacing_first_layer() * (wall_count() - 1) + (line_width_first_layer() * (1 - m_encroachment));
|
||||
} else {
|
||||
/* Draw a line at slightly slower accel and speed in order to trick gcode writer to force update acceleration and speed.
|
||||
* We do this since several tests may be generated by their own gcode writers which are
|
||||
* not aware about their neighbours updating acceleration/speed */
|
||||
gcode << m_writer.set_print_acceleration(accel - 10);
|
||||
gcode << move_to(Vec2d(m_starting_point.x(), m_starting_point.y()), m_writer, "Move to starting point", zhop_height, layer_height);
|
||||
gcode << draw_line(m_writer, Vec2d(m_starting_point.x(), m_starting_point.y() + frame_size_y()), line_width(), height_layer(), speed_adjust(speed_perimeter() - 10), "Accel/flow trick line");
|
||||
gcode << m_writer.set_print_acceleration(accel);
|
||||
}
|
||||
|
||||
double initial_x = to_x;
|
||||
|
@ -713,7 +730,7 @@ void CalibPressureAdvancePattern::generate_custom_gcodes(const DynamicPrintConfi
|
|||
info.mode = CustomGCode::Mode::SingleExtruder;
|
||||
info.gcodes = gcode_items;
|
||||
|
||||
model.plates_custom_gcodes[model.curr_plate_index] = info;
|
||||
return info;
|
||||
}
|
||||
|
||||
void CalibPressureAdvancePattern::set_start_offset(const Vec3d &offset)
|
||||
|
@ -729,30 +746,30 @@ Vec3d CalibPressureAdvancePattern::get_start_offset()
|
|||
|
||||
void CalibPressureAdvancePattern::refresh_setup(const DynamicPrintConfig &config,
|
||||
bool is_bbl_machine,
|
||||
const Model &model,
|
||||
const ModelObject &object,
|
||||
const Vec3d &origin)
|
||||
{
|
||||
m_config = config;
|
||||
m_config.apply(model.objects.front()->config.get(), true);
|
||||
m_config.apply(model.objects.front()->volumes.front()->config.get(), true);
|
||||
m_config.apply(object.config.get(), true);
|
||||
m_config.apply(object.volumes.front()->config.get(), true);
|
||||
|
||||
_refresh_starting_point(model);
|
||||
_refresh_writer(is_bbl_machine, model, origin);
|
||||
_refresh_starting_point(object);
|
||||
_refresh_writer(is_bbl_machine, object, origin);
|
||||
}
|
||||
|
||||
void CalibPressureAdvancePattern::_refresh_starting_point(const Model &model)
|
||||
void CalibPressureAdvancePattern::_refresh_starting_point(const ModelObject &object)
|
||||
{
|
||||
if (m_is_start_point_fixed)
|
||||
return;
|
||||
|
||||
ModelObject *obj = model.objects.front();
|
||||
BoundingBoxf3 bbox = obj->instance_bounding_box(*obj->instances.front(), false);
|
||||
BoundingBoxf3 bbox = object.instance_bounding_box(*object.instances.front(), false);
|
||||
|
||||
m_starting_point = Vec3d(bbox.min.x(), bbox.max.y(), 0);
|
||||
m_starting_point.y() += m_handle_spacing;
|
||||
m_starting_point.x() -= m_handle_spacing;
|
||||
m_starting_point.y() -= std::sin(to_radians(m_corner_angle) / 2) * m_wall_side_length + (bbox.max.y() - bbox.min.y()) / 2;
|
||||
}
|
||||
|
||||
void CalibPressureAdvancePattern::_refresh_writer(bool is_bbl_machine, const Model &model, const Vec3d &origin)
|
||||
void CalibPressureAdvancePattern::_refresh_writer(bool is_bbl_machine, const ModelObject &object, const Vec3d &origin)
|
||||
{
|
||||
PrintConfig print_config;
|
||||
print_config.apply(m_config, true);
|
||||
|
@ -761,7 +778,7 @@ void CalibPressureAdvancePattern::_refresh_writer(bool is_bbl_machine, const Mod
|
|||
m_writer.set_xy_offset(origin(0), origin(1));
|
||||
m_writer.set_is_bbl_machine(is_bbl_machine);
|
||||
|
||||
const unsigned int extruder_id = model.objects.front()->volumes.front()->extruder_id();
|
||||
const unsigned int extruder_id = object.volumes.front()->extruder_id();
|
||||
m_writer.set_extruders({extruder_id});
|
||||
m_writer.set_extruder(extruder_id);
|
||||
}
|
||||
|
@ -837,7 +854,7 @@ size_t CalibPressureAdvancePattern::max_numbering_length() const
|
|||
}
|
||||
}
|
||||
|
||||
std::string sAccel = convert_number_to_string(m_config.opt_float("default_acceleration"));
|
||||
std::string sAccel = convert_number_to_string(accel_perimeter());
|
||||
most_characters = std::max(most_characters, sAccel.length());
|
||||
|
||||
/* don't actually check flow value: we'll print as many fractional digits as fits */
|
||||
|
|
|
@ -31,6 +31,10 @@ struct Calib_Params
|
|||
Calib_Params() : mode(CalibMode::Calib_None){};
|
||||
double start, end, step;
|
||||
bool print_numbers;
|
||||
|
||||
std::vector<double> accelerations;
|
||||
std::vector<double> speeds;
|
||||
|
||||
CalibMode mode;
|
||||
};
|
||||
|
||||
|
@ -249,16 +253,17 @@ class CalibPressureAdvancePattern : public CalibPressureAdvance
|
|||
|
||||
public:
|
||||
CalibPressureAdvancePattern(
|
||||
const Calib_Params ¶ms, const DynamicPrintConfig &config, bool is_bbl_machine, Model &model, const Vec3d &origin);
|
||||
const Calib_Params ¶ms, const DynamicPrintConfig &config, bool is_bbl_machine, const ModelObject &object, const Vec3d &origin);
|
||||
|
||||
double handle_xy_size() const { return m_handle_xy_size; };
|
||||
double handle_spacing() const { return m_handle_spacing; };
|
||||
Vec3d handle_pos_offset() const;
|
||||
double print_size_x() const { return object_size_x() + pattern_shift(); };
|
||||
double print_size_y() const { return object_size_y(); };
|
||||
double max_layer_z() const { return height_first_layer() + ((m_num_layers - 1) * height_layer()); };
|
||||
double flow_val() const;
|
||||
|
||||
void generate_custom_gcodes(const DynamicPrintConfig &config, bool is_bbl_machine, Model &model, const Vec3d &origin);
|
||||
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();
|
||||
|
@ -266,6 +271,7 @@ public:
|
|||
protected:
|
||||
double speed_first_layer() const { return m_config.option<ConfigOptionFloat>("initial_layer_speed")->value; };
|
||||
double speed_perimeter() const { return m_config.option<ConfigOptionFloat>("outer_wall_speed")->value; };
|
||||
double accel_perimeter() const { return m_config.option<ConfigOptionFloat>("outer_wall_acceleration")->value; }
|
||||
double line_width_first_layer() const
|
||||
{
|
||||
// TODO: FIXME: find out current filament/extruder?
|
||||
|
@ -281,9 +287,9 @@ protected:
|
|||
int wall_count() const { return m_config.option<ConfigOptionInt>("wall_loops")->value; };
|
||||
|
||||
private:
|
||||
void refresh_setup(const DynamicPrintConfig &config, bool is_bbl_machine, const Model &model, const Vec3d &origin);
|
||||
void _refresh_starting_point(const Model &model);
|
||||
void _refresh_writer(bool is_bbl_machine, const Model &model, const Vec3d &origin);
|
||||
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 { return m_config.option<ConfigOptionFloat>("initial_layer_print_height")->value; };
|
||||
double height_z_offset() const { return m_config.option<ConfigOptionFloat>("z_offset")->value; };
|
||||
|
@ -319,7 +325,7 @@ private:
|
|||
bool m_is_start_point_fixed = false;
|
||||
|
||||
const double m_handle_xy_size{5};
|
||||
const double m_handle_spacing{2};
|
||||
const double m_handle_spacing{1.2};
|
||||
const int m_num_layers{4};
|
||||
|
||||
const double m_wall_side_length{30.0};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue