FIX: parts file download failed && canvas display error

Jira: [STUDIO-13253]
Change-Id: I6ce11c0ceb1c4f7ed49c41eb9c6d7a6d96e866f9
(cherry picked from commit 37f742007bc168d8a3365ca617c7bd27bafca038)
This commit is contained in:
hemai 2025-07-08 19:23:38 +08:00 committed by Noisyfox
parent 1928add5a1
commit 7d147cc550
8 changed files with 379 additions and 376 deletions

View file

@ -5216,6 +5216,7 @@ void MachineObject::update_slice_info(std::string project_id, std::string profil
if (plate_idx >= 0) {
plate_index = plate_idx;
this->m_plate_index = plate_idx;
}
else {
std::string subtask_json;
@ -5278,8 +5279,7 @@ void MachineObject::update_slice_info(std::string project_id, std::string profil
BOOST_LOG_TRIVIAL(error) << "task_info: get subtask id failed!";
}
}
this->m_plate_index = plate_index;
// this->m_plate_index = plate_index;
});
}
}

File diff suppressed because it is too large Load diff

View file

@ -38,19 +38,19 @@ class PartSkipConfirmDialog : public DPIDialog
{
private:
protected:
Label *m_msg_label;
Label *m_tip_label;
Button *m_apply_button;
Label *m_msg_label;
Label *m_tip_label;
Button *m_apply_button;
public:
PartSkipConfirmDialog(wxWindow *parent);
~PartSkipConfirmDialog();
void on_dpi_changed(const wxRect &suggested_rect);
Button* GetConfirmButton();
void SetMsgLabel(wxString msg);
void SetTipLabel(wxString msg);
bool Show(bool show);
void on_dpi_changed(const wxRect &suggested_rect);
Button *GetConfirmButton();
void SetMsgLabel(wxString msg);
void SetTipLabel(wxString msg);
bool Show(bool show);
};
class PartSkipDialog : public DPIDialog
@ -69,68 +69,69 @@ public:
MachineObject *m_obj{nullptr};
wxSimplebook* m_simplebook;
wxPanel* m_book_third_panel;
wxPanel* m_book_second_panel;
wxPanel* m_book_first_panel;
wxSimplebook *m_simplebook;
wxPanel *m_book_third_panel;
wxPanel *m_book_second_panel;
wxPanel *m_book_first_panel;
SkipPartCanvas* m_canvas;
Button* m_zoom_in_btn;
Button* m_zoom_out_btn;
Button* m_switch_drag_btn;
CheckBox* m_all_checkbox;
Button* m_percent_label;
Label* m_all_label;
wxPanel* m_line;
wxPanel* m_line_top;
wxScrolledWindow* m_list_view;
SkipPartCanvas *m_canvas;
Button *m_zoom_in_btn;
Button *m_zoom_out_btn;
Button *m_switch_drag_btn;
CheckBox *m_all_checkbox;
Button *m_percent_label;
Label *m_all_label;
wxPanel *m_line;
wxPanel *m_line_top;
wxScrolledWindow *m_list_view;
wxPanel* m_dlg_placeholder;
Label* m_cnt_label;
Label* m_tot_label;
wxPanel *m_dlg_placeholder;
Label *m_cnt_label;
Label *m_tot_label;
Button* m_apply_btn;
Button *m_apply_btn;
Label* m_loading_label;
Label* m_retry_label;
ScalableBitmap* m_retry_icon;
wxStaticBitmap* m_retry_bitmap;
Label *m_loading_label;
Label *m_retry_label;
ScalableBitmap *m_retry_icon;
wxStaticBitmap *m_retry_bitmap;
wxBoxSizer* m_sizer;
wxBoxSizer* m_dlg_sizer;
wxBoxSizer* m_dlg_content_sizer;
wxBoxSizer* m_dlg_btn_sizer;
wxBoxSizer* m_canvas_sizer;
wxBoxSizer* m_canvas_btn_sizer;
wxBoxSizer* m_list_sizer;
wxBoxSizer* m_scroll_sizer;
wxBoxSizer* m_book_first_sizer;
wxBoxSizer* m_book_second_sizer;
wxBoxSizer* m_book_second_btn_sizer;
Button* m_second_retry_btn;
AnimaIcon* m_loading_icon;
wxBoxSizer *m_sizer;
wxBoxSizer *m_dlg_sizer;
wxBoxSizer *m_dlg_content_sizer;
wxBoxSizer *m_dlg_btn_sizer;
wxBoxSizer *m_canvas_sizer;
wxBoxSizer *m_canvas_btn_sizer;
wxBoxSizer *m_list_sizer;
wxBoxSizer *m_scroll_sizer;
wxBoxSizer *m_book_first_sizer;
wxBoxSizer *m_book_second_sizer;
wxBoxSizer *m_book_second_btn_sizer;
Button *m_second_retry_btn;
AnimaIcon *m_loading_icon;
private:
int m_zoom_percent{100};
int m_plate_idx{-1};
int m_zoom_percent{100};
bool m_is_drag{false};
bool m_print_lock{true};
std::map<uint32_t, PartState> m_parts_state;
std::map<uint32_t, PartState> m_parts_state;
std::map<uint32_t, std::string> m_parts_name;
std::vector<int> m_partskip_ids;
std::vector<int> m_partskip_ids;
enum URL_STATE m_url_state = URL_STATE::URL_TCP;
PartsInfo GetPartsInfo();
bool is_drag_mode();
bool is_drag_mode();
boost::shared_ptr<PrinterFileSystem> m_file_sys;
bool m_file_sys_result{false};
std::string m_timestamp;
std::string m_tmp_path;
std::vector<string> m_local_paths;
std::vector<string> m_target_paths;
std::string create_tmp_path();
bool m_file_sys_result{false};
std::string m_timestamp;
std::string m_tmp_path;
std::vector<string> m_local_paths;
std::vector<string> m_target_paths;
std::string create_tmp_path();
bool is_local_file_existed(const std::vector<string> &local_paths);
@ -139,7 +140,6 @@ private:
void OnFileSystemResult(wxCommandEvent &event);
void fetchUrl(boost::weak_ptr<PrinterFileSystem> wfs);
void OnZoomIn(wxCommandEvent &event);
void OnZoomOut(wxCommandEvent &event);
void OnSwitchDrag(wxCommandEvent &event);
@ -156,4 +156,4 @@ private:
void OnApplyDialog(wxCommandEvent &event);
};
}}
}} // namespace Slic3r::GUI

