FIX:fixed some issues with sending prints

1. send to printer change to send to print sd card
2. update the default error message
3. display networking error messages on the page

Change-Id: I27b67091e9449bb9d469f9ded53148e0b1a74369
This commit is contained in:
tao wang 2022-10-19 14:45:18 +08:00 committed by Lane.Wei
parent 11651ac437
commit 77e45b8709
7 changed files with 96 additions and 15 deletions

View File

@ -30,6 +30,10 @@ BBLStatusBarSend::BBLStatusBarSend(wxWindow *parent, int id)
m_status_text->SetForegroundColour(wxColour(107, 107, 107)); m_status_text->SetForegroundColour(wxColour(107, 107, 107));
m_status_text->SetFont(::Label::Body_13); m_status_text->SetFont(::Label::Body_13);
m_status_text->Wrap(m_self->FromDIP(280)); m_status_text->Wrap(m_self->FromDIP(280));
m_status_text->SetSize(wxSize(m_self->FromDIP(280), m_self->FromDIP(46)));
m_status_text->SetMaxSize(wxSize(m_self->FromDIP(280), m_self->FromDIP(46)));
//m_status_text->SetSize()
m_prog = new wxGauge(m_self, wxID_ANY, 100, wxDefaultPosition, wxSize(-1, m_self->FromDIP(6)), wxGA_HORIZONTAL); m_prog = new wxGauge(m_self, wxID_ANY, 100, wxDefaultPosition, wxSize(-1, m_self->FromDIP(6)), wxGA_HORIZONTAL);
@ -168,15 +172,61 @@ wxPanel* BBLStatusBarSend::get_panel()
return m_self; return m_self;
} }
bool BBLStatusBarSend::is_english_text(wxString str)
{
std::regex reg("^[0-9a-zA-Z]+$");
std::smatch matchResult;
std::string pattern_Special = "{}[]<>~!@#$%^&*(),.?/ :";
for (auto i = 0; i < str.Length(); i++) {
std::string regex_str = wxString(str[i]).ToStdString();
if (std::regex_match(regex_str, matchResult, reg)) {
continue;
}
else {
int result = pattern_Special.find(regex_str.c_str());
if (result < 0 || result > pattern_Special.length()) {
return false;
}
}
}
return true;
}
wxString BBLStatusBarSend::format_text(wxStaticText* st, wxString str, int warp)
{
int index = 0;
if (!str.empty()) {
while ((index = str.find('\n', index)) != string::npos) {
str.erase(index, 1);
}
}
wxString out_txt = str;
wxString count_txt = "";
int new_line_pos = 0;
for (int i = 0; i < str.length(); i++) {
auto text_size = st->GetTextExtent(count_txt);
if (text_size.x < warp) {
count_txt += str[i];
}
else {
out_txt.insert(i - 1, '\n');
count_txt = "";
}
}
return out_txt;
}
void BBLStatusBarSend::set_status_text(const wxString& txt) void BBLStatusBarSend::set_status_text(const wxString& txt)
{ {
//auto txtss = "Sending the printing task has timed out.\nPlease try again!"; //auto txtss = "Sending the printing task has timed out.\nPlease try again!";
//auto txtss = "The printing project is being uploaded... 25%%"; //auto txtss = "The printing project is being uploaded... 25%%";
//m_status_text->SetLabelText(txtss); //m_status_text->SetLabelText(txtss);
m_status_text->SetLabelText(txt); wxString str = format_text(m_status_text,txt,280);
m_status_text->SetSize(wxSize(m_self->FromDIP(280), -1)); m_status_text->SetLabelText(str);
m_status_text->SetMaxSize(wxSize(m_self->FromDIP(280), -1)); //if (is_english_text(str)) m_status_text->Wrap(m_self->FromDIP(280));
m_status_text->Wrap(m_self->FromDIP(280));
} }
void BBLStatusBarSend::set_percent_text(const wxString &txt) void BBLStatusBarSend::set_percent_text(const wxString &txt)
@ -206,6 +256,7 @@ wxString BBLStatusBarSend::get_status_text() const
bool BBLStatusBarSend::update_status(wxString &msg, bool &was_cancel, int percent, bool yield) bool BBLStatusBarSend::update_status(wxString &msg, bool &was_cancel, int percent, bool yield)
{ {
//auto test_txt = _L("Unkown Error.") + _L("status=150, body=Timeout was reached: Connection timed out after 10009 milliseconds [Error 28]");
set_status_text(msg); set_status_text(msg);
if (percent >= 0) if (percent >= 0)

View File

@ -56,7 +56,9 @@ public:
void set_cancel_callback(CancelFn = CancelFn()) override; void set_cancel_callback(CancelFn = CancelFn()) override;
inline void reset_cancel_callback() { set_cancel_callback(); } inline void reset_cancel_callback() { set_cancel_callback(); }
wxPanel * get_panel(); wxPanel * get_panel();
void set_status_text(const wxString &txt); bool is_english_text(wxString str);
wxString format_text(wxStaticText* st, wxString str, int warp);
void set_status_text(const wxString& txt);
void set_percent_text(const wxString &txt); void set_percent_text(const wxString &txt);
void msw_rescale(); void msw_rescale();
void set_status_text(const std::string &txt); void set_status_text(const std::string &txt);

View File

@ -12,7 +12,7 @@ namespace GUI {
static wxString check_gcode_failed_str = _L("Abnormal print file data. Please slice again"); static wxString check_gcode_failed_str = _L("Abnormal print file data. Please slice again");
static wxString printjob_cancel_str = _L("Task canceled"); static wxString printjob_cancel_str = _L("Task canceled");
static wxString timeout_to_upload_str = _L("Upload task timed out. Please check the network problem and try again"); static wxString timeout_to_upload_str = _L("Upload task timed out. Please check the network problem and try again");
static wxString failed_in_cloud_service_str = _L("Cloud service connection failed. Please try again."); static wxString failed_in_cloud_service_str = _L("Send to Printer failed. Please try again.");
static wxString file_is_not_exists_str = _L("Print file not found, please slice again"); static wxString file_is_not_exists_str = _L("Print file not found, please slice again");
static wxString file_over_size_str = _L("The print file exceeds the maximum allowable size (1GB). Please simplify the model and slice again"); static wxString file_over_size_str = _L("The print file exceeds the maximum allowable size (1GB). Please simplify the model and slice again");
static wxString print_canceled_str = _L("Task canceled"); static wxString print_canceled_str = _L("Task canceled");
@ -151,8 +151,7 @@ void SendJob::process()
BBL::PrintParams params; BBL::PrintParams params;
params.dev_id = m_dev_id; params.dev_id = m_dev_id;
//params.project_name = wxGetApp().plater()->get_project_name().ToUTF8().data(); //params.project_name = wxGetApp().plater()->get_project_name().ToUTF8().data();
params.project_name = wxGetApp().plater()->get_project_name().utf8_string(); params.project_name = wxGetApp().plater()->get_export_gcode_filename(".gcode.3mf", true).utf8_string();
params.preset_name = wxGetApp().preset_bundle->prints.get_selected_preset_name(); params.preset_name = wxGetApp().preset_bundle->prints.get_selected_preset_name();
params.filename = job_data._3mf_path.string(); params.filename = job_data._3mf_path.string();
params.config_filename = job_data._3mf_config_path.string(); params.config_filename = job_data._3mf_config_path.string();

View File

@ -13,6 +13,7 @@
#include "Widgets/StaticBox.hpp" #include "Widgets/StaticBox.hpp"
#include "Widgets/WebView.hpp" #include "Widgets/WebView.hpp"
#include <wx/regex.h>
#include <wx/progdlg.h> #include <wx/progdlg.h>
#include <wx/clipbrd.h> #include <wx/clipbrd.h>
#include <wx/dcgraph.h> #include <wx/dcgraph.h>
@ -420,16 +421,36 @@ void SecondaryCheckDialog::update_text(wxString text)
text = format_text(m_staticText_release_note, text, FromDIP(240)); text = format_text(m_staticText_release_note, text, FromDIP(240));
m_staticText_release_note->SetLabelText(text); m_staticText_release_note->SetLabelText(text);
m_staticText_release_note->Wrap(FromDIP(240)); if (is_english_text(text)) m_staticText_release_note->Wrap(FromDIP(240));
sizer_text_release_note->Add(m_staticText_release_note, 0, wxALIGN_CENTER, 5); sizer_text_release_note->Add(m_staticText_release_note, 0, wxALIGN_CENTER, 5);
m_vebview_release_note->SetSizer(sizer_text_release_note); m_vebview_release_note->SetSizer(sizer_text_release_note);
m_vebview_release_note->Layout(); m_vebview_release_note->Layout();
//Fit(); }
bool SecondaryCheckDialog::is_english_text(wxString str)
{
std::regex reg("^[0-9a-zA-Z]+$");
std::smatch matchResult;
std::string pattern_Special = "{}[]<>~!@#$%^&*(),.?/ :";
for (auto i = 0; i < str.Length(); i++) {
std::string regex_str = wxString(str[i]).ToStdString();
if(std::regex_match(regex_str, matchResult, reg)){
continue;
}
else {
int result = pattern_Special.find(regex_str.c_str());
if (result < 0 || result > pattern_Special.length()) {
return false;
}
}
}
return true;
} }
wxString SecondaryCheckDialog::format_text(wxStaticText* st, wxString str, int warp) wxString SecondaryCheckDialog::format_text(wxStaticText* st, wxString str, int warp)
{ {
if (wxGetApp().app_config->get("language") != "zh_CN") { return str; } if (is_english_text(str)) return str;
wxString out_txt = str; wxString out_txt = str;
wxString count_txt = ""; wxString count_txt = "";

View File

@ -83,6 +83,7 @@ class SecondaryCheckDialog : public DPIDialog
public: public:
SecondaryCheckDialog(wxWindow* parent); SecondaryCheckDialog(wxWindow* parent);
void update_text(wxString text); void update_text(wxString text);
bool is_english_text(wxString str);
wxString format_text(wxStaticText* st, wxString str, int warp); wxString format_text(wxStaticText* st, wxString str, int warp);
~SecondaryCheckDialog(); ~SecondaryCheckDialog();
void on_dpi_changed(const wxRect& suggested_rect) override; void on_dpi_changed(const wxRect& suggested_rect) override;

View File

@ -71,7 +71,7 @@ wxString SendToPrinterDialog::format_text(wxString &m_msg)
} }
SendToPrinterDialog::SendToPrinterDialog(Plater *plater) SendToPrinterDialog::SendToPrinterDialog(Plater *plater)
: DPIDialog(static_cast<wxWindow *>(wxGetApp().mainframe), wxID_ANY, _L("Send to Printer"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX) : DPIDialog(static_cast<wxWindow *>(wxGetApp().mainframe), wxID_ANY, _L("Send to Printer SD card"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
, m_plater(plater), m_export_3mf_cancel(false) , m_plater(plater), m_export_3mf_cancel(false)
{ {
#ifdef __WINDOWS__ #ifdef __WINDOWS__
@ -135,7 +135,7 @@ SendToPrinterDialog::SendToPrinterDialog(Plater *plater)
wxBoxSizer *m_sizer_printer = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer *m_sizer_printer = new wxBoxSizer(wxHORIZONTAL);
m_stext_printer_title = new wxStaticText(this, wxID_ANY, L("Printer"), wxDefaultPosition, wxSize(-1, -1), 0); m_stext_printer_title = new wxStaticText(this, wxID_ANY, _L("Printer"), wxDefaultPosition, wxSize(-1, -1), 0);
m_stext_printer_title->SetFont(::Label::Head_14); m_stext_printer_title->SetFont(::Label::Head_14);
m_stext_printer_title->Wrap(-1); m_stext_printer_title->Wrap(-1);
m_stext_printer_title->SetForegroundColour(m_colour_bold_color); m_stext_printer_title->SetForegroundColour(m_colour_bold_color);
@ -237,14 +237,17 @@ SendToPrinterDialog::SendToPrinterDialog(Plater *plater)
m_scrollable_region->SetSizer(m_sizer_scrollable_region); m_scrollable_region->SetSizer(m_sizer_scrollable_region);
m_scrollable_region->Layout(); m_scrollable_region->Layout();
//file name
m_file_name = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0);
m_sizer_main->Add(m_line_top, 0, wxEXPAND, 0); m_sizer_main->Add(m_line_top, 0, wxEXPAND, 0);
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(22)); m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(22));
m_sizer_main->Add(m_scrollable_region, 0, wxALIGN_CENTER_HORIZONTAL, 0); m_sizer_main->Add(m_scrollable_region, 0, wxALIGN_CENTER_HORIZONTAL, 0);
m_sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(8)); m_sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(8));
m_sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(8)); m_sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(8));
m_sizer_main->Add(m_file_name, 0, wxALIGN_CENTER_HORIZONTAL, 0);
m_sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(8));
m_sizer_main->Add(m_line_materia, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(30)); m_sizer_main->Add(m_line_materia, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(30));
m_sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(14)); m_sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(15));
m_sizer_main->Add(m_sizer_printer, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(30)); m_sizer_main->Add(m_sizer_printer, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(30));
m_sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(5)); m_sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(5));
m_sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(8)); m_sizer_main->Add(0, 0, 0, wxEXPAND | wxTOP, FromDIP(8));
@ -896,6 +899,9 @@ void SendToPrinterDialog::on_dpi_changed(const wxRect &suggested_rect)
void SendToPrinterDialog::set_default() void SendToPrinterDialog::set_default()
{ {
wxString filename = m_plater->get_export_gcode_filename(".gcode.3mf", true);
m_file_name->SetLabelText(filename);
enable_prepare_mode = true; enable_prepare_mode = true;
prepare_mode(); prepare_mode();

View File

@ -92,6 +92,7 @@ protected:
wxBoxSizer* sizer_thumbnail; wxBoxSizer* sizer_thumbnail;
wxBoxSizer* m_sizer_main; wxBoxSizer* m_sizer_main;
wxBoxSizer* m_sizer_bottom; wxBoxSizer* m_sizer_bottom;
wxStaticText* m_file_name;
bool enable_prepare_mode{true}; bool enable_prepare_mode{true};
bool m_need_adaptation_screen{ false }; bool m_need_adaptation_screen{ false };