Muti send

This commit is contained in:
sunsets
2024-01-22 13:27:46 +08:00
parent 4983297dee
commit 8c016acf83
3 changed files with 105 additions and 4 deletions

View File

@@ -7825,14 +7825,40 @@ void Plater::send_gcode()
wxGetApp().preset_bundle->printers.get_edited_preset().config.opt_string("printer_notes"));
}
//B53
auto pppd = dlg.pppd();
auto checkbox_states = dlg.checkbox_states();
for (int i = 0; i < pppd.size(); i++) {
if (checkbox_states[i]) {
PresetBundle &preset_bundle = *wxGetApp().preset_bundle;
auto m_collection = &preset_bundle.printers;
auto preset_data = pppd[i];
Preset *preset = m_collection->find_preset((preset_data.name).ToStdString());
if (!preset || !preset->is_visible)
continue;
wxStringTokenizer tokenizer((preset_data.fullname), "*");
std::string tem_name = (into_u8(tokenizer.GetNextToken().Trim().mb_str()));
auto * printer = preset_bundle.physical_printers.find_printer(tem_name);
if (printer == nullptr)
return;
DynamicPrintConfig *cfg_t = &(printer->config);
PrintHostJob upload_job(cfg_t);
if (upload_job.empty())
return;
upload_job.upload_data.upload_path = dlg.filename();
upload_job.upload_data.post_action = dlg.post_action();
upload_job.upload_data.group = dlg.group();
upload_job.upload_data.storage = dlg.storage();
// Show "Is printer clean" dialog for PrusaConnect - Upload and print.
if (std::string(upload_job.printhost->get_name()) == "PrusaConnect" && upload_job.upload_data.post_action == PrintHostPostUploadAction::StartPrint) {
GUI::MessageDialog dlg(nullptr, _L("Is the printer ready? Is the print sheet in place, empty and clean?"), _L("Upload and Print"), wxOK | wxCANCEL);
if (std::string(upload_job.printhost->get_name()) == "PrusaConnect" &&
upload_job.upload_data.post_action == PrintHostPostUploadAction::StartPrint) {
GUI::MessageDialog dlg(nullptr, _L("Is the printer ready? Is the print sheet in place, empty and clean?"),
_L("Upload and Print"), wxOK | wxCANCEL);
if (dlg.ShowModal() != wxID_OK)
return;
}
@@ -7840,6 +7866,8 @@ void Plater::send_gcode()
p->export_gcode(fs::path(), false, std::move(upload_job));
}
}
}
}
// Called when the Eject button is pressed.
void Plater::eject_drive()

View File

