Merge branch 'lm_del_info_item'

This commit is contained in:
Lukas Matena 2021-08-17 10:05:15 +02:00
commit 2173e8ab5a
3 changed files with 50 additions and 5 deletions

View File

@ -1778,10 +1778,8 @@ void ObjectList::del_subobject_item(wxDataViewItem& item)
del_layers_from_object(obj_idx); del_layers_from_object(obj_idx);
else if (type & itLayer && obj_idx != -1) else if (type & itLayer && obj_idx != -1)
del_layer_from_object(obj_idx, m_objects_model->GetLayerRangeByItem(item)); del_layer_from_object(obj_idx, m_objects_model->GetLayerRangeByItem(item));
else if (type & itInfo && obj_idx != -1) { else if (type & itInfo && obj_idx != -1)
Unselect(item); del_info_item(obj_idx, m_objects_model->GetInfoItemType(item));
Select(parent);
}
else if (idx == -1) else if (idx == -1)
return; return;
else if (!del_subobject_from_object(obj_idx, idx, type)) else if (!del_subobject_from_object(obj_idx, idx, type))
@ -1795,6 +1793,52 @@ void ObjectList::del_subobject_item(wxDataViewItem& item)
update_info_items(obj_idx); update_info_items(obj_idx);
} }
void ObjectList::del_info_item(const int obj_idx, InfoItemType type)
{
Plater* plater = wxGetApp().plater();
GLCanvas3D* cnv = plater->canvas3D();
switch (type) {
case InfoItemType::CustomSupports:
cnv->get_gizmos_manager().reset_all_states();
Plater::TakeSnapshot(plater, _L("Remove paint-on supports"));
for (ModelVolume* mv : (*m_objects)[obj_idx]->volumes)
mv->supported_facets.clear();
break;
case InfoItemType::CustomSeam:
cnv->get_gizmos_manager().reset_all_states();
Plater::TakeSnapshot(plater, _L("Remove paint-on seam"));
for (ModelVolume* mv : (*m_objects)[obj_idx]->volumes)
mv->seam_facets.clear();
break;
case InfoItemType::MmuSegmentation:
cnv->get_gizmos_manager().reset_all_states();
Plater::TakeSnapshot(plater, _L("Remove Multi Material painting"));
for (ModelVolume* mv : (*m_objects)[obj_idx]->volumes)
mv->mmu_segmentation_facets.clear();
break;
case InfoItemType::Sinking:
Plater::TakeSnapshot(plater, _L("Shift objects to bed"));
(*m_objects)[obj_idx]->ensure_on_bed();
cnv->reload_scene(true, true);
break;
case InfoItemType::VariableLayerHeight:
Plater::TakeSnapshot(plater, _L("Remove variable layer height"));
(*m_objects)[obj_idx]->layer_height_profile.clear();
if (cnv->is_layers_editing_enabled())
//cnv->post_event(SimpleEvent(EVT_GLTOOLBAR_LAYERSEDITING));
cnv->force_main_toolbar_left_action(cnv->get_main_toolbar_item_id("layersediting"));
break;
case InfoItemType::Undef : assert(false); break;
}
cnv->post_event(SimpleEvent(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS));
}
void ObjectList::del_settings_from_config(const wxDataViewItem& parent_item) void ObjectList::del_settings_from_config(const wxDataViewItem& parent_item)
{ {
const bool is_layer_settings = m_objects_model->GetItemType(parent_item) == itLayer; const bool is_layer_settings = m_objects_model->GetItemType(parent_item) == itLayer;

View File

@ -254,6 +254,7 @@ public:
void del_layer_from_object(const int obj_idx, const t_layer_height_range& layer_range); void del_layer_from_object(const int obj_idx, const t_layer_height_range& layer_range);
void del_layers_from_object(const int obj_idx); void del_layers_from_object(const int obj_idx);
bool del_subobject_from_object(const int obj_idx, const int idx, const int type); bool del_subobject_from_object(const int obj_idx, const int idx, const int type);
void del_info_item(const int obj_idx, InfoItemType type);
void split(); void split();
void merge(bool to_multipart_object); void merge(bool to_multipart_object);
void layers_editing(); void layers_editing();

View File

@ -1141,7 +1141,7 @@ void ObjectDataViewModel::GetItemInfo(const wxDataViewItem& item, ItemType& type
if (!node || if (!node ||
node->GetIdx() <-1 || node->GetIdx() <-1 ||
( node->GetIdx() == -1 && ( node->GetIdx() == -1 &&
!(node->GetType() & (itObject | itSettings | itInstanceRoot | itLayerRoot/* | itLayer*/)) !(node->GetType() & (itObject | itSettings | itInstanceRoot | itLayerRoot | itInfo))
) )
) )
return; return;