mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-27 12:52:07 +00:00
Merge branch '2.2.0' into dev_bury_point_alves
This commit is contained in:
@@ -1154,7 +1154,14 @@ void GUI_App::shutdown()
|
||||
delete web_preprint_dialog;
|
||||
web_preprint_dialog = nullptr;
|
||||
}
|
||||
|
||||
|
||||
// Delete WebPresetDialog to ensure proper cleanup
|
||||
if (SSWCP_MqttAgent_Instance::m_dialog != nullptr) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": destroy WebPresetDialog");
|
||||
delete SSWCP_MqttAgent_Instance::m_dialog;
|
||||
SSWCP_MqttAgent_Instance::m_dialog = nullptr;
|
||||
}
|
||||
|
||||
|
||||
if (m_is_recreating_gui) return;
|
||||
m_is_closing = true;
|
||||
|
||||
@@ -27,6 +27,10 @@ NetworkTestDialog::NetworkTestDialog(wxWindow* parent, wxWindowID id, const wxSt
|
||||
wxSize(1000, 700),
|
||||
/*wxCAPTION*/wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER)
|
||||
{
|
||||
// Create a self-managing shared_ptr for weak_ptr support
|
||||
// Note: This creates a self-reference, so we need to break it in destructor
|
||||
self_ptr = std::shared_ptr<NetworkTestDialog>(this, [](NetworkTestDialog*) { /* custom deleter - do nothing, object is stack-allocated */ });
|
||||
weak_this = self_ptr;
|
||||
this->SetBackgroundColour(wxColour(255, 255, 255));
|
||||
|
||||
this->SetSizeHints(wxDefaultSize, wxDefaultSize);
|
||||
@@ -80,15 +84,21 @@ wxBoxSizer* NetworkTestDialog::create_top_sizer(wxWindow* parent)
|
||||
btn_clear_log->SetStyle(ButtonStyle::Regular, ButtonType::Window);
|
||||
line_sizer->Add(btn_clear_log, 0, wxALL, 5);
|
||||
|
||||
btn_start->Bind(wxEVT_BUTTON, [this](wxCommandEvent &evt) {
|
||||
start_all_job();
|
||||
btn_start->Bind(wxEVT_BUTTON, [weak_this = weak_this](wxCommandEvent &evt) {
|
||||
if (auto self = weak_this.lock()) {
|
||||
self->start_all_job();
|
||||
}
|
||||
});
|
||||
btn_start_sequence->Bind(wxEVT_BUTTON, [this](wxCommandEvent &evt) {
|
||||
start_all_job_sequence();
|
||||
btn_start_sequence->Bind(wxEVT_BUTTON, [weak_this = weak_this](wxCommandEvent &evt) {
|
||||
if (auto self = weak_this.lock()) {
|
||||
self->start_all_job_sequence();
|
||||
}
|
||||
});
|
||||
btn_clear_log->Bind(wxEVT_BUTTON, [this](wxCommandEvent &evt) {
|
||||
if (txt_log) {
|
||||
txt_log->Clear();
|
||||
btn_clear_log->Bind(wxEVT_BUTTON, [weak_this = weak_this](wxCommandEvent &evt) {
|
||||
if (auto self = weak_this.lock()) {
|
||||
if (self->txt_log) {
|
||||
self->txt_log->Clear();
|
||||
}
|
||||
}
|
||||
});
|
||||
sizer->Add(line_sizer, 0, wxEXPAND, 5);
|
||||
@@ -228,28 +238,40 @@ wxBoxSizer* NetworkTestDialog::create_content_sizer(wxWindow* parent)
|
||||
|
||||
sizer->Add(grid_sizer, 1, wxEXPAND, 5);
|
||||
|
||||
btn_link->Bind(wxEVT_BUTTON, [this](wxCommandEvent& evt) {
|
||||
start_test_github_thread();
|
||||
btn_link->Bind(wxEVT_BUTTON, [weak_this = weak_this](wxCommandEvent& evt) {
|
||||
if (auto self = weak_this.lock()) {
|
||||
self->start_test_github_thread();
|
||||
}
|
||||
});
|
||||
|
||||
btn_bing->Bind(wxEVT_BUTTON, [this](wxCommandEvent& evt) {
|
||||
start_test_bing_thread();
|
||||
btn_bing->Bind(wxEVT_BUTTON, [weak_this = weak_this](wxCommandEvent& evt) {
|
||||
if (auto self = weak_this.lock()) {
|
||||
self->start_test_bing_thread();
|
||||
}
|
||||
});
|
||||
|
||||
btn_lan_mqtt->Bind(wxEVT_BUTTON, [this](wxCommandEvent& evt) {
|
||||
start_test_lan_mqtt_thread();
|
||||
btn_lan_mqtt->Bind(wxEVT_BUTTON, [weak_this = weak_this](wxCommandEvent& evt) {
|
||||
if (auto self = weak_this.lock()) {
|
||||
self->start_test_lan_mqtt_thread();
|
||||
}
|
||||
});
|
||||
|
||||
btn_cloud_mqtt->Bind(wxEVT_BUTTON, [this](wxCommandEvent& evt) {
|
||||
start_test_cloud_mqtt_thread();
|
||||
btn_cloud_mqtt->Bind(wxEVT_BUTTON, [weak_this = weak_this](wxCommandEvent& evt) {
|
||||
if (auto self = weak_this.lock()) {
|
||||
self->start_test_cloud_mqtt_thread();
|
||||
}
|
||||
});
|
||||
|
||||
btn_login_api->Bind(wxEVT_BUTTON, [this](wxCommandEvent& evt) {
|
||||
start_test_login_api_thread();
|
||||
btn_login_api->Bind(wxEVT_BUTTON, [weak_this = weak_this](wxCommandEvent& evt) {
|
||||
if (auto self = weak_this.lock()) {
|
||||
self->start_test_login_api_thread();
|
||||
}
|
||||
});
|
||||
|
||||
btn_upload_api->Bind(wxEVT_BUTTON, [this](wxCommandEvent& evt) {
|
||||
start_test_upload_api_thread();
|
||||
btn_upload_api->Bind(wxEVT_BUTTON, [weak_this = weak_this](wxCommandEvent& evt) {
|
||||
if (auto self = weak_this.lock()) {
|
||||
self->start_test_upload_api_thread();
|
||||
}
|
||||
});
|
||||
|
||||
return sizer;
|
||||
@@ -271,25 +293,28 @@ NetworkTestDialog::~NetworkTestDialog()
|
||||
m_closing.store(true);
|
||||
m_download_cancel = true;
|
||||
cleanup_threads();
|
||||
// Break the self-reference to avoid issues
|
||||
self_ptr.reset();
|
||||
}
|
||||
|
||||
void NetworkTestDialog::init_bind()
|
||||
{
|
||||
Bind(EVT_UPDATE_RESULT, [this](wxCommandEvent& evt) {
|
||||
if (m_closing.load()) return;
|
||||
Bind(EVT_UPDATE_RESULT, [weak_this = weak_this](wxCommandEvent& evt) {
|
||||
auto self = weak_this.lock();
|
||||
if (!self || self->m_closing.load()) return;
|
||||
|
||||
if (evt.GetInt() == TEST_ORCA_JOB) {
|
||||
text_link_val->SetLabelText(evt.GetString());
|
||||
self->text_link_val->SetLabelText(evt.GetString());
|
||||
} else if (evt.GetInt() == TEST_BING_JOB) {
|
||||
text_bing_val->SetLabelText(evt.GetString());
|
||||
self->text_bing_val->SetLabelText(evt.GetString());
|
||||
} else if (evt.GetInt() == TEST_LAN_MQTT_JOB) {
|
||||
text_lan_mqtt_val->SetLabelText(evt.GetString());
|
||||
self->text_lan_mqtt_val->SetLabelText(evt.GetString());
|
||||
} else if (evt.GetInt() == TEST_CLOUD_MQTT_JOB) {
|
||||
text_cloud_mqtt_val->SetLabelText(evt.GetString());
|
||||
self->text_cloud_mqtt_val->SetLabelText(evt.GetString());
|
||||
} else if (evt.GetInt() == TEST_LOGIN_API_JOB) {
|
||||
text_login_api_val->SetLabelText(evt.GetString());
|
||||
self->text_login_api_val->SetLabelText(evt.GetString());
|
||||
} else if (evt.GetInt() == TEST_UPLOAD_API_JOB) {
|
||||
text_upload_api_val->SetLabelText(evt.GetString());
|
||||
self->text_upload_api_val->SetLabelText(evt.GetString());
|
||||
}
|
||||
|
||||
std::time_t t = std::time(0);
|
||||
@@ -298,8 +323,8 @@ void NetworkTestDialog::init_bind()
|
||||
buf << std::put_time(now_time, "%a %b %d %H:%M:%S");
|
||||
wxString info = wxString(buf.str()) + ": " + evt.GetString() + "\n";
|
||||
try {
|
||||
if (!m_closing.load() && txt_log) {
|
||||
txt_log->AppendText(info);
|
||||
if (!self->m_closing.load() && self->txt_log) {
|
||||
self->txt_log->AppendText(info);
|
||||
}
|
||||
}
|
||||
catch (std::exception& e) {
|
||||
@@ -360,52 +385,54 @@ void NetworkTestDialog::start_all_job_sequence()
|
||||
device_ip = dlg.GetValue().Trim();
|
||||
}
|
||||
|
||||
m_sequence_job = new boost::thread([this, device_ip] {
|
||||
update_status(-1, "========================================");
|
||||
update_status(-1, "Start sequence test (single-thread mode)");
|
||||
update_status(-1, "========================================");
|
||||
update_status(-1, "");
|
||||
m_sequence_job = new boost::thread([weak_this = weak_this, device_ip] {
|
||||
auto self = weak_this.lock();
|
||||
if (!self) return;
|
||||
self->update_status(-1, "========================================");
|
||||
self->update_status(-1, "Start sequence test (single-thread mode)");
|
||||
self->update_status(-1, "========================================");
|
||||
self->update_status(-1, "");
|
||||
|
||||
start_test_url(TEST_BING_JOB, "Bing", "http://www.bing.com");
|
||||
if (m_closing.load()) return;
|
||||
self->start_test_url(TEST_BING_JOB, "Bing", "http://www.bing.com");
|
||||
if (self->m_closing.load()) return;
|
||||
|
||||
update_status(-1, "");
|
||||
start_test_url(TEST_ORCA_JOB, "Snapmaker Orca(GitHub)", "https://github.com/Snapmaker/OrcaSlicer");
|
||||
if (m_closing.load()) return;
|
||||
self->update_status(-1, "");
|
||||
self->start_test_url(TEST_ORCA_JOB, "Snapmaker Orca(GitHub)", "https://github.com/Snapmaker/OrcaSlicer");
|
||||
if (self->m_closing.load()) return;
|
||||
|
||||
// 如果用户输入了局域网设备IP,则进行测试
|
||||
if (!device_ip.IsEmpty()) {
|
||||
update_status(-1, "");
|
||||
start_test_telnet(TEST_LAN_MQTT_JOB, "LAN Device", device_ip, 1884);
|
||||
if (m_closing.load()) return;
|
||||
self->update_status(-1, "");
|
||||
self->start_test_telnet(TEST_LAN_MQTT_JOB, "LAN Device", device_ip, 1884);
|
||||
if (self->m_closing.load()) return;
|
||||
}
|
||||
|
||||
// 测试云服务器
|
||||
wxString cloud_server = get_cloud_server_address();
|
||||
wxString cloud_server = self->get_cloud_server_address();
|
||||
if (!cloud_server.IsEmpty()) {
|
||||
update_status(-1, "");
|
||||
start_test_telnet(TEST_CLOUD_MQTT_JOB, "Cloud Server", cloud_server, 8883);
|
||||
self->update_status(-1, "");
|
||||
self->start_test_telnet(TEST_CLOUD_MQTT_JOB, "Cloud Server", cloud_server, 8883);
|
||||
}
|
||||
if (m_closing.load()) return;
|
||||
if (self->m_closing.load()) return;
|
||||
|
||||
// 测试登录API
|
||||
update_status(-1, "");
|
||||
self->update_status(-1, "");
|
||||
auto app_config = wxGetApp().app_config;
|
||||
std::string region = app_config->get("region");
|
||||
wxString login_api_url = (region == "Chinese Mainland" || region == "China") ? "https://id.snapmaker.cn" : "https://id.snapmaker.com";
|
||||
start_test_url(TEST_LOGIN_API_JOB, "Login API", login_api_url);
|
||||
if (m_closing.load()) return;
|
||||
self->start_test_url(TEST_LOGIN_API_JOB, "Login API", login_api_url);
|
||||
if (self->m_closing.load()) return;
|
||||
|
||||
// 测试上传API
|
||||
update_status(-1, "");
|
||||
self->update_status(-1, "");
|
||||
wxString upload_api_url = (region == "Chinese Mainland" || region == "China") ? "https://public.resource.snapmaker.cn" : "https://public.resource.snapmaker.com";
|
||||
start_test_url(TEST_UPLOAD_API_JOB, "Upload API", upload_api_url);
|
||||
if (m_closing.load()) return;
|
||||
self->start_test_url(TEST_UPLOAD_API_JOB, "Upload API", upload_api_url);
|
||||
if (self->m_closing.load()) return;
|
||||
|
||||
update_status(-1, "");
|
||||
update_status(-1, "========================================");
|
||||
update_status(-1, "Sequence test completed");
|
||||
update_status(-1, "========================================");
|
||||
self->update_status(-1, "");
|
||||
self->update_status(-1, "========================================");
|
||||
self->update_status(-1, "Sequence test completed");
|
||||
self->update_status(-1, "========================================");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -424,9 +451,11 @@ void NetworkTestDialog::start_test_url(TestJob job, wxString name, wxString url)
|
||||
update_status(-1, "");
|
||||
|
||||
int result = -1;
|
||||
auto weak_self = weak_this;
|
||||
http.timeout_max(10)
|
||||
.on_complete([this, &result, job](std::string body, unsigned status) {
|
||||
if (m_closing.load()) return;
|
||||
.on_complete([weak_self, &result, job](std::string body, unsigned status) {
|
||||
auto self = weak_self.lock();
|
||||
if (!self || self->m_closing.load()) return;
|
||||
try {
|
||||
if (status == 200) {
|
||||
result = 0;
|
||||
@@ -440,21 +469,23 @@ void NetworkTestDialog::start_test_url(TestJob job, wxString name, wxString url)
|
||||
;
|
||||
}
|
||||
})
|
||||
.on_ip_resolve([this,name,job](std::string ip) {
|
||||
if (m_closing.load()) return;
|
||||
.on_ip_resolve([weak_self, name, job](std::string ip) {
|
||||
auto self = weak_self.lock();
|
||||
if (!self || self->m_closing.load()) return;
|
||||
wxString ip_report = "test " + name + " ip resolved = " + wxString::FromUTF8(ip);
|
||||
update_status(job, ip_report);
|
||||
self->update_status(job, ip_report);
|
||||
})
|
||||
.on_error([this,name,job](std::string body, std::string error, unsigned int status) {
|
||||
if (m_closing.load()) return;
|
||||
.on_error([weak_self, name, job](std::string body, std::string error, unsigned int status) {
|
||||
auto self = weak_self.lock();
|
||||
if (!self || self->m_closing.load()) return;
|
||||
// Upload API: 403 is OK (HTTPS resource with permission check)
|
||||
if (job == TEST_UPLOAD_API_JOB && status == 403) {
|
||||
this->update_status(job, "test " + name + " ok (403 - access restricted, but server reachable)");
|
||||
self->update_status(job, "test " + name + " ok (403 - access restricted, but server reachable)");
|
||||
return;
|
||||
}
|
||||
wxString info = wxString::Format("status=%u, body=", status) + wxString::FromUTF8(body) + ", error=" + wxString::FromUTF8(error);
|
||||
this->update_status(job, "test " + name + " failed");
|
||||
this->update_status(-1, info);
|
||||
self->update_status(job, "test " + name + " failed");
|
||||
self->update_status(-1, info);
|
||||
}).perform_sync();
|
||||
|
||||
if (result == 0) {
|
||||
@@ -468,10 +499,12 @@ void NetworkTestDialog::start_test_url(TestJob job, wxString name, wxString url)
|
||||
|
||||
void NetworkTestDialog::start_test_ping_thread()
|
||||
{
|
||||
test_job[TEST_PING_JOB] = new boost::thread([this] {
|
||||
m_in_testing[TEST_PING_JOB].store(true);
|
||||
test_job[TEST_PING_JOB] = new boost::thread([weak_this = weak_this] {
|
||||
auto self = weak_this.lock();
|
||||
if (!self) return;
|
||||
self->m_in_testing[TEST_PING_JOB].store(true);
|
||||
|
||||
m_in_testing[TEST_PING_JOB].store(false);
|
||||
self->m_in_testing[TEST_PING_JOB].store(false);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -859,9 +892,11 @@ void NetworkTestDialog::start_test_lan_mqtt_thread()
|
||||
test_job[TEST_LAN_MQTT_JOB] = nullptr;
|
||||
}
|
||||
|
||||
test_job[TEST_LAN_MQTT_JOB] = new boost::thread([this, device_ip] {
|
||||
test_job[TEST_LAN_MQTT_JOB] = new boost::thread([weak_this = weak_this, device_ip] {
|
||||
auto self = weak_this.lock();
|
||||
if (!self) return;
|
||||
// 测试局域网设备 - 端口默认1884
|
||||
start_test_telnet(TEST_LAN_MQTT_JOB, "LAN Device", device_ip, 1884);
|
||||
self->start_test_telnet(TEST_LAN_MQTT_JOB, "LAN Device", device_ip, 1884);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -895,9 +930,11 @@ void NetworkTestDialog::start_test_cloud_mqtt_thread()
|
||||
test_job[TEST_CLOUD_MQTT_JOB] = nullptr;
|
||||
}
|
||||
|
||||
test_job[TEST_CLOUD_MQTT_JOB] = new boost::thread([this, cloud_server] {
|
||||
test_job[TEST_CLOUD_MQTT_JOB] = new boost::thread([weak_this = weak_this, cloud_server] {
|
||||
auto self = weak_this.lock();
|
||||
if (!self) return;
|
||||
// 测试云服务器 - 使用telnet方式,端口8883
|
||||
start_test_telnet(TEST_CLOUD_MQTT_JOB, "Cloud Server", cloud_server, 8883);
|
||||
self->start_test_telnet(TEST_CLOUD_MQTT_JOB, "Cloud Server", cloud_server, 8883);
|
||||
});
|
||||
}
|
||||
void NetworkTestDialog::start_test_github_thread()
|
||||
@@ -911,8 +948,10 @@ void NetworkTestDialog::start_test_github_thread()
|
||||
test_job[TEST_ORCA_JOB] = nullptr;
|
||||
}
|
||||
|
||||
test_job[TEST_ORCA_JOB] = new boost::thread([this] {
|
||||
start_test_url(TEST_ORCA_JOB, "Snapmaker Orca(GitHub)", "https://github.com/Snapmaker/OrcaSlicer");
|
||||
test_job[TEST_ORCA_JOB] = new boost::thread([weak_this = weak_this] {
|
||||
auto self = weak_this.lock();
|
||||
if (!self) return;
|
||||
self->start_test_url(TEST_ORCA_JOB, "Snapmaker Orca(GitHub)", "https://github.com/Snapmaker/OrcaSlicer");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -927,8 +966,10 @@ void NetworkTestDialog::start_test_bing_thread()
|
||||
test_job[TEST_BING_JOB] = nullptr;
|
||||
}
|
||||
|
||||
test_job[TEST_BING_JOB] = new boost::thread([this] {
|
||||
start_test_url(TEST_BING_JOB, "Bing", "http://www.bing.com");
|
||||
test_job[TEST_BING_JOB] = new boost::thread([weak_this = weak_this] {
|
||||
auto self = weak_this.lock();
|
||||
if (!self) return;
|
||||
self->start_test_url(TEST_BING_JOB, "Bing", "http://www.bing.com");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -943,11 +984,13 @@ void NetworkTestDialog::start_test_login_api_thread()
|
||||
test_job[TEST_LOGIN_API_JOB] = nullptr;
|
||||
}
|
||||
|
||||
test_job[TEST_LOGIN_API_JOB] = new boost::thread([this] {
|
||||
test_job[TEST_LOGIN_API_JOB] = new boost::thread([weak_this = weak_this] {
|
||||
auto self = weak_this.lock();
|
||||
if (!self) return;
|
||||
auto app_config = wxGetApp().app_config;
|
||||
std::string region = app_config->get("region");
|
||||
wxString login_api_url = (region == "Chinese Mainland") ? "https://id.snapmaker.cn" : "https://id.snapmaker.com";
|
||||
start_test_url(TEST_LOGIN_API_JOB, "Login API", login_api_url);
|
||||
self->start_test_url(TEST_LOGIN_API_JOB, "Login API", login_api_url);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -962,11 +1005,13 @@ void NetworkTestDialog::start_test_upload_api_thread()
|
||||
test_job[TEST_UPLOAD_API_JOB] = nullptr;
|
||||
}
|
||||
|
||||
test_job[TEST_UPLOAD_API_JOB] = new boost::thread([this] {
|
||||
test_job[TEST_UPLOAD_API_JOB] = new boost::thread([weak_this = weak_this] {
|
||||
auto self = weak_this.lock();
|
||||
if (!self) return;
|
||||
auto app_config = wxGetApp().app_config;
|
||||
std::string region = app_config->get("region");
|
||||
wxString upload_api_url = (region == "Chinese Mainland") ? "https://public.resource.snapmaker.cn" : "https://public.resource.snapmaker.com";
|
||||
start_test_url(TEST_UPLOAD_API_JOB, "Upload API", upload_api_url);
|
||||
self->start_test_url(TEST_UPLOAD_API_JOB, "Upload API", upload_api_url);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <time.h>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
@@ -47,6 +48,8 @@ enum TestJob {
|
||||
class NetworkTestDialog : public DPIDialog
|
||||
{
|
||||
protected:
|
||||
std::shared_ptr<NetworkTestDialog> self_ptr;
|
||||
std::weak_ptr<NetworkTestDialog> weak_this;
|
||||
Button* btn_start;
|
||||
Button* btn_start_sequence;
|
||||
Button* btn_download_log;
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "MoonRaker.hpp"
|
||||
|
||||
#include "slic3r/GUI/WebPresetDialog.hpp"
|
||||
#include <mutex>
|
||||
|
||||
#include "slic3r/GUI/SMPhysicalPrinterDialog.hpp"
|
||||
#include "slic3r/GUI/WebUrlDialog.hpp"
|
||||
@@ -184,6 +185,7 @@ WCP_Logger::~WCP_Logger()
|
||||
}
|
||||
|
||||
extern json m_ProfileJson;
|
||||
extern std::mutex m_ProfileJson_mutex;
|
||||
|
||||
std::vector<std::string> load_thumbnails(const std::string& file, size_t image_count)
|
||||
{
|
||||
@@ -5236,30 +5238,33 @@ void SSWCP_MqttAgent_Instance::sw_mqtt_set_engine()
|
||||
m_dialog->m_device_id = ip;
|
||||
|
||||
// 检查是否该预设已经选入系统
|
||||
int nModel = m_ProfileJson["model"].size();
|
||||
bool isFind = false;
|
||||
for (int m = 0; m < nModel; m++) {
|
||||
if (m_ProfileJson["model"][m]["model"].get<std::string>() == info.model_name) {
|
||||
// 绑定的预设已被选入系统
|
||||
isFind = true;
|
||||
std::string nozzle_selected = m_ProfileJson["model"][m]["nozzle_selected"]
|
||||
.get<std::string>();
|
||||
std::string se_nozz_selected = nozzle_diameters[0];
|
||||
if (nozzle_selected.find(se_nozz_selected) == std::string::npos) {
|
||||
nozzle_selected += ";" + se_nozz_selected;
|
||||
m_ProfileJson["model"][m]["nozzle_selected"] = nozzle_selected;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_ProfileJson_mutex);
|
||||
int nModel = m_ProfileJson["model"].size();
|
||||
bool isFind = false;
|
||||
for (int m = 0; m < nModel; m++) {
|
||||
if (m_ProfileJson["model"][m]["model"].get<std::string>() == info.model_name) {
|
||||
// 绑定的预设已被选入系统
|
||||
isFind = true;
|
||||
std::string nozzle_selected = m_ProfileJson["model"][m]["nozzle_selected"]
|
||||
.get<std::string>();
|
||||
std::string se_nozz_selected = nozzle_diameters[0];
|
||||
if (nozzle_selected.find(se_nozz_selected) == std::string::npos) {
|
||||
nozzle_selected += ";" + se_nozz_selected;
|
||||
m_ProfileJson["model"][m]["nozzle_selected"] = nozzle_selected;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isFind) {
|
||||
json new_item;
|
||||
new_item["vendor"] = "Snapmaker";
|
||||
new_item["model"] = info.model_name;
|
||||
new_item["nozzle_selected"] = nozzle_diameters[0];
|
||||
m_ProfileJson["model"].push_back(new_item);
|
||||
if (!isFind) {
|
||||
json new_item;
|
||||
new_item["vendor"] = "Snapmaker";
|
||||
new_item["model"] = info.model_name;
|
||||
new_item["nozzle_selected"] = nozzle_diameters[0];
|
||||
m_ProfileJson["model"].push_back(new_item);
|
||||
}
|
||||
}
|
||||
|
||||
wxGetApp().mainframe->plater()->sidebar().update_all_preset_comboboxes(false);
|
||||
|
||||
@@ -33,12 +33,14 @@
|
||||
#include <libslic3r/miniz_extension.hpp>
|
||||
#include <libslic3r/Utils.hpp>
|
||||
#include "CreatePresetsDialog.hpp"
|
||||
#include <mutex>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
json m_ProfileJson;
|
||||
std::mutex m_ProfileJson_mutex;
|
||||
|
||||
static wxString update_custom_filaments()
|
||||
{
|
||||
@@ -229,7 +231,11 @@ wxString GuideFrame::SetStartPage(GuidePage startpage, bool load)
|
||||
} else if (startpage == BBL_FILAMENTS) {
|
||||
SetTitle(_L("Setup Wizard"));
|
||||
|
||||
int nSize = m_ProfileJson["model"].size();
|
||||
int nSize;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_ProfileJson_mutex);
|
||||
nSize = m_ProfileJson["model"].size();
|
||||
}
|
||||
|
||||
if (nSize>0)
|
||||
TargetUrl = from_u8((boost::filesystem::path(resources_dir()) / "web/guide/0/index.html?target=22").make_preferred().string());
|
||||
@@ -403,7 +409,10 @@ void GuideFrame::OnScriptMessage(wxWebViewEvent &evt)
|
||||
json m_Res = json::object();
|
||||
m_Res["command"] = "response_userguide_profile";
|
||||
m_Res["sequence_id"] = "10001";
|
||||
m_Res["response"] = m_ProfileJson;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_ProfileJson_mutex);
|
||||
m_Res["response"] = m_ProfileJson;
|
||||
}
|
||||
|
||||
//wxString strJS = wxString::Format("HandleStudio(%s)", m_Res.dump(-1, ' ', false, json::error_handler_t::ignore));
|
||||
wxString strJS = wxString::Format("HandleStudio(%s)", m_Res.dump(-1, ' ', true));
|
||||
@@ -426,43 +435,53 @@ void GuideFrame::OnScriptMessage(wxWebViewEvent &evt)
|
||||
{
|
||||
json MSelected = j["data"];
|
||||
|
||||
int nModel = m_ProfileJson["model"].size();
|
||||
for (int m = 0; m < nModel; m++) {
|
||||
json TmpModel = m_ProfileJson["model"][m];
|
||||
m_ProfileJson["model"][m]["nozzle_selected"] = "";
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_ProfileJson_mutex);
|
||||
int nModel = m_ProfileJson["model"].size();
|
||||
for (int m = 0; m < nModel; m++) {
|
||||
json TmpModel = m_ProfileJson["model"][m];
|
||||
m_ProfileJson["model"][m]["nozzle_selected"] = "";
|
||||
|
||||
for (auto it = MSelected.begin(); it != MSelected.end(); ++it) {
|
||||
json OneSelect = it.value();
|
||||
for (auto it = MSelected.begin(); it != MSelected.end(); ++it) {
|
||||
json OneSelect = it.value();
|
||||
|
||||
wxString s1 = TmpModel["model"];
|
||||
wxString s2 = OneSelect["model"];
|
||||
if (s1.compare(s2) == 0) {
|
||||
m_ProfileJson["model"][m]["nozzle_selected"] = OneSelect["nozzle_diameter"];
|
||||
break;
|
||||
wxString s1 = TmpModel["model"];
|
||||
wxString s2 = OneSelect["model"];
|
||||
if (s1.compare(s2) == 0) {
|
||||
m_ProfileJson["model"][m]["nozzle_selected"] = OneSelect["nozzle_diameter"];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (strCmd == "save_userguide_filaments") {
|
||||
//reset
|
||||
for (auto it = m_ProfileJson["filament"].begin(); it != m_ProfileJson["filament"].end(); ++it)
|
||||
{
|
||||
m_ProfileJson["filament"][it.key()]["selected"] = 0;
|
||||
}
|
||||
std::lock_guard<std::mutex> lock(m_ProfileJson_mutex);
|
||||
//reset
|
||||
for (auto it = m_ProfileJson["filament"].begin(); it != m_ProfileJson["filament"].end(); ++it)
|
||||
{
|
||||
m_ProfileJson["filament"][it.key()]["selected"] = 0;
|
||||
}
|
||||
|
||||
json fSelected = j["data"]["filament"];
|
||||
int nF = fSelected.size();
|
||||
for (int m = 0; m < nF; m++)
|
||||
{
|
||||
std::string fName = fSelected[m];
|
||||
json fSelected = j["data"]["filament"];
|
||||
int nF = fSelected.size();
|
||||
for (int m = 0; m < nF; m++)
|
||||
{
|
||||
std::string fName = fSelected[m];
|
||||
|
||||
m_ProfileJson["filament"][fName]["selected"] = 1;
|
||||
m_ProfileJson["filament"][fName]["selected"] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (strCmd == "user_guide_finish") {
|
||||
SaveProfile();
|
||||
|
||||
std::string oldregion = m_ProfileJson["region"];
|
||||
std::string oldregion;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_ProfileJson_mutex);
|
||||
oldregion = m_ProfileJson["region"];
|
||||
}
|
||||
bool bLogin = false;
|
||||
if (m_Region != oldregion) {
|
||||
AppConfig* config = GUI::wxGetApp().app_config;
|
||||
@@ -492,7 +511,10 @@ void GuideFrame::OnScriptMessage(wxWebViewEvent &evt)
|
||||
this->Close();
|
||||
} else if (strCmd == "save_region") {
|
||||
m_Region = j["region"];
|
||||
m_ProfileJson["region"] = m_Region;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_ProfileJson_mutex);
|
||||
m_ProfileJson["region"] = m_Region;
|
||||
}
|
||||
}
|
||||
else if (strCmd == "common_openurl") {
|
||||
|
||||
@@ -635,7 +657,11 @@ int GuideFrame::SaveProfile()
|
||||
|
||||
m_MainPtr->app_config->save();
|
||||
|
||||
std::string strAll = m_ProfileJson.dump(-1, ' ', false, json::error_handler_t::ignore);
|
||||
std::string strAll;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_ProfileJson_mutex);
|
||||
strAll = m_ProfileJson.dump(-1, ' ', false, json::error_handler_t::ignore);
|
||||
}
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "before save to app_config: "<< std::endl<<strAll;
|
||||
|
||||
@@ -643,9 +669,12 @@ int GuideFrame::SaveProfile()
|
||||
const std::string §ion_name = AppConfig::SECTION_FILAMENTS;
|
||||
std::map<std::string, std::string> section_new;
|
||||
m_appconfig_new.clear_section(section_name);
|
||||
for (auto it = m_ProfileJson["filament"].begin(); it != m_ProfileJson["filament"].end(); ++it) {
|
||||
if (it.value()["selected"] == 1){
|
||||
section_new[it.key()] = "true";
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_ProfileJson_mutex);
|
||||
for (auto it = m_ProfileJson["filament"].begin(); it != m_ProfileJson["filament"].end(); ++it) {
|
||||
if (it.value()["selected"] == 1){
|
||||
section_new[it.key()] = "true";
|
||||
}
|
||||
}
|
||||
}
|
||||
m_appconfig_new.set_section(section_name, section_new);
|
||||
@@ -653,28 +682,30 @@ int GuideFrame::SaveProfile()
|
||||
//set vendors to app_config
|
||||
Slic3r::AppConfig::VendorMap empty_vendor_map;
|
||||
m_appconfig_new.set_vendors(empty_vendor_map);
|
||||
for (auto it = m_ProfileJson["model"].begin(); it != m_ProfileJson["model"].end(); ++it)
|
||||
{
|
||||
if (it.value().is_object()) {
|
||||
json temp_model = it.value();
|
||||
std::string model_name = temp_model["model"];
|
||||
std::string vendor_name = temp_model["vendor"];
|
||||
std::string selected = temp_model["nozzle_selected"];
|
||||
boost::trim(selected);
|
||||
std::string nozzle;
|
||||
while (selected.size() > 0) {
|
||||
auto pos = selected.find(';');
|
||||
if (pos != std::string::npos) {
|
||||
nozzle = selected.substr(0, pos);
|
||||
m_appconfig_new.set_variant(vendor_name, model_name, nozzle, "true");
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format("vendor_name %1%, model_name %2%, nozzle %3% selected")%vendor_name %model_name %nozzle;
|
||||
selected = selected.substr(pos + 1);
|
||||
boost::trim(selected);
|
||||
}
|
||||
else {
|
||||
m_appconfig_new.set_variant(vendor_name, model_name, selected, "true");
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format("vendor_name %1%, model_name %2%, nozzle %3% selected")%vendor_name %model_name %selected;
|
||||
break;
|
||||
std::lock_guard<std::mutex> lock(m_ProfileJson_mutex);
|
||||
for (auto it = m_ProfileJson["model"].begin(); it != m_ProfileJson["model"].end(); ++it) {
|
||||
if (it.value().is_object()) {
|
||||
json temp_model = it.value();
|
||||
std::string model_name = temp_model["model"];
|
||||
std::string vendor_name = temp_model["vendor"];
|
||||
std::string selected = temp_model["nozzle_selected"];
|
||||
boost::trim(selected);
|
||||
std::string nozzle;
|
||||
while (selected.size() > 0) {
|
||||
auto pos = selected.find(';');
|
||||
if (pos != std::string::npos) {
|
||||
nozzle = selected.substr(0, pos);
|
||||
m_appconfig_new.set_variant(vendor_name, model_name, nozzle, "true");
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format("vendor_name %1%, model_name %2%, nozzle %3% selected")%vendor_name %model_name %nozzle;
|
||||
selected = selected.substr(pos + 1);
|
||||
boost::trim(selected);
|
||||
}
|
||||
else {
|
||||
m_appconfig_new.set_variant(vendor_name, model_name, selected, "true");
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format("vendor_name %1%, model_name %2%, nozzle %3% selected")%vendor_name %model_name %selected;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -997,6 +1028,7 @@ int GuideFrame::GetFilamentInfo( std::string VendorDirectory, json & pFilaList,
|
||||
|
||||
int GuideFrame::LoadProfileData()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_ProfileJson_mutex);
|
||||
try {
|
||||
m_ProfileJson = json::parse("{}");
|
||||
m_ProfileJson["model"] = json::array();
|
||||
@@ -1068,7 +1100,7 @@ int GuideFrame::LoadProfileData()
|
||||
}
|
||||
|
||||
//sync to web
|
||||
std::string strAll = m_ProfileJson.dump(-1, ' ', false, json::error_handler_t::ignore);
|
||||
std::string strAll = m_ProfileJson.dump(-1, ' ', false, json::error_handler_t::ignore); // Already locked at function start
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ", finished, json contents: " << std::endl << strAll;
|
||||
json m_Res = json::object();
|
||||
@@ -1093,6 +1125,7 @@ int GuideFrame::LoadProfileData()
|
||||
|
||||
int GuideFrame::SaveProfileData()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_ProfileJson_mutex);
|
||||
try {
|
||||
const auto enabled_filaments = wxGetApp().app_config->has_section(AppConfig::SECTION_FILAMENTS) ? wxGetApp().app_config->get_section(AppConfig::SECTION_FILAMENTS) : std::map<std::string, std::string>();
|
||||
m_appconfig_new.set_vendors(*wxGetApp().app_config);
|
||||
|
||||
@@ -30,12 +30,14 @@
|
||||
#include <libslic3r/Utils.hpp>
|
||||
#include "CreatePresetsDialog.hpp"
|
||||
#include "slic3r/GUI/Tab.hpp"
|
||||
#include <mutex>
|
||||
|
||||
using namespace nlohmann;
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
extern json m_ProfileJson;
|
||||
extern std::mutex m_ProfileJson_mutex;
|
||||
extern void StringReplace(string& strBase, string strSrc, string strDes);
|
||||
|
||||
static wxString update_custom_filaments()
|
||||
@@ -112,7 +114,7 @@ static wxString update_custom_filaments()
|
||||
}
|
||||
|
||||
WebPresetDialog::WebPresetDialog(GUI_App* pGUI, long style)
|
||||
: DPIDialog((wxWindow*) (pGUI->mainframe), wxID_ANY, "Snapmaker Orca", wxDefaultPosition, wxDefaultSize, style), m_appconfig_new()
|
||||
: DPIDialog((wxWindow*) (nullptr), wxID_ANY, "Snapmaker Orca", wxDefaultPosition, wxDefaultSize, style), m_appconfig_new()
|
||||
{
|
||||
SetBackgroundColour(*wxWHITE);
|
||||
// INI
|
||||
@@ -181,7 +183,7 @@ WebPresetDialog::WebPresetDialog(GUI_App* pGUI, long style)
|
||||
// Connect the idle events
|
||||
// Bind(wxEVT_IDLE, &WebPresetDialog::OnIdle, this);
|
||||
// Bind(wxEVT_CLOSE_WINDOW, &WebPresetDialog::OnClose, this);
|
||||
std::thread* load_thread = new std::thread([this]() {
|
||||
m_load_thread = new std::thread([this]() {
|
||||
LoadProfile();
|
||||
});
|
||||
// LoadProfile();
|
||||
@@ -424,7 +426,11 @@ void WebPresetDialog::OnScriptMessage(wxWebViewEvent& evt)
|
||||
m_Res["command"] = "response_userguide_profile";
|
||||
m_Res["sequence_id"] = "10001";
|
||||
|
||||
json res_json = m_ProfileJson;
|
||||
json res_json;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_ProfileJson_mutex);
|
||||
res_json = m_ProfileJson;
|
||||
}
|
||||
|
||||
// 把所有的选中信息取消,换成当前连接的机器
|
||||
std::string model_name = "";
|
||||
@@ -491,27 +497,30 @@ void WebPresetDialog::OnScriptMessage(wxWebViewEvent& evt)
|
||||
} else if (strCmd == "save_userguide_models") {
|
||||
json MSelected = j["data"];
|
||||
|
||||
int nModel = m_ProfileJson["model"].size();
|
||||
bool isFind = false;
|
||||
for (int m = 0; m < nModel; m++) {
|
||||
if (m_ProfileJson["model"][m]["model"].get<std::string>() == MSelected.begin().value()["model"].get<std::string>()) {
|
||||
// 绑定的预设已被选入系统
|
||||
isFind = true;
|
||||
std::string nozzle_selected = m_ProfileJson["model"][m]["nozzle_selected"].get<std::string>();
|
||||
std::string se_nozz_selected = MSelected.begin().value()["nozzle_diameter"].get<std::string>();
|
||||
if (nozzle_selected.find(se_nozz_selected) == std::string::npos) {
|
||||
nozzle_selected += ";" + se_nozz_selected;
|
||||
m_ProfileJson["model"][m]["nozzle_selected"] = nozzle_selected;
|
||||
}
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_ProfileJson_mutex);
|
||||
int nModel = m_ProfileJson["model"].size();
|
||||
bool isFind = false;
|
||||
for (int m = 0; m < nModel; m++) {
|
||||
if (m_ProfileJson["model"][m]["model"].get<std::string>() == MSelected.begin().value()["model"].get<std::string>()) {
|
||||
// 绑定的预设已被选入系统
|
||||
isFind = true;
|
||||
std::string nozzle_selected = m_ProfileJson["model"][m]["nozzle_selected"].get<std::string>();
|
||||
std::string se_nozz_selected = MSelected.begin().value()["nozzle_diameter"].get<std::string>();
|
||||
if (nozzle_selected.find(se_nozz_selected) == std::string::npos) {
|
||||
nozzle_selected += ";" + se_nozz_selected;
|
||||
m_ProfileJson["model"][m]["nozzle_selected"] = nozzle_selected;
|
||||
}
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isFind) {
|
||||
json new_item;
|
||||
new_item["model"] = MSelected.begin().value()["model"];
|
||||
new_item["nozzle_selected"] = MSelected.begin().value()["nozzle_diameter"];
|
||||
m_ProfileJson["model"].push_back(new_item);
|
||||
}
|
||||
}
|
||||
if (!isFind) {
|
||||
json new_item;
|
||||
new_item["model"] = MSelected.begin().value()["model"];
|
||||
new_item["nozzle_selected"] = MSelected.begin().value()["nozzle_diameter"];
|
||||
m_ProfileJson["model"].push_back(new_item);
|
||||
}
|
||||
|
||||
DeviceInfo info;
|
||||
@@ -548,22 +557,29 @@ void WebPresetDialog::OnScriptMessage(wxWebViewEvent& evt)
|
||||
}
|
||||
|
||||
} else if (strCmd == "save_userguide_filaments") {
|
||||
// reset
|
||||
for (auto it = m_ProfileJson["filament"].begin(); it != m_ProfileJson["filament"].end(); ++it) {
|
||||
m_ProfileJson["filament"][it.key()]["selected"] = 0;
|
||||
}
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_ProfileJson_mutex);
|
||||
// reset
|
||||
for (auto it = m_ProfileJson["filament"].begin(); it != m_ProfileJson["filament"].end(); ++it) {
|
||||
m_ProfileJson["filament"][it.key()]["selected"] = 0;
|
||||
}
|
||||
|
||||
json fSelected = j["data"]["filament"];
|
||||
int nF = fSelected.size();
|
||||
for (int m = 0; m < nF; m++) {
|
||||
std::string fName = fSelected[m];
|
||||
json fSelected = j["data"]["filament"];
|
||||
int nF = fSelected.size();
|
||||
for (int m = 0; m < nF; m++) {
|
||||
std::string fName = fSelected[m];
|
||||
|
||||
m_ProfileJson["filament"][fName]["selected"] = 1;
|
||||
m_ProfileJson["filament"][fName]["selected"] = 1;
|
||||
}
|
||||
}
|
||||
} else if (strCmd == "user_guide_finish") {
|
||||
SaveProfile();
|
||||
|
||||
std::string oldregion = m_ProfileJson["region"];
|
||||
std::string oldregion;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_ProfileJson_mutex);
|
||||
oldregion = m_ProfileJson["region"];
|
||||
}
|
||||
bool bLogin = false;
|
||||
if (m_Region != oldregion) {
|
||||
AppConfig* config = GUI::wxGetApp().app_config;
|
||||
@@ -590,7 +606,10 @@ void WebPresetDialog::OnScriptMessage(wxWebViewEvent& evt)
|
||||
this->Close();
|
||||
} else if (strCmd == "save_region") {
|
||||
m_Region = j["region"];
|
||||
m_ProfileJson["region"] = m_Region;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_ProfileJson_mutex);
|
||||
m_ProfileJson["region"] = m_Region;
|
||||
}
|
||||
}
|
||||
else if (strCmd == "common_openurl") {
|
||||
|
||||
@@ -622,7 +641,10 @@ void WebPresetDialog::OnScriptMessage(wxWebViewEvent& evt)
|
||||
BOOST_LOG_TRIVIAL(trace) << "WebPresetDialog::OnScriptMessage;Error:" << e.what();
|
||||
}
|
||||
|
||||
wxString strAll = m_ProfileJson.dump(-1, ' ', false, json::error_handler_t::ignore);
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_ProfileJson_mutex);
|
||||
wxString strAll = m_ProfileJson.dump(-1, ' ', false, json::error_handler_t::ignore);
|
||||
}
|
||||
}
|
||||
|
||||
void WebPresetDialog::RunScript(const wxString& javascript)
|
||||
@@ -754,7 +776,11 @@ int WebPresetDialog::SaveProfile()
|
||||
|
||||
m_MainPtr->app_config->save();
|
||||
|
||||
std::string strAll = m_ProfileJson.dump(-1, ' ', false, json::error_handler_t::ignore);
|
||||
std::string strAll;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_ProfileJson_mutex);
|
||||
strAll = m_ProfileJson.dump(-1, ' ', false, json::error_handler_t::ignore);
|
||||
}
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "before save to app_config: " << std::endl << strAll;
|
||||
|
||||
@@ -762,9 +788,12 @@ int WebPresetDialog::SaveProfile()
|
||||
const std::string& section_name = AppConfig::SECTION_FILAMENTS;
|
||||
std::map<std::string, std::string> section_new;
|
||||
m_appconfig_new.clear_section(section_name);
|
||||
for (auto it = m_ProfileJson["filament"].begin(); it != m_ProfileJson["filament"].end(); ++it) {
|
||||
if (it.value()["selected"] == 1) {
|
||||
section_new[it.key()] = "true";
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_ProfileJson_mutex);
|
||||
for (auto it = m_ProfileJson["filament"].begin(); it != m_ProfileJson["filament"].end(); ++it) {
|
||||
if (it.value()["selected"] == 1) {
|
||||
section_new[it.key()] = "true";
|
||||
}
|
||||
}
|
||||
}
|
||||
m_appconfig_new.set_section(section_name, section_new);
|
||||
@@ -772,30 +801,33 @@ int WebPresetDialog::SaveProfile()
|
||||
// set vendors to app_config
|
||||
Slic3r::AppConfig::VendorMap empty_vendor_map;
|
||||
m_appconfig_new.set_vendors(empty_vendor_map);
|
||||
for (auto it = m_ProfileJson["model"].begin(); it != m_ProfileJson["model"].end(); ++it) {
|
||||
if (it.value().is_object()) {
|
||||
json temp_model = it.value();
|
||||
std::string model_name = temp_model["model"];
|
||||
std::string vendor_name = temp_model["vendor"];
|
||||
std::string selected = temp_model["nozzle_selected"];
|
||||
boost::trim(selected);
|
||||
std::string nozzle;
|
||||
while (selected.size() > 0) {
|
||||
auto pos = selected.find(';');
|
||||
if (pos != std::string::npos) {
|
||||
nozzle = selected.substr(0, pos);
|
||||
m_appconfig_new.set_variant(vendor_name, model_name, nozzle, "true");
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__
|
||||
<< boost::format("vendor_name %1%, model_name %2%, nozzle %3% selected") % vendor_name %
|
||||
model_name % nozzle;
|
||||
selected = selected.substr(pos + 1);
|
||||
boost::trim(selected);
|
||||
} else {
|
||||
m_appconfig_new.set_variant(vendor_name, model_name, selected, "true");
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__
|
||||
<< boost::format("vendor_name %1%, model_name %2%, nozzle %3% selected") % vendor_name %
|
||||
model_name % selected;
|
||||
break;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_ProfileJson_mutex);
|
||||
for (auto it = m_ProfileJson["model"].begin(); it != m_ProfileJson["model"].end(); ++it) {
|
||||
if (it.value().is_object()) {
|
||||
json temp_model = it.value();
|
||||
std::string model_name = temp_model["model"];
|
||||
std::string vendor_name = temp_model["vendor"];
|
||||
std::string selected = temp_model["nozzle_selected"];
|
||||
boost::trim(selected);
|
||||
std::string nozzle;
|
||||
while (selected.size() > 0) {
|
||||
auto pos = selected.find(';');
|
||||
if (pos != std::string::npos) {
|
||||
nozzle = selected.substr(0, pos);
|
||||
m_appconfig_new.set_variant(vendor_name, model_name, nozzle, "true");
|
||||
BOOST_LOG_TRIVIAL(info)
|
||||
<< __FUNCTION__
|
||||
<< boost::format("vendor_name %1%, model_name %2%, nozzle %3% selected") % vendor_name % model_name % nozzle;
|
||||
selected = selected.substr(pos + 1);
|
||||
boost::trim(selected);
|
||||
} else {
|
||||
m_appconfig_new.set_variant(vendor_name, model_name, selected, "true");
|
||||
BOOST_LOG_TRIVIAL(info)
|
||||
<< __FUNCTION__
|
||||
<< boost::format("vendor_name %1%, model_name %2%, nozzle %3% selected") % vendor_name % model_name % selected;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1121,6 +1153,7 @@ int WebPresetDialog::GetFilamentInfo(std::string VendorDirectory, json& pFilaLis
|
||||
|
||||
int WebPresetDialog::LoadProfile()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_ProfileJson_mutex);
|
||||
try {
|
||||
// wxString ExePath = boost::dll::program_location().parent_path().string();
|
||||
// wxString TargetFolder = ExePath + "\\resources\\profiles\\";
|
||||
|
||||
@@ -122,6 +122,8 @@ public:
|
||||
|
||||
wxString m_sm_user_agent;
|
||||
std::string m_editing_filament_id;
|
||||
|
||||
std::thread* m_load_thread = nullptr;
|
||||
};
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
|
||||
@@ -1745,7 +1745,7 @@ void PresetUpdater::import_flutter_web()
|
||||
|
||||
wxString message;
|
||||
if (!outdated_presets.empty()) {
|
||||
message = _L("The following profiles could not be imported due to outdated versions.") + "\n";
|
||||
message = _L("This web resouce could not be imported due to outdated versions.") + "\n";
|
||||
for (const auto& preset : outdated_presets) {
|
||||
message += "• " + preset + "\n";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user