mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-20 11:53:48 +00:00
FIX: parts file download failed && canvas display error
Jira: [STUDIO-13253] Change-Id: I6ce11c0ceb1c4f7ed49c41eb9c6d7a6d96e866f9 (cherry picked from commit 37f742007bc168d8a3365ca617c7bd27bafca038)
This commit is contained in:
@@ -5216,6 +5216,7 @@ void MachineObject::update_slice_info(std::string project_id, std::string profil
|
|||||||
|
|
||||||
if (plate_idx >= 0) {
|
if (plate_idx >= 0) {
|
||||||
plate_index = plate_idx;
|
plate_index = plate_idx;
|
||||||
|
this->m_plate_index = plate_idx;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
std::string subtask_json;
|
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!";
|
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
@@ -38,19 +38,19 @@ class PartSkipConfirmDialog : public DPIDialog
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
protected:
|
protected:
|
||||||
Label *m_msg_label;
|
Label *m_msg_label;
|
||||||
Label *m_tip_label;
|
Label *m_tip_label;
|
||||||
Button *m_apply_button;
|
Button *m_apply_button;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PartSkipConfirmDialog(wxWindow *parent);
|
PartSkipConfirmDialog(wxWindow *parent);
|
||||||
~PartSkipConfirmDialog();
|
~PartSkipConfirmDialog();
|
||||||
|
|
||||||
void on_dpi_changed(const wxRect &suggested_rect);
|
void on_dpi_changed(const wxRect &suggested_rect);
|
||||||
Button* GetConfirmButton();
|
Button *GetConfirmButton();
|
||||||
void SetMsgLabel(wxString msg);
|
void SetMsgLabel(wxString msg);
|
||||||
void SetTipLabel(wxString msg);
|
void SetTipLabel(wxString msg);
|
||||||
bool Show(bool show);
|
bool Show(bool show);
|
||||||
};
|
};
|
||||||
|
|
||||||
class PartSkipDialog : public DPIDialog
|
class PartSkipDialog : public DPIDialog
|
||||||
@@ -69,68 +69,69 @@ public:
|
|||||||
|
|
||||||
MachineObject *m_obj{nullptr};
|
MachineObject *m_obj{nullptr};
|
||||||
|
|
||||||
wxSimplebook* m_simplebook;
|
wxSimplebook *m_simplebook;
|
||||||
wxPanel* m_book_third_panel;
|
wxPanel *m_book_third_panel;
|
||||||
wxPanel* m_book_second_panel;
|
wxPanel *m_book_second_panel;
|
||||||
wxPanel* m_book_first_panel;
|
wxPanel *m_book_first_panel;
|
||||||
|
|
||||||
SkipPartCanvas* m_canvas;
|
SkipPartCanvas *m_canvas;
|
||||||
Button* m_zoom_in_btn;
|
Button *m_zoom_in_btn;
|
||||||
Button* m_zoom_out_btn;
|
Button *m_zoom_out_btn;
|
||||||
Button* m_switch_drag_btn;
|
Button *m_switch_drag_btn;
|
||||||
CheckBox* m_all_checkbox;
|
CheckBox *m_all_checkbox;
|
||||||
Button* m_percent_label;
|
Button *m_percent_label;
|
||||||
Label* m_all_label;
|
Label *m_all_label;
|
||||||
wxPanel* m_line;
|
wxPanel *m_line;
|
||||||
wxPanel* m_line_top;
|
wxPanel *m_line_top;
|
||||||
wxScrolledWindow* m_list_view;
|
wxScrolledWindow *m_list_view;
|
||||||
|
|
||||||
wxPanel* m_dlg_placeholder;
|
wxPanel *m_dlg_placeholder;
|
||||||
Label* m_cnt_label;
|
Label *m_cnt_label;
|
||||||
Label* m_tot_label;
|
Label *m_tot_label;
|
||||||
|
|
||||||
Button* m_apply_btn;
|
Button *m_apply_btn;
|
||||||
|
|
||||||
Label* m_loading_label;
|
Label *m_loading_label;
|
||||||
Label* m_retry_label;
|
Label *m_retry_label;
|
||||||
ScalableBitmap* m_retry_icon;
|
ScalableBitmap *m_retry_icon;
|
||||||
wxStaticBitmap* m_retry_bitmap;
|
wxStaticBitmap *m_retry_bitmap;
|
||||||
|
|
||||||
wxBoxSizer* m_sizer;
|
wxBoxSizer *m_sizer;
|
||||||
wxBoxSizer* m_dlg_sizer;
|
wxBoxSizer *m_dlg_sizer;
|
||||||
wxBoxSizer* m_dlg_content_sizer;
|
wxBoxSizer *m_dlg_content_sizer;
|
||||||
wxBoxSizer* m_dlg_btn_sizer;
|
wxBoxSizer *m_dlg_btn_sizer;
|
||||||
wxBoxSizer* m_canvas_sizer;
|
wxBoxSizer *m_canvas_sizer;
|
||||||
wxBoxSizer* m_canvas_btn_sizer;
|
wxBoxSizer *m_canvas_btn_sizer;
|
||||||
wxBoxSizer* m_list_sizer;
|
wxBoxSizer *m_list_sizer;
|
||||||
wxBoxSizer* m_scroll_sizer;
|
wxBoxSizer *m_scroll_sizer;
|
||||||
wxBoxSizer* m_book_first_sizer;
|
wxBoxSizer *m_book_first_sizer;
|
||||||
wxBoxSizer* m_book_second_sizer;
|
wxBoxSizer *m_book_second_sizer;
|
||||||
wxBoxSizer* m_book_second_btn_sizer;
|
wxBoxSizer *m_book_second_btn_sizer;
|
||||||
Button* m_second_retry_btn;
|
Button *m_second_retry_btn;
|
||||||
AnimaIcon* m_loading_icon;
|
AnimaIcon *m_loading_icon;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_zoom_percent{100};
|
int m_plate_idx{-1};
|
||||||
|
int m_zoom_percent{100};
|
||||||
bool m_is_drag{false};
|
bool m_is_drag{false};
|
||||||
bool m_print_lock{true};
|
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::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;
|
enum URL_STATE m_url_state = URL_STATE::URL_TCP;
|
||||||
|
|
||||||
PartsInfo GetPartsInfo();
|
PartsInfo GetPartsInfo();
|
||||||
bool is_drag_mode();
|
bool is_drag_mode();
|
||||||
|
|
||||||
boost::shared_ptr<PrinterFileSystem> m_file_sys;
|
boost::shared_ptr<PrinterFileSystem> m_file_sys;
|
||||||
bool m_file_sys_result{false};
|
bool m_file_sys_result{false};
|
||||||
std::string m_timestamp;
|
std::string m_timestamp;
|
||||||
std::string m_tmp_path;
|
std::string m_tmp_path;
|
||||||
std::vector<string> m_local_paths;
|
std::vector<string> m_local_paths;
|
||||||
std::vector<string> m_target_paths;
|
std::vector<string> m_target_paths;
|
||||||
std::string create_tmp_path();
|
std::string create_tmp_path();
|
||||||
|
|
||||||
bool is_local_file_existed(const std::vector<string> &local_paths);
|
bool is_local_file_existed(const std::vector<string> &local_paths);
|
||||||
|
|
||||||
@@ -139,7 +140,6 @@ private:
|
|||||||
void OnFileSystemResult(wxCommandEvent &event);
|
void OnFileSystemResult(wxCommandEvent &event);
|
||||||
void fetchUrl(boost::weak_ptr<PrinterFileSystem> wfs);
|
void fetchUrl(boost::weak_ptr<PrinterFileSystem> wfs);
|
||||||
|
|
||||||
|
|
||||||
void OnZoomIn(wxCommandEvent &event);
|
void OnZoomIn(wxCommandEvent &event);
|
||||||
void OnZoomOut(wxCommandEvent &event);
|
void OnZoomOut(wxCommandEvent &event);
|
||||||
void OnSwitchDrag(wxCommandEvent &event);
|
void OnSwitchDrag(wxCommandEvent &event);
|
||||||
@@ -156,4 +156,4 @@ private:
|
|||||||
void OnApplyDialog(wxCommandEvent &event);
|
void OnApplyDialog(wxCommandEvent &event);
|
||||||
};
|
};
|
||||||
|
|
||||||
}}
|
}} // namespace Slic3r::GUI
|
||||||
@@ -252,6 +252,7 @@ struct PrinterFileSystem::Download : Progress
|
|||||||
|
|
||||||
void PrinterFileSystem::GetPickImages(const std::vector<std::string> &local_paths, const std::vector<std::string> &targetpaths)
|
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(1, local_paths[0], targetpaths[0]);
|
||||||
GetPickImage(2, local_paths[1], targetpaths[1]);
|
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");
|
wxLogWarning("Download failed: result = 1");
|
||||||
return ERROR_JSON;
|
return ERROR_JSON;
|
||||||
}
|
}
|
||||||
|
if(mem_dl_json.contains("size") && mem_dl_json["size"] == 0 )
|
||||||
|
return FILE_SIZE_ERR;
|
||||||
|
|
||||||
return CONTINUE;
|
return CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,13 +359,27 @@ void PrinterFileSystem::DownloadRamFile(int index, const std::string &local_path
|
|||||||
if (result == CONTINUE) { return; }
|
if (result == CONTINUE) { return; }
|
||||||
std::string msg;
|
std::string msg;
|
||||||
if (result == SUCCESS) {
|
if (result == SUCCESS) {
|
||||||
wxLogMessage("DownloadImageFromRam finished: %s", download->local_path);
|
if (std::filesystem::exists(download->local_path)) {
|
||||||
msg = "SUCCESS";
|
m_download_states.emplace_back(true);
|
||||||
SendChangedEvent(EVT_RAMDOWNLOAD, result, result ? download->error : download->local_path);
|
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) {
|
} else if (result != CONTINUE) {
|
||||||
wxLogWarning("DownloadImageFromRam failed: %s", download->error);
|
m_download_states.emplace_back(false);
|
||||||
msg = "ERROR";
|
BOOST_LOG_TRIVIAL(warning) << "DownloadImageFromRam failed: " << download->error << "result = " << result;
|
||||||
SendChangedEvent(EVT_RAMDOWNLOAD, result, result ? download->error : download->local_path);
|
}
|
||||||
|
|
||||||
|
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);
|
},param);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -317,6 +317,8 @@ private:
|
|||||||
size_t m_lock_end = 0;
|
size_t m_lock_end = 0;
|
||||||
int m_task_flags = 0;
|
int m_task_flags = 0;
|
||||||
|
|
||||||
|
std::vector<bool> m_download_states;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Session
|
struct Session
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include <expat.h>
|
#include <expat.h>
|
||||||
#include <earcut/earcut.hpp>
|
#include <earcut/earcut.hpp>
|
||||||
#include <libslic3r/Color.hpp>
|
#include <libslic3r/Color.hpp>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
wxDEFINE_EVENT(EVT_ZOOM_PERCENT, wxCommandEvent);
|
wxDEFINE_EVENT(EVT_ZOOM_PERCENT, wxCommandEvent);
|
||||||
wxDEFINE_EVENT(EVT_CANVAS_PART, 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)
|
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 {
|
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);
|
cv::Mat mask = cv::Mat::zeros(image.size(), CV_8UC1);
|
||||||
|
|
||||||
@@ -249,8 +252,12 @@ void SkipPartCanvas::Render()
|
|||||||
|
|
||||||
int w, h;
|
int w, h;
|
||||||
GetClientSize(&w, &h);
|
GetClientSize(&w, &h);
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
double scale = GetDPIScaleFactor();
|
||||||
|
glViewport(0, 0, w * scale, h * scale);
|
||||||
|
#else
|
||||||
glViewport(0, 0, w, h);
|
glViewport(0, 0, w, h);
|
||||||
|
#endif
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
auto view_rect = ViewPtToImagePt(wxPoint(w, h));
|
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)
|
void ModelSettingHelper::DataHandler(const XML_Char *s, int len)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ public:
|
|||||||
ModelSettingHelper(const std::string &path);
|
ModelSettingHelper(const std::string &path);
|
||||||
|
|
||||||
bool Parse();
|
bool Parse();
|
||||||
std::vector<PlateInfo> GetPlates();
|
std::vector<ObjectInfo> GetPlateObjects(int plate_idx);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string path_;
|
std::string path_;
|
||||||
|
|||||||
@@ -9,12 +9,13 @@
|
|||||||
AnimaIcon::AnimaIcon(wxWindow *parent, wxWindowID id, std::vector<std::string> img_list, std::string img_enable, int ivt)
|
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)
|
: wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize), m_ivt(ivt)
|
||||||
{
|
{
|
||||||
|
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
SetBackgroundColour((wxColour(255, 255, 255)));
|
SetBackgroundColour((wxColour(255, 255, 255)));
|
||||||
m_size = 20;
|
m_size = 25;
|
||||||
|
|
||||||
//add ScalableBitmap
|
//add ScalableBitmap
|
||||||
for (const auto &filename : img_list) m_images.emplace_back(create_scaled_bitmap(filename, this, FromDIP(m_size)));
|
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, FromDIP(m_size-8));
|
m_image_enable = create_scaled_bitmap(img_enable, this, m_size-8);
|
||||||
|
|
||||||
// show first wxStaticBitmap
|
// 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)));
|
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));
|
SetCursor(wxCursor(wxCURSOR_ARROW));
|
||||||
e.Skip();
|
e.Skip();
|
||||||
});
|
});
|
||||||
|
sizer->Add(m_bitmap, 0, wxALIGN_CENTER, 0);
|
||||||
|
SetSizer(sizer);
|
||||||
SetSize(wxSize(FromDIP(m_size), FromDIP(m_size)));
|
SetSize(wxSize(FromDIP(m_size), FromDIP(m_size)));
|
||||||
SetMaxSize(wxSize(FromDIP(m_size), FromDIP(m_size)));
|
SetMaxSize(wxSize(FromDIP(m_size), FromDIP(m_size)));
|
||||||
SetMinSize(wxSize(FromDIP(m_size), FromDIP(m_size)));
|
SetMinSize(wxSize(FromDIP(m_size), FromDIP(m_size)));
|
||||||
Refresh();
|
Layout();
|
||||||
|
Fit();
|
||||||
Play();
|
Play();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user