FIX:cut connector can't be valid in gizmoMove and so on

Jira: STUDIO-5670
commit a8440db5ec6cff6319a8bb7b9824a416d1414be4
thanks to PrusaSlicer and YuSanka
Author: YuSanka <yusanka@gmail.com>
Date:   Fri Sep 30 14:07:17 2022 +0200
    Cut WIP:
    * ObjectList & Selection: Show Connectors in the Scene, when CutConnectors Item is selected

Change-Id: I72ef5cf6e85893b12f43ba9e2876c0cd7e711143
This commit is contained in:
YuSanka 2023-12-25 10:01:04 +08:00 committed by Lane.Wei
parent f6f27b700f
commit 9f545fd18d
6 changed files with 46 additions and 9 deletions

View File

@ -544,8 +544,20 @@ void GLGizmoAdvancedCut::on_set_state()
bool GLGizmoAdvancedCut::on_is_activable() const
{
const Selection& selection = m_parent.get_selection();
return selection.is_single_full_instance() && !selection.is_wipe_tower();
const Selection &selection = m_parent.get_selection();
const int object_idx = selection.get_object_idx();
if (object_idx < 0 || selection.is_wipe_tower())
return false;
if (const ModelObject *mo = wxGetApp().plater()->model().objects[object_idx]; mo->is_cut() && mo->volumes.size() == 1) {
const ModelVolume *volume = mo->volumes[0];
if (volume->is_cut_connector() && volume->cut_info.connector_type == CutConnectorType::Dowel)
return false;
}
// This is assumed in GLCanvas3D::do_rotate, do not change this
// without updating that function too.
return selection.is_single_full_instance() && !m_parent.is_layers_editing_enabled();
}
CommonGizmosDataID GLGizmoAdvancedCut::on_get_requirements() const

View File

@ -68,7 +68,8 @@ std::string GLGizmoMove3D::on_get_name() const
bool GLGizmoMove3D::on_is_activable() const
{
return !m_parent.get_selection().is_empty();
const Selection &selection = m_parent.get_selection();
return !selection.is_any_cut_volume() && !selection.is_any_connector() && !selection.is_empty();
}
void GLGizmoMove3D::on_start_dragging()

View File

@ -477,10 +477,10 @@ std::string GLGizmoRotate3D::on_get_name() const
}
bool GLGizmoRotate3D::on_is_activable() const
{
// BBS: don't support rotate wipe tower
const Selection& selection = m_parent.get_selection();
return !m_parent.get_selection().is_empty() && !selection.is_wipe_tower();
{
const Selection &selection = m_parent.get_selection();
return !selection.is_empty() && !selection.is_wipe_tower() // BBS: don't support rotate wipe tower
&&!selection.is_any_cut_volume() && !selection.is_any_connector();
}
void GLGizmoRotate3D::on_start_dragging()

View File

@ -100,8 +100,8 @@ std::string GLGizmoScale3D::on_get_name() const
bool GLGizmoScale3D::on_is_activable() const
{
const Selection& selection = m_parent.get_selection();
return !selection.is_empty() && !selection.is_wipe_tower();
const Selection &selection = m_parent.get_selection();
return !selection.is_empty() && !selection.is_wipe_tower() && !selection.is_any_cut_volume() && !selection.is_any_connector();
}
void GLGizmoScale3D::on_start_dragging()

View File

@ -703,6 +703,28 @@ bool Selection::is_single_full_instance() const
return m_model->objects[object_idx]->volumes.size() == volumes_idxs.size();
}
bool Selection::is_any_connector() const
{
const int obj_idx = get_object_idx();
if ((is_any_volume() || is_any_modifier() || is_mixed()) && // some solid_part AND/OR modifier is selected
obj_idx >= 0 && m_model->objects[obj_idx]->is_cut()) {
const ModelVolumePtrs &obj_volumes = m_model->objects[obj_idx]->volumes;
for (size_t vol_idx = 0; vol_idx < obj_volumes.size(); vol_idx++)
if (obj_volumes[vol_idx]->is_cut_connector())
for (const GLVolume *v : *m_volumes)
if (v->object_idx() == obj_idx && v->volume_idx() == (int) vol_idx && v->selected)
return true;
}
return false;
}
bool Selection::is_any_cut_volume() const
{
const int obj_idx = get_object_idx();
return is_any_volume() && obj_idx >= 0 && m_model->objects[obj_idx]->is_cut();
}
bool Selection::is_from_single_object() const
{
const int idx = get_object_idx();

View File

@ -292,6 +292,8 @@ public:
bool is_single_volume() const { return m_type == SingleVolume; }
bool is_multiple_volume() const { return m_type == MultipleVolume; }
bool is_any_volume() const { return is_single_volume() || is_multiple_volume(); }
bool is_any_connector() const;
bool is_any_cut_volume() const;
bool is_mixed() const { return m_type == Mixed; }
bool is_from_single_instance() const { return get_instance_idx() != -1; }
bool is_from_single_object() const;