NEW:add some new changes for send print job

1. change tray id like to A1, B1, C1, D1
2. can change the name of the project that is sent
3. add ams mapping instructions

Change-Id: If301f4051f640157a53d6927a0ddf2facf4961b4
This commit is contained in:
tao wang 2022-11-16 21:13:10 +08:00 committed by Lane.Wei
parent 06ac3f73a6
commit 46dc96fddf
15 changed files with 567 additions and 21 deletions

View file

@ -0,0 +1,3 @@
<svg width="26" height="11" viewBox="0 0 26 11" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M25.0877 5.97153C25.3595 5.69978 25.3595 5.2592 25.0877 4.98746L20.6594 0.55913C20.3877 0.287386 19.9471 0.287386 19.6753 0.55913C19.4036 0.830875 19.4036 1.27146 19.6753 1.5432L23.6116 5.47949L19.6753 9.41578C19.4036 9.68753 19.4036 10.1281 19.6753 10.3999C19.9471 10.6716 20.3877 10.6716 20.6594 10.3999L25.0877 5.97153ZM0.90332 6.17534H24.5957V4.78365H0.90332V6.17534Z" fill="#00AE42"/>
</svg>

After

Width:  |  Height:  |  Size: 502 B

View file

@ -0,0 +1,6 @@
<svg width="54" height="33" viewBox="0 0 54 33" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="50" height="30" rx="4.63896" fill="#EA4E38"/>
<path d="M0 19H50V25.361C50 27.9231 47.9231 30 45.361 30H4.63896C2.07693 30 0 27.9231 0 25.361V19Z" fill="#C041C2"/>
<path d="M16.0526 4.96415C16.6934 4.96415 17.2649 5.08971 17.7672 5.34084C18.2781 5.59196 18.6764 5.94266 18.9622 6.39295C19.2479 6.83458 19.3908 7.34116 19.3908 7.91268C19.3908 8.4842 19.2479 8.9951 18.9622 9.44539C18.6851 9.88702 18.2911 10.2334 17.7801 10.4845C17.2779 10.727 16.7021 10.8482 16.0526 10.8482H14.2861V14.4722H13.1301V4.96415H16.0526ZM15.9097 9.83506C16.6371 9.83506 17.1956 9.65754 17.5853 9.30251C17.975 8.93881 18.1698 8.47554 18.1698 7.91268C18.1698 7.34982 17.975 6.88654 17.5853 6.52284C17.1956 6.15915 16.6371 5.9773 15.9097 5.9773H14.2861V9.83506H15.9097ZM20.8423 4.96415H21.9984V13.433H26.6874V14.4722H20.8423V4.96415ZM31.7844 4.96415L35.6032 14.4722H34.3173L33.2652 11.7445H29.3295L28.3293 14.4722H27.1603L30.8102 4.96415H31.7844ZM32.8625 10.7053L31.2519 6.50985L29.7192 10.7053H32.8625Z" fill="white"/>
<path d="M21.3664 20.7625L24.0941 27.554H23.0086L22.3128 25.7355H19.5572L18.8892 27.554H17.8872L20.5129 20.7625H21.3664ZM21.9788 24.8634L20.9025 22.0614L19.882 24.8634H21.9788ZM25.0369 22.9057V21.913L27.0502 20.7532H27.8203V27.554H26.809V21.9037L25.0369 22.9057Z" fill="white"/>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 14 KiB

View file

