fix some bug

This commit is contained in:
QIDI TECH
2025-02-25 10:53:15 +08:00
parent afc204307c
commit 1957136227
25 changed files with 1087 additions and 132 deletions

View File

@@ -3623,6 +3623,7 @@ void GUI_App::check_printer_presets()
void switch_window_pools();
void release_window_pools();
//y54
void GUI_App::recreate_GUI(const wxString &msg_name)
{
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "recreate_GUI enter";
@@ -3632,6 +3633,7 @@ void GUI_App::recreate_GUI(const wxString &msg_name)
// y19
mainframe->m_printer_view->StopStatusThread();
mainframe->shutdown();
ProgressDialog dlg(msg_name, msg_name, 100, nullptr, wxPD_AUTO_HIDE);
dlg.Pulse();
dlg.Update(10, _L("Rebuild") + dots);

View File

@@ -86,7 +86,6 @@ std::map<std::string, std::vector<SimpleSettingData>> SettingsFactory::OBJECT_C
{ L("Support"), {{"brim_type", "",1},{"brim_width", "",2},{"brim_object_gap", "",3},
{"enable_support", "",4},{"support_type", "",5},{"support_threshold_angle", "",6},{"support_on_build_plate_only", "",7},
{"support_filament", "",8},{"support_interface_filament", "",9},{"support_expansion", "",24},{"support_style", "",25},
//1.9.5
{"tree_support_branch_angle", "",10}, {"tree_support_wall_count", "",11},{"tree_support_branch_diameter_angle", "",11},//tree support
{"support_top_z_distance", "",13},{"support_bottom_z_distance", "",12},{"support_base_pattern", "",14},{"support_base_pattern_spacing", "",15},
{"support_interface_top_layers", "",16},{"support_interface_bottom_layers", "",17},{"support_interface_spacing", "",18},{"support_bottom_interface_spacing", "",19},
@@ -106,7 +105,6 @@ std::map<std::string, std::vector<SimpleSettingData>> SettingsFactory::PART_CAT
{"infill_combination", "",1}, {"infill_wall_overlap", "",1}, {"infill_direction", "",1}, {"bridge_angle", "",1},{"minimum_sparse_infill_area", "",1}
}},
{ L("Speed"), {{"outer_wall_speed", "",1},{"inner_wall_speed", "",2},{"sparse_infill_speed", "",3},{"top_surface_speed", "",4}, {"internal_solid_infill_speed", "",5},
//1.9.5
{"enable_overhang_speed", "",6}, {"overhang_1_4_speed", "",7}, {"overhang_2_4_speed", "",8}, {"overhang_3_4_speed", "",9}, {"overhang_4_4_speed", "",10}, {"overhang_totally_speed", "",11},
{"bridge_speed", "",12}, {"gap_infill_speed", "",13}
}}
@@ -544,7 +542,6 @@ void MenuFactory::append_menu_item_edit_svg(wxMenu *menu)
append_menu_item(menu, wxID_ANY, name, description, open_svg, icon, nullptr, can_edit_svg, m_parent);
}
wxMenu* MenuFactory::append_submenu_add_generic(wxMenu* menu, ModelVolumeType type) {
auto sub_menu = new wxMenu;

View File

@@ -628,7 +628,8 @@ void GLGizmoBrimEars::on_render_input_window(float x, float y, float bottom_limi
if (glb_cfg.opt_enum<BrimType>("brim_type") != btBrimEars) {
ImGui::SameLine();
auto link_text = [&]() {
ImColor HyperColor = m_link_text_hover ? ImColor(0, 240, 91).Value : ImColor(0, 174, 66).Value;
//y54
ImColor HyperColor = m_link_text_hover ? ImColor(80, 140, 255).Value : ImColor(50, 100, 230).Value;
ImGui::PushStyleColor(ImGuiCol_Text, ImGuiWrapper::to_ImVec4(ColorRGB::WARNING()));
float parent_width = ImGui::GetContentRegionAvail().x;
m_imgui->text_wrapped(_L("Warning: The brim type is not set to \"painted\",the brim ears will not take effect !"), parent_width);

View File

@@ -68,7 +68,9 @@
#include <slic3r/GUI/CreatePresetsDialog.hpp>
//y
#ifdef QDT_RELEASE_TO_PUBLIC
#include "../QIDI/QIDINetwork.hpp"
#endif
namespace Slic3r {
namespace GUI {
@@ -687,6 +689,33 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, BORDERLESS_FRAME_
wxGetApp().persist_window_geometry(this, true);
wxGetApp().persist_window_geometry(&m_settings_dialog, true);
//53
Bind(wxEVT_ICONIZE, [this](wxIconizeEvent& event) {
if (event.IsIconized()) {
if (m_printer_view->GetHasLoadUrl()) {
printer_view_ip = m_printer_view->GetWebIp();
printer_view_url = m_printer_view->GetWeburl();
}
wxString url;
if (m_printer_view->GetNetMode()) {
url = wxString::Format("file://%s/web/qidi/link_missing_connection.html", from_u8(resources_dir()));
}
else {
url = wxString::Format("file://%s/web/qidi/missing_connection.html", from_u8(resources_dir()));
}
m_printer_view->load_disconnect_url(url);
}
else {
if (!printer_view_ip.empty() && new_sel == tpMonitor) {
if (is_net_url)
m_printer_view->load_net_url(printer_view_url, printer_view_ip);
else
m_printer_view->load_url(printer_view_url);
}
m_printer_view->Layout();
}
});
}
#ifdef __WIN32__
@@ -1031,7 +1060,9 @@ void MainFrame::init_tabpanel()
m_tabpanel->Bind(wxEVT_NOTEBOOK_PAGE_CHANGING, [this](wxBookCtrlEvent& e) {
int old_sel = e.GetOldSelection();
int new_sel = e.GetSelection();
//y53
new_sel = e.GetSelection();
if (wxGetApp().preset_bundle &&
wxGetApp().preset_bundle->printers.get_edited_preset().is_qdt_vendor_preset(wxGetApp().preset_bundle) &&
new_sel == tpMonitor) {
@@ -1061,34 +1092,15 @@ void MainFrame::init_tabpanel()
m_confirm_download_plugin_dlg->on_show();
}
}
//y
else if (new_sel == tpMonitor && wxGetApp().preset_bundle != nullptr) {
// auto cfg = wxGetApp().preset_bundle->printers.get_edited_preset().config;
//wxString url;
//if (cfg.has("print_host_webui") && !cfg.opt_string("print_host_webui").empty()) {
// url = cfg.opt_string("print_host_webui");
//} else if (cfg.has("print_host") && !cfg.opt_string("print_host").empty()) {
// url = cfg.opt_string("print_host");
//}
//else {
// ;
//}
// y24
// wxString url = m_printer_view->GetWeburl();
// y3 //y13 //y23 //y24
// if (url.empty()) {
// if (m_printer_view->GetNetMode()) {
// url = wxString::Format("file://%s/web/qidi/link_missing_connection.html", from_u8(resources_dir()));
// }
// else {
// url = wxString::Format("file://%s/web/qidi/missing_connection.html", from_u8(resources_dir()));
// }
// }
// m_printer_view->load_url(url);
// y28
m_printer_view->Layout();
//y53
if(!printer_view_ip.empty()){
if (is_net_url)
m_printer_view->load_net_url(printer_view_url, printer_view_ip);
else
m_printer_view->load_url(printer_view_url);
}
m_printer_view->Layout();
}
else if(new_sel == tpCalibration && wxGetApp().preset_bundle != nullptr)
{
@@ -1096,6 +1108,22 @@ void MainFrame::init_tabpanel()
m_calibration->m_filament_choice->update();
m_calibration->m_print_choice->update();
}
//y53
else if (new_sel != tpMonitor){
if(m_printer_view->GetHasLoadUrl()){
printer_view_ip = m_printer_view->GetWebIp();
printer_view_url = m_printer_view->GetWeburl();
is_net_url = m_printer_view->IsNetUrl();
}
wxString url;
if (m_printer_view->GetNetMode()) {
url = wxString::Format("file://%s/web/qidi/link_missing_connection.html", from_u8(resources_dir()));
}
else {
url = wxString::Format("file://%s/web/qidi/missing_connection.html", from_u8(resources_dir()));
}
m_printer_view->load_disconnect_url(url);
}
});
#ifdef __WXMSW__
@@ -2283,6 +2311,60 @@ static wxMenu* generate_help_menu()
// });
// About
//y54
append_menu_item(helpMenu, wxID_ANY, _L("Clean the Webview Cache" ), _L("Clean the Webview Cache" ), [](wxCommandEvent&) {
CleanCacheDialog* dlg = new CleanCacheDialog(static_cast<wxWindow*>(wxGetApp().mainframe));
int res = dlg->ShowModal();
if (res == wxID_OK) {
#ifdef _WIN32
wxString local_path = wxStandardPaths::Get().GetUserLocalDataDir();
wxString command = wxString::Format("explorer %s", local_path);
if (fs::exists(into_u8(local_path))) {
BOOST_LOG_TRIVIAL(error) << boost::format("The path is Exitsts : %1%") % local_path;
wxExecute(command);
wxPostEvent(wxGetApp().mainframe, wxCloseEvent(wxEVT_CLOSE_WINDOW));
}
else {
wxMessageBox(_L("The path is not exists!"), "Error", wxICON_ERROR | wxOK);
BOOST_LOG_TRIVIAL(error) << boost::format("The path is not exitsts: %1%") % local_path;
}
#elif defined(__APPLE__)
wxString local_path = wxFileName::GetHomeDir() + "/Library/Caches";
wxString command = wxString::Format("open \"%s\"", local_path);
wxString local_path_2 = wxFileName::GetHomeDir() + "/Library/WebKit";
wxString command_2 = wxString::Format("open \"%s\"", local_path_2);
if (fs::exists(into_u8(local_path)) && fs::exists(into_u8(local_path_2))) {
BOOST_LOG_TRIVIAL(error) << boost::format("The path is Exitsts : %1%") % local_path;
wxExecute(command);
wxExecute(command_2);
wxPostEvent(wxGetApp().mainframe, wxCloseEvent(wxEVT_CLOSE_WINDOW));
}
else {
wxMessageBox(_L("The path is not exists!"), "Error", wxICON_ERROR | wxOK);
BOOST_LOG_TRIVIAL(error) << boost::format("The path is not exitsts: %1%") % local_path;
}
#elif defined __linux__
wxString local_path = wxFileName::GetHomeDir() + "/.local/share";
wxString command = wxString::Format("xdg-open \"%s\"", local_path);
wxString local_path_2 = wxFileName::GetHomeDir() + "/.cache";
wxString command_2 = wxString::Format("xdg-open \"%s\"", local_path_2);
if (fs::exists(into_u8(local_path)) && fs::exists(into_u8(local_path_2))) {
BOOST_LOG_TRIVIAL(error) << boost::format("The path is Exitsts : %1%") % local_path;
wxExecute(command);
wxExecute(command_2);
wxPostEvent(wxGetApp().mainframe, wxCloseEvent(wxEVT_CLOSE_WINDOW));
}
else {
wxMessageBox(_L("The path is not exists!"), "Error", wxICON_ERROR | wxOK);
BOOST_LOG_TRIVIAL(error) << boost::format("The path is not exitsts: %1%") % local_path;
}
#endif
}
dlg->Destroy();
});
#ifndef __APPLE__
wxString about_title = wxString::Format(_L("&About %s"), SLIC3R_APP_FULL_NAME);
append_menu_item(helpMenu, wxID_ANY, about_title, about_title,
@@ -4063,6 +4145,5 @@ void SettingsDialog::on_dpi_changed(const wxRect& suggested_rect)
Refresh();
}
} // GUI
} // Slic3r

View File

@@ -416,6 +416,12 @@ public:
int select_device_page_count{ 0 };
//y53
wxString printer_view_url = "";
wxString printer_view_ip = "";
bool is_net_url = false;
int new_sel;
#ifdef __APPLE__
std::unique_ptr<wxTaskBarIcon> m_taskbar_icon;
#endif // __APPLE__

View File

@@ -717,6 +717,92 @@ NetworkErrorDialog::NetworkErrorDialog(wxWindow* parent)
Centre(wxBOTH);
}
//y54
CleanCacheDialog::CleanCacheDialog(wxWindow* parent)
: wxDialog(parent, wxID_ANY, _L("Clean the Webview Cache"), wxDefaultPosition)
{
std::string icon_path = (boost::format("%1%/images/QIDIStudioTitle.ico") % resources_dir()).str();
SetIcon(wxIcon(encode_path(icon_path.c_str()), wxBITMAP_TYPE_ICO));
wxBoxSizer* main_sizer = new wxBoxSizer(wxVERTICAL);
auto m_line_top = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 1), wxTAB_TRAVERSAL);
m_line_top->SetBackgroundColour(wxColour(0xA6, 0xa9, 0xAA));
main_sizer->Add(m_line_top, 0, wxEXPAND, 0);
main_sizer->Add(0, 0, 0, wxTOP, FromDIP(5));
wxBoxSizer* content_sizer = new wxBoxSizer(wxHORIZONTAL);
wxStaticBitmap* info_bitmap = new wxStaticBitmap(this, wxID_ANY, create_scaled_bitmap("info", nullptr, 60), wxDefaultPosition, wxSize(FromDIP(70), FromDIP(70)), 0);
content_sizer->Add(info_bitmap, 0, wxEXPAND | wxALL, FromDIP(5));
wxBoxSizer* vertical_sizer = new wxBoxSizer(wxVERTICAL);
wxStaticText* message_text = new wxStaticText(this, wxID_ANY,
_L("Click the OK button, the software will open the WebView cache folder.\n"
"You need to manually delete the WebView folder.\n"),
wxDefaultPosition);
message_text->SetForegroundColour(StateColor::darkModeColorFor(wxColour("#000000")));
vertical_sizer->Add(message_text, 0, wxEXPAND | wxTOP, FromDIP(5));
wxString hyperlink_text = "https://wiki.qidi3d.com/en/software/qidi-studio/troubleshooting/blank-page";
wxHyperlinkCtrl* hyperlink = new wxHyperlinkCtrl(this, wxID_ANY, _L("Learn more"), hyperlink_text, wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE);
vertical_sizer->Add(hyperlink, 0, wxRIGHT, FromDIP(5));
content_sizer->Add(vertical_sizer, 0, wxEXPAND | wxALL, FromDIP(5));
main_sizer->Add(content_sizer, 0, wxEXPAND | wxALL, FromDIP(10));
m_btn_bg_enable = StateColor(std::pair<wxColour, int>(wxColour(95, 82, 253), StateColor::Pressed), std::pair<wxColour, int>(wxColour(129, 150, 255), StateColor::Hovered),
std::pair<wxColour, int>(wxColour(68, 121, 251), StateColor::Normal));
Button* ok_btn = new Button(this, _L("OK"));
ok_btn->SetBackgroundColor(m_btn_bg_enable);
ok_btn->SetBorderColor(m_btn_bg_enable);
ok_btn->SetTextColor(StateColor::darkModeColorFor("#FFFFFE"));
ok_btn->SetSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE);
ok_btn->SetMinSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE);
ok_btn->SetMinSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE);
ok_btn->SetCornerRadius(FromDIP(12));
ok_btn->Enable(true);
Button* cancel_btn = new Button(this, _L("Cancel"));
cancel_btn->SetBackgroundColor(m_btn_bg_enable);
cancel_btn->SetBorderColor(m_btn_bg_enable);
cancel_btn->SetTextColor(StateColor::darkModeColorFor("#FFFFFE"));
cancel_btn->SetSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE);
cancel_btn->SetMinSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE);
cancel_btn->SetMinSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE);
cancel_btn->SetCornerRadius(FromDIP(12));
cancel_btn->Enable(true);
ok_btn->Bind(wxEVT_BUTTON, &CleanCacheDialog::OnOK, this);
cancel_btn->Bind(wxEVT_BUTTON, &CleanCacheDialog::OnCancel, this);
wxBoxSizer* hsizer_button = new wxBoxSizer(wxHORIZONTAL);
hsizer_button->AddStretchSpacer(1);
hsizer_button->Add(ok_btn, 0, wxRIGHT, FromDIP(10));
hsizer_button->AddSpacer(5);
hsizer_button->Add(cancel_btn, 0, wxRIGHT, FromDIP(10));
main_sizer->Add(hsizer_button, 0, wxEXPAND | wxBOTTOM, FromDIP(10));
this->SetSizer(main_sizer);
Layout();
Fit();
CenterOnParent();
}
CleanCacheDialog::~CleanCacheDialog(){}
void CleanCacheDialog::OnOK(wxCommandEvent& event)
{
EndModal(wxID_OK);
}
void CleanCacheDialog::OnCancel(wxCommandEvent& event)
{
EndModal(wxID_CANCEL);
}
} // namespace GUI
} // namespace Slic3r

