mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-09 07:56:24 -06:00
NEW: Add Ellis' pattern method for pressure advance calibration
Add a new calibration pattern method for pressure advance calibration, which can better test the influence of k value on the corner. The changes of this patch are picked from OrcaSlicer by thewildmage, thanks to thewildmage for the great work! github issue: https://github.com/bambulab/BambuStudio/issues/2222 Change-Id: Icc8fd4d52b20c1668bfa08716b48549dfada515b (cherry picked from commit eb72d8b681bef270906406a2d10a36d4efbce900) (cherry picked from commit 2b07c1154f4a009612f951938e7865dc338b2d9b)
This commit is contained in:
parent
d3785577ef
commit
047015fa5e
12 changed files with 1131 additions and 279 deletions
|
@ -8337,55 +8337,140 @@ void Plater::calib_pa(const Calib_Params ¶ms)
|
|||
const auto calib_pa_name = wxString::Format(L"Pressure Advance Test");
|
||||
new_project(false, false, calib_pa_name);
|
||||
wxGetApp().mainframe->select_tab(size_t(MainFrame::tp3DEditor));
|
||||
if (params.mode == CalibMode::Calib_PA_Line) {
|
||||
add_model(false, Slic3r::resources_dir() + "/calib/pressure_advance/pressure_advance_test.stl");
|
||||
} else {
|
||||
add_model(false, Slic3r::resources_dir() + "/calib/pressure_advance/tower_with_seam.stl");
|
||||
auto print_config = &wxGetApp().preset_bundle->prints.get_edited_preset().config;
|
||||
auto printer_config = &wxGetApp().preset_bundle->printers.get_edited_preset().config;
|
||||
auto filament_config = &wxGetApp().preset_bundle->filaments.get_edited_preset().config;
|
||||
filament_config->set_key_value("slow_down_layer_time", new ConfigOptionInts{1});
|
||||
// todo: for 3rd printer
|
||||
//print_config->set_key_value("default_jerk", new ConfigOptionFloat(1.0f));
|
||||
//print_config->set_key_value("outer_wall_jerk", new ConfigOptionFloat(1.0f));
|
||||
//print_config->set_key_value("inner_wall_jerk", new ConfigOptionFloat(1.0f));
|
||||
if (print_config->option<ConfigOptionEnum<PerimeterGeneratorType>>("wall_generator")->value == PerimeterGeneratorType::Arachne)
|
||||
print_config->set_key_value("wall_transition_angle", new ConfigOptionFloat(25));
|
||||
model().objects[0]->config.set_key_value("seam_position", new ConfigOptionEnum<SeamPosition>(spRear));
|
||||
|
||||
changed_objects({0});
|
||||
wxGetApp().get_tab(Preset::TYPE_PRINT)->update_dirty();
|
||||
wxGetApp().get_tab(Preset::TYPE_FILAMENT)->update_dirty();
|
||||
wxGetApp().get_tab(Preset::TYPE_PRINTER)->update_dirty();
|
||||
wxGetApp().get_tab(Preset::TYPE_PRINT)->reload_config();
|
||||
wxGetApp().get_tab(Preset::TYPE_FILAMENT)->reload_config();
|
||||
wxGetApp().get_tab(Preset::TYPE_PRINTER)->reload_config();
|
||||
|
||||
auto new_height = std::ceil((params.end - params.start) / params.step) + 1;
|
||||
auto obj_bb = model().objects[0]->bounding_box();
|
||||
if (new_height < obj_bb.size().z()) {
|
||||
std::array<Vec3d, 4> plane_pts = get_cut_plane(obj_bb, new_height);
|
||||
cut(0, 0, plane_pts, ModelObjectCutAttribute::KeepLower);
|
||||
}
|
||||
|
||||
// automatic selection of added objects
|
||||
// update printable state for new volumes on canvas3D
|
||||
wxGetApp().plater()->canvas3D()->update_instance_printable_state_for_objects({0});
|
||||
|
||||
Selection &selection = p->view3D->get_canvas3d()->get_selection();
|
||||
selection.clear();
|
||||
selection.add_object(0, false);
|
||||
|
||||
// BBS: update object list selection
|
||||
p->sidebar->obj_list()->update_selections();
|
||||
selection.notify_instance_update(-1, -1);
|
||||
if (p->view3D->get_canvas3d()->get_gizmos_manager().is_enabled())
|
||||
// this is required because the selected object changed and the flatten on face an sla support gizmos need to be updated accordingly
|
||||
p->view3D->get_canvas3d()->update_gizmos_on_off_state();
|
||||
switch (params.mode) {
|
||||
case CalibMode::Calib_PA_Line:
|
||||
add_model(false, Slic3r::resources_dir() + "/calib/pressure_advance/pressure_advance_test.stl");
|
||||
break;
|
||||
case CalibMode::Calib_PA_Pattern:
|
||||
_calib_pa_pattern(params);
|
||||
break;
|
||||
case CalibMode::Calib_PA_Tower:
|
||||
_calib_pa_tower(params);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
p->background_process.fff_print()->set_calib_params(params);
|
||||
}
|
||||
|
||||
void Plater::_calib_pa_pattern(const Calib_Params ¶ms)
|
||||
{
|
||||
// add "handle" cube
|
||||
sidebar().obj_list()->load_generic_subobject("Cube", ModelVolumeType::INVALID);
|
||||
orient();
|
||||
changed_objects({0});
|
||||
_calib_pa_select_added_objects();
|
||||
|
||||
const DynamicPrintConfig &printer_config = wxGetApp().preset_bundle->printers.get_edited_preset().config;
|
||||
DynamicPrintConfig & print_config = wxGetApp().preset_bundle->prints.get_edited_preset().config;
|
||||
float nozzle_diameter = printer_config.option<ConfigOptionFloats>("nozzle_diameter")->get_at(0);
|
||||
|
||||
for (const auto opt : SuggestedConfigCalibPAPattern().float_pairs) {
|
||||
print_config.set_key_value(opt.first, new ConfigOptionFloat(opt.second));
|
||||
}
|
||||
print_config.set_key_value("outer_wall_speed",
|
||||
new ConfigOptionFloat(CalibPressureAdvance::find_optimal_PA_speed(
|
||||
wxGetApp().preset_bundle->full_config(), print_config.get_abs_value("line_width"),
|
||||
print_config.get_abs_value("layer_height"), 0)));
|
||||
|
||||
for (const auto opt : SuggestedConfigCalibPAPattern().nozzle_ratio_pairs) {
|
||||
print_config.set_key_value(opt.first, new ConfigOptionFloat(nozzle_diameter * opt.second / 100));
|
||||
}
|
||||
|
||||
for (const auto opt : SuggestedConfigCalibPAPattern().int_pairs) {
|
||||
print_config.set_key_value(opt.first, new ConfigOptionInt(opt.second));
|
||||
}
|
||||
|
||||
print_config.set_key_value(SuggestedConfigCalibPAPattern().brim_pair.first,
|
||||
new ConfigOptionEnum<BrimType>(SuggestedConfigCalibPAPattern().brim_pair.second));
|
||||
|
||||
wxGetApp().get_tab(Preset::TYPE_PRINT)->update_dirty();
|
||||
wxGetApp().get_tab(Preset::TYPE_PRINT)->reload_config();
|
||||
|
||||
const DynamicPrintConfig full_config = wxGetApp().preset_bundle->full_config();
|
||||
PresetBundle * preset_bundle = wxGetApp().preset_bundle;
|
||||
const bool is_bbl_machine = preset_bundle->printers.get_edited_preset().has_lidar(preset_bundle);
|
||||
const Vec3d plate_origin = get_partplate_list().get_current_plate_origin();
|
||||
CalibPressureAdvancePattern pa_pattern(params, full_config, is_bbl_machine, model(), plate_origin);
|
||||
|
||||
// scale cube to suit test
|
||||
GizmoObjectManipulation &giz_obj_manip = p->view3D->get_canvas3d()->get_gizmos_manager().get_object_manipulation();
|
||||
giz_obj_manip.set_uniform_scaling(true);
|
||||
giz_obj_manip.on_change("size", 0, pa_pattern.handle_xy_size());
|
||||
giz_obj_manip.set_uniform_scaling(false);
|
||||
giz_obj_manip.on_change("size", 2, pa_pattern.max_layer_z());
|
||||
// start with pattern centered on plate
|
||||
center_selection();
|
||||
const Vec3d plate_center = get_partplate_list().get_curr_plate()->get_center_origin();
|
||||
giz_obj_manip.on_change("position", 0, plate_center.x() - (pa_pattern.print_size_x() / 2));
|
||||
giz_obj_manip.on_change("position", 1, plate_center.y() - (pa_pattern.print_size_y() / 2) - pa_pattern.handle_spacing());
|
||||
|
||||
pa_pattern.generate_custom_gcodes(full_config, is_bbl_machine, model(), plate_origin);
|
||||
model().calib_pa_pattern = std::make_unique<CalibPressureAdvancePattern>(pa_pattern);
|
||||
changed_objects({0});
|
||||
}
|
||||
|
||||
void Plater::_calib_pa_tower(const Calib_Params ¶ms)
|
||||
{
|
||||
add_model(false, Slic3r::resources_dir() + "/calib/pressure_advance/tower_with_seam.stl");
|
||||
|
||||
auto print_config = &wxGetApp().preset_bundle->prints.get_edited_preset().config;
|
||||
auto printer_config = &wxGetApp().preset_bundle->printers.get_edited_preset().config;
|
||||
auto filament_config = &wxGetApp().preset_bundle->filaments.get_edited_preset().config;
|
||||
|
||||
const float nozzle_diameter = printer_config->option<ConfigOptionFloats>("nozzle_diameter")->get_at(0);
|
||||
|
||||
filament_config->set_key_value("slow_down_layer_time", new ConfigOptionInts{1});
|
||||
//print_config->set_key_value("default_jerk", new ConfigOptionFloat(1.0f));
|
||||
//print_config->set_key_value("outer_wall_jerk", new ConfigOptionFloat(1.0f));
|
||||
//print_config->set_key_value("inner_wall_jerk", new ConfigOptionFloat(1.0f));
|
||||
auto full_config = wxGetApp().preset_bundle->full_config();
|
||||
auto wall_speed = CalibPressureAdvance::find_optimal_PA_speed(full_config, full_config.get_abs_value("line_width"),
|
||||
full_config.get_abs_value("layer_height"), 0);
|
||||
print_config->set_key_value("outer_wall_speed", new ConfigOptionFloat(wall_speed));
|
||||
print_config->set_key_value("inner_wall_speed", new ConfigOptionFloat(wall_speed));
|
||||
// print_config->set_key_value("wall_generator", new ConfigOptionEnum<PerimeterGeneratorType>(PerimeterGeneratorType::Classic));
|
||||
const auto _wall_generator = print_config->option<ConfigOptionEnum<PerimeterGeneratorType>>("wall_generator");
|
||||
if (_wall_generator->value == PerimeterGeneratorType::Arachne) print_config->set_key_value("wall_transition_angle", new ConfigOptionFloat(25));
|
||||
model().objects[0]->config.set_key_value("seam_position", new ConfigOptionEnum<SeamPosition>(spRear));
|
||||
|
||||
changed_objects({0});
|
||||
wxGetApp().get_tab(Preset::TYPE_PRINT)->update_dirty();
|
||||
wxGetApp().get_tab(Preset::TYPE_FILAMENT)->update_dirty();
|
||||
wxGetApp().get_tab(Preset::TYPE_PRINTER)->update_dirty();
|
||||
wxGetApp().get_tab(Preset::TYPE_PRINT)->reload_config();
|
||||
wxGetApp().get_tab(Preset::TYPE_FILAMENT)->reload_config();
|
||||
wxGetApp().get_tab(Preset::TYPE_PRINTER)->reload_config();
|
||||
|
||||
auto new_height = std::ceil((params.end - params.start) / params.step) + 1;
|
||||
auto obj_bb = model().objects[0]->bounding_box();
|
||||
if (new_height < obj_bb.size().z()) {
|
||||
std::array<Vec3d, 4> plane_pts = get_cut_plane(obj_bb, new_height);
|
||||
cut(0, 0, plane_pts, ModelObjectCutAttribute::KeepLower);
|
||||
}
|
||||
|
||||
_calib_pa_select_added_objects();
|
||||
}
|
||||
|
||||
void Plater::_calib_pa_select_added_objects()
|
||||
{
|
||||
// update printable state for new volumes on canvas3D
|
||||
wxGetApp().plater()->canvas3D()->update_instance_printable_state_for_objects({0});
|
||||
|
||||
Selection &selection = p->view3D->get_canvas3d()->get_selection();
|
||||
selection.clear();
|
||||
selection.add_object(0, false);
|
||||
|
||||
// BBS: update object list selection
|
||||
p->sidebar->obj_list()->update_selections();
|
||||
selection.notify_instance_update(-1, -1);
|
||||
if (p->view3D->get_canvas3d()->get_gizmos_manager().is_enabled()) {
|
||||
// this is required because the selected object changed and the flatten on face an sla support gizmos need to be updated accordingly
|
||||
p->view3D->get_canvas3d()->update_gizmos_on_off_state();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Plater::calib_flowrate(int pass)
|
||||
{
|
||||
if (pass != 1 && pass != 2) return;
|
||||
|
@ -10554,6 +10639,19 @@ void Plater::reslice()
|
|||
// Stop arrange and (or) optimize rotation tasks.
|
||||
this->stop_jobs();
|
||||
|
||||
// softfever: regenerate CalibPressureAdvancePattern custom G-code to apply changes
|
||||
if (model().calib_pa_pattern) {
|
||||
PresetBundle* preset_bundle = wxGetApp().preset_bundle;
|
||||
|
||||
model().calib_pa_pattern->generate_custom_gcodes(
|
||||
wxGetApp().preset_bundle->full_config(),
|
||||
preset_bundle->printers.get_edited_preset().is_bbl_vendor_preset(preset_bundle),
|
||||
model(),
|
||||
get_partplate_list().get_current_plate_origin()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if (printer_technology() == ptSLA) {
|
||||
for (auto& object : model().objects)
|
||||
if (object->sla_points_status == sla::PointsStatus::NoPoints)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue