FIX:fix crash for no valid filaments

jira: none
Change-Id: I9433da99d2ad355f088917e88350c5fd36bd1aea
This commit is contained in:
zhou.xu 2025-02-05 14:25:38 +08:00 committed by lane.wei
parent d7f969f0cf
commit 52442fa6d5
7 changed files with 44 additions and 12 deletions

View File

@ -106,6 +106,10 @@ BaseTransparentDPIFrame::BaseTransparentDPIFrame(
} }
}); });
Bind(wxEVT_LEAVE_WINDOW, [this](auto &e) { Bind(wxEVT_LEAVE_WINDOW, [this](auto &e) {
auto x = e.GetX();
auto y = e.GetY();
auto size = this->GetClientSize();
if (x >= 0 && y >= 0 && x <= size.x && y <= size.y) { return; }
if (m_enter_window_valid) { if (m_enter_window_valid) {
m_refresh_timer->Start(ANIMATION_REFRESH_INTERVAL); m_refresh_timer->Start(ANIMATION_REFRESH_INTERVAL);
} }

View File

@ -48,7 +48,7 @@ protected:
DisappearanceMode m_timed_disappearance_mode; DisappearanceMode m_timed_disappearance_mode;
float m_timer_count = 0; float m_timer_count = 0;
wxTimer * m_refresh_timer{nullptr}; wxTimer * m_refresh_timer{nullptr};
int m_disappearance_second = 1500; // unit ms: mean 5s int m_disappearance_second = 2500; //ANIMATION_REFRESH_INTERVAL 20 unit ms: m_disappearance_second * ANIMATION_REFRESH_INTERVAL
bool m_move_to_target_gradual_disappearance = false; bool m_move_to_target_gradual_disappearance = false;
wxPoint m_target_pos; wxPoint m_target_pos;

View File

@ -3232,7 +3232,8 @@ void GCodeViewer::load_shells(const Print& print, bool initialized, bool force_p
const Vec3d z_offset = slicing_parameters.object_print_z_min * Vec3d::UnitZ(); const Vec3d z_offset = slicing_parameters.object_print_z_min * Vec3d::UnitZ();
for (size_t i = current_volumes_count; i < m_shells.volumes.volumes.size(); ++i) { for (size_t i = current_volumes_count; i < m_shells.volumes.volumes.size(); ++i) {
GLVolume* v = m_shells.volumes.volumes[i]; GLVolume* v = m_shells.volumes.volumes[i];
v->set_volume_offset(v->get_volume_offset() + z_offset); auto offset = v->get_instance_transformation().get_matrix_no_offset().inverse() * z_offset;
v->set_volume_offset(v->get_volume_offset() + offset);
} }
} }
@ -4622,7 +4623,7 @@ void GCodeViewer::render_legend_color_arr_recommen(float window_padding)
ImGui::GetWindowDrawList()->AddLine(lineStart, lineEnd, HyperColor); ImGui::GetWindowDrawList()->AddLine(lineStart, lineEnd, HyperColor);
// click behavior // click behavior
if (ImGui::IsMouseHoveringRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax(), true)) { if (ImGui::IsMouseHoveringRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax(), true)) {
if (ImGui::IsMouseClicked(ImGuiMouseButton_Left)) { if (ImGui::IsMouseClicked(ImGuiMouseButton_Left)) {
Plater *plater = wxGetApp().plater(); Plater *plater = wxGetApp().plater();
wxCommandEvent evt(EVT_OPEN_FILAMENT_MAP_SETTINGS_DIALOG); wxCommandEvent evt(EVT_OPEN_FILAMENT_MAP_SETTINGS_DIALOG);
evt.SetEventObject(plater); evt.SetEventObject(plater);

View File

@ -2916,6 +2916,20 @@ void Sidebar::sync_ams_list(bool is_from_big_sync_btn)
p->plater->pop_warning_and_go_to_device_page(printer_name, Plater::PrinterWarningType::NOT_CONNECTED, _L("Sync printer information")); p->plater->pop_warning_and_go_to_device_page(printer_name, Plater::PrinterWarningType::NOT_CONNECTED, _L("Sync printer information"));
return; return;
} }
bool exist_at_list_one_filament =false;
for (auto &cur : list) {
auto temp_config = cur.second;
auto filament_type = temp_config.opt_string("filament_type", 0u);
auto filament_color = temp_config.opt_string("filament_colour", 0u);
if (!filament_type.empty() || temp_config.opt_bool("filament_exist", 0u)) {
exist_at_list_one_filament = true;
break;
}
}
if (!exist_at_list_one_filament) {
p->plater->pop_warning_and_go_to_device_page("", Plater::PrinterWarningType::EMPTY_FILAMENT, _L("Sync printer information"));
return;
}
if (!wxGetApp().plater()->is_same_printer_for_connected_and_selected()) { if (!wxGetApp().plater()->is_same_printer_for_connected_and_selected()) {
return; return;
} }
@ -10655,9 +10669,7 @@ int Plater::new_project(bool skip_confirm, bool silent, const wxString &project_
return wxID_YES; return wxID_YES;
} }
bool Plater::try_sync_preset_with_connected_printer(int& nozzle_diameter)
bool Plater::try_sync_preset_with_connected_printer()
{ {
DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager(); DeviceManager* dev = Slic3r::GUI::wxGetApp().getDeviceManager();
if (!dev) if (!dev)
@ -10687,7 +10699,8 @@ bool Plater::try_sync_preset_with_connected_printer()
std::string printer_model = machine_preset->config.option<ConfigOptionString>("printer_model")->value; std::string printer_model = machine_preset->config.option<ConfigOptionString>("printer_model")->value;
bool sync_printer_preset = false; bool sync_printer_preset = false;
bool is_multi_extruder = machine_preset->config.option<ConfigOptionFloatsNullable>("nozzle_diameter")->values.size() > 1; nozzle_diameter = machine_preset->config.option<ConfigOptionFloatsNullable>("nozzle_diameter")->values.size();
bool is_multi_extruder = nozzle_diameter > 1;
if (!wxGetApp().app_config->has("sync_after_load_file_show_flag")) { if (!wxGetApp().app_config->has("sync_after_load_file_show_flag")) {
if (printer_preset.get_current_printer_type(preset_bundle) != printer_type || !is_approx((float)(preset_nozzle_diameter), machine_nozzle_diameter)) { if (printer_preset.get_current_printer_type(preset_bundle) != printer_type || !is_approx((float)(preset_nozzle_diameter), machine_nozzle_diameter)) {
wxString tips; wxString tips;
@ -10851,8 +10864,9 @@ int Plater::load_project(wxString const &filename2,
// only pop up in 3mf // only pop up in 3mf
if (!this->m_exported_file && !this->m_only_gcode){ if (!this->m_exported_file && !this->m_only_gcode){
auto ok = try_sync_preset_with_connected_printer(); int nozzle_diameter = 1;
if (ok) { auto ok = try_sync_preset_with_connected_printer(nozzle_diameter);
if (ok && nozzle_diameter > 1) {
sidebar().pop_sync_nozzle_and_ams_ialog(); sidebar().pop_sync_nozzle_and_ams_ialog();
} }
} }
@ -15366,6 +15380,10 @@ void Plater::pop_warning_and_go_to_device_page(wxString printer_name, PrinterWar
} else if (type == PrinterWarningType::INCONSISTENT) { } else if (type == PrinterWarningType::INCONSISTENT) {
content = wxString::Format(_L("The currently connected printer on the device page is not an %s. Please switch to an %s before syncing."), printer_name, printer_name); content = wxString::Format(_L("The currently connected printer on the device page is not an %s. Please switch to an %s before syncing."), printer_name, printer_name);
} else if (type == PrinterWarningType::UNINSTALL_FILAMENT) {
content = _L("There are no filaments on the printer. Please load the filaments on the printer first.");
} else if (type == PrinterWarningType::EMPTY_FILAMENT) {
content = _L("The filaments on the printer are all unknown types. Please go to the printer screen or software device page to set the filament type.");
} }
MessageDialog dlg(this, content, title, wxOK | wxFORWARD | wxICON_WARNING, _L("Device Page")); MessageDialog dlg(this, content, title, wxOK | wxFORWARD | wxICON_WARNING, _L("Device Page"));
auto result = dlg.ShowModal(); auto result = dlg.ShowModal();

View File

@ -263,7 +263,7 @@ public:
void render_project_state_debug_window() const; void render_project_state_debug_window() const;
#endif // ENABLE_PROJECT_DIRTY_STATE_DEBUG_WINDOW #endif // ENABLE_PROJECT_DIRTY_STATE_DEBUG_WINDOW
bool try_sync_preset_with_connected_printer(); bool try_sync_preset_with_connected_printer(int &nozzle_diameter);
Sidebar& sidebar(); Sidebar& sidebar();
const Model& model() const; const Model& model() const;
@ -499,6 +499,8 @@ public:
enum class PrinterWarningType { enum class PrinterWarningType {
NOT_CONNECTED, NOT_CONNECTED,
INCONSISTENT, INCONSISTENT,
UNINSTALL_FILAMENT,
EMPTY_FILAMENT
}; };
void pop_warning_and_go_to_device_page(wxString printer_name, PrinterWarningType type, const wxString &title); void pop_warning_and_go_to_device_page(wxString printer_name, PrinterWarningType type, const wxString &title);
bool check_printer_initialized(MachineObject *obj, bool only_warning = false); bool check_printer_initialized(MachineObject *obj, bool only_warning = false);

View File

@ -4070,6 +4070,8 @@ void SelectMachineDialog::unify_deal_thumbnail_data(ThumbnailData &input_data, T
change_default_normal(-1, wxColour()); change_default_normal(-1, wxColour());
final_deal_edge_pixels_data(m_preview_thumbnail_data); final_deal_edge_pixels_data(m_preview_thumbnail_data);
set_default_normal(m_preview_thumbnail_data); set_default_normal(m_preview_thumbnail_data);
} else {
set_default_normal(input_data);
} }
} }

View File

@ -403,8 +403,10 @@ void SyncAmsInfoDialog::update_map_when_change_map_mode()
m_cur_colors_in_thumbnail[i] = result; m_cur_colors_in_thumbnail[i] = result;
} }
else { else {
//todo:give warning if (!m_cur_colors_in_thumbnail.empty()) {
m_cur_colors_in_thumbnail[i] = m_cur_colors_in_thumbnail[0]; // todo:give warning
m_cur_colors_in_thumbnail[i] = m_cur_colors_in_thumbnail[0];
}
} }
} }
} }
@ -4300,6 +4302,9 @@ void SyncAmsInfoDialog::unify_deal_thumbnail_data(ThumbnailData &input_data, Thu
final_deal_edge_pixels_data(m_preview_thumbnail_data); final_deal_edge_pixels_data(m_preview_thumbnail_data);
set_default_normal(m_preview_thumbnail_data); set_default_normal(m_preview_thumbnail_data);
} }
else {
set_default_normal(input_data);
}
} }
void SyncAmsInfoDialog::change_default_normal(int old_filament_id, wxColour temp_ams_color) void SyncAmsInfoDialog::change_default_normal(int old_filament_id, wxColour temp_ams_color)