Added Possibility to create "shape" as an independent object from 3dScene,
using right click on empty place
This commit is contained in:
parent
0b093160f5
commit
8aaff08355
3 changed files with 66 additions and 42 deletions
|
@ -1094,7 +1094,7 @@ void GLCanvas3D::LegendTexture::render(const GLCanvas3D& canvas) const
|
||||||
wxDEFINE_EVENT(EVT_GLCANVAS_INIT, SimpleEvent);
|
wxDEFINE_EVENT(EVT_GLCANVAS_INIT, SimpleEvent);
|
||||||
wxDEFINE_EVENT(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS, SimpleEvent);
|
wxDEFINE_EVENT(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS, SimpleEvent);
|
||||||
wxDEFINE_EVENT(EVT_GLCANVAS_OBJECT_SELECT, SimpleEvent);
|
wxDEFINE_EVENT(EVT_GLCANVAS_OBJECT_SELECT, SimpleEvent);
|
||||||
wxDEFINE_EVENT(EVT_GLCANVAS_RIGHT_CLICK, Vec2dEvent);
|
wxDEFINE_EVENT(EVT_GLCANVAS_RIGHT_CLICK, RBtnEvent);
|
||||||
wxDEFINE_EVENT(EVT_GLCANVAS_REMOVE_OBJECT, SimpleEvent);
|
wxDEFINE_EVENT(EVT_GLCANVAS_REMOVE_OBJECT, SimpleEvent);
|
||||||
wxDEFINE_EVENT(EVT_GLCANVAS_ARRANGE, SimpleEvent);
|
wxDEFINE_EVENT(EVT_GLCANVAS_ARRANGE, SimpleEvent);
|
||||||
wxDEFINE_EVENT(EVT_GLCANVAS_SELECT_ALL, SimpleEvent);
|
wxDEFINE_EVENT(EVT_GLCANVAS_SELECT_ALL, SimpleEvent);
|
||||||
|
@ -3012,15 +3012,23 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||||
wxGetApp().obj_manipul()->set_dirty();
|
wxGetApp().obj_manipul()->set_dirty();
|
||||||
// forces a frame render to update the view before the context menu is shown
|
// forces a frame render to update the view before the context menu is shown
|
||||||
render();
|
render();
|
||||||
|
/* #et_FIXME
|
||||||
Vec2d logical_pos = pos.cast<double>();
|
Vec2d logical_pos = pos.cast<double>();
|
||||||
#if ENABLE_RETINA_GL
|
#if ENABLE_RETINA_GL
|
||||||
const float factor = m_retina_helper->get_scale_factor();
|
const float factor = m_retina_helper->get_scale_factor();
|
||||||
logical_pos = logical_pos.cwiseQuotient(Vec2d(factor, factor));
|
logical_pos = logical_pos.cwiseQuotient(Vec2d(factor, factor));
|
||||||
#endif // ENABLE_RETINA_GL
|
#endif // ENABLE_RETINA_GL
|
||||||
post_event(Vec2dEvent(EVT_GLCANVAS_RIGHT_CLICK, logical_pos));
|
post_event(Vec2dEvent(EVT_GLCANVAS_RIGHT_CLICK, logical_pos));
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// #et_FIXME
|
||||||
|
Vec2d logical_pos = pos.cast<double>();
|
||||||
|
#if ENABLE_RETINA_GL
|
||||||
|
const float factor = m_retina_helper->get_scale_factor();
|
||||||
|
logical_pos = logical_pos.cwiseQuotient(Vec2d(factor, factor));
|
||||||
|
#endif // ENABLE_RETINA_GL
|
||||||
|
post_event(RBtnEvent(EVT_GLCANVAS_RIGHT_CLICK, {logical_pos, m_hover_volume_idxs.empty()}));
|
||||||
}
|
}
|
||||||
|
|
||||||
mouse_up_cleanup();
|
mouse_up_cleanup();
|
||||||
|
|
|
@ -71,6 +71,9 @@ public:
|
||||||
wxDECLARE_EVENT(EVT_GLCANVAS_OBJECT_SELECT, SimpleEvent);
|
wxDECLARE_EVENT(EVT_GLCANVAS_OBJECT_SELECT, SimpleEvent);
|
||||||
|
|
||||||
using Vec2dEvent = Event<Vec2d>;
|
using Vec2dEvent = Event<Vec2d>;
|
||||||
|
// #et_FIXME : RBtnEvent is used instead of Vec2dEvent on EVT_GLCANVAS_RIGHT_CLICK
|
||||||
|
// _bool_ value is used as a indicator of selection in the 3DScene
|
||||||
|
using RBtnEvent = Event<std::pair<Vec2d, bool>>;
|
||||||
template <size_t N> using Vec2dsEvent = ArrayEvent<Vec2d, N>;
|
template <size_t N> using Vec2dsEvent = ArrayEvent<Vec2d, N>;
|
||||||
|
|
||||||
using Vec3dEvent = Event<Vec3d>;
|
using Vec3dEvent = Event<Vec3d>;
|
||||||
|
@ -78,7 +81,7 @@ template <size_t N> using Vec3dsEvent = ArrayEvent<Vec3d, N>;
|
||||||
|
|
||||||
wxDECLARE_EVENT(EVT_GLCANVAS_INIT, SimpleEvent);
|
wxDECLARE_EVENT(EVT_GLCANVAS_INIT, SimpleEvent);
|
||||||
wxDECLARE_EVENT(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS, SimpleEvent);
|
wxDECLARE_EVENT(EVT_GLCANVAS_SCHEDULE_BACKGROUND_PROCESS, SimpleEvent);
|
||||||
wxDECLARE_EVENT(EVT_GLCANVAS_RIGHT_CLICK, Vec2dEvent);
|
wxDECLARE_EVENT(EVT_GLCANVAS_RIGHT_CLICK, RBtnEvent);
|
||||||
wxDECLARE_EVENT(EVT_GLCANVAS_REMOVE_OBJECT, SimpleEvent);
|
wxDECLARE_EVENT(EVT_GLCANVAS_REMOVE_OBJECT, SimpleEvent);
|
||||||
wxDECLARE_EVENT(EVT_GLCANVAS_ARRANGE, SimpleEvent);
|
wxDECLARE_EVENT(EVT_GLCANVAS_ARRANGE, SimpleEvent);
|
||||||
wxDECLARE_EVENT(EVT_GLCANVAS_SELECT_ALL, SimpleEvent);
|
wxDECLARE_EVENT(EVT_GLCANVAS_SELECT_ALL, SimpleEvent);
|
||||||
|
|
|
@ -1340,6 +1340,8 @@ struct Plater::priv
|
||||||
MenuWithSeparators part_menu;
|
MenuWithSeparators part_menu;
|
||||||
// SLA-Object popup menu
|
// SLA-Object popup menu
|
||||||
MenuWithSeparators sla_object_menu;
|
MenuWithSeparators sla_object_menu;
|
||||||
|
// Default popup menu (when nothing is selected on 3DScene)
|
||||||
|
MenuWithSeparators default_menu;
|
||||||
|
|
||||||
// Removed/Prepended Items according to the view mode
|
// Removed/Prepended Items according to the view mode
|
||||||
std::vector<wxMenuItem*> items_increase;
|
std::vector<wxMenuItem*> items_increase;
|
||||||
|
@ -1879,7 +1881,7 @@ struct Plater::priv
|
||||||
void on_action_layersediting(SimpleEvent&);
|
void on_action_layersediting(SimpleEvent&);
|
||||||
|
|
||||||
void on_object_select(SimpleEvent&);
|
void on_object_select(SimpleEvent&);
|
||||||
void on_right_click(Vec2dEvent&);
|
void on_right_click(RBtnEvent&);
|
||||||
void on_wipetower_moved(Vec3dEvent&);
|
void on_wipetower_moved(Vec3dEvent&);
|
||||||
void on_wipetower_rotated(Vec3dEvent&);
|
void on_wipetower_rotated(Vec3dEvent&);
|
||||||
void on_update_geometry(Vec3dsEvent<2>&);
|
void on_update_geometry(Vec3dsEvent<2>&);
|
||||||
|
@ -3446,13 +3448,21 @@ void Plater::priv::on_object_select(SimpleEvent& evt)
|
||||||
selection_changed();
|
selection_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Plater::priv::on_right_click(Vec2dEvent& evt)
|
void Plater::priv::on_right_click(RBtnEvent& evt)
|
||||||
{
|
{
|
||||||
int obj_idx = get_selected_object_idx();
|
int obj_idx = get_selected_object_idx();
|
||||||
|
|
||||||
|
wxMenu* menu = nullptr;
|
||||||
|
|
||||||
if (obj_idx == -1)
|
if (obj_idx == -1)
|
||||||
|
menu = &default_menu;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// If in 3DScene is(are) selected volume(s), but right button was clicked on empty space
|
||||||
|
if (evt.data.second)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxMenu* menu = printer_technology == ptSLA ? &sla_object_menu :
|
menu = printer_technology == ptSLA ? &sla_object_menu :
|
||||||
get_selection().is_single_full_instance() ? // show "Object menu" for each FullInstance instead of FullObject
|
get_selection().is_single_full_instance() ? // show "Object menu" for each FullInstance instead of FullObject
|
||||||
&object_menu : &part_menu;
|
&object_menu : &part_menu;
|
||||||
|
|
||||||
|
@ -3489,14 +3499,15 @@ void Plater::priv::on_right_click(Vec2dEvent& evt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (q != nullptr) {
|
if (q != nullptr && menu) {
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
// For some reason on Linux the menu isn't displayed if position is specified
|
// For some reason on Linux the menu isn't displayed if position is specified
|
||||||
// (even though the position is sane).
|
// (even though the position is sane).
|
||||||
q->PopupMenu(menu);
|
q->PopupMenu(menu);
|
||||||
#else
|
#else
|
||||||
q->PopupMenu(menu, (int)evt.data.x(), (int)evt.data.y());
|
q->PopupMenu(menu, (int)evt.data.first.x(), (int)evt.data.first.y());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3548,12 +3559,14 @@ bool Plater::priv::init_object_menu()
|
||||||
init_common_menu(&part_menu, true);
|
init_common_menu(&part_menu, true);
|
||||||
complit_init_part_menu();
|
complit_init_part_menu();
|
||||||
|
|
||||||
|
sidebar->obj_list()->create_default_popupmenu(&default_menu);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Plater::priv::msw_rescale_object_menu()
|
void Plater::priv::msw_rescale_object_menu()
|
||||||
{
|
{
|
||||||
for (MenuWithSeparators* menu : { &object_menu, &sla_object_menu, &part_menu })
|
for (MenuWithSeparators* menu : { &object_menu, &sla_object_menu, &part_menu, &default_menu })
|
||||||
msw_rescale_menu(dynamic_cast<wxMenu*>(menu));
|
msw_rescale_menu(dynamic_cast<wxMenu*>(menu));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue