mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-19 19:33:47 +00:00
ENH: add default item for pa
jira: none Change-Id: I4ad3bd094325bdbd1e6b013a91766214951dc032 (cherry picked from commit 0c772105f946121c292f92ab3ca1d050b898311b)
This commit is contained in:
@@ -13,6 +13,31 @@ namespace Slic3r { namespace GUI {
|
|||||||
|
|
||||||
wxDEFINE_EVENT(EVT_SELECTED_COLOR, wxCommandEvent);
|
wxDEFINE_EVENT(EVT_SELECTED_COLOR, wxCommandEvent);
|
||||||
|
|
||||||
|
static void get_default_k_n_value(const std::string &filament_id, float &k, float &n)
|
||||||
|
{
|
||||||
|
if (filament_id.compare("GFG00") == 0) {
|
||||||
|
// PETG
|
||||||
|
k = 0.04;
|
||||||
|
n = 1.0;
|
||||||
|
} else if (filament_id.compare("GFB00") == 0 || filament_id.compare("GFB50") == 0) {
|
||||||
|
// ABS
|
||||||
|
k = 0.04;
|
||||||
|
n = 1.0;
|
||||||
|
} else if (filament_id.compare("GFU01") == 0) {
|
||||||
|
// TPU
|
||||||
|
k = 0.2;
|
||||||
|
n = 1.0;
|
||||||
|
} else if (filament_id.compare("GFB01") == 0) {
|
||||||
|
// ASA
|
||||||
|
k = 0.04;
|
||||||
|
n = 1.0;
|
||||||
|
} else {
|
||||||
|
// PLA , other
|
||||||
|
k = 0.02;
|
||||||
|
n = 1.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static std::string float_to_string_with_precision(float value, int precision = 3)
|
static std::string float_to_string_with_precision(float value, int precision = 3)
|
||||||
{
|
{
|
||||||
std::stringstream stream;
|
std::stringstream stream;
|
||||||
@@ -76,7 +101,7 @@ void AMSMaterialsSetting::create()
|
|||||||
m_sizer_button->Add(m_button_close, 0, wxALIGN_CENTER, 0);
|
m_sizer_button->Add(m_button_close, 0, wxALIGN_CENTER, 0);
|
||||||
|
|
||||||
m_sizer_main->Add(m_panel_normal, 0, wxALL, FromDIP(2));
|
m_sizer_main->Add(m_panel_normal, 0, wxALL, FromDIP(2));
|
||||||
|
|
||||||
m_sizer_main->Add(m_panel_kn, 0, wxALL, FromDIP(2));
|
m_sizer_main->Add(m_panel_kn, 0, wxALL, FromDIP(2));
|
||||||
|
|
||||||
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(24));
|
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(24));
|
||||||
@@ -353,7 +378,7 @@ void AMSMaterialsSetting::create_panel_kn(wxWindow* parent)
|
|||||||
parent->SetSizer(sizer);
|
parent->SetSizer(sizer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AMSMaterialsSetting::paintEvent(wxPaintEvent &evt)
|
void AMSMaterialsSetting::paintEvent(wxPaintEvent &evt)
|
||||||
{
|
{
|
||||||
auto size = GetSize();
|
auto size = GetSize();
|
||||||
wxPaintDC dc(this);
|
wxPaintDC dc(this);
|
||||||
@@ -368,7 +393,7 @@ AMSMaterialsSetting::~AMSMaterialsSetting()
|
|||||||
m_comboBox_cali_result->Disconnect(wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler(AMSMaterialsSetting::on_select_cali_result), NULL, this);
|
m_comboBox_cali_result->Disconnect(wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler(AMSMaterialsSetting::on_select_cali_result), NULL, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AMSMaterialsSetting::input_min_finish()
|
void AMSMaterialsSetting::input_min_finish()
|
||||||
{
|
{
|
||||||
if (m_input_nozzle_min->GetTextCtrl()->GetValue().empty()) return;
|
if (m_input_nozzle_min->GetTextCtrl()->GetValue().empty()) return;
|
||||||
|
|
||||||
@@ -423,7 +448,7 @@ void AMSMaterialsSetting::enable_confirm_button(bool en)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!m_is_third) {
|
if (!m_is_third) {
|
||||||
m_tip_readonly->Hide();
|
m_tip_readonly->Hide();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!obj->is_support_filament_setting_inprinting) {
|
if (!obj->is_support_filament_setting_inprinting) {
|
||||||
@@ -530,7 +555,7 @@ void AMSMaterialsSetting::on_select_ok(wxCommandEvent &event)
|
|||||||
std::string vendor_name = vendor->values[0];
|
std::string vendor_name = vendor->values[0];
|
||||||
DeviceManager::check_filaments_in_blacklist(vendor_name, filamnt_type, in_blacklist, action, info);
|
DeviceManager::check_filaments_in_blacklist(vendor_name, filamnt_type, in_blacklist, action, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (in_blacklist) {
|
if (in_blacklist) {
|
||||||
if (action == "prohibition") {
|
if (action == "prohibition") {
|
||||||
@@ -582,7 +607,7 @@ void AMSMaterialsSetting::on_select_ok(wxCommandEvent &event)
|
|||||||
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);
|
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
|
//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();
|
||||||
@@ -710,7 +735,7 @@ void AMSMaterialsSetting::on_picker_color(wxCommandEvent& event)
|
|||||||
set_color(wxColour(color_num>>24&0xFF, color_num>>16&0xFF, color_num>>8&0xFF, color_num&0xFF));
|
set_color(wxColour(color_num>>24&0xFF, color_num>>16&0xFF, color_num>>8&0xFF, color_num&0xFF));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AMSMaterialsSetting::on_clr_picker(wxMouseEvent &event)
|
void AMSMaterialsSetting::on_clr_picker(wxMouseEvent &event)
|
||||||
{
|
{
|
||||||
if(!m_is_third)
|
if(!m_is_third)
|
||||||
return;
|
return;
|
||||||
@@ -769,8 +794,8 @@ void AMSMaterialsSetting::update_widgets()
|
|||||||
Layout();
|
Layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AMSMaterialsSetting::Show(bool show)
|
bool AMSMaterialsSetting::Show(bool show)
|
||||||
{
|
{
|
||||||
if (show) {
|
if (show) {
|
||||||
m_button_confirm->SetMinSize(AMS_MATERIALS_SETTING_BUTTON_SIZE);
|
m_button_confirm->SetMinSize(AMS_MATERIALS_SETTING_BUTTON_SIZE);
|
||||||
m_input_nozzle_max->GetTextCtrl()->SetSize(wxSize(-1, FromDIP(20)));
|
m_input_nozzle_max->GetTextCtrl()->SetSize(wxSize(-1, FromDIP(20)));
|
||||||
@@ -794,7 +819,7 @@ bool AMSMaterialsSetting::Show(bool show)
|
|||||||
Fit();
|
Fit();
|
||||||
wxGetApp().UpdateDarkUI(this);
|
wxGetApp().UpdateDarkUI(this);
|
||||||
}
|
}
|
||||||
return DPIDialog::Show(show);
|
return DPIDialog::Show(show);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AMSMaterialsSetting::Popup(wxString filament, wxString sn, wxString temp_min, wxString temp_max, wxString k, wxString n)
|
void AMSMaterialsSetting::Popup(wxString filament, wxString sn, wxString temp_min, wxString temp_max, wxString k, wxString n)
|
||||||
@@ -820,7 +845,7 @@ void AMSMaterialsSetting::Popup(wxString filament, wxString sn, wxString temp_mi
|
|||||||
stream << std::fixed << std::setprecision(1) << obj->nozzle_diameter;
|
stream << std::fixed << std::setprecision(1) << obj->nozzle_diameter;
|
||||||
std::string nozzle_diameter_str = stream.str();
|
std::string nozzle_diameter_str = stream.str();
|
||||||
std::set<std::string> printer_names = preset_bundle->get_printer_names_by_printer_type_and_nozzle(MachineObject::get_preset_printer_model_name(obj->printer_type), nozzle_diameter_str);
|
std::set<std::string> printer_names = preset_bundle->get_printer_names_by_printer_type_and_nozzle(MachineObject::get_preset_printer_model_name(obj->printer_type), nozzle_diameter_str);
|
||||||
|
|
||||||
if (preset_bundle) {
|
if (preset_bundle) {
|
||||||
BOOST_LOG_TRIVIAL(trace) << "system_preset_bundle filament number=" << preset_bundle->filaments.size();
|
BOOST_LOG_TRIVIAL(trace) << "system_preset_bundle filament number=" << preset_bundle->filaments.size();
|
||||||
for (auto filament_it = preset_bundle->filaments.begin(); filament_it != preset_bundle->filaments.end(); filament_it++) {
|
for (auto filament_it = preset_bundle->filaments.begin(); filament_it != preset_bundle->filaments.end(); filament_it++) {
|
||||||
@@ -832,7 +857,7 @@ void AMSMaterialsSetting::Popup(wxString filament, wxString sn, wxString temp_mi
|
|||||||
if (preset_bundle->filaments.get_preset_base(*filament_it) != &preset || (!filament_it->is_system && !obj->is_support_user_preset)) {
|
if (preset_bundle->filaments.get_preset_base(*filament_it) != &preset || (!filament_it->is_system && !obj->is_support_user_preset)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigOption * printer_opt = filament_it->config.option("compatible_printers");
|
ConfigOption * printer_opt = filament_it->config.option("compatible_printers");
|
||||||
ConfigOptionStrings *printer_strs = dynamic_cast<ConfigOptionStrings *>(printer_opt);
|
ConfigOptionStrings *printer_strs = dynamic_cast<ConfigOptionStrings *>(printer_opt);
|
||||||
for (auto printer_str : printer_strs->values) {
|
for (auto printer_str : printer_strs->values) {
|
||||||
@@ -867,7 +892,7 @@ void AMSMaterialsSetting::Popup(wxString filament, wxString sn, wxString temp_mi
|
|||||||
if (filament_it->filament_id == ams_filament_id) {
|
if (filament_it->filament_id == ams_filament_id) {
|
||||||
selection_idx = idx;
|
selection_idx = idx;
|
||||||
bambu_filament_name = filament_it->alias;
|
bambu_filament_name = filament_it->alias;
|
||||||
|
|
||||||
|
|
||||||
// update if nozzle_temperature_range is found
|
// update if nozzle_temperature_range is found
|
||||||
ConfigOption *opt_min = filament_it->config.option("nozzle_temperature_range_low");
|
ConfigOption *opt_min = filament_it->config.option("nozzle_temperature_range_low");
|
||||||
@@ -891,7 +916,7 @@ void AMSMaterialsSetting::Popup(wxString filament, wxString sn, wxString temp_mi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -913,7 +938,7 @@ void AMSMaterialsSetting::Popup(wxString filament, wxString sn, wxString temp_mi
|
|||||||
else {
|
else {
|
||||||
m_readonly_filament->SetLabel(bambu_filament_name);
|
m_readonly_filament->SetLabel(bambu_filament_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_input_nozzle_min->GetTextCtrl()->SetValue(temp_min);
|
m_input_nozzle_min->GetTextCtrl()->SetValue(temp_min);
|
||||||
m_input_nozzle_max->GetTextCtrl()->SetValue(temp_max);
|
m_input_nozzle_max->GetTextCtrl()->SetValue(temp_max);
|
||||||
}
|
}
|
||||||
@@ -934,7 +959,7 @@ void AMSMaterialsSetting::Popup(wxString filament, wxString sn, wxString temp_mi
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_button_reset->Show();
|
m_button_reset->Show();
|
||||||
//m_button_confirm->Show();
|
//m_button_confirm->Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_comboBox_filament->Set(filament_items);
|
m_comboBox_filament->Set(filament_items);
|
||||||
@@ -1093,8 +1118,16 @@ void AMSMaterialsSetting::on_select_filament(wxCommandEvent &evt)
|
|||||||
wxArrayString items;
|
wxArrayString items;
|
||||||
m_pa_profile_items.clear();
|
m_pa_profile_items.clear();
|
||||||
m_comboBox_cali_result->SetValue(wxEmptyString);
|
m_comboBox_cali_result->SetValue(wxEmptyString);
|
||||||
|
|
||||||
if (obj->cali_version >= 0) {
|
if (obj->cali_version >= 0) {
|
||||||
|
// add default item
|
||||||
|
PACalibResult default_item;
|
||||||
|
default_item.filament_id = ams_filament_id;
|
||||||
|
default_item.cali_idx = -1;
|
||||||
|
get_default_k_n_value(ams_filament_id, default_item.k_value, default_item.n_coef);
|
||||||
|
m_pa_profile_items.emplace_back(default_item);
|
||||||
|
items.push_back(_L("Default"));
|
||||||
|
|
||||||
m_input_k_val->GetTextCtrl()->SetValue(wxEmptyString);
|
m_input_k_val->GetTextCtrl()->SetValue(wxEmptyString);
|
||||||
std::vector<PACalibResult> cali_history = this->obj->pa_calib_tab;
|
std::vector<PACalibResult> cali_history = this->obj->pa_calib_tab;
|
||||||
for (auto cali_item : cali_history) {
|
for (auto cali_item : cali_history) {
|
||||||
@@ -1111,6 +1144,9 @@ void AMSMaterialsSetting::on_select_filament(wxCommandEvent &evt)
|
|||||||
if (cali_select_idx >= 0) {
|
if (cali_select_idx >= 0) {
|
||||||
m_comboBox_cali_result->SetSelection(cali_select_idx);
|
m_comboBox_cali_result->SetSelection(cali_select_idx);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
m_comboBox_cali_result->SetSelection(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Ams* selected_ams = this->obj->amsList[std::to_string(ams_id)];
|
Ams* selected_ams = this->obj->amsList[std::to_string(ams_id)];
|
||||||
@@ -1121,8 +1157,11 @@ void AMSMaterialsSetting::on_select_filament(wxCommandEvent &evt)
|
|||||||
if (cali_select_idx >= 0) {
|
if (cali_select_idx >= 0) {
|
||||||
m_comboBox_cali_result->SetSelection(cali_select_idx);
|
m_comboBox_cali_result->SetSelection(cali_select_idx);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
m_comboBox_cali_result->SetSelection(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cali_select_idx >= 0) {
|
if (cali_select_idx >= 0) {
|
||||||
m_input_k_val->GetTextCtrl()->SetValue(float_to_string_with_precision(m_pa_profile_items[cali_select_idx].k_value));
|
m_input_k_val->GetTextCtrl()->SetValue(float_to_string_with_precision(m_pa_profile_items[cali_select_idx].k_value));
|
||||||
m_input_n_val->GetTextCtrl()->SetValue(float_to_string_with_precision(m_pa_profile_items[cali_select_idx].n_coef));
|
m_input_n_val->GetTextCtrl()->SetValue(float_to_string_with_precision(m_pa_profile_items[cali_select_idx].n_coef));
|
||||||
@@ -1144,8 +1183,8 @@ void AMSMaterialsSetting::on_select_filament(wxCommandEvent &evt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AMSMaterialsSetting::on_dpi_changed(const wxRect &suggested_rect)
|
void AMSMaterialsSetting::on_dpi_changed(const wxRect &suggested_rect)
|
||||||
{
|
{
|
||||||
m_input_nozzle_max->GetTextCtrl()->SetSize(wxSize(-1, FromDIP(20)));
|
m_input_nozzle_max->GetTextCtrl()->SetSize(wxSize(-1, FromDIP(20)));
|
||||||
m_input_nozzle_min->GetTextCtrl()->SetSize(wxSize(-1, FromDIP(20)));
|
m_input_nozzle_min->GetTextCtrl()->SetSize(wxSize(-1, FromDIP(20)));
|
||||||
//m_clr_picker->msw_rescale();
|
//m_clr_picker->msw_rescale();
|
||||||
@@ -1158,7 +1197,7 @@ void AMSMaterialsSetting::on_dpi_changed(const wxRect &suggested_rect)
|
|||||||
m_button_confirm->SetCornerRadius(FromDIP(12));
|
m_button_confirm->SetCornerRadius(FromDIP(12));
|
||||||
m_button_close->SetMinSize(AMS_MATERIALS_SETTING_BUTTON_SIZE);
|
m_button_close->SetMinSize(AMS_MATERIALS_SETTING_BUTTON_SIZE);
|
||||||
m_button_close->SetCornerRadius(FromDIP(12));
|
m_button_close->SetCornerRadius(FromDIP(12));
|
||||||
this->Refresh();
|
this->Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
ColorPicker::ColorPicker(wxWindow* parent, wxWindowID id, const wxPoint& pos /*= wxDefaultPosition*/, const wxSize& size /*= wxDefaultSize*/)
|
ColorPicker::ColorPicker(wxWindow* parent, wxWindowID id, const wxPoint& pos /*= wxDefaultPosition*/, const wxSize& size /*= wxDefaultSize*/)
|
||||||
@@ -1607,7 +1646,7 @@ void ColorPickerPopup::paintEvent(wxPaintEvent& evt)
|
|||||||
|
|
||||||
void ColorPickerPopup::OnDismiss() {}
|
void ColorPickerPopup::OnDismiss() {}
|
||||||
|
|
||||||
void ColorPickerPopup::Popup()
|
void ColorPickerPopup::Popup()
|
||||||
{
|
{
|
||||||
PopupWindow::Popup();
|
PopupWindow::Popup();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user