@ -379,11 +379,12 @@ std::vector<TrayData> AmsMapingPopup::parse_ams_mapping(std::map<std::string, Am
void AmsMapingPopup::add_ams_mapping(std::vector<TrayData> tray_data)
{
auto sizer_mapping_list = new wxBoxSizer(wxHORIZONTAL);
for (auto i = 0; i < tray_data.size(); i++) {
wxBoxSizer *sizer_mapping_item = new wxBoxSizer(wxVERTICAL);
// set number
auto number = new wxStaticText(this, wxID_ANY, wxString::Format("%02d",tray_data[i].id + 1), wxDefaultPosition, wxDefaultSize, 0);
auto number = new wxStaticText(this, wxID_ANY, wxGetApp().transition_tridid(tray_data[i].id), wxDefaultPosition, wxDefaultSize, 0);
number->SetFont(::Label::Body_13);
number->SetForegroundColour(wxColour(0X6B, 0X6B, 0X6B));
number->Wrap(-1);
@ -476,9 +477,11 @@ void AmsMapingPopup::paintEvent(wxPaintEvent &evt)
void MappingItem::send_event(int fliament_id)
{
auto number = wxGetApp().transition_tridid(m_tray_data.id);
wxCommandEvent event(EVT_SET_FINISH_MAPPING);
event.SetInt(m_tray_data.id);
wxString param = wxString::Format("%d|%d|%d|%02d|%d", m_coloul.Red(), m_coloul.Green(), m_coloul.Blue(), m_tray_data.id + 1, fliament_id);
wxString param = wxString::Format("%d|%d|%d|%s|%d", m_coloul.Red(), m_coloul.Green(), m_coloul.Blue(), number, fliament_id);
event.SetString(param);
event.SetEventObject(this->GetParent()->GetParent());
wxPostEvent(this->GetParent()->GetParent(), event);
@ -655,4 +658,107 @@ void AmsMapingTipPopup::OnDismiss() {}
bool AmsMapingTipPopup::ProcessLeftDown(wxMouseEvent &event) {
return wxPopupTransientWindow::ProcessLeftDown(event); }
AmsTutorialPopup::AmsTutorialPopup(wxWindow* parent)
:wxPopupTransientWindow(parent, wxBORDER_NONE)
{
Bind(wxEVT_PAINT, &AmsTutorialPopup::paintEvent, this);
SetBackgroundColour(*wxWHITE);
wxBoxSizer* sizer_main;
sizer_main = new wxBoxSizer(wxVERTICAL);
text_title = new Label(this, Label::Head_14, _L("Config which AMS slot should be used for a filament used in the print job"));
text_title->SetSize(wxSize(FromDIP(350), -1));
text_title->Wrap(FromDIP(350));
sizer_main->Add(text_title, 0, wxALIGN_CENTER | wxTOP, 18);
sizer_main->Add(0, 0, 0, wxTOP, 30);
wxBoxSizer* sizer_top;
sizer_top = new wxBoxSizer(wxHORIZONTAL);
img_top = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap("ams_item_examples", this, 30), wxDefaultPosition, wxSize(FromDIP(50), FromDIP(30)), 0);
sizer_top->Add(img_top, 0, wxALIGN_CENTER, 0);
sizer_top->Add(0, 0, 0, wxLEFT, 10);
wxBoxSizer* sizer_top_tips = new wxBoxSizer(wxVERTICAL);
wxBoxSizer* sizer_tip_top = new wxBoxSizer(wxHORIZONTAL);
arrows_top = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap("ams_arrow", this, 8), wxDefaultPosition, wxSize(FromDIP(24), FromDIP(8)), 0);
sizer_tip_top->Add(arrows_top, 0, wxALIGN_CENTER, 0);
tip_top = new wxStaticText(this, wxID_ANY, _L("Filament used in this print job"), wxDefaultPosition, wxDefaultSize, 0);
tip_top->SetForegroundColour(wxColour("#686868"));
sizer_tip_top->Add(tip_top, 0, wxALL, 0);
sizer_top_tips->Add(sizer_tip_top, 0, wxEXPAND, 0);
sizer_top_tips->Add(0, 0, 0, wxTOP, 6);
wxBoxSizer* sizer_tip_bottom = new wxBoxSizer(wxHORIZONTAL);
arrows_bottom = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap("ams_arrow", this, 8), wxDefaultPosition, wxSize(FromDIP(24), FromDIP(8)), 0);
tip_bottom = new wxStaticText(this, wxID_ANY, _L("AMS slot used for this filament"), wxDefaultPosition, wxDefaultSize, 0);
tip_bottom->SetForegroundColour(wxColour("#686868"));
sizer_tip_bottom->Add(arrows_bottom, 0, wxALIGN_CENTER, 0);
sizer_tip_bottom->Add(tip_bottom, 0, wxALL, 0);
sizer_top_tips->Add(sizer_tip_bottom, 0, wxEXPAND, 0);
sizer_top->Add(sizer_top_tips, 0, wxALIGN_CENTER, 0);
wxBoxSizer* sizer_middle = new wxBoxSizer(wxHORIZONTAL);
img_middle= new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap("ams_item_examples", this, 30), wxDefaultPosition, wxSize(FromDIP(50), FromDIP(30)), 0);
sizer_middle->Add(img_middle, 0, wxALIGN_CENTER, 0);
tip_middle = new wxStaticText(this, wxID_ANY, _L("Click to select AMS slot manually"), wxDefaultPosition, wxDefaultSize, 0);
tip_middle->SetForegroundColour(wxColour("#686868"));
sizer_middle->Add(0, 0, 0,wxLEFT, 15);
sizer_middle->Add(tip_middle, 0, wxALIGN_CENTER, 0);
sizer_main->Add(sizer_top, 0, wxLEFT, 40);
sizer_main->Add(0, 0, 0, wxTOP, 10);
sizer_main->Add(sizer_middle, 0, wxLEFT, 40);
sizer_main->Add(0, 0, 0, wxTOP, 10);
img_botton = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap("ams_mapping_examples", this, 87), wxDefaultPosition, wxDefaultSize, 0);
sizer_main->Add(img_botton, 0, wxLEFT | wxRIGHT, 40);
sizer_main->Add(0, 0, 0, wxTOP, 12);
SetSizer(sizer_main);
Layout();
Fit();
}
void AmsTutorialPopup::paintEvent(wxPaintEvent& evt)
{
wxPaintDC dc(this);
dc.SetPen(wxColour(0xAC, 0xAC, 0xAC));
dc.SetBrush(*wxTRANSPARENT_BRUSH);
dc.DrawRoundedRectangle(0, 0, GetSize().x, GetSize().y, 0);
}
void AmsTutorialPopup::OnDismiss() {}
bool AmsTutorialPopup::ProcessLeftDown(wxMouseEvent& event) {
return wxPopupTransientWindow::ProcessLeftDown(event);
}
}} // namespace Slic3r::GUI

