FIX:fixed some issues with send to printer

Change-Id: Ic14f1285d234cd00895a343ae22aef90be415072
(cherry picked from commit 9bfb2ddb01878ffa983e9174cb46041fc8330aa8)
This commit is contained in:
tao wang 2022-10-14 11:16:14 +08:00 committed by Lane.Wei
parent 8029b62daa
commit a4cda21926
5 changed files with 56 additions and 15 deletions

View file

@ -27,7 +27,7 @@ SendJob::SendJob(std::shared_ptr<ProgressIndicator> pri, Plater* plater, std::st
: PlaterJob{ std::move(pri), plater },
m_dev_id(dev_id)
{
m_print_job_completed_id = plater->get_print_finished_event();
m_print_job_completed_id = plater->get_send_finished_event();
}
void SendJob::prepare()
@ -191,8 +191,8 @@ void SendJob::process()
}
}
else if (stage == SendingPrintJobStage::PrintingStageFinished) {
curr_percent = 100;
msg = wxString::Format(_L("Successfully sent."));
curr_percent = 100;
msg = wxString::Format(_L("Successfully sent. Close current page in %s s"), info);
}
else {
if (this->connection_type == "lan") {
@ -291,7 +291,10 @@ void SendJob::process()
BOOST_LOG_TRIVIAL(error) << "send_job: failed, result = " << result;
} else {
BOOST_LOG_TRIVIAL(error) << "send_job: send ok.";
m_success_fun();
//m_success_fun();
wxCommandEvent* evt = new wxCommandEvent(m_print_job_completed_id);
evt->SetString(m_dev_id);
wxQueueEvent(m_plater, evt);
m_job_finished = true;
}
}

View file

