Support upload g-code to third-party printers

* wip

* fix cmake warning

* add UI and config options for Moonraker connection

* wip: copy whole print host UI from PS

* add more needed options

* wip 2

* fix string issue on Mac

* wip3

* fix cmake warning

* working
need tweaks

* cleanup

* support thumbnail

* fix DNS resolving issue in Windows

* code clean up
This commit is contained in:
SoftFever 2022-08-20 23:06:41 +08:00 committed by GitHub
parent 82127a92c9
commit 488b1cd8f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
51 changed files with 5000 additions and 17 deletions

View file

@ -25,6 +25,7 @@
#include "ProgressStatusBar.hpp"
#include "3DScene.hpp"
#include "ParamsDialog.hpp"
#include "PrintHostDialogs.hpp"
#include "wxExtensions.hpp"
#include "GUI_ObjectList.hpp"
#include "Mouse3DController.hpp"
@ -149,6 +150,7 @@ wxDEFINE_EVENT(EVT_SYNC_CLOUD_PRESET, SimpleEvent);
MainFrame::MainFrame() :
DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, BORDERLESS_FRAME_STYLE, "mainframe")
, m_printhost_queue_dlg(new PrintHostQueueDialog(this))
// BBS
, m_recent_projects(9)
, m_settings_dialog(this)
@ -399,6 +401,10 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, BORDERLESS_FRAME_
BOOST_LOG_TRIVIAL(info) << __FUNCTION__<< "cancelled by close_with_confirm selection";
return;
}
if (event.CanVeto() && !wxGetApp().check_print_host_queue()) {
event.Veto();
return;
}
#if 0 // BBS
//if (m_plater != nullptr) {
@ -1105,6 +1111,17 @@ bool MainFrame::can_export_gcode() const
return true;
}
bool MainFrame::can_send_gcode() const
{
if (m_plater && !m_plater->model().objects.empty())
{
auto cfg = wxGetApp().preset_bundle->printers.get_selected_preset().config;
if (const auto *print_host_opt = cfg.option<ConfigOptionString>("print_host"); print_host_opt)
return !print_host_opt->value.empty();
}
return true;
}
/*bool MainFrame::can_export_gcode_sd() const
{
if (m_plater == nullptr)
@ -1226,6 +1243,8 @@ wxBoxSizer* MainFrame::create_side_tools()
}
else if (m_print_select == eExportGcode)
wxPostEvent(m_plater, SimpleEvent(EVT_GLTOOLBAR_EXPORT_GCODE));
else if (m_print_select == eSendGcode)
wxPostEvent(m_plater, SimpleEvent(EVT_GLTOOLBAR_SEND_GCODE));
else if (m_print_select == eExportSlicedFile)
wxPostEvent(m_plater, SimpleEvent(EVT_GLTOOLBAR_EXPORT_SLICED_FILE));
});
@ -1313,6 +1332,17 @@ wxBoxSizer* MainFrame::create_side_tools()
this->Layout();
p->Dismiss();
});
SideButton* send_gcode_btn = new SideButton(p, _L("Send sliced file (.gcode)"), "");
send_gcode_btn->SetCornerRadius(0);
send_gcode_btn->Bind(wxEVT_BUTTON, [this, p](wxCommandEvent&) {
m_print_btn->SetLabel(_L("Send Sliced File (.gcode)"));
m_print_select = eSendGcode;
if (m_print_enable)
m_print_enable = get_enable_print_status() && can_send_gcode();
m_print_btn->Enable(m_print_enable);
this->Layout();
p->Dismiss();
});
#if ENABEL_PRINT_ALL
p->append_button(print_all_btn);
@ -1320,6 +1350,7 @@ wxBoxSizer* MainFrame::create_side_tools()
p->append_button(print_plate_btn);
p->append_button(export_sliced_file_3mf_btn);
p->append_button(export_sliced_file_gcode_btn);
p->append_button(send_gcode_btn);
p->Popup(m_print_btn);
}
);