diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index f7789d681b..b334bdf67e 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -4875,6 +4875,14 @@ void GLCanvas3D::do_center() m_selection.center(); } +void GLCanvas3D::do_drop() +{ + if (m_model == nullptr) + return; + + m_selection.drop(); +} + void GLCanvas3D::do_center_plate(const int plate_idx) { if (m_model == nullptr) return; diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index ad4d21cf3a..023e95a976 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -978,6 +978,7 @@ public: void do_rotate(const std::string& snapshot_type); void do_scale(const std::string& snapshot_type); void do_center(); + void do_drop(); void do_center_plate(const int plate_idx); void do_mirror(const std::string& snapshot_type); diff --git a/src/slic3r/GUI/GUI_Factories.cpp b/src/slic3r/GUI/GUI_Factories.cpp index 334705618e..4ac0af51e4 100644 --- a/src/slic3r/GUI/GUI_Factories.cpp +++ b/src/slic3r/GUI/GUI_Factories.cpp @@ -1314,6 +1314,8 @@ void MenuFactory::create_extra_object_menu() append_menu_item_merge_parts_to_single_part(&m_object_menu); // Object Center append_menu_item_center(&m_object_menu); + // Object Drop + append_menu_item_drop(&m_object_menu); // Object Split wxMenu* split_menu = new wxMenu(); if (!split_menu) @@ -1436,6 +1438,7 @@ void MenuFactory::create_bbl_part_menu() append_menu_item_fix_through_netfabb(menu); append_menu_item_simplify(menu); append_menu_item_center(menu); + append_menu_item_drop(menu); append_menu_items_mirror(menu); wxMenu* split_menu = new wxMenu(); if (!split_menu) @@ -1675,6 +1678,7 @@ wxMenu* MenuFactory::multi_selection_menu() index++; } append_menu_item_center(menu); + append_menu_item_drop(menu); append_menu_item_fix_through_netfabb(menu); //append_menu_item_simplify(menu); append_menu_item_delete(menu); @@ -1691,6 +1695,7 @@ wxMenu* MenuFactory::multi_selection_menu() } else { append_menu_item_center(menu); + append_menu_item_drop(menu); append_menu_item_fix_through_netfabb(menu); //append_menu_item_simplify(menu); append_menu_item_delete(menu); @@ -1819,6 +1824,21 @@ void MenuFactory::append_menu_item_center(wxMenu* menu) }, m_parent); } +void MenuFactory::append_menu_item_drop(wxMenu* menu) +{ + append_menu_item(menu, wxID_ANY, _L("Drop") , "", + [this](wxCommandEvent&) { + plater()->drop_selection(); + }, "", nullptr, + []() { + if (plater()->canvas3D()->get_canvas_type() != GLCanvas3D::ECanvasType::CanvasView3D) + return false; + else { + return (plater()->get_view3D_canvas3D()->get_selection().get_bounding_box().min.z() != 0); + } //disable if model is on the bed / not in View3D + }, m_parent); +} + void MenuFactory::append_menu_item_per_object_process(wxMenu* menu) { const std::vector names = { _L("Edit Process Settings"), _L("Edit Process Settings") }; diff --git a/src/slic3r/GUI/GUI_Factories.hpp b/src/slic3r/GUI/GUI_Factories.hpp index f0e503c450..7c73e0facf 100644 --- a/src/slic3r/GUI/GUI_Factories.hpp +++ b/src/slic3r/GUI/GUI_Factories.hpp @@ -157,6 +157,7 @@ private: void append_menu_item_clone(wxMenu* menu); void append_menu_item_simplify(wxMenu* menu); void append_menu_item_center(wxMenu* menu); + void append_menu_item_drop(wxMenu* menu); void append_menu_item_per_object_process(wxMenu* menu); void append_menu_item_per_object_settings(wxMenu* menu); void append_menu_item_change_filament(wxMenu* menu); diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index 13e67556e6..f87f277ac8 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -157,6 +157,12 @@ void View3D::center_selected() m_canvas->do_center(); } +void View3D::drop_selected() +{ + if (m_canvas != nullptr) + m_canvas->do_drop(); +} + void View3D::center_selected_plate(const int plate_idx) { if (m_canvas != nullptr) m_canvas->do_center_plate(plate_idx); diff --git a/src/slic3r/GUI/GUI_Preview.hpp b/src/slic3r/GUI/GUI_Preview.hpp index 7d6a332bc0..0478cc9818 100644 --- a/src/slic3r/GUI/GUI_Preview.hpp +++ b/src/slic3r/GUI/GUI_Preview.hpp @@ -66,6 +66,7 @@ public: void exit_gizmo(); void delete_selected(); void center_selected(); + void drop_selected(); void center_selected_plate(const int plate_idx); void mirror_selection(Axis axis); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 7de59dee2a..450bf768f2 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2436,6 +2436,7 @@ struct Plater::priv void delete_all_objects_from_model(); void reset(bool apply_presets_change = false); void center_selection(); + void drop_selection(); void mirror(Axis axis); void split_object(); void split_volume(); @@ -5022,6 +5023,11 @@ void Plater::priv::center_selection() view3D->center_selected(); } +void Plater::priv::drop_selection() +{ + view3D->drop_selected(); +} + void Plater::priv::mirror(Axis axis) { view3D->mirror_selection(axis); @@ -13239,6 +13245,7 @@ void Plater::suppress_background_process(const bool stop_background_process) } void Plater::center_selection() { p->center_selection(); } +void Plater::drop_selection() { p->drop_selection(); } void Plater::mirror(Axis axis) { p->mirror(axis); } void Plater::split_object() { p->split_object(); } void Plater::split_volume() { p->split_volume(); } diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 52f0706e89..5e5c88e7e6 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -529,6 +529,7 @@ public: //BBS: add clone logic void clone_selection(); void center_selection(); + void drop_selection(); void search(bool plater_is_active, Preset::Type type, wxWindow *tag, TextInput *etag, wxWindow *stag); void mirror(Axis axis); void split_object(); diff --git a/src/slic3r/GUI/Selection.cpp b/src/slic3r/GUI/Selection.cpp index baf0773ce7..9d42a624c6 100644 --- a/src/slic3r/GUI/Selection.cpp +++ b/src/slic3r/GUI/Selection.cpp @@ -490,6 +490,12 @@ void Selection::center() return; } +void Selection::drop() +{ + this->move_to_center(Vec3d(0, 0, -this->get_bounding_box().min.z())); + wxGetApp().plater()->get_view3D_canvas3D()->do_move(L("Move Object")); +} + void Selection::center_plate(const int plate_idx) { PartPlate* plate = wxGetApp().plater()->get_partplate_list().get_plate(plate_idx); diff --git a/src/slic3r/GUI/Selection.hpp b/src/slic3r/GUI/Selection.hpp index 52b1a81851..8fc0f8bc66 100644 --- a/src/slic3r/GUI/Selection.hpp +++ b/src/slic3r/GUI/Selection.hpp @@ -230,6 +230,7 @@ public: void remove_curr_plate(); void clone(int numbers = 1); void center(); + void drop(); void center_plate(const int plate_idx); void set_printable(bool printable);