FIX:add "is_new_project_in_gcode3mf" api in .gcode.3mf

jira: STUDIO-9437
Change-Id: I5deb03cb535d3099ecadb1ce626fc632f65cd814
This commit is contained in:
zhou.xu 2025-01-01 17:32:12 +08:00 committed by lane.wei
parent 9b5bbebf31
commit 60fde9ca01
3 changed files with 26 additions and 0 deletions

View File

@ -2521,6 +2521,7 @@ void Sidebar::add_filament() {
} }
void Sidebar::delete_filament(size_t filament_id, int replace_filament_id) { void Sidebar::delete_filament(size_t filament_id, int replace_filament_id) {
if (is_new_project_in_gcode3mf()) { return; }
if (p->combos_filament.size() <= 1) return; if (p->combos_filament.size() <= 1) return;
wxBusyCursor busy; wxBusyCursor busy;
size_t filament_count = p->combos_filament.size() - 1; size_t filament_count = p->combos_filament.size() - 1;
@ -2563,6 +2564,7 @@ void Sidebar::edit_filament()
} }
void Sidebar::add_custom_filament(wxColour new_col) { void Sidebar::add_custom_filament(wxColour new_col) {
if (is_new_project_in_gcode3mf()) { return; }
if (p->combos_filament.size() >= size_t(EnforcerBlockerType::ExtruderMax)) return; if (p->combos_filament.size() >= size_t(EnforcerBlockerType::ExtruderMax)) return;
int filament_count = p->combos_filament.size() + 1; int filament_count = p->combos_filament.size() + 1;
@ -2575,6 +2577,27 @@ void Sidebar::add_custom_filament(wxColour new_col) {
auto_calc_flushing_volumes(filament_count - 1); auto_calc_flushing_volumes(filament_count - 1);
} }
bool Sidebar::is_new_project_in_gcode3mf()
{
if (p->plater->using_exported_file()) {
ConfirmBeforeSendDialog confirm_dlg(this, wxID_ANY, _L("Warning"));
bool is_cancle = true;
confirm_dlg.Bind(EVT_SECONDARY_CHECK_CONFIRM, [this, &is_cancle](wxCommandEvent &e) {
is_cancle = false;
});
confirm_dlg.update_btn_label(_L("Yes"), _L("No"));
auto filename = p->plater->get_preview_only_filename();
confirm_dlg.update_text(filename + " " + _L("will be closed before modify filament. Do you want to continue?"));
confirm_dlg.on_show();
if (!is_cancle) {
p->plater->new_project();
}
return is_cancle;
}
return false;
}
void Sidebar::on_bed_type_change(BedType bed_type) void Sidebar::on_bed_type_change(BedType bed_type)
{ {
// btDefault option is not included in global bed type setting // btDefault option is not included in global bed type setting
@ -7540,6 +7563,7 @@ void Plater::priv::on_combobox_select(wxCommandEvent &evt)
if (combo && combo->is_drop_down()) { if (combo && combo->is_drop_down()) {
sidebar->update_soft_first_start_state(); sidebar->update_soft_first_start_state();
} }
if (q->sidebar().is_new_project_in_gcode3mf()) { return; }
PlaterPresetComboBox* preset_combo_box = dynamic_cast<PlaterPresetComboBox*>(evt.GetEventObject()); PlaterPresetComboBox* preset_combo_box = dynamic_cast<PlaterPresetComboBox*>(evt.GetEventObject());
if (preset_combo_box) { if (preset_combo_box) {
this->on_select_preset(evt); this->on_select_preset(evt);

View File

@ -149,6 +149,7 @@ public:
void change_filament(size_t from_id, size_t to_id); // 0 base void change_filament(size_t from_id, size_t to_id); // 0 base
void edit_filament(); void edit_filament();
void add_custom_filament(wxColour new_col); void add_custom_filament(wxColour new_col);
bool is_new_project_in_gcode3mf();
// BBS // BBS
void on_bed_type_change(BedType bed_type); void on_bed_type_change(BedType bed_type);
void load_ams_list(std::string const & device, MachineObject* obj); void load_ams_list(std::string const & device, MachineObject* obj);

View File

@ -1354,6 +1354,7 @@ void ConfirmBeforeSendDialog::on_show()
m_button_ok->GetEventHandler()->ProcessEvent(evt_ok); m_button_ok->GetEventHandler()->ProcessEvent(evt_ok);
wxMouseEvent evt_cancel(wxEVT_LEFT_UP); wxMouseEvent evt_cancel(wxEVT_LEFT_UP);
m_button_cancel->GetEventHandler()->ProcessEvent(evt_cancel); m_button_cancel->GetEventHandler()->ProcessEvent(evt_cancel);
CenterOnScreen();
this->ShowModal(); this->ShowModal();
} }