Update calib_dlg

This commit is contained in:
76Octane
2023-08-30 16:53:46 +08:00
parent 140ee733ca
commit 49f599efbf
2 changed files with 47 additions and 19 deletions

View File

@@ -41,33 +41,57 @@ FRF_Calibration_Dlg::FRF_Calibration_Dlg(wxWindow* parent, wxWindowID id, Plater
SetSizer(v_sizer);
// Settings
DynamicPrintConfig m_config;
auto filament_config = &wxGetApp().preset_bundle->filaments.get_edited_preset().config;
wxString start_length_str = _L("Extrusion Multipler: ");
auto text_size = wxWindow::GetTextExtent(start_length_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));
// extru length
auto desc_size = FromDIP(wxSize(300, -1));
// extru
auto multip = filament_config->opt_float("extrusion_multiplier",0);
std::string multip_str = std::to_string(multip);
if (multip_str.find(".") > 0) {
size_t fp = multip_str.rfind(".");
size_t f = multip_str.rfind("0");
while (f > fp) {
if (f != -1) {
multip_str = multip_str.erase(f);
}
f = multip_str.rfind("0");
}
fp = multip_str.rfind(".");
if (fp == multip_str.size() - 1) {
multip_str = multip_str.erase(fp);
}
}
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_tiExtru = new TextInput(this, "", "", "", wxDefaultPosition, ti_size, wxTE_CENTRE);
m_tiExtru = new TextInput(this, multip_str, "", "", wxDefaultPosition, ti_size, wxTE_CENTRE);
m_tiExtru->GetTextCtrl()->SetValidator(wxTextValidator(wxFILTER_NUMERIC));
// desc
auto setting_desc = new wxStaticText(this, wxID_ANY, _u8L("Please note that modifying the extrusion multiplier parameter will affect different extrusion ratios.\nValid values area:0.9-1.1"),
wxDefaultPosition, desc_size, wxALIGN_LEFT);
setting_desc->Wrap(setting_desc->GetClientSize().x);
setting_desc->SetForegroundColour(wxColour(*wxRED));
// delay
start_length_sizer->Add(start_length_text, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
start_length_sizer->Add(m_tiExtru, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
settings_sizer->Add(start_length_sizer);
v_sizer->Add(settings_sizer);
v_sizer->Add(0, FromDIP(10), 0, wxEXPAND, 5);
v_sizer->Add(start_length_sizer);
v_sizer->Add(setting_desc, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
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));
StateColor btn_bg_blue(std::pair<wxColour, int>(wxColour(51, 91, 188), StateColor::Pressed),
std::pair<wxColour, int>(wxColour(51, 109, 251), StateColor::Hovered),
std::pair<wxColour, int>(wxColour(68, 121, 251), StateColor::Normal));
m_btnStart->SetBackgroundColor(btn_bg_green);
m_btnStart->SetBorderColor(wxColour(0, 150, 136));
m_btnStart->SetBackgroundColor(btn_bg_blue);
m_btnStart->SetBorderColor(wxColour(68, 121, 251));
m_btnStart->SetTextColor(wxColour("#FFFFFE"));
m_btnStart->SetSize(wxSize(FromDIP(48), FromDIP(24)));
m_btnStart->SetMinSize(wxSize(FromDIP(48), FromDIP(24)));
@@ -92,9 +116,11 @@ void FRF_Calibration_Dlg::on_start(wxCommandEvent& event) {
bool read_double = false;
read_double = m_tiExtru->GetTextCtrl()->GetValue().ToDouble(&m_params.start);
if (!read_double || m_params.start <= 0 || m_params.start > 2) {
MessageDialog msg_dlg(nullptr, _L("Please input valid values:\n0 < Extru <= 2.)"), wxEmptyString, wxICON_WARNING | wxOK);
msg_dlg.ShowModal();
if (!read_double || m_params.start < 0.9) {
m_tiExtru->GetTextCtrl()->SetValue("0.9");
return;
} else if (!read_double || m_params.start > 1.1) {
m_tiExtru->GetTextCtrl()->SetValue("1.1");
return;
}
@@ -178,9 +204,9 @@ PA_Calibration_Dlg::PA_Calibration_Dlg(wxWindow* parent, wxWindowID id, Plater*
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));
StateColor btn_bg_green(std::pair<wxColour, int>(wxColour(51, 91, 188), StateColor::Pressed),
std::pair<wxColour, int>(wxColour(51, 109, 251), StateColor::Hovered),
std::pair<wxColour, int>(wxColour(68, 121, 251), StateColor::Normal));
m_btnStart->SetBackgroundColor(btn_bg_green);
m_btnStart->SetBorderColor(wxColour(0, 150, 136));