View file

@ -158,6 +158,27 @@ public:
wxStaticText * m_tip_disable_ams;
};
class AmsTutorialPopup : public wxPopupTransientWindow
{
public:
Label* text_title;
wxStaticBitmap* img_top;
wxStaticBitmap* arrows_top;
wxStaticText* tip_top;
wxStaticBitmap* arrows_bottom;
wxStaticText* tip_bottom;
wxStaticBitmap* img_middle;
wxStaticText* tip_middle;
wxStaticBitmap* img_botton;
AmsTutorialPopup(wxWindow* parent);
~AmsTutorialPopup() {};
void paintEvent(wxPaintEvent& evt);
virtual void OnDismiss() wxOVERRIDE;
virtual bool ProcessLeftDown(wxMouseEvent& event) wxOVERRIDE;
};
wxDECLARE_EVENT(EVT_SET_FINISH_MAPPING, wxCommandEvent);

View file

@ -3129,6 +3129,14 @@ void GUI_App::load_gcode(wxWindow* parent, wxString& input_file) const
input_file = dialog.GetPath();
}
wxString GUI_App::transition_tridid(int trid_id)
{
wxString maping_dict[8] = { "A", "B", "C", "D", "E", "F", "G" };
int id_index = ceil(trid_id / 4);
int id_suffix = (trid_id + 1) % 4 == 0 ? 4 : (trid_id + 1) % 4;
return wxString::Format("%s%d", maping_dict[id_index], id_suffix);
}
//BBS
void GUI_App::request_login(bool show_user_info)
{

View file

@ -364,6 +364,7 @@ public:
void import_model(wxWindow *parent, wxArrayString& input_files) const;
void load_gcode(wxWindow* parent, wxString& input_file) const;
wxString transition_tridid(int trid_id);
void ShowUserGuide();
void ShowDownNetPluginDlg();
void ShowUserLogin();

View file

@ -146,7 +146,8 @@ void PrintJob::process()
BBL::PrintParams params;
params.dev_id = m_dev_id;
params.project_name = project_name;
//params.project_name = project_name;
params.project_name = m_project_name + ".gcode.3mf";
params.preset_name = wxGetApp().preset_bundle->prints.get_selected_preset_name();
params.filename = job_data._3mf_path.string();
params.config_filename = job_data._3mf_config_path.string();
@ -339,4 +340,9 @@ void PrintJob::finalize() {
Job::finalize();
}
void PrintJob::set_project_name(std::string name)
{
m_project_name = name;
}
}} // namespace Slic3r::GUI

View file

@ -37,7 +37,7 @@ protected:
public:
PrintJob(std::shared_ptr<ProgressIndicator> pri, Plater *plater, std::string dev_id = "");
std::string m_project_name;
std::string m_dev_ip;
std::string m_access_code;
std::string task_bed_type;
@ -75,6 +75,7 @@ public:
wxString get_http_error_msg(unsigned int status, std::string body);
void process() override;
void finalize() override;
void set_project_name(std::string name);
};
}} // namespace Slic3r::GUI

View file

@ -150,9 +150,7 @@ void SendJob::process()
BBL::PrintParams params;
params.dev_id = m_dev_id;
//params.project_name = wxGetApp().plater()->get_project_name().ToUTF8().data();
params.project_name = wxGetApp().plater()->get_project_name().utf8_string();
params.project_name = m_project_name + ".gcode.3mf";
params.preset_name = wxGetApp().preset_bundle->prints.get_selected_preset_name();
params.filename = job_data._3mf_path.string();
params.config_filename = job_data._3mf_config_path.string();
@ -327,4 +325,9 @@ void SendJob::finalize() {
Job::finalize();
}
void SendJob::set_project_name(std::string name)
{
m_project_name = name;
}
}} // namespace Slic3r::GUI

View file

@ -30,7 +30,7 @@ protected:
public:
SendJob(std::shared_ptr<ProgressIndicator> pri, Plater *plater, std::string dev_id = "");
std::string m_project_name;
std::string m_dev_ip;
std::string m_access_code;
std::string task_bed_type;
@ -53,6 +53,7 @@ public:
void process() override;
void on_success(std::function<void()> success);
void finalize() override;
void set_project_name(std::string name);
};
}}

View file