@ -152,6 +152,8 @@ wxDEFINE_EVENT(EVT_PUBLISH, wxCommandEvent);
// BBS: backup & restore
wxDEFINE_EVENT(EVT_RESTORE_PROJECT, wxCommandEvent);
wxDEFINE_EVENT(EVT_PRINT_FINISHED, wxCommandEvent);
wxDEFINE_EVENT(EVT_SEND_FINISHED, wxCommandEvent);
wxDEFINE_EVENT(EVT_PUBLISH_FINISHED, wxCommandEvent);
//BBS: repair model
wxDEFINE_EVENT(EVT_REPAIR_MODEL, wxCommandEvent);
wxDEFINE_EVENT(EVT_FILAMENT_COLOR_CHANGED, wxCommandEvent);
@ -1690,6 +1692,7 @@ struct Plater::priv
// BBS
void hide_select_machine_dlg() { m_select_machine_dlg->EndModal(wxID_OK); }
void hide_send_to_printer_dlg() { m_send_to_sdcard_dlg->EndModal(wxID_OK); }
void update_preview_bottom_toolbar();
@ -2266,6 +2269,8 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
q->Bind(EVT_DOWNLOAD_PROJECT, &priv::on_action_download_project, this);
q->Bind(EVT_IMPORT_MODEL_ID, &priv::on_action_request_model_id, this);
q->Bind(EVT_PRINT_FINISHED, [q](wxCommandEvent &evt) { q->print_job_finished(evt); });
q->Bind(EVT_SEND_FINISHED, [q](wxCommandEvent &evt) { q->send_job_finished(evt); });
q->Bind(EVT_PUBLISH_FINISHED, [q](wxCommandEvent &evt) { q->publish_job_finished(evt);});
//q->Bind(EVT_GLVIEWTOOLBAR_ASSEMBLE, [q](SimpleEvent&) { q->select_view_3D("Assemble"); });
}
@ -6118,11 +6123,22 @@ void Plater::get_print_job_data(PrintPrepareData* data)
data->_3mf_config_path = p->m_print_job_data._3mf_config_path;
}
}
int Plater::get_print_finished_event()
{
return EVT_PRINT_FINISHED;
}
int Plater::get_send_finished_event()
{
return EVT_SEND_FINISHED;
}
int Plater::get_publish_finished_event()
{
return EVT_PUBLISH_FINISHED;
}
void Plater::priv::set_current_canvas_as_dirty()
{
if (current_panel == view3D)
@ -9125,6 +9141,26 @@ void Plater::print_job_finished(wxCommandEvent &evt)
curr_monitor->get_tabpanel()->ChangeSelection(MonitorPanel::PrinterTab::PT_STATUS);
}
void Plater::send_job_finished(wxCommandEvent& evt)
{
Slic3r::DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev) return;
dev->set_selected_machine(evt.GetString().ToStdString());
p->hide_send_to_printer_dlg();
//p->main_frame->request_select_tab(MainFrame::TabPosition::tpMonitor);
////jump to monitor and select device status panel
//MonitorPanel* curr_monitor = p->main_frame->m_monitor;
//if (curr_monitor)
// curr_monitor->get_tabpanel()->ChangeSelection(MonitorPanel::PrinterTab::PT_STATUS);
}
void Plater::publish_job_finished(wxCommandEvent &evt)
{
p->m_publish_dlg->EndModal(wxID_OK);
GUI::wxGetApp().load_url(evt.GetString());
}
// Called when the Eject button is pressed.
void Plater::eject_drive()
{

View file

@ -338,8 +338,9 @@ public:
int export_config_3mf(int plate_idx = -1, Export3mfProgressFn proFn = nullptr);
//BBS jump to nonitor after print job finished
void print_job_finished(wxCommandEvent &evt);
void publish_job_finished(wxCommandEvent &evt);
void eject_drive();
void send_job_finished(wxCommandEvent& evt);
void publish_job_finished(wxCommandEvent& evt);
void eject_drive();
void take_snapshot(const std::string &snapshot_name);
//void take_snapshot(const wxString &snapshot_name);
@ -402,6 +403,8 @@ public:
//BBS: add print job releated functions
void get_print_job_data(PrintPrepareData* data);
int get_print_finished_event();
int get_send_finished_event();
int get_publish_finished_event();
void set_current_canvas_as_dirty();
void unbind_canvas_event_handlers();

View file

@ -385,7 +385,7 @@ void SendToPrinterDialog::on_cancel(wxCloseEvent &event)
}
this->EndModal(wxID_CANCEL);
}
void SendToPrinterDialog::on_ok(wxCommandEvent &event)
{
BOOST_LOG_TRIVIAL(info) << "print_job: on_ok to send";
@ -488,8 +488,10 @@ void SendToPrinterDialog::on_ok(wxCommandEvent &event)
m_send_job->on_success([this]() {
enable_prepare_mode = true;
//prepare_mode();
//enable_prepare_mode = true;enable_prepare_mode
m_status_bar->reset();
prepare_mode();
//EndModal(wxID_CLOSE);
});
enable_prepare_mode = false;
@ -779,11 +781,6 @@ void SendToPrinterDialog::show_status(PrintDialogStatus status, std::vector<wxSt
if (status == PrintDialogStatus::PrintStatusSending) {
sending_mode();
}
else {
if (enable_prepare_mode) {
prepare_mode();
}
}
// other
if (status == PrintDialogStatus::PrintStatusInit) {
@ -888,6 +885,8 @@ void SendToPrinterDialog::on_dpi_changed(const wxRect &suggested_rect)
void SendToPrinterDialog::set_default()
{
enable_prepare_mode = true;
prepare_mode();
//clear combobox
m_list.clear();
m_comboBox_printer->Clear();

View file

@ -149,7 +149,7 @@ protected:
void on_timer(wxTimerEvent& event);
void on_selection_changed(wxCommandEvent& event);
void Enable_Refresh_Button(bool en);
void show_status(PrintDialogStatus status, std::vector<wxString> params = std::vector<wxString>());
void show_status(PrintDialogStatus status, std::vector<wxString> params = std::vector<wxString>());
void Enable_Send_Button(bool en);
void on_dpi_changed(const wxRect& suggested_rect) override;
void update_user_machine_list();