ENH:Brim ear updates model object in real-time

jira: studio-8687 8683
Change-Id: Ic730957bf8c1e96c0464791cce60cb097d1a4dc9
(cherry picked from commit af174cb8b64e870929f926d3957d3471d0b09e29)
This commit is contained in:
Mack 2024-11-26 10:38:02 +08:00 committed by lane.wei
parent 6a12df8afa
commit a1037509ae
3 changed files with 10 additions and 6 deletions

View File

@ -140,6 +140,7 @@ void GLGizmoBrimEars::render_points(const Selection &selection, bool picking) co
const bool &point_selected = editing_cache[i].selected;
const bool &hover = editing_cache[i].is_hover;
const bool &error = editing_cache[i].is_error;
if (!is_use_point(brim_point) && !hover) continue;
// keep show brim ear
// if (is_mesh_point_clipped(brim_point.pos.cast<double>()))
// continue;
@ -464,6 +465,7 @@ void GLGizmoBrimEars::delete_selected_points()
select_point(NoPoints);
find_single();
update_model_object();
}
void GLGizmoBrimEars::on_update(const UpdateData &data)
@ -563,6 +565,7 @@ void GLGizmoBrimEars::on_render_input_window(float x, float y, float bottom_limi
if (cache_entry.selected) {
cache_entry.brim_point.head_front_radius = m_new_point_head_diameter / 2.f;
find_single();
update_model_object();
}
};
m_imgui->bbl_slider_float_style("##head_diameter", &m_new_point_head_diameter, 5, 20, "%.1f", 1.0f, true);
@ -648,7 +651,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();
@ -748,7 +751,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) {
@ -756,6 +759,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
@ -771,8 +775,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);
}
@ -980,6 +983,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

@ -78,7 +78,7 @@ public:
void set_brim_data(ModelObject* model_object, const Selection& selection);
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

@ -1951,7 +1951,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;