FIX:fix crash for no valid filaments

jira: none
Change-Id: I9433da99d2ad355f088917e88350c5fd36bd1aea
(cherry picked from commit 52442fa6d58d4d9204c386ec1a2ccfedf7115151)
This commit is contained in:
zhou.xu 2025-02-05 14:25:38 +08:00 committed by Noisyfox
parent 552c674483
commit 7d3acd75ae
7 changed files with 37 additions and 5 deletions

View file

@ -106,6 +106,10 @@ BaseTransparentDPIFrame::BaseTransparentDPIFrame(
}
});
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) {
m_refresh_timer->Start(ANIMATION_REFRESH_INTERVAL);
}

View file

@ -48,7 +48,7 @@ protected:
DisappearanceMode m_timed_disappearance_mode;
float m_timer_count = 0;
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;
wxPoint m_target_pos;

View file

@ -3161,7 +3161,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();
for (size_t i = current_volumes_count; i < m_shells.volumes.volumes.size(); ++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);
}
}
@ -4406,7 +4407,7 @@ void GCodeViewer::render_legend_color_arr_recommen(float window_padding)
ImGui::GetWindowDrawList()->AddLine(lineStart, lineEnd, HyperColor);
// click behavior
if (ImGui::IsMouseHoveringRect(ImGui::GetItemRectMin(), ImGui::GetItemRectMax(), true)) {
if (ImGui::IsMouseClicked(ImGuiMouseButton_Left)) {
if (ImGui::IsMouseClicked(ImGuiMouseButton_Left)) {
Plater *plater = wxGetApp().plater();
wxCommandEvent evt(EVT_OPEN_FILAMENT_MAP_SETTINGS_DIALOG);
evt.SetEventObject(plater);

View file

@ -2791,6 +2791,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"));
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()) {
return;
}
@ -15325,6 +15339,10 @@ void Plater::pop_warning_and_go_to_device_page(wxString printer_name, PrinterWar
} 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);
} 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"));
auto result = dlg.ShowModal();

View file

@ -542,6 +542,8 @@ public:
enum class PrinterWarningType {
NOT_CONNECTED,
INCONSISTENT,
UNINSTALL_FILAMENT,
EMPTY_FILAMENT
};
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);

View file

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

View file

@ -405,8 +405,10 @@ void SyncAmsInfoDialog::update_map_when_change_map_mode()
m_cur_colors_in_thumbnail[i] = result;
}
else {
//todo:give warning
m_cur_colors_in_thumbnail[i] = m_cur_colors_in_thumbnail[0];
if (!m_cur_colors_in_thumbnail.empty()) {
// todo:give warning
m_cur_colors_in_thumbnail[i] = m_cur_colors_in_thumbnail[0];
}
}
}
}
@ -4293,6 +4295,9 @@ void SyncAmsInfoDialog::unify_deal_thumbnail_data(ThumbnailData &input_data, Thu
final_deal_edge_pixels_data(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)