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:
hemai
2025-07-15 21:55:18 +08:00
committed by Noisyfox
parent 6148c73ffc
commit b4c08f9bdf
4 changed files with 37 additions and 5 deletions

View File

@@ -191,7 +191,7 @@ PartSkipDialog::PartSkipDialog(wxWindow *parent) : DPIDialog(parent, wxID_ANY, _
m_apply_btn->SetSize(wxSize(FromDIP(80), FromDIP(32)));
m_apply_btn->SetMinSize(wxSize(FromDIP(80), FromDIP(32)));
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_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()
{
BOOST_LOG_TRIVIAL(info) << "part skip: create temp path begin.";
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_target_paths.clear();
@@ -440,6 +442,7 @@ void PartSkipDialog::DownloadPartsFile()
}
} else {
m_file_sys->SendExistedFile();
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << "part skip: local parts info file is existed.";
}
}
// actor
@@ -686,7 +689,8 @@ bool PartSkipDialog::Show(bool show)
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.";
m_scroll_sizer->Clear(true);
m_all_checkbox->SetValue(false);
@@ -709,7 +713,8 @@ void PartSkipDialog::InitDialogUI()
ModelSettingHelper helper(slice_info);
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) {
m_parts_state[part.identify_id] = part.state;
m_parts_name[part.identify_id] = part.name;
@@ -769,6 +774,7 @@ void PartSkipDialog::InitDialogUI()
m_scroll_sizer->Layout();
m_list_view->FitInside();
UpdateApplyButtonStatus();
UpdateCountLabel();
Refresh();
m_print_lock = false;
@@ -872,16 +878,29 @@ void PartSkipDialog::UpdateApplyButtonStatus()
{
if (IsAllCancled()) {
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 {
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)
{
event.Skip();
if (!m_enable_apply_btn) return;
m_partskip_ids.clear();
for (const auto &[part_id, part_state] : m_parts_state) {
if (part_state == PartState::psChecked) { m_partskip_ids.push_back(part_id); }

View File

@@ -115,6 +115,8 @@ private:
int m_zoom_percent{100};
bool m_is_drag{false};
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, std::string> m_parts_name;

View File

@@ -649,6 +649,7 @@ void XMLCALL ModelSettingHelper::StartElementHandler(void *userData, const XML_C
if (strcmp(atts[i], "value") == 0) value = atts[i + 1];
}
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) {
ObjectInfo obj;
for (int i = 0; atts[i]; i += 2) {
@@ -678,6 +679,14 @@ std::vector<ObjectInfo> ModelSettingHelper::GetPlateObjects(int plate_idx) {
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)
{
// do nothing

View File

@@ -135,6 +135,7 @@ struct PlateInfo
{
int index{-1};
std::vector<ObjectInfo> objects;
bool label_object_enabled = false;
};
class ModelSettingHelper : public _BBS_3MF_Base
@@ -152,6 +153,7 @@ public:
bool Parse();
std::vector<ObjectInfo> GetPlateObjects(int plate_idx);
bool GetLabelObjectEnabled(int plate_idx);
private:
std::string path_;