FIX: the pa profile name cannot be repeated when edit k value
jira: STUDIO-10992 Change-Id: I50d61e9581e188a10a4f804df163b3d50eb7caa0
This commit is contained in:
parent
e6e412479f
commit
431925adf0
|
@ -406,7 +406,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, curr_obj);
|
EditCalibrationHistoryDialog dlg(this, result_buffer, curr_obj, m_calib_results_history);
|
||||||
if (dlg.ShowModal() == wxID_OK) {
|
if (dlg.ShowModal() == wxID_OK) {
|
||||||
auto new_result = dlg.get_result();
|
auto new_result = dlg.get_result();
|
||||||
|
|
||||||
|
@ -484,10 +484,16 @@ void HistoryWindow::on_click_new_button(wxCommandEvent& event)
|
||||||
dlg.ShowModal();
|
dlg.ShowModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
EditCalibrationHistoryDialog::EditCalibrationHistoryDialog(wxWindow *parent, const PACalibResult &result, const MachineObject *obj)
|
EditCalibrationHistoryDialog::EditCalibrationHistoryDialog(wxWindow *parent,
|
||||||
|
const PACalibResult &result,
|
||||||
|
const MachineObject *obj,
|
||||||
|
const std::vector<PACalibResult> history_results)
|
||||||
: 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)
|
||||||
|
, m_history_results(history_results)
|
||||||
{
|
{
|
||||||
|
curr_obj = obj;
|
||||||
|
|
||||||
this->SetBackgroundColour(*wxWHITE);
|
this->SetBackgroundColour(*wxWHITE);
|
||||||
auto main_sizer = new wxBoxSizer(wxVERTICAL);
|
auto main_sizer = new wxBoxSizer(wxVERTICAL);
|
||||||
|
|
||||||
|
@ -611,6 +617,22 @@ void EditCalibrationHistoryDialog::on_save(wxCommandEvent& event) {
|
||||||
m_k_value->GetTextCtrl()->SetValue(k_str);
|
m_k_value->GetTextCtrl()->SetValue(k_str);
|
||||||
m_new_result.k_value = k;
|
m_new_result.k_value = k;
|
||||||
|
|
||||||
|
auto iter = std::find_if(m_history_results.begin(), m_history_results.end(), [this](const PACalibResult &item) {
|
||||||
|
bool has_same_name = item.name == m_new_result.name && item.filament_id == m_new_result.filament_id;
|
||||||
|
if (curr_obj && curr_obj->is_multi_extruders()) {
|
||||||
|
has_same_name &= (item.extruder_id == m_new_result.extruder_id && item.nozzle_volume_type == m_new_result.nozzle_volume_type);
|
||||||
|
}
|
||||||
|
return has_same_name;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (iter != m_history_results.end()) {
|
||||||
|
wxString duplicate_name_info = wxString::Format(
|
||||||
|
_L("Within the same extruder, the name '%s' must be unique when the filament type, nozzle diameter, and nozzle flow are identical. Please choose a different name."),
|
||||||
|
m_new_result.name);
|
||||||
|
MessageDialog msg_dlg(nullptr, duplicate_name_info, wxEmptyString, wxICON_WARNING | wxOK);
|
||||||
|
msg_dlg.ShowModal();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
EndModal(wxID_OK);
|
EndModal(wxID_OK);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ protected:
|
||||||
class EditCalibrationHistoryDialog : public DPIDialog
|
class EditCalibrationHistoryDialog : public DPIDialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
EditCalibrationHistoryDialog(wxWindow* parent, const PACalibResult& result, const MachineObject* obj);
|
EditCalibrationHistoryDialog(wxWindow *parent, const PACalibResult &result, const MachineObject *obj, const std::vector<PACalibResult> history_results);
|
||||||
~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();
|
||||||
|
@ -55,6 +55,8 @@ protected:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
PACalibResult m_new_result;
|
PACalibResult m_new_result;
|
||||||
|
std::vector<PACalibResult> m_history_results;
|
||||||
|
const MachineObject * curr_obj;
|
||||||
|
|
||||||
TextInput* m_name_value{ nullptr };
|
TextInput* m_name_value{ nullptr };
|
||||||
TextInput* m_k_value{ nullptr };
|
TextInput* m_k_value{ nullptr };
|
||||||
|
|
|
@ -608,12 +608,13 @@ void CalibrationPresetPage::create_selection_panel(wxWindow* parent)
|
||||||
on_device_connected(curr_obj);
|
on_device_connected(curr_obj);
|
||||||
});
|
});
|
||||||
|
|
||||||
auto sync_button_text = new Label(parent, _L("Sync printer information"));
|
wxString sync_text = _L("Sync printer information") + _L(" Synced");
|
||||||
sync_button_text->SetFont(Label::Head_14);
|
m_sync_button_text = new Label(parent, sync_text);
|
||||||
sync_button_text->Wrap(-1);
|
m_sync_button_text->SetFont(Label::Head_14);
|
||||||
|
m_sync_button_text->Wrap(-1);
|
||||||
sync_button_sizer->Add(m_btn_sync);
|
sync_button_sizer->Add(m_btn_sync);
|
||||||
sync_button_sizer->AddSpacer(FromDIP(20));
|
sync_button_sizer->AddSpacer(FromDIP(20));
|
||||||
sync_button_sizer->Add(sync_button_text, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);
|
sync_button_sizer->Add(m_sync_button_text, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);
|
||||||
panel_sizer->Add(sync_button_sizer);
|
panel_sizer->Add(sync_button_sizer);
|
||||||
panel_sizer->AddSpacer(PRESET_GAP);
|
panel_sizer->AddSpacer(PRESET_GAP);
|
||||||
|
|
||||||
|
@ -1726,9 +1727,13 @@ void CalibrationPresetPage::update_sync_button_status()
|
||||||
if (synced) {
|
if (synced) {
|
||||||
m_btn_sync->SetBorderColor(synced_colour);
|
m_btn_sync->SetBorderColor(synced_colour);
|
||||||
m_btn_sync->SetIcon("ams_nozzle_sync");
|
m_btn_sync->SetIcon("ams_nozzle_sync");
|
||||||
|
wxString sync_text = _L("Sync printer information") + _L(" (Synced)");
|
||||||
|
m_sync_button_text->SetLabel(sync_text);
|
||||||
} else {
|
} else {
|
||||||
m_btn_sync->SetBorderColor(not_synced_colour);
|
m_btn_sync->SetBorderColor(not_synced_colour);
|
||||||
m_btn_sync->SetIcon("printer_sync");
|
m_btn_sync->SetIcon("printer_sync");
|
||||||
|
wxString sync_text = _L("Sync printer information") + _L(" (Not synced)");
|
||||||
|
m_sync_button_text->SetLabel(sync_text);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -305,6 +305,7 @@ protected:
|
||||||
void on_select_nozzle_volume_type(wxCommandEvent &evt, size_t extruder_id);
|
void on_select_nozzle_volume_type(wxCommandEvent &evt, size_t extruder_id);
|
||||||
|
|
||||||
Button *m_btn_sync{nullptr};
|
Button *m_btn_sync{nullptr};
|
||||||
|
Label* m_sync_button_text;
|
||||||
|
|
||||||
wxPanel* m_single_nozzle_info_panel{nullptr};
|
wxPanel* m_single_nozzle_info_panel{nullptr};
|
||||||
wxPanel* m_multi_nozzle_info_panel{nullptr};
|
wxPanel* m_multi_nozzle_info_panel{nullptr};
|
||||||
|
|
Loading…
Reference in New Issue