mirror of
https://github.com/QIDITECH/QIDISlicer.git
synced 2026-01-31 07:58:43 +03:00
Optimized PressureAdvance
This commit is contained in:
@@ -5363,52 +5363,16 @@ void Plater::add_model(bool imperial_units/* = false*/)
|
||||
if (! load_files(paths, true, false, imperial_units).empty())
|
||||
wxGetApp().mainframe->update_title();
|
||||
}
|
||||
//B34
|
||||
void Plater::add_model_calibration(bool imperial_units /* = false*/, std::string fname /* = ""*/)
|
||||
{
|
||||
std::vector<fs::path> paths;
|
||||
|
||||
if (fname.empty()) {
|
||||
wxArrayString input_files;
|
||||
wxGetApp().import_model(this, input_files);
|
||||
if (input_files.empty())
|
||||
return;
|
||||
|
||||
for (const auto &file : input_files)
|
||||
paths.emplace_back(into_path(file));
|
||||
} else {
|
||||
paths.emplace_back(fname);
|
||||
}
|
||||
|
||||
wxString snapshot_label;
|
||||
assert(!paths.empty());
|
||||
if (paths.size() == 1) {
|
||||
snapshot_label = "Import Object";
|
||||
snapshot_label += ": ";
|
||||
snapshot_label += wxString::FromUTF8(paths.front().filename().string().c_str());
|
||||
} else {
|
||||
snapshot_label = "Import Objects";
|
||||
snapshot_label += ": ";
|
||||
snapshot_label += paths.front().filename().string().c_str();
|
||||
for (size_t i = 1; i < paths.size(); ++i) {
|
||||
snapshot_label += ", ";
|
||||
snapshot_label += wxString::FromUTF8(paths[i].filename().string().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
Plater::TakeSnapshot snapshot(this, snapshot_label);
|
||||
if (!load_files(paths, true, false, imperial_units).empty())
|
||||
wxGetApp().mainframe->update_title();
|
||||
}
|
||||
|
||||
//B34
|
||||
void Plater::calib_flowrate_coarse()
|
||||
{
|
||||
new_project();
|
||||
wxGetApp().mainframe->select_tab(size_t(0));
|
||||
Tab *tab_print = wxGetApp().get_tab(Preset::TYPE_PRINT);
|
||||
Tab *tab_filament = wxGetApp().get_tab(Preset::TYPE_FILAMENT);
|
||||
Tab *tab_printer = wxGetApp().get_tab(Preset::TYPE_PRINTER);
|
||||
DynamicPrintConfig new_config;
|
||||
wxGetApp().mainframe->select_tab(size_t(0));
|
||||
|
||||
new_config.set_key_value("complete_objects", new ConfigOptionBool(true));
|
||||
new_config.set_key_value("extruder_clearance_radius", new ConfigOptionFloat(1));
|
||||
@@ -5425,7 +5389,10 @@ void Plater::calib_flowrate_coarse()
|
||||
tab_print->load_config(new_config);
|
||||
tab_filament->load_config(new_config);
|
||||
tab_printer->load_config(new_config);
|
||||
add_model_calibration(false, (boost::filesystem::path(Slic3r::resources_dir()) / "calib" / "FlowRate" / "flowrate_coarse.3mf").string());
|
||||
|
||||
std::vector<fs::path> model_path;
|
||||
model_path.emplace_back(Slic3r::resources_dir() + "/calib/FlowRate/flowrate_coarse.3mf");
|
||||
load_files(model_path, true, false, false);
|
||||
|
||||
std::string message = _u8L("NOTICE: The calibration function modifies some parameters. After calibration, record the best value and restore the other parameters.");
|
||||
get_notification_manager()->push_notification(NotificationType::CustomNotification, NotificationManager::NotificationLevel::PrintInfoNotificationLevel, message);
|
||||
@@ -5433,6 +5400,7 @@ void Plater::calib_flowrate_coarse()
|
||||
|
||||
void Plater::calib_flowrate_fine(const Calib_Params ¶ms)
|
||||
{
|
||||
new_project();
|
||||
wxGetApp().mainframe->select_tab(size_t(0));
|
||||
if (params.mode != CalibMode::Calib_FRF)
|
||||
return;
|
||||
@@ -5460,32 +5428,58 @@ void Plater::calib_flowrate_fine(const Calib_Params ¶ms)
|
||||
tab_print->load_config(new_config);
|
||||
tab_filament->load_config(new_config);
|
||||
tab_printer->load_config(new_config);
|
||||
add_model_calibration(false, (boost::filesystem::path(Slic3r::resources_dir()) / "calib" / "FlowRate" / "flowrate_fine.3mf").string());
|
||||
|
||||
std::vector<fs::path> model_path;
|
||||
model_path.emplace_back(Slic3r::resources_dir() + "/calib/FlowRate/flowrate_fine.3mf");
|
||||
load_files(model_path, true, false, false);
|
||||
|
||||
std::string message = _u8L("NOTICE: The calibration function modifies some parameters. After calibration, record the best value and restore the other parameters.");
|
||||
get_notification_manager()->push_notification(NotificationType::CustomNotification, NotificationManager::NotificationLevel::PrintInfoNotificationLevel, message);
|
||||
}
|
||||
|
||||
//B34
|
||||
void Plater::calib_pa(const Calib_Params ¶ms)
|
||||
void Plater::calib_pa(const int pa_method, wxString StartPA, wxString EndPA, wxString PAStep)
|
||||
{
|
||||
const auto calib_pa_name = wxString::Format(L"Pressure Advance Test");
|
||||
new_project();
|
||||
wxGetApp().mainframe->select_tab(size_t(0));
|
||||
std::vector<fs::path> model_path;
|
||||
//double pa = StartPA;
|
||||
|
||||
switch (params.mode) {
|
||||
case CalibMode::Calib_PA_Line:
|
||||
add_model_calibration(false, Slic3r::resources_dir() + "/calib/PressureAdvance/pa_line.stl");
|
||||
break;
|
||||
//case CalibMode::Calib_PA_Pattern: _calib_pa_pattern(params); break;
|
||||
//case CalibMode::Calib_PA_Tower: _calib_pa_tower(params); break;
|
||||
default: break;
|
||||
switch (pa_method) {
|
||||
case 0:
|
||||
{
|
||||
Tab *tab_printer = wxGetApp().get_tab(Preset::TYPE_PRINTER);
|
||||
DynamicPrintConfig new_config;
|
||||
auto printerConfig = &wxGetApp().preset_bundle->printers.get_edited_preset().config;
|
||||
|
||||
auto end_gcode = printerConfig->opt_string("end_gcode");
|
||||
std::string set_pa_gcode = "M900 K";
|
||||
end_gcode = set_pa_gcode + end_gcode;
|
||||
new_config.set_key_value("end_gcode", new ConfigOptionString(end_gcode));
|
||||
tab_printer->load_config(new_config);
|
||||
|
||||
model_path.emplace_back(Slic3r::resources_dir() + "/calib/PressureAdvance/pa_line.stl");
|
||||
load_files(model_path, true, false, false);
|
||||
break;
|
||||
}
|
||||
|
||||
case 1:
|
||||
{
|
||||
model_path.emplace_back(Slic3r::resources_dir() + "/calib/PressureAdvance/pa_pattern.stl");
|
||||
load_files(model_path, true, false, false);
|
||||
break;
|
||||
}
|
||||
|
||||
case 2:
|
||||
{
|
||||
model_path.emplace_back(Slic3r::resources_dir() + "/calib/PressureAdvance/pa_tower.stl");
|
||||
load_files(model_path, true, false, false);
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
|
||||
//p->background_process.fff_print()->set_calib_params(params);
|
||||
}
|
||||
|
||||
|
||||
void Plater::import_zip_archive()
|
||||
{
|
||||
wxString input_file;
|
||||
|
||||
@@ -167,7 +167,7 @@ public:
|
||||
SLAPrint& sla_print();
|
||||
|
||||
//B34
|
||||
void calib_pa(const Calib_Params ¶ms);
|
||||
void calib_pa(const int pa_method, wxString StartPA, wxString EndPA, wxString PAStep);
|
||||
void calib_flowrate_coarse();
|
||||
void calib_flowrate_fine(const Calib_Params ¶ms);
|
||||
|
||||
|
||||
@@ -138,21 +138,16 @@ void FRF_Calibration_Dlg::on_dpi_changed(const wxRect& suggested_rect) {
|
||||
}
|
||||
|
||||
PA_Calibration_Dlg::PA_Calibration_Dlg(wxWindow* parent, wxWindowID id, Plater* plater)
|
||||
: DPIDialog(parent, id, _L("PA Calibration"), wxDefaultPosition, parent->FromDIP(wxSize(-1, 280)), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), m_plater(plater)
|
||||
: DPIDialog(parent, id, _L("Pressure Advance Calibration"), wxDefaultPosition, parent->FromDIP(wxSize(-1, 280)), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), m_plater(plater)
|
||||
{
|
||||
wxBoxSizer* v_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
SetSizer(v_sizer);
|
||||
wxBoxSizer* choice_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
wxString m_rbExtruderTypeChoices[] = { _L("DDE"), _L("Bowden") };
|
||||
int m_rbExtruderTypeNChoices = sizeof(m_rbExtruderTypeChoices) / sizeof(wxString);
|
||||
m_rbExtruderType = new wxRadioBox(this, wxID_ANY, _L("Extruder type"), wxDefaultPosition, wxDefaultSize, m_rbExtruderTypeNChoices, m_rbExtruderTypeChoices, 2, wxRA_SPECIFY_COLS);
|
||||
m_rbExtruderType->SetSelection(0);
|
||||
choice_sizer->Add(m_rbExtruderType, 0, wxALL, 5);
|
||||
choice_sizer->Add(FromDIP(5), 0, 0, wxEXPAND, 5);
|
||||
wxString m_rbMethodChoices[] = { _L("PA Tower"), _L("PA Line"), _L("PA Pattern") };
|
||||
wxString m_rbMethodChoices[] = { _L("PA Line"), _L("PA Pattern"), _L("PA Tower") };
|
||||
int m_rbMethodNChoices = sizeof(m_rbMethodChoices) / sizeof(wxString);
|
||||
m_rbMethod = new wxRadioBox(this, wxID_ANY, _L("Method"), wxDefaultPosition, wxDefaultSize, m_rbMethodNChoices, m_rbMethodChoices, 2, wxRA_SPECIFY_COLS);
|
||||
m_rbMethod = new wxRadioBox(this, wxID_ANY, _L("Method"), wxDefaultPosition, wxDefaultSize, m_rbMethodNChoices, m_rbMethodChoices, 1, wxRA_SPECIFY_COLS);
|
||||
m_rbMethod->SetSelection(0);
|
||||
choice_sizer->Add(m_rbMethod, 0, wxALL, 5);
|
||||
|
||||
@@ -199,9 +194,6 @@ PA_Calibration_Dlg::PA_Calibration_Dlg(wxWindow* parent, wxWindowID id, Plater*
|
||||
PA_step_sizer->Add(m_tiPAStep, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
||||
settings_sizer->Add(PA_step_sizer);
|
||||
|
||||
settings_sizer->Add(create_item_checkbox(_L("Print numbers"), this, &m_params.print_numbers, m_cbPrintNum));
|
||||
m_cbPrintNum->SetValue(false);
|
||||
|
||||
v_sizer->Add(settings_sizer);
|
||||
v_sizer->Add(0, FromDIP(10), 0, wxEXPAND, 5);
|
||||
m_btnStart = new Button(this, _L("OK"));
|
||||
@@ -221,10 +213,8 @@ PA_Calibration_Dlg::PA_Calibration_Dlg(wxWindow* parent, wxWindowID id, Plater*
|
||||
PA_Calibration_Dlg::reset_params();
|
||||
|
||||
// Connect Events
|
||||
m_rbExtruderType->Connect(wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler(PA_Calibration_Dlg::on_extruder_type_changed), NULL, this);
|
||||
m_rbMethod->Connect(wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler(PA_Calibration_Dlg::on_method_changed), NULL, this);
|
||||
this->Connect(wxEVT_SHOW, wxShowEventHandler(PA_Calibration_Dlg::on_show));
|
||||
//wxGetApp().UpdateDlgDarkUI(this);
|
||||
|
||||
Layout();
|
||||
Fit();
|
||||
@@ -232,49 +222,31 @@ PA_Calibration_Dlg::PA_Calibration_Dlg(wxWindow* parent, wxWindowID id, Plater*
|
||||
|
||||
PA_Calibration_Dlg::~PA_Calibration_Dlg() {
|
||||
// Disconnect Events
|
||||
m_rbExtruderType->Disconnect(wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler(PA_Calibration_Dlg::on_extruder_type_changed), NULL, this);
|
||||
m_rbMethod->Disconnect(wxEVT_COMMAND_RADIOBOX_SELECTED, wxCommandEventHandler(PA_Calibration_Dlg::on_method_changed), NULL, this);
|
||||
m_btnStart->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(PA_Calibration_Dlg::on_start), NULL, this);
|
||||
}
|
||||
|
||||
void PA_Calibration_Dlg::reset_params() {
|
||||
bool isDDE = m_rbExtruderType->GetSelection() == 0 ? true : false;
|
||||
int method = m_rbMethod->GetSelection();
|
||||
|
||||
m_tiStartPA->GetTextCtrl()->SetValue(wxString::FromDouble(0.0));
|
||||
|
||||
switch (method) {
|
||||
case 1:
|
||||
m_params.mode = CalibMode::Calib_PA_Line;
|
||||
m_tiEndPA->GetTextCtrl()->SetValue(wxString::FromDouble(0.1));
|
||||
m_tiPAStep->GetTextCtrl()->SetValue(wxString::FromDouble(0.002));
|
||||
m_cbPrintNum->SetValue(true);
|
||||
m_cbPrintNum->Enable(true);
|
||||
break;
|
||||
case 2:
|
||||
m_params.mode = CalibMode::Calib_PA_Pattern;
|
||||
m_tiEndPA->GetTextCtrl()->SetValue(wxString::FromDouble(0.08));
|
||||
m_tiPAStep->GetTextCtrl()->SetValue(wxString::FromDouble(0.005));
|
||||
m_cbPrintNum->SetValue(true);
|
||||
m_cbPrintNum->Enable(false);
|
||||
break;
|
||||
default:
|
||||
case 2:
|
||||
m_params.mode = CalibMode::Calib_PA_Tower;
|
||||
m_tiEndPA->GetTextCtrl()->SetValue(wxString::FromDouble(0.1));
|
||||
m_tiPAStep->GetTextCtrl()->SetValue(wxString::FromDouble(0.002));
|
||||
m_cbPrintNum->SetValue(false);
|
||||
m_cbPrintNum->Enable(false);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!isDDE) {
|
||||
m_tiEndPA->GetTextCtrl()->SetValue(wxString::FromDouble(1.0));
|
||||
|
||||
if (m_params.mode == CalibMode::Calib_PA_Pattern) {
|
||||
m_tiPAStep->GetTextCtrl()->SetValue(wxString::FromDouble(0.05));
|
||||
} else {
|
||||
m_tiPAStep->GetTextCtrl()->SetValue(wxString::FromDouble(0.02));
|
||||
}
|
||||
default:
|
||||
m_params.mode = CalibMode::Calib_PA_Line;
|
||||
m_tiEndPA->GetTextCtrl()->SetValue(wxString::FromDouble(0.1));
|
||||
m_tiPAStep->GetTextCtrl()->SetValue(wxString::FromDouble(0.002));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,25 +263,19 @@ void PA_Calibration_Dlg::on_start(wxCommandEvent& event) {
|
||||
|
||||
switch (m_rbMethod->GetSelection()) {
|
||||
case 1:
|
||||
m_params.mode = CalibMode::Calib_PA_Line;
|
||||
break;
|
||||
case 2:
|
||||
m_params.mode = CalibMode::Calib_PA_Pattern;
|
||||
break;
|
||||
default:
|
||||
case 2:
|
||||
m_params.mode = CalibMode::Calib_PA_Tower;
|
||||
break;
|
||||
default:
|
||||
m_params.mode = CalibMode::Calib_PA_Line;
|
||||
}
|
||||
|
||||
m_params.print_numbers = m_cbPrintNum->GetValue();
|
||||
|
||||
m_plater->calib_pa(m_params);
|
||||
m_plater->calib_pa(m_rbMethod->GetSelection(), m_tiStartPA->GetTextCtrl()->GetValue(), m_tiEndPA->GetTextCtrl()->GetValue(), m_tiPAStep->GetTextCtrl()->GetValue());
|
||||
EndModal(wxID_OK);
|
||||
}
|
||||
|
||||
}
|
||||
void PA_Calibration_Dlg::on_extruder_type_changed(wxCommandEvent& event) {
|
||||
PA_Calibration_Dlg::reset_params();
|
||||
event.Skip();
|
||||
}
|
||||
void PA_Calibration_Dlg::on_method_changed(wxCommandEvent& event) {
|
||||
PA_Calibration_Dlg::reset_params();
|
||||
event.Skip();
|
||||
@@ -324,22 +290,4 @@ void PA_Calibration_Dlg::on_show(wxShowEvent& event) {
|
||||
PA_Calibration_Dlg::reset_params();
|
||||
}
|
||||
|
||||
// Temp Calib dlg
|
||||
//
|
||||
enum FILAMENT_TYPE : int
|
||||
{
|
||||
tPLA = 0,
|
||||
tABS_ASA,
|
||||
tPETG,
|
||||
tTPU,
|
||||
tPA_CF,
|
||||
tPET_CF,
|
||||
tCustom
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
|
||||
@@ -44,22 +44,15 @@ public:
|
||||
protected:
|
||||
void reset_params();
|
||||
virtual void on_start(wxCommandEvent& event);
|
||||
virtual void on_extruder_type_changed(wxCommandEvent& event);
|
||||
virtual void on_method_changed(wxCommandEvent& event);
|
||||
|
||||
protected:
|
||||
bool m_bDDE;
|
||||
Calib_Params m_params;
|
||||
|
||||
|
||||
wxRadioBox* m_rbExtruderType;
|
||||
wxRadioBox* m_rbMethod;
|
||||
TextInput* m_tiStartPA;
|
||||
TextInput* m_tiEndPA;
|
||||
TextInput* m_tiPAStep;
|
||||
CheckBoxInWT *m_cbPrintNum;
|
||||
Button* m_btnStart;
|
||||
|
||||
Plater* m_plater;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user