FIX:delete old selection.translate api
jira: STUDIO-8201 code is from PrusaSlicer,thanks for PrusaSlicer and enricoturri1966 commit 88ce6ccdef5f680709ea8b676688784a7af287dd Author: enricoturri1966 <enricoturri@seznam.cz> Date: Wed May 11 10:54:42 2022 +0200 Tech ENABLE_TRANSFORMATIONS_BY_MATRICES - Change-Id: Iafe963f0f7bf9028f32a4fb4a4cc8cc609662283 Change-Id: Ibbc36c004734f35564f0028dd1e537ac926a2f1f
This commit is contained in:
parent
6323b1d29b
commit
c6d9f2685e
|
@ -3482,7 +3482,9 @@ void GLCanvas3D::on_key(wxKeyEvent& evt)
|
|||
else
|
||||
displacement = multiplier * direction;
|
||||
|
||||
m_selection.translate(displacement);
|
||||
TransformationType trafo_type;
|
||||
trafo_type.set_relative();
|
||||
m_selection.translate(displacement, trafo_type);
|
||||
m_selection.stop_dragging();
|
||||
m_dirty = true;
|
||||
}
|
||||
|
@ -4304,8 +4306,9 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
cur_pos = Linef3(_mouse_to_3d(pos, &z0), _mouse_to_3d(pos, &z1)).intersect_plane(m_mouse.drag.start_position_3D(2));
|
||||
}
|
||||
}
|
||||
|
||||
m_selection.translate(cur_pos - m_mouse.drag.start_position_3D);
|
||||
TransformationType trafo_type;
|
||||
trafo_type.set_relative();
|
||||
m_selection.translate(cur_pos - m_mouse.drag.start_position_3D, trafo_type);
|
||||
if (current_printer_technology() == ptFFF && (fff_print()->config().print_sequence == PrintSequence::ByObject))
|
||||
update_sequential_clearance();
|
||||
// BBS
|
||||
|
|
|
@ -290,9 +290,24 @@ void GizmoObjectManipulation::change_position_value(int axis, double value)
|
|||
position(axis) = value;
|
||||
|
||||
Selection& selection = m_glcanvas.get_selection();
|
||||
selection.start_dragging();
|
||||
selection.translate(position - m_cache.position, selection.requires_local_axes());
|
||||
wxGetApp().plater()->take_snapshot(_u8L("Set Position"), UndoRedo::SnapshotType::GizmoAction);
|
||||
selection.setup_cache();
|
||||
TransformationType trafo_type;
|
||||
trafo_type.set_relative();
|
||||
switch (m_coordinates_type) {
|
||||
case ECoordinatesType::Instance: {
|
||||
trafo_type.set_instance();
|
||||
break;
|
||||
}
|
||||
case ECoordinatesType::Local: {
|
||||
trafo_type.set_local();
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
selection.translate(position - m_cache.position, trafo_type);
|
||||
wxGetApp().plater()->take_snapshot("Set Position", UndoRedo::SnapshotType::GizmoAction);
|
||||
m_glcanvas.do_move("");
|
||||
|
||||
m_cache.position = position;
|
||||
|
|
|
@ -1172,77 +1172,6 @@ void Selection::setup_cache()
|
|||
set_caches();
|
||||
}
|
||||
|
||||
void Selection::translate(const Vec3d &displacement, bool local)
|
||||
{
|
||||
if (!m_valid)
|
||||
return;
|
||||
|
||||
EMode translation_type = m_mode;
|
||||
//BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << boost::format(": %1%, displacement {%2%, %3%, %4%}") % __LINE__ % displacement(X) % displacement(Y) % displacement(Z);
|
||||
|
||||
for (unsigned int i : m_list) {
|
||||
GLVolume& v = *(*m_volumes)[i];
|
||||
if (v.is_wipe_tower) {
|
||||
int plate_idx = v.object_idx() - 1000;
|
||||
BoundingBoxf3 plate_bbox = wxGetApp().plater()->get_partplate_list().get_plate(plate_idx)->get_bounding_box();
|
||||
Vec3d tower_size = v.bounding_box().size();
|
||||
Vec3d tower_origin = m_cache.volumes_data[i].get_volume_position();
|
||||
Vec3d actual_displacement = displacement;
|
||||
const double margin = WIPE_TOWER_MARGIN;
|
||||
|
||||
if (!local)
|
||||
actual_displacement = (m_cache.volumes_data[i].get_instance_rotation_matrix() * m_cache.volumes_data[i].get_instance_scale_matrix() * m_cache.volumes_data[i].get_instance_mirror_matrix()).inverse() * displacement;
|
||||
|
||||
if (tower_origin(0) + actual_displacement(0) - margin < plate_bbox.min(0)) {
|
||||
actual_displacement(0) = plate_bbox.min(0) - tower_origin(0) + margin;
|
||||
}
|
||||
else if (tower_origin(0) + actual_displacement(0) + tower_size(0) + margin > plate_bbox.max(0)) {
|
||||
actual_displacement(0) = plate_bbox.max(0) - tower_origin(0) - tower_size(0) - margin;
|
||||
}
|
||||
|
||||
if (tower_origin(1) + actual_displacement(1) - margin < plate_bbox.min(1)) {
|
||||
actual_displacement(1) = plate_bbox.min(1) - tower_origin(1) + margin;
|
||||
}
|
||||
else if (tower_origin(1) + actual_displacement(1) + tower_size(1) + margin > plate_bbox.max(1)) {
|
||||
actual_displacement(1) = plate_bbox.max(1) - tower_origin(1) - tower_size(1) - margin;
|
||||
}
|
||||
|
||||
v.set_volume_offset(m_cache.volumes_data[i].get_volume_position() + actual_displacement);
|
||||
}
|
||||
else if (m_mode == Volume || v.is_wipe_tower) {
|
||||
if (local)
|
||||
v.set_volume_offset(m_cache.volumes_data[i].get_volume_position() + displacement);
|
||||
else {
|
||||
const Vec3d local_displacement = (m_cache.volumes_data[i].get_instance_rotation_matrix() * m_cache.volumes_data[i].get_instance_scale_matrix() * m_cache.volumes_data[i].get_instance_mirror_matrix()).inverse() * displacement;
|
||||
v.set_volume_offset(m_cache.volumes_data[i].get_volume_position() + local_displacement);
|
||||
}
|
||||
}
|
||||
else if (m_mode == Instance) {
|
||||
if (is_from_fully_selected_instance(i))
|
||||
v.set_instance_offset(m_cache.volumes_data[i].get_instance_position() + displacement);
|
||||
else {
|
||||
const Vec3d local_displacement = (m_cache.volumes_data[i].get_instance_rotation_matrix() * m_cache.volumes_data[i].get_instance_scale_matrix() * m_cache.volumes_data[i].get_instance_mirror_matrix()).inverse() * displacement;
|
||||
v.set_volume_offset(m_cache.volumes_data[i].get_volume_position() + local_displacement);
|
||||
translation_type = Volume;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if !DISABLE_INSTANCES_SYNCH
|
||||
if (translation_type == Instance)
|
||||
synchronize_unselected_instances(SyncRotationType::NONE);
|
||||
else if (translation_type == Volume)
|
||||
synchronize_unselected_volumes();
|
||||
#endif // !DISABLE_INSTANCES_SYNCH
|
||||
if (wxGetApp().plater()->canvas3D()->get_canvas_type() != GLCanvas3D::ECanvasType::CanvasAssembleView) {
|
||||
ensure_not_below_bed();
|
||||
}
|
||||
set_bounding_boxes_dirty();
|
||||
if (wxGetApp().plater()->canvas3D()->get_canvas_type() != GLCanvas3D::ECanvasType::CanvasAssembleView) {
|
||||
wxGetApp().plater()->canvas3D()->requires_check_outside_state();
|
||||
}
|
||||
}
|
||||
|
||||
void Selection::translate(const Vec3d &displacement, TransformationType transformation_type)
|
||||
{
|
||||
if (!m_valid) return;
|
||||
|
@ -1524,7 +1453,9 @@ void Selection::scale_to_fit_print_volume(const BuildVolume& volume)
|
|||
// center selection on print bed
|
||||
start_dragging();
|
||||
offset.z() = -get_bounding_box().min.z();
|
||||
translate(offset);
|
||||
TransformationType trafo_type;
|
||||
trafo_type.set_relative();
|
||||
translate(offset, trafo_type);
|
||||
wxGetApp().plater()->canvas3D()->do_move(""); // avoid storing another snapshot
|
||||
|
||||
// BBS
|
||||
|
|
|
@ -410,7 +410,6 @@ public:
|
|||
const std::pair<Vec3d, double> get_bounding_sphere() const;
|
||||
|
||||
void setup_cache();
|
||||
void translate(const Vec3d &displacement, bool local = false);//old
|
||||
void translate(const Vec3d &displacement, TransformationType transformation_type);//new
|
||||
void move_to_center(const Vec3d& displacement, bool local = false);
|
||||
void rotate(const Vec3d& rotation, TransformationType transformation_type);
|
||||
|
|
Loading…
Reference in New Issue