mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 23:46:24 -06:00
Duplicate Current Plate With Objects (Second PR) (#6710)
* Added `duplicate plate` feature. This the initial commit and this still needs work. * [#2025] Fixed the SEGFAULT, apparently an icon id=6 needed to be updated to id=7 as we have one more plate icon. [#2025] Removed the `printf` statements. * [#2025] Plate duplication is now fully implemented. * [#2025] Updated icons for plate duplicate funcctionality. * [#2025] Added toolbar icon fro "Duplicate Current Plate" action. * [#2025] Revert changes for `toolbar_add_plate_dark.svg`. * [#2025] Removed the `BBS` label in the code that is not written by BBS. * [#2025] Updated `.gitignore` to ignore VSCode workspace file. * [#2025] Fixed the instances not transforming in global space when the plate is duplicated. * [#2025] Removed the Duplicate Plate action from the plate actions and the toolbar. * [#2025] Added the `Duplicate Current Plate` functionality to the `Edit` menu. * [#2025] Addressed review comments. * [#2025] Addressed review comments. * [#2025] Removed unused icons related to the previously introduced "Duplicate Plate" functionality.
This commit is contained in:
parent
d87734ebfa
commit
2b4cd6577b
6 changed files with 71 additions and 9 deletions
|
@ -2716,7 +2716,7 @@ bool PartPlate::set_shape(const Pointfs& shape, const Pointfs& exclude_areas, Ve
|
|||
calc_vertex_for_number(0, false, m_plate_idx_icon);
|
||||
if (m_plater) {
|
||||
// calc vertex for plate name
|
||||
generate_plate_name_texture();
|
||||
generate_plate_name_texture();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3654,6 +3654,38 @@ int PartPlateList::create_plate(bool adjust_position)
|
|||
return new_index;
|
||||
}
|
||||
|
||||
|
||||
int PartPlateList::duplicate_plate(int index)
|
||||
{
|
||||
// create a new plate
|
||||
int new_plate_index = create_plate(true);
|
||||
PartPlate* old_plate = NULL;
|
||||
PartPlate* new_plate = NULL;
|
||||
old_plate = get_plate(index);
|
||||
new_plate = get_plate(new_plate_index);
|
||||
|
||||
// get the offset between plate centers
|
||||
Vec3d plate_to_plate_offset = new_plate->m_origin - old_plate->m_origin;
|
||||
|
||||
// iterate over all the objects in this plate
|
||||
ModelObjectPtrs obj_ptrs = old_plate->get_objects_on_this_plate();
|
||||
for (ModelObject* object : obj_ptrs){
|
||||
// copy and move the object to the same relative position in the new plate
|
||||
ModelObject* object_copy = m_model->add_object(*object);
|
||||
int new_obj_id = new_plate->m_model->objects.size() - 1;
|
||||
// go over the instances and pair with the object
|
||||
for (size_t new_instance_id = 0; new_instance_id < object_copy->instances.size(); new_instance_id++){
|
||||
new_plate->obj_to_instance_set.emplace(std::pair(new_obj_id, new_instance_id));
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": duplicate object into plate: index_pair [%1%,%2%], obj_id %3%") % new_obj_id % new_instance_id % object_copy->id().id;
|
||||
}
|
||||
}
|
||||
new_plate->translate_all_instance(plate_to_plate_offset);
|
||||
// update the plates
|
||||
wxGetApp().obj_list()->reload_all_plates();
|
||||
return new_plate_index;
|
||||
}
|
||||
|
||||
|
||||
//destroy print's objects and results
|
||||
int PartPlateList::destroy_print(int print_index)
|
||||
{
|
||||
|
@ -4781,7 +4813,7 @@ void PartPlateList::render(const Transform3d& view_matrix, const Transform3d& pr
|
|||
if (m_is_dark != last_dark_mode_status) {
|
||||
last_dark_mode_status = m_is_dark;
|
||||
generate_icon_textures();
|
||||
}else if(m_del_texture.get_id() == 0)
|
||||
} else if(m_del_texture.get_id() == 0)
|
||||
generate_icon_textures();
|
||||
for (it = m_plate_list.begin(); it != m_plate_list.end(); it++) {
|
||||
int current_index = (*it)->get_index();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue