FIX: undo/redo plate name

Change-Id: Ic47d399ecce25db4a5b6cbd1f58b821c6cb36136
(cherry picked from commit 0c11d73777d507381419d928549143c9ee56682d)
This commit is contained in:
zhou.xu 2023-07-17 19:44:27 +08:00 committed by Lane.Wei
parent 19525b6564
commit 1f30783f11
2 changed files with 11 additions and 6 deletions

View file

@ -827,7 +827,7 @@ void PartPlate::render_icon_texture(int position_id, int tex_coords_id, const Ge
void PartPlate::render_plate_name_texture(int position_id, int tex_coords_id)
{
if (m_name_change == true) {
if (m_name_change) {
m_name_change = false;
if (m_plate_name_vbo_id > 0) {
glsafe(::glDeleteBuffers(1, &m_plate_name_vbo_id));
@ -841,6 +841,10 @@ void PartPlate::render_plate_name_texture(int position_id, int tex_coords_id)
if (m_plate_name_vbo_id==0) {
if (generate_plate_name_texture()) {
calc_vertex_for_plate_name(m_name_texture, m_plate_name_icon);
if (m_plate_name_edit_vbo_id > 0) { //for redo
glsafe(::glDeleteBuffers(1, &m_plate_name_edit_vbo_id));
m_plate_name_edit_vbo_id = 0;
}
calc_vertex_for_plate_name_edit_icon(&m_name_texture, 0, m_plate_name_edit_icon);
}
else {
@ -891,6 +895,7 @@ void PartPlate::render_icons(bool bottom, bool only_body, int hover_id)
if (tex_coords_id != -1) {
glsafe(::glEnableVertexAttribArray(tex_coords_id));
}
render_plate_name_texture(position_id, tex_coords_id);
if (!only_body) {
if (hover_id == 1)
render_icon_texture(position_id, tex_coords_id, m_del_icon, m_partplate_list->m_del_hovered_texture, m_del_vbo_id);
@ -943,7 +948,6 @@ void PartPlate::render_icons(bool bottom, bool only_body, int hover_id)
render_icon_texture(position_id, tex_coords_id, m_plate_idx_icon, m_partplate_list->m_idx_textures[m_plate_index], m_plate_idx_vbo_id);
}
}
render_plate_name_texture(position_id, tex_coords_id);
if (tex_coords_id != -1)
glsafe(::glDisableVertexAttribArray(tex_coords_id));
@ -1700,8 +1704,9 @@ bool PartPlate::generate_plate_name_texture()
void PartPlate::set_plate_name(const std::string &name)
{
// compare if name equal to m_name, case sensitive
if (boost::equals(m_name, name)) return;
m_name = name;
if (boost::equals(m_name, name)) return;
m_plater->take_snapshot("set_plate_name");
m_name = name;
std::regex reg("[\\\\/:*?\"<>|\\0]");
m_name= regex_replace(m_name, reg, "");

View file

@ -449,7 +449,7 @@ public:
std::vector<std::pair<int, int>> objects_and_instances;
std::vector<std::pair<int, int>> instances_outside;
ar(m_plate_index, m_print_index, m_origin, m_width, m_depth, m_height, m_locked, m_selected, m_ready_for_slice, m_slice_result_valid, m_apply_invalid, m_printable, m_tmp_gcode_path, objects_and_instances, instances_outside, m_config);
ar(m_plate_index, m_print_index, m_origin, m_width, m_depth, m_height, m_locked, m_selected, m_ready_for_slice, m_slice_result_valid, m_apply_invalid, m_printable, m_tmp_gcode_path, objects_and_instances, instances_outside, m_config, m_name);
for (std::vector<std::pair<int, int>>::iterator it = objects_and_instances.begin(); it != objects_and_instances.end(); ++it)
obj_to_instance_set.insert(std::pair(it->first, it->second));
@ -467,7 +467,7 @@ public:
for (std::set<std::pair<int, int>>::iterator it = obj_to_instance_set.begin(); it != obj_to_instance_set.end(); ++it)
objects_and_instances.emplace_back(it->first, it->second);
ar(m_plate_index, m_print_index, m_origin, m_width, m_depth, m_height, m_locked, m_selected, m_ready_for_slice, m_slice_result_valid, m_apply_invalid, m_printable, m_tmp_gcode_path, objects_and_instances, instances_outside, m_config);
ar(m_plate_index, m_print_index, m_origin, m_width, m_depth, m_height, m_locked, m_selected, m_ready_for_slice, m_slice_result_valid, m_apply_invalid, m_printable,m_tmp_gcode_path, objects_and_instances, instances_outside, m_config, m_name);
}
/*template<class Archive> void serialize(Archive& ar)
{