Fixed conflicts after merge with master

This commit is contained in:
enricoturri1966 2022-02-25 12:02:44 +01:00
commit 7d971b15a3
5 changed files with 14 additions and 33 deletions

View File

@ -2774,7 +2774,7 @@ void GLCanvas3D::on_key(wxKeyEvent& evt)
m_dirty = true; m_dirty = true;
}, },
[this](const Vec3d& direction, bool slow, bool camera_space) { [this](const Vec3d& direction, bool slow, bool camera_space) {
m_selection.start_dragging(); m_selection.setup_cache();
double multiplier = slow ? 1.0 : 10.0; double multiplier = slow ? 1.0 : 10.0;
Vec3d displacement; Vec3d displacement;
@ -2787,7 +2787,6 @@ void GLCanvas3D::on_key(wxKeyEvent& evt)
displacement = multiplier * direction; displacement = multiplier * direction;
m_selection.translate(displacement); m_selection.translate(displacement);
m_selection.stop_dragging();
m_dirty = true; m_dirty = true;
} }
); );
@ -2884,9 +2883,8 @@ void GLCanvas3D::on_key(wxKeyEvent& evt)
m_dirty = true; m_dirty = true;
else if (m_gizmos.is_enabled() && !m_selection.is_empty()) { else if (m_gizmos.is_enabled() && !m_selection.is_empty()) {
auto do_rotate = [this](double angle_z_rad) { auto do_rotate = [this](double angle_z_rad) {
m_selection.start_dragging(); m_selection.setup_cache();
m_selection.rotate(Vec3d(0.0, 0.0, angle_z_rad), TransformationType(TransformationType::World_Relative_Joint)); m_selection.rotate(Vec3d(0.0, 0.0, angle_z_rad), TransformationType(TransformationType::World_Relative_Joint));
m_selection.stop_dragging();
m_dirty = true; m_dirty = true;
// wxGetApp().obj_manipul()->set_dirty(); // wxGetApp().obj_manipul()->set_dirty();
}; };
@ -3352,7 +3350,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
m_volumes.volumes[volume_idx]->hover = GLVolume::HS_None; m_volumes.volumes[volume_idx]->hover = GLVolume::HS_None;
// The dragging operation is initiated. // The dragging operation is initiated.
m_mouse.drag.move_volume_idx = volume_idx; m_mouse.drag.move_volume_idx = volume_idx;
m_selection.start_dragging(); m_selection.setup_cache();
m_mouse.drag.start_position_3D = m_mouse.scene_position; m_mouse.drag.start_position_3D = m_mouse.scene_position;
m_sequential_print_clearance_first_displacement = true; m_sequential_print_clearance_first_displacement = true;
m_moving = true; m_moving = true;
@ -3464,9 +3462,6 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
} }
} }
else if (evt.LeftUp() || evt.MiddleUp() || evt.RightUp()) { else if (evt.LeftUp() || evt.MiddleUp() || evt.RightUp()) {
if (evt.LeftUp())
m_selection.stop_dragging();
if (m_layers_editing.state != LayersEditing::Unknown) { if (m_layers_editing.state != LayersEditing::Unknown) {
m_layers_editing.state = LayersEditing::Unknown; m_layers_editing.state = LayersEditing::Unknown;
_stop_timer(); _stop_timer();

View File

@ -839,7 +839,7 @@ void ObjectManipulation::update_if_dirty()
else else
m_og->disable(); m_og->disable();
if (!selection.is_dragging()) { if (!wxGetApp().plater()->canvas3D()->is_dragging()) {
update_reset_buttons_visibility(); update_reset_buttons_visibility();
update_mirror_buttons_visibility(); update_mirror_buttons_visibility();
} }
@ -1028,13 +1028,12 @@ void ObjectManipulation::change_position_value(int axis, double value)
auto canvas = wxGetApp().plater()->canvas3D(); auto canvas = wxGetApp().plater()->canvas3D();
Selection& selection = canvas->get_selection(); Selection& selection = canvas->get_selection();
selection.start_dragging(); selection.setup_cache();
#if ENABLE_WORLD_COORDINATE #if ENABLE_WORLD_COORDINATE
selection.translate(position - m_cache.position, get_coordinates_type()); selection.translate(position - m_cache.position, get_coordinates_type());
#else #else
selection.translate(position - m_cache.position, selection.requires_local_axes()); selection.translate(position - m_cache.position, selection.requires_local_axes());
#endif // ENABLE_WORLD_COORDINATE #endif // ENABLE_WORLD_COORDINATE
selection.stop_dragging();
canvas->do_move(L("Set Position")); canvas->do_move(L("Set Position"));
m_cache.position = position; m_cache.position = position;
@ -1075,11 +1074,10 @@ void ObjectManipulation::change_rotation_value(int axis, double value)
} }
#endif // ENABLE_WORLD_COORDINATE #endif // ENABLE_WORLD_COORDINATE
selection.start_dragging(); selection.setup_cache();
selection.rotate( selection.rotate(
(M_PI / 180.0) * (transformation_type.absolute() ? rotation : rotation - m_cache.rotation), (M_PI / 180.0) * (transformation_type.absolute() ? rotation : rotation - m_cache.rotation),
transformation_type); transformation_type);
selection.stop_dragging();
canvas->do_rotate(L("Set Orientation")); canvas->do_rotate(L("Set Orientation"));
m_cache.rotation = rotation; m_cache.rotation = rotation;
@ -1199,9 +1197,8 @@ void ObjectManipulation::do_scale(int axis, const Vec3d &scale) const
scaling_factor = scale(axis) * Vec3d::Ones(); scaling_factor = scale(axis) * Vec3d::Ones();
#endif // ENABLE_WORLD_COORDINATE #endif // ENABLE_WORLD_COORDINATE
selection.start_dragging(); selection.setup_cache();
selection.scale(scaling_factor, transformation_type); selection.scale(scaling_factor, transformation_type);
selection.stop_dragging();
wxGetApp().plater()->canvas3D()->do_scale(L("Set Scale")); wxGetApp().plater()->canvas3D()->do_scale(L("Set Scale"));
} }
@ -1229,9 +1226,8 @@ void ObjectManipulation::do_size(int axis, const Vec3d& scale) const
} }
} }
selection.start_dragging(); selection.setup_cache();
selection.scale(scaling_factor, transformation_type); selection.scale(scaling_factor, transformation_type);
selection.stop_dragging();
wxGetApp().plater()->canvas3D()->do_scale(L("Set Size")); wxGetApp().plater()->canvas3D()->do_scale(L("Set Size"));
} }
#endif // ENABLE_WORLD_COORDINATE_SCALE_REVISITED #endif // ENABLE_WORLD_COORDINATE_SCALE_REVISITED

