mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-22 22:24:01 -06:00
Calibration: retraction test
This commit is contained in:
parent
a14943665b
commit
99230aabac
9 changed files with 226 additions and 14 deletions
BIN
resources/calib/retraction/retraction_tower.stl
Normal file
BIN
resources/calib/retraction/retraction_tower.stl
Normal file
Binary file not shown.
|
@ -2844,6 +2844,27 @@ GCode::LayerResult GCode::process_layer(
|
|||
+ "\n";
|
||||
}
|
||||
|
||||
if (print.calib_mode() == CalibMode::Calib_PA_Tower) {
|
||||
gcode += writer().set_pressure_advance(print.calib_params().start + static_cast<int>(print_z) * print.calib_params().step);
|
||||
} else if (print.calib_mode() == CalibMode::Calib_Temp_Tower) {
|
||||
auto offset = static_cast<unsigned int>(print_z / 10.001) * 5;
|
||||
gcode += writer().set_temperature(print.calib_params().start - offset);
|
||||
} else if (print.calib_mode() == CalibMode::Calib_VFA_Tower) {
|
||||
auto _speed = print.calib_params().start + std::floor(print_z / 5.0) * print.calib_params().step;
|
||||
m_calib_config.set_key_value("outer_wall_speed", new ConfigOptionFloat(std::round(_speed)));
|
||||
} else if (print.calib_mode() == CalibMode::Calib_Vol_speed_Tower) {
|
||||
auto _speed = print.calib_params().start + print_z * print.calib_params().step;
|
||||
m_calib_config.set_key_value("outer_wall_speed", new ConfigOptionFloat(std::round(_speed)));
|
||||
}
|
||||
else if (print.calib_mode() == CalibMode::Calib_Retraction_tower) {
|
||||
auto _length = print.calib_params().start + std::floor(print_z) * print.calib_params().step;
|
||||
DynamicConfig _cfg;
|
||||
_cfg.set_key_value("retraction_length", new ConfigOptionFloats{_length});
|
||||
writer().config.apply(_cfg);
|
||||
sprintf(buf, "; Calib_Retraction_tower: Z_HEIGHT: %g, length:%g\n", print_z, _length);
|
||||
gcode += buf;
|
||||
}
|
||||
|
||||
// BBS: don't use lazy_raise when enable spiral vase
|
||||
gcode += this->change_layer(print_z, !m_spiral_vase); // this will increase m_layer_index
|
||||
m_layer = &layer;
|
||||
|
@ -2858,19 +2879,6 @@ GCode::LayerResult GCode::process_layer(
|
|||
config.set_key_value("max_layer_z", new ConfigOptionFloat(m_max_layer_z));
|
||||
}
|
||||
|
||||
if (print.calib_mode() == CalibMode::Calib_PA_Tower) {
|
||||
gcode += writer().set_pressure_advance(print.calib_params().start + static_cast<int>(print_z) * print.calib_params().step);
|
||||
} else if (print.calib_mode() == CalibMode::Calib_Temp_Tower) {
|
||||
auto offset = static_cast<unsigned int>(print_z / 10.001) * 5;
|
||||
gcode += writer().set_temperature(print.calib_params().start - offset);
|
||||
} else if (print.calib_mode() == CalibMode::Calib_VFA_Tower) {
|
||||
auto _speed = print.calib_params().start + std::floor(print_z / 5.0) * print.calib_params().step;
|
||||
m_calib_config.set_key_value("outer_wall_speed", new ConfigOptionFloat(std::round(_speed)));
|
||||
} else if (print.calib_mode() == CalibMode::Calib_Vol_speed_Tower) {
|
||||
auto _speed = print.calib_params().start + print_z * print.calib_params().step;
|
||||
m_calib_config.set_key_value("outer_wall_speed", new ConfigOptionFloat(std::round(_speed)));
|
||||
}
|
||||
|
||||
//BBS
|
||||
if (first_layer) {
|
||||
if (m_config.default_acceleration.value > 0 && m_config.initial_layer_acceleration.value > 0) {
|
||||
|
|
|
@ -13,7 +13,8 @@ enum class CalibMode : int {
|
|||
Calib_PA_Tower,
|
||||
Calib_Temp_Tower,
|
||||
Calib_Vol_speed_Tower,
|
||||
Calib_VFA_Tower
|
||||
Calib_VFA_Tower,
|
||||
Calib_Retraction_tower
|
||||
|
||||
};
|
||||
struct Calib_Params
|
||||
|
|
|
@ -2621,6 +2621,13 @@ void MainFrame::init_menubar_as_editor()
|
|||
m_pa_calib_dlg->ShowModal();
|
||||
}, "", nullptr,
|
||||
[this]() {return m_plater->is_view3D_shown();; }, this);
|
||||
append_menu_item(m_topbar->GetCalibMenu(), wxID_ANY, _L("Retraction test"), _L("Retraction test"),
|
||||
[this](wxCommandEvent&) {
|
||||
if (!m_retraction_calib_dlg)
|
||||
m_retraction_calib_dlg = new Retraction_Test_Dlg((wxWindow*)this, wxID_ANY, m_plater);
|
||||
m_retraction_calib_dlg->ShowModal();
|
||||
}, "", nullptr,
|
||||
[this]() {return m_plater->is_view3D_shown();; }, this);
|
||||
|
||||
// Advance calibrations
|
||||
auto advance_menu = new wxMenu();
|
||||
|
@ -2692,6 +2699,15 @@ void MainFrame::init_menubar_as_editor()
|
|||
}, "", nullptr,
|
||||
[this]() {return m_plater->is_view3D_shown();; }, this);
|
||||
|
||||
// Retraction
|
||||
append_menu_item(calib_menu, wxID_ANY, _L("Retraction test"), _L("Retraction test"),
|
||||
[this](wxCommandEvent&) {
|
||||
if (!m_retraction_calib_dlg)
|
||||
m_retraction_calib_dlg = new Retraction_Test_Dlg((wxWindow*)this, wxID_ANY, m_plater);
|
||||
m_retraction_calib_dlg->ShowModal();
|
||||
}, "", nullptr,
|
||||
[this]() {return m_plater->is_view3D_shown();; }, this);
|
||||
|
||||
// Advance calibrations
|
||||
auto advance_menu = new wxMenu();
|
||||
append_menu_item(
|
||||
|
|
|
@ -341,6 +341,7 @@ public:
|
|||
Temp_Calibration_Dlg* m_temp_calib_dlg{ nullptr };
|
||||
MaxVolumetricSpeed_Test_Dlg* m_vol_test_dlg { nullptr };
|
||||
VFA_Test_Dlg* m_vfa_test_dlg { nullptr };
|
||||
Retraction_Test_Dlg* m_retraction_calib_dlg{ nullptr };
|
||||
|
||||
// BBS. Replace title bar and menu bar with top bar.
|
||||
BBLTopbar* m_topbar{ nullptr };
|
||||
|
|
|
@ -8368,6 +8368,64 @@ void Plater::calib_max_vol_speed(const Calib_Params& params)
|
|||
|
||||
p->background_process.fff_print()->set_calib_params(new_params);
|
||||
}
|
||||
|
||||
void Plater::calib_retraction(const Calib_Params& params)
|
||||
{
|
||||
const auto calib_retraction_name = wxString::Format(L"Retraction test");
|
||||
new_project(false, false, calib_retraction_name);
|
||||
wxGetApp().mainframe->select_tab(size_t(MainFrame::tp3DEditor));
|
||||
if (params.mode != CalibMode::Calib_Retraction_tower)
|
||||
return;
|
||||
|
||||
add_model(false, Slic3r::resources_dir() + "/calib/retraction/retraction_tower.stl");
|
||||
|
||||
auto print_config = &wxGetApp().preset_bundle->prints.get_edited_preset().config;
|
||||
auto filament_config = &wxGetApp().preset_bundle->filaments.get_edited_preset().config;
|
||||
auto printer_config = &wxGetApp().preset_bundle->printers.get_edited_preset().config;
|
||||
auto obj = model().objects[0];
|
||||
|
||||
//auto bed_shape = printer_config->option<ConfigOptionPoints>("printable_area")->values;
|
||||
//BoundingBoxf bed_ext = get_extents(bed_shape);
|
||||
//auto scale_obj = (bed_ext.size().x() - 10) / obj->bounding_box().size().x();
|
||||
//if (scale_obj < 1.0)
|
||||
// obj->scale(scale_obj, 1, 1);
|
||||
|
||||
//const ConfigOptionFloats* nozzle_diameter_config = printer_config->option<ConfigOptionFloats>("nozzle_diameter");
|
||||
//assert(nozzle_diameter_config->values.size() > 0);
|
||||
//double nozzle_diameter = nozzle_diameter_config->values[0];
|
||||
//double line_width = nozzle_diameter * 1.75;
|
||||
double layer_height = 0.2;
|
||||
|
||||
auto max_lh = printer_config->option<ConfigOptionFloats>("max_layer_height");
|
||||
if (max_lh->values[0] < layer_height)
|
||||
max_lh->values[0] = { layer_height };
|
||||
|
||||
obj->config.set_key_value("wall_loops", new ConfigOptionInt(2));
|
||||
obj->config.set_key_value("top_shell_layers", new ConfigOptionInt(0));
|
||||
obj->config.set_key_value("bottom_shell_layers", new ConfigOptionInt(1));
|
||||
obj->config.set_key_value("sparse_infill_density", new ConfigOptionPercent(0));
|
||||
obj->config.set_key_value("initial_layer_print_height", new ConfigOptionFloat(layer_height));
|
||||
obj->config.set_key_value("layer_height", new ConfigOptionFloat(layer_height));
|
||||
|
||||
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();
|
||||
|
||||
// cut upper
|
||||
auto obj_bb = obj->bounding_box();
|
||||
auto height = (params.end - params.start + 1) / params.step;
|
||||
if (height < obj_bb.size().z()) {
|
||||
std::array<Vec3d, 4> plane_pts = get_cut_plane(obj_bb, height);
|
||||
cut(0, 0, plane_pts, ModelObjectCutAttribute::KeepLower);
|
||||
}
|
||||
|
||||
p->background_process.fff_print()->set_calib_params(params);
|
||||
}
|
||||
|
||||
void Plater::calib_VFA(const Calib_Params& params)
|
||||
{
|
||||
const auto calib_vfa_name = wxString::Format(L"VFA test");
|
||||
|
|
|
@ -237,6 +237,7 @@ public:
|
|||
void calib_flowrate(int pass);
|
||||
void calib_temp(const Calib_Params& params);
|
||||
void calib_max_vol_speed(const Calib_Params& params);
|
||||
void calib_retraction(const Calib_Params& params);
|
||||
void calib_VFA(const Calib_Params& params);
|
||||
|
||||
BuildVolume_Type get_build_volume_type() const;
|
||||
|
|
|
@ -584,4 +584,111 @@ void VFA_Test_Dlg::on_dpi_changed(const wxRect& suggested_rect)
|
|||
this->Refresh();
|
||||
Fit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Retraction_Test_Dlg
|
||||
//
|
||||
|
||||
Retraction_Test_Dlg::Retraction_Test_Dlg(wxWindow* parent, wxWindowID id, Plater* plater)
|
||||
: DPIDialog(parent, id, _L("Retraction test"), wxDefaultPosition, parent->FromDIP(wxSize(-1, 280)), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), m_plater(plater)
|
||||
{
|
||||
wxBoxSizer* v_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
SetSizer(v_sizer);
|
||||
|
||||
// Settings
|
||||
//
|
||||
wxString start_length_str = _L("Start retraction length: ");
|
||||
wxString end_length_str = _L("End retraction length: ");
|
||||
wxString length_step_str = _L("step: ");
|
||||
auto text_size = wxWindow::GetTextExtent(start_length_str);
|
||||
text_size.IncTo(wxWindow::GetTextExtent(end_length_str));
|
||||
text_size.IncTo(wxWindow::GetTextExtent(length_step_str));
|
||||
text_size.x = text_size.x * 1.5;
|
||||
wxStaticBoxSizer* settings_sizer = new wxStaticBoxSizer(wxVERTICAL, this, _L("Settings"));
|
||||
|
||||
auto st_size = FromDIP(wxSize(text_size.x, -1));
|
||||
auto ti_size = FromDIP(wxSize(90, -1));
|
||||
// start length
|
||||
auto start_length_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
auto start_length_text = new wxStaticText(this, wxID_ANY, start_length_str, wxDefaultPosition, st_size, wxALIGN_LEFT);
|
||||
m_tiStart = new TextInput(this, std::to_string(0), _L("mm"), "", wxDefaultPosition, ti_size, wxTE_CENTRE);
|
||||
m_tiStart->GetTextCtrl()->SetValidator(wxTextValidator(wxFILTER_NUMERIC));
|
||||
|
||||
start_length_sizer->Add(start_length_text, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
||||
start_length_sizer->Add(m_tiStart, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
||||
settings_sizer->Add(start_length_sizer);
|
||||
|
||||
// end length
|
||||
auto end_length_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
auto end_length_text = new wxStaticText(this, wxID_ANY, end_length_str, wxDefaultPosition, st_size, wxALIGN_LEFT);
|
||||
m_tiEnd = new TextInput(this, std::to_string(2), _L("mm"), "", wxDefaultPosition, ti_size, wxTE_CENTRE);
|
||||
m_tiStart->GetTextCtrl()->SetValidator(wxTextValidator(wxFILTER_NUMERIC));
|
||||
end_length_sizer->Add(end_length_text, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
||||
end_length_sizer->Add(m_tiEnd, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
||||
settings_sizer->Add(end_length_sizer);
|
||||
|
||||
// length step
|
||||
auto length_step_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
auto length_step_text = new wxStaticText(this, wxID_ANY, length_step_str, wxDefaultPosition, st_size, wxALIGN_LEFT);
|
||||
m_tiStep = new TextInput(this, wxString::FromDouble(0.1), _L("mm/mm"), "", wxDefaultPosition, ti_size, wxTE_CENTRE);
|
||||
m_tiStart->GetTextCtrl()->SetValidator(wxTextValidator(wxFILTER_NUMERIC));
|
||||
length_step_sizer->Add(length_step_text, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
||||
length_step_sizer->Add(m_tiStep, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
||||
settings_sizer->Add(length_step_sizer);
|
||||
|
||||
v_sizer->Add(settings_sizer);
|
||||
v_sizer->Add(0, FromDIP(10), 0, wxEXPAND, 5);
|
||||
m_btnStart = new Button(this, _L("OK"));
|
||||
StateColor btn_bg_green(std::pair<wxColour, int>(wxColour(0, 137, 123), StateColor::Pressed),
|
||||
std::pair<wxColour, int>(wxColour(38, 166, 154), StateColor::Hovered),
|
||||
std::pair<wxColour, int>(wxColour(0, 150, 136), StateColor::Normal));
|
||||
|
||||
m_btnStart->SetBackgroundColor(btn_bg_green);
|
||||
m_btnStart->SetBorderColor(wxColour(0, 150, 136));
|
||||
m_btnStart->SetTextColor(wxColour("#FFFFFE"));
|
||||
m_btnStart->SetSize(wxSize(FromDIP(48), FromDIP(24)));
|
||||
m_btnStart->SetMinSize(wxSize(FromDIP(48), FromDIP(24)));
|
||||
m_btnStart->SetCornerRadius(FromDIP(3));
|
||||
m_btnStart->Bind(wxEVT_BUTTON, &Retraction_Test_Dlg::on_start, this);
|
||||
v_sizer->Add(m_btnStart, 0, wxALL | wxALIGN_RIGHT, FromDIP(5));
|
||||
|
||||
m_btnStart->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(Retraction_Test_Dlg::on_start), NULL, this);
|
||||
|
||||
//wxGetApp().UpdateDlgDarkUI(this);
|
||||
|
||||
Layout();
|
||||
Fit();
|
||||
}
|
||||
|
||||
Retraction_Test_Dlg::~Retraction_Test_Dlg() {
|
||||
// Disconnect Events
|
||||
m_btnStart->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(Retraction_Test_Dlg::on_start), NULL, this);
|
||||
}
|
||||
|
||||
void Retraction_Test_Dlg::on_start(wxCommandEvent& event) {
|
||||
bool read_double = false;
|
||||
read_double = m_tiStart->GetTextCtrl()->GetValue().ToDouble(&m_params.start);
|
||||
read_double = read_double && m_tiEnd->GetTextCtrl()->GetValue().ToDouble(&m_params.end);
|
||||
read_double = read_double && m_tiStep->GetTextCtrl()->GetValue().ToDouble(&m_params.step);
|
||||
|
||||
if (!read_double || m_params.start < 0 || m_params.step <= 0 || m_params.end < (m_params.start + m_params.step)) {
|
||||
MessageDialog msg_dlg(nullptr, _L("Please input valid values:\nstart > 0 \step >= 0\nend > start + step)"), wxEmptyString, wxICON_WARNING | wxOK);
|
||||
msg_dlg.ShowModal();
|
||||
return;
|
||||
}
|
||||
|
||||
m_params.mode = CalibMode::Calib_Retraction_tower;
|
||||
m_plater->calib_retraction(m_params);
|
||||
EndModal(wxID_OK);
|
||||
|
||||
}
|
||||
|
||||
void Retraction_Test_Dlg::on_dpi_changed(const wxRect& suggested_rect) {
|
||||
this->Refresh();
|
||||
Fit();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
|
|
|
@ -102,6 +102,26 @@ protected:
|
|||
Plater* m_plater;
|
||||
};
|
||||
|
||||
|
||||
class Retraction_Test_Dlg : public DPIDialog
|
||||
{
|
||||
public:
|
||||
Retraction_Test_Dlg (wxWindow* parent, wxWindowID id, Plater* plater);
|
||||
~Retraction_Test_Dlg ();
|
||||
void on_dpi_changed(const wxRect& suggested_rect) override;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void on_start(wxCommandEvent& event);
|
||||
Calib_Params m_params;
|
||||
|
||||
TextInput* m_tiStart;
|
||||
TextInput* m_tiEnd;
|
||||
TextInput* m_tiStep;
|
||||
Button* m_btnStart;
|
||||
Plater* m_plater;
|
||||
};
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue