ENH: calibration

1.fix some issue: STUDIO-3127、STUDIO-3138、STUDIO-3135、STUDIO-3123、STUDIO-3117、STUDIO-3115、STUDIO-3114、STUDIO-3113、STUDIO-3112 and other issues
2.refine UI
3.FLOW RATE multi-slots calibrate saving related logic
4.add input validate and access protection

Change-Id: Ie6c04fdfd050cc48607182bd8cc8f145381a5b70
This commit is contained in:
liz.li 2023-06-06 16:47:14 +08:00 committed by Lane.Wei
parent 959de9d8af
commit 304c3abfe9
16 changed files with 1105 additions and 686 deletions

View File

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

Before

Width:  |  Height:  |  Size: 194 KiB

After

Width:  |  Height:  |  Size: 194 KiB

View File

Before

Width:  |  Height:  |  Size: 536 KiB

After

Width:  |  Height:  |  Size: 536 KiB

View File

@ -2,7 +2,9 @@
#include "I18N.hpp" #include "I18N.hpp"
namespace Slic3r { namespace GUI { namespace Slic3r { namespace GUI {
#define REFRESH_INTERVAL 1000 #define REFRESH_INTERVAL 1000
CalibrationPanel::CalibrationPanel(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style) CalibrationPanel::CalibrationPanel(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
: wxPanel(parent, id, pos, size, style) : wxPanel(parent, id, pos, size, style)
{ {
@ -39,6 +41,15 @@ void CalibrationPanel::init_tabpanel() {
m_temp_panel = new TemperatureWizard(m_tabpanel); m_temp_panel = new TemperatureWizard(m_tabpanel);
m_tabpanel->AddPage(m_temp_panel, _L("Temperature"), "", false); m_tabpanel->AddPage(m_temp_panel, _L("Temperature"), "", false);
for (int i = 0; i < 4; i++)
m_tabpanel->SetPageImage(i, "");
m_tabpanel->Bind(wxEVT_BOOKCTRL_PAGE_CHANGED, [this](wxBookCtrlEvent&) {
wxCommandEvent e (EVT_CALIBRATION_TAB_CHANGED);
e.SetEventObject(m_tabpanel->GetCurrentPage());
wxPostEvent(m_tabpanel->GetCurrentPage(), e);
}, m_tabpanel->GetId());
} }
void CalibrationPanel::init_timer() void CalibrationPanel::init_timer()
@ -54,19 +65,19 @@ void CalibrationPanel::on_timer(wxTimerEvent& event) {
} }
void CalibrationPanel::update_all() { void CalibrationPanel::update_all() {
if (m_pa_panel) { if (m_pa_panel && m_pa_panel->IsShown()) {
m_pa_panel->update_printer_selections(); m_pa_panel->update_printer_selections();
m_pa_panel->update_print_progress(); m_pa_panel->update_print_progress();
} }
if (m_flow_panel) { if (m_flow_panel && m_flow_panel->IsShown()) {
m_flow_panel->update_printer_selections(); m_flow_panel->update_printer_selections();
m_flow_panel->update_print_progress(); m_flow_panel->update_print_progress();
} }
if (m_volumetric_panel) { if (m_volumetric_panel && m_volumetric_panel->IsShown()) {
m_volumetric_panel->update_printer_selections(); m_volumetric_panel->update_printer_selections();
m_volumetric_panel->update_print_progress(); m_volumetric_panel->update_print_progress();
} }
if (m_temp_panel) { if (m_temp_panel && m_temp_panel->IsShown()) {
m_temp_panel->update_printer_selections(); m_temp_panel->update_printer_selections();
m_temp_panel->update_print_progress(); m_temp_panel->update_print_progress();
} }

File diff suppressed because it is too large Load Diff

View File

@ -16,6 +16,7 @@ namespace Slic3r { namespace GUI {
wxDECLARE_EVENT(EVT_CALIBRATION_TRAY_SELECTION_CHANGED, SimpleEvent); wxDECLARE_EVENT(EVT_CALIBRATION_TRAY_SELECTION_CHANGED, SimpleEvent);
wxDECLARE_EVENT(EVT_CALIBRATION_NOTIFY_CHANGE_PAGES, SimpleEvent); wxDECLARE_EVENT(EVT_CALIBRATION_NOTIFY_CHANGE_PAGES, SimpleEvent);
wxDECLARE_EVENT(EVT_CALIBRATION_TAB_CHANGED, wxCommandEvent);
enum FilamentSelectMode { enum FilamentSelectMode {
FSMCheckBoxMode, FSMCheckBoxMode,
@ -32,6 +33,7 @@ public:
void load_tray_from_ams(int id, DynamicPrintConfig& tray); void load_tray_from_ams(int id, DynamicPrintConfig& tray);
void update_from_preset(); void update_from_preset();
int get_tray_id() { return m_tray_id; } int get_tray_id() { return m_tray_id; }
bool is_bbl_filament() { return m_is_bbl_filamnet; }
std::string get_tray_name() { return m_tray_name; } std::string get_tray_name() { return m_tray_name; }
CalibrateFilamentComboBox* GetComboBox() { return m_comboBox; } CalibrateFilamentComboBox* GetComboBox() { return m_comboBox; }
CheckBox* GetCheckBox() { return m_checkBox; } CheckBox* GetCheckBox() { return m_checkBox; }
@ -45,6 +47,7 @@ public:
protected: protected:
int m_tray_id; int m_tray_id;
std::string m_tray_name; std::string m_tray_name;
bool m_is_bbl_filamnet{ false };
CheckBox* m_checkBox{nullptr}; CheckBox* m_checkBox{nullptr};
//RadioBox* m_radioBox; //RadioBox* m_radioBox;
@ -73,6 +76,7 @@ protected:
virtual bool save_calibration_result() = 0; virtual bool save_calibration_result() = 0;
virtual bool recommend_input_value(); virtual bool recommend_input_value();
virtual void request_calib_result() {}; virtual void request_calib_result() {};
virtual void change_ams_select_mode() {};
protected: protected:
MachineObject* curr_obj{ nullptr }; MachineObject* curr_obj{ nullptr };
@ -122,6 +126,8 @@ protected:
// print panel // print panel
wxPanel* m_print_panel; wxPanel* m_print_panel;
wxStaticText* m_staticText_profile_value;
wxStaticText* m_printing_stage_value;
wxStaticText* m_staticText_progress_percent; wxStaticText* m_staticText_progress_percent;
wxStaticText* m_staticText_progress_left_time; wxStaticText* m_staticText_progress_left_time;
wxStaticText* m_staticText_layers; wxStaticText* m_staticText_layers;
@ -132,21 +138,28 @@ protected:
PageButton* m_btn_recali; PageButton* m_btn_recali;
// save panel // save panel
//wxPanel* m_save_panel; wxPanel* m_save_panel;
void create_presets_panel(CalibrationWizardPage* page, wxBoxSizer* sizer, bool need_custom_range = true);
void add_presets_panel_to_page(CalibrationWizardPage* page, wxBoxSizer* sizer); void create_send_progress_bar(CalibrationWizardPage* page, wxBoxSizer* sizer);
void add_print_panel_to_page(CalibrationWizardPage* page, wxBoxSizer* sizer); void init_presets_selections();
void add_send_progress_to_page(CalibrationWizardPage* page, wxBoxSizer* sizer); void init_nozzle_selections();
void init_bed_type_selections();
void reset_printing_values(); void init_process_selections();
bool save_presets(const std::string& config_key, ConfigOption* config_value);
int get_bed_temp(DynamicPrintConfig* config); int get_bed_temp(DynamicPrintConfig* config);
FilamentSelectMode get_ams_select_mode() { if (!m_filament_comboBox_list.empty()) return m_filament_comboBox_list[0]->get_select_mode(); return FilamentSelectMode::FSMRadioMode; } FilamentSelectMode get_ams_select_mode() { if (!m_filament_comboBox_list.empty()) return m_filament_comboBox_list[0]->get_select_mode(); return FilamentSelectMode::FSMRadioMode; }
void set_ams_select_mode(FilamentSelectMode mode) { for (auto fcb : m_filament_comboBox_list) fcb->set_select_mode(mode); }; void set_ams_select_mode(FilamentSelectMode mode);
std::vector<int> get_selected_tray(); std::vector<int> get_selected_tray();
FilamentComboBoxList get_selected_filament_comboBox(); FilamentComboBoxList get_selected_filament_comboBox();
void create_print_panel(CalibrationWizardPage* page, wxBoxSizer* sizer);
void reset_printing_values();
void create_save_panel(CalibrationWizardPage* page, wxBoxSizer* sizer);
virtual void create_save_panel_content(wxBoxSizer* sizer) {}
bool save_presets(const std::string& config_key, ConfigOption* config_value, const std::string& name);
// event handlers
void on_select_printer(wxCommandEvent& evt); void on_select_printer(wxCommandEvent& evt);
void on_select_nozzle(wxCommandEvent& evt); void on_select_nozzle(wxCommandEvent& evt);
void on_select_tray(SimpleEvent& evt); void on_select_tray(SimpleEvent& evt);
@ -159,17 +172,6 @@ protected:
void on_choose_ext_spool(wxCommandEvent& event); void on_choose_ext_spool(wxCommandEvent& event);
void on_update_ams_filament(bool dialog = true); void on_update_ams_filament(bool dialog = true);
void on_switch_ams(std::string ams_id); void on_switch_ams(std::string ams_id);
private:
void create_presets_panel();
void create_print_panel();
//void create_save_panel();
void create_send_progress_bar();
void init_presets_selections();
void init_nozzle_selections();
void init_bed_type_selections();
void init_process_selections();
}; };
class PressureAdvanceWizard : public CalibrationWizard{ class PressureAdvanceWizard : public CalibrationWizard{
@ -177,30 +179,39 @@ public:
PressureAdvanceWizard(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL); PressureAdvanceWizard(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL);
~PressureAdvanceWizard() {}; ~PressureAdvanceWizard() {};
protected: protected:
void create_low_end_pages(); void create_history_window();
void create_high_end_pages();
virtual void create_pages() override; virtual void create_pages() override;
virtual void create_save_panel_content(wxBoxSizer* sizer) override;
virtual bool start_calibration(std::vector<int> tray_ids) override; virtual bool start_calibration(std::vector<int> tray_ids) override;
virtual bool save_calibration_result() override; virtual bool save_calibration_result() override;
virtual bool recommend_input_value() override; virtual bool recommend_input_value() override;
virtual void request_calib_result() override; virtual void request_calib_result() override;
virtual void change_ams_select_mode() override;
void sync_save_page_data(); void sync_save_page_data();
void switch_pages(SimpleEvent& evt); void switch_pages(SimpleEvent& evt);
private: private:
// page 1 // history page
//CalibrationWizardPage* m_history_page{ nullptr };
// start page
CalibrationWizardPage* m_page0{ nullptr };
// preset page
CalibrationWizardPage* m_page1{ nullptr }; CalibrationWizardPage* m_page1{ nullptr };
// page 2 // print page
CalibrationWizardPage* m_page2{ nullptr }; CalibrationWizardPage* m_page2{ nullptr };
// page 3 // save page
CalibrationWizardPage* m_low_end_page3{ nullptr }; CalibrationWizardPage* m_page3{ nullptr };
wxPanel* m_low_end_save_panel;
TextInput* m_k_val; TextInput* m_k_val;
TextInput* m_n_val; TextInput* m_n_val;
CalibrationWizardPage* m_high_end_page3{ nullptr }; wxPanel* m_high_end_save_panel;
std::vector<PACalibResult> m_calib_results; std::vector<PACalibResult> m_calib_results;
std::vector<PACalibResult> m_calib_results_history;
wxPanel* m_grid_panel; wxPanel* m_grid_panel;
}; };
@ -212,32 +223,46 @@ protected:
void create_low_end_pages(); void create_low_end_pages();
void create_high_end_pages(); void create_high_end_pages();
virtual void create_pages() override; virtual void create_pages() override;
virtual void create_save_panel_content(wxBoxSizer* sizer) override;
virtual bool start_calibration(std::vector<int> tray_ids) override; virtual bool start_calibration(std::vector<int> tray_ids) override;
virtual bool save_calibration_result() override; virtual bool save_calibration_result() override;
virtual bool recommend_input_value() override; virtual bool recommend_input_value() override;
virtual void request_calib_result() override; virtual void request_calib_result() override;
virtual void change_ams_select_mode() override;
void sync_save_page_data();
void switch_pages(SimpleEvent& evt); void switch_pages(SimpleEvent& evt);
private: private:
// page 1 // preset page
CalibrationWizardPage* m_page1{ nullptr }; CalibrationWizardPage* m_page1{ nullptr };
// page 2 // print page
CalibrationWizardPage* m_page2{ nullptr }; CalibrationWizardPage* m_page2{ nullptr };
// page 3 // page 3
CalibrationWizardPage* m_low_end_page3{ nullptr }; CalibrationWizardPage* m_low_end_page3{ nullptr };
ComboBox* m_optimal_block_coarse; ComboBox* m_optimal_block_coarse;
wxStaticText* m_coarse_calc_result_text;
float m_coarse_calc_result;
CheckBox* m_checkBox_skip_calibration;
CalibrationWizardPage* m_high_end_page3{ nullptr }; CalibrationWizardPage* m_high_end_page3{ nullptr };
std::vector<FlowRatioCalibResult> m_calib_results; std::vector<FlowRatioCalibResult> m_calib_results;
wxPanel* m_grid_panel;
std::map<int, std::string> m_high_end_save_names;
// page 4 // page 4
CalibrationWizardPage* m_low_end_page4{ nullptr }; CalibrationWizardPage* m_low_end_page4{ nullptr };
// page 5 // save page
CalibrationWizardPage* m_low_end_page5{ nullptr }; CalibrationWizardPage* m_low_end_page5{ nullptr };
ComboBox* m_optimal_block_fine; ComboBox* m_optimal_block_fine;
wxStaticText* m_fine_calc_result_text;
float m_fine_calc_result;
std::string m_save_name;
void reset_print_panel_to_page(CalibrationWizardPage* page, wxBoxSizer* sizer);
void reset_send_progress_to_page(CalibrationWizardPage* page, wxBoxSizer* sizer);
void on_fine_tune(wxCommandEvent&); void on_fine_tune(wxCommandEvent&);
}; };
@ -247,19 +272,23 @@ public:
~MaxVolumetricSpeedWizard() {}; ~MaxVolumetricSpeedWizard() {};
protected: protected:
virtual void create_pages() override; virtual void create_pages() override;
virtual void create_save_panel_content(wxBoxSizer* sizer) override;
virtual bool start_calibration(std::vector<int> tray_ids) override; virtual bool start_calibration(std::vector<int> tray_ids) override;
virtual bool save_calibration_result() override; virtual bool save_calibration_result() override;
virtual bool recommend_input_value() override; virtual bool recommend_input_value() override;
private: private:
// page 1 // preset page
CalibrationWizardPage* m_page1; CalibrationWizardPage* m_page1;
// page 2 // print page
CalibrationWizardPage* m_page2; CalibrationWizardPage* m_page2;
// page 3 // save page
CalibrationWizardPage* m_page3; CalibrationWizardPage* m_page3;
TextInput* m_optimal_max_speed; TextInput* m_optimal_max_speed;
wxStaticText* m_calc_result_text;
float m_calc_result;
std::string m_save_name;
}; };
class TemperatureWizard : public CalibrationWizard { class TemperatureWizard : public CalibrationWizard {
@ -268,19 +297,21 @@ public:
~TemperatureWizard() {}; ~TemperatureWizard() {};
protected: protected:
virtual void create_pages() override; virtual void create_pages() override;
virtual void create_save_panel_content(wxBoxSizer* sizer) override;
virtual bool start_calibration(std::vector<int> tray_ids) override; virtual bool start_calibration(std::vector<int> tray_ids) override;
virtual bool save_calibration_result() override; virtual bool save_calibration_result() override;
virtual bool recommend_input_value() override; virtual bool recommend_input_value() override;
private: private:
// page 1 // preset page
CalibrationWizardPage* m_page1; CalibrationWizardPage* m_page1;
// page 2 // print page
CalibrationWizardPage* m_page2; CalibrationWizardPage* m_page2;
// page 3 // save page
CalibrationWizardPage* m_page3; CalibrationWizardPage* m_page3;
TextInput* m_optimal_temp; TextInput* m_optimal_temp;
std::string m_save_name;
}; };
class VFAWizard : public CalibrationWizard {}; class VFAWizard : public CalibrationWizard {};

View File

@ -87,40 +87,41 @@ CalibrationWizardPage::CalibrationWizardPage(wxWindow* parent, wxWindowID id, co
page_sizer->AddSpacer(FromDIP(20)); page_sizer->AddSpacer(FromDIP(20));
m_top_sizer = new wxBoxSizer(wxHORIZONTAL); m_top_sizer = new wxBoxSizer(wxHORIZONTAL);
m_top_sizer->AddSpacer(FromDIP(180)); m_top_sizer->AddStretchSpacer();
m_preset_text = new wxStaticText(this, wxID_ANY, _L("Preset"), wxDefaultPosition, wxDefaultSize, 0); m_preset_text = new wxStaticText(this, wxID_ANY, _L("Preset"), wxDefaultPosition, wxDefaultSize, 0);
m_preset_text->SetFont(::Label::Head_14); m_preset_text->SetFont(::Label::Head_14);
m_top_sizer->Add(m_preset_text, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, FromDIP(15)); m_top_sizer->Add(m_preset_text, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, FromDIP(15));
auto line1 = new wxPanel(this, wxID_ANY, wxDefaultPosition, {FromDIP(250), 1}); auto line1 = new wxPanel(this, wxID_ANY, wxDefaultPosition, {FromDIP(200), 1});
line1->SetBackgroundColour(*wxBLACK); line1->SetBackgroundColour(*wxBLACK);
m_top_sizer->Add(line1, 1, wxALIGN_CENTER, 0); m_top_sizer->Add(line1, 1, wxALIGN_CENTER, 0);
m_calibration_text = new wxStaticText(this, wxID_ANY, _L("Calibration"), wxDefaultPosition, wxDefaultSize, 0); m_calibration_text = new wxStaticText(this, wxID_ANY, _L("Calibration"), wxDefaultPosition, wxDefaultSize, 0);
m_calibration_text->SetFont(::Label::Head_14); m_calibration_text->SetFont(::Label::Head_14);
m_top_sizer->Add(m_calibration_text, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, FromDIP(15)); m_top_sizer->Add(m_calibration_text, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, FromDIP(15));
auto line2 = new wxPanel(this, wxID_ANY, wxDefaultPosition, { FromDIP(250), 1}); auto line2 = new wxPanel(this, wxID_ANY, wxDefaultPosition, { FromDIP(200), 1});
line2->SetBackgroundColour(*wxBLACK); line2->SetBackgroundColour(*wxBLACK);
m_top_sizer->Add(line2, 1, wxALIGN_CENTER, 0); m_top_sizer->Add(line2, 1, wxALIGN_CENTER, 0);
m_record_text = new wxStaticText(this, wxID_ANY, _L("Record"), wxDefaultPosition, wxDefaultSize, 0); m_record_text = new wxStaticText(this, wxID_ANY, _L("Record"), wxDefaultPosition, wxDefaultSize, 0);
m_record_text->SetFont(::Label::Head_14); m_record_text->SetFont(::Label::Head_14);
m_top_sizer->Add(m_record_text, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, FromDIP(15)); m_top_sizer->Add(m_record_text, 0, wxALIGN_CENTER | wxLEFT | wxRIGHT, FromDIP(15));
m_top_sizer->AddSpacer(FromDIP(180)); m_top_sizer->AddStretchSpacer();
page_sizer->Add(m_top_sizer, 0, wxEXPAND, 0); page_sizer->Add(m_top_sizer, 0, wxEXPAND, 0);
page_sizer->AddSpacer(FromDIP(40)); page_sizer->AddSpacer(FromDIP(40));
m_content_sizer = new wxBoxSizer(wxVERTICAL); m_content_sizer = new wxBoxSizer(wxVERTICAL);
page_sizer->Add(m_content_sizer, 0, wxEXPAND, 0); page_sizer->Add(m_content_sizer, 0, wxALIGN_CENTER, 0);
page_sizer->AddStretchSpacer(); page_sizer->AddSpacer(FromDIP(40));
m_btn_sizer = new wxBoxSizer(wxHORIZONTAL); m_btn_sizer = new wxBoxSizer(wxHORIZONTAL);
m_btn_sizer->Add(0, 0, 1, wxEXPAND, 0); m_btn_sizer->AddStretchSpacer();
m_btn_prev = new PageButton(this, "Back", Back); m_btn_prev = new PageButton(this, "Back", Back);
m_btn_sizer->Add(m_btn_prev, 0); m_btn_sizer->Add(m_btn_prev, 0);
m_btn_sizer->AddSpacer(FromDIP(10)); m_btn_sizer->AddSpacer(FromDIP(10));
m_btn_next = new PageButton(this, "Next", Next); m_btn_next = new PageButton(this, "Next", Next);
m_btn_sizer->Add(m_btn_next, 0); m_btn_sizer->Add(m_btn_next, 0);
m_btn_sizer->AddStretchSpacer();
page_sizer->Add(m_btn_sizer, 0, wxEXPAND, 0); page_sizer->Add(m_btn_sizer, 0, wxEXPAND, 0);

View File

@ -1383,10 +1383,11 @@ void Sidebar::load_ams_list(std::string const &device, MachineObject* obj)
if (is_support_virtual_tray) { if (is_support_virtual_tray) {
DynamicPrintConfig vt_tray_config; DynamicPrintConfig vt_tray_config;
vt_tray_config.set_key_value("filament_id", new ConfigOptionStrings{ vt_tray.setting_id }); vt_tray_config.set_key_value("filament_id", new ConfigOptionStrings{ vt_tray.setting_id });
vt_tray_config.set_key_value("tag_uid", new ConfigOptionStrings{ vt_tray.tag_uid });
vt_tray_config.set_key_value("filament_type", new ConfigOptionStrings{ vt_tray.type }); vt_tray_config.set_key_value("filament_type", new ConfigOptionStrings{ vt_tray.type });
vt_tray_config.set_key_value("tray_name", new ConfigOptionStrings{std::string("Ext")}); vt_tray_config.set_key_value("tray_name", new ConfigOptionStrings{std::string("Ext")});
vt_tray_config.set_key_value("filament_colour", new ConfigOptionStrings{into_u8(wxColour("#" + vt_tray.color).GetAsString(wxC2S_HTML_SYNTAX))}); vt_tray_config.set_key_value("filament_colour", new ConfigOptionStrings{into_u8(wxColour("#" + vt_tray.color).GetAsString(wxC2S_HTML_SYNTAX))});
vt_tray_config.set_key_value("filament_exist", new ConfigOptionBools{ vt_tray.is_exists }); vt_tray_config.set_key_value("filament_exist", new ConfigOptionBools{ true });
filament_ams_list.emplace(VIRTUAL_TRAY_ID, std::move(vt_tray_config)); filament_ams_list.emplace(VIRTUAL_TRAY_ID, std::move(vt_tray_config));
} }
@ -1400,6 +1401,7 @@ void Sidebar::load_ams_list(std::string const &device, MachineObject* obj)
char t = tray.first.front() - '0' + '1'; char t = tray.first.front() - '0' + '1';
DynamicPrintConfig tray_config; DynamicPrintConfig tray_config;
tray_config.set_key_value("filament_id", new ConfigOptionStrings{tray.second->setting_id}); tray_config.set_key_value("filament_id", new ConfigOptionStrings{tray.second->setting_id});
tray_config.set_key_value("tag_uid", new ConfigOptionStrings{ tray.second->tag_uid });
tray_config.set_key_value("filament_type", new ConfigOptionStrings{tray.second->type}); tray_config.set_key_value("filament_type", new ConfigOptionStrings{tray.second->type});
tray_config.set_key_value("tray_name", new ConfigOptionStrings{std::string(1, n) + std::string(1, t)}); tray_config.set_key_value("tray_name", new ConfigOptionStrings{std::string(1, n) + std::string(1, t)});
tray_config.set_key_value("filament_colour", new ConfigOptionStrings{into_u8(wxColour("#" + tray.second->color).GetAsString(wxC2S_HTML_SYNTAX))}); tray_config.set_key_value("filament_colour", new ConfigOptionStrings{into_u8(wxColour("#" + tray.second->color).GetAsString(wxC2S_HTML_SYNTAX))});

View File

@ -1397,6 +1397,7 @@ void GUI::CalibrateFilamentComboBox::load_tray(DynamicPrintConfig &config)
{ {
m_tray_name = config.opt_string("tray_name", 0u); m_tray_name = config.opt_string("tray_name", 0u);
m_filament_id = config.opt_string("filament_id", 0u); m_filament_id = config.opt_string("filament_id", 0u);
m_tag_uid = config.opt_string("tag_uid", 0u);
m_filament_type = config.opt_string("filament_type", 0u); m_filament_type = config.opt_string("filament_type", 0u);
m_filament_color = config.opt_string("filament_colour", 0u); m_filament_color = config.opt_string("filament_colour", 0u);
m_filament_exist = config.opt_bool("filament_exist", 0u); m_filament_exist = config.opt_bool("filament_exist", 0u);
@ -1408,21 +1409,32 @@ void GUI::CalibrateFilamentComboBox::load_tray(DynamicPrintConfig &config)
#endif #endif
if (!m_filament_exist) { if (!m_filament_exist) {
SetValue(_L("Empty")); SetValue(_L("Empty"));
m_selected_preset = nullptr;
m_is_compatible = false;
clr_picker->SetBitmap(*get_extruder_color_icon("#F0F0F0FF", m_tray_name, 16, 16)); clr_picker->SetBitmap(*get_extruder_color_icon("#F0F0F0FF", m_tray_name, 16, 16));
} else { } else {
auto &filaments = m_collection->get_presets(); auto &filaments = m_collection->get_presets();
auto iter = std::find_if(filaments.begin(), filaments.end(), [this](auto &f) { return f.is_compatible && f.is_system && f.filament_id == m_filament_id; }); auto iter = std::find_if(filaments.begin(), filaments.end(), [this](auto &f) {
if (iter == filaments.end() && !m_filament_type.empty()) { bool is_compatible = m_preset_bundle->calibrate_filaments.find(&f) != m_preset_bundle->calibrate_filaments.end();
auto filament_type = "Generic " + m_filament_type; return is_compatible && f.is_system && f.filament_id == m_filament_id;
iter = std::find_if(filaments.begin(), filaments.end(), });
[&filament_type](auto &f) { return f.is_compatible && f.is_system && boost::algorithm::starts_with(f.name, filament_type); }); //if (iter == filaments.end() && !m_filament_type.empty()) {
} // auto filament_type = "Generic " + m_filament_type;
// iter = std::find_if(filaments.begin(), filaments.end(),
// [this , &filament_type](auto &f) {
// bool is_compatible = m_preset_bundle->calibrate_filaments.find(&f) != m_preset_bundle->calibrate_filaments.end();
// return is_compatible && f.is_system && boost::algorithm::starts_with(f.name, filament_type); });
//}
if (iter != filaments.end()) { if (iter != filaments.end()) {
m_selected_preset = &*iter; m_selected_preset = &*iter;
m_is_compatible = true;
SetValue(get_preset_name(*iter)); SetValue(get_preset_name(*iter));
} }
else else {
m_selected_preset = nullptr;
m_is_compatible = false;
SetValue(_L("Incompatible")); SetValue(_L("Incompatible"));
}
Enable(); Enable();
} }
} }
@ -1444,8 +1456,7 @@ void GUI::CalibrateFilamentComboBox::update()
std::map<wxString, wxBitmap*> system_presets; std::map<wxString, wxBitmap*> system_presets;
wxString selected_preset = m_selected_preset ? get_preset_name(*m_selected_preset) : GetValue(); wxString selected_preset = m_selected_preset ? get_preset_name(*m_selected_preset) : GetValue();
if (!m_selected_preset)
m_selected_preset = m_collection->find_preset(selected_preset.ToStdString());
wxString tooltip; wxString tooltip;
const std::deque<Preset>& presets = m_collection->get_presets(); const std::deque<Preset>& presets = m_collection->get_presets();
@ -1498,16 +1509,13 @@ void GUI::CalibrateFilamentComboBox::update()
update_selection(); update_selection();
Thaw(); Thaw();
if (!tooltip.IsEmpty()) { SetToolTip(NULL);
#ifdef __WXMSW__
SetToolTip(NULL);
#endif
SetToolTip(tooltip);
}
} }
void GUI::CalibrateFilamentComboBox::OnSelect(wxCommandEvent &evt) void GUI::CalibrateFilamentComboBox::OnSelect(wxCommandEvent &evt)
{ {
m_is_compatible = true;
static_cast<FilamentComboBox*>(m_parent)->Enable(true);
std::string preset_name = m_collection->get_preset_name_by_alias(evt.GetString().ToUTF8().data()); std::string preset_name = m_collection->get_preset_name_by_alias(evt.GetString().ToUTF8().data());
m_selected_preset = m_collection->find_preset(preset_name); m_selected_preset = m_collection->find_preset(preset_name);
SimpleEvent e(EVT_CALIBRATION_TRAY_SELECTION_CHANGED); SimpleEvent e(EVT_CALIBRATION_TRAY_SELECTION_CHANGED);

View File

@ -230,14 +230,18 @@ public:
void OnSelect(wxCommandEvent &evt) override; void OnSelect(wxCommandEvent &evt) override;
const Preset* get_selected_preset() { return m_selected_preset; } const Preset* get_selected_preset() { return m_selected_preset; }
std::string get_tray_name() { return m_tray_name; } std::string get_tray_name() { return m_tray_name; }
std::string get_tag_uid() { return m_tag_uid; }
bool is_tray_exist() { return m_filament_exist; } bool is_tray_exist() { return m_filament_exist; }
bool is_compatible_with_printer() { return m_is_compatible; }
private: private:
std::string m_tray_name; std::string m_tray_name;
std::string m_filament_id; std::string m_filament_id;
std::string m_tag_uid;
std::string m_filament_type; std::string m_filament_type;
std::string m_filament_color; std::string m_filament_color;
bool m_filament_exist{false}; bool m_filament_exist{false};
bool m_is_compatible{true};
const Preset* m_selected_preset = nullptr; const Preset* m_selected_preset = nullptr;
}; };

View File

@ -151,12 +151,16 @@ void TabButtonsListCtrl::RemovePage(size_t n)
m_sizer->Layout(); m_sizer->Layout();
} }
bool TabButtonsListCtrl::SetPageImage(size_t n, const std::string &bmp_name) const bool TabButtonsListCtrl::SetPageImage(size_t n, const std::string &bmp_name)
{ {
if (n >= m_pageButtons.size()) if (n >= m_pageButtons.size())
return false; return false;
ScalableBitmap bitmap(NULL, bmp_name); ScalableBitmap bitmap;
if (!bmp_name.empty())
bitmap = ScalableBitmap(this, bmp_name, 14);
m_pageButtons[n]->SetBitmap(bitmap);
return true; return true;
} }

View File

@ -26,7 +26,7 @@ public:
void Rescale(); void Rescale();
bool InsertPage(size_t n, const wxString& text, bool bSelect = false, const std::string& bmp_name = ""); bool InsertPage(size_t n, const wxString& text, bool bSelect = false, const std::string& bmp_name = "");
void RemovePage(size_t n); void RemovePage(size_t n);
bool SetPageImage(size_t n, const std::string& bmp_name) const; bool SetPageImage(size_t n, const std::string& bmp_name);
void SetPageText(size_t n, const wxString& strText); void SetPageText(size_t n, const wxString& strText);
wxString GetPageText(size_t n) const; wxString GetPageText(size_t n) const;

View File

@ -2,7 +2,6 @@
#include "../GUI/GUI_App.hpp" #include "../GUI/GUI_App.hpp"
#include "../GUI/DeviceManager.hpp" #include "../GUI/DeviceManager.hpp"
#include "../GUI/Jobs/PrintJob.hpp"
#include "../GUI/Jobs/ProgressIndicator.hpp" #include "../GUI/Jobs/ProgressIndicator.hpp"
#include "../GUI/PartPlate.hpp" #include "../GUI/PartPlate.hpp"
@ -14,7 +13,7 @@
namespace Slic3r { namespace Slic3r {
namespace GUI { namespace GUI {
std::shared_ptr<PrintJob> print_job; std::shared_ptr<PrintJob> CalibUtils::print_job;
static const std::string temp_dir = fs::path(fs::temp_directory_path() / "calib").string(); static const std::string temp_dir = fs::path(fs::temp_directory_path() / "calib").string();
static const std::string temp_gcode_path = temp_dir + "/temp.gcode"; static const std::string temp_gcode_path = temp_dir + "/temp.gcode";
static const std::string path = temp_dir + "/test.3mf"; static const std::string path = temp_dir + "/test.3mf";
@ -302,7 +301,7 @@ void CalibUtils::calib_flowrate(int pass, const CalibInfo& calib_info, std::stri
params.mode = CalibMode::Calib_Flow_Rate; params.mode = CalibMode::Calib_Flow_Rate;
process_and_store_3mf(&model, full_config, params, error_message); process_and_store_3mf(&model, full_config, params, error_message);
if (!error_message.empty()) if (!error_message.empty())
return return;
send_to_print(calib_info.dev_id, calib_info.select_ams, calib_info.process_bar, calib_info.bed_type, error_message); send_to_print(calib_info.dev_id, calib_info.select_ams, calib_info.process_bar, calib_info.bed_type, error_message);
} }
@ -360,6 +359,7 @@ void CalibUtils::calib_temptue(const CalibInfo& calib_info, std::string& error_m
model.objects[0]->config.set_key_value("brim_type", new ConfigOptionEnum<BrimType>(btOuterOnly)); model.objects[0]->config.set_key_value("brim_type", new ConfigOptionEnum<BrimType>(btOuterOnly));
model.objects[0]->config.set_key_value("brim_width", new ConfigOptionFloat(5.0)); model.objects[0]->config.set_key_value("brim_width", new ConfigOptionFloat(5.0));
model.objects[0]->config.set_key_value("brim_object_gap", new ConfigOptionFloat(0.0)); model.objects[0]->config.set_key_value("brim_object_gap", new ConfigOptionFloat(0.0));
model.objects[0]->config.set_key_value("enable_support", new ConfigOptionBool(false));
// apply preset // apply preset
DynamicPrintConfig full_config; DynamicPrintConfig full_config;
@ -405,7 +405,7 @@ void CalibUtils::calib_max_vol_speed(const CalibInfo& calib_info, std::string& e
auto max_lh = printer_config.option<ConfigOptionFloats>("max_layer_height"); auto max_lh = printer_config.option<ConfigOptionFloats>("max_layer_height");
if (max_lh->values[0] < layer_height) max_lh->values[0] = {layer_height}; if (max_lh->values[0] < layer_height) max_lh->values[0] = {layer_height};
filament_config.set_key_value("filament_max_volumetric_speed", new ConfigOptionFloats{200}); filament_config.set_key_value("filament_max_volumetric_speed", new ConfigOptionFloats{50});
filament_config.set_key_value("slow_down_layer_time", new ConfigOptionInts{0}); filament_config.set_key_value("slow_down_layer_time", new ConfigOptionInts{0});
print_config.set_key_value("enable_overhang_speed", new ConfigOptionBool{false}); print_config.set_key_value("enable_overhang_speed", new ConfigOptionBool{false});
@ -555,12 +555,12 @@ void CalibUtils::process_and_store_3mf(Model* model, const DynamicPrintConfig& f
Print *fff_print = dynamic_cast<Print *>(print); Print *fff_print = dynamic_cast<Print *>(print);
fff_print->set_calib_params(params); fff_print->set_calib_params(params);
StringObjectException warning; //StringObjectException warning;
auto err = print->validate(&warning); //auto err = print->validate(&warning);
if (!err.string.empty()) { //if (!err.string.empty()) {
error_message = "slice validate: " + err.string; // error_message = "slice validate: " + err.string;
return; // return;
} //}
fff_print->process(); fff_print->process();
part_plate->update_slice_result_valid_state(true); part_plate->update_slice_result_valid_state(true);
@ -662,16 +662,17 @@ void CalibUtils::send_to_print(const std::string& dev_id, const std::string& sel
print_job->job_data = job_data; print_job->job_data = job_data;
print_job->plate_data = plate_data; print_job->plate_data = plate_data;
print_job->m_print_type = "from_normal";
if (!obj_->is_support_ams_mapping()) { //if (!obj_->is_support_ams_mapping()) {
error_message = "It is not support ams mapping."; // error_message = "It is not support ams mapping.";
return; // return;
} //}
if (!obj_->has_ams()) { //if (!obj_->has_ams()) {
error_message = "There is no ams."; // error_message = "There is no ams.";
return; // return;
} //}
print_job->task_ams_mapping = select_ams; print_job->task_ams_mapping = select_ams;
print_job->task_ams_mapping_info = ""; print_job->task_ams_mapping_info = "";

View File

@ -1,6 +1,7 @@
#pragma once #pragma once
#include "libslic3r/Calib.hpp" #include "libslic3r/Calib.hpp"
#include "../GUI/DeviceManager.hpp" #include "../GUI/DeviceManager.hpp"
#include "../GUI/Jobs/PrintJob.hpp"
namespace Slic3r { namespace Slic3r {
@ -26,6 +27,7 @@ class CalibUtils
{ {
public: public:
CalibUtils(){}; CalibUtils(){};
static std::shared_ptr<PrintJob> print_job;
static void calib_PA(const X1CCalibInfos& calib_infos, std::string& error_message); static void calib_PA(const X1CCalibInfos& calib_infos, std::string& error_message);
static void emit_get_PA_calib_results(); static void emit_get_PA_calib_results();
static bool get_PA_calib_results(std::vector<PACalibResult> &pa_calib_results); static bool get_PA_calib_results(std::vector<PACalibResult> &pa_calib_results);