FIX:setting calibration information in filaments
Change-Id: I55019b40487f4ad4f1d823047c1b518974b9231f
This commit is contained in:
parent
1dc030b221
commit
8f580895a7
|
@ -279,6 +279,8 @@ void AMSMaterialsSetting::create_panel_kn(wxWindow* parent)
|
||||||
wxBoxSizer *m_sizer_cali_resutl = new wxBoxSizer(wxHORIZONTAL);
|
wxBoxSizer *m_sizer_cali_resutl = new wxBoxSizer(wxHORIZONTAL);
|
||||||
// pa profile
|
// pa profile
|
||||||
m_title_pa_profile = new wxStaticText(parent, wxID_ANY, _L("PA Profile"), wxDefaultPosition, wxSize(AMS_MATERIALS_SETTING_LABEL_WIDTH, -1), 0);
|
m_title_pa_profile = new wxStaticText(parent, wxID_ANY, _L("PA Profile"), wxDefaultPosition, wxSize(AMS_MATERIALS_SETTING_LABEL_WIDTH, -1), 0);
|
||||||
|
m_title_pa_profile->SetMinSize(wxSize(FromDIP(80), -1));
|
||||||
|
m_title_pa_profile->SetMaxSize(wxSize(FromDIP(80), -1));
|
||||||
m_title_pa_profile->SetFont(::Label::Body_13);
|
m_title_pa_profile->SetFont(::Label::Body_13);
|
||||||
m_title_pa_profile->SetForegroundColour(AMS_MATERIALS_SETTING_GREY800);
|
m_title_pa_profile->SetForegroundColour(AMS_MATERIALS_SETTING_GREY800);
|
||||||
m_title_pa_profile->Wrap(-1);
|
m_title_pa_profile->Wrap(-1);
|
||||||
|
@ -295,14 +297,16 @@ void AMSMaterialsSetting::create_panel_kn(wxWindow* parent)
|
||||||
|
|
||||||
// k params input
|
// k params input
|
||||||
m_k_param = new wxStaticText(parent, wxID_ANY, _L("Factor K"), wxDefaultPosition, wxDefaultSize, 0);
|
m_k_param = new wxStaticText(parent, wxID_ANY, _L("Factor K"), wxDefaultPosition, wxDefaultSize, 0);
|
||||||
|
m_k_param->SetMinSize(wxSize(FromDIP(80), -1));
|
||||||
|
m_k_param->SetMaxSize(wxSize(FromDIP(80), -1));
|
||||||
m_k_param->SetFont(::Label::Body_13);
|
m_k_param->SetFont(::Label::Body_13);
|
||||||
m_k_param->SetForegroundColour(wxColour(50, 58, 61));
|
m_k_param->SetForegroundColour(wxColour(50, 58, 61));
|
||||||
m_k_param->Wrap(-1);
|
m_k_param->Wrap(-1);
|
||||||
kn_val_sizer->Add(m_k_param, 0, wxALL | wxALIGN_CENTER_VERTICAL, FromDIP(5));
|
kn_val_sizer->Add(m_k_param, 0, wxALL | wxALIGN_CENTER_VERTICAL, FromDIP(0));
|
||||||
|
|
||||||
m_input_k_val = new TextInput(parent, wxEmptyString, wxEmptyString, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_CENTRE | wxTE_PROCESS_ENTER);
|
m_input_k_val = new TextInput(parent, wxEmptyString, wxEmptyString, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_CENTRE | wxTE_PROCESS_ENTER);
|
||||||
m_input_k_val->GetTextCtrl()->SetValidator(wxTextValidator(wxFILTER_NUMERIC));
|
m_input_k_val->GetTextCtrl()->SetValidator(wxTextValidator(wxFILTER_NUMERIC));
|
||||||
kn_val_sizer->Add(m_input_k_val, 0, wxALL | wxEXPAND | wxALIGN_CENTER_VERTICAL, FromDIP(5));
|
kn_val_sizer->Add(m_input_k_val, 0, wxALL | wxEXPAND | wxALIGN_CENTER_VERTICAL, FromDIP(0));
|
||||||
|
|
||||||
// n params input
|
// n params input
|
||||||
wxBoxSizer* n_sizer = new wxBoxSizer(wxHORIZONTAL);
|
wxBoxSizer* n_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
@ -314,6 +318,8 @@ void AMSMaterialsSetting::create_panel_kn(wxWindow* parent)
|
||||||
m_input_n_val = new TextInput(parent, wxEmptyString, wxEmptyString, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_CENTRE | wxTE_PROCESS_ENTER);
|
m_input_n_val = new TextInput(parent, wxEmptyString, wxEmptyString, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_CENTRE | wxTE_PROCESS_ENTER);
|
||||||
m_input_n_val->GetTextCtrl()->SetValidator(wxTextValidator(wxFILTER_NUMERIC));
|
m_input_n_val->GetTextCtrl()->SetValidator(wxTextValidator(wxFILTER_NUMERIC));
|
||||||
kn_val_sizer->Add(m_input_n_val, 0, wxALL | wxEXPAND | wxALIGN_CENTER_VERTICAL, FromDIP(5));
|
kn_val_sizer->Add(m_input_n_val, 0, wxALL | wxEXPAND | wxALIGN_CENTER_VERTICAL, FromDIP(5));
|
||||||
|
m_n_param->Hide();
|
||||||
|
m_input_n_val->Hide();
|
||||||
|
|
||||||
// hide n (P1P old logic)
|
// hide n (P1P old logic)
|
||||||
//if (!this->obj || !this->obj->is_high_printer_type()) {
|
//if (!this->obj || !this->obj->is_high_printer_type()) {
|
||||||
|
@ -419,6 +425,7 @@ void AMSMaterialsSetting::on_select_reset(wxCommandEvent& event) {
|
||||||
m_input_nozzle_max->GetTextCtrl()->SetValue("");
|
m_input_nozzle_max->GetTextCtrl()->SetValue("");
|
||||||
ams_filament_id = "";
|
ams_filament_id = "";
|
||||||
ams_setting_id = "";
|
ams_setting_id = "";
|
||||||
|
m_filament_selection = -1;
|
||||||
wxString k_text = "0.000";
|
wxString k_text = "0.000";
|
||||||
wxString n_text = "0.000";
|
wxString n_text = "0.000";
|
||||||
m_filament_type = "";
|
m_filament_type = "";
|
||||||
|
@ -430,7 +437,7 @@ void AMSMaterialsSetting::on_select_reset(wxCommandEvent& event) {
|
||||||
|
|
||||||
if (obj) {
|
if (obj) {
|
||||||
// set filament
|
// set filament
|
||||||
if (obj->is_support_filament_edit_virtual_tray || !is_virtual_tray()) {
|
if (!is_virtual_tray()) {
|
||||||
if (is_virtual_tray()) {
|
if (is_virtual_tray()) {
|
||||||
obj->command_ams_filament_settings(255, VIRTUAL_TRAY_ID, ams_filament_id, ams_setting_id, std::string(col_buf), m_filament_type, nozzle_temp_min_int, nozzle_temp_max_int);
|
obj->command_ams_filament_settings(255, VIRTUAL_TRAY_ID, ams_filament_id, ams_setting_id, std::string(col_buf), m_filament_type, nozzle_temp_min_int, nozzle_temp_max_int);
|
||||||
}
|
}
|
||||||
|
@ -467,32 +474,101 @@ void AMSMaterialsSetting::on_select_reset(wxCommandEvent& event) {
|
||||||
|
|
||||||
void AMSMaterialsSetting::on_select_ok(wxCommandEvent &event)
|
void AMSMaterialsSetting::on_select_ok(wxCommandEvent &event)
|
||||||
{
|
{
|
||||||
|
//get filament id
|
||||||
|
ams_filament_id = "";
|
||||||
|
ams_setting_id = "";
|
||||||
|
|
||||||
|
PresetBundle* preset_bundle = wxGetApp().preset_bundle;
|
||||||
|
if (preset_bundle) {
|
||||||
|
for (auto it = preset_bundle->filaments.begin(); it != preset_bundle->filaments.end(); it++) {
|
||||||
|
|
||||||
|
if (it->alias.compare(m_comboBox_filament->GetValue().ToStdString()) == 0) {
|
||||||
|
|
||||||
|
|
||||||
|
//check is it in the filament blacklist
|
||||||
|
if (!is_virtual_tray() && wxGetApp().app_config->get("skip_ams_blacklist_check") != "true") {
|
||||||
|
bool in_blacklist = false;
|
||||||
|
std::string action;
|
||||||
|
std::string info;
|
||||||
|
std::string filamnt_type;
|
||||||
|
it->get_filament_type(filamnt_type);
|
||||||
|
|
||||||
|
if (it->vendor) {
|
||||||
|
DeviceManager::check_filaments_in_blacklist(it->vendor->name, filamnt_type, in_blacklist, action, info);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (in_blacklist) {
|
||||||
|
if (action == "prohibition") {
|
||||||
|
MessageDialog msg_wingow(nullptr, info, _L("Error"), wxICON_WARNING | wxOK);
|
||||||
|
msg_wingow.ShowModal();
|
||||||
|
//m_comboBox_filament->SetSelection(m_filament_selection);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (action == "warning") {
|
||||||
|
MessageDialog msg_wingow(nullptr, info, _L("Warning"), wxICON_INFORMATION | wxOK);
|
||||||
|
msg_wingow.ShowModal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ams_filament_id = it->filament_id;
|
||||||
|
ams_setting_id = it->setting_id;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString nozzle_temp_min = m_input_nozzle_min->GetTextCtrl()->GetValue();
|
||||||
|
auto filament = m_comboBox_filament->GetValue();
|
||||||
|
|
||||||
|
wxString nozzle_temp_max = m_input_nozzle_max->GetTextCtrl()->GetValue();
|
||||||
|
|
||||||
|
long nozzle_temp_min_int, nozzle_temp_max_int;
|
||||||
|
nozzle_temp_min.ToLong(&nozzle_temp_min_int);
|
||||||
|
nozzle_temp_max.ToLong(&nozzle_temp_max_int);
|
||||||
|
wxColour color = m_clr_picker->m_colour;
|
||||||
|
char col_buf[10];
|
||||||
|
sprintf(col_buf, "%02X%02X%02X%02X", (int)color.Red(), (int)color.Green(), (int)color.Blue(), (int)color.Alpha());
|
||||||
|
|
||||||
|
if (ams_filament_id.empty() || nozzle_temp_min.empty() || nozzle_temp_max.empty() || m_filament_type.empty()) {
|
||||||
|
BOOST_LOG_TRIVIAL(trace) << "Invalid Setting id";
|
||||||
|
MessageDialog msg_dlg(nullptr, _L("You need to select the material type and color first."), wxEmptyString, wxICON_WARNING | wxOK);
|
||||||
|
msg_dlg.ShowModal();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ams_filament_id.empty() || nozzle_temp_min.empty() || nozzle_temp_max.empty() || m_filament_type.empty()) {
|
||||||
|
BOOST_LOG_TRIVIAL(trace) << "Invalid Setting id";
|
||||||
|
MessageDialog msg_dlg(nullptr, _L("You need to select the material type and color first."), wxEmptyString, wxICON_WARNING | wxOK);
|
||||||
|
msg_dlg.ShowModal();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// set filament
|
||||||
|
if (!is_virtual_tray()) {
|
||||||
|
if (is_virtual_tray()) {
|
||||||
|
obj->command_ams_filament_settings(255, VIRTUAL_TRAY_ID, ams_filament_id, ams_setting_id, std::string(col_buf), m_filament_type, nozzle_temp_min_int, nozzle_temp_max_int);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
obj->command_ams_filament_settings(ams_id, tray_id, ams_filament_id, ams_setting_id, std::string(col_buf), m_filament_type, nozzle_temp_min_int, nozzle_temp_max_int);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//reset param
|
||||||
wxString k_text = m_input_k_val->GetTextCtrl()->GetValue();
|
wxString k_text = m_input_k_val->GetTextCtrl()->GetValue();
|
||||||
wxString n_text = m_input_n_val->GetTextCtrl()->GetValue();
|
wxString n_text = m_input_n_val->GetTextCtrl()->GetValue();
|
||||||
|
|
||||||
if (obj && obj->is_high_printer_type()) {
|
if (!ExtrusionCalibration::check_k_validation(k_text)) {
|
||||||
PACalibIndexInfo select_index_info;
|
wxString k_tips = _L("Please input a valid value (K in 0~0.5)");
|
||||||
select_index_info.tray_id = tray_id;
|
wxString kn_tips = _L("Please input a valid value (K in 0~0.5, N in 0.6~2.0)");
|
||||||
select_index_info.nozzle_diameter = obj->nozzle_diameter;
|
MessageDialog msg_dlg(nullptr, k_tips, wxEmptyString, wxICON_WARNING | wxOK);
|
||||||
if (m_pa_cali_select_id > 0) {
|
msg_dlg.ShowModal();
|
||||||
select_index_info.cali_idx = obj->pa_calib_tab[m_pa_cali_select_id - 1].cali_idx;
|
return;
|
||||||
select_index_info.filament_id = obj->pa_calib_tab[m_pa_cali_select_id - 1].filament_id;
|
|
||||||
} else { // default item
|
|
||||||
select_index_info.cali_idx = -1;
|
|
||||||
select_index_info.filament_id = obj->pa_calib_tab[0].filament_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
CalibUtils::select_PA_calib_result(select_index_info);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_virtual_tray() && obj && !obj->is_support_filament_edit_virtual_tray) {
|
// set k / n value
|
||||||
if (!ExtrusionCalibration::check_k_validation(k_text)) {
|
if (is_virtual_tray()) {
|
||||||
wxString k_tips = _L("Please input a valid value (K in 0~0.5)");
|
|
||||||
wxString kn_tips = _L("Please input a valid value (K in 0~0.5, N in 0.6~2.0)");
|
|
||||||
MessageDialog msg_dlg(nullptr, k_tips, wxEmptyString, wxICON_WARNING | wxOK);
|
|
||||||
msg_dlg.ShowModal();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
double k = 0.0;
|
double k = 0.0;
|
||||||
try {
|
try {
|
||||||
k_text.ToDouble(&k);
|
k_text.ToDouble(&k);
|
||||||
|
@ -507,153 +583,63 @@ void AMSMaterialsSetting::on_select_ok(wxCommandEvent &event)
|
||||||
catch (...) {
|
catch (...) {
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
obj->command_extrusion_cali_set(VIRTUAL_TRAY_ID, "", "", k, n);
|
|
||||||
Close();
|
if (obj->is_high_printer_type()) {
|
||||||
}
|
PACalibIndexInfo select_index_info;
|
||||||
else {
|
select_index_info.tray_id = tray_id;
|
||||||
if (!m_is_third) {
|
select_index_info.nozzle_diameter = obj->nozzle_diameter;
|
||||||
// check and set k n
|
|
||||||
if (obj->is_function_supported(PrinterFunction::FUNC_VIRTUAL_TYAY)) {
|
|
||||||
if (!ExtrusionCalibration::check_k_validation(k_text)) {
|
if (m_pa_cali_select_id > 0) {
|
||||||
wxString k_tips = _L("Please input a valid value (K in 0~0.5)");
|
select_index_info.cali_idx = m_pa_profile_items[m_pa_cali_select_id].cali_idx;
|
||||||
wxString kn_tips = _L("Please input a valid value (K in 0~0.5, N in 0.6~2.0)");
|
select_index_info.filament_id = m_pa_profile_items[m_pa_cali_select_id].filament_id;
|
||||||
MessageDialog msg_dlg(nullptr, k_tips, wxEmptyString, wxICON_WARNING | wxOK);
|
}
|
||||||
msg_dlg.ShowModal();
|
else { // default item
|
||||||
return;
|
select_index_info.cali_idx = -1;
|
||||||
}
|
select_index_info.filament_id = ams_filament_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CalibUtils::select_PA_calib_result(select_index_info);
|
||||||
// set k / n value
|
|
||||||
if (obj->is_function_supported(PrinterFunction::FUNC_VIRTUAL_TYAY)) {
|
|
||||||
// set extrusion cali ratio
|
|
||||||
int cali_tray_id = ams_id * 4 + tray_id;
|
|
||||||
|
|
||||||
double k = 0.0;
|
|
||||||
try {
|
|
||||||
k_text.ToDouble(&k);
|
|
||||||
}
|
|
||||||
catch (...) {
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
double n = 0.0;
|
|
||||||
try {
|
|
||||||
n_text.ToDouble(&n);
|
|
||||||
}
|
|
||||||
catch (...) {
|
|
||||||
;
|
|
||||||
}
|
|
||||||
obj->command_extrusion_cali_set(cali_tray_id, "", "", k, n);
|
|
||||||
}
|
|
||||||
Close();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
wxString nozzle_temp_min = m_input_nozzle_min->GetTextCtrl()->GetValue();
|
|
||||||
auto filament = m_comboBox_filament->GetValue();
|
|
||||||
|
|
||||||
wxString nozzle_temp_max = m_input_nozzle_max->GetTextCtrl()->GetValue();
|
|
||||||
|
|
||||||
long nozzle_temp_min_int, nozzle_temp_max_int;
|
|
||||||
nozzle_temp_min.ToLong(&nozzle_temp_min_int);
|
|
||||||
nozzle_temp_max.ToLong(&nozzle_temp_max_int);
|
|
||||||
wxColour color = m_clr_picker->m_colour;
|
|
||||||
char col_buf[10];
|
|
||||||
sprintf(col_buf, "%02X%02X%02X%02X", (int)color.Red(), (int)color.Green(), (int)color.Blue(), (int)color.Alpha());
|
|
||||||
ams_filament_id = "";
|
|
||||||
ams_setting_id = "";
|
|
||||||
|
|
||||||
PresetBundle* preset_bundle = wxGetApp().preset_bundle;
|
|
||||||
if (preset_bundle) {
|
|
||||||
for (auto it = preset_bundle->filaments.begin(); it != preset_bundle->filaments.end(); it++) {
|
|
||||||
|
|
||||||
if (it->alias.compare(m_comboBox_filament->GetValue().ToStdString()) == 0) {
|
|
||||||
|
|
||||||
|
|
||||||
//check is it in the filament blacklist
|
|
||||||
if (!is_virtual_tray() && wxGetApp().app_config->get("skip_ams_blacklist_check") != "true") {
|
|
||||||
bool in_blacklist = false;
|
|
||||||
std::string action;
|
|
||||||
std::string info;
|
|
||||||
std::string filamnt_type;
|
|
||||||
it->get_filament_type(filamnt_type);
|
|
||||||
|
|
||||||
if (it->vendor) {
|
|
||||||
DeviceManager::check_filaments_in_blacklist(it->vendor->name, filamnt_type, in_blacklist, action, info);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_blacklist) {
|
|
||||||
if (action == "prohibition") {
|
|
||||||
MessageDialog msg_wingow(nullptr, info, _L("Error"), wxICON_WARNING | wxOK);
|
|
||||||
msg_wingow.ShowModal();
|
|
||||||
//m_comboBox_filament->SetSelection(m_filament_selection);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (action == "warning") {
|
|
||||||
MessageDialog msg_wingow(nullptr, info, _L("Warning"), wxICON_INFORMATION | wxOK);
|
|
||||||
msg_wingow.ShowModal();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ams_filament_id = it->filament_id;
|
|
||||||
ams_setting_id = it->setting_id;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ams_filament_id.empty() || nozzle_temp_min.empty() || nozzle_temp_max.empty() || m_filament_type.empty()) {
|
|
||||||
BOOST_LOG_TRIVIAL(trace) << "Invalid Setting id";
|
|
||||||
MessageDialog msg_dlg(nullptr, _L("You need to select the material type and color first."), wxEmptyString, wxICON_WARNING | wxOK);
|
|
||||||
msg_dlg.ShowModal();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (obj) {
|
obj->command_extrusion_cali_set(VIRTUAL_TRAY_ID, "", "", k, n);
|
||||||
if (obj->is_function_supported(PrinterFunction::FUNC_VIRTUAL_TYAY)) {
|
}
|
||||||
if (!ExtrusionCalibration::check_k_validation(k_text)) {
|
}
|
||||||
wxString k_tips = _L("Please input a valid value (K in 0~0.5)");
|
else {
|
||||||
wxString kn_tips = _L("Please input a valid value (K in 0~0.5, N in 0.6~2.0)");
|
int cali_tray_id = ams_id * 4 + tray_id;
|
||||||
MessageDialog msg_dlg(nullptr, k_tips, wxEmptyString, wxICON_WARNING | wxOK);
|
double k = 0.0;
|
||||||
msg_dlg.ShowModal();
|
try {
|
||||||
return;
|
k_text.ToDouble(&k);
|
||||||
}
|
}
|
||||||
}
|
catch (...) {
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
// set filament
|
double n = 0.0;
|
||||||
if (obj->is_support_filament_edit_virtual_tray || !is_virtual_tray()) {
|
try {
|
||||||
if (is_virtual_tray()) {
|
n_text.ToDouble(&n);
|
||||||
obj->command_ams_filament_settings(255, VIRTUAL_TRAY_ID, ams_filament_id, ams_setting_id, std::string(col_buf), m_filament_type, nozzle_temp_min_int, nozzle_temp_max_int);
|
}
|
||||||
}
|
catch (...) {
|
||||||
else {
|
;
|
||||||
obj->command_ams_filament_settings(ams_id, tray_id, ams_filament_id, ams_setting_id, std::string(col_buf), m_filament_type, nozzle_temp_min_int, nozzle_temp_max_int);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// set k / n value
|
if (obj->is_high_printer_type()) {
|
||||||
if (obj->is_function_supported(PrinterFunction::FUNC_VIRTUAL_TYAY)) {
|
PACalibIndexInfo select_index_info;
|
||||||
// set extrusion cali ratio
|
select_index_info.tray_id = tray_id;
|
||||||
int cali_tray_id = ams_id * 4 + tray_id;
|
select_index_info.nozzle_diameter = obj->nozzle_diameter;
|
||||||
|
if (m_pa_cali_select_id > 0) {
|
||||||
double k = 0.0;
|
select_index_info.cali_idx = m_pa_profile_items[m_pa_cali_select_id].cali_idx;
|
||||||
try {
|
select_index_info.filament_id = m_pa_profile_items[m_pa_cali_select_id].filament_id;
|
||||||
k_text.ToDouble(&k);
|
|
||||||
}
|
|
||||||
catch (...) {
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
double n = 0.0;
|
|
||||||
try {
|
|
||||||
n_text.ToDouble(&n);
|
|
||||||
}
|
|
||||||
catch (...) {
|
|
||||||
;
|
|
||||||
}
|
|
||||||
obj->command_extrusion_cali_set(cali_tray_id, "", "", k, n);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else { // default item
|
||||||
|
select_index_info.cali_idx = -1;
|
||||||
|
select_index_info.filament_id = ams_filament_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
CalibUtils::select_PA_calib_result(select_index_info);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
obj->command_extrusion_cali_set(cali_tray_id, "", "", k, n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Close();
|
Close();
|
||||||
|
@ -725,7 +711,7 @@ void AMSMaterialsSetting::update_widgets()
|
||||||
{
|
{
|
||||||
// virtual tray
|
// virtual tray
|
||||||
if (is_virtual_tray()) {
|
if (is_virtual_tray()) {
|
||||||
if (obj && obj->is_support_filament_edit_virtual_tray)
|
if (obj)
|
||||||
m_panel_normal->Show();
|
m_panel_normal->Show();
|
||||||
else
|
else
|
||||||
m_panel_normal->Hide();
|
m_panel_normal->Hide();
|
||||||
|
@ -777,7 +763,7 @@ void AMSMaterialsSetting::Popup(wxString filament, wxString sn, wxString temp_mi
|
||||||
m_input_k_val->GetTextCtrl()->SetValue(k);
|
m_input_k_val->GetTextCtrl()->SetValue(k);
|
||||||
m_input_n_val->GetTextCtrl()->SetValue(n);
|
m_input_n_val->GetTextCtrl()->SetValue(n);
|
||||||
|
|
||||||
if (is_virtual_tray() && obj && !obj->is_support_filament_edit_virtual_tray) {
|
if (is_virtual_tray() && obj) {
|
||||||
m_button_reset->Show();
|
m_button_reset->Show();
|
||||||
m_button_confirm->Show();
|
m_button_confirm->Show();
|
||||||
update();
|
update();
|
||||||
|
@ -891,48 +877,23 @@ void AMSMaterialsSetting::Popup(wxString filament, wxString sn, wxString temp_mi
|
||||||
}
|
}
|
||||||
m_comboBox_filament->Set(filament_items);
|
m_comboBox_filament->Set(filament_items);
|
||||||
m_comboBox_filament->SetSelection(selection_idx);
|
m_comboBox_filament->SetSelection(selection_idx);
|
||||||
post_select_event();
|
post_select_event(selection_idx);
|
||||||
|
|
||||||
|
if (selection_idx < 0) {
|
||||||
|
m_comboBox_filament->SetValue(wxEmptyString);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxArrayString items;
|
|
||||||
if (this->obj && this->obj->is_high_printer_type()) {
|
|
||||||
std::vector<PACalibResult> cali_history = this->obj->pa_calib_tab;
|
|
||||||
items.push_back("default");
|
|
||||||
for (auto cali_item : cali_history) {
|
|
||||||
items.push_back(cali_item.name);
|
|
||||||
}
|
|
||||||
m_comboBox_cali_result->Set(items);
|
|
||||||
|
|
||||||
Ams* selected_ams = this->obj->amsList[std::to_string(ams_id)];
|
|
||||||
AmsTray* selected_tray = selected_ams->trayList[std::to_string(tray_id)];
|
|
||||||
int select_idx = CalibUtils::get_selected_calib_idx(this->obj->pa_calib_tab, selected_tray->cali_idx);
|
|
||||||
m_comboBox_cali_result->SetSelection(select_idx + 1);
|
|
||||||
|
|
||||||
if (select_idx >= 0) {
|
|
||||||
m_input_k_val->GetTextCtrl()->SetValue(std::to_string(this->obj->pa_calib_tab[select_idx].k_value));
|
|
||||||
m_input_n_val->GetTextCtrl()->SetValue(std::to_string(this->obj->pa_calib_tab[select_idx].n_coef));
|
|
||||||
} else { // default value
|
|
||||||
m_input_k_val->GetTextCtrl()->SetValue("0.00");
|
|
||||||
m_input_n_val->GetTextCtrl()->SetValue("0.00");
|
|
||||||
}
|
|
||||||
m_input_k_val->Enable(false);
|
|
||||||
m_input_n_val->Enable(false);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
m_input_k_val->Enable(true);
|
|
||||||
m_input_n_val->Enable(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
update();
|
update();
|
||||||
Layout();
|
Layout();
|
||||||
Fit();
|
Fit();
|
||||||
ShowModal();
|
ShowModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AMSMaterialsSetting::post_select_event() {
|
void AMSMaterialsSetting::post_select_event(int index) {
|
||||||
wxCommandEvent event(wxEVT_COMBOBOX);
|
wxCommandEvent event(wxEVT_COMBOBOX);
|
||||||
|
event.SetInt(index);
|
||||||
event.SetEventObject(m_comboBox_filament);
|
event.SetEventObject(m_comboBox_filament);
|
||||||
wxPostEvent(m_comboBox_filament, event);
|
wxPostEvent(m_comboBox_filament, event);
|
||||||
}
|
}
|
||||||
|
@ -1006,6 +967,78 @@ void AMSMaterialsSetting::on_select_filament(wxCommandEvent &evt)
|
||||||
}
|
}
|
||||||
|
|
||||||
m_filament_selection = evt.GetSelection();
|
m_filament_selection = evt.GetSelection();
|
||||||
|
|
||||||
|
//reset cali
|
||||||
|
int cali_select_idx;
|
||||||
|
|
||||||
|
if ( !this->obj || m_filament_selection < 0) {
|
||||||
|
m_input_k_val->GetTextCtrl()->SetValue("0.00");
|
||||||
|
m_input_n_val->GetTextCtrl()->SetValue("0.00");
|
||||||
|
m_input_k_val->Enable(false);
|
||||||
|
m_input_n_val->Enable(false);
|
||||||
|
m_button_confirm->Disable();
|
||||||
|
m_button_confirm->SetBackgroundColor(wxColour(0x90, 0x90, 0x90));
|
||||||
|
m_button_confirm->SetBorderColor(wxColour(0x90, 0x90, 0x90));
|
||||||
|
m_comboBox_cali_result->Clear();
|
||||||
|
m_comboBox_cali_result->SetValue(wxEmptyString);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_button_confirm->Enable();
|
||||||
|
m_button_confirm->SetBackgroundColor(m_btn_bg_green);
|
||||||
|
m_button_confirm->SetBorderColor(wxColour(0, 174, 66));
|
||||||
|
m_button_confirm->SetTextColor(wxColour("#FFFFFE"));
|
||||||
|
|
||||||
|
//filament id
|
||||||
|
ams_filament_id = "";
|
||||||
|
ams_setting_id = "";
|
||||||
|
|
||||||
|
if (preset_bundle) {
|
||||||
|
for (auto it = preset_bundle->filaments.begin(); it != preset_bundle->filaments.end(); it++) {
|
||||||
|
if (it->alias.compare(m_comboBox_filament->GetValue().ToStdString()) == 0) {
|
||||||
|
ams_filament_id = it->filament_id;
|
||||||
|
ams_setting_id = it->setting_id;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wxArrayString items;
|
||||||
|
m_pa_profile_items.clear();
|
||||||
|
|
||||||
|
if (this->obj->is_high_printer_type()) {
|
||||||
|
std::vector<PACalibResult> cali_history = this->obj->pa_calib_tab;
|
||||||
|
items.push_back("default");
|
||||||
|
for (auto cali_item : cali_history) {
|
||||||
|
if (cali_item.filament_id == ams_filament_id) {
|
||||||
|
items.push_back(cali_item.name);
|
||||||
|
m_pa_profile_items.push_back(cali_item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_comboBox_cali_result->Set(items);
|
||||||
|
|
||||||
|
|
||||||
|
if (tray_id == VIRTUAL_TRAY_ID) {
|
||||||
|
AmsTray selected_tray = this->obj->vt_tray;
|
||||||
|
cali_select_idx = CalibUtils::get_selected_calib_idx(this->obj->pa_calib_tab,selected_tray.cali_idx);
|
||||||
|
m_comboBox_cali_result->SetSelection(cali_select_idx + 1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Ams* selected_ams = this->obj->amsList[std::to_string(ams_id)];
|
||||||
|
AmsTray selected_tray = *selected_ams->trayList[std::to_string(tray_id)];
|
||||||
|
cali_select_idx = CalibUtils::get_selected_calib_idx(this->obj->pa_calib_tab, selected_tray.cali_idx);
|
||||||
|
m_comboBox_cali_result->SetSelection(cali_select_idx + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cali_select_idx >= 0) {
|
||||||
|
m_input_k_val->GetTextCtrl()->SetValue(std::to_string(this->obj->pa_calib_tab[cali_select_idx].k_value));
|
||||||
|
m_input_n_val->GetTextCtrl()->SetValue(std::to_string(this->obj->pa_calib_tab[cali_select_idx].n_coef));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_input_k_val->Enable(true);
|
||||||
|
m_input_n_val->Enable(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AMSMaterialsSetting::on_dpi_changed(const wxRect &suggested_rect)
|
void AMSMaterialsSetting::on_dpi_changed(const wxRect &suggested_rect)
|
||||||
|
|
|
@ -103,7 +103,7 @@ public:
|
||||||
wxString temp_min = wxEmptyString, wxString temp_max = wxEmptyString,
|
wxString temp_min = wxEmptyString, wxString temp_max = wxEmptyString,
|
||||||
wxString k = wxEmptyString, wxString n = wxEmptyString);
|
wxString k = wxEmptyString, wxString n = wxEmptyString);
|
||||||
|
|
||||||
void post_select_event();
|
void post_select_event(int index);
|
||||||
void msw_rescale();
|
void msw_rescale();
|
||||||
void set_color(wxColour color);
|
void set_color(wxColour color);
|
||||||
void set_empty_color(wxColour color);
|
void set_empty_color(wxColour color);
|
||||||
|
@ -125,6 +125,7 @@ public:
|
||||||
std::string m_filament_type;
|
std::string m_filament_type;
|
||||||
ColorPickerPopup m_color_picker_popup;
|
ColorPickerPopup m_color_picker_popup;
|
||||||
ColorPicker * m_clr_picker;
|
ColorPicker * m_clr_picker;
|
||||||
|
std::vector<PACalibResult> m_pa_profile_items;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void create_panel_normal(wxWindow* parent);
|
void create_panel_normal(wxWindow* parent);
|
||||||
|
|
Loading…
Reference in New Issue