Add instances (#6237)

* Add instances

* - Added a new menu item for converting instances to objects,

---------

Co-authored-by: SoftFever <softfeverever@gmail.com>
This commit is contained in:
Vovodroid
2025-10-26 10:13:14 +02:00
committed by GitHub
parent ca064dee1d
commit e922411371
12 changed files with 382 additions and 40 deletions

View File

@@ -3550,20 +3550,20 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
break;
}
//case '+': {
// if (dynamic_cast<Preview*>(m_canvas->GetParent()) != nullptr)
// post_event(wxKeyEvent(EVT_GLCANVAS_EDIT_COLOR_CHANGE, evt));
// else
// post_event(Event<int>(EVT_GLCANVAS_INCREASE_INSTANCES, +1));
// break;
//}
//case '-': {
// if (dynamic_cast<Preview*>(m_canvas->GetParent()) != nullptr)
// post_event(wxKeyEvent(EVT_GLCANVAS_EDIT_COLOR_CHANGE, evt));
// else
// post_event(Event<int>(EVT_GLCANVAS_INCREASE_INSTANCES, -1));
// break;
//}
case '+': {
if (dynamic_cast<Preview*>(m_canvas->GetParent()) != nullptr)
post_event(wxKeyEvent(EVT_GLCANVAS_EDIT_COLOR_CHANGE, evt));
else
post_event(Event<int>(EVT_GLCANVAS_INCREASE_INSTANCES, +1));
break;
}
case '-': {
if (dynamic_cast<Preview*>(m_canvas->GetParent()) != nullptr)
post_event(wxKeyEvent(EVT_GLCANVAS_EDIT_COLOR_CHANGE, evt));
else
post_event(Event<int>(EVT_GLCANVAS_INCREASE_INSTANCES, -1));
break;
}
case '?': { post_event(SimpleEvent(EVT_GLCANVAS_QUESTION_MARK)); break; }
case 'A':
case 'a':
@@ -6656,6 +6656,12 @@ void GLCanvas3D::_switch_toolbars_icon_filename()
item = m_main_toolbar.get_item("arrange");
item->set_icon_filename(m_is_dark ? "toolbar_arrange_dark.svg" : "toolbar_arrange.svg");
item = m_main_toolbar.get_item("more");
item->set_icon_filename(m_is_dark ? "instance_add_dark.svg" : "instance_add.svg");
item = m_main_toolbar.get_item("fewer");
item->set_icon_filename(m_is_dark ? "instance_remove_dark.svg" : "instance_remove.svg");
item = m_main_toolbar.get_item("splitobjects");
item->set_icon_filename(m_is_dark ? "split_objects_dark.svg" : "split_objects.svg");
@@ -6805,6 +6811,30 @@ bool GLCanvas3D::_init_main_toolbar()
if (!m_main_toolbar.add_separator())
return false;
item.name = "more";
item.icon_filename = m_is_dark ? "instance_add_dark.svg" : "instance_add.svg";
item.tooltip = _utf8(L("Add instance")) + " [+]";
item.sprite_id++;
item.left.render_callback = nullptr;
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_MORE)); };
item.visibility_callback = GLToolbarItem::Default_Visibility_Callback;
item.left.toggable = false;
item.enabling_callback = []()->bool { return wxGetApp().plater()->can_increase_instances(); };
if (!m_main_toolbar.add_item(item))
return false;
item.name = "fewer";
item.icon_filename = m_is_dark ? "instance_remove_dark.svg" : "instance_remove.svg";
item.tooltip = _utf8(L("Remove instance")) + " [-]";
item.sprite_id++;
item.left.render_callback = nullptr;
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_FEWER)); };
item.visibility_callback = GLToolbarItem::Default_Visibility_Callback;
item.left.toggable = false;
item.enabling_callback = []()->bool { return wxGetApp().plater()->can_decrease_instances(); };
if (!m_main_toolbar.add_item(item))
return false;
item.name = "splitobjects";
item.icon_filename = m_is_dark ? "split_objects_dark.svg" : "split_objects.svg";
item.tooltip = _utf8(L("Split to objects"));