View file

@ -252,6 +252,7 @@ struct PrinterFileSystem::Download : Progress
void PrinterFileSystem::GetPickImages(const std::vector<std::string> &local_paths, const std::vector<std::string> &targetpaths)
{
m_download_states.clear();
GetPickImage(1, local_paths[0], targetpaths[0]);
GetPickImage(2, local_paths[1], targetpaths[1]);
@ -303,6 +304,9 @@ void PrinterFileSystem::DownloadRamFile(int index, const std::string &local_path
wxLogWarning("Download failed: result = 1");
return ERROR_JSON;
}
if(mem_dl_json.contains("size") && mem_dl_json["size"] == 0 )
return FILE_SIZE_ERR;
return CONTINUE;
}
@ -355,13 +359,27 @@ void PrinterFileSystem::DownloadRamFile(int index, const std::string &local_path
if (result == CONTINUE) { return; }
std::string msg;
if (result == SUCCESS) {
wxLogMessage("DownloadImageFromRam finished: %s", download->local_path);
msg = "SUCCESS";
SendChangedEvent(EVT_RAMDOWNLOAD, result, result ? download->error : download->local_path);
if (std::filesystem::exists(download->local_path)) {
m_download_states.emplace_back(true);
BOOST_LOG_TRIVIAL(info) <<"DownloadImageFromRam finished: " << download->local_path << "result = " << result;
}else{
m_download_states.emplace_back(false);
BOOST_LOG_TRIVIAL(warning) <<"DownloadImageFromRam finished, but file not exist: " << download->local_path << "result = " << result;
}
} else if (result != CONTINUE) {
wxLogWarning("DownloadImageFromRam failed: %s", download->error);
msg = "ERROR";
SendChangedEvent(EVT_RAMDOWNLOAD, result, result ? download->error : download->local_path);
m_download_states.emplace_back(false);
BOOST_LOG_TRIVIAL(warning) << "DownloadImageFromRam failed: " << download->error << "result = " << result;
}
if(m_download_states.size() == 3){
if(m_download_states[0] && m_download_states[1] && m_download_states[2]){
SendChangedEvent(EVT_RAMDOWNLOAD, SUCCESS);
}else{
// FILE_NO_EXIST is not really error_code
SendChangedEvent(EVT_RAMDOWNLOAD, FILE_NO_EXIST);
}
}else{
BOOST_LOG_TRIVIAL(warning) << "m_download_states current size is : " << m_download_states.size();
}
},param);
}