@@ -59,6 +59,44 @@ PrintHostSendDialog::PrintHostSendDialog(const fs::path &path, PrintHostPostUplo
content_sizer->Add(txt_filename, 0, wxEXPAND);
content_sizer->Add(label_dir_hint);
content_sizer->AddSpacer(VERT_SPACING);
//B53
wxBoxSizer * checkbox_sizer = new wxBoxSizer(wxVERTICAL);
PresetBundle & preset_bundle = *wxGetApp().preset_bundle;
const PhysicalPrinterCollection & ph_printers = preset_bundle.physical_printers;
std::vector<PhysicalPrinterPresetData> preset_data;
for (PhysicalPrinterCollection::ConstIterator it = ph_printers.begin(); it != ph_printers.end(); ++it) {
for (const std::string &preset_name : it->get_preset_names()) {
Preset *preset = wxGetApp().preset_bundle->printers.find_preset(preset_name);
if (preset != nullptr) {
preset_data.push_back({wxString::FromUTF8(it->get_full_name(preset_name)).Lower(), wxString::FromUTF8(preset_name),
wxString::FromUTF8(it->get_full_name(preset_name)), ph_printers.is_selected(it, preset_name)});
}
}
}
m_presetData = preset_data;
for (const PhysicalPrinterPresetData &data : preset_data) {
wxCheckBox *checkbox = new wxCheckBox(this, wxID_ANY, _L(data.fullname));
checkbox->SetValue(data.selected);
checkbox_sizer->Add(checkbox, 0, wxEXPAND | wxALL, 5);
}
wxCheckBox *select_all_checkbox = new wxCheckBox(this, wxID_ANY, "Select All");
checkbox_sizer->Add(select_all_checkbox, 0, wxEXPAND | wxALL, 5);
select_all_checkbox->Bind(wxEVT_CHECKBOX, [checkbox_sizer](wxCommandEvent &event) {
bool selectAll = event.IsChecked();
for (int i = 0; i < checkbox_sizer->GetItemCount(); i++) {
wxCheckBox *checkbox = dynamic_cast<wxCheckBox *>(checkbox_sizer->GetItem(i)->GetWindow());
if (checkbox) {
checkbox->SetValue(selectAll);
}
}
});
content_sizer->Add(checkbox_sizer);
if (combo_groups != nullptr) {
// Repetier specific: Show a selection of file groups.
@@ -109,9 +147,19 @@ PrintHostSendDialog::PrintHostSendDialog(const fs::path &path, PrintHostPostUplo
return true;
};
//B53
auto* btn_ok = add_button(wxID_OK, true, _L("Upload"));
btn_ok->Bind(wxEVT_BUTTON, [this, validate_path](wxCommandEvent&) {
btn_ok->Bind(wxEVT_BUTTON, [this, validate_path, checkbox_sizer](wxCommandEvent &) {
if (validate_path(txt_filename->GetValue())) {
std::vector<bool> checkbox_states;
for (int i = 0; i < checkbox_sizer->GetItemCount(); i++) {
wxCheckBox *checkbox = dynamic_cast<wxCheckBox *>(checkbox_sizer->GetItem(i)->GetWindow());
if (checkbox) {
checkbox_states.push_back(checkbox->GetValue());
}
}
m_checkbox_states = checkbox_states;
post_upload_action = PrintHostPostUploadAction::None;
EndDialog(wxID_OK);
}
@@ -128,10 +176,20 @@ PrintHostSendDialog::PrintHostSendDialog(const fs::path &path, PrintHostPostUplo
});
}
//B53
if (post_actions.has(PrintHostPostUploadAction::StartPrint)) {
auto* btn_print = add_button(wxID_YES, false, _L("Upload and Print"));
btn_print->Bind(wxEVT_BUTTON, [this, validate_path](wxCommandEvent&) {
btn_print->Bind(wxEVT_BUTTON, [this, validate_path, checkbox_sizer](wxCommandEvent &) {
if (validate_path(txt_filename->GetValue())) {
std::vector<bool> checkbox_states;
for (int i = 0; i < checkbox_sizer->GetItemCount(); i++) {
wxCheckBox *checkbox = dynamic_cast<wxCheckBox *>(checkbox_sizer->GetItem(i)->GetWindow());
if (checkbox) {
checkbox_states.push_back(checkbox->GetValue());
}
}
m_checkbox_states = checkbox_states;
post_upload_action = PrintHostPostUploadAction::StartPrint;
EndDialog(wxID_OK);
}

View File

@@ -23,6 +23,15 @@ namespace Slic3r {
namespace GUI {
//B53
struct PhysicalPrinterPresetData
{
wxString lower_name; // just for sorting
wxString name; // preset_name
wxString fullname; // full name
bool selected; // is selected
int checkboxId;
};
class PrintHostSendDialog : public GUI::MsgDialog
{
public:
@@ -31,6 +40,9 @@ public:
PrintHostPostUploadAction post_action() const;
std::string group() const;
std::string storage() const;
//B53
std::vector<PhysicalPrinterPresetData> pppd() { return m_presetData; }
std::vector<bool> checkbox_states() { return m_checkbox_states; }
virtual void EndModal(int ret) override;
private:
@@ -41,6 +53,9 @@ private:
wxString m_valid_suffix;
wxString m_preselected_storage;
wxArrayString m_paths;
//B53
std::vector<PhysicalPrinterPresetData> m_presetData;
std::vector<bool> m_checkbox_states;
};