Brim ear updates model object in real-time (#9625)

* ENH:Brim ear updates model object in real-time

jira: studio-8687 8683
Change-Id: Ic730957bf8c1e96c0464791cce60cb097d1a4dc9
(cherry picked from commit af174cb8b64e870929f926d3957d3471d0b09e29)
(cherry picked from commit a1037509aef57b2276bba3ddcab33a6bfeebf87a)

* Fix build error

---------

Co-authored-by: Mack <yongfang.bian@bambulab.com>
This commit is contained in:
Noisyfox 2025-05-16 23:52:48 +08:00 committed by GitHub
parent 294d07a2a0
commit a91fa2a40c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 6 deletions

View file

@ -541,6 +541,7 @@ void GLGizmoBrimEars::delete_selected_points()
select_point(NoPoints);
find_single();
update_model_object();
}
void GLGizmoBrimEars::on_dragging(const UpdateData& data)
@ -596,6 +597,7 @@ void GLGizmoBrimEars::update_cache_radius()
if (cache_entry.selected) {
cache_entry.brim_point.head_front_radius = m_new_point_head_diameter / 2.f;
find_single();
update_model_object();
}
m_parent.set_as_dirty();
}
@ -744,7 +746,7 @@ void GLGizmoBrimEars::on_render_input_window(float x, float y, float bottom_limi
ImGui::PushStyleColor(ImGuiCol_Text, HyperColor.Value);
ImGui::Dummy(ImVec2(font_size * 1.8, font_size * 1.3));
ImGui::SameLine();
m_imgui->bold_text(_u8L("Set the brim type to \"painted\""));
m_imgui->bold_text(_u8L("Set the brim type of this object to \"painted\""));
ImGui::PopStyleColor();
// underline
ImVec2 lineEnd = ImGui::GetItemRectMax();
@ -844,7 +846,7 @@ CommonGizmosDataID GLGizmoBrimEars::on_get_requirements() const
int(CommonGizmosDataID::ObjectClipper));
}
void GLGizmoBrimEars::save_model()
void GLGizmoBrimEars::update_model_object()
{
ModelObject* mo = m_c->selection_info()->model_object();
if (mo) {
@ -852,6 +854,7 @@ void GLGizmoBrimEars::save_model()
for (const CacheEntry& ce : m_editing_cache) mo->brim_points.emplace_back(ce.brim_point);
wxGetApp().plater()->set_plater_dirty(true);
}
m_parent.post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS));
}
// switch gizmos
@ -867,8 +870,7 @@ void GLGizmoBrimEars::on_set_state()
if (m_state == Off && m_old_state != Off) {
// the gizmo was just turned Off
Plater::TakeSnapshot snapshot(wxGetApp().plater(), "Brim ears edit");
save_model();
m_parent.post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS));
update_model_object();
wxGetApp().plater()->leave_gizmos_stack();
// wxGetApp().mainframe->update_slice_print_status(MainFrame::SlicePrintEventType::eEventSliceUpdate, true, true);
}
@ -1077,6 +1079,7 @@ bool GLGizmoBrimEars::add_point_to_cache(Vec3f pos, float head_radius, bool sele
if (m_editing_cache[i].brim_point == point) { return false; }
}
m_editing_cache.emplace_back(point, selected, normal);
update_model_object();
return true;
}

View file

@ -80,7 +80,7 @@ public:
bool on_mouse(const wxMouseEvent& mouse_event) override;
bool gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down, bool alt_down, bool control_down);
void delete_selected_points();
void save_model();
void update_model_object();
//ClippingPlane get_sla_clipping_plane() const;
bool is_selection_rectangle_dragging() const { return m_selection_rectangle.is_dragging(); }

View file

@ -1375,7 +1375,7 @@ bool GLGizmosManager::is_in_editing_mode(bool error_notification) const
/*if (m_current == SlaSupports && dynamic_cast<GLGizmoSlaSupports*>(get_current())->is_in_editing_mode()) {
return true;
} else*/ if (m_current == BrimEars) {
dynamic_cast<GLGizmoBrimEars*>(get_current())->save_model();
dynamic_cast<GLGizmoBrimEars *>(get_current())->update_model_object();
return false;
} else {
return false;