diff --git a/src/slic3r/GUI/BackgroundSlicingProcess.cpp b/src/slic3r/GUI/BackgroundSlicingProcess.cpp index 3d93a4e..2905f76 100644 --- a/src/slic3r/GUI/BackgroundSlicingProcess.cpp +++ b/src/slic3r/GUI/BackgroundSlicingProcess.cpp @@ -159,13 +159,16 @@ std::string BackgroundSlicingProcess::output_filepath_for_project(const boost::f void BackgroundSlicingProcess::process_fff() { assert(m_print == m_fff_print); - m_print->process(); - wxCommandEvent evt(m_event_slicing_completed_id); - // Post the Slicing Finished message for the G-code viewer to update. - // Passing the timestamp - evt.SetInt((int)(m_fff_print->step_state_with_timestamp(PrintStep::psSlicingFinished).timestamp)); - wxQueueEvent(GUI::wxGetApp().mainframe->m_plater, evt.Clone()); - m_fff_print->export_gcode(m_temp_output_path, m_gcode_result, [this](const ThumbnailsParams& params) { return this->render_thumbnails(params); }); + if (!m_print->finished()) { + m_print->process(); + wxCommandEvent evt(m_event_slicing_completed_id); + // Post the Slicing Finished message for the G-code viewer to update. + // Passing the timestamp + evt.SetInt((int)(m_fff_print->step_state_with_timestamp(PrintStep::psSlicingFinished).timestamp)); + wxQueueEvent(GUI::wxGetApp().mainframe->m_plater, evt.Clone()); + m_fff_print->export_gcode(m_temp_output_path, m_gcode_result, [this](const ThumbnailsParams& params) { return this->render_thumbnails(params); }); + } + if (this->set_step_started(bspsGCodeFinalize)) { if (! m_export_path.empty()) { wxQueueEvent(GUI::wxGetApp().mainframe->m_plater, new wxCommandEvent(m_event_export_began_id)); diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 0b46850..7169a82 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1980,7 +1980,7 @@ float project_overview_table(float scale) { } } - ImGui::PushStyleColor(ImGuiCol_Text, ImGuiPureWrap::COL_ORANGE_LIGHT); + ImGui::PushStyleColor(ImGuiCol_Text, ImGuiPureWrap::COL_BLUE_LIGHT); const StatisticsSum statistics_sum{get_statistics_sum()}; ImGui::TableNextRow(); @@ -2087,7 +2087,7 @@ void extruder_usage_table(const PerExtruderStatistics &extruder_statistics, cons ImGui::Text("%.2f", statistics.filament_length); } - ImGui::PushStyleColor(ImGuiCol_Text, ImGuiPureWrap::COL_ORANGE_LIGHT); + ImGui::PushStyleColor(ImGuiCol_Text, ImGuiPureWrap::COL_BLUE_LIGHT); const ExtruderStatistics extruder_statistics_sum{sum_extruder_statistics(extruder_statistics)}; ImGui::TableNextRow(); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoFuzzySkin.cpp b/src/slic3r/GUI/Gizmos/GLGizmoFuzzySkin.cpp index e250b39..2eb83d4 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoFuzzySkin.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoFuzzySkin.cpp @@ -120,7 +120,7 @@ void GLGizmoFuzzySkin::on_render_input_window(float x, float y, float bottom_lim window_width = std::max(window_width, 2.f * buttons_width + m_imgui->scaled(1.f)); auto draw_text_with_caption = [&caption_max](const std::string &caption, const std::string &text) { - ImGuiPureWrap::text_colored(ImGuiPureWrap::COL_ORANGE_LIGHT, caption); + ImGuiPureWrap::text_colored(ImGuiPureWrap::COL_BLUE_LIGHT, caption); ImGui::SameLine(caption_max); ImGuiPureWrap::text(text); }; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index e1cbe04..9cec489 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1900,7 +1900,7 @@ void Plater::priv::object_list_changed() (it != s_multiple_beds.get_inst_map().end() && it->second == bed_index && instance->printable - && instance->print_volume_state == ModelInstancePVS_Partly_Outside) || (object->in_exclude) + && instance->print_volume_state == ModelInstancePVS_Partly_Outside) || (it->second == bed_index && object->in_exclude) ) { s_print_statuses[bed_index] = PrintStatus::outside; break; diff --git a/src/slic3r/GUI/PrintHostDialogs.cpp b/src/slic3r/GUI/PrintHostDialogs.cpp index 7883d1c..81699af 100644 --- a/src/slic3r/GUI/PrintHostDialogs.cpp +++ b/src/slic3r/GUI/PrintHostDialogs.cpp @@ -969,6 +969,8 @@ void PrintHostQueueDialog::on_progress(Event &evt) const std::string& nm_str = into_u8(nm.GetString()); const std::string& hst_str = into_u8(hst.GetString()); wxGetApp().notification_manager()->set_upload_job_notification_percentage(evt.job_id + 1, nm_str, hst_str, evt.progress / 100.f); + //y21 + Moonraker::progress_percentage = evt.progress / 100.f; } } diff --git a/src/slic3r/GUI/PrinterWebView.cpp b/src/slic3r/GUI/PrinterWebView.cpp index bff74c4..e60d9f2 100644 --- a/src/slic3r/GUI/PrinterWebView.cpp +++ b/src/slic3r/GUI/PrinterWebView.cpp @@ -1152,11 +1152,13 @@ void PrinterWebView::RunScript(const wxString &javascript) { 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); + if (link_url.find(":") == wxString::npos) + url = wxString::Format("%s:10088", link_url); + else + url = link_url; - if (!url.Lower().ends_with("10088")) - url = wxString::Format("%s:10088", url); + if (!m_link_url.Lower().starts_with("http")) + url = wxString::Format("http://%s", url); load_url(url); } diff --git a/src/slic3r/Utils/Http.cpp b/src/slic3r/Utils/Http.cpp index 1a354e7..41ba3c2 100644 --- a/src/slic3r/Utils/Http.cpp +++ b/src/slic3r/Utils/Http.cpp @@ -107,7 +107,8 @@ struct Http::priv { enum { DEFAULT_TIMEOUT_CONNECT = 10, - DEFAULT_TIMEOUT_MAX = 0, + //y21 + DEFAULT_TIMEOUT_MAX = 10, DEFAULT_SIZE_LIMIT = 5 * 1024 * 1024, }; diff --git a/src/slic3r/Utils/Moonraker.cpp b/src/slic3r/Utils/Moonraker.cpp index adffabf..eef7ecf 100644 --- a/src/slic3r/Utils/Moonraker.cpp +++ b/src/slic3r/Utils/Moonraker.cpp @@ -21,8 +21,9 @@ namespace fs = boost::filesystem; namespace pt = boost::property_tree; namespace Slic3r { -//y6 +//y21 bool Moonraker::m_isStop = false; +double Moonraker::progress_percentage = 0; namespace { #ifdef WIN32 @@ -68,7 +69,7 @@ std::string substitute_host(const std::string& orig_addr, std::string sub_addr) } //B55 Moonraker::Moonraker(DynamicPrintConfig *config, bool add_port) : - m_host(add_port ? config->opt_string("print_host").find(":10088") == std::string::npos ? config->opt_string("print_host") + ":10088" : + m_host(add_port ? config->opt_string("print_host").find(":") == std::string::npos ? config->opt_string("print_host") + ":10088" : config->opt_string("print_host") : config->opt_string("print_host")), m_apikey(config->opt_string("printhost_apikey")), @@ -171,56 +172,56 @@ std::string Moonraker::get_status(wxString &msg) const //B64 //y6 http.timeout_connect(4) .on_error([&](std::string body, std::string error, unsigned status) { - // y1 - 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: %2%") % name % body; + // y1 + 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: %2%") % name % body; - try { - // All successful HTTP requests will return a json encoded object in the form of : - // {result: } - 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"; - return; - } - if (!ptree.front().second.get_optional("status")) { - msg = "Could not parse server response"; - print_state = "offline"; - return; - } - print_state = ptree.get("result.status.print_stats.state"); - BOOST_LOG_TRIVIAL(info) << boost::format("%1%: Got state: %2%") % name % print_state; - ; - } catch (const std::exception &) { + try { + // All successful HTTP requests will return a json encoded object in the form of : + // {result: } + 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"; - msg = "Could not parse server response"; + return; } - }) + if (!ptree.front().second.get_optional("status")) { + msg = "Could not parse server response"; + print_state = "offline"; + return; + } + print_state = ptree.get("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); - }) + .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(); + .perform_sync(); return print_state; } @@ -241,55 +242,55 @@ float Moonraker::get_progress(wxString &msg) const auto http = Http::get(std::move(url)); set_auth(http); http.on_error([&](std::string body, std::string error, unsigned status) { - // y1 - 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; - res = false; - msg = format_error(body, error, status); - }) - .on_complete([&](std::string body, unsigned) { - BOOST_LOG_TRIVIAL(debug) << boost::format("%1%: Got display_status: %2%") % name % body; + // y1 + 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; + res = false; + msg = format_error(body, error, status); + }) + .on_complete([&](std::string body, unsigned) { + BOOST_LOG_TRIVIAL(debug) << boost::format("%1%: Got display_status: %2%") % name % body; - try { - // All successful HTTP requests will return a json encoded object in the form of : - // {result: } - std::stringstream ss(body); - pt::ptree ptree; - pt::read_json(ss, ptree); - if (ptree.front().first != "result") { - msg = "Could not parse server response"; - res = false; - return; - } - if (!ptree.front().second.get_optional("status")) { - msg = "Could not parse server response"; - res = false; - return; - } - process = std::stof(ptree.get("result.status.display_status.progress")); - BOOST_LOG_TRIVIAL(info) << boost::format("%1%: Got state: %2%") % name % process; - } catch (const std::exception &) { - res = false; + try { + // All successful HTTP requests will return a json encoded object in the form of : + // {result: } + std::stringstream ss(body); + pt::ptree ptree; + pt::read_json(ss, ptree); + if (ptree.front().first != "result") { msg = "Could not parse server response"; + res = false; + return; } - }) + if (!ptree.front().second.get_optional("status")) { + msg = "Could not parse server response"; + res = false; + return; + } + process = std::stof(ptree.get("result.status.display_status.progress")); + BOOST_LOG_TRIVIAL(info) << boost::format("%1%: Got state: %2%") % name % process; + } catch (const std::exception &) { + res = false; + 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); - }) + .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(); + .perform_sync(); return process; } @@ -436,24 +437,26 @@ bool Moonraker::upload(PrintHostUpload upload_data, ProgressFn prorgess_fn, Erro http.form_add("path", upload_parent_path.string()); if (upload_data.post_action == PrintHostPostUploadAction::StartPrint) http.form_add("print", "true"); - + 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) { - // y1 - 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."); + // y21 + 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); diff --git a/src/slic3r/Utils/Moonraker.hpp b/src/slic3r/Utils/Moonraker.hpp index 0e4724b..7270b74 100644 --- a/src/slic3r/Utils/Moonraker.hpp +++ b/src/slic3r/Utils/Moonraker.hpp @@ -48,6 +48,7 @@ public: static void SetStop(bool isStop) { m_isStop = isStop; }; static bool GetStop() { return m_isStop; }; static bool m_isStop; + static double progress_percentage; protected: /*