View File

@ -162,8 +162,7 @@ bool GLGizmoBase::use_grabbers(const wxMouseEvent &mouse_event) {
Selection &selection = m_parent.get_selection(); Selection &selection = m_parent.get_selection();
if (!selection.is_empty() && m_hover_id != -1 && if (!selection.is_empty() && m_hover_id != -1 &&
(m_grabbers.empty() || m_hover_id < static_cast<int>(m_grabbers.size()))) { (m_grabbers.empty() || m_hover_id < static_cast<int>(m_grabbers.size()))) {
// TODO: investigate if it is neccessary -> there was no stop dragging selection.setup_cache();
selection.start_dragging();
m_dragging = true; m_dragging = true;
for (auto &grabber : m_grabbers) grabber.dragging = false; for (auto &grabber : m_grabbers) grabber.dragging = false;
@ -207,8 +206,6 @@ bool GLGizmoBase::use_grabbers(const wxMouseEvent &mouse_event) {
on_stop_dragging(); on_stop_dragging();
m_parent.get_selection().stop_dragging();
// There is prediction that after draggign, data are changed // There is prediction that after draggign, data are changed
// Data are updated twice also by canvas3D::reload_scene. // Data are updated twice also by canvas3D::reload_scene.
// Should be fixed. // Should be fixed.
@ -241,8 +238,6 @@ void GLGizmoBase::do_stop_dragging(bool perform_mouse_cleanup)
on_stop_dragging(); on_stop_dragging();
m_parent.get_selection().stop_dragging();
// There is prediction that after draggign, data are changed // There is prediction that after draggign, data are changed
// Data are updated twice also by canvas3D::reload_scene. // Data are updated twice also by canvas3D::reload_scene.
// Should be fixed. // Should be fixed.

View File

@ -120,7 +120,6 @@ Selection::Selection()
, m_type(Empty) , m_type(Empty)
, m_valid(false) , m_valid(false)
, m_scale_factor(1.0f) , m_scale_factor(1.0f)
, m_dragging(false)
{ {
this->set_bounding_boxes_dirty(); this->set_bounding_boxes_dirty();
#if ENABLE_WORLD_COORDINATE_SHOW_AXES #if ENABLE_WORLD_COORDINATE_SHOW_AXES
@ -751,12 +750,11 @@ const BoundingBoxf3& Selection::get_scaled_instance_bounding_box() const
return *m_scaled_instance_bounding_box; return *m_scaled_instance_bounding_box;
} }
void Selection::start_dragging() void Selection::setup_cache()
{ {
if (!m_valid) if (!m_valid)
return; return;
m_dragging = true;
set_caches(); set_caches();
} }
@ -1113,12 +1111,12 @@ void Selection::scale_to_fit_print_volume(const BuildVolume& volume)
type.set_joint(); type.set_joint();
// apply scale // apply scale
start_dragging(); setup_cache();
scale(s * Vec3d::Ones(), type); scale(s * Vec3d::Ones(), type);
wxGetApp().plater()->canvas3D()->do_scale(""); // avoid storing another snapshot wxGetApp().plater()->canvas3D()->do_scale(""); // avoid storing another snapshot
// center selection on print bed // center selection on print bed
start_dragging(); setup_cache();
offset.z() = -get_bounding_box().min.z(); offset.z() = -get_bounding_box().min.z();
translate(offset); translate(offset);
wxGetApp().plater()->canvas3D()->do_move(""); // avoid storing another snapshot wxGetApp().plater()->canvas3D()->do_move(""); // avoid storing another snapshot

View File

@ -243,7 +243,6 @@ private:
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL #endif // ENABLE_GLBEGIN_GLEND_REMOVAL
float m_scale_factor; float m_scale_factor;
bool m_dragging;
public: public:
Selection(); Selection();
@ -351,9 +350,7 @@ public:
const BoundingBoxf3& get_unscaled_instance_bounding_box() const; const BoundingBoxf3& get_unscaled_instance_bounding_box() const;
const BoundingBoxf3& get_scaled_instance_bounding_box() const; const BoundingBoxf3& get_scaled_instance_bounding_box() const;
void start_dragging(); void setup_cache();
void stop_dragging() { m_dragging = false; }
bool is_dragging() const { return m_dragging; }
#if ENABLE_WORLD_COORDINATE #if ENABLE_WORLD_COORDINATE
void translate(const Vec3d& displacement, ECoordinatesType type = ECoordinatesType::World); void translate(const Vec3d& displacement, ECoordinatesType type = ECoordinatesType::World);