Drop object on the plate (#6166)

Co-authored-by: SoftFever <softfeverever@gmail.com>
This commit is contained in:
Vovodroid 2024-08-06 18:18:28 +03:00 committed by GitHub
parent 724762bbc8
commit 98a243c302
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 52 additions and 0 deletions

View file

@ -4875,6 +4875,14 @@ void GLCanvas3D::do_center()
m_selection.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) { void GLCanvas3D::do_center_plate(const int plate_idx) {
if (m_model == nullptr) if (m_model == nullptr)
return; return;

View file

@ -978,6 +978,7 @@ public:
void do_rotate(const std::string& snapshot_type); void do_rotate(const std::string& snapshot_type);
void do_scale(const std::string& snapshot_type); void do_scale(const std::string& snapshot_type);
void do_center(); void do_center();
void do_drop();
void do_center_plate(const int plate_idx); void do_center_plate(const int plate_idx);
void do_mirror(const std::string& snapshot_type); void do_mirror(const std::string& snapshot_type);

View file

@ -1314,6 +1314,8 @@ void MenuFactory::create_extra_object_menu()
append_menu_item_merge_parts_to_single_part(&m_object_menu); append_menu_item_merge_parts_to_single_part(&m_object_menu);
// Object Center // Object Center
append_menu_item_center(&m_object_menu); append_menu_item_center(&m_object_menu);
// Object Drop
append_menu_item_drop(&m_object_menu);
// Object Split // Object Split
wxMenu* split_menu = new wxMenu(); wxMenu* split_menu = new wxMenu();
if (!split_menu) if (!split_menu)
@ -1436,6 +1438,7 @@ void MenuFactory::create_bbl_part_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);
append_menu_item_center(menu); append_menu_item_center(menu);
append_menu_item_drop(menu);
append_menu_items_mirror(menu); append_menu_items_mirror(menu);
wxMenu* split_menu = new wxMenu(); wxMenu* split_menu = new wxMenu();
if (!split_menu) if (!split_menu)
@ -1675,6 +1678,7 @@ wxMenu* MenuFactory::multi_selection_menu()
index++; index++;
} }
append_menu_item_center(menu); append_menu_item_center(menu);
append_menu_item_drop(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);
append_menu_item_delete(menu); append_menu_item_delete(menu);
@ -1691,6 +1695,7 @@ wxMenu* MenuFactory::multi_selection_menu()
} }
else { else {
append_menu_item_center(menu); append_menu_item_center(menu);
append_menu_item_drop(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);
append_menu_item_delete(menu); append_menu_item_delete(menu);
@ -1819,6 +1824,21 @@ void MenuFactory::append_menu_item_center(wxMenu* menu)
}, m_parent); }, 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) void MenuFactory::append_menu_item_per_object_process(wxMenu* menu)
{ {
const std::vector<wxString> names = { _L("Edit Process Settings"), _L("Edit Process Settings") }; const std::vector<wxString> names = { _L("Edit Process Settings"), _L("Edit Process Settings") };

View file

@ -157,6 +157,7 @@ private:
void append_menu_item_clone(wxMenu* menu); void append_menu_item_clone(wxMenu* menu);
void append_menu_item_simplify(wxMenu* menu); void append_menu_item_simplify(wxMenu* menu);
void append_menu_item_center(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_process(wxMenu* menu);
void append_menu_item_per_object_settings(wxMenu* menu); void append_menu_item_per_object_settings(wxMenu* menu);
void append_menu_item_change_filament(wxMenu* menu); void append_menu_item_change_filament(wxMenu* menu);

View file

@ -157,6 +157,12 @@ void View3D::center_selected()
m_canvas->do_center(); 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) { void View3D::center_selected_plate(const int plate_idx) {
if (m_canvas != nullptr) if (m_canvas != nullptr)
m_canvas->do_center_plate(plate_idx); m_canvas->do_center_plate(plate_idx);

View file

@ -66,6 +66,7 @@ public:
void exit_gizmo(); void exit_gizmo();
void delete_selected(); void delete_selected();
void center_selected(); void center_selected();
void drop_selected();
void center_selected_plate(const int plate_idx); void center_selected_plate(const int plate_idx);
void mirror_selection(Axis axis); void mirror_selection(Axis axis);

View file

@ -2436,6 +2436,7 @@ struct Plater::priv
void delete_all_objects_from_model(); void delete_all_objects_from_model();
void reset(bool apply_presets_change = false); void reset(bool apply_presets_change = false);
void center_selection(); void center_selection();
void drop_selection();
void mirror(Axis axis); void mirror(Axis axis);
void split_object(); void split_object();
void split_volume(); void split_volume();
@ -5022,6 +5023,11 @@ void Plater::priv::center_selection()
view3D->center_selected(); view3D->center_selected();
} }
void Plater::priv::drop_selection()
{
view3D->drop_selected();
}
void Plater::priv::mirror(Axis axis) void Plater::priv::mirror(Axis axis)
{ {
view3D->mirror_selection(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::center_selection() { p->center_selection(); }
void Plater::drop_selection() { p->drop_selection(); }
void Plater::mirror(Axis axis) { p->mirror(axis); } void Plater::mirror(Axis axis) { p->mirror(axis); }
void Plater::split_object() { p->split_object(); } void Plater::split_object() { p->split_object(); }
void Plater::split_volume() { p->split_volume(); } void Plater::split_volume() { p->split_volume(); }

View file

@ -529,6 +529,7 @@ public:
//BBS: add clone logic //BBS: add clone logic
void clone_selection(); void clone_selection();
void center_selection(); void center_selection();
void drop_selection();
void search(bool plater_is_active, Preset::Type type, wxWindow *tag, TextInput *etag, wxWindow *stag); void search(bool plater_is_active, Preset::Type type, wxWindow *tag, TextInput *etag, wxWindow *stag);
void mirror(Axis axis); void mirror(Axis axis);
void split_object(); void split_object();

View file

@ -490,6 +490,12 @@ void Selection::center()
return; 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) { void Selection::center_plate(const int plate_idx) {
PartPlate* plate = wxGetApp().plater()->get_partplate_list().get_plate(plate_idx); PartPlate* plate = wxGetApp().plater()->get_partplate_list().get_plate(plate_idx);

View file

@ -230,6 +230,7 @@ public:
void remove_curr_plate(); void remove_curr_plate();
void clone(int numbers = 1); void clone(int numbers = 1);
void center(); void center();
void drop();
void center_plate(const int plate_idx); void center_plate(const int plate_idx);
void set_printable(bool printable); void set_printable(bool printable);