From d783651751b5bd367e4ed52a1c0815269912e665 Mon Sep 17 00:00:00 2001 From: sunsets <845944018@qq.com> Date: Mon, 1 Apr 2024 16:47:52 +0800 Subject: [PATCH] Optimized the interface for sending files --- src/slic3r/GUI/MsgDialog.cpp | 10 +++-- src/slic3r/GUI/Plater.cpp | 14 ++++++- src/slic3r/GUI/Plater.hpp | 2 + src/slic3r/GUI/PrintHostDialogs.cpp | 60 ++++++++++++++++++++++++++++- src/slic3r/GUI/PrintHostDialogs.hpp | 14 ++++++- 5 files changed, 92 insertions(+), 8 deletions(-) diff --git a/src/slic3r/GUI/MsgDialog.cpp b/src/slic3r/GUI/MsgDialog.cpp index eb1c054..00ea236 100644 --- a/src/slic3r/GUI/MsgDialog.cpp +++ b/src/slic3r/GUI/MsgDialog.cpp @@ -52,15 +52,18 @@ MsgDialog::MsgDialog(wxWindow *parent, const wxString &title, const wxString &he auto *headtext = new wxStaticText(this, wxID_ANY, headline); headtext->SetFont(boldfont); headtext->Wrap(CONTENT_WIDTH*wxGetApp().em_unit()); + //B61 + if (title != _L("Send G-Code to printer host")) { rightsizer->Add(headtext); rightsizer->AddSpacer(VERT_SPACING); + } rightsizer->Add(content_sizer, 1, wxEXPAND); btn_sizer->AddStretchSpacer(); - //B44 + //B44 //B61 logo = new wxStaticBitmap(this, wxID_ANY, bitmap.IsOk() ? bitmap : wxNullBitmap); - if (title == "App Update available") { + if (title == "App Update available" or title == _L("Send G-Code to printer host")) { topsizer->Add(rightsizer, 1, wxLEFT | wxTOP | wxRIGHT | wxEXPAND, BORDER); } else { @@ -73,7 +76,8 @@ MsgDialog::MsgDialog(wxWindow *parent, const wxString &title, const wxString &he //B50 // if (style & wxOK) // add_button(wxID_OK, true); - if (title != "App Update available") { + //B61 + if (title != "App Update available" and title != _L("Send G-Code to printer host")) { apply_style(style); } SetSizerAndFit(main_sizer); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index eabf0c6..c2c5a47 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -7726,6 +7726,13 @@ void publish(Model &model) { } } } +//B61 +ThumbnailData Plater::get_thumbnailldate() { + ThumbnailData thumbnail_data; + ThumbnailsParams thumbnail_params = {{}, false, true, true, true}; + p->generate_thumbnail(thumbnail_data, THUMBNAIL_SIZE_3MF.first, THUMBNAIL_SIZE_3MF.second, thumbnail_params, Camera::EType::Ortho); + return thumbnail_data; +} bool Plater::export_3mf(const boost::filesystem::path& output_path) { if (p->model.objects.empty()) { @@ -7960,8 +7967,10 @@ void Plater::send_gcode() return; } } + //B61 + PrintHostSendDialog dlg(default_output_file, upload_job.printhost->get_post_upload_actions(), groups, storage_paths, storage_names, + this, (this->fff_print().print_statistics())); - PrintHostSendDialog dlg(default_output_file, upload_job.printhost->get_post_upload_actions(), groups, storage_paths, storage_names); if (dlg.ShowModal() == wxID_OK) { if (printer_technology() == ptFFF) { const std::string ext = boost::algorithm::to_lower_copy(dlg.filename().extension().string()); @@ -7969,7 +7978,8 @@ void Plater::send_gcode() wxGetApp().app_config->get_bool("use_binary_gcode_when_supported"); const wxString error_str = check_binary_vs_ascii_gcode_extension(printer_technology(), ext, binary_output); if (! error_str.IsEmpty()) { - ErrorDialog(this, error_str, t_kill_focus([](const std::string& key) -> void { wxGetApp().sidebar().jump_to_option(key); })).ShowModal(); + ErrorDialog(this, error_str, t_kill_focus([](const std::string &key) -> void { wxGetApp().sidebar().jump_to_option(key); })) + .ShowModal(); return; } bool supports_binary = wxGetApp().preset_bundle->printers.get_edited_preset().config.opt_bool("binary_gcode"); diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 171ff08..f5c6186 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -291,6 +291,8 @@ public: void apply_cut_object_to_model(size_t init_obj_idx, const ModelObjectPtrs& cut_objects); + //B61 + ThumbnailData get_thumbnailldate(); void export_gcode(bool prefer_removable); void export_stl_obj(bool extended = false, bool selection_only = false); void export_amf(); diff --git a/src/slic3r/GUI/PrintHostDialogs.cpp b/src/slic3r/GUI/PrintHostDialogs.cpp index 97eb101..bdfc841 100644 --- a/src/slic3r/GUI/PrintHostDialogs.cpp +++ b/src/slic3r/GUI/PrintHostDialogs.cpp @@ -39,14 +39,25 @@ static const char *CONFIG_KEY_PATH = "printhost_path"; static const char *CONFIG_KEY_GROUP = "printhost_group"; static const char* CONFIG_KEY_STORAGE = "printhost_storage"; -PrintHostSendDialog::PrintHostSendDialog(const fs::path &path, PrintHostPostUploadActions post_actions, const wxArrayString &groups, const wxArrayString& storage_paths, const wxArrayString& storage_names) - : MsgDialog(static_cast(wxGetApp().mainframe), _L("Send G-Code to printer host"), _L("Upload to Printer Host with the following filename:"), 0) // Set style = 0 to avoid default creation of the "OK" button. +//B61 +PrintHostSendDialog::PrintHostSendDialog(const fs::path & path, + PrintHostPostUploadActions post_actions, + const wxArrayString & groups, + const wxArrayString & storage_paths, + const wxArrayString & storage_names, + Plater * plater, + const PrintStatistics & ps) + : MsgDialog(static_cast(wxGetApp().mainframe), + _L("Send G-Code to printer host"), + _L(""), + 0) // Set style = 0 to avoid default creation of the "OK" button. // All buttons will be added later in this constructor , txt_filename(new wxTextCtrl(this, wxID_ANY)) , combo_groups(!groups.IsEmpty() ? new wxComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, groups, wxCB_READONLY) : nullptr) , combo_storage(storage_names.GetCount() > 1 ? new wxComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, storage_names, wxCB_READONLY) : nullptr) , post_upload_action(PrintHostPostUploadAction::None) , m_paths(storage_paths) + , m_plater(plater) { #ifdef __APPLE__ txt_filename->OSXDisableAllSmartSubstitutions(); @@ -55,7 +66,52 @@ PrintHostSendDialog::PrintHostSendDialog(const fs::path &path, PrintHostPostUplo auto *label_dir_hint = new wxStaticText(this, wxID_ANY, _L("Use forward slashes ( / ) as a directory separator if needed.")); label_dir_hint->Wrap(CONTENT_WIDTH * wxGetApp().em_unit()); + //B61 + auto *label_dir_hint2 = new wxStaticText(this, wxID_ANY, _L("Upload to Printer Host with the following filename:")); + label_dir_hint2->Wrap(CONTENT_WIDTH * wxGetApp().em_unit()); + //B61 + ThumbnailData thumbnail_data = m_plater->get_thumbnailldate(); + + wxImage image(thumbnail_data.width, thumbnail_data.height); + image.InitAlpha(); + + for (unsigned int r = 0; r < thumbnail_data.height; ++r) { + unsigned int rr = (thumbnail_data.height - 1 - r) * thumbnail_data.width; + for (unsigned int c = 0; c < thumbnail_data.width; ++c) { + unsigned char *px = (unsigned char *) thumbnail_data.pixels.data() + 4 * (rr + c); + image.SetRGB((int) c, (int) r, px[0], px[1], px[2]); + image.SetAlpha((int) c, (int) r, px[3]); + } + } + wxBitmap bitmap(image); + wxStaticBitmap *static_bitmap = new wxStaticBitmap(this, wxID_ANY, bitmap); + //static_bitmap->SetSize(wxSize(20, 20)); + static_bitmap->SetMinSize(wxSize(100, 100)); + content_sizer->Add(static_bitmap, 0, wxALL | wxALIGN_CENTER); + + wxBoxSizer *row_sizer = new wxBoxSizer(wxHORIZONTAL); + + // Add add.svg image + //wxBitmap add_bitmap(*get_bmp_bundle("add.svg"), wxBITMAP_TYPE_SVG); + wxStaticBitmap *add_bitmap = new wxStaticBitmap(this, wxID_ANY, *get_bmp_bundle("print_time", 20)); + row_sizer->Add(add_bitmap, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); + + // Add ps.estimated_normal_print_time text + wxStaticText *estimated_print_time_text = new wxStaticText(this, wxID_ANY, wxString::Format("%s", ps.estimated_normal_print_time)); + row_sizer->Add(estimated_print_time_text, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); + + // Add delete.svg image + wxStaticBitmap *delete_static_bitmap = new wxStaticBitmap(this, wxID_ANY, *get_bmp_bundle("cost_weight", 20)); + row_sizer->Add(delete_static_bitmap, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); + + // Add ps.total_weight text + wxStaticText *total_weight_text = new wxStaticText(this, wxID_ANY, wxString::Format("%.4fg", ps.total_weight)); + row_sizer->Add(total_weight_text, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); + + content_sizer->Add(row_sizer, 0, wxALIGN_CENTER); + //B61 + content_sizer->Add(label_dir_hint2); content_sizer->Add(txt_filename, 0, wxEXPAND); content_sizer->Add(label_dir_hint); content_sizer->AddSpacer(VERT_SPACING); diff --git a/src/slic3r/GUI/PrintHostDialogs.hpp b/src/slic3r/GUI/PrintHostDialogs.hpp index 90cf797..5abda50 100644 --- a/src/slic3r/GUI/PrintHostDialogs.hpp +++ b/src/slic3r/GUI/PrintHostDialogs.hpp @@ -12,6 +12,9 @@ #include "GUI_Utils.hpp" #include "MsgDialog.hpp" #include "../Utils/PrintHost.hpp" +//B61 +#include "Plater.hpp" +#include "libslic3r/Print.hpp" class wxButton; class wxTextCtrl; @@ -36,7 +39,14 @@ struct PhysicalPrinterPresetData class PrintHostSendDialog : public GUI::MsgDialog { public: - PrintHostSendDialog(const boost::filesystem::path &path, PrintHostPostUploadActions post_actions, const wxArrayString& groups, const wxArrayString& storage_paths, const wxArrayString& storage_names); + //B61 + PrintHostSendDialog(const boost::filesystem::path &path, + PrintHostPostUploadActions post_actions, + const wxArrayString & groups, + const wxArrayString & storage_paths, + const wxArrayString & storage_names, + Plater * plater, + const PrintStatistics & ps); boost::filesystem::path filename() const; PrintHostPostUploadAction post_action() const; std::string group() const; @@ -57,6 +67,8 @@ private: //B53 std::vector m_presetData; std::vector m_checkbox_states; + //B61 + Plater *m_plater{nullptr}; };