mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-20 11:53:48 +00:00
ENH: disable skip when objects number>64 or model is not support
Jira: [TUDIO-13411] Change-Id: I93617965e69ba72a1cc34dd0981b8fd92eb58d3a (cherry picked from commit 417109e5f02613bd18eae125705effa7ae61cfda)
This commit is contained in:
@@ -191,7 +191,7 @@ PartSkipDialog::PartSkipDialog(wxWindow *parent) : DPIDialog(parent, wxID_ANY, _
|
|||||||
m_apply_btn->SetSize(wxSize(FromDIP(80), FromDIP(32)));
|
m_apply_btn->SetSize(wxSize(FromDIP(80), FromDIP(32)));
|
||||||
m_apply_btn->SetMinSize(wxSize(FromDIP(80), FromDIP(32)));
|
m_apply_btn->SetMinSize(wxSize(FromDIP(80), FromDIP(32)));
|
||||||
m_apply_btn->SetCornerRadius(FromDIP(16));
|
m_apply_btn->SetCornerRadius(FromDIP(16));
|
||||||
m_apply_btn->Enable(false);
|
m_apply_btn->SetToolTip(wxEmptyString);
|
||||||
|
|
||||||
m_canvas_sizer->Add(m_canvas, 0, wxLEFT | wxTOP | wxEXPAND, FromDIP(17));
|
m_canvas_sizer->Add(m_canvas, 0, wxLEFT | wxTOP | wxEXPAND, FromDIP(17));
|
||||||
m_canvas_sizer->Add(m_canvas_btn_sizer, 0, wxTOP, FromDIP(8));
|
m_canvas_sizer->Add(m_canvas_btn_sizer, 0, wxTOP, FromDIP(8));
|
||||||
@@ -407,7 +407,9 @@ bool PartSkipDialog::is_local_file_existed(const std::vector<string> &local_path
|
|||||||
|
|
||||||
void PartSkipDialog::DownloadPartsFile()
|
void PartSkipDialog::DownloadPartsFile()
|
||||||
{
|
{
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "part skip: create temp path begin.";
|
||||||
m_tmp_path = create_tmp_path(); // wxGetApp().app_config->get("download_path");
|
m_tmp_path = create_tmp_path(); // wxGetApp().app_config->get("download_path");
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "part skip: create temp path end.";
|
||||||
|
|
||||||
m_local_paths.clear();
|
m_local_paths.clear();
|
||||||
m_target_paths.clear();
|
m_target_paths.clear();
|
||||||
@@ -440,6 +442,7 @@ void PartSkipDialog::DownloadPartsFile()
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m_file_sys->SendExistedFile();
|
m_file_sys->SendExistedFile();
|
||||||
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "part skip: local parts info file is existed.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// actor
|
// actor
|
||||||
@@ -686,7 +689,8 @@ bool PartSkipDialog::Show(bool show)
|
|||||||
|
|
||||||
void PartSkipDialog::InitDialogUI()
|
void PartSkipDialog::InitDialogUI()
|
||||||
{
|
{
|
||||||
m_print_lock = true;
|
m_print_lock = true;
|
||||||
|
is_model_support_partskip = false;
|
||||||
BOOST_LOG_TRIVIAL(info) << "part skip: lock parts info from printer.";
|
BOOST_LOG_TRIVIAL(info) << "part skip: lock parts info from printer.";
|
||||||
m_scroll_sizer->Clear(true);
|
m_scroll_sizer->Clear(true);
|
||||||
m_all_checkbox->SetValue(false);
|
m_all_checkbox->SetValue(false);
|
||||||
@@ -709,7 +713,8 @@ void PartSkipDialog::InitDialogUI()
|
|||||||
ModelSettingHelper helper(slice_info);
|
ModelSettingHelper helper(slice_info);
|
||||||
|
|
||||||
if (helper.Parse()) {
|
if (helper.Parse()) {
|
||||||
auto parse_result = helper.GetPlateObjects(m_plate_idx);
|
is_model_support_partskip = helper.GetLabelObjectEnabled(m_plate_idx);
|
||||||
|
auto parse_result = helper.GetPlateObjects(m_plate_idx);
|
||||||
for (const auto &part : parse_result) {
|
for (const auto &part : parse_result) {
|
||||||
m_parts_state[part.identify_id] = part.state;
|
m_parts_state[part.identify_id] = part.state;
|
||||||
m_parts_name[part.identify_id] = part.name;
|
m_parts_name[part.identify_id] = part.name;
|
||||||
@@ -769,6 +774,7 @@ void PartSkipDialog::InitDialogUI()
|
|||||||
|
|
||||||
m_scroll_sizer->Layout();
|
m_scroll_sizer->Layout();
|
||||||
m_list_view->FitInside();
|
m_list_view->FitInside();
|
||||||
|
UpdateApplyButtonStatus();
|
||||||
UpdateCountLabel();
|
UpdateCountLabel();
|
||||||
Refresh();
|
Refresh();
|
||||||
m_print_lock = false;
|
m_print_lock = false;
|
||||||
@@ -872,16 +878,29 @@ void PartSkipDialog::UpdateApplyButtonStatus()
|
|||||||
{
|
{
|
||||||
if (IsAllCancled()) {
|
if (IsAllCancled()) {
|
||||||
m_apply_btn->SetBackgroundColor(btn_bg_gray);
|
m_apply_btn->SetBackgroundColor(btn_bg_gray);
|
||||||
m_apply_btn->Enable(false);
|
m_apply_btn->SetToolTip(_L("Nothing selected"));
|
||||||
|
m_enable_apply_btn = false;
|
||||||
|
} else if (m_parts_state.size() > 64) {
|
||||||
|
m_apply_btn->SetBackgroundColor(btn_bg_gray);
|
||||||
|
m_apply_btn->SetToolTip(_L("Over 64 objects in single plate"));
|
||||||
|
m_enable_apply_btn = false;
|
||||||
|
} else if (!is_model_support_partskip) {
|
||||||
|
m_apply_btn->SetBackgroundColor(btn_bg_gray);
|
||||||
|
m_apply_btn->SetToolTip(_L("The current print job cannot be skipped"));
|
||||||
|
m_enable_apply_btn = false;
|
||||||
} else {
|
} else {
|
||||||
m_apply_btn->SetBackgroundColor(btn_bg_green);
|
m_apply_btn->SetBackgroundColor(btn_bg_green);
|
||||||
m_apply_btn->Enable(true);
|
m_apply_btn->SetToolTip(wxEmptyString);
|
||||||
|
m_enable_apply_btn = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartSkipDialog::OnApplyDialog(wxCommandEvent &event)
|
void PartSkipDialog::OnApplyDialog(wxCommandEvent &event)
|
||||||
{
|
{
|
||||||
event.Skip();
|
event.Skip();
|
||||||
|
|
||||||
|
if (!m_enable_apply_btn) return;
|
||||||
|
|
||||||
m_partskip_ids.clear();
|
m_partskip_ids.clear();
|
||||||
for (const auto &[part_id, part_state] : m_parts_state) {
|
for (const auto &[part_id, part_state] : m_parts_state) {
|
||||||
if (part_state == PartState::psChecked) { m_partskip_ids.push_back(part_id); }
|
if (part_state == PartState::psChecked) { m_partskip_ids.push_back(part_id); }
|
||||||
|
|||||||
@@ -115,6 +115,8 @@ private:
|
|||||||
int m_zoom_percent{100};
|
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};
|
||||||
|
bool m_enable_apply_btn{false};
|
||||||
|
bool is_model_support_partskip{false};
|
||||||
|
|
||||||
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;
|
||||||
|
|||||||
@@ -649,6 +649,7 @@ void XMLCALL ModelSettingHelper::StartElementHandler(void *userData, const XML_C
|
|||||||
if (strcmp(atts[i], "value") == 0) value = atts[i + 1];
|
if (strcmp(atts[i], "value") == 0) value = atts[i + 1];
|
||||||
}
|
}
|
||||||
if (key == "index") { self->context_.current_plate.index = std::stoi(value); }
|
if (key == "index") { self->context_.current_plate.index = std::stoi(value); }
|
||||||
|
if (key == "label_object_enabled") { self->context_.current_plate.label_object_enabled = value == "true"; }
|
||||||
} else if (strcmp(name, "object") == 0 && self->context_.in_plate) {
|
} else if (strcmp(name, "object") == 0 && self->context_.in_plate) {
|
||||||
ObjectInfo obj;
|
ObjectInfo obj;
|
||||||
for (int i = 0; atts[i]; i += 2) {
|
for (int i = 0; atts[i]; i += 2) {
|
||||||
@@ -678,6 +679,14 @@ std::vector<ObjectInfo> ModelSettingHelper::GetPlateObjects(int plate_idx) {
|
|||||||
return std::vector<ObjectInfo>();
|
return std::vector<ObjectInfo>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ModelSettingHelper::GetLabelObjectEnabled(int plate_idx)
|
||||||
|
{
|
||||||
|
for (const auto &plate : context_.plates) {
|
||||||
|
if (plate.index == plate_idx) { return plate.label_object_enabled; }
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void ModelSettingHelper::DataHandler(const XML_Char *s, int len)
|
void ModelSettingHelper::DataHandler(const XML_Char *s, int len)
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
|
|||||||
@@ -135,6 +135,7 @@ struct PlateInfo
|
|||||||
{
|
{
|
||||||
int index{-1};
|
int index{-1};
|
||||||
std::vector<ObjectInfo> objects;
|
std::vector<ObjectInfo> objects;
|
||||||
|
bool label_object_enabled = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ModelSettingHelper : public _BBS_3MF_Base
|
class ModelSettingHelper : public _BBS_3MF_Base
|
||||||
@@ -152,6 +153,7 @@ public:
|
|||||||
|
|
||||||
bool Parse();
|
bool Parse();
|
||||||
std::vector<ObjectInfo> GetPlateObjects(int plate_idx);
|
std::vector<ObjectInfo> GetPlateObjects(int plate_idx);
|
||||||
|
bool GetLabelObjectEnabled(int plate_idx);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string path_;
|
std::string path_;
|
||||||
|
|||||||
Reference in New Issue
Block a user