@ -922,6 +922,7 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
, m_plater(plater), m_export_3mf_cancel(false)
, m_mapping_popup(AmsMapingPopup(this))
, m_mapping_tip_popup(AmsMapingTipPopup(this))
, m_mapping_tutorial_popup(AmsTutorialPopup(this))
{
#ifdef __WINDOWS__
SetDoubleBuffered(true);
@ -954,6 +955,73 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
m_scrollable_region = new wxPanel(m_scrollable_view, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
m_sizer_scrollable_region = new wxBoxSizer(wxVERTICAL);
//rename normal
m_rename_switch_panel = new wxSimplebook(m_scrollable_region);
m_rename_switch_panel->SetSize(wxSize(FromDIP(420), FromDIP(25)));
m_rename_switch_panel->SetMinSize(wxSize(FromDIP(420), FromDIP(25)));
m_rename_switch_panel->SetMaxSize(wxSize(FromDIP(420), FromDIP(25)));
m_rename_normal_panel = new wxPanel(m_rename_switch_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
m_rename_normal_panel->SetBackgroundColour(*wxWHITE);
rename_sizer_v = new wxBoxSizer(wxVERTICAL);
rename_sizer_h = new wxBoxSizer(wxHORIZONTAL);
m_rename_text = new wxStaticText(m_rename_normal_panel, wxID_ANY, wxT("MyLabel"), wxDefaultPosition, wxDefaultSize, 0);
m_rename_text->SetFont(::Label::Body_13);
m_rename_text->SetMaxSize(wxSize(FromDIP(390), -1));
m_rename_button = new Button(m_rename_normal_panel, "", "ams_editable", wxBORDER_NONE, FromDIP(10));
m_rename_button->SetBackgroundColor(*wxWHITE);
m_rename_button->SetBackgroundColour(*wxWHITE);
rename_sizer_h->Add(m_rename_text, 0, wxALIGN_CENTER, 0);
rename_sizer_h->Add(m_rename_button, 0, wxALIGN_CENTER, 0);
rename_sizer_v->Add(rename_sizer_h, 1, wxALIGN_CENTER, 0);
m_rename_normal_panel->SetSizer(rename_sizer_v);
m_rename_normal_panel->Layout();
rename_sizer_v->Fit(m_rename_normal_panel);
//rename edit
auto m_rename_edit_panel = new wxPanel(m_rename_switch_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
m_rename_edit_panel->SetBackgroundColour(*wxWHITE);
auto rename_edit_sizer_v = new wxBoxSizer(wxVERTICAL);
m_rename_input = new ::TextInput(m_rename_edit_panel, wxEmptyString, wxEmptyString, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);
m_rename_input->GetTextCtrl()->SetFont(::Label::Body_13);
m_rename_input->SetSize(wxSize(FromDIP(380), FromDIP(24)));
m_rename_input->SetMinSize(wxSize(FromDIP(380), FromDIP(24)));
m_rename_input->SetMaxSize(wxSize(FromDIP(380), FromDIP(24)));
rename_edit_sizer_v->Add(m_rename_input, 1, wxALIGN_CENTER, 0);
m_rename_edit_panel->SetSizer(rename_edit_sizer_v);
m_rename_edit_panel->Layout();
rename_edit_sizer_v->Fit(m_rename_edit_panel);
m_rename_input->Bind(wxEVT_TEXT_ENTER, &SelectMachineDialog::on_rename_enter, this);
m_rename_button->Bind(wxEVT_BUTTON, &SelectMachineDialog::on_rename_click, this);
m_rename_switch_panel->AddPage(m_rename_normal_panel, wxEmptyString, true);
m_rename_switch_panel->AddPage(m_rename_edit_panel, wxEmptyString, false);
Bind(wxEVT_CHAR_HOOK, [this](wxKeyEvent& e) {
if (e.GetKeyCode() == WXK_ESCAPE) {
if (m_rename_switch_panel->GetSelection() == 0) {
e.Skip();
}
else {
m_rename_switch_panel->SetSelection(0);
m_rename_text->SetLabel(m_current_project_name);
m_rename_normal_panel->Layout();
}
}
else {
e.Skip();
}
});
m_panel_image = new wxPanel(m_scrollable_region, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
m_panel_image->SetBackgroundColour(m_colour_def_color);
@ -983,7 +1051,38 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
m_sizer_basic_time->Add(m_stext_weight, 0, wxALL, FromDIP(5));
m_sizer_basic->Add(m_sizer_basic_time, 0, wxALIGN_CENTER, 0);
m_sizer_material = new wxGridSizer(0, 4, 0, 0);
auto m_sizer_material_area = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer* m_sizer_material_tips = new wxBoxSizer(wxHORIZONTAL);
auto img_amsmapping_tip = new wxStaticBitmap(m_scrollable_region, wxID_ANY, create_scaled_bitmap("enable_ams", this, 16), wxDefaultPosition, wxSize(FromDIP(16), FromDIP(16)), 0);
m_sizer_material_tips->Add(img_amsmapping_tip, 0, wxALIGN_CENTER | wxLEFT, FromDIP(5));
img_amsmapping_tip->Bind(wxEVT_ENTER_WINDOW, [this, img_amsmapping_tip](auto& e) {
wxPoint img_pos = img_amsmapping_tip->ClientToScreen(wxPoint(0, 0));
wxPoint popup_pos(img_pos.x, img_pos.y + img_amsmapping_tip->GetRect().height);
m_mapping_tutorial_popup.Position(popup_pos, wxSize(0, 0));
m_mapping_tutorial_popup.Popup();
if (m_mapping_tutorial_popup.ClientToScreen(wxPoint(0, 0)).y < img_pos.y) {
m_mapping_tutorial_popup.Dismiss();
popup_pos = wxPoint(img_pos.x, img_pos.y - m_mapping_tutorial_popup.GetRect().height);
m_mapping_tutorial_popup.Position(popup_pos, wxSize(0, 0));
m_mapping_tutorial_popup.Popup();
}
});
img_amsmapping_tip->Bind(wxEVT_LEAVE_WINDOW, [this](wxMouseEvent& e) {
m_mapping_tutorial_popup.Dismiss();
});
m_sizer_material = new wxGridSizer(0, 4, 0, FromDIP(5));
m_sizer_material_area->Add(m_sizer_material_tips, 0, wxALIGN_CENTER|wxLEFT, FromDIP(8));
m_sizer_material_area->Add(m_sizer_material, 0, wxLEFT, FromDIP(15));
m_statictext_ams_msg = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxALIGN_CENTER_HORIZONTAL);
m_statictext_ams_msg->SetFont(::Label::Body_13);
@ -1120,11 +1219,13 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater)
Bind(EVT_PRINT_JOB_CANCEL, &SelectMachineDialog::on_print_job_cancel, this);
Bind(EVT_SET_FINISH_MAPPING, &SelectMachineDialog::on_set_finish_mapping, this);
m_sizer_scrollable_region->Add(m_rename_switch_panel, 0, wxALIGN_CENTER_HORIZONTAL, 0);
m_sizer_scrollable_region->Add(0, 0, 0, wxTOP, FromDIP(8));
m_sizer_scrollable_region->Add(m_panel_image, 0, wxALIGN_CENTER_HORIZONTAL, 0);
m_sizer_scrollable_region->Add(0, 0, 0, wxTOP, FromDIP(10));
m_sizer_scrollable_region->Add(m_sizer_basic, 0, wxALIGN_CENTER_HORIZONTAL, 0);
m_sizer_scrollable_region->Add(m_sizer_material, 0, wxALIGN_CENTER_HORIZONTAL);
//m_sizer_scrollable_region->Add(m_sizer_material, 0, wxALIGN_CENTER_HORIZONTAL, 0);
m_sizer_scrollable_region->Add(m_sizer_material_area, 0, wxLEFT, FromDIP(10));
m_scrollable_region->SetSizer(m_sizer_scrollable_region);
m_scrollable_region->Layout();
@ -1342,7 +1443,8 @@ void SelectMachineDialog::sync_ams_mapping_result(std::vector<FilamentInfo> &res
wxColour ams_col;
if (f->tray_id >= 0) {
ams_id = wxString::Format("%02d", f->tray_id + 1);
ams_id = wxGetApp().transition_tridid(f->tray_id);
//ams_id = wxString::Format("%02d", f->tray_id + 1);
} else {
ams_id = "-";
}
@ -1936,6 +2038,8 @@ void SelectMachineDialog::on_ok()
m_print_job->m_dev_ip = obj_->dev_ip;
m_print_job->m_access_code = obj_->access_code;
m_print_job->connection_type = obj_->connection_type();
m_print_job->set_project_name(m_current_project_name.utf8_string());
if (obj_->is_support_ams_mapping()) {
m_print_job->task_ams_mapping = ams_mapping_array;
m_print_job->task_ams_mapping_info = ams_mapping_info;
@ -2150,6 +2254,60 @@ void SelectMachineDialog::update_user_printer()
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "for send task, current printer id = " << m_printer_last_select << std::endl;
}
void SelectMachineDialog::on_rename_click(wxCommandEvent& event)
{
m_rename_input->GetTextCtrl()->SetValue(m_current_project_name);
m_rename_switch_panel->SetSelection(1);
}
void SelectMachineDialog::on_rename_enter(wxCommandEvent& event)
{
auto new_file_name = m_rename_input->GetTextCtrl()->GetValue();
auto m_valid_type = Valid;
wxString info_line;
const char* unusable_symbols = "<>[]:/\\|?*\"";
const std::string unusable_suffix = PresetCollection::get_suffix_modified(); //"(modified)";
for (size_t i = 0; i < std::strlen(unusable_symbols); i++) {
if (new_file_name.find_first_of(unusable_symbols[i]) != std::string::npos) {
info_line = _L("Name is invalid;") + "\n" + _L("illegal characters:") + " " + unusable_symbols;
m_valid_type = NoValid;
break;
}
}
if (m_valid_type == Valid && new_file_name.find(unusable_suffix) != std::string::npos) {
info_line = _L("Name is invalid;") + "\n" + _L("illegal suffix:") + "\n\t" + from_u8(PresetCollection::get_suffix_modified());
m_valid_type = NoValid;
}
if (m_valid_type == Valid && new_file_name.empty()) {
info_line = _L("The name is not allowed to be empty.");
m_valid_type = NoValid;
}
if (m_valid_type == Valid && new_file_name.find_first_of(' ') == 0) {
info_line = _L("The name is not allowed to start with space character.");
m_valid_type = NoValid;
}
if (m_valid_type == Valid && new_file_name.find_last_of(' ') == new_file_name.length() - 1) {
info_line = _L("The name is not allowed to end with space character.");
m_valid_type = NoValid;
}
if (m_valid_type != Valid) {
MessageDialog msg_wingow(nullptr, info_line, "", wxICON_WARNING | wxOK);
if (msg_wingow.ShowModal() == wxOK) { return; }
}
m_current_project_name = new_file_name;
m_rename_switch_panel->SetSelection(0);
m_rename_text->SetLabel(m_current_project_name);
m_rename_normal_panel->Layout();
}
void SelectMachineDialog::update_printer_combobox(wxCommandEvent &event)
{
show_status(PrintDialogStatus::PrintStatusInit);
@ -2454,6 +2612,20 @@ wxImage *SelectMachineDialog::LoadImageFromBlob(const unsigned char *data, int s
void SelectMachineDialog::set_default()
{
//project name
m_rename_switch_panel->SetSelection(0);
wxString filename = m_plater->get_export_gcode_filename("", false);
if (filename.empty()) {
filename = m_plater->get_export_gcode_filename("", true);
}
fs::path filename_path(filename.c_str());
m_current_project_name = wxString::FromUTF8(filename_path.filename().string());
m_rename_text->SetLabelText(m_current_project_name);
m_rename_normal_panel->Layout();
//clear combobox
m_list.clear();
m_comboBox_printer->Clear();
@ -2520,8 +2692,6 @@ void SelectMachineDialog::set_default()
}
// material info
//auto extruders1 = m_plater->get_partplate_list().get_curr_plate()->get_extruders();
auto extruders = wxGetApp().plater()->get_preview_canvas3D()->get_gcode_viewer().get_plater_extruder();
BitmapCache bmcache;
@ -2536,7 +2706,6 @@ void SelectMachineDialog::set_default()
m_sizer_material->Clear();
m_materialList.clear();
m_filaments.clear();
for (auto i = 0; i < extruders.size(); i++) {
@ -2548,6 +2717,16 @@ void SelectMachineDialog::set_default()
auto colour_rgb = wxColour((int) rgb[0], (int) rgb[1], (int) rgb[2]);
if (extruder >= materials.size() || extruder < 0 || extruder >= display_materials.size())
continue;
/* if (m_materialList.size() == 0) {
auto tips_panel = new wxPanel(m_scrollable_region, wxID_ANY);
tips_panel->SetSize(wxSize(60,40));
tips_panel->SetMinSize(wxSize(60,40));
tips_panel->SetMaxSize(wxSize(60,40));
tips_panel->SetBackgroundColour(*wxRED);
m_sizer_material->Add(tips_panel, 0, wxALL, FromDIP(4));
}*/
MaterialItem *item = new MaterialItem(m_scrollable_region, colour_rgb, _L(display_materials[extruder]));
m_sizer_material->Add(item, 0, wxALL, FromDIP(4));

View file

@ -292,6 +292,14 @@ protected:
wxPanel * m_line_materia{nullptr};
wxStaticText *m_stext_printer_title{nullptr};
wxBoxSizer* rename_sizer_v{ nullptr };
wxBoxSizer* rename_sizer_h{ nullptr };
wxStaticText* m_rename_text{nullptr};
TextInput* m_rename_input{nullptr};
Button* m_rename_button{nullptr};
wxPanel* m_rename_normal_panel{nullptr};
wxSimplebook* m_rename_switch_panel{nullptr};
wxStaticText *m_statictext_ams_msg{nullptr};
wxStaticText * m_statictext_printer_msg{nullptr};
wxStaticBitmap* m_staticbitmap {nullptr};
@ -380,7 +388,8 @@ protected:
wxButton * m_button_cancel{nullptr};
AmsMapingPopup m_mapping_popup{nullptr};
AmsMapingTipPopup m_mapping_tip_popup{nullptr};
AmsTutorialPopup m_mapping_tutorial_popup{nullptr};
wxString m_current_project_name;
std::string m_print_info;
int timeout_count = 0;
bool is_timeout();
@ -395,6 +404,9 @@ protected:
std::shared_ptr<PrintJob> m_print_job;
// Virtual event handlers, overide them in your derived class
void on_rename_click(wxCommandEvent &event);
void on_rename_enter(wxCommandEvent &event);
void update_printer_combobox(wxCommandEvent &event);
void on_cancel(wxCloseEvent &event);
void on_ok_btn(wxCommandEvent &event);

View file

@ -31,6 +31,7 @@ wxDEFINE_EVENT(EVT_UPDATE_USER_MACHINE_LIST, wxCommandEvent);
wxDEFINE_EVENT(EVT_PRINT_JOB_CANCEL, wxCommandEvent);
wxDEFINE_EVENT(EVT_SEND_JOB_SUCCESS, wxCommandEvent);
void SendToPrinterDialog::stripWhiteSpace(std::string& str)
{
if (str == "") { return; }
@ -70,6 +71,72 @@ wxString SendToPrinterDialog::format_text(wxString &m_msg)
return out_txt;
}
void SendToPrinterDialog::on_kill_focus(wxFocusEvent& event)
{
if (m_rename_switch_panel->GetSelection() == 1) {
m_rename_switch_panel->SetSelection(0);
m_rename_text->SetLabel(m_current_project_name);
m_rename_normal_panel->Layout();
}
event.Skip();
}
void SendToPrinterDialog::on_rename_click(wxCommandEvent& event)
{
m_rename_input->GetTextCtrl()->SetValue(m_current_project_name);
m_rename_switch_panel->SetSelection(1);
m_rename_input->GetTextCtrl()->SetFocus();
}
void SendToPrinterDialog::on_rename_enter(wxCommandEvent& event)
{
auto new_file_name = m_rename_input->GetTextCtrl()->GetValue();
auto m_valid_type = Valid;
wxString info_line;
const char* unusable_symbols = "<>[]:/\\|?*\"";
const std::string unusable_suffix = PresetCollection::get_suffix_modified(); //"(modified)";
for (size_t i = 0; i < std::strlen(unusable_symbols); i++) {
if (new_file_name.find_first_of(unusable_symbols[i]) != std::string::npos) {
info_line = _L("Name is invalid;") + "\n" + _L("illegal characters:") + " " + unusable_symbols;
m_valid_type = NoValid;
break;
}
}
if (m_valid_type == Valid && new_file_name.find(unusable_suffix) != std::string::npos) {
info_line = _L("Name is invalid;") + "\n" + _L("illegal suffix:") + "\n\t" + from_u8(PresetCollection::get_suffix_modified());
m_valid_type = NoValid;
}
if (m_valid_type == Valid && new_file_name.empty()) {
info_line = _L("The name is not allowed to be empty.");
m_valid_type = NoValid;
}
if (m_valid_type == Valid && new_file_name.find_first_of(' ') == 0) {
info_line = _L("The name is not allowed to start with space character.");
m_valid_type = NoValid;
}
if (m_valid_type == Valid && new_file_name.find_last_of(' ') == new_file_name.length() - 1) {
info_line = _L("The name is not allowed to end with space character.");
m_valid_type = NoValid;
}
if (m_valid_type != Valid) {
MessageDialog msg_wingow(nullptr, info_line, "", wxICON_WARNING | wxOK);
if (msg_wingow.ShowModal() == wxOK) { return; }
}
m_current_project_name = new_file_name;
m_rename_switch_panel->SetSelection(0);
m_rename_text->SetLabel(m_current_project_name);
m_rename_normal_panel->Layout();
}
SendToPrinterDialog::SendToPrinterDialog(Plater *plater)
: DPIDialog(static_cast<wxWindow *>(wxGetApp().mainframe), wxID_ANY, _L("Send to Printer"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxCLOSE_BOX)
, m_plater(plater), m_export_3mf_cancel(false)
@ -237,20 +304,86 @@ SendToPrinterDialog::SendToPrinterDialog(Plater *plater)
m_scrollable_region->SetSizer(m_sizer_scrollable_region);
m_scrollable_region->Layout();
//file name
//rename normal
m_rename_switch_panel = new wxSimplebook(this);
m_rename_switch_panel->SetSize(wxSize(FromDIP(420), FromDIP(25)));
m_rename_switch_panel->SetMinSize(wxSize(FromDIP(420), FromDIP(25)));
m_rename_switch_panel->SetMaxSize(wxSize(FromDIP(420), FromDIP(25)));
m_rename_normal_panel = new wxPanel(m_rename_switch_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
m_rename_normal_panel->SetBackgroundColour(*wxWHITE);
rename_sizer_v = new wxBoxSizer(wxVERTICAL);
rename_sizer_h = new wxBoxSizer(wxHORIZONTAL);
m_rename_text = new wxStaticText(m_rename_normal_panel, wxID_ANY, wxT("MyLabel"), wxDefaultPosition, wxDefaultSize, 0);
m_rename_text->SetFont(::Label::Body_13);
m_rename_text->SetMaxSize(wxSize(FromDIP(390), -1));
m_rename_button = new Button(m_rename_normal_panel, "", "ams_editable", wxBORDER_NONE, FromDIP(10));
m_rename_button->SetBackgroundColor(*wxWHITE);
m_rename_button->SetBackgroundColour(*wxWHITE);
rename_sizer_h->Add(m_rename_text, 0, wxALIGN_CENTER, 0);
rename_sizer_h->Add(m_rename_button, 0, wxALIGN_CENTER, 0);
rename_sizer_v->Add(rename_sizer_h, 1, wxALIGN_CENTER, 0);
m_rename_normal_panel->SetSizer(rename_sizer_v);
m_rename_normal_panel->Layout();
rename_sizer_v->Fit(m_rename_normal_panel);
//rename edit
auto m_rename_edit_panel = new wxPanel(m_rename_switch_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
m_rename_edit_panel->SetBackgroundColour(*wxWHITE);
auto rename_edit_sizer_v = new wxBoxSizer(wxVERTICAL);
m_rename_input = new ::TextInput(m_rename_edit_panel, wxEmptyString, wxEmptyString, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);
m_rename_input->GetTextCtrl()->SetFont(::Label::Body_13);
m_rename_input->SetSize(wxSize(FromDIP(380), FromDIP(24)));
m_rename_input->SetMinSize(wxSize(FromDIP(380), FromDIP(24)));
m_rename_input->SetMaxSize(wxSize(FromDIP(380), FromDIP(24)));
rename_edit_sizer_v->Add(m_rename_input, 1, wxALIGN_CENTER, 0);
m_rename_edit_panel->SetSizer(rename_edit_sizer_v);
m_rename_edit_panel->Layout();
rename_edit_sizer_v->Fit(m_rename_edit_panel);
m_rename_input->GetTextCtrl()->Bind(wxEVT_KILL_FOCUS, &SendToPrinterDialog::on_kill_focus, this);
m_rename_input->Bind(wxEVT_TEXT_ENTER, &SendToPrinterDialog::on_rename_enter, this);
m_rename_button->Bind(wxEVT_BUTTON, &SendToPrinterDialog::on_rename_click, this);
m_rename_switch_panel->AddPage(m_rename_normal_panel, wxEmptyString, true);
m_rename_switch_panel->AddPage(m_rename_edit_panel, wxEmptyString, false);
Bind(wxEVT_CHAR_HOOK, [this](wxKeyEvent& e) {
if (e.GetKeyCode() == WXK_ESCAPE) {
if (m_rename_switch_panel->GetSelection() == 0) {
e.Skip();
}
else {
m_rename_switch_panel->SetSelection(0);
m_rename_text->SetLabel(m_current_project_name);
m_rename_normal_panel->Layout();
}
}
else {
e.Skip();
}
});
m_sizer_main->Add(m_line_top, 0, wxEXPAND, 0);
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(0, 0, 0, wxEXPAND | wxTOP, FromDIP(8));
m_sizer_main->Add(m_rename_switch_panel, 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(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(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(13));
m_sizer_main->Add(m_statictext_printer_msg, 0, wxALIGN_CENTER_HORIZONTAL, 0);
m_sizer_main->Add(0, 1, 0, wxTOP, FromDIP(20));
m_sizer_main->Add(0, 1, 0, wxTOP, FromDIP(12));
m_sizer_main->Add(0, 1, 0, wxTOP, FromDIP(32));
m_sizer_main->Add(m_line_schedule, 0, wxEXPAND | wxLEFT | wxRIGHT, FromDIP(30));
m_sizer_main->Add(m_simplebook, 0, wxALIGN_CENTER_HORIZONTAL, 0);
m_sizer_main->Add(m_sizer_bottom, 0, wxALIGN_CENTER_HORIZONTAL);
@ -485,6 +618,7 @@ void SendToPrinterDialog::on_ok(wxCommandEvent &event)
m_send_job->connection_type = obj_->connection_type();
m_send_job->cloud_print_only = true;
m_send_job->has_sdcard = obj_->has_sdcard();
m_send_job->set_project_name(m_current_project_name.utf8_string());
m_send_job->on_success([this]() {
@ -896,6 +1030,19 @@ void SendToPrinterDialog::on_dpi_changed(const wxRect &suggested_rect)
void SendToPrinterDialog::set_default()
{
//project name
m_rename_switch_panel->SetSelection(0);
wxString filename = m_plater->get_export_gcode_filename("", false);
if (filename.empty()) {
filename = m_plater->get_export_gcode_filename("", true);
}
fs::path filename_path(filename.c_str());
m_current_project_name = wxString::FromUTF8(filename_path.filename().string());
m_rename_text->SetLabelText(m_current_project_name);
m_rename_normal_panel->Layout();
enable_prepare_mode = true;
prepare_mode();

View file

@ -60,6 +60,14 @@ private:
wxColour m_colour_bold_color{ wxColour(38, 46, 48) };
protected:
wxString m_current_project_name;
wxBoxSizer* rename_sizer_v{ nullptr };
wxBoxSizer* rename_sizer_h{ nullptr };
wxStaticText* m_rename_text{ nullptr };
TextInput* m_rename_input{ nullptr };
Button* m_rename_button{ nullptr };
wxPanel* m_rename_normal_panel{ nullptr };
wxSimplebook* m_rename_switch_panel{ nullptr };
Plater* m_plater{ nullptr };
wxPanel* m_line_top{ nullptr };
wxPanel* m_panel_image{ nullptr };
@ -98,6 +106,9 @@ protected:
wxPanel* m_scrollable_region;
wxBoxSizer* m_sizer_scrollable_region;
void on_kill_focus(wxFocusEvent& event);
void on_rename_click(wxCommandEvent& event);
void on_rename_enter(wxCommandEvent& event);
void stripWhiteSpace(std::string& str);
wxString format_text(wxString& m_msg);