View File

@@ -429,6 +429,22 @@ public:
bool m_show_again{false};
};
//y54
class CleanCacheDialog : public wxDialog
{
#define SELECT_MACHINE_DIALOG_BUTTON_SIZE wxSize(FromDIP(68), FromDIP(23))
#define SELECT_MACHINE_DIALOG_SIMBOOK_SIZE wxSize(FromDIP(370), FromDIP(64))
public:
CleanCacheDialog(wxWindow* parent);
~CleanCacheDialog();
void OnOK(wxCommandEvent& event);
void OnCancel(wxCommandEvent& event);
StateColor m_btn_bg_enable;
};
}
}

View File

@@ -734,7 +734,24 @@ Sidebar::Sidebar(Plater *parent)
// Bed type selection
wxBoxSizer* bed_type_sizer = new wxBoxSizer(wxHORIZONTAL);
wxStaticText* bed_type_title = new wxStaticText(p->m_panel_printer_content, wxID_ANY, _L("Bed type"));
//y52
wxStaticText* bed_type_title = new Label(p->m_panel_printer_content, _L("Bed type"));
wxFont bed_type_font = bed_type_title->GetFont();
bed_type_title->SetToolTip(_L("https://wiki.qidi3d.com/en/software/qidi-studio/print-settings/plate-type"));
bed_type_title->Bind(wxEVT_ENTER_WINDOW, [bed_type_title](wxMouseEvent& event) {
bed_type_title->SetFont(bed_type_title->GetFont().Underlined());
});
bed_type_title->Bind(wxEVT_LEAVE_WINDOW, [bed_type_title, bed_type_font](wxMouseEvent& event) {
bed_type_title->SetFont(bed_type_font);
});
bed_type_title->Bind(wxEVT_LEFT_DOWN, [](wxMouseEvent& event) {
wxLaunchDefaultBrowser("https://wiki.qidi3d.com/en/software/qidi-studio/print-settings/plate-type");
event.Skip();
});
bed_type_title->SetForegroundColour(StateColor::darkModeColorFor(wxColour("#000000")));
//bed_type_title->SetBackgroundColour();
bed_type_title->Wrap(-1);
@@ -891,9 +908,24 @@ Sidebar::Sidebar(Plater *parent)
bSizer39->Hide(p->m_flushing_volume_btn);
bSizer39->Add(FromDIP(10), 0, 0, 0, 0 );
//w13
//w13 y52
wxBoxSizer* hbox = new wxBoxSizer(wxHORIZONTAL);
wxStaticText* label = new Label(p->m_panel_filament_title, _L("Seal"));
wxStaticText* label = new Label(p->m_panel_filament_title, _L("Seal"));
label->SetToolTip(_L("The Seal button is primarily used to control the auxiliary component cooling fan to balance the chamber temperature."));
wxFont labe_fon = label->GetFont();
label->Bind(wxEVT_ENTER_WINDOW, [label](wxMouseEvent& event) {
label->SetFont(label->GetFont().Underlined());
});
label->Bind(wxEVT_LEAVE_WINDOW, [label, labe_fon](wxMouseEvent& event) {
label->SetFont(labe_fon);
});
label->Bind(wxEVT_LEFT_DOWN, [](wxMouseEvent& event) {
wxLaunchDefaultBrowser("https://wiki.qidi3d.com/en/software/qidi-studio/print-settings/seal");
event.Skip();
});
SwitchButton* checkbox = new SwitchButton(p->m_panel_filament_title, wxID_ANY);
bool init_val = wxGetApp().enable_seal();
@@ -965,6 +997,19 @@ Sidebar::Sidebar(Plater *parent)
//bSizer39->Add(ams_btn, 0, wxALIGN_CENTER|wxALL, FromDIP(5));
//bSizer39->Add(FromDIP(10), 0, 0, 0, 0 );
//w42
/*
fila_sync_btn = new ScalableButton(p->m_panel_filament_title, wxID_ANY, "box_fila_sync", wxEmptyString, wxDefaultSize, wxDefaultPosition,
wxBU_EXACTFIT | wxNO_BORDER, false, 18);
fila_sync_btn->SetToolTip(_L("Synchronize filament list from BOX"));
fila_sync_btn->Bind(wxEVT_BUTTON, [this, scrolled_sizer](wxCommandEvent& e) {
sync_box_list();
});
p->m_bpButton_ams_filament = fila_sync_btn;
bSizer39->Add(fila_sync_btn, 0, wxALIGN_CENTER | wxALL, FromDIP(5));
bSizer39->Add(FromDIP(10), 0, 0, 0, 0);*/
ScalableButton* set_btn = new ScalableButton(p->m_panel_filament_title, wxID_ANY, "settings");
set_btn->SetToolTip(_L("Set filaments to use"));
set_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent &e) {
@@ -1917,6 +1962,80 @@ void Sidebar::sync_ams_list()
Layout();
}
//w42
//w42
std::map<int, DynamicPrintConfig> Sidebar::build_filament_box_list(std::vector<std::string> id, std::vector<std::string> color)
{
std::map<int, DynamicPrintConfig> filament_ams_list;
char n = 'A';
char t = 0;
for (int i = 0; i < 4; i++) {
DynamicPrintConfig tray_config;
tray_config.set_key_value("filament_id", new ConfigOptionStrings{ id[i] });
tray_config.set_key_value("tag_uid", new ConfigOptionStrings{ "" }); //clear
tray_config.set_key_value("filament_type", new ConfigOptionStrings{ "" }); //clear
tray_config.set_key_value("tray_name", new ConfigOptionStrings{ "1A" }); //1A 1B 1C
tray_config.set_key_value("filament_colour", new ConfigOptionStrings{ into_u8(wxColour(color[i]).GetAsString(wxC2S_HTML_SYNTAX)) });//filament_color
tray_config.set_key_value("filament_exist", new ConfigOptionBools{ true }); //default
tray_config.set_key_value("filament_multi_colors", new ConfigOptionStrings{});
for (int j = 0; j < 4; ++j) {
tray_config.opt<ConfigOptionStrings>("filament_multi_colors")->values.push_back(into_u8(wxColour(color[j]).GetAsString(wxC2S_HTML_SYNTAX)));
}
filament_ams_list.emplace('A' + i, std::move(tray_config));
}
return filament_ams_list;
}
void Sidebar::sync_box_list()
{
SelectMachineDialog* m_select_machine_dlg = nullptr;
SendMultiMachinePage* m_send_multi_dlg = nullptr;
SendToPrinterDialog* m_send_to_sdcard_dlg = nullptr;
wxString title = "";
if (!m_select_machine_dlg) m_select_machine_dlg = new SelectMachineDialog(wxGetApp().plater(), title);
m_select_machine_dlg->set_print_type(PrintFromType::FROM_NORMAL);
m_select_machine_dlg->prepare(0);
m_select_machine_dlg->remove_area();
if (m_select_machine_dlg->ShowModal() == wxID_YES)
{
//
}
}
void Sidebar::updata_filament_list() {
wxGetApp().get_tab(Preset::TYPE_FILAMENT)->select_preset(wxGetApp().preset_bundle->filament_presets[0]);
wxGetApp().preset_bundle->export_selections(*wxGetApp().app_config);
dynamic_filament_list.update();
// Expand filament list
p->m_panel_filament_content->SetMaxSize({ -1, -1 });
Layout();
}
void Sidebar::load_box_list(std::vector<std::string> id, std::vector<std::string> color)
{
std::map<int, DynamicPrintConfig> filament_ams_list = build_filament_box_list(box_filament_id, box_filment_colors);
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": %1% items") % filament_ams_list.size();
wxGetApp().preset_bundle->filament_ams_list = filament_ams_list;
unsigned int unknowns = 0;
auto n = wxGetApp().preset_bundle->sync_box_list(unknowns);
wxGetApp().plater()->on_filaments_change(n);
for (auto c : p->combos_filament)
c->update();
}
ObjectList* Sidebar::obj_list()
{
// QDS
@@ -3812,37 +3931,39 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
//// // Is there any modifier or advanced config data?
//// for (ModelVolume *model_volume : model_object->volumes) model_volume->config.reset();
//// }
else if (load_config && (file_version > app_version)) {
Semver cloud_ver;
if (wxGetApp().app_config->has("app", "cloud_version")) {
std::string cloud_version = wxGetApp().app_config->get("app", "cloud_version");
cloud_ver = *(Semver::parse(cloud_version));
} else {
cloud_ver = app_version;
}
if (config_substitutions.unrecogized_keys.size() > 0) {
// std::string context = into_u8(text);
wxString context;
if (wxGetApp().app_config->get("user_mode") == "develop") {
context = _L("Found following keys unrecognized:\n");
for (auto &key : config_substitutions.unrecogized_keys) {
context += " -";
context += key;
context += ";\n";
}
}
context += "\n\n";
Newer3mfVersionDialog newer_dlg(q, &file_version, &cloud_ver, context);
newer_dlg.ShowModal();
}
else {
//if the minor version is not matched
if (file_version.min() != app_version.min()) {
Newer3mfVersionDialog newer_dlg(q, &file_version, &cloud_ver, "");
auto res = newer_dlg.ShowModal();
}
}
} else if (!load_config) {
//y54
// else if (load_config && (file_version > app_version)) {
// Semver cloud_ver;
// if (wxGetApp().app_config->has("app", "cloud_version")) {
// std::string cloud_version = wxGetApp().app_config->get("app", "cloud_version");
// cloud_ver = *(Semver::parse(cloud_version));
// } else {
// cloud_ver = app_version;
// }
// if (config_substitutions.unrecogized_keys.size() > 0) {
// // std::string context = into_u8(text);
// wxString context;
// if (wxGetApp().app_config->get("user_mode") == "develop") {
// context = _L("Found following keys unrecognized:\n");
// for (auto &key : config_substitutions.unrecogized_keys) {
// context += " -";
// context += key;
// context += ";\n";
// }
// }
// context += "\n\n";
// Newer3mfVersionDialog newer_dlg(q, &file_version, &cloud_ver, context);
// newer_dlg.ShowModal();
// }
// else {
// //if the minor version is not matched
// if (file_version.min() != app_version.min()) {
// Newer3mfVersionDialog newer_dlg(q, &file_version, &cloud_ver, "");
// auto res = newer_dlg.ShowModal();
// }
// }
//}
else if (!load_config) {
// reset config except color
for (ModelObject *model_object : model.objects) {
bool has_extruder = model_object->config.has("extruder");
@@ -7329,6 +7450,8 @@ void Plater::priv::on_action_print_plate(SimpleEvent&)
//y40
wxString title = "Send print job to";
SelectMachineDialog* dlg = new SelectMachineDialog(q, title);
//y52
dlg->prepare(partplate_list.get_curr_plate_index());
if (dlg->ShowModal() == wxID_YES)
{
std::string send_ip = dlg->get_machine_url();
@@ -7400,7 +7523,8 @@ void Plater::priv::on_action_send_to_multi_machine(SimpleEvent&)
// m_send_multi_dlg->ShowModal();
if (!m_send_multi_dlg)
m_send_multi_dlg = new SendMultiMachinePage(q);
//y52
m_send_multi_dlg->prepare(partplate_list.get_curr_plate_index());
max_send_number = std::stoi(wxGetApp().app_config->get("max_send"));
if (m_send_multi_dlg->ShowModal() == wxID_YES)
{
@@ -7572,6 +7696,8 @@ void Plater::priv::on_action_export_to_sdcard(SimpleEvent&)
//y40
wxString title = "Send to Printer SD card";
SelectMachineDialog* dlg = new SelectMachineDialog(q, title);
//y52
dlg->prepare(partplate_list.get_curr_plate_index());
if (dlg->ShowModal() == wxID_YES)
{
std::string send_ip = dlg->get_machine_url();

View File

@@ -151,6 +151,14 @@ public:
std::map<int, DynamicPrintConfig> build_filament_ams_list(MachineObject* obj);
void sync_ams_list();
//w42
std::vector<std::string> box_filament_id;
std::vector<std::string> box_filment_colors;
void sync_box_list();
void load_box_list(std::vector<std::string> id, std::vector<std::string> color);
std::map<int, DynamicPrintConfig> build_filament_box_list(std::vector<std::string> id, std::vector<std::string> color);
void updata_filament_list();
ObjectList* obj_list();
ObjectSettings* obj_settings();
ObjectLayers* obj_layers();
@@ -203,6 +211,10 @@ private:
bool m_soft_first_start {true };
bool m_is_gcode_file{ false };
bool m_update_3d_state{false};
//w42
ScalableButton* fila_sync_btn = nullptr;
};
class Plater: public wxPanel

View File

@@ -407,6 +407,44 @@ void PresetComboBox::add_ams_filaments(std::string selected, bool alias_name)
}
}
//w42
void PresetComboBox::add_box_filaments(std::string selected, bool alias_name)
{
bool is_qdt_vendor_preset = true; //m_preset_bundle->printers.get_edited_preset().is_qdt_vendor_preset(m_preset_bundle);
if (is_qdt_vendor_preset && !m_preset_bundle->filament_ams_list.empty()) {
set_label_marker(Append(separator(L("BOX filaments")), wxNullBitmap));
m_first_ams_filament = GetCount();
auto& filaments = m_collection->get_presets();
for (auto& entry : m_preset_bundle->filament_ams_list) {
auto& tray = entry.second;
std::string filament_id = tray.opt_string("filament_id", 0u);
if (filament_id.empty()) continue;
auto iter = std::find_if(filaments.begin(), filaments.end(),
[&filament_id, this](auto& f) { return f.filament_id == filament_id; });
if (iter == filaments.end()) {
auto filament_type = tray.opt_string("filament_type", 0u);
if (!filament_type.empty()) {
filament_type = "Generic " + filament_type;
iter = std::find_if(filaments.begin(), filaments.end(),
[&filament_type](auto& f) { return f.is_system; });
}
}
if (iter == filaments.end()) {
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << boost::format(": filament_id %1% not found or system or compatible") % filament_id;
continue;
}
const_cast<Preset&>(*iter).is_visible = true;
auto color = tray.opt_string("filament_colour", 0u);
auto name = tray.opt_string("tray_name", 0u);
wxBitmap bmp(*get_extruder_color_icon(color, name, 24, 16));
int item_id = Append(get_preset_name(*iter), bmp.ConvertToImage(), &m_first_ams_filament + entry.first);
//validate_selection(id->value == selected); // can not select
}
m_last_ams_filament = GetCount();
}
}
int PresetComboBox::selected_ams_filament() const
{
if (m_first_ams_filament && m_last_selected >= m_first_ams_filament && m_last_selected < m_last_ams_filament) {

View File

@@ -86,6 +86,9 @@ public:
virtual void sys_color_changed();
virtual void OnSelect(wxCommandEvent& evt);
//w42
void add_box_filaments(std::string selected, bool alias_name = false);
protected:
typedef std::size_t Marker;
std::function<void(int)> on_selection_changed { nullptr };

View File

@@ -421,6 +421,8 @@ void PrintHostQueueDialog::on_progress(Event &evt)
job_list->GetValue(nm, evt.job_id, COL_FILENAME);
job_list->GetValue(hst, evt.job_id, COL_HOST);
wxGetApp().notification_manager()->set_upload_job_notification_percentage(evt.job_id + 1, boost::nowide::narrow(nm.GetString()), boost::nowide::narrow(hst.GetString()), evt.progress / 100.f);
//y53
OctoPrint::progress_percentage = evt.progress / 100.f;
}
}

View File

@@ -525,7 +525,7 @@ wxBoxSizer *PrinterWebView::init_menu_bar(wxPanel *Panel)
std::pair<wxColour, int>(wxColour(67, 67, 71), StateColor::Normal));
//y50
wxString machine_icon_path = wxString(Slic3r::resources_dir() + "/" + "profiles" + "/" + "thumbnail" + "/" + Machine_Name + ".png");
wxString machine_icon_path = wxString(Slic3r::resources_dir() + "/" + "profiles" + "/" + "thumbnail" + "/" + Machine_Name + ".png", wxConvUTF8);
DeviceButton *machine_button = new DeviceButton(leftScrolledWindow, fullname, machine_icon_path, wxBU_LEFT, wxSize(80, 80), device_name, ip, apikey);
machine_button->SetBackgroundColor(mac_btn_bg);
@@ -614,7 +614,7 @@ wxBoxSizer *PrinterWebView::init_menu_bar(wxPanel *Panel)
QIDINetwork m_qidinetwork;
//y50
wxString machine_icon_path = wxString(Slic3r::resources_dir() + "/" + "profiles" + "/" + "thumbnail" + "/" + Machine_Name + ".png");
wxString machine_icon_path = wxString(Slic3r::resources_dir() + "/" + "profiles" + "/" + "thumbnail" + "/" + Machine_Name + ".png", wxConvUTF8);
// device_name = m_qidinetwork.UTF8ToGBK(device_name.c_str());
DeviceButton *machine_button = new DeviceButton(leftScrolledWindow, device.device_name, machine_icon_path, wxBU_LEFT, wxSize(80, 80),
@@ -1007,6 +1007,8 @@ wxBoxSizer *PrinterWebView::init_menu_bar(wxPanel *Panel)
webisNetMode = isDisconnect;
m_web = url;
m_ip = "";
//y53
has_load_url = false;
m_browser->LoadURL(url);
UpdateState();
}
@@ -1016,6 +1018,8 @@ wxBoxSizer *PrinterWebView::init_menu_bar(wxPanel *Panel)
if (m_browser == nullptr || m_web == url)
return;
m_web = url;
//y53
has_load_url = true;
m_browser->LoadURL(url);
//y28
webisNetMode = isLocalWeb;
@@ -1038,14 +1042,15 @@ wxBoxSizer *PrinterWebView::init_menu_bar(wxPanel *Panel)
}
UpdateState();
}
void PrinterWebView::load_net_url(std::string url, std::string ip)
void PrinterWebView::load_net_url(wxString& url, wxString& ip)
{
if (m_browser == nullptr || m_web == url)
return;
// y13
m_web = url;
m_ip = ip;
//y34
//y53
has_load_url = true;
m_browser->LoadURL(m_web);
//y28
webisNetMode = isNetWeb;
@@ -1155,20 +1160,26 @@ wxBoxSizer *PrinterWebView::init_menu_bar(wxPanel *Panel)
{
formattedHost = "http://" + link_url;
}
load_net_url(formattedHost, local_ip);
wxString host = from_u8(formattedHost);
wxString ip = from_u8(local_ip);
load_net_url(host, ip);
}
void PrinterWebView::FormatUrl(std::string link_url)
{
wxString m_link_url = from_u8(link_url);
wxString url;
if (!m_link_url.Lower().starts_with("http"))
url = wxString::Format("http://%s", m_link_url);
//y52
wxString m_link_url = from_u8(link_url);
wxString url;
if(m_link_url.find(":") == wxString::npos)
url = wxString::Format("%s:10088", m_link_url);
else
url = m_link_url;
if (!url.Lower().ends_with("10088"))
url = wxString::Format("%s:10088", url);
if (!url.Lower().starts_with("http"))
url = wxString::Format("http://%s", url);
load_url(url);
load_url(url);
}
void PrinterWebView::SetToggleBar(bool is_net_mode)

View File

@@ -68,7 +68,7 @@ public:
void init_scroll_window(wxPanel *Panel);
void CreatThread();
void load_url(wxString& url);
void load_net_url(std::string url, std::string ip);
void load_net_url(wxString& url, wxString& ip);
void UpdateState();
void OnClose(wxCloseEvent& evt);
@@ -126,6 +126,11 @@ public:
bool GetNetMode() { return m_isNetMode; };
std::vector<DeviceButton *> GetNetButton() { return m_net_buttons; };
wxString GetWeburl(){ return m_web; };
//y53
wxString GetWebIp(){return m_ip;};
bool GetHasLoadUrl(){return has_load_url;};
bool IsNetUrl() {return webisNetMode == isNetWeb;};
void load_disconnect_url(wxString& url);
void FormatNetUrl(std::string link_url, std::string local_ip, bool isSpecialMachine);
void FormatUrl(std::string link_url);
@@ -176,6 +181,8 @@ private:
std::set<std::string> m_exit_host;
std::string m_user_head_name; //y33
bool m_isfluidd_1; //y35
//y53
bool has_load_url;
};
// y13

