FIX: fix sending gcode to octoprint

Change-Id: Id541b18d8e3522854d83f57dd4f3b02863a6aae7
Signed-off-by: Stone Li <stone.li@bambulab.com>
This commit is contained in:
Stone Li 2023-01-12 16:34:16 +08:00 committed by Lane.Wei
parent 32afff46fc
commit 67d4e2148f
6 changed files with 33 additions and 63 deletions

View file

@ -193,8 +193,6 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, BORDERLESS_FRAME_
panel_topbar->Layout(); panel_topbar->Layout();
#endif #endif
//wxAuiToolBar* toolbar = new wxAuiToolBar(); //wxAuiToolBar* toolbar = new wxAuiToolBar();
/* /*
#ifndef __WXOSX__ // Don't call SetFont under OSX to avoid name cutting in ObjectList #ifndef __WXOSX__ // Don't call SetFont under OSX to avoid name cutting in ObjectList
@ -1228,10 +1226,6 @@ bool MainFrame::can_send_gcode() const
{ {
if (m_plater && !m_plater->model().objects.empty()) if (m_plater && !m_plater->model().objects.empty())
{ {
// BBL printer presets
if (!wxGetApp().preset_bundle->printers.get_edited_preset().is_custom_defined())
return false;
auto cfg = wxGetApp().preset_bundle->printers.get_edited_preset().config; auto cfg = wxGetApp().preset_bundle->printers.get_edited_preset().config;
if (const auto *print_host_opt = cfg.option<ConfigOptionString>("print_host"); print_host_opt) if (const auto *print_host_opt = cfg.option<ConfigOptionString>("print_host"); print_host_opt)
return !print_host_opt->value.empty(); return !print_host_opt->value.empty();
@ -1416,7 +1410,7 @@ wxBoxSizer* MainFrame::create_side_tools()
m_print_option_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent& event) m_print_option_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent& event)
{ {
SidePopup* p = new SidePopup(this); SidePopup* p = new SidePopup(this);
if (wxGetApp().preset_bundle if (wxGetApp().preset_bundle
&& !wxGetApp().preset_bundle->printers.get_edited_preset().is_bbl_vendor_preset(wxGetApp().preset_bundle)) { && !wxGetApp().preset_bundle->printers.get_edited_preset().is_bbl_vendor_preset(wxGetApp().preset_bundle)) {
// ThirdParty Buttons // ThirdParty Buttons
@ -1444,7 +1438,7 @@ wxBoxSizer* MainFrame::create_side_tools()
}); });
// upload only // upload only
SideButton* upload_gcode_btn = new SideButton(p, _L("Send"), ""); /*SideButton* upload_gcode_btn = new SideButton(p, _L("Send"), "");
upload_gcode_btn->SetCornerRadius(0); upload_gcode_btn->SetCornerRadius(0);
upload_gcode_btn->Bind(wxEVT_BUTTON, [this, p](wxCommandEvent&) { upload_gcode_btn->Bind(wxEVT_BUTTON, [this, p](wxCommandEvent&) {
m_print_btn->SetLabel(_L("Send")); m_print_btn->SetLabel(_L("Send"));
@ -1453,10 +1447,10 @@ wxBoxSizer* MainFrame::create_side_tools()
m_print_btn->Enable(m_print_enable); m_print_btn->Enable(m_print_enable);
this->Layout(); this->Layout();
p->Dismiss(); p->Dismiss();
}); });*/
p->append_button(send_gcode_btn); p->append_button(send_gcode_btn);
p->append_button(upload_gcode_btn); //p->append_button(upload_gcode_btn);
p->append_button(export_gcode_btn); p->append_button(export_gcode_btn);
} }
else { else {
@ -1503,15 +1497,15 @@ wxBoxSizer* MainFrame::create_side_tools()
}); });
SideButton* send_to_printer_all_btn = new SideButton(p, _L("Send all"), ""); SideButton* send_to_printer_all_btn = new SideButton(p, _L("Send all"), "");
send_to_printer_all_btn->SetCornerRadius(0); send_to_printer_all_btn->SetCornerRadius(0);
send_to_printer_all_btn->Bind(wxEVT_BUTTON, [this, p](wxCommandEvent&) { send_to_printer_all_btn->Bind(wxEVT_BUTTON, [this, p](wxCommandEvent&) {
m_print_btn->SetLabel(_L("Send all")); m_print_btn->SetLabel(_L("Send all"));
m_print_select = eSendToPrinterAll; m_print_select = eSendToPrinterAll;
m_print_enable = get_enable_print_status(); m_print_enable = get_enable_print_status();
m_print_btn->Enable(m_print_enable); m_print_btn->Enable(m_print_enable);
this->Layout(); this->Layout();
p->Dismiss(); p->Dismiss();
}); });
export_sliced_file_btn->Bind(wxEVT_BUTTON, [this, p](wxCommandEvent&) { export_sliced_file_btn->Bind(wxEVT_BUTTON, [this, p](wxCommandEvent&) {
m_print_btn->SetLabel(_L("Export plate sliced file")); m_print_btn->SetLabel(_L("Export plate sliced file"));
@ -2918,7 +2912,7 @@ void MainFrame::set_print_button_to_default(PrintSelectType select_type)
m_print_btn->SetLabel(_L("Print")); m_print_btn->SetLabel(_L("Print"));
m_print_select = eSendGcode; m_print_select = eSendGcode;
if (m_print_enable) if (m_print_enable)
m_print_enable = get_enable_print_status(); m_print_enable = get_enable_print_status() && can_send_gcode();
m_print_btn->Enable(m_print_enable); m_print_btn->Enable(m_print_enable);
this->Layout(); this->Layout();
} else { } else {

View file

@ -292,13 +292,10 @@ void PhysicalPrinterDialog::build_printhost_settings(ConfigOptionsGroup* m_optgr
} }
#ifdef WIN32 #ifdef WIN32
/* //option = m_optgroup->get_option("printhost_ssl_ignore_revoke");
option = m_optgroup->get_option("printhost_ssl_ignore_revoke"); //option.opt.width = Field::def_width_wider();
option.opt.width = Field::def_width_wider(); //m_optgroup->append_single_option_line(option);
m_optgroup->append_single_option_line(option);
*/
#endif #endif
m_optgroup->activate(); m_optgroup->activate();
@ -447,6 +444,7 @@ void PhysicalPrinterDialog::update(bool printer_change)
m_optgroup->hide_field(opt_key); m_optgroup->hide_field(opt_key);
supports_multiple_printers = opt && opt->value == htRepetier; supports_multiple_printers = opt && opt->value == htRepetier;
} }
} }
else { else {
m_optgroup->set_value("host_type", int(PrintHostType::htOctoPrint), false); m_optgroup->set_value("host_type", int(PrintHostType::htOctoPrint), false);

View file

@ -1774,6 +1774,7 @@ struct Plater::priv
priv(Plater *q, MainFrame *main_frame); priv(Plater *q, MainFrame *main_frame);
~priv(); ~priv();
bool need_update() const { return m_need_update; } bool need_update() const { return m_need_update; }
void set_need_update(bool need_update) { m_need_update = need_update; } void set_need_update(bool need_update) { m_need_update = need_update; }
@ -2028,7 +2029,6 @@ struct Plater::priv
void on_action_print_all(SimpleEvent&); void on_action_print_all(SimpleEvent&);
void on_action_export_gcode(SimpleEvent&); void on_action_export_gcode(SimpleEvent&);
void on_action_send_gcode(SimpleEvent&); void on_action_send_gcode(SimpleEvent&);
void on_action_upload_gcode(SimpleEvent&);
void on_action_export_sliced_file(SimpleEvent&); void on_action_export_sliced_file(SimpleEvent&);
void on_action_export_all_sliced_file(SimpleEvent&); void on_action_export_all_sliced_file(SimpleEvent&);
void on_action_select_sliced_plate(wxCommandEvent& evt); void on_action_select_sliced_plate(wxCommandEvent& evt);
@ -2439,7 +2439,6 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
q->Bind(EVT_GLTOOLBAR_PRINT_ALL, &priv::on_action_print_all, this); q->Bind(EVT_GLTOOLBAR_PRINT_ALL, &priv::on_action_print_all, this);
q->Bind(EVT_GLTOOLBAR_EXPORT_GCODE, &priv::on_action_export_gcode, this); q->Bind(EVT_GLTOOLBAR_EXPORT_GCODE, &priv::on_action_export_gcode, this);
q->Bind(EVT_GLTOOLBAR_SEND_GCODE, &priv::on_action_send_gcode, this); q->Bind(EVT_GLTOOLBAR_SEND_GCODE, &priv::on_action_send_gcode, this);
q->Bind(EVT_GLTOOLBAR_UPLOAD_GCODE, &priv::on_action_upload_gcode, this);
q->Bind(EVT_GLTOOLBAR_EXPORT_SLICED_FILE, &priv::on_action_export_sliced_file, this); q->Bind(EVT_GLTOOLBAR_EXPORT_SLICED_FILE, &priv::on_action_export_sliced_file, this);
q->Bind(EVT_GLTOOLBAR_EXPORT_ALL_SLICED_FILE, &priv::on_action_export_all_sliced_file, this); q->Bind(EVT_GLTOOLBAR_EXPORT_ALL_SLICED_FILE, &priv::on_action_export_all_sliced_file, this);
q->Bind(EVT_GLTOOLBAR_SEND_TO_PRINTER, &priv::on_action_export_to_sdcard, this); q->Bind(EVT_GLTOOLBAR_SEND_TO_PRINTER, &priv::on_action_export_to_sdcard, this);
@ -6084,19 +6083,11 @@ void Plater::priv::on_action_export_gcode(SimpleEvent&)
} }
} }
void Plater::priv::on_action_upload_gcode(SimpleEvent&)
{
if (q != nullptr) {
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << ":received export gcode event\n";
q->send_gcode_legacy(-1, nullptr, true);
}
}
void Plater::priv::on_action_send_gcode(SimpleEvent&) void Plater::priv::on_action_send_gcode(SimpleEvent&)
{ {
if (q != nullptr) { if (q != nullptr) {
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << ":received export gcode event\n" ; BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << ":received export gcode event\n" ;
q->send_gcode_legacy(-1, nullptr, false); q->send_gcode_legacy();
} }
} }
@ -9765,7 +9756,7 @@ void Plater::reslice_SLA_until_step(SLAPrintObjectStep step, const ModelObject &
// and let the background processing start. // and let the background processing start.
this->p->restart_background_process(state | priv::UPDATE_BACKGROUND_PROCESS_FORCE_RESTART); this->p->restart_background_process(state | priv::UPDATE_BACKGROUND_PROCESS_FORCE_RESTART);
} }
void Plater::send_gcode_legacy(int plate_idx, Export3mfProgressFn proFn, bool upload_only) void Plater::send_gcode_legacy(int plate_idx, Export3mfProgressFn proFn)
{ {
// if physical_printer is selected, send gcode for this printer // if physical_printer is selected, send gcode for this printer
// DynamicPrintConfig* physical_printer_config = wxGetApp().preset_bundle->physical_printers.get_selected_printer_config(); // DynamicPrintConfig* physical_printer_config = wxGetApp().preset_bundle->physical_printers.get_selected_printer_config();
@ -9803,7 +9794,7 @@ void Plater::send_gcode_legacy(int plate_idx, Export3mfProgressFn proFn, bool up
upload_job.printhost->get_groups(groups); upload_job.printhost->get_groups(groups);
} }
PrintHostSendDialog dlg(default_output_file, upload_job.printhost->get_post_upload_actions(), groups, upload_only); PrintHostSendDialog dlg(default_output_file, upload_job.printhost->get_post_upload_actions(), groups);
if (dlg.ShowModal() == wxID_OK) { if (dlg.ShowModal() == wxID_OK) {
upload_job.upload_data.upload_path = dlg.filename(); upload_job.upload_data.upload_path = dlg.filename();
upload_job.upload_data.post_action = dlg.post_action(); upload_job.upload_data.post_action = dlg.post_action();
@ -10990,8 +10981,8 @@ int Plater::select_plate_by_hover_id(int hover_id, bool right_click)
PartPlate* curr_plate = p->partplate_list.get_curr_plate(); PartPlate* curr_plate = p->partplate_list.get_curr_plate();
dlg.sync_bed_type(curr_plate->get_bed_type(false)); dlg.sync_bed_type(curr_plate->get_bed_type(false));
dlg.Bind(EVT_SET_BED_TYPE_CONFIRM, [this, plate_index](wxCommandEvent& e) { dlg.Bind(EVT_SET_BED_TYPE_CONFIRM, [this, plate_index](wxCommandEvent& e) {
PartPlate *curr_plate = p->partplate_list.get_curr_plate(); PartPlate *curr_plate = p->partplate_list.get_curr_plate();
BedType old_bed_type = curr_plate->get_bed_type(false); BedType old_bed_type = curr_plate->get_bed_type(false);
auto type = (BedType)(e.GetInt()); auto type = (BedType)(e.GetInt());
if (old_bed_type != type) { if (old_bed_type != type) {
curr_plate->set_bed_type(type); curr_plate->set_bed_type(type);

View file

@ -348,7 +348,7 @@ public:
/* -1: send current gcode if not specified /* -1: send current gcode if not specified
* -2: send all gcode to target machine */ * -2: send all gcode to target machine */
int send_gcode(int plate_idx = -1, Export3mfProgressFn proFn = nullptr); int send_gcode(int plate_idx = -1, Export3mfProgressFn proFn = nullptr);
void send_gcode_legacy(int plate_idx = -1, Export3mfProgressFn proFn = nullptr, bool upload_only = false); void send_gcode_legacy(int plate_idx = -1, Export3mfProgressFn proFn = nullptr);
int export_config_3mf(int plate_idx = -1, Export3mfProgressFn proFn = nullptr); int export_config_3mf(int plate_idx = -1, Export3mfProgressFn proFn = nullptr);
//BBS jump to nonitor after print job finished //BBS jump to nonitor after print job finished
void print_job_finished(wxCommandEvent &evt); void print_job_finished(wxCommandEvent &evt);

View file

@ -36,8 +36,8 @@ namespace GUI {
static const char *CONFIG_KEY_PATH = "printhost_path"; static const char *CONFIG_KEY_PATH = "printhost_path";
static const char *CONFIG_KEY_GROUP = "printhost_group"; static const char *CONFIG_KEY_GROUP = "printhost_group";
PrintHostSendDialog::PrintHostSendDialog(const fs::path &path, PrintHostPostUploadActions post_actions, const wxArrayString &groups, bool upload_only) PrintHostSendDialog::PrintHostSendDialog(const fs::path &path, PrintHostPostUploadActions post_actions, const wxArrayString &groups)
: MsgDialog(static_cast<wxWindow*>(wxGetApp().mainframe), _L("Upload and Print"), _L("Upload to Printer Host with the following filename:"),0) : MsgDialog(static_cast<wxWindow*>(wxGetApp().mainframe), _L("Send to print"), _L("Upload to Printer Host with the following filename:"),0)
, txt_filename(new wxTextCtrl(this, wxID_ANY)) , txt_filename(new wxTextCtrl(this, wxID_ANY))
, combo_groups(!groups.IsEmpty() ? new wxComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, groups, wxCB_READONLY) : nullptr) , combo_groups(!groups.IsEmpty() ? new wxComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, groups, wxCB_READONLY) : nullptr)
, post_upload_action(PrintHostPostUploadAction::None) , post_upload_action(PrintHostPostUploadAction::None)
@ -88,19 +88,7 @@ PrintHostSendDialog::PrintHostSendDialog(const fs::path &path, PrintHostPostUplo
return true; return true;
}; };
auto* btn_confirm = add_button(wxID_YES, false, _L("Confirm")); auto* btn_upload = add_button(wxID_YES, false, _L("Upload"));
btn_confirm->Bind(wxEVT_BUTTON, [this, upload_only, validate_path](wxCommandEvent&) {
if (validate_path(txt_filename->GetValue())) {
if (upload_only) {
post_upload_action = PrintHostPostUploadAction::None;
} else {
post_upload_action = PrintHostPostUploadAction::StartPrint;
}
EndDialog(wxID_OK);
}
});
/*auto* btn_upload = add_button(wxID_YES, false, _L("Upload"));
btn_upload->Bind(wxEVT_BUTTON, [this, validate_path](wxCommandEvent&) { btn_upload->Bind(wxEVT_BUTTON, [this, validate_path](wxCommandEvent&) {
if (validate_path(txt_filename->GetValue())) { if (validate_path(txt_filename->GetValue())) {
post_upload_action = PrintHostPostUploadAction::None; post_upload_action = PrintHostPostUploadAction::None;
@ -108,8 +96,8 @@ PrintHostSendDialog::PrintHostSendDialog(const fs::path &path, PrintHostPostUplo
} }
}); });
if (post_actions.has(PrintHostPostUploadAction::StartPrint) && !upload_only) { if (post_actions.has(PrintHostPostUploadAction::StartPrint)) {
auto* btn_print = add_button(wxID_YES, false, _L("Upload and Print")); auto* btn_print = add_button(wxID_YES, false, _L("Print"));
btn_print->Bind(wxEVT_BUTTON, [this, validate_path](wxCommandEvent&) { btn_print->Bind(wxEVT_BUTTON, [this, validate_path](wxCommandEvent&) {
if (validate_path(txt_filename->GetValue())) { if (validate_path(txt_filename->GetValue())) {
post_upload_action = PrintHostPostUploadAction::StartPrint; post_upload_action = PrintHostPostUploadAction::StartPrint;
@ -120,7 +108,7 @@ PrintHostSendDialog::PrintHostSendDialog(const fs::path &path, PrintHostPostUplo
if (post_actions.has(PrintHostPostUploadAction::StartSimulation)) { if (post_actions.has(PrintHostPostUploadAction::StartSimulation)) {
// Using wxID_MORE as a button identifier to be different from the other buttons, wxID_MORE has no other meaning here. // Using wxID_MORE as a button identifier to be different from the other buttons, wxID_MORE has no other meaning here.
auto* btn_simulate = add_button(wxID_MORE, false, _L("Upload and Simulate")); auto* btn_simulate = add_button(wxID_MORE, false, _L("Simulate"));
btn_simulate->Bind(wxEVT_BUTTON, [this, validate_path](wxCommandEvent&) { btn_simulate->Bind(wxEVT_BUTTON, [this, validate_path](wxCommandEvent&) {
if (validate_path(txt_filename->GetValue())) { if (validate_path(txt_filename->GetValue())) {
post_upload_action = PrintHostPostUploadAction::StartSimulation; post_upload_action = PrintHostPostUploadAction::StartSimulation;
@ -128,9 +116,8 @@ PrintHostSendDialog::PrintHostSendDialog(const fs::path &path, PrintHostPostUplo
} }
}); });
} }
*/
add_button(wxID_CANCEL, false, "Cancel"); add_button(wxID_CANCEL,false,"Cancel");
finalize(); finalize();
#ifdef __linux__ #ifdef __linux__

View file

@ -26,7 +26,7 @@ namespace GUI {
class PrintHostSendDialog : public GUI::MsgDialog class PrintHostSendDialog : public GUI::MsgDialog
{ {
public: public:
PrintHostSendDialog(const boost::filesystem::path &path, PrintHostPostUploadActions post_actions, const wxArrayString& groups, bool upload_only); PrintHostSendDialog(const boost::filesystem::path &path, PrintHostPostUploadActions post_actions, const wxArrayString& groups);
boost::filesystem::path filename() const; boost::filesystem::path filename() const;
PrintHostPostUploadAction post_action() const; PrintHostPostUploadAction post_action() const;
std::string group() const; std::string group() const;