ENH:add reload to thread
Change-Id: I7d7d1bf38fbb31cd7f56dd24d1c8bcc3147ab56e
This commit is contained in:
parent
7235e146e2
commit
629b717148
|
@ -70,96 +70,98 @@ ProjectPanel::~ProjectPanel() {}
|
||||||
|
|
||||||
void ProjectPanel::on_reload(wxCommandEvent& evt)
|
void ProjectPanel::on_reload(wxCommandEvent& evt)
|
||||||
{
|
{
|
||||||
std::string update_type;
|
boost::thread reload = boost::thread([this] {
|
||||||
std::string license;
|
std::string update_type;
|
||||||
std::string model_name;
|
std::string license;
|
||||||
std::string model_author;
|
std::string model_name;
|
||||||
std::string cover_file;
|
std::string model_author;
|
||||||
std::string description;
|
std::string cover_file;
|
||||||
std::map<std::string, std::vector<json>> files;
|
std::string description;
|
||||||
|
std::map<std::string, std::vector<json>> files;
|
||||||
|
|
||||||
std::string p_name;
|
std::string p_name;
|
||||||
std::string p_author;
|
std::string p_author;
|
||||||
std::string p_description;
|
std::string p_description;
|
||||||
std::string p_cover_file;
|
std::string p_cover_file;
|
||||||
|
|
||||||
Model model = wxGetApp().plater()->model();
|
Model model = wxGetApp().plater()->model();
|
||||||
|
|
||||||
license = model.model_info->license;
|
license = model.model_info->license;
|
||||||
model_name = model.model_info->model_name;
|
model_name = model.model_info->model_name;
|
||||||
cover_file = model.model_info->cover_file;
|
cover_file = model.model_info->cover_file;
|
||||||
description = model.model_info->description;
|
description = model.model_info->description;
|
||||||
update_type = model.model_info->origin;
|
update_type = model.model_info->origin;
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!model.model_info->copyright.empty()) {
|
if (!model.model_info->copyright.empty()) {
|
||||||
json copy_right = json::parse(model.model_info->copyright);
|
json copy_right = json::parse(model.model_info->copyright);
|
||||||
|
|
||||||
if (copy_right.is_array()) {
|
if (copy_right.is_array()) {
|
||||||
for (auto it = copy_right.begin(); it != copy_right.end(); it++) {
|
for (auto it = copy_right.begin(); it != copy_right.end(); it++) {
|
||||||
if ((*it).contains("author")) {
|
if ((*it).contains("author")) {
|
||||||
model_author = (*it)["author"].get<std::string>();
|
model_author = (*it)["author"].get<std::string>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
catch (...) {
|
||||||
catch (...) {
|
;
|
||||||
;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (model_author.empty() && model.design_info != nullptr)
|
if (model_author.empty() && model.design_info != nullptr)
|
||||||
model_author = model.design_info->Designer;
|
model_author = model.design_info->Designer;
|
||||||
|
|
||||||
if (model.profile_info != nullptr) {
|
if (model.profile_info != nullptr) {
|
||||||
p_name = model.profile_info->ProfileTile;
|
p_name = model.profile_info->ProfileTile;
|
||||||
p_description = model.profile_info->ProfileDescription;
|
p_description = model.profile_info->ProfileDescription;
|
||||||
p_cover_file = model.profile_info->ProfileCover;
|
p_cover_file = model.profile_info->ProfileCover;
|
||||||
p_author = model.profile_info->ProfileUserName;
|
p_author = model.profile_info->ProfileUserName;
|
||||||
}
|
}
|
||||||
|
|
||||||
//file info
|
//file info
|
||||||
std::string file_path = encode_path(wxGetApp().plater()->model().get_auxiliary_file_temp_path().c_str());
|
std::string file_path = encode_path(wxGetApp().plater()->model().get_auxiliary_file_temp_path().c_str());
|
||||||
if (!file_path.empty()) {
|
if (!file_path.empty()) {
|
||||||
files = Reload(file_path);
|
files = Reload(file_path);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
clear_model_info();
|
clear_model_info();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
json j;
|
json j;
|
||||||
j["model"]["license"] = license;
|
j["model"]["license"] = license;
|
||||||
j["model"]["name"] = wxGetApp().url_encode(model_name);
|
j["model"]["name"] = wxGetApp().url_encode(model_name);
|
||||||
j["model"]["author"] = wxGetApp().url_encode(model_author);;
|
j["model"]["author"] = wxGetApp().url_encode(model_author);;
|
||||||
j["model"]["cover_img"] = wxGetApp().url_encode(cover_file);
|
j["model"]["cover_img"] = wxGetApp().url_encode(cover_file);
|
||||||
j["model"]["description"] = wxGetApp().url_encode(description);
|
j["model"]["description"] = wxGetApp().url_encode(description);
|
||||||
j["model"]["preview_img"] = files["Model Pictures"];
|
j["model"]["preview_img"] = files["Model Pictures"];
|
||||||
j["model"]["upload_type"] = update_type;
|
j["model"]["upload_type"] = update_type;
|
||||||
|
|
||||||
j["file"]["BOM"] = files["Bill of Materials"];
|
j["file"]["BOM"] = files["Bill of Materials"];
|
||||||
j["file"]["Assembly"] = files["Assembly Guide"];
|
j["file"]["Assembly"] = files["Assembly Guide"];
|
||||||
j["file"]["Other"] = files["Others"];
|
j["file"]["Other"] = files["Others"];
|
||||||
|
|
||||||
j["profile"]["name"] = wxGetApp().url_encode(p_name);
|
j["profile"]["name"] = wxGetApp().url_encode(p_name);
|
||||||
j["profile"]["author"] = wxGetApp().url_encode(p_author);
|
j["profile"]["author"] = wxGetApp().url_encode(p_author);
|
||||||
j["profile"]["description"] = wxGetApp().url_encode(p_description);
|
j["profile"]["description"] = wxGetApp().url_encode(p_description);
|
||||||
j["profile"]["cover_img"] = wxGetApp().url_encode(p_cover_file);
|
j["profile"]["cover_img"] = wxGetApp().url_encode(p_cover_file);
|
||||||
j["profile"]["preview_img"] = files["Profile Pictures"];
|
j["profile"]["preview_img"] = files["Profile Pictures"];
|
||||||
|
|
||||||
json m_Res = json::object();
|
json m_Res = json::object();
|
||||||
m_Res["command"] = "show_3mf_info";
|
m_Res["command"] = "show_3mf_info";
|
||||||
m_Res["sequence_id"] = std::to_string(ProjectPanel::m_sequence_id++);
|
m_Res["sequence_id"] = std::to_string(ProjectPanel::m_sequence_id++);
|
||||||
m_Res["model"] = j;
|
m_Res["model"] = j;
|
||||||
|
|
||||||
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, ' ', false, json::error_handler_t::ignore));
|
||||||
|
|
||||||
if (m_web_init_completed) {
|
if (m_web_init_completed) {
|
||||||
wxGetApp().CallAfter([this, strJS] {
|
wxGetApp().CallAfter([this, strJS] {
|
||||||
RunScript(strJS.ToStdString());
|
RunScript(strJS.ToStdString());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectPanel::msw_rescale()
|
void ProjectPanel::msw_rescale()
|
||||||
|
|
Loading…
Reference in New Issue