mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-07 23:17:35 -06:00
ENH: unify multi-object copy with single copy
Also adapt empty cell stride with object size plus 1mm. Change-Id: I47ac98bede196d636ebb3da549c16e393756de0a
This commit is contained in:
parent
b71917b28c
commit
9edc90704a
3 changed files with 17 additions and 14 deletions
|
@ -2619,6 +2619,7 @@ void Selection::paste_objects_from_clipboard()
|
|||
|
||||
//BBS: if multiple objects are selected, move them as a whole after copy
|
||||
Vec2d shift_all = {0, 0};
|
||||
Vec2f empty_cell_all = {0, 0};
|
||||
if (src_objects.size() > 1) {
|
||||
BoundingBoxf3 bbox_all;
|
||||
for (const ModelObject *src_object : src_objects) {
|
||||
|
@ -2632,25 +2633,27 @@ void Selection::paste_objects_from_clipboard()
|
|||
shift_all = {0, bbox_all.size().y()};
|
||||
}
|
||||
|
||||
for (const ModelObject* src_object : src_objects)
|
||||
for (size_t i=0;i<src_objects.size();i++)
|
||||
{
|
||||
const ModelObject *src_object = src_objects[i];
|
||||
ModelObject* dst_object = m_model->add_object(*src_object);
|
||||
|
||||
// BBS: find an empty cell to put the copied object
|
||||
BoundingBoxf3 bbox = src_object->instance_convex_hull_bounding_box(0);
|
||||
|
||||
Vec3d displacement;
|
||||
bool in_current = plate->intersects(bbox);
|
||||
auto start_point = in_current ? bbox.center() : plate->get_build_volume().center();
|
||||
if (shift_all(0) != 0 || shift_all(1) != 0) {
|
||||
// BBS: if multiple objects are selected, move them as a whole after copy
|
||||
auto start_point = bbox.center();
|
||||
displacement = {shift_all.x() + start_point.x(), shift_all.y() + start_point.y(), start_point(2)};
|
||||
if (i == 0) empty_cell_all = wxGetApp().plater()->canvas3D()->get_nearest_empty_cell({start_point(0), start_point(1)}, {bbox.size()(0)+1,bbox.size()(1)+1});
|
||||
auto instance_shift = src_object->instances.front()->get_offset() - src_objects[0]->instances.front()->get_offset();
|
||||
displacement = {shift_all.x() + empty_cell_all.x()+instance_shift.x(), shift_all.y() + empty_cell_all.y()+instance_shift.y(), start_point(2)};
|
||||
} else {
|
||||
// BBS: if only one object is copied, find an empty cell to put it
|
||||
bool in_current = plate->intersects(bbox);
|
||||
auto start_point = in_current ? bbox.center() : plate->get_build_volume().center();
|
||||
auto start_offset = in_current ? src_object->instances.front()->get_offset() : plate->get_build_volume().center();
|
||||
auto point_offset = start_offset - start_point;
|
||||
auto empty_cell = wxGetApp().plater()->canvas3D()->get_nearest_empty_cell({start_point(0), start_point(1)});
|
||||
auto empty_cell = wxGetApp().plater()->canvas3D()->get_nearest_empty_cell({start_point(0), start_point(1)}, {bbox.size()(0)+1, bbox.size()(1)+1});
|
||||
displacement = {empty_cell.x() + point_offset.x(), empty_cell.y() + point_offset.y(), start_point(2)};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue