FIX:array bound in m_font_names array

and confirm selected model_object at corresponding plate
Jira: STUDIO-6548
Change-Id: I3c2927305fc9007918deb83e5a38734427eaf30f
This commit is contained in:
zhou.xu 2024-03-18 18:19:50 +08:00 committed by Lane.Wei
parent 5aae2f9252
commit 26b72e36c3
4 changed files with 53 additions and 9 deletions

View File

@ -1911,7 +1911,11 @@ void GLCanvas3D::render(bool only_init)
GLGizmosManager::EType gizmo_type = m_gizmos.get_current_type();
if (!m_main_toolbar.is_enabled() || m_gizmos.is_show_only_active_plate()) {
//only_body = true;
only_current = true;
if (m_gizmos.get_object_located_outside_plate()) {
no_partplate = true;
} else {
only_current = true;
}
}
else if ((gizmo_type == GLGizmosManager::FdmSupports) || (gizmo_type == GLGizmosManager::Seam) || (gizmo_type == GLGizmosManager::MmuSegmentation))
no_partplate = true;
@ -7003,12 +7007,6 @@ void GLCanvas3D::_render_objects(GLVolumeCollection::ERenderType type, bool with
return !volume.is_modifier && !volume.is_wipe_tower;
}
else {
if (m_gizmos.is_show_only_active_plate()) {
auto plate_box = wxGetApp().plater()->get_partplate_list().get_curr_plate()->get_plate_box();
if (!plate_box.contains(volume.transformed_bounding_box())) {
return false;
}
}
return (m_render_sla_auxiliaries || volume.composite_id.volume_id >= 0);
}
}, with_outline);

View File

@ -1559,7 +1559,13 @@ void GLGizmoText::load_from_text_info(const TextInfo &text_info)
{
m_font_name = text_info.m_font_name;
m_font_size = text_info.m_font_size;
m_curr_font_idx = text_info.m_curr_font_idx;
// from other user's computer may exist case:font library size is different
if (text_info.m_curr_font_idx < m_font_names.size()) {
m_curr_font_idx = text_info.m_curr_font_idx;
}
else {
m_curr_font_idx = 0;
}
m_bold = text_info.m_bold;
m_italic = text_info.m_italic;
m_thickness = text_info.m_thickness;

View File

@ -675,6 +675,38 @@ bool GLGizmosManager::is_show_only_active_plate()
return false;
}
void GLGizmosManager::check_object_located_outside_plate() {
PartPlateList &plate_list = wxGetApp().plater()->get_partplate_list();
auto curr_plate_index = plate_list.get_curr_plate_index();
Selection & selection = m_parent.get_selection();
auto idxs = selection.get_volume_idxs();
m_object_located_outside_plate = false;
if (idxs.size() > 0) {
const GLVolume *v = selection.get_volume(*idxs.begin());
int object_idx = v->object_idx();
const Model * m_model = m_parent.get_model();
if (0 <= object_idx && object_idx < (int) m_model->objects.size()) {
bool find_object = false;
ModelObject *model_object = m_model->objects[object_idx];
for (size_t i = 0; i < plate_list.get_plate_count(); i++) {
auto plate = plate_list.get_plate(i);
ModelObjectPtrs objects = plate->get_objects_on_this_plate();
for (auto object : objects) {
if (model_object == object) {
if (curr_plate_index != i) { // confirm selected model_object at corresponding plate
wxGetApp().plater()->get_partplate_list().select_plate(i);
}
find_object = true;
}
}
}
if (!find_object) {
m_object_located_outside_plate = true;
}
}
}
}
// Returns true if the gizmo used the event to do something, false otherwise.
bool GLGizmosManager::gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down, bool alt_down, bool control_down)
{
@ -1738,6 +1770,9 @@ bool GLGizmosManager::activate_gizmo(EType type)
// wxGetApp().imgui()->load_fonts_texture();
//}
new_gizmo->set_state(GLGizmoBase::On);
if (is_show_only_active_plate()) {
check_object_located_outside_plate();
}
}
return true;
}

View File

@ -284,6 +284,8 @@ public:
bool is_gizmo_activable_when_single_full_instance();
bool is_gizmo_click_empty_not_exit();
bool is_show_only_active_plate();
void check_object_located_outside_plate();
bool get_object_located_outside_plate() { return m_object_located_outside_plate; }
bool gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position = Vec2d::Zero(), bool shift_down = false, bool alt_down = false, bool control_down = false);
ClippingPlane get_clipping_plane() const;
ClippingPlane get_assemble_view_clipping_plane() const;
@ -334,6 +336,9 @@ private:
void update_on_off_state(const Vec2d& mouse_pos);
std::string update_hover_state(const Vec2d& mouse_pos);
bool grabber_contains_mouse() const;
private:
bool m_object_located_outside_plate{false};
};
std::string get_name_from_gizmo_etype(GLGizmosManager::EType type);