mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-20 06:01:16 +00:00
Add Align/Distribute objects on the print plate (#13373)
* Add Align/Distribute objects on the print plate Ports the Align/Distribute feature from BambuStudio 2.5 (AGPLv3, same license as OrcaSlicer). Adds a new GLGizmoAlignment helper that operates on the GLCanvas3D selection, twelve thin Plater wrappers, and an Align/Distribute submenu attached to the same five context menus BambuStudio attaches it to: object menu, text part, BBL part, and the single/multi-volume context menus. GLCanvas3D::do_move gains a defaulted force_volume_move parameter so the helper can move multiple selected volumes within a single object even when selection mode is Instance. GLGizmosManager gains check_object_located_outside_plate, which switches the active plate to the one containing the selection before align/distribute runs. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix build errors --------- Co-authored-by: yw4z <ywsyildiz@gmail.com> Co-authored-by: SoftFever <103989404+SoftFever@users.noreply.github.com>
This commit is contained in:
11 files changed
+1196
-15
No files matched your search
@@ -5520,7 +5520,7 @@ void GLCanvas3D::set_tooltip(const std::string& tooltip)
|
||||
m_tooltip.set_text(tooltip);
|
||||
}
|
||||
|
||||
void GLCanvas3D::do_move(const std::string& snapshot_type)
|
||||
void GLCanvas3D::do_move(const std::string& snapshot_type, bool force_volume_move)
|
||||
{
|
||||
if (m_model == nullptr)
|
||||
return;
|
||||
@@ -5552,10 +5552,18 @@ void GLCanvas3D::do_move(const std::string& snapshot_type)
|
||||
|
||||
// Move instances/volumes
|
||||
ModelObject* model_object = m_model->objects[object_idx];
|
||||
if (model_object == nullptr)
|
||||
if (model_object == nullptr)
|
||||
continue;
|
||||
|
||||
if (selection_mode == Selection::Instance) {
|
||||
if (force_volume_move || selection_mode == Selection::Volume) {
|
||||
auto cur_mv = model_object->volumes[volume_idx];
|
||||
if (cur_mv->get_transformation() != v->get_volume_transformation()) {
|
||||
cur_mv->set_transformation(v->get_volume_transformation());
|
||||
// BBS: backup
|
||||
Slic3r::save_object_mesh(*model_object);
|
||||
}
|
||||
}
|
||||
else if (selection_mode == Selection::Instance) {
|
||||
if (m_canvas_type == GLCanvas3D::ECanvasType::CanvasAssembleView) {
|
||||
if ((model_object->instances[instance_idx]->get_assemble_offset() - v->get_instance_offset()).norm() > 1e-2) {
|
||||
model_object->instances[instance_idx]->set_assemble_transformation(v->get_instance_transformation());
|
||||
@@ -5564,14 +5572,6 @@ void GLCanvas3D::do_move(const std::string& snapshot_type)
|
||||
model_object->instances[instance_idx]->set_transformation(v->get_instance_transformation());
|
||||
}
|
||||
}
|
||||
else if (selection_mode == Selection::Volume) {
|
||||
auto cur_mv = model_object->volumes[volume_idx];
|
||||
if (cur_mv->get_transformation() != v->get_volume_transformation()) {
|
||||
cur_mv->set_transformation(v->get_volume_transformation());
|
||||
// BBS: backup
|
||||
Slic3r::save_object_mesh(*model_object);
|
||||
}
|
||||
}
|
||||
|
||||
object_moved = true;
|
||||
model_object->invalidate_bounding_box();
|
||||
|
||||
Reference in new issue
Block a user