Allow rotation of multiple selected items. Disable auto positioning

This commit is contained in:
tamasmeszaros 2021-03-31 14:50:24 +02:00
parent 804758dfed
commit 649dfca8d6
6 changed files with 99 additions and 44 deletions

View file

@ -2669,32 +2669,36 @@ void Plater::priv::mirror(Axis axis)
view3D->mirror_selection(axis);
}
void Plater::find_new_position(const ModelInstancePtrs &instances,
coord_t min_d)
void Plater::find_new_position(const ModelInstancePtrs &instances)
{
arrangement::ArrangePolygons movable, fixed;
arrangement::ArrangeParams arr_params = get_arrange_params(this);
for (const ModelObject *mo : p->model.objects)
for (const ModelInstance *inst : mo->instances) {
for (ModelInstance *inst : mo->instances) {
auto it = std::find(instances.begin(), instances.end(), inst);
auto arrpoly = inst->get_arrange_polygon();
auto arrpoly = get_arrange_poly(inst, this);
if (it == instances.end())
fixed.emplace_back(std::move(arrpoly));
else
else {
arrpoly.setter = [it](const arrangement::ArrangePolygon &p) {
if (p.is_arranged() && p.bed_idx == 0) {
Vec2d t = p.translation.cast<double>();
(*it)->apply_arrange_result(t, p.rotation);
}
};
movable.emplace_back(std::move(arrpoly));
}
}
if (auto wt = get_wipe_tower_arrangepoly(*this))
fixed.emplace_back(*wt);
arrangement::arrange(movable, fixed, get_bed_shape(*config()),
arrangement::ArrangeParams{min_d});
arrangement::arrange(movable, fixed, get_bed_shape(*config()), arr_params);
for (size_t i = 0; i < instances.size(); ++i)
if (movable[i].bed_idx == 0)
instances[i]->apply_arrange_result(movable[i].translation.cast<double>(),
movable[i].rotation);
for (auto & m : movable)
m.apply();
}
void Plater::priv::split_object()