NEW: support restore calibration status of printer

1.store each printer's calibration status to appconfig.
2.add retraction calibration
3.add choose fine calibration directly at flowrate calibration
4.add start pages for every calibration
5.add history window for pa calibration

Change-Id: I117fd46e689e0573e70e8579f5a52ba62d99f3d6
This commit is contained in:
liz.li 2023-06-16 10:04:51 +08:00 committed by Lane.Wei
parent cacd42f4e0
commit e2934516ed
14 changed files with 1134 additions and 504 deletions

View file

@ -508,6 +508,15 @@ std::string AppConfig::load()
m_storage[it.key()][iter.key()] = iter.value().get<std::string>();
}
}
} else if (it.key() == "calis") {
for (auto &j : it.value()) {
PrinterCaliInfo cali_info;
cali_info.dev_id = j["dev_id"].get<std::string>();
cali_info.mode = CalibMode(j["cali_mode"].get<int>());
cali_info.state = CalibState(j["cali_state"].get<int>());
cali_info.filament_preset = j["preset"].get<std::string>();
m_printer_cali_infos.emplace_back(cali_info);
}
} else {
if (it.value().is_object()) {
for (auto iter = it.value().begin(); iter != it.value().end(); iter++) {
@ -613,6 +622,15 @@ void AppConfig::save()
j["app"]["filament_colors"].push_back(filament_color);
}
for (const auto &cali_info : m_printer_cali_infos) {
json json;
json["dev_id"] = cali_info.dev_id;
json["cali_mode"] = int(cali_info.mode);
json["cali_state"] = int(cali_info.state);
json["preset"] = cali_info.filament_preset;
j["calis"].push_back(json);
}
// Write the other categories.
for (const auto& category : m_storage) {
if (category.first.empty())
@ -939,6 +957,22 @@ void AppConfig::set_vendors(const AppConfig &from)
m_dirty = true;
}
void AppConfig::save_printer_cali_infos(const PrinterCaliInfo &cali_info)
{
auto iter = std::find_if(m_printer_cali_infos.begin(), m_printer_cali_infos.end(), [&cali_info](const PrinterCaliInfo &cali_info_item) {
return cali_info_item.dev_id == cali_info.dev_id;
});
if (iter == m_printer_cali_infos.end()) {
m_printer_cali_infos.emplace_back(cali_info);
} else {
(*iter).filament_preset = cali_info.filament_preset;
(*iter).mode = cali_info.mode;
(*iter).state = cali_info.state;
}
m_dirty = true;
}
std::string AppConfig::get_last_dir() const
{
const auto it = m_storage.find("recent");

View file

@ -9,6 +9,7 @@
#include "libslic3r/Config.hpp"
#include "libslic3r/Semver.hpp"
#include "Calib.hpp"
using namespace nlohmann;
@ -178,6 +179,9 @@ public:
m_dirty = true;
}
const std::vector<PrinterCaliInfo> &get_printer_cali_infos() const { return m_printer_cali_infos; }
void save_printer_cali_infos(const PrinterCaliInfo& cali_info);
// return recent/last_opened_folder or recent/settings_folder or empty string.
std::string get_last_dir() const;
void update_config_dir(const std::string &dir);
@ -276,6 +280,8 @@ private:
std::vector<std::string> m_filament_presets;
std::vector<std::string> m_filament_colors;
std::vector<PrinterCaliInfo> m_printer_cali_infos;
};
} // namespace Slic3r

View file

@ -15,7 +15,23 @@ enum class CalibMode : int {
Calib_Vol_speed_Tower,
Calib_VFA_Tower,
Calib_Retraction_tower
};
enum class CalibState {
Start = 0,
Preset,
Calibration,
CoarseSave,
FineCalibration,
Save,
};
struct PrinterCaliInfo
{
std::string dev_id;
CalibMode mode;
CalibState state;
std::string filament_preset;
};
struct Calib_Params

