Follow-up of 5b5fdfba01 - Removed member variable Selection::m_dragging

It was used only in ObjectManipulation::update_if_dirty() to avoid the update the sidebar reset and mirror button, which results in a slow down of the GUI, while dragging objects/gizmos in the 3D scene

A call to GLCanvas3D::is_dragging() is used instead
This commit is contained in:
enricoturri1966 2022-02-25 11:42:42 +01:00
parent 5b5fdfba01
commit 1e9951dec5
5 changed files with 13 additions and 29 deletions

View File

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

View File

@ -657,9 +657,9 @@ void ObjectManipulation::update_if_dirty()
else
m_og->disable();
if (!selection.is_dragging()) {
if (!wxGetApp().plater()->canvas3D()->is_dragging()) {
update_reset_buttons_visibility();
update_mirror_buttons_visibility();
update_mirror_buttons_visibility();
}
m_dirty = false;
@ -814,9 +814,8 @@ void ObjectManipulation::change_position_value(int axis, double value)
auto canvas = wxGetApp().plater()->canvas3D();
Selection& selection = canvas->get_selection();
selection.start_dragging();
selection.setup_cache();
selection.translate(position - m_cache.position, selection.requires_local_axes());
selection.stop_dragging();
canvas->do_move(L("Set Position"));
m_cache.position = position;
@ -844,11 +843,10 @@ void ObjectManipulation::change_rotation_value(int axis, double value)
transformation_type.set_local();
}
selection.start_dragging();
selection.setup_cache();
selection.rotate(
(M_PI / 180.0) * (transformation_type.absolute() ? rotation : rotation - m_cache.rotation),
transformation_type);
selection.stop_dragging();
canvas->do_rotate(L("Set Orientation"));
m_cache.rotation = rotation;
@ -925,9 +923,8 @@ void ObjectManipulation::do_scale(int axis, const Vec3d &scale) const
if (m_uniform_scale || selection.requires_uniform_scale())
scaling_factor = scale(axis) * Vec3d::Ones();
selection.start_dragging();
selection.setup_cache();
selection.scale(scaling_factor, transformation_type);
selection.stop_dragging();
wxGetApp().plater()->canvas3D()->do_scale(L("Set Scale"));
}

View File

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

View File

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

View File

@ -229,7 +229,6 @@ private:
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
float m_scale_factor;
bool m_dragging;
public:
Selection();
@ -322,9 +321,7 @@ public:
const BoundingBoxf3& get_unscaled_instance_bounding_box() const;
const BoundingBoxf3& get_scaled_instance_bounding_box() const;
void start_dragging();
void stop_dragging() { m_dragging = false; }
bool is_dragging() const { return m_dragging; }
void setup_cache();
void translate(const Vec3d& displacement, bool local = false);
void rotate(const Vec3d& rotation, TransformationType transformation_type);