ENH: enhance cali history dialog for mutli_extruder
jira: none Change-Id: Id23ae2c12b93b9f49d3031fbb9a49930d072b02c
This commit is contained in:
parent
d479d1186a
commit
8b8b6bdec8
|
@ -390,7 +390,7 @@ void HistoryWindow::sync_history_data() {
|
||||||
PACalibResult result_buffer = result;
|
PACalibResult result_buffer = result;
|
||||||
result_buffer.k_value = stof(k_value->GetLabel().ToStdString());
|
result_buffer.k_value = stof(k_value->GetLabel().ToStdString());
|
||||||
result_buffer.name = name_value->GetLabel().ToUTF8().data();
|
result_buffer.name = name_value->GetLabel().ToUTF8().data();
|
||||||
EditCalibrationHistoryDialog dlg(this, result_buffer);
|
EditCalibrationHistoryDialog dlg(this, result_buffer, curr_obj);
|
||||||
if (dlg.ShowModal() == wxID_OK) {
|
if (dlg.ShowModal() == wxID_OK) {
|
||||||
auto new_result = dlg.get_result();
|
auto new_result = dlg.get_result();
|
||||||
|
|
||||||
|
@ -468,7 +468,7 @@ void HistoryWindow::on_click_new_button(wxCommandEvent& event)
|
||||||
dlg.ShowModal();
|
dlg.ShowModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
EditCalibrationHistoryDialog::EditCalibrationHistoryDialog(wxWindow* parent, const PACalibResult& result)
|
EditCalibrationHistoryDialog::EditCalibrationHistoryDialog(wxWindow *parent, const PACalibResult &result, const MachineObject *obj)
|
||||||
: DPIDialog(parent, wxID_ANY, _L("Edit Flow Dynamics Calibration"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE)
|
: DPIDialog(parent, wxID_ANY, _L("Edit Flow Dynamics Calibration"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE)
|
||||||
, m_new_result(result)
|
, m_new_result(result)
|
||||||
{
|
{
|
||||||
|
@ -496,6 +496,31 @@ EditCalibrationHistoryDialog::EditCalibrationHistoryDialog(wxWindow* parent, con
|
||||||
flex_sizer->Add(preset_name_title);
|
flex_sizer->Add(preset_name_title);
|
||||||
flex_sizer->Add(preset_name_value);
|
flex_sizer->Add(preset_name_value);
|
||||||
|
|
||||||
|
if (obj && obj->is_multi_extruders()) {
|
||||||
|
|
||||||
|
Label *extruder_name_title = new Label(top_panel, _L("Extruder"));
|
||||||
|
int extruder_index = obj->is_main_extruder_on_left() ? result.extruder_id : 1 - result.extruder_id;
|
||||||
|
wxString extruder_name = extruder_index == 0 ? _L("Left") : _L("Right");
|
||||||
|
Label *extruder_name_value = new Label(top_panel, extruder_name);
|
||||||
|
flex_sizer->Add(extruder_name_title);
|
||||||
|
flex_sizer->Add(extruder_name_value);
|
||||||
|
|
||||||
|
Label *nozzle_name_title = new Label(top_panel, _L("Nozzle"));
|
||||||
|
wxString nozzle_name;
|
||||||
|
const ConfigOptionDef *nozzle_volume_type_def = print_config_def.get("nozzle_volume_type");
|
||||||
|
if (nozzle_volume_type_def && nozzle_volume_type_def->enum_keys_map) {
|
||||||
|
for (auto iter = nozzle_volume_type_def->enum_keys_map->begin(); iter != nozzle_volume_type_def->enum_keys_map->end(); ++iter) {
|
||||||
|
if (iter->second == result.nozzle_volume_type) {
|
||||||
|
nozzle_name = _L(iter->first);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Label *nozzle_name_value = new Label(top_panel, nozzle_name);
|
||||||
|
flex_sizer->Add(nozzle_name_title);
|
||||||
|
flex_sizer->Add(nozzle_name_value);
|
||||||
|
}
|
||||||
|
|
||||||
Label* k_title = new Label(top_panel, _L("Factor K"));
|
Label* k_title = new Label(top_panel, _L("Factor K"));
|
||||||
auto k_str = wxString::Format("%.3f", m_new_result.k_value);
|
auto k_str = wxString::Format("%.3f", m_new_result.k_value);
|
||||||
m_k_value = new TextInput(top_panel, k_str, "", "", wxDefaultPosition, EDIT_HISTORY_DIALOG_INPUT_SIZE, wxTE_PROCESS_ENTER);
|
m_k_value = new TextInput(top_panel, k_str, "", "", wxDefaultPosition, EDIT_HISTORY_DIALOG_INPUT_SIZE, wxTE_PROCESS_ENTER);
|
||||||
|
@ -702,6 +727,33 @@ NewCalibrationHistoryDialog::NewCalibrationHistoryDialog(wxWindow *parent, const
|
||||||
flex_sizer->Add(preset_name_title);
|
flex_sizer->Add(preset_name_title);
|
||||||
flex_sizer->Add(m_comboBox_filament);
|
flex_sizer->Add(m_comboBox_filament);
|
||||||
|
|
||||||
|
if (curr_obj->is_multi_extruders())
|
||||||
|
{
|
||||||
|
Label *extruder_name_title = new Label(top_panel, _L("Extruder"));
|
||||||
|
m_comboBox_extruder = new ::ComboBox(top_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, NEW_HISTORY_DIALOG_INPUT_SIZE, 0, nullptr, wxCB_READONLY);
|
||||||
|
wxArrayString extruder_items;
|
||||||
|
extruder_items.push_back("Left");
|
||||||
|
extruder_items.push_back("Right");
|
||||||
|
m_comboBox_extruder->Set(extruder_items);
|
||||||
|
m_comboBox_extruder->SetSelection(-1);
|
||||||
|
flex_sizer->Add(extruder_name_title);
|
||||||
|
flex_sizer->Add(m_comboBox_extruder);
|
||||||
|
|
||||||
|
Label *nozzle_name_title = new Label(top_panel, _L("Nozzle"));
|
||||||
|
m_comboBox_nozzle_type = new ::ComboBox(top_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, NEW_HISTORY_DIALOG_INPUT_SIZE, 0, nullptr, wxCB_READONLY);
|
||||||
|
wxArrayString nozzle_items;
|
||||||
|
const ConfigOptionDef *nozzle_volume_type_def = print_config_def.get("nozzle_volume_type");
|
||||||
|
if (nozzle_volume_type_def && nozzle_volume_type_def->enum_keys_map) {
|
||||||
|
for (auto item : nozzle_volume_type_def->enum_labels) {
|
||||||
|
nozzle_items.push_back(_L(item));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_comboBox_nozzle_type->Set(nozzle_items);
|
||||||
|
m_comboBox_nozzle_type->SetSelection(-1);
|
||||||
|
flex_sizer->Add(nozzle_name_title);
|
||||||
|
flex_sizer->Add(m_comboBox_nozzle_type);
|
||||||
|
}
|
||||||
|
|
||||||
Label *nozzle_diameter_title = new Label(top_panel, _L("Nozzle Diameter"));
|
Label *nozzle_diameter_title = new Label(top_panel, _L("Nozzle Diameter"));
|
||||||
m_comboBox_nozzle_diameter = new ::ComboBox(top_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, NEW_HISTORY_DIALOG_INPUT_SIZE, 0, nullptr, wxCB_READONLY);
|
m_comboBox_nozzle_diameter = new ::ComboBox(top_panel, wxID_ANY, wxEmptyString, wxDefaultPosition, NEW_HISTORY_DIALOG_INPUT_SIZE, 0, nullptr, wxCB_READONLY);
|
||||||
static std::array<float, 4> nozzle_diameter_list = {0.2f, 0.4f, 0.6f, 0.8f};
|
static std::array<float, 4> nozzle_diameter_list = {0.2f, 0.4f, 0.6f, 0.8f};
|
||||||
|
@ -760,6 +812,14 @@ NewCalibrationHistoryDialog::NewCalibrationHistoryDialog(wxWindow *parent, const
|
||||||
wxGetApp().UpdateDlgDarkUI(this);
|
wxGetApp().UpdateDlgDarkUI(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int NewCalibrationHistoryDialog::get_extruder_id(int extruder_index)
|
||||||
|
{
|
||||||
|
if ((extruder_index != -1) && curr_obj->is_multi_extruders()) {
|
||||||
|
return curr_obj->is_main_extruder_on_left() ? extruder_index : (1 - extruder_index);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void NewCalibrationHistoryDialog::on_ok(wxCommandEvent &event)
|
void NewCalibrationHistoryDialog::on_ok(wxCommandEvent &event)
|
||||||
{
|
{
|
||||||
wxString name = m_name_value->GetTextCtrl()->GetValue();
|
wxString name = m_name_value->GetTextCtrl()->GetValue();
|
||||||
|
@ -786,6 +846,24 @@ void NewCalibrationHistoryDialog::on_ok(wxCommandEvent &event)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (curr_obj->is_multi_extruders()) {
|
||||||
|
std::string extruder_name = m_comboBox_extruder->GetValue().ToStdString();
|
||||||
|
if (extruder_name.empty()) {
|
||||||
|
MessageDialog msg_dlg(nullptr, _L("The extruder must be selected."), wxEmptyString, wxICON_WARNING | wxOK);
|
||||||
|
msg_dlg.ShowModal();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::string nozzle_name = m_comboBox_nozzle_type->GetValue().ToStdString();
|
||||||
|
if (nozzle_name.empty()) {
|
||||||
|
MessageDialog msg_dlg(nullptr, _L("The nozzle must be selected."), wxEmptyString, wxICON_WARNING | wxOK);
|
||||||
|
msg_dlg.ShowModal();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_new_result.extruder_id = get_extruder_id(m_comboBox_extruder->GetSelection());
|
||||||
|
m_new_result.nozzle_volume_type = NozzleVolumeType(m_comboBox_extruder->GetSelection());
|
||||||
|
}
|
||||||
|
|
||||||
auto filament_item = map_filament_items[m_comboBox_filament->GetValue().ToStdString()];
|
auto filament_item = map_filament_items[m_comboBox_filament->GetValue().ToStdString()];
|
||||||
std::string filament_id = filament_item.filament_id;
|
std::string filament_id = filament_item.filament_id;
|
||||||
std::string setting_id = filament_item.setting_id;
|
std::string setting_id = filament_item.setting_id;
|
||||||
|
|
|
@ -44,7 +44,7 @@ protected:
|
||||||
class EditCalibrationHistoryDialog : public DPIDialog
|
class EditCalibrationHistoryDialog : public DPIDialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
EditCalibrationHistoryDialog(wxWindow* parent, const PACalibResult& result);
|
EditCalibrationHistoryDialog(wxWindow* parent, const PACalibResult& result, const MachineObject* obj);
|
||||||
~EditCalibrationHistoryDialog();
|
~EditCalibrationHistoryDialog();
|
||||||
void on_dpi_changed(const wxRect& suggested_rect) override;
|
void on_dpi_changed(const wxRect& suggested_rect) override;
|
||||||
PACalibResult get_result();
|
PACalibResult get_result();
|
||||||
|
@ -73,6 +73,7 @@ protected:
|
||||||
|
|
||||||
|
|
||||||
wxArrayString get_all_filaments(const MachineObject *obj);
|
wxArrayString get_all_filaments(const MachineObject *obj);
|
||||||
|
int get_extruder_id(int extruder_index); // extruder_index 0 : left, 1 : right
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
PACalibResult m_new_result;
|
PACalibResult m_new_result;
|
||||||
|
@ -84,6 +85,8 @@ protected:
|
||||||
|
|
||||||
ComboBox *m_comboBox_nozzle_diameter;
|
ComboBox *m_comboBox_nozzle_diameter;
|
||||||
ComboBox *m_comboBox_filament;
|
ComboBox *m_comboBox_filament;
|
||||||
|
ComboBox *m_comboBox_extruder;
|
||||||
|
ComboBox *m_comboBox_nozzle_type;
|
||||||
|
|
||||||
struct FilamentInfos
|
struct FilamentInfos
|
||||||
{
|
{
|
||||||
|
|
|
@ -2309,6 +2309,7 @@ int MachineObject::command_set_pa_calibration(const std::vector<PACalibResult> &
|
||||||
j["print"]["filaments"][i]["tray_id"] = pa_calib_values[i].tray_id;
|
j["print"]["filaments"][i]["tray_id"] = pa_calib_values[i].tray_id;
|
||||||
j["print"]["filaments"][i]["extruder_id"] = pa_calib_values[i].extruder_id;
|
j["print"]["filaments"][i]["extruder_id"] = pa_calib_values[i].extruder_id;
|
||||||
j["print"]["filaments"][i]["nozzle_id"] = generate_nozzle_id(pa_calib_values[i].nozzle_volume_type).ToStdString();
|
j["print"]["filaments"][i]["nozzle_id"] = generate_nozzle_id(pa_calib_values[i].nozzle_volume_type).ToStdString();
|
||||||
|
j["print"]["filaments"][i]["nozzle_diameter"] = to_string_nozzle_diameter(pa_calib_values[i].nozzle_diameter);
|
||||||
j["print"]["filaments"][i]["ams_id"] = pa_calib_values[i].ams_id;
|
j["print"]["filaments"][i]["ams_id"] = pa_calib_values[i].ams_id;
|
||||||
j["print"]["filaments"][i]["slot_id"] = pa_calib_values[i].slot_id;
|
j["print"]["filaments"][i]["slot_id"] = pa_calib_values[i].slot_id;
|
||||||
j["print"]["filaments"][i]["filament_id"] = pa_calib_values[i].filament_id;
|
j["print"]["filaments"][i]["filament_id"] = pa_calib_values[i].filament_id;
|
||||||
|
|
Loading…
Reference in New Issue