mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-07 23:17:35 -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
|
@ -6,7 +6,20 @@
|
|||
#include "MainFrame.hpp"
|
||||
#include <string>
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
void ParseStringValues(std::string str, std::vector<double> &vec)
|
||||
{
|
||||
vec.clear();
|
||||
std::replace(str.begin(), str.end(), ',', ' ');
|
||||
std::istringstream inss(str);
|
||||
std::copy_if(std::istream_iterator<int>(inss), std::istream_iterator<int>(), std::back_inserter(vec),
|
||||
[](int x){ return x > 0; });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
wxBoxSizer* create_item_checkbox(wxString title, wxWindow* parent, bool* value, CheckBox*& checkbox)
|
||||
{
|
||||
wxBoxSizer* m_sizer_checkbox = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
@ -59,14 +72,18 @@ PA_Calibration_Dlg::PA_Calibration_Dlg(wxWindow* parent, wxWindowID id, Plater*
|
|||
wxString start_pa_str = _L("Start PA: ");
|
||||
wxString end_pa_str = _L("End PA: ");
|
||||
wxString PA_step_str = _L("PA step: ");
|
||||
wxString sp_accel_str = _L("Accelerations: ");
|
||||
wxString sp_speed_str = _L("Speeds: ");
|
||||
auto text_size = wxWindow::GetTextExtent(start_pa_str);
|
||||
text_size.IncTo(wxWindow::GetTextExtent(end_pa_str));
|
||||
text_size.IncTo(wxWindow::GetTextExtent(PA_step_str));
|
||||
text_size.x = text_size.x * 1.5;
|
||||
text_size.IncTo(wxWindow::GetTextExtent(sp_accel_str));
|
||||
text_size.IncTo(wxWindow::GetTextExtent(sp_speed_str));
|
||||
text_size.x = text_size.x * 1.1;
|
||||
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));
|
||||
auto ti_size = FromDIP(wxSize(140, -1));
|
||||
// start PA
|
||||
auto start_PA_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
auto start_pa_text = new wxStaticText(this, wxID_ANY, start_pa_str, wxDefaultPosition, st_size, wxALIGN_LEFT);
|
||||
|
@ -98,6 +115,27 @@ PA_Calibration_Dlg::PA_Calibration_Dlg(wxWindow* parent, wxWindowID id, Plater*
|
|||
settings_sizer->Add(create_item_checkbox(_L("Print numbers"), this, &m_params.print_numbers, m_cbPrintNum));
|
||||
m_cbPrintNum->SetValue(false);
|
||||
|
||||
wxTextValidator val_list_validator(wxFILTER_INCLUDE_CHAR_LIST);
|
||||
val_list_validator.SetCharIncludes(wxString("0123456789,"));
|
||||
|
||||
auto sp_accel_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
auto sp_accel_text = new wxStaticText(this, wxID_ANY, sp_accel_str, wxDefaultPosition, st_size, wxALIGN_LEFT);
|
||||
m_tiBMAccels = new TextInput(this, "", "", "", wxDefaultPosition, ti_size, wxTE_PROCESS_ENTER);
|
||||
m_tiBMAccels->SetToolTip(_L("Comma-separated list of printing accelerations"));
|
||||
m_tiBMAccels->GetTextCtrl()->SetValidator(val_list_validator);
|
||||
sp_accel_sizer->Add(sp_accel_text, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
||||
sp_accel_sizer->Add(m_tiBMAccels, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
||||
settings_sizer->Add(sp_accel_sizer);
|
||||
|
||||
auto sp_speed_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
auto sp_speed_text = new wxStaticText(this, wxID_ANY, sp_speed_str, wxDefaultPosition, st_size, wxALIGN_LEFT);
|
||||
m_tiBMSpeeds = new TextInput(this, "", "", "", wxDefaultPosition, ti_size, wxTE_PROCESS_ENTER);
|
||||
m_tiBMSpeeds->SetToolTip(_L("Comma-separated list of printing speeds"));
|
||||
m_tiBMSpeeds->GetTextCtrl()->SetValidator(val_list_validator);
|
||||
sp_speed_sizer->Add(sp_speed_text, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
||||
sp_speed_sizer->Add(m_tiBMSpeeds, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
|
||||
settings_sizer->Add(sp_speed_sizer);
|
||||
|
||||
v_sizer->Add(settings_sizer);
|
||||
v_sizer->Add(0, FromDIP(10), 0, wxEXPAND, 5);
|
||||
m_btnStart = new Button(this, _L("OK"));
|
||||
|
@ -146,6 +184,8 @@ void PA_Calibration_Dlg::reset_params() {
|
|||
m_tiPAStep->GetTextCtrl()->SetValue(wxString::FromDouble(0.002));
|
||||
m_cbPrintNum->SetValue(true);
|
||||
m_cbPrintNum->Enable(true);
|
||||
m_tiBMAccels->Enable(false);
|
||||
m_tiBMSpeeds->Enable(false);
|
||||
break;
|
||||
case 2:
|
||||
m_params.mode = CalibMode::Calib_PA_Pattern;
|
||||
|
@ -153,6 +193,8 @@ void PA_Calibration_Dlg::reset_params() {
|
|||
m_tiPAStep->GetTextCtrl()->SetValue(wxString::FromDouble(0.005));
|
||||
m_cbPrintNum->SetValue(true);
|
||||
m_cbPrintNum->Enable(false);
|
||||
m_tiBMAccels->Enable(true);
|
||||
m_tiBMSpeeds->Enable(true);
|
||||
break;
|
||||
default:
|
||||
m_params.mode = CalibMode::Calib_PA_Tower;
|
||||
|
@ -160,6 +202,8 @@ void PA_Calibration_Dlg::reset_params() {
|
|||
m_tiPAStep->GetTextCtrl()->SetValue(wxString::FromDouble(0.002));
|
||||
m_cbPrintNum->SetValue(false);
|
||||
m_cbPrintNum->Enable(false);
|
||||
m_tiBMAccels->Enable(false);
|
||||
m_tiBMSpeeds->Enable(false);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -197,6 +241,8 @@ void PA_Calibration_Dlg::on_start(wxCommandEvent& event) {
|
|||
}
|
||||
|
||||
m_params.print_numbers = m_cbPrintNum->GetValue();
|
||||
ParseStringValues(m_tiBMAccels->GetTextCtrl()->GetValue().ToStdString(), m_params.accelerations);
|
||||
ParseStringValues(m_tiBMSpeeds->GetTextCtrl()->GetValue().ToStdString(), m_params.speeds);
|
||||
|
||||
m_plater->calib_pa(m_params);
|
||||
EndModal(wxID_OK);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue