FIX:ban move glvolume when at cut and

so on gizmo
jira:STUDIO-8408
part code is from OrcaSlicer,thanks for OrcaSlicer and Filip Sykala
commit 9dbb2dfe0d5395577a1f86fad7954771d7c77910
Author: Filip Sykala <filip.sykala@prusa3d.cz>
Date:   Sun Oct 29 23:11:10 2023 +0800

    Various gizmos refactoring

Change-Id: I7173e997bab1611c96643628fde9b147c54df5e6
This commit is contained in:
zhou.xu 2024-10-10 17:35:51 +08:00 committed by Lane.Wei
parent a26a7f126a
commit 72245ed079
5 changed files with 24 additions and 5 deletions

View File

@ -3475,7 +3475,10 @@ void GLCanvas3D::on_key(wxKeyEvent& evt)
m_dirty = true;
},
[this](const Vec3d& direction, bool slow, bool camera_space) {
m_selection.start_dragging();
if (m_gizmos.is_ban_move_glvolume()) {
return;
}
m_selection.setup_cache();
double multiplier = slow ? 1.0 : 10.0;
Vec3d displacement;
@ -3490,7 +3493,6 @@ void GLCanvas3D::on_key(wxKeyEvent& evt)
TransformationType trafo_type;
trafo_type.set_relative();
m_selection.translate(displacement, trafo_type);
m_selection.stop_dragging();
m_dirty = true;
}
);}
@ -3647,12 +3649,14 @@ void GLCanvas3D::on_key(wxKeyEvent& evt)
post_event(SimpleEvent(EVT_GLCANVAS_COLLAPSE_SIDEBAR));
} else if (m_gizmos.is_enabled() && !m_selection.is_empty() && m_canvas_type != CanvasAssembleView) {
auto _do_rotate = [this](double angle_z_rad) {
if (m_gizmos.is_ban_move_glvolume()) {
return;
}
if (!m_gizmos.get_gizmo_active_condition(GLGizmosManager::EType::Rotate)) {
return;
}
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();
};

View File

@ -510,6 +510,8 @@ void GLGizmoRotate3D::data_changed(bool is_serializing) {
}
m_object_manipulation->set_init_rotation(tran);
}
for (GLGizmoRotate &g : m_gizmos)
g.init_data_from_selection(m_parent.get_selection());
}
bool GLGizmoRotate3D::on_is_activable() const

View File

@ -59,6 +59,7 @@ public:
void set_center(const Vec3d &point) { m_custom_center = point; }
void set_force_local_coordinate(bool use) { m_force_local_coordinate = use; }
void init_data_from_selection(const Selection &selection);
protected:
bool on_init() override;
@ -80,7 +81,6 @@ private:
void transform_to_local(const Selection& selection) const;
// returns the intersection of the mouse ray with the plane perpendicular to the gizmo axis, in local coordinate
Vec3d mouse_position_in_local_plane(const Linef3& mouse_ray, const Selection& selection) const;
void init_data_from_selection(const Selection &selection);
};
class GLGizmoRotate3D : public GLGizmoBase

View File

@ -724,6 +724,18 @@ bool GLGizmosManager::is_show_only_active_plate()
return false;
}
bool GLGizmosManager::is_ban_move_glvolume()
{
auto current_type = get_current_type();
if (current_type == GLGizmosManager::EType::Undefined ||
current_type == GLGizmosManager::EType::Move ||
current_type == GLGizmosManager::EType::Rotate ||
current_type == GLGizmosManager::EType::Scale) {
return false;
}
return true;
}
bool GLGizmosManager::get_gizmo_active_condition(GLGizmosManager::EType type) {
if (auto cur_gizmo = get_gizmo(type)) {
return cur_gizmo->is_activable();

View File

@ -294,6 +294,7 @@ public:
bool is_gizmo_activable_when_single_full_instance();
bool is_gizmo_click_empty_not_exit();
bool is_show_only_active_plate();
bool is_ban_move_glvolume();
bool get_gizmo_active_condition(GLGizmosManager::EType type);
void check_object_located_outside_plate(bool change_plate =true);
bool get_object_located_outside_plate() { return m_object_located_outside_plate; }