View file

@ -317,6 +317,8 @@ private:
size_t m_lock_end = 0;
int m_task_flags = 0;
std::vector<bool> m_download_states;
private:
struct Session
{

View file

@ -9,6 +9,7 @@
#include <expat.h>
#include <earcut/earcut.hpp>
#include <libslic3r/Color.hpp>
#include <filesystem>
wxDEFINE_EVENT(EVT_ZOOM_PERCENT, wxCommandEvent);
wxDEFINE_EVENT(EVT_CANVAS_PART, wxCommandEvent);
@ -32,6 +33,8 @@ SkipPartCanvas::SkipPartCanvas(wxWindow *parent, const wxGLAttributes& dispAttrs
void SkipPartCanvas::LoadPickImage(const std::string & path)
{
if(!std::filesystem::exists(path)) return;
auto ParseShapeId = [](cv::Mat image, const std::vector<std::vector<cv::Point>> &contours, const std::vector<cv::Vec4i> &hierarchy, int root_idx) -> uint32_t {
cv::Mat mask = cv::Mat::zeros(image.size(), CV_8UC1);
@ -249,8 +252,12 @@ void SkipPartCanvas::Render()
int w, h;
GetClientSize(&w, &h);
#if defined(__APPLE__)
double scale = GetDPIScaleFactor();
glViewport(0, 0, w * scale, h * scale);
#else
glViewport(0, 0, w, h);
#endif
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
auto view_rect = ViewPtToImagePt(wxPoint(w, h));
@ -661,7 +668,14 @@ void XMLCALL ModelSettingHelper::EndElementHandler(void *userData, const XML_Cha
}
}
std::vector<PlateInfo> ModelSettingHelper::GetPlates() { return context_.plates; }
std::vector<ObjectInfo> ModelSettingHelper::GetPlateObjects(int plate_idx) {
for (const auto &plate : context_.plates) {
if (plate.index == plate_idx) {
return plate.objects;
}
}
return std::vector<ObjectInfo>();
}
void ModelSettingHelper::DataHandler(const XML_Char *s, int len)
{

View file

@ -150,7 +150,7 @@ public:
ModelSettingHelper(const std::string &path);
bool Parse();
std::vector<PlateInfo> GetPlates();
std::vector<ObjectInfo> GetPlateObjects(int plate_idx);
private:
std::string path_;

View file

@ -9,12 +9,13 @@
AnimaIcon::AnimaIcon(wxWindow *parent, wxWindowID id, std::vector<std::string> img_list, std::string img_enable, int ivt)
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize), m_ivt(ivt)
{
auto sizer = new wxBoxSizer(wxHORIZONTAL);
SetBackgroundColour((wxColour(255, 255, 255)));
m_size = 20;
m_size = 25;
//add ScalableBitmap
for (const auto &filename : img_list) m_images.emplace_back(create_scaled_bitmap(filename, this, FromDIP(m_size)));
m_image_enable = create_scaled_bitmap(img_enable, this, FromDIP(m_size-8));
for (const auto &filename : img_list) m_images.emplace_back(create_scaled_bitmap(filename, this, m_size));
m_image_enable = create_scaled_bitmap(img_enable, this, m_size-8);
// show first wxStaticBitmap
if (!m_images.empty()) m_bitmap = new wxStaticBitmap(this, wxID_ANY, m_images[0], wxDefaultPosition, wxSize(FromDIP(m_size), FromDIP(m_size)));
@ -47,12 +48,13 @@ AnimaIcon::AnimaIcon(wxWindow *parent, wxWindowID id, std::vector<std::string> i
SetCursor(wxCursor(wxCURSOR_ARROW));
e.Skip();
});
sizer->Add(m_bitmap, 0, wxALIGN_CENTER, 0);
SetSizer(sizer);
SetSize(wxSize(FromDIP(m_size), FromDIP(m_size)));
SetMaxSize(wxSize(FromDIP(m_size), FromDIP(m_size)));
SetMinSize(wxSize(FromDIP(m_size), FromDIP(m_size)));
Refresh();
Layout();
Fit();
Play();
}