View File

@@ -1277,6 +1277,32 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater, wxString title)
}
});
//w42
m_comboBox_printer->Bind(wxEVT_COMBOBOX, [this](wxCommandEvent& evt) {
wxString selected = evt.GetString();
MachineObject* selected_machine = nullptr;
if (!m_isNetMode) {
for (auto& machine : machine_list_local) {
if (from_u8(machine.display_name) == selected) {
OctoPrint octo(machine.url, machine.ip);
wxString msg;
if (octo.get_box_state(msg)) {
machine_filament_info = octo.get_box_info(msg);
octo.get_color_filament_str(msg, machine_filament_info);
select_use_box->Show();
get_machine_filament_info();
}
else {
select_use_box->Hide();
}
break;
}
}
}
m_sizer_main->Layout();
evt.Skip();
});
m_isSwitch = new wxCheckBox(switch_button_panel, wxID_ANY, _L("Switch to Device tab"), wxDefaultPosition);
m_isSwitch->SetValue((wxGetApp().app_config->get("switch to device tab after upload") == "true") ? true : false);
m_isSwitch->SetForegroundColour(StateColor::darkModeColorFor(wxColour(0, 0, 0)));
@@ -1301,16 +1327,25 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater, wxString title)
select_timelapse = create_item_checkbox(_L("Timelapse"), this, _L("Timelapse"), "timelapse");
select_use_ams = create_ams_checkbox(_L("Enable BOX"), this, _L("Enable BOX"));
//w42
select_use_box = create_ams_checkbox(_L("Enable BOX"), this, _L("Enable BOX"));
m_sizer_select->Add(select_bed, 0, wxLEFT | wxRIGHT, WRAP_GAP);
m_sizer_select->Add(select_flow, 0, wxLEFT | wxRIGHT, WRAP_GAP);
m_sizer_select->Add(select_timelapse, 0, wxLEFT | wxRIGHT, WRAP_GAP);
m_sizer_select->Add(select_use_ams, 0, wxLEFT | wxRIGHT, WRAP_GAP);
//w42
m_sizer_select->Add(select_use_box, 0, wxLEFT | wxRIGHT, WRAP_GAP);
select_bed->Show(false);
select_flow->Show(false);
select_timelapse->Show(false);
select_use_ams->Show(false);
//w42
select_use_box->Show(false);
m_sizer_select->Layout();
// line schedule
@@ -1521,6 +1556,35 @@ SelectMachineDialog::SelectMachineDialog(Plater *plater, wxString title)
wxGetApp().UpdateDlgDarkUI(this);
}
//w42
void SelectMachineDialog::remove_area()
{
m_scrollable_view->Hide();
m_isSwitch->Hide();
m_simplebook->Show(false);
select_use_box->Hide();
m_line_schedule->Hide();
m_line_materia->Hide();
m_sizer_select->Show(false);
m_sizer_select->Layout();
m_button_sync = new Button(this, _L("Sync"));
m_button_sync->SetBackgroundColor(m_btn_bg_enable);
m_button_sync->SetBorderColor(m_btn_bg_enable);
m_button_sync->SetTextColor(StateColor::darkModeColorFor("#FFFFFE"));
m_button_sync->SetSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE);
m_button_sync->SetMinSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE);
m_button_sync->SetMinSize(SELECT_MACHINE_DIALOG_BUTTON_SIZE);
m_button_sync->SetCornerRadius(FromDIP(12));
m_button_sync->Bind(wxEVT_BUTTON, &SelectMachineDialog::on_sync_btn, this);
m_sizer_main->Add(m_button_sync, 0, wxALIGN_CENTER_HORIZONTAL, FromDIP(30));
SetSizer(m_sizer_main);
Layout();
Fit();
Thaw();
}
void SelectMachineDialog::init_bind()
{
Bind(wxEVT_TIMER, &SelectMachineDialog::on_timer, this);
@@ -2787,6 +2851,75 @@ void SelectMachineDialog::on_ok_btn(wxCommandEvent &event)
//}
}
//w42
void SelectMachineDialog::on_sync_btn(wxCommandEvent& event)
{
bool isSwitch = m_isSwitch->GetValue();
if (isSwitch)
wxGetApp().app_config->set_bool("switch to device tab after upload", true);
else
wxGetApp().app_config->set_bool("switch to device tab after upload", false);
machine_name = into_u8(m_comboBox_printer->GetValue());
bool have_get_phy_printer = false;
if (!m_isNetMode)
{
for (auto machine : machine_list_local)
{
if (machine.display_name == machine_name)
{
machine_url = machine.url;
machine_ip = machine.ip;
machine_apikey = machine.apikey;
have_get_phy_printer = true;
break;
}
}
}
else
{
#if QDT_RELEASE_TO_PUBLIC
for (auto machine : machine_list_link)
{
if (machine.display_name == machine_name)
{
machine_url = machine.url;
machine_ip = machine.ip;
machine_apikey = "";
machine_link_url = machine.link_url;
machine_is_special = machine.is_special;
have_get_phy_printer = true;
break;
}
}
#endif
}
if (have_get_phy_printer) {
OctoPrint octo(machine_url, machine_ip);
wxString msg;
if (octo.get_box_state(msg)) {
machine_filament_info = octo.get_box_info(msg);
}
else {
}
}
wxGetApp().plater()->sidebar().load_box_list(wxGetApp().plater()->sidebar().box_filament_id, wxGetApp().plater()->sidebar().box_filment_colors);
wxGetApp().plater()->sidebar().updata_filament_list();
EndDialog(wxID_YES);
}
void SelectMachineDialog::get_machine_filament_info() {
wxGetApp().plater()->sidebar().box_filament_id = std::move(machine_filament_info.filament_id);
wxGetApp().plater()->sidebar().box_filment_colors = std::move(machine_filament_info.filment_colors);
//return { machine_filament_info.filament_id, machine_filament_info.filment_colors };
}
wxString SelectMachineDialog::format_steel_name(std::string name)
{
if (name == "hardened_steel") {
@@ -4056,8 +4189,9 @@ void SelectMachineDialog::set_default()
//project name
m_rename_switch_panel->SetSelection(0);
//y49
wxString filename = m_plater->get_output_filename();
// //y49
// wxString filename = m_plater->get_output_filename();
wxString filename = m_plater->get_export_gcode_filename("", true, m_print_plate_idx == PLATE_ALL_IDX ? true : false);
if (m_print_plate_idx == PLATE_ALL_IDX && filename.empty()) {
filename = _L("Untitled");
@@ -4069,22 +4203,23 @@ void SelectMachineDialog::set_default()
}
fs::path filename_path(filename.c_str());
std::string file_name = filename_path.filename().string();
if (from_u8(file_name).find(_L("Untitled")) != wxString::npos) {
//y52
wxString file_name = from_u8(filename_path.filename().string());
if (file_name.find(_L("Untitled")) != wxString::npos) {
PartPlate *part_plate = m_plater->get_partplate_list().get_plate(m_print_plate_idx);
if (part_plate) {
if (std::vector<ModelObject *> objects = part_plate->get_objects_on_this_plate(); objects.size() > 0) {
file_name = objects[0]->name;
file_name = from_u8(objects[0]->name);
for (int i = 1; i < objects.size(); i++) {
file_name += (" + " + objects[i]->name);
file_name += " + " + from_u8(objects[i]->name);
}
}
if (file_name.size() > 100) {
file_name = file_name.substr(0, 97) + "...";
if (file_name.size() > 50) {
file_name = file_name.substr(0, 50) + "...";
}
}
}
m_current_project_name = wxString::FromUTF8(file_name);
m_current_project_name = file_name;
//unsupported character filter

View File

@@ -73,6 +73,25 @@ struct Machine_info {
bool is_special = false;
};
//w42
struct Box_info {
std::vector<int> filament_index;
std::vector<int> filament_vendor;
std::vector<int> filament_color_index;
std::vector<int> slot_state;
std::vector<std::string> filament_id;
std::vector<std::string> filment_colors;
int box_count;
Box_info() : box_count(0) {
filament_index.resize(16, 1);
filament_vendor.resize(16, 1);
filament_color_index.resize(16, 1);
slot_state.resize(16, 0);
filament_id.resize(16, "");
filment_colors.resize(16, "");
}
};
static int get_brightness_value(wxImage image) {
@@ -397,6 +416,9 @@ private:
std::string m_required_data_file_name;
std::string m_required_data_file_path;
//w42
Box_info machine_filament_info;
protected:
PrintFromType m_print_type{FROM_NORMAL};
AmsMapingPopup m_mapping_popup{ nullptr };
@@ -480,6 +502,10 @@ protected:
std::string preset_typename;
wxCheckBox* m_isSwitch{ nullptr };
//w42
wxWindow* select_use_box{ nullptr };
Button* m_button_sync{ nullptr };
public:
//y30
SelectMachineDialog(Plater *plater, wxString title);
@@ -576,6 +602,10 @@ public:
bool GetMachineNetMode() { return m_isNetMode; }
bool isSpecialMachine() { return machine_is_special; }
//w42
void remove_area();
void on_sync_btn(wxCommandEvent& event);
void get_machine_filament_info();
};
wxDECLARE_EVENT(EVT_FINISHED_UPDATE_MACHINE_LIST, wxCommandEvent);

View File

@@ -1470,8 +1470,9 @@ void SendMultiMachinePage::set_default_normal(const ThumbnailData& data)
void SendMultiMachinePage::set_default()
{
//y49
wxString filename = m_plater->get_output_filename();
// //y49
// wxString filename = m_plater->get_output_filename();
wxString filename = m_plater->get_export_gcode_filename("", true, m_print_plate_idx == PLATE_ALL_IDX ? true : false);
if (m_print_plate_idx == PLATE_ALL_IDX && filename.empty()) {
filename = _L("Untitled");
}
@@ -1482,23 +1483,24 @@ void SendMultiMachinePage::set_default()
}
fs::path filename_path(filename.c_str());
std::string file_name = filename_path.filename().string();
if (from_u8(file_name).find(_L("Untitled")) != wxString::npos) {
//y52
wxString file_name = from_u8(filename_path.filename().string());
if (file_name.find(_L("Untitled")) != wxString::npos) {
PartPlate* part_plate = m_plater->get_partplate_list().get_plate(m_print_plate_idx);
if (part_plate) {
if (std::vector<ModelObject*> objects = part_plate->get_objects_on_this_plate(); objects.size() > 0) {
file_name = objects[0]->name;
file_name = from_u8(objects[0]->name);
for (int i = 1; i < objects.size(); i++) {
file_name += (" + " + objects[i]->name);
file_name += " + " + from_u8(objects[i]->name);
}
}
if (file_name.size() > 100) {
file_name = file_name.substr(0, 97) + "...";
if (file_name.size() > 50) {
file_name = file_name.substr(0, 50) + "...";
}
}
}
m_current_project_name = wxString::FromUTF8(file_name);
m_current_project_name = file_name;
//unsupported character filter
//y51
m_current_project_name = from_u8(filter_characters(m_current_project_name.ToUTF8().data(), "<>[]:\\|?*\""));

View File

@@ -2050,7 +2050,7 @@ void TabPrint::build()
//w16
optgroup = page->new_optgroup(L("Resonance avoidance"), L"param_speed", 15);
optgroup->append_single_option_line("resonance_avoidance");
optgroup->append_single_option_line("resonance_avoidance", "print-settings/resonance-avoidance");
optgroup->append_single_option_line("min_resonance_avoidance_speed");
optgroup->append_single_option_line("max_resonance_avoidance_speed");

View File

@@ -54,10 +54,6 @@ namespace Slic3r {
TargetUrl = m_qidinetwork.get_qidi_host();
#endif
BOOST_LOG_TRIVIAL(error) << "login url = " << TargetUrl.ToStdString();
m_qdt_user_agent = wxString::Format("QDT-Slicer/v%s", SLIC3R_VERSION);
// set the frame icon

View File

@@ -31,7 +31,8 @@ namespace pt = boost::property_tree;
namespace Slic3r {
bool OctoPrint::m_isStop = false;
//y53
double OctoPrint::progress_percentage = 0;
#ifdef WIN32
// Workaround for Windows 10/11 mDNS resolve issue, where two mDNS resolves in succession fail.
@@ -125,7 +126,7 @@ bool OctoPrint::test(wxString &msg) const
bool res = true;
auto url = make_url("api/version");
BOOST_LOG_TRIVIAL(info) << boost::format("%1%: Get version at: %2%") % name % url;
// BOOST_LOG_TRIVIAL(info) << boost::format("%1%: Get version at: %2%") % name % url;
auto http = Http::get(std::move(url));
set_auth(http);
@@ -221,17 +222,17 @@ bool OctoPrint::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, Erro
// Solves troubles of uploades failing with name address.
// in original address (m_host) replace host for resolved ip
url = substitute_host(make_url("server/files/upload"), GUI::into_u8(test_msg_or_host_ip));
BOOST_LOG_TRIVIAL(info) << "Upload address after ip resolve: " << url;
// BOOST_LOG_TRIVIAL(info) << "Upload address after ip resolve: " << url;
}
#endif // _WIN32
BOOST_LOG_TRIVIAL(info) << boost::format("%1%: Uploading file %2% at %3%, filename: %4%, path: %5%, print: %6%")
% name
% upload_data.source_path
% url
% upload_filename.string()
% upload_parent_path.string()
% (upload_data.post_action == PrintHostPostUploadAction::StartPrint ? "true" : "false");
// BOOST_LOG_TRIVIAL(info) << boost::format("%1%: Uploading file %2% at %3%, filename: %4%, path: %5%, print: %6%")
// % name
// % upload_data.source_path
// % url
// % upload_filename.string()
// % upload_parent_path.string()
// % (upload_data.post_action == PrintHostPostUploadAction::StartPrint ? "true" : "false");
auto http = Http::post(std::move(url));
set_auth(http);
@@ -242,24 +243,28 @@ bool OctoPrint::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, Erro
if (upload_data.post_action == PrintHostPostUploadAction::StartPrint)
http.form_add("print", "true");
//y53
progress_percentage = 0;
http.form_add_file("file", upload_data.source_path.string(), upload_filename.string())
.on_complete([&](std::string body, unsigned status) {
BOOST_LOG_TRIVIAL(debug) << boost::format("%1%: File uploaded: HTTP %2%: %3%") % name % status % body;
})
.on_error([&](std::string body, std::string error, unsigned status) {
//y40
if (status == 404)
{
body = ("Network connection fails.");
if (body.find("AWS") != std::string::npos)
body += ("Unable to get required resources from AWS server, please check your network settings.");
else
body += ("Unable to get required resources from Aliyun server, please check your network settings.");
//y40 y53
if (progress_percentage < 0.99){
if (status == 404)
{
body = ("Network connection fails.");
if (body.find("AWS") != std::string::npos)
body += ("Unable to get required resources from AWS server, please check your network settings.");
else
body += ("Unable to get required resources from Aliyun server, please check your network settings.");
}
BOOST_LOG_TRIVIAL(error) << boost::format("%1%: Error uploading file: %2%, HTTP %3%, body: `%4%`") % name % error % status % body;
error_fn(format_error(body, error, status));
res = false;
}
BOOST_LOG_TRIVIAL(error) << boost::format("%1%: Error uploading file: %2%, HTTP %3%, body: `%4%`") % name % error % status % body;
error_fn(format_error(body, error, status));
res = false;
})
.on_progress([&](Http::Progress progress, bool &cancel) {
prorgess_fn(std::move(progress), cancel);
@@ -316,7 +321,7 @@ std::string OctoPrint::get_status(wxString& msg) const
std::string print_state = "standby";
auto url = make_url("printer/objects/query?print_stats=state");
BOOST_LOG_TRIVIAL(info) << boost::format("%1%: Get version at: %2%") % name % url;
// BOOST_LOG_TRIVIAL(info) << boost::format("%1%: Get version at: %2%") % name % url;
auto http = Http::get(std::move(url));
set_auth(http);
@@ -388,7 +393,7 @@ float OctoPrint::get_progress(wxString& msg) const
bool res = true;
auto url = make_url("printer/objects/query?display_status=progress");
float process = 0;
BOOST_LOG_TRIVIAL(info) << boost::format("%1%: Get version at: %2%") % name % url;
// BOOST_LOG_TRIVIAL(info) << boost::format("%1%: Get version at: %2%") % name % url;
auto http = Http::get(std::move(url));
set_auth(http);
@@ -447,6 +452,323 @@ float OctoPrint::get_progress(wxString& msg) const
return process;
}
//w42
bool OctoPrint::get_printer_state(wxString& msg)
{
return true;
const char* name = get_name();
std::string print_state = "";
float process = 0;
auto url = make_url("printer/objects/query?print_stats=state&display_status=progress");
BOOST_LOG_TRIVIAL(info) << boost::format("%1%: Get version at: %2%") % name % url;
auto http = Http::get(std::move(url));
set_auth(http);
http.timeout_connect(4)
.on_error([&](std::string body, std::string error, unsigned status) {
if (status == 404) {
body = ("Network connection fails.");
if (body.find("AWS") != std::string::npos)
body += ("Unable to get required resources from AWS server, please check your network settings.");
else
body += ("Unable to get required resources from Aliyun server, please check your network settings.");
}
BOOST_LOG_TRIVIAL(error) << boost::format("%1%: Error getting version: %2%, HTTP %3%, body: `%4%`") % name % error % status %
body;
print_state = "offline";
msg = format_error(body, error, status);
})
.on_complete([&](std::string body, unsigned) {
BOOST_LOG_TRIVIAL(debug) << boost::format("%1%: Got print_stats and process: %2%") % name % body;
try {
// All successful HTTP requests will return a json encoded object in the form of :
// {result: <response data>}
std::stringstream ss(body);
pt::ptree ptree;
pt::read_json(ss, ptree);
if (ptree.front().first != "result") {
msg = "Could not parse server response";
print_state = "offline";
process = 0;
}
if (!ptree.front().second.get_optional<std::string>("status")) {
msg = "Could not parse server response";
print_state = "offline";
}
print_state = ptree.get<std::string>("result.status.print_stats.state");
BOOST_LOG_TRIVIAL(info) << boost::format("%1%: Got state: %2%") % name % print_state;
;
}
catch (const std::exception&) {
print_state = "offline";
msg = "Could not parse server response";
}
})
#ifdef _WIN32
.ssl_revoke_best_effort(m_ssl_revoke_best_effort)
.on_ip_resolve([&](std::string address) {
// Workaround for Windows 10/11 mDNS resolve issue, where two mDNS resolves in succession fail.
// Remember resolved address to be reused at successive REST API call.
msg = GUI::from_u8(address);
})
#endif // _WIN32
.perform_sync();
return print_state == "standby" ? true : false;
}
bool OctoPrint::get_box_state(wxString& msg)
{
const char* name = get_name();
int box_count = 0;
auto url = make_url("server/files/config/saved_variables.cfg");
BOOST_LOG_TRIVIAL(info) << boost::format("%1%: Getting saved variables at: %2%") % name % url;
auto http = Http::get(std::move(url));
set_auth(http);
http.timeout_connect(4)
.on_error([&](std::string body, std::string error, unsigned status) {
BOOST_LOG_TRIVIAL(error) << boost::format("%1%: Error getting saved variables: %2%, HTTP %3%, body: `%4%`")
% name % error % status % body;
msg = format_error(body, error, status);
})
.on_complete([&](std::string body, unsigned) {
try {
std::istringstream cfg_stream(body);
std::string line;
while (std::getline(cfg_stream, line)) {
if (line.find("box_count = ") != std::string::npos) {
size_t value_start = line.find("=") + 1;
std::string value_str = line.substr(value_start);
// Trim whitespace
value_str.erase(0, value_str.find_first_not_of(" "));
value_str.erase(value_str.find_last_not_of(" ") + 1);
box_count = std::stoi(value_str);
BOOST_LOG_TRIVIAL(debug) << boost::format("%1%: Got box_count value: %2%") % name % box_count;
break;
}
}
}
catch (const std::exception& e) {
msg = wxString::Format("Error parsing box_count value: %s", e.what());
}
})
#ifdef _WIN32
.ssl_revoke_best_effort(m_ssl_revoke_best_effort)
.on_ip_resolve([&](std::string address) {
msg = GUI::from_u8(address);
})
#endif // _WIN32
.perform_sync();
if (box_count > 0)
return true;
else
return false;
}
GUI::Box_info OctoPrint::get_box_info(wxString& msg)
{
const char* name = get_name();
int box_count = 0;
GUI::Box_info filament_info;
auto url = make_url("server/files/config/saved_variables.cfg");
BOOST_LOG_TRIVIAL(info) << boost::format("%1%: Getting saved variables at: %2%") % name % url;
auto http = Http::get(std::move(url));
set_auth(http);
http.timeout_connect(4)
.on_error([&](std::string body, std::string error, unsigned status) {
BOOST_LOG_TRIVIAL(error) << boost::format("%1%: Error getting saved variables: %2%, HTTP %3%, body: `%4%`")
% name % error % status % body;
msg = format_error(body, error, status);
})
.on_complete([&](std::string body, unsigned) {
try {
std::istringstream cfg_stream(body);
std::string line;
filament_info = GUI::Box_info();
while (std::getline(cfg_stream, line)) {
line.erase(0, line.find_first_not_of(" "));
line.erase(line.find_last_not_of(" ") + 1);
if (line.find("box_count = ") != std::string::npos) {
size_t value_start = line.find("=") + 1;
std::string value_str = line.substr(value_start);
value_str.erase(0, value_str.find_first_not_of(" "));
value_str.erase(value_str.find_last_not_of(" ") + 1);
box_count = std::stoi(value_str);
filament_info.box_count = box_count;
BOOST_LOG_TRIVIAL(debug) << boost::format("%1%: Got box_count value: %2%") % name % box_count;
}
for (int i = 0; i < box_count * 4; ++i) {
std::string color_key = "color_slot" + std::to_string(i);
std::string filament_key = "filament_slot" + std::to_string(i);
std::string vendor_key = "vendor_slot" + std::to_string(i);
std::string slot_key = "slot" + std::to_string(i);
if (line.find(color_key) != std::string::npos) {
size_t value_start = line.find("=") + 1;
std::string value_str = line.substr(value_start);
value_str.erase(0, value_str.find_first_not_of(" "));
value_str.erase(value_str.find_last_not_of(" ") + 1);
filament_info.filament_color_index[i] = std::stoi(value_str);
}
if (line.find(filament_key) != std::string::npos) {
size_t value_start = line.find("=") + 1;
std::string value_str = line.substr(value_start);
value_str.erase(0, value_str.find_first_not_of(" "));
value_str.erase(value_str.find_last_not_of(" ") + 1);
filament_info.filament_index[i] = std::stoi(value_str);
}
if (line.find(vendor_key) != std::string::npos) {
size_t value_start = line.find("=") + 1;
std::string value_str = line.substr(value_start);
value_str.erase(0, value_str.find_first_not_of(" "));
value_str.erase(value_str.find_last_not_of(" ") + 1);
filament_info.filament_vendor[i] = std::stoi(value_str);
}
if (line.find(slot_key) != std::string::npos) {
size_t value_start = line.find("=") + 1;
std::string value_str = line.substr(value_start);
value_str.erase(0, value_str.find_first_not_of(" "));
value_str.erase(value_str.find_last_not_of(" ") + 1);
filament_info.slot_state[i] = std::stoi(value_str);
}
}
}
}
catch (const std::exception& e) {
msg = wxString::Format("Error parsing config values: %s", e.what());
}
})
#ifdef _WIN32
.ssl_revoke_best_effort(m_ssl_revoke_best_effort)
.on_ip_resolve([&](std::string address) {
msg = GUI::from_u8(address);
})
#endif // _WIN32
.perform_sync();
return filament_info;
}
void OctoPrint::get_color_filament_str(wxString& msg, GUI::Box_info& machine_filament_info)
{
const char* name = get_name();
auto url = make_url("server/files/config/officiall_filas_list.cfg");
BOOST_LOG_TRIVIAL(info) << boost::format("%1%: Getting saved variables at: %2%") % name % url;
auto http = Http::get(std::move(url));
set_auth(http);
http.timeout_connect(4)
.on_error([&](std::string body, std::string error, unsigned status) {
BOOST_LOG_TRIVIAL(error) << boost::format("%1%: Error getting saved variables: %2%, HTTP %3%, body: `%4%`")
% name % error % status % body;
msg = format_error(body, error, status);
})
.on_complete([&](std::string body, unsigned) {
try {
boost::property_tree::ptree pt;
std::istringstream is(body);
boost::property_tree::ini_parser::read_ini(is, pt);
int slots_to_process = machine_filament_info.box_count * 4;
for (int i = 0; i < slots_to_process && i < 16; i++) {
int fila_index = machine_filament_info.filament_index[i];
std::string section_name = "fila" + std::to_string(fila_index);
try {
std::string fila_id = pt.get<std::string>(section_name + ".fila_id", "");
machine_filament_info.filament_id[i] = fila_id;
std::string vendor = pt.get<std::string>(section_name + ".vendor", "");
if (!vendor.empty()) {
machine_filament_info.filament_vendor[i] =
vendor == "QIDI" ? 1 : 2;
}
}
catch (const boost::property_tree::ptree_error& e) {
BOOST_LOG_TRIVIAL(warning) << boost::format("%1%: Could not find filament info for index %2%: %3%")
% name % fila_index % e.what();
}
int color_index = machine_filament_info.filament_color_index[i];
std::string color_key = std::to_string(color_index);
try {
std::string color_value = pt.get<std::string>("colordict." + color_key, "");
machine_filament_info.filment_colors[i] = color_value;
}
catch (const boost::property_tree::ptree_error& e) {
BOOST_LOG_TRIVIAL(warning) << boost::format("%1%: Could not find color for index %2%: %3%")
% name % color_index % e.what();
}
}
msg = wxString::Format("Successfully loaded filament and color information for %d boxes",
machine_filament_info.box_count);
}
catch (const std::exception& e) {
msg = wxString::Format("Error parsing config values: %s", e.what());
}
})
#ifdef _WIN32
.ssl_revoke_best_effort(m_ssl_revoke_best_effort)
.on_ip_resolve([&](std::string address) {
msg = GUI::from_u8(address);
})
#endif // _WIN32
.perform_sync();
machine_filament_info.filament_index[0]=0;
}
std::pair<std::string, float> OctoPrint::send_command_to_printer(wxString& msg)
{
// printer_state: http://192.168.20.66/printer/objects/query?print_stats
const char* name = get_name();
std::string gcode = "G28";
std::string json_body = "{\"script\": \"" + gcode + "\"}";
auto url = make_url("printer/gcode/script");
Http http = Http::post(std::move(url));
http.header("Content-Type", "application/json")
.set_post_body(json_body)
.timeout_connect(4)
.on_error([&](std::string body, std::string error, unsigned status) {
BOOST_LOG_TRIVIAL(error) << boost::format("%1%: Error sending G-code: %2%, HTTP %3%, body: %4%")
% name % error % status % body;
})
.on_complete([&](std::string body, unsigned status) {
BOOST_LOG_TRIVIAL(debug) << boost::format("%1%: G-code sent successfully: %2%") % name % gcode;
})
#ifdef _WIN32
.ssl_revoke_best_effort(m_ssl_revoke_best_effort)
#endif // _WIN32
.perform_sync();
return std::make_pair("test", 0.01);
}
std::pair<std::string, float> OctoPrint::get_status_progress(wxString& msg) const
{
// GET /server/info
@@ -460,7 +782,7 @@ std::pair<std::string, float> OctoPrint::get_status_progress(wxString& msg) cons
float process = 0;
auto url = make_url("printer/objects/query?print_stats=state&display_status=progress");
BOOST_LOG_TRIVIAL(info) << boost::format("%1%: Get version at: %2%") % name % url;
//BOOST_LOG_TRIVIAL(info) << boost::format("%1%: Get version at: %2%") % name % url;
auto http = Http::get(std::move(url));
set_auth(http);
@@ -629,7 +951,7 @@ bool QIDILink::get_storage(wxArrayString& storage_path, wxArrayString& storage_n
};
std::vector<StorageInfo> storage;
BOOST_LOG_TRIVIAL(info) << boost::format("%1%: Get storage at: %2%") % name % url;
// BOOST_LOG_TRIVIAL(info) << boost::format("%1%: Get storage at: %2%") % name % url;
wxString wlang = GUI::wxGetApp().current_language_code();
std::string lang = GUI::format(wlang.SubString(0, 1));

View File

@@ -7,6 +7,8 @@
#include "PrintHost.hpp"
#include "libslic3r/PrintConfig.hpp"
//w42
#include "slic3r/GUI/SelectMachine.hpp"
namespace Slic3r {
@@ -41,6 +43,15 @@ public:
static void SetStop(bool isStop) { m_isStop = isStop; };
static bool GetStop() { return m_isStop; };
static bool m_isStop;
//y53
static double progress_percentage;
//w42
bool get_box_state(wxString& curl_msg);
bool get_printer_state(wxString& curl_msg);
std::pair<std::string, float> send_command_to_printer(wxString& curl_msg);
GUI::Box_info get_box_info(wxString& msg);
void get_color_filament_str(wxString& msg, GUI::Box_info& machine_filament_info);
protected:
std::string m_show_ip;