mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-15 02:15:55 +08:00
Add svg edit to context menu(right button mouse click).
This commit is contained in:
parent
66c2011d65
commit
497f67764a
@ -1021,15 +1021,18 @@ 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 = []() {
|
||||||
if (plater() != nullptr) {
|
if (plater() == nullptr)
|
||||||
const Selection& sel = plater()->get_selection();
|
|
||||||
if (sel.volumes_count() == 1) {
|
|
||||||
const GLVolume* gl_vol = sel.get_first_volume();
|
|
||||||
const ModelVolume* vol = plater()->model().objects[gl_vol->object_idx()]->volumes[gl_vol->volume_idx()];
|
|
||||||
return vol->text_configuration.has_value();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
|
const Selection& selection = plater()->get_selection();
|
||||||
|
if (selection.volumes_count() != 1)
|
||||||
|
return false;
|
||||||
|
const GLVolume* gl_volume = selection.get_first_volume();
|
||||||
|
if (gl_volume == nullptr)
|
||||||
|
return false;
|
||||||
|
const ModelVolume *volume = get_model_volume(*gl_volume, selection.get_model()->objects);
|
||||||
|
if (volume == nullptr)
|
||||||
|
return false;
|
||||||
|
return volume->is_text();
|
||||||
};
|
};
|
||||||
|
|
||||||
if (menu != &m_text_part_menu) {
|
if (menu != &m_text_part_menu) {
|
||||||
@ -1041,7 +1044,7 @@ void MenuFactory::append_menu_item_edit_text(wxMenu *menu)
|
|||||||
}
|
}
|
||||||
|
|
||||||
wxString description = _L("Ability to change text, font, size, ...");
|
wxString description = _L("Ability to change text, font, size, ...");
|
||||||
std::string icon = "";
|
std::string icon = "cog";
|
||||||
auto open_emboss = [](const wxCommandEvent &) {
|
auto open_emboss = [](const wxCommandEvent &) {
|
||||||
GLGizmosManager &mng = plater()->canvas3D()->get_gizmos_manager();
|
GLGizmosManager &mng = plater()->canvas3D()->get_gizmos_manager();
|
||||||
if (mng.get_current_type() == GLGizmosManager::Emboss)
|
if (mng.get_current_type() == GLGizmosManager::Emboss)
|
||||||
@ -1051,6 +1054,43 @@ void MenuFactory::append_menu_item_edit_text(wxMenu *menu)
|
|||||||
append_menu_item(menu, wxID_ANY, name, description, open_emboss, icon, nullptr, can_edit_text, m_parent);
|
append_menu_item(menu, wxID_ANY, name, description, open_emboss, icon, nullptr, can_edit_text, m_parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MenuFactory::append_menu_item_edit_svg(wxMenu *menu)
|
||||||
|
{
|
||||||
|
wxString name = _L("Edit svg");
|
||||||
|
auto can_edit_svg = []() {
|
||||||
|
if (plater() == nullptr)
|
||||||
|
return false;
|
||||||
|
const Selection& selection = plater()->get_selection();
|
||||||
|
if (selection.volumes_count() != 1)
|
||||||
|
return false;
|
||||||
|
const GLVolume* gl_volume = selection.get_first_volume();
|
||||||
|
if (gl_volume == nullptr)
|
||||||
|
return false;
|
||||||
|
const ModelVolume *volume = get_model_volume(*gl_volume, selection.get_model()->objects);
|
||||||
|
if (volume == nullptr)
|
||||||
|
return false;
|
||||||
|
return volume->is_svg();
|
||||||
|
};
|
||||||
|
|
||||||
|
if (menu != &m_svg_part_menu) {
|
||||||
|
const int menu_item_id = menu->FindItem(name);
|
||||||
|
if (menu_item_id != wxNOT_FOUND)
|
||||||
|
menu->Destroy(menu_item_id);
|
||||||
|
if (!can_edit_svg())
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString description = _L("Ability to change SVG source file, projection, size, ...");
|
||||||
|
std::string icon = "cog";
|
||||||
|
auto open_svg = [](const wxCommandEvent &) {
|
||||||
|
GLGizmosManager &mng = plater()->canvas3D()->get_gizmos_manager();
|
||||||
|
if (mng.get_current_type() == GLGizmosManager::Svg)
|
||||||
|
mng.open_gizmo(GLGizmosManager::Svg); // close() and reopen - move to be visible
|
||||||
|
mng.open_gizmo(GLGizmosManager::Svg);
|
||||||
|
};
|
||||||
|
append_menu_item(menu, wxID_ANY, name, description, open_svg, icon, nullptr, can_edit_svg, m_parent);
|
||||||
|
}
|
||||||
|
|
||||||
MenuFactory::MenuFactory()
|
MenuFactory::MenuFactory()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < mtCount; i++) {
|
for (int i = 0; i < mtCount; i++) {
|
||||||
@ -1150,8 +1190,20 @@ void MenuFactory::create_text_part_menu()
|
|||||||
{
|
{
|
||||||
wxMenu* menu = &m_text_part_menu;
|
wxMenu* menu = &m_text_part_menu;
|
||||||
|
|
||||||
append_menu_item_delete(menu);
|
|
||||||
append_menu_item_edit_text(menu);
|
append_menu_item_edit_text(menu);
|
||||||
|
append_menu_item_delete(menu);
|
||||||
|
append_menu_item_fix_through_netfabb(menu);
|
||||||
|
append_menu_item_simplify(menu);
|
||||||
|
|
||||||
|
append_immutable_part_menu_items(menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MenuFactory::create_svg_part_menu()
|
||||||
|
{
|
||||||
|
wxMenu* menu = &m_svg_part_menu;
|
||||||
|
|
||||||
|
append_menu_item_edit_svg(menu);
|
||||||
|
append_menu_item_delete(menu);
|
||||||
append_menu_item_fix_through_netfabb(menu);
|
append_menu_item_fix_through_netfabb(menu);
|
||||||
append_menu_item_simplify(menu);
|
append_menu_item_simplify(menu);
|
||||||
|
|
||||||
@ -1175,6 +1227,7 @@ void MenuFactory::init(wxWindow* parent)
|
|||||||
create_common_object_menu(&m_sla_object_menu);
|
create_common_object_menu(&m_sla_object_menu);
|
||||||
create_part_menu();
|
create_part_menu();
|
||||||
create_text_part_menu();
|
create_text_part_menu();
|
||||||
|
create_svg_part_menu();
|
||||||
create_instance_menu();
|
create_instance_menu();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1197,6 +1250,7 @@ wxMenu* MenuFactory::object_menu()
|
|||||||
update_menu_items_instance_manipulation(mtObjectFFF);
|
update_menu_items_instance_manipulation(mtObjectFFF);
|
||||||
append_menu_item_invalidate_cut_info(&m_object_menu);
|
append_menu_item_invalidate_cut_info(&m_object_menu);
|
||||||
append_menu_item_edit_text(&m_object_menu);
|
append_menu_item_edit_text(&m_object_menu);
|
||||||
|
append_menu_item_edit_svg(&m_object_menu);
|
||||||
|
|
||||||
return &m_object_menu;
|
return &m_object_menu;
|
||||||
}
|
}
|
||||||
@ -1208,6 +1262,7 @@ wxMenu* MenuFactory::sla_object_menu()
|
|||||||
update_menu_items_instance_manipulation(mtObjectSLA);
|
update_menu_items_instance_manipulation(mtObjectSLA);
|
||||||
append_menu_item_invalidate_cut_info(&m_sla_object_menu);
|
append_menu_item_invalidate_cut_info(&m_sla_object_menu);
|
||||||
append_menu_item_edit_text(&m_sla_object_menu);
|
append_menu_item_edit_text(&m_sla_object_menu);
|
||||||
|
append_menu_item_edit_svg(&m_object_menu);
|
||||||
|
|
||||||
return &m_sla_object_menu;
|
return &m_sla_object_menu;
|
||||||
}
|
}
|
||||||
@ -1228,6 +1283,12 @@ wxMenu* MenuFactory::text_part_menu()
|
|||||||
return &m_text_part_menu;
|
return &m_text_part_menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxMenu *MenuFactory::svg_part_menu()
|
||||||
|
{
|
||||||
|
append_mutable_part_menu_items(&m_svg_part_menu);
|
||||||
|
return &m_svg_part_menu;
|
||||||
|
}
|
||||||
|
|
||||||
wxMenu* MenuFactory::instance_menu()
|
wxMenu* MenuFactory::instance_menu()
|
||||||
{
|
{
|
||||||
return &m_instance_menu;
|
return &m_instance_menu;
|
||||||
|
@ -57,6 +57,7 @@ public:
|
|||||||
wxMenu* sla_object_menu();
|
wxMenu* sla_object_menu();
|
||||||
wxMenu* part_menu();
|
wxMenu* part_menu();
|
||||||
wxMenu* text_part_menu();
|
wxMenu* text_part_menu();
|
||||||
|
wxMenu* svg_part_menu();
|
||||||
wxMenu* instance_menu();
|
wxMenu* instance_menu();
|
||||||
wxMenu* layer_menu();
|
wxMenu* layer_menu();
|
||||||
wxMenu* multi_selection_menu();
|
wxMenu* multi_selection_menu();
|
||||||
@ -73,6 +74,7 @@ private:
|
|||||||
MenuWithSeparators m_object_menu;
|
MenuWithSeparators m_object_menu;
|
||||||
MenuWithSeparators m_part_menu;
|
MenuWithSeparators m_part_menu;
|
||||||
MenuWithSeparators m_text_part_menu;
|
MenuWithSeparators m_text_part_menu;
|
||||||
|
MenuWithSeparators m_svg_part_menu;
|
||||||
MenuWithSeparators m_sla_object_menu;
|
MenuWithSeparators m_sla_object_menu;
|
||||||
MenuWithSeparators m_default_menu;
|
MenuWithSeparators m_default_menu;
|
||||||
MenuWithSeparators m_instance_menu;
|
MenuWithSeparators m_instance_menu;
|
||||||
@ -88,6 +90,7 @@ private:
|
|||||||
void append_mutable_part_menu_items(wxMenu* menu);
|
void append_mutable_part_menu_items(wxMenu* menu);
|
||||||
void create_part_menu();
|
void create_part_menu();
|
||||||
void create_text_part_menu();
|
void create_text_part_menu();
|
||||||
|
void create_svg_part_menu();
|
||||||
void create_instance_menu();
|
void create_instance_menu();
|
||||||
|
|
||||||
wxMenu* append_submenu_add_generic(wxMenu* menu, ModelVolumeType type);
|
wxMenu* append_submenu_add_generic(wxMenu* menu, ModelVolumeType type);
|
||||||
@ -114,6 +117,7 @@ private:
|
|||||||
// void append_menu_item_merge_to_single_object(wxMenu *menu);
|
// void append_menu_item_merge_to_single_object(wxMenu *menu);
|
||||||
void append_menu_items_mirror(wxMenu *menu);
|
void append_menu_items_mirror(wxMenu *menu);
|
||||||
void append_menu_item_edit_text(wxMenu *menu);
|
void append_menu_item_edit_text(wxMenu *menu);
|
||||||
|
void append_menu_item_edit_svg(wxMenu *menu);
|
||||||
void append_menu_items_instance_manipulation(wxMenu *menu);
|
void append_menu_items_instance_manipulation(wxMenu *menu);
|
||||||
void update_menu_items_instance_manipulation(MenuType type);
|
void update_menu_items_instance_manipulation(MenuType type);
|
||||||
void append_menu_items_split(wxMenu *menu);
|
void append_menu_items_split(wxMenu *menu);
|
||||||
|
@ -1040,7 +1040,11 @@ void ObjectList::show_context_menu(const bool evt_context_menu)
|
|||||||
get_selected_item_indexes(obj_idx, vol_idx, item);
|
get_selected_item_indexes(obj_idx, vol_idx, item);
|
||||||
if (obj_idx < 0 || vol_idx < 0)
|
if (obj_idx < 0 || vol_idx < 0)
|
||||||
return;
|
return;
|
||||||
menu = object(obj_idx)->volumes[vol_idx]->text_configuration.has_value() ? plater->text_part_menu() : plater->part_menu();
|
const ModelVolume *volume = object(obj_idx)->volumes[vol_idx];
|
||||||
|
|
||||||
|
menu = volume->is_text() ? plater->text_part_menu() :
|
||||||
|
volume->is_svg() ? plater->svg_part_menu() :
|
||||||
|
plater->part_menu();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
menu = type & itInstance ? plater->instance_menu() :
|
menu = type & itInstance ? plater->instance_menu() :
|
||||||
|
@ -4495,9 +4495,13 @@ void Plater::priv::on_right_click(RBtnEvent& evt)
|
|||||||
const bool is_part = selection.is_single_volume_or_modifier() && ! selection.is_any_connector();
|
const bool is_part = selection.is_single_volume_or_modifier() && ! selection.is_any_connector();
|
||||||
if (is_some_full_instances)
|
if (is_some_full_instances)
|
||||||
menu = printer_technology == ptSLA ? menus.sla_object_menu() : menus.object_menu();
|
menu = printer_technology == ptSLA ? menus.sla_object_menu() : menus.object_menu();
|
||||||
else if (is_part)
|
else if (is_part) {
|
||||||
menu = selection.is_single_text() ? menus.text_part_menu() : menus.part_menu();
|
const GLVolume* gl_volume = selection.get_first_volume();
|
||||||
else
|
const ModelVolume *model_volume = get_model_volume(*gl_volume, selection.get_model()->objects);
|
||||||
|
menu = (model_volume != nullptr && model_volume->is_text()) ? menus.text_part_menu() :
|
||||||
|
(model_volume != nullptr && model_volume->is_svg()) ? menus.svg_part_menu() :
|
||||||
|
menus.part_menu();
|
||||||
|
} else
|
||||||
menu = menus.multi_selection_menu();
|
menu = menus.multi_selection_menu();
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
@ -8069,6 +8073,7 @@ void Plater::bring_instance_forward()
|
|||||||
wxMenu* Plater::object_menu() { return p->menus.object_menu(); }
|
wxMenu* Plater::object_menu() { return p->menus.object_menu(); }
|
||||||
wxMenu* Plater::part_menu() { return p->menus.part_menu(); }
|
wxMenu* Plater::part_menu() { return p->menus.part_menu(); }
|
||||||
wxMenu* Plater::text_part_menu() { return p->menus.text_part_menu(); }
|
wxMenu* Plater::text_part_menu() { return p->menus.text_part_menu(); }
|
||||||
|
wxMenu* Plater::svg_part_menu() { return p->menus.svg_part_menu(); }
|
||||||
wxMenu* Plater::sla_object_menu() { return p->menus.sla_object_menu(); }
|
wxMenu* Plater::sla_object_menu() { return p->menus.sla_object_menu(); }
|
||||||
wxMenu* Plater::default_menu() { return p->menus.default_menu(); }
|
wxMenu* Plater::default_menu() { return p->menus.default_menu(); }
|
||||||
wxMenu* Plater::instance_menu() { return p->menus.instance_menu(); }
|
wxMenu* Plater::instance_menu() { return p->menus.instance_menu(); }
|
||||||
|
@ -493,6 +493,7 @@ public:
|
|||||||
wxMenu* object_menu();
|
wxMenu* object_menu();
|
||||||
wxMenu* part_menu();
|
wxMenu* part_menu();
|
||||||
wxMenu* text_part_menu();
|
wxMenu* text_part_menu();
|
||||||
|
wxMenu* svg_part_menu();
|
||||||
wxMenu* sla_object_menu();
|
wxMenu* sla_object_menu();
|
||||||
wxMenu* default_menu();
|
wxMenu* default_menu();
|
||||||
wxMenu* instance_menu();
|
wxMenu* instance_menu();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user