View file

@ -162,7 +162,6 @@ void MObjectPanel::on_mouse_left_up(wxMouseEvent& evt)
wxCommandEvent event(EVT_DISSMISS_MACHINE_LIST);
event.SetEventObject(this->GetParent()->GetParent());
wxPostEvent(this, event);
}
}
@ -464,7 +463,10 @@ void CalibrationPanel::init_tabpanel() {
m_temp_panel = new TemperatureWizard(m_tabpanel);
m_tabpanel->AddPage(m_temp_panel, _L("Temperature"), "", false);
for (int i = 0; i < 4; i++)
m_retraction_panel = new RetractionWizard(m_tabpanel);
m_tabpanel->AddPage(m_retraction_panel, _L("Retraction"), "", false);
for (int i = 0; i < 5; i++)
m_tabpanel->SetPageImage(i, "");
m_tabpanel->Bind(wxEVT_BOOKCTRL_PAGE_CHANGED, [this](wxBookCtrlEvent&) {
@ -487,22 +489,31 @@ void CalibrationPanel::on_timer(wxTimerEvent& event) {
}
void CalibrationPanel::update_all() {
if (m_pa_panel && m_pa_panel->IsShown()) {
m_pa_panel->update_printer_selections();
if (m_pa_panel) {
m_pa_panel->update_printer();
if (m_pa_panel->IsShown())
m_pa_panel->update_print_progress();
}
if (m_flow_panel && m_flow_panel->IsShown()) {
m_flow_panel->update_printer_selections();
if (m_flow_panel) {
m_flow_panel->update_printer();
if (m_flow_panel->IsShown())
m_flow_panel->update_print_progress();
}
if (m_volumetric_panel && m_volumetric_panel->IsShown()) {
m_volumetric_panel->update_printer_selections();
if (m_volumetric_panel) {
m_volumetric_panel->update_printer();
if (m_volumetric_panel->IsShown())
m_volumetric_panel->update_print_progress();
}
if (m_temp_panel && m_temp_panel->IsShown()) {
m_temp_panel->update_printer_selections();
if (m_temp_panel) {
m_temp_panel->update_printer();
if (m_temp_panel->IsShown())
m_temp_panel->update_print_progress();
}
if (m_retraction_panel) {
m_retraction_panel->update_printer();
if (m_retraction_panel->IsShown())
m_retraction_panel->update_print_progress();
}
NetworkAgent* m_agent = wxGetApp().getAgent();
Slic3r::DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
@ -510,7 +521,10 @@ void CalibrationPanel::update_all() {
return;
MachineObject* obj = dev->get_selected_machine();
if (!obj) return;
if (!obj) {
m_side_tools->set_none_printer_mode();
return;
}
/* Update Device Info */
m_side_tools->set_current_printer_name(obj->dev_name);

View file

@ -115,8 +115,8 @@ private:
CalibrationWizard* m_pa_panel{ nullptr };
CalibrationWizard* m_flow_panel{ nullptr };
CalibrationWizard* m_volumetric_panel{ nullptr };
TemperatureWizard* m_temp_panel{ nullptr };
CalibrationWizard* m_vfa_panel{ nullptr };
CalibrationWizard* m_temp_panel{ nullptr };
CalibrationWizard* m_retraction_panel{ nullptr };
wxTimer* m_refresh_timer = nullptr;
};

File diff suppressed because it is too large Load diff

View file

@ -60,23 +60,29 @@ typedef std::vector<FilamentComboBox*> FilamentComboBoxList;
class CalibrationWizard : public wxPanel {
public:
CalibrationWizard(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL);
CalibrationWizard(wxWindow* parent, CalibMode mode, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL);
~CalibrationWizard() {};
CalibrationWizardPage* get_curr_page() { return m_curr_page; }
CalibrationWizardPage* get_frist_page() { return m_first_page; }
void show_page(CalibrationWizardPage* page);
void show_send_progress_bar(bool show);
void update_printer_selections();
void update_printer();
void update_print_progress();
void update_filaments_from_preset();
CalibMode get_calibration_mode() { return m_mode; }
protected:
virtual CalibrationWizardPage* create_start_page() { return nullptr; }
virtual CalibrationWizardPage* create_presets_page(bool need_custom_range);
virtual CalibrationWizardPage* create_print_page();
virtual CalibrationWizardPage* create_save_page();
virtual void create_save_panel_content(wxBoxSizer* sizer) {}
virtual void create_pages() = 0;
virtual bool start_calibration(std::vector<int> tray_ids) = 0;
virtual bool save_calibration_result() = 0;
virtual bool recommend_input_value();
virtual void set_save_name() {};
virtual void request_calib_result() {};
virtual void jump_to_page(PageType page_type);
virtual void change_ams_select_mode() {};
virtual void init_bitmaps();
@ -92,8 +98,10 @@ private:
ScalableBitmap m_bitmap_abort_disable;
protected:
std::map<std::string, PrinterCaliInfo> m_printer_calib_infos;
CalibMode m_mode;
MachineObject* curr_obj{ nullptr };
std::vector<MachineObject*> obj_list{ nullptr };
wxScrolledWindow* m_scrolledWindow;
wxBoxSizer* m_all_pages_sizer;
@ -116,7 +124,6 @@ protected:
FilamentComboBoxList m_filament_comboBox_list;
wxPanel* m_virtual_panel;
FilamentComboBox* m_virtual_tray_comboBox;
ComboBox* m_comboBox_printer;
ComboBox* m_comboBox_nozzle_dia;
ComboBox* m_comboBox_bed_type;
ComboBox* m_comboBox_process;
@ -139,6 +146,7 @@ protected:
// print panel
wxPanel* m_print_panel;
wxStaticBitmap* m_print_picture;
wxStaticText* m_staticText_profile_value;
wxStaticText* m_printing_stage_value;
wxStaticText* m_staticText_progress_percent;
@ -148,13 +156,14 @@ protected:
ScalableButton* m_button_abort;
ProgressBar* m_print_gauge_progress; // for print
PageButton* m_btn_next;
PageButton* m_btn_recali;
// save panel
wxPanel* m_save_panel;
void create_presets_panel(CalibrationWizardPage* page, wxBoxSizer* sizer, bool need_custom_range = true);
void create_send_progress_bar(CalibrationWizardPage* page, wxBoxSizer* sizer);
void init_printer_calib_info_from_appconfig();
void save_to_printer_calib_info(PageType page_type);
// preset
void init_presets_selections();
void init_nozzle_selections();
void init_bed_type_selections();
@ -165,15 +174,13 @@ protected:
std::vector<int> get_selected_tray();
FilamentComboBoxList get_selected_filament_comboBox();
void create_print_panel(CalibrationWizardPage* page, wxBoxSizer* sizer);
// print
void reset_printing_values();
void create_save_panel(CalibrationWizardPage* page, wxBoxSizer* sizer);
virtual void create_save_panel_content(wxBoxSizer* sizer) {}
// save
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_nozzle(wxCommandEvent& evt);
void on_select_tray(SimpleEvent& evt);
void on_select_bed_type(wxCommandEvent& evt);
@ -187,11 +194,22 @@ protected:
void on_switch_ams(std::string ams_id);
};
class HistoryWindow : public DPIDialog {
public:
HistoryWindow(wxWindow* parent);
~HistoryWindow() {};
void on_dpi_changed(const wxRect& suggested_rect) {}
void create();
wxPanel* m_history_data_panel;
};
class PressureAdvanceWizard : public CalibrationWizard{
public:
PressureAdvanceWizard(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL);
~PressureAdvanceWizard() {};
protected:
virtual CalibrationWizardPage* create_start_page() override;
void create_history_window();
virtual void create_pages() override;
virtual void create_save_panel_content(wxBoxSizer* sizer) override;
@ -202,21 +220,22 @@ protected:
virtual void change_ams_select_mode() override;
virtual void init_bitmaps() override;
void sync_history_window_data();
void sync_save_page_data();
void switch_pages(SimpleEvent& evt);
private:
// history page
//CalibrationWizardPage* m_history_page{ nullptr };
HistoryWindow* m_history_page{ nullptr };
// start page
CalibrationWizardPage* m_page0{ nullptr };
std::string m_wiki_url;
// preset page
CalibrationWizardPage* m_page1{ nullptr };
// print page
CalibrationWizardPage* m_page2{ nullptr };
wxStaticBitmap* m_print_picture;
// save page
CalibrationWizardPage* m_page3{ nullptr };
@ -236,6 +255,7 @@ public:
FlowRateWizard(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL);
~FlowRateWizard() {};
protected:
virtual CalibrationWizardPage* create_start_page() override;
void create_low_end_pages();
void create_high_end_pages();
virtual void create_pages() override;
@ -251,12 +271,18 @@ protected:
void sync_save_page_data();
void switch_pages(SimpleEvent& evt);
private:
// start page
CalibrationWizardPage* m_page0{ nullptr };
std::string m_wiki_url;
// preset page
CalibrationWizardPage* m_page1{ nullptr };
wxPanel* m_choose_step_panel;
wxRadioButton* m_complete_radioBox;
wxRadioButton* m_fine_radioBox;
// print page
CalibrationWizardPage* m_page2{ nullptr };
wxStaticBitmap* m_print_picture;
// page 3
CalibrationWizardPage* m_low_end_page3{ nullptr };
@ -295,6 +321,7 @@ public:
MaxVolumetricSpeedWizard(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL);
~MaxVolumetricSpeedWizard() {};
protected:
virtual CalibrationWizardPage* create_start_page() 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;
@ -303,12 +330,15 @@ protected:
virtual void set_save_name() override;
virtual void init_bitmaps() override;
private:
// start page
CalibrationWizardPage* m_page0;
std::string m_wiki_url;
// preset page
CalibrationWizardPage* m_page1;
// print page
CalibrationWizardPage* m_page2;
wxStaticBitmap* m_print_picture;
// save page
CalibrationWizardPage* m_page3;
@ -325,6 +355,7 @@ public:
TemperatureWizard(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL);
~TemperatureWizard() {};
protected:
virtual CalibrationWizardPage* create_start_page() 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;
@ -333,12 +364,15 @@ protected:
virtual void set_save_name() override;
virtual void init_bitmaps() override;
private:
// start page
CalibrationWizardPage* m_page0;
std::string m_wiki_url;
// preset page
CalibrationWizardPage* m_page1;
// print page
CalibrationWizardPage* m_page2;
wxStaticBitmap* m_print_picture;
// save page
CalibrationWizardPage* m_page3;
@ -348,7 +382,37 @@ private:
std::string m_save_name;
};
class VFAWizard : public CalibrationWizard {};
class RetractionWizard : public CalibrationWizard {
public:
RetractionWizard(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL);
~RetractionWizard() {};
protected:
virtual CalibrationWizardPage* create_start_page() 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 save_calibration_result() override;
virtual bool recommend_input_value() override;
virtual void set_save_name() override;
virtual void init_bitmaps() override;
private:
// start page
CalibrationWizardPage* m_page0;
std::string m_wiki_url;
// preset page
CalibrationWizardPage* m_page1;
// print page
CalibrationWizardPage* m_page2;
// save page
CalibrationWizardPage* m_page3;
wxStaticBitmap* m_record_picture;
TextInput* m_optimal_retraction;
TextInput* m_save_name_input;
std::string m_save_name;
};
}} // namespace Slic3r::GUI

View file

@ -77,11 +77,6 @@ CalibrationWizardPage::CalibrationWizardPage(wxWindow* parent, wxWindowID id, co
title_sizer->AddStretchSpacer();
m_index = new wxStaticText(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, 0);
m_index->Wrap(-1);
m_index->SetFont(Label::Head_16);
title_sizer->Add(m_index, 0, wxALL, 0);
page_sizer->Add(title_sizer, 0, wxEXPAND, 0);
page_sizer->AddSpacer(FromDIP(20));
@ -133,15 +128,20 @@ CalibrationWizardPage::CalibrationWizardPage(wxWindow* parent, wxWindowID id, co
m_btn_next->Bind(wxEVT_BUTTON, &CalibrationWizardPage::on_click_next, this);
}
void CalibrationWizardPage::set_highlight_step_text(wxString text) {
void CalibrationWizardPage::set_highlight_step_text(PageType page_type) {
if (page_type == PageType::Start) {
m_top_sizer->Clear(true);
Layout();
return;
}
m_preset_text->SetForegroundColour(wxColour(181, 181, 181));
m_calibration_text->SetForegroundColour(wxColour(181, 181, 181));
m_record_text->SetForegroundColour(wxColour(181, 181, 181));
if(text == "Preset")
if(page_type == PageType::Preset)
m_preset_text->SetForegroundColour(*wxBLACK);
if (text == "Calibration")
if (page_type == PageType::Calibration || page_type == PageType::CoarseSave || page_type == PageType::FineCalibration)
m_calibration_text->SetForegroundColour(*wxBLACK);
if (text == "Record")
if (page_type == PageType::Save)
m_record_text->SetForegroundColour(*wxBLACK);
}

View file

@ -31,6 +31,16 @@ private:
ButtonType m_type;
};
enum class PageType {
Start,
Preset,
Calibration,
CoarseSave,
FineCalibration,
Save,
Finish,
};
class CalibrationWizardPage : public wxPanel
{
public:
@ -53,14 +63,14 @@ public:
wxBoxSizer* get_btn_hsizer() { return m_btn_sizer; }
PageButton* get_prev_btn() { return m_btn_prev; }
PageButton* get_next_btn() { return m_btn_next; }
PageType get_page_type() { return m_page_type; }
void set_page_type(PageType type) { m_page_type = type; }
void set_page_title(wxString title) { m_title->SetLabel(title); }
void set_page_index(wxString index) { m_index->SetLabel(index); }
void set_highlight_step_text(wxString text);
void set_highlight_step_text(PageType page_type);
private:
wxStaticText* m_title;
wxStaticText* m_index;
wxBoxSizer* m_top_sizer;
wxStaticText* m_preset_text;
wxStaticText* m_calibration_text;
@ -69,6 +79,7 @@ private:
wxBoxSizer* m_btn_sizer;
PageButton* m_btn_prev;
PageButton* m_btn_next;
PageType m_page_type;
CalibrationWizardPage* m_prev_page{nullptr};
CalibrationWizardPage* m_next_page{nullptr};

View file

@ -584,7 +584,7 @@ void IMSlider::draw_colored_band(const ImRect& groove, const ImRect& slideable_r
}
};
auto draw_main_band = [&main_band, this](const ImU32& clr) {
if (clr == m_is_dark ? BACKGROUND_COLOR_DARK : BACKGROUND_COLOR_LIGHT) {
if (clr == (m_is_dark ? BACKGROUND_COLOR_DARK : BACKGROUND_COLOR_LIGHT)) {
ImRect rc = main_band;
rc.Min += ImVec2(1, 1) * m_scale;
rc.Max -= ImVec2(1, 1) * m_scale;

View file

@ -258,7 +258,7 @@ bool MeshRaycaster::unproject_on_mesh(const Vec2d& mouse_pos, const Transform3d&
// Also, remove anything below the bed (sinking objects).
for (i=0; i<hits.size(); ++i) {
Vec3d transformed_hit = trafo * hits[i].position();
if (transformed_hit.z() >= sinking_limit ? SINKING_Z_THRESHOLD : -std::numeric_limits<double>::max() &&
if (transformed_hit.z() >= (sinking_limit ? SINKING_Z_THRESHOLD : -std::numeric_limits<double>::max()) &&
(!clipping_plane || !clipping_plane->is_point_clipped(transformed_hit)))
break;
}

View file

@ -1385,7 +1385,7 @@ GUI::CalibrateFilamentComboBox::CalibrateFilamentComboBox(wxWindow *parent)
: PlaterPresetComboBox(parent, Preset::TYPE_FILAMENT)
{
clr_picker->SetBackgroundColour(*wxWHITE);
clr_picker->SetBitmap(*get_extruder_color_icon("#FFFFFFFF", "", 16, 16));
clr_picker->SetBitmap(*get_extruder_color_icon("#FFFFFFFF", "", 20, 20));
clr_picker->SetToolTip("");
clr_picker->Bind(wxEVT_BUTTON, [this](wxCommandEvent& e) {});
}
@ -1403,7 +1403,7 @@ void GUI::CalibrateFilamentComboBox::load_tray(DynamicPrintConfig &config)
m_filament_color = config.opt_string("filament_colour", 0u);
m_filament_exist = config.opt_bool("filament_exist", 0u);
wxColor clr(m_filament_color);
clr_picker->SetBitmap(*get_extruder_color_icon(m_filament_color, m_tray_name, 16, 16));
clr_picker->SetBitmap(*get_extruder_color_icon(m_filament_color, m_tray_name, 20, 20));
#ifdef __WXOSX__
clr_picker->SetLabel(clr_picker->GetLabel()); // Let setBezelStyle: be called
clr_picker->Refresh();
@ -1412,7 +1412,7 @@ void GUI::CalibrateFilamentComboBox::load_tray(DynamicPrintConfig &config)
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, 20, 20));
} else {
auto &filaments = m_collection->get_presets();
auto iter = std::find_if(filaments.begin(), filaments.end(), [this](auto &f) {

View file

@ -24,6 +24,14 @@ static std::string MachineBedTypeString[5] = {
"pte"
};
static std::map<CalibMode, std::string> calib_mode_to_name = {
{CalibMode::Calib_Flow_Rate, "flow_rate_calib_mode"},
{CalibMode::Calib_Temp_Tower, "temp_tower_calib_mode"},
{CalibMode::Calib_Vol_speed_Tower, "vol_speed_tower_calib_mode"},
{CalibMode::Calib_VFA_Tower, "vfa_tower_calib_mode"},
{CalibMode::Calib_Retraction_tower, "retration_tower_calib_mode"}
};
static void cut_model(Model &model, std::array<Vec3d, 4> plane_points, ModelObjectCutAttributes attributes)
{
size_t obj_idx = 0;
@ -74,6 +82,16 @@ std::array<Vec3d, 4> get_cut_plane_points(const BoundingBoxf3 &bbox, const doubl
return plane_pts;
}
CalibMode CalibUtils::get_calib_mode_by_name(const std::string &name)
{
for (auto iter = calib_mode_to_name.begin(); iter != calib_mode_to_name.end(); ++iter) {
if (iter->second == name) {
return iter->first;
}
}
return CalibMode::Calib_None;
}
void CalibUtils::calib_PA(const X1CCalibInfos& calib_infos, std::string& error_message)
{
DeviceManager *dev = Slic3r::GUI::wxGetApp().getDeviceManager();
@ -311,7 +329,7 @@ void CalibUtils::calib_flowrate(int pass, const CalibInfo& calib_info, std::stri
if (!error_message.empty())
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, error_message);
}
void CalibUtils::calib_generic_PA(const CalibInfo &calib_info, std::string &error_message)
@ -338,7 +356,7 @@ void CalibUtils::calib_generic_PA(const CalibInfo &calib_info, std::string &erro
if (!error_message.empty())
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, error_message);
}
void CalibUtils::calib_temptue(const CalibInfo& calib_info, std::string& error_message)
@ -407,7 +425,7 @@ void CalibUtils::calib_temptue(const CalibInfo& calib_info, std::string& error_m
if (!error_message.empty())
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, error_message);
}
void CalibUtils::calib_max_vol_speed(const CalibInfo& calib_info, std::string& error_message)
@ -485,7 +503,7 @@ void CalibUtils::calib_max_vol_speed(const CalibInfo& calib_info, std::string& e
if (!error_message.empty())
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, error_message);
}
void CalibUtils::calib_VFA(const CalibInfo& calib_info, std::string& error_message)
@ -541,7 +559,7 @@ void CalibUtils::calib_VFA(const CalibInfo& calib_info, std::string& error_messa
if (!error_message.empty())
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, error_message);
}
void CalibUtils::calib_retraction(const CalibInfo &calib_info, std::string &error_message)
@ -590,7 +608,7 @@ void CalibUtils::calib_retraction(const CalibInfo &calib_info, std::string &erro
if (!error_message.empty())
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, error_message);
}
void CalibUtils::process_and_store_3mf(Model* model, const DynamicPrintConfig& full_config, const Calib_Params& params, std::string& error_message)
@ -676,8 +694,13 @@ void CalibUtils::process_and_store_3mf(Model* model, const DynamicPrintConfig& f
success = Slic3r::store_bbs_3mf(store_params);
}
void CalibUtils::send_to_print(const std::string& dev_id, const std::string& select_ams, std::shared_ptr<ProgressIndicator> process_bar, BedType bed_type, std::string& error_message)
void CalibUtils::send_to_print(const CalibInfo& calib_info, std::string &error_message)
{
std::string dev_id = calib_info.dev_id;
std::string select_ams = calib_info.select_ams;
std::shared_ptr<ProgressIndicator> process_bar = calib_info.process_bar;
BedType bed_type = calib_info.bed_type;
DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev) {
error_message = "Need select printer";
@ -748,19 +771,10 @@ void CalibUtils::send_to_print(const std::string& dev_id, const std::string& sel
print_job->plate_data = plate_data;
print_job->m_print_type = "from_normal";
//if (!obj_->is_support_ams_mapping()) {
// error_message = "It is not support ams mapping.";
// return;
//}
//if (!obj_->has_ams()) {
// error_message = "There is no ams.";
// return;
//}
print_job->task_ams_mapping = select_ams;
print_job->task_ams_mapping_info = "";
print_job->task_use_ams = select_ams == "[254]" ? false : true;
print_job->m_project_name = calib_mode_to_name[calib_info.params.mode];
print_job->has_sdcard = obj_->has_sdcard();
print_job->set_print_config(MachineBedTypeString[bed_type], true, false, false, false, true);

View file

@ -22,12 +22,14 @@ public:
std::shared_ptr<ProgressIndicator> process_bar;
};
class CalibUtils
{
public:
CalibUtils(){};
static std::shared_ptr<PrintJob> print_job;
static CalibMode get_calib_mode_by_name(const std::string &name);
static void calib_PA(const X1CCalibInfos& calib_infos, std::string& error_message);
static void emit_get_PA_calib_results();
static bool get_PA_calib_results(std::vector<PACalibResult> &pa_calib_results);
@ -50,7 +52,7 @@ public:
private:
static void process_and_store_3mf(Model* model, const DynamicPrintConfig& full_config, const Calib_Params& params, std::string& error_message);
static void send_to_print(const std::string& dev_id, const std::string& select_ams, std::shared_ptr<ProgressIndicator> process_bar, BedType bed_type, std::string& error_message);
static void send_to_print(const CalibInfo& calib_info, std::string &error_message);
};
}