MenuFactory: SLA specific: Fixed adding of the "Edit text" menu item

This commit is contained in:
YuSanka 2022-12-08 11:20:05 +01:00 committed by tamasmeszaros
parent 7b207aaf5c
commit 0dadde6ae3

View File

@ -1018,16 +1018,19 @@ void MenuFactory::append_menu_item_edit_text(wxMenu *menu)
wxString name = _L("Edit text"); wxString name = _L("Edit text");
auto can_edit_text = []() { auto can_edit_text = []() {
const auto& sel = plater()->get_selection(); if (plater() != nullptr) {
if (sel.volumes_count() != 1) return false; const Selection& sel = plater()->get_selection();
auto cid = sel.get_volume(*sel.get_volume_idxs().begin()); if (sel.volumes_count() == 1) {
const ModelVolume* vol = plater()->canvas3D()->get_model() const GLVolume* gl_vol = sel.get_first_volume();
->objects[cid->object_idx()]->volumes[cid->volume_idx()]; const ModelVolume* vol = plater()->model().objects[gl_vol->object_idx()]->volumes[gl_vol->volume_idx()];
return vol->text_configuration.has_value(); return vol->text_configuration.has_value();
}
}
return false;
}; };
if (menu == &m_object_menu) { if (menu != &m_text_part_menu) {
auto menu_item_id = menu->FindItem(name); const int menu_item_id = menu->FindItem(name);
if (menu_item_id != wxNOT_FOUND) if (menu_item_id != wxNOT_FOUND)
menu->Destroy(menu_item_id); menu->Destroy(menu_item_id);
if (!can_edit_text()) if (!can_edit_text())