From b2556f8df08c287ce150d1666d7616744bed229e Mon Sep 17 00:00:00 2001 From: Erkan Ozgur Yilmaz Date: Thu, 30 May 2024 03:04:11 +0100 Subject: [PATCH 01/14] Added `duplicate plate` feature. This the initial commit and this still needs work. --- resources/images/plate_duplicate.svg | 1 + resources/images/plate_duplicate_dark.svg | 10 ++ resources/images/plate_duplicate_hover.svg | 1 + .../images/plate_duplicate_hover_dark.svg | 10 ++ src/slic3r/GUI/GLCanvas3D.cpp | 1 + src/slic3r/GUI/GLCanvas3D.hpp | 1 + src/slic3r/GUI/PartPlate.cpp | 120 +++++++++++++++--- src/slic3r/GUI/PartPlate.hpp | 10 +- src/slic3r/GUI/Plater.cpp | 56 ++++++-- src/slic3r/GUI/Plater.hpp | 1 + 10 files changed, 186 insertions(+), 25 deletions(-) create mode 100644 resources/images/plate_duplicate.svg create mode 100644 resources/images/plate_duplicate_dark.svg create mode 100644 resources/images/plate_duplicate_hover.svg create mode 100644 resources/images/plate_duplicate_hover_dark.svg diff --git a/resources/images/plate_duplicate.svg b/resources/images/plate_duplicate.svg new file mode 100644 index 00000000000..caa52e8d768 --- /dev/null +++ b/resources/images/plate_duplicate.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources/images/plate_duplicate_dark.svg b/resources/images/plate_duplicate_dark.svg new file mode 100644 index 00000000000..1de72192085 --- /dev/null +++ b/resources/images/plate_duplicate_dark.svg @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/resources/images/plate_duplicate_hover.svg b/resources/images/plate_duplicate_hover.svg new file mode 100644 index 00000000000..78154b649e8 --- /dev/null +++ b/resources/images/plate_duplicate_hover.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/resources/images/plate_duplicate_hover_dark.svg b/resources/images/plate_duplicate_hover_dark.svg new file mode 100644 index 00000000000..04c5953c64d --- /dev/null +++ b/resources/images/plate_duplicate_hover_dark.svg @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index be6c8d8289e..0d2398f8ae3 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -992,6 +992,7 @@ wxDEFINE_EVENT(EVT_GLCANVAS_PLATE_RIGHT_CLICK, RBtnPlateEvent); wxDEFINE_EVENT(EVT_GLCANVAS_REMOVE_OBJECT, SimpleEvent); wxDEFINE_EVENT(EVT_GLCANVAS_ARRANGE, SimpleEvent); //BBS: add arrange and orient event +// wxDEFINE_EVENT(EVT_GLCANVAS_DUPLICATE_PLATE, SimpleEvent); wxDEFINE_EVENT(EVT_GLCANVAS_ARRANGE_PARTPLATE, SimpleEvent); wxDEFINE_EVENT(EVT_GLCANVAS_ORIENT, SimpleEvent); wxDEFINE_EVENT(EVT_GLCANVAS_ORIENT_PARTPLATE, SimpleEvent); diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index 2d67401d5f8..4bb996f7ae3 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -159,6 +159,7 @@ wxDECLARE_EVENT(EVT_GLCANVAS_PLATE_RIGHT_CLICK, RBtnPlateEvent); wxDECLARE_EVENT(EVT_GLCANVAS_REMOVE_OBJECT, SimpleEvent); wxDECLARE_EVENT(EVT_GLCANVAS_ARRANGE, SimpleEvent); //BBS: add arrange and orient event +// wxDECLARE_EVENT(EVT_GLCANVAS_DUPLICATE_PLATE, SimpleEvent); wxDECLARE_EVENT(EVT_GLCANVAS_ARRANGE_PARTPLATE, SimpleEvent); wxDECLARE_EVENT(EVT_GLCANVAS_ORIENT, SimpleEvent); wxDECLARE_EVENT(EVT_GLCANVAS_ORIENT_PARTPLATE, SimpleEvent); diff --git a/src/slic3r/GUI/PartPlate.cpp b/src/slic3r/GUI/PartPlate.cpp index f99db5445c8..ab0b75639c5 100644 --- a/src/slic3r/GUI/PartPlate.cpp +++ b/src/slic3r/GUI/PartPlate.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -971,6 +972,8 @@ void PartPlate::show_tooltip(const std::string tooltip) void PartPlate::render_icons(bool bottom, bool only_name, int hover_id) { + printf("----\n"); + printf("PartPlate::render_icons START\n"); GLShaderProgram* shader = wxGetApp().get_shader("printbed"); if (shader != nullptr) { shader->start_using(); @@ -996,21 +999,31 @@ void PartPlate::render_icons(bool bottom, bool only_name, int hover_id) else render_icon_texture(m_del_icon.model, m_partplate_list->m_del_texture); + + printf("Before registering m_duplicate_icon.model\n"); if (hover_id == 2) { + render_icon_texture(m_duplicate_icon.model, m_partplate_list->m_duplicate_hovered_texture); + show_tooltip(_u8L("Duplicate current plate with objects")); + } + else + render_icon_texture(m_duplicate_icon.model, m_partplate_list->m_duplicate_texture); + printf("After registering m_duplicate_icon.model\n"); + + if (hover_id == 3) { render_icon_texture(m_orient_icon.model, m_partplate_list->m_orient_hovered_texture); show_tooltip(_u8L("Auto orient objects on current plate")); } else render_icon_texture(m_orient_icon.model, m_partplate_list->m_orient_texture); - if (hover_id == 3) { + if (hover_id == 4) { render_icon_texture(m_arrange_icon.model, m_partplate_list->m_arrange_hovered_texture); show_tooltip(_u8L("Arrange objects on current plate")); } else render_icon_texture(m_arrange_icon.model, m_partplate_list->m_arrange_texture); - if (hover_id == 4) { + if (hover_id == 5) { if (this->is_locked()) { render_icon_texture(m_lock_icon.model, m_partplate_list->m_locked_hovered_texture); @@ -1028,7 +1041,7 @@ void PartPlate::render_icons(bool bottom, bool only_name, int hover_id) render_icon_texture(m_lock_icon.model, m_partplate_list->m_lockopen_texture); } - if (hover_id == 6) { + if (hover_id == 7) { render_icon_texture(m_plate_name_edit_icon.model, m_partplate_list->m_plate_name_edit_hovered_texture); show_tooltip(_u8L("Edit current plate name")); } @@ -1037,7 +1050,7 @@ void PartPlate::render_icons(bool bottom, bool only_name, int hover_id) if (m_partplate_list->render_plate_settings) { bool has_plate_settings = get_bed_type() != BedType::btDefault || get_print_seq() != PrintSequence::ByDefault || !get_first_layer_print_sequence().empty() || !get_other_layers_print_sequence().empty() || has_spiral_mode_config(); - if (hover_id == 5) { + if (hover_id == 6) { if (!has_plate_settings) render_icon_texture(m_plate_settings_icon.model, m_partplate_list->m_plate_settings_hovered_texture); else @@ -1066,6 +1079,7 @@ void PartPlate::render_icons(bool bottom, bool only_name, int hover_id) glsafe(::glDepthMask(GL_TRUE)); shader->stop_using(); } + printf("PartPlate::render_icons END\n"); } void PartPlate::render_only_numbers(bool bottom) @@ -1326,21 +1340,29 @@ static void register_model_for_picking(GLCanvas3D &canvas, PickingModel &model, void PartPlate::register_raycasters_for_picking(GLCanvas3D &canvas) { + printf("PartPlate::register_raycasters_for_picking START\n"); register_model_for_picking(canvas, m_triangles, picking_id_component(0)); register_model_for_picking(canvas, m_del_icon, picking_id_component(1)); - register_model_for_picking(canvas, m_orient_icon, picking_id_component(2)); - register_model_for_picking(canvas, m_arrange_icon, picking_id_component(3)); - register_model_for_picking(canvas, m_lock_icon, picking_id_component(4)); + register_model_for_picking(canvas, m_duplicate_icon, picking_id_component(2)); + register_model_for_picking(canvas, m_orient_icon, picking_id_component(3)); + register_model_for_picking(canvas, m_arrange_icon, picking_id_component(4)); + register_model_for_picking(canvas, m_lock_icon, picking_id_component(5)); if (m_partplate_list->render_plate_settings) - register_model_for_picking(canvas, m_plate_settings_icon, picking_id_component(5)); + register_model_for_picking(canvas, m_plate_settings_icon, picking_id_component(6)); - canvas.remove_raycasters_for_picking(SceneRaycaster::EType::Bed, picking_id_component(6)); - register_model_for_picking(canvas, m_plate_name_edit_icon, picking_id_component(6)); + canvas.remove_raycasters_for_picking(SceneRaycaster::EType::Bed, picking_id_component(7)); + register_model_for_picking(canvas, m_plate_name_edit_icon, picking_id_component(7)); + printf("PartPlate::register_raycasters_for_picking END\n"); } int PartPlate::picking_id_component(int idx) const { + printf("----\n"); + printf("PartPlate::picking_id_component START\n"); unsigned int id = PLATE_BASE_ID - this->m_plate_index * GRABBER_COUNT - idx; + printf("PartPlate::picking_id_component idx: %i\n", idx); + printf("PartPlate::picking_id_component id: %u\n", id); + printf("PartPlate::picking_id_component END\n"); return id; } @@ -2647,6 +2669,8 @@ void PartPlate::generate_exclude_polygon(ExPolygon &exclude_polygon) bool PartPlate::set_shape(const Pointfs& shape, const Pointfs& exclude_areas, Vec2d position, float height_to_lid, float height_to_rod) { + printf("PartPlate::set_shape START;\n"); + Pointfs new_shape, new_exclude_areas; m_raw_shape = shape; for (const Vec2d& p : shape) { @@ -2659,6 +2683,7 @@ bool PartPlate::set_shape(const Pointfs& shape, const Pointfs& exclude_areas, Ve if ((m_shape == new_shape)&&(m_exclude_area == new_exclude_areas) &&(m_height_to_lid == height_to_lid)&&(m_height_to_rod == height_to_rod)) { BOOST_LOG_TRIVIAL(info) << "PartPlate same shape, skip directly"; + printf("PartPlate::set_shape END 1;\n"); return false; } @@ -2707,13 +2732,18 @@ bool PartPlate::set_shape(const Pointfs& shape, const Pointfs& exclude_areas, Ve //calc_vertex_for_icons_background(5, m_del_and_background_icon); //calc_vertex_for_icons(4, m_del_icon); + printf("BEFORE calc_vertex_for_icons calls;\n"); calc_vertex_for_icons(0, m_del_icon); - calc_vertex_for_icons(1, m_orient_icon); - calc_vertex_for_icons(2, m_arrange_icon); - calc_vertex_for_icons(3, m_lock_icon); - calc_vertex_for_icons(4, m_plate_settings_icon); + printf("BEFORE calc_vertex_for_icons(1, m_duplicate_icon);\n"); + calc_vertex_for_icons(1, m_duplicate_icon); + printf("AFTER calc_vertex_for_icons(1, m_duplicate_icon);\n"); + calc_vertex_for_icons(2, m_orient_icon); + calc_vertex_for_icons(3, m_arrange_icon); + calc_vertex_for_icons(4, m_lock_icon); + calc_vertex_for_icons(5, m_plate_settings_icon); //calc_vertex_for_number(0, (m_plate_index < 9), m_plate_idx_icon); calc_vertex_for_number(0, false, m_plate_idx_icon); + printf("AFTER calc_vertex_for_icons calls;\n"); if (m_plater) { // calc vertex for plate name generate_plate_name_texture(); @@ -2722,6 +2752,7 @@ bool PartPlate::set_shape(const Pointfs& shape, const Pointfs& exclude_areas, Ve calc_height_limit(); + printf("PartPlate::set_shape END 2;\n"); return true; } @@ -3261,6 +3292,7 @@ Vec2d PartPlateList::compute_shape_position(int index, int cols) //generate icon textures void PartPlateList::generate_icon_textures() { + printf("PartPlateList::generate_icon_textures START\n"); // use higher resolution images if graphic card and opengl version allow GLint max_tex_size = OpenGLManager::get_gl_info().get_max_tex_size(), icon_size = max_tex_size / 8; std::string path = resources_dir() + "/images/"; @@ -3284,6 +3316,28 @@ void PartPlateList::generate_icon_textures() } } + //if (m_duplicate_texture.get_id() == 0) + printf("BEFORE loading SVG for m_duplicate_texture\n"); + { + file_name = path + (m_is_dark ? "plate_duplicate_dark.svg" : "plate_duplicate.svg"); + // file_name = path + (m_is_dark ? "plate_close_dark.svg" : "plate_close.svg"); + if (!m_duplicate_texture.load_from_svg_file(file_name, true, false, false, icon_size)) { + printf(":load file %s failed\n", file_name.c_str()); + BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(":load file %1% failed") % file_name; + } + } + printf("AFTER loading SVG for m_duplicate_hovered_texture\n"); + + //if (m_duplicate_hovered_texture.get_id() == 0) + { + file_name = path + (m_is_dark ? "plate_duplicate_hover_dark.svg" : "plate_duplicate_hover.svg"); + // file_name = path + (m_is_dark ? "plate_close_hover_dark.svg" : "plate_close_hover.svg"); + if (!m_duplicate_hovered_texture.load_from_svg_file(file_name, true, false, false, icon_size)) { + printf(":load file %s failed\n", file_name.c_str()); + BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(":load file %1% failed") % file_name; + } + } + //if (m_arrange_texture.get_id() == 0) { file_name = path + (m_is_dark ? "plate_arrange_dark.svg" : "plate_arrange.svg"); @@ -3412,13 +3466,21 @@ void PartPlateList::generate_icon_textures() } } } + printf("PartPlateList::generate_icon_textures END\n"); } void PartPlateList::release_icon_textures() { + printf("PartPlateList::release_icon_textures START\n"); m_logo_texture.reset(); m_del_texture.reset(); m_del_hovered_texture.reset(); + printf("PartPlateList::release_icon_textures before m_duplicate_texture.reset()\n"); + m_duplicate_texture.reset(); + printf("PartPlateList::release_icon_textures after m_duplicate_texture.reset()\n"); + printf("PartPlateList::release_icon_textures before m_duplicate_hovered_texture.reset()\n"); + m_duplicate_hovered_texture.reset(); + printf("PartPlateList::release_icon_textures after m_duplicate_hovered_texture.reset()\n"); m_arrange_texture.reset(); m_arrange_hovered_texture.reset(); m_orient_texture.reset(); @@ -3450,6 +3512,7 @@ void PartPlateList::release_icon_textures() } } } + printf("PartPlateList::release_icon_textures END\n"); } void PartPlateList::set_default_wipe_tower_pos_for_plate(int plate_idx) @@ -3654,6 +3717,29 @@ int PartPlateList::create_plate(bool adjust_position) return new_index; } + +int PartPlateList::duplicate_plate(int index) +{ + printf("PartPlateList::duplicate_plate START\n"); + // create a new plate + int new_plate_index = create_plate(true); + PartPlate* old_plate = NULL; + PartPlate* new_plate = NULL; + old_plate = get_plate(index); + new_plate = get_plate(new_plate_index); + + // copy the object from the original plate + for(int obj_id = 0; obj_id < old_plate->m_model->objects.size(); obj_id++){ + ModelObject* model_object = old_plate->m_model->objects[obj_id]; + ModelObject* model_object_copy = m_model->add_object(*model_object); + // model_object_copy->name = + } + + printf("PartPlateList::duplicate_plate END\n"); + return new_plate_index; +} + + //destroy print's objects and results int PartPlateList::destroy_print(int print_index) { @@ -4767,6 +4853,7 @@ void PartPlateList::postprocess_arrange_polygon(arrangement::ArrangePolygon& arr //render void PartPlateList::render(const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, bool only_current, bool only_body, int hover_id, bool render_cali) { + printf("PartPlateList::render START\n"); const std::lock_guard local_lock(m_plates_mutex); std::vector::iterator it = m_plate_list.begin(); @@ -4776,12 +4863,14 @@ void PartPlateList::render(const Transform3d& view_matrix, const Transform3d& pr plate_hover_index = hover_id / PartPlate::GRABBER_COUNT; plate_hover_action = hover_id % PartPlate::GRABBER_COUNT; } + printf("plate_hover_index : %i\n", plate_hover_index); + printf("plate_hover_action: %i\n", plate_hover_action); static bool last_dark_mode_status = m_is_dark; if (m_is_dark != last_dark_mode_status) { last_dark_mode_status = m_is_dark; generate_icon_textures(); - }else if(m_del_texture.get_id() == 0) + } else if(m_del_texture.get_id() == 0) generate_icon_textures(); for (it = m_plate_list.begin(); it != m_plate_list.end(); it++) { int current_index = (*it)->get_index(); @@ -4801,6 +4890,7 @@ void PartPlateList::render(const Transform3d& view_matrix, const Transform3d& pr (*it)->render(view_matrix, projection_matrix, bottom, only_body, false, PartPlate::HEIGHT_LIMIT_NONE, -1, render_cali); } } + printf("PartPlateList::render END\n"); } /*int PartPlateList::select_plate_by_hover_id(int hover_id) diff --git a/src/slic3r/GUI/PartPlate.hpp b/src/slic3r/GUI/PartPlate.hpp index e0b0e90ace3..4ca38d7eb47 100644 --- a/src/slic3r/GUI/PartPlate.hpp +++ b/src/slic3r/GUI/PartPlate.hpp @@ -136,6 +136,7 @@ class PartPlate : public ObjectBase GLModel m_height_limit_bottom; GLModel m_height_limit_top; PickingModel m_del_icon; + PickingModel m_duplicate_icon; PickingModel m_arrange_icon; PickingModel m_orient_icon; PickingModel m_lock_icon; @@ -198,8 +199,8 @@ class PartPlate : public ObjectBase public: static const unsigned int PLATE_BASE_ID = 255 * 255 * 253; - static const unsigned int PLATE_NAME_HOVER_ID = 6; - static const unsigned int GRABBER_COUNT = 7; + static const unsigned int PLATE_NAME_HOVER_ID = 7; + static const unsigned int GRABBER_COUNT = 8; static ColorRGBA SELECT_COLOR; static ColorRGBA UNSELECT_COLOR; @@ -546,6 +547,8 @@ class PartPlateList : public ObjectBase GLTexture m_logo_texture; GLTexture m_del_texture; GLTexture m_del_hovered_texture; + GLTexture m_duplicate_texture; + GLTexture m_duplicate_hovered_texture; GLTexture m_arrange_texture; GLTexture m_arrange_hovered_texture; GLTexture m_orient_texture; @@ -660,6 +663,9 @@ class PartPlateList : public ObjectBase //create an empty plate and return its index int create_plate(bool adjust_position = true); + // duplicate plate + int duplicate_plate(int index); + //destroy print which has the index of print_index int destroy_print(int print_index); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 352dfe95a8d..0105210f5f5 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2558,6 +2558,7 @@ struct Plater::priv void on_action_add(SimpleEvent&); void on_action_add_plate(SimpleEvent&); void on_action_del_plate(SimpleEvent&); + void on_action_duplicate_plate(SimpleEvent&); void on_action_split_objects(SimpleEvent&); void on_action_split_volumes(SimpleEvent&); void on_action_layersediting(SimpleEvent&); @@ -2948,22 +2949,26 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) view3D_canvas->Bind(EVT_GLCANVAS_OBJECT_SELECT, &priv::on_object_select, this); view3D_canvas->Bind(EVT_GLCANVAS_RIGHT_CLICK, &priv::on_right_click, this); //BBS: add part plate related logic + // view3D_canvas->Bind(EVT_GLCANVAS_DUPLICATE_PLATE, [this](SimpleEvent& evt){ + // this->q->set_prepare_state(Job::PREPARE_STATE_DEFAULT); + // this->q->duplicate_plate(); + // }); view3D_canvas->Bind(EVT_GLCANVAS_PLATE_RIGHT_CLICK, &priv::on_plate_right_click, this); view3D_canvas->Bind(EVT_GLCANVAS_REMOVE_OBJECT, [q](SimpleEvent&) { q->remove_selected(); }); view3D_canvas->Bind(EVT_GLCANVAS_ARRANGE, [this](SimpleEvent& evt) { - //BBS arrage from EVT set default state. + //BBS arrange from EVT set default state. this->q->set_prepare_state(Job::PREPARE_STATE_DEFAULT); this->q->arrange(); }); view3D_canvas->Bind(EVT_GLCANVAS_ARRANGE_PARTPLATE, [this](SimpleEvent& evt) { - //BBS arrage from EVT set default state. + //BBS arrange from EVT set default state. this->q->set_prepare_state(Job::PREPARE_STATE_MENU); this->q->arrange(); }); view3D_canvas->Bind(EVT_GLCANVAS_ORIENT, [this](SimpleEvent& evt) { - //BBS oriant from EVT set default state. + //BBS orient from EVT set default state. this->q->set_prepare_state(Job::PREPARE_STATE_DEFAULT); this->q->orient(); }); view3D_canvas->Bind(EVT_GLCANVAS_ORIENT_PARTPLATE, [this](SimpleEvent& evt) { - //BBS oriant from EVT set default state. + //BBS orient from EVT set default state. this->q->set_prepare_state(Job::PREPARE_STATE_MENU); this->q->orient(); }); //BBS @@ -7076,6 +7081,17 @@ void Plater::priv::on_action_del_plate(SimpleEvent&) } } +//BBS: duplicate plate from toolbar +void Plater::priv::on_action_duplicate_plate(SimpleEvent&) +{ + printf("Plater::priv::on_action_duplicate_plate START\n"); + if (q != nullptr) { + // without a plate index this will duplicate the current plate only + q->duplicate_plate(); + } + printf("Plater::priv::on_action_duplicate_plate END\n"); +} + //BBS: GUI refactor: GLToolbar void Plater::priv::on_action_open_project(SimpleEvent&) { @@ -13819,6 +13835,7 @@ void Plater::open_platesettings_dialog(wxCommandEvent& evt) { //BBS: select Plate by hover_id int Plater::select_plate_by_hover_id(int hover_id, bool right_click, bool isModidyPlateName) { + printf("Plater::select_plate_by_hover_id START\n"); int ret; int action, plate_index; @@ -13912,6 +13929,13 @@ int Plater::select_plate_by_hover_id(int hover_id, bool right_click, bool isModi ret = delete_plate(plate_index); } else if ((action == 2)&&(!right_click)) + { + printf("before duplicate_plate call in Plater::select_plate_by_hover_id\n"); + // duplicate plate + ret = duplicate_plate(plate_index); + printf("after duplicate_plate call in Plater::select_plate_by_hover_id\n"); + } + else if ((action == 3)&&(!right_click)) { //arrange the plate //take_snapshot("select_orient partplate"); @@ -13927,7 +13951,7 @@ int Plater::select_plate_by_hover_id(int hover_id, bool right_click, bool isModi ret = -1; } } - else if ((action == 3)&&(!right_click)) + else if ((action == 4)&&(!right_click)) { //arrange the plate //take_snapshot("select_arrange partplate"); @@ -13945,13 +13969,13 @@ int Plater::select_plate_by_hover_id(int hover_id, bool right_click, bool isModi ret = -1; } } - else if ((action == 4)&&(!right_click)) + else if ((action == 5)&&(!right_click)) { //lock the plate take_snapshot("lock partplate"); ret = p->partplate_list.lock_plate(plate_index, !p->partplate_list.is_locked(plate_index)); } - else if ((action == 5)&&(!right_click)) + else if ((action == 6)&&(!right_click)) { // set the plate type ret = select_plate(plate_index); @@ -13967,7 +13991,7 @@ int Plater::select_plate_by_hover_id(int hover_id, bool right_click, bool isModi ret = -1; } } - else if ((action == 6) && (!right_click)) { + else if ((action == 7) && (!right_click)) { // set the plate type ret = select_plate(plate_index); if (!ret) { @@ -13994,6 +14018,22 @@ int Plater::select_plate_by_hover_id(int hover_id, bool right_click, bool isModi } BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(" %1%: return %2%")%__LINE__ % ret; + printf("Plater::select_plate_by_hover_id END\n"); + return ret; +} + +int Plater::duplicate_plate(int plate_index) +{ + printf("Plater::duplicate_plate START\n"); + int index = plate_index, ret; + if (plate_index == -1) + index = p->partplate_list.get_curr_plate_index(); + + ret = p->partplate_list.duplicate_plate(index); + + //need to call update + update(); + printf("Plater::duplicate_plate END\n"); return ret; } diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index 109e7845dc7..0b25c424594 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -599,6 +599,7 @@ class Plater: public wxPanel int select_plate_by_hover_id(int hover_id, bool right_click = false, bool isModidyPlateName = false); //BBS: delete the plate, index= -1 means the current plate int delete_plate(int plate_index = -1); + int duplicate_plate(int plate_index = -1); //BBS: select the sliced plate by index int select_sliced_plate(int plate_index); //BBS: set bed positions From a2ea10c3e45b47656db5236e898bca898a21502a Mon Sep 17 00:00:00 2001 From: Erkan Ozgur Yilmaz Date: Thu, 30 May 2024 23:13:48 +0100 Subject: [PATCH 02/14] [#2025] Fixed the SEGFAULT, apparently an icon id=6 needed to be updated to id=7 as we have one more plate icon. [#2025] Removed the `printf` statements. --- src/slic3r/GUI/PartPlate.cpp | 62 ++++++------------------------------ src/slic3r/GUI/Plater.cpp | 8 ----- 2 files changed, 10 insertions(+), 60 deletions(-) diff --git a/src/slic3r/GUI/PartPlate.cpp b/src/slic3r/GUI/PartPlate.cpp index ab0b75639c5..ee5d9469893 100644 --- a/src/slic3r/GUI/PartPlate.cpp +++ b/src/slic3r/GUI/PartPlate.cpp @@ -2,7 +2,6 @@ #include #include #include -#include #include #include #include @@ -972,8 +971,6 @@ void PartPlate::show_tooltip(const std::string tooltip) void PartPlate::render_icons(bool bottom, bool only_name, int hover_id) { - printf("----\n"); - printf("PartPlate::render_icons START\n"); GLShaderProgram* shader = wxGetApp().get_shader("printbed"); if (shader != nullptr) { shader->start_using(); @@ -999,15 +996,12 @@ void PartPlate::render_icons(bool bottom, bool only_name, int hover_id) else render_icon_texture(m_del_icon.model, m_partplate_list->m_del_texture); - - printf("Before registering m_duplicate_icon.model\n"); if (hover_id == 2) { render_icon_texture(m_duplicate_icon.model, m_partplate_list->m_duplicate_hovered_texture); show_tooltip(_u8L("Duplicate current plate with objects")); } else render_icon_texture(m_duplicate_icon.model, m_partplate_list->m_duplicate_texture); - printf("After registering m_duplicate_icon.model\n"); if (hover_id == 3) { render_icon_texture(m_orient_icon.model, m_partplate_list->m_orient_hovered_texture); @@ -1079,7 +1073,6 @@ void PartPlate::render_icons(bool bottom, bool only_name, int hover_id) glsafe(::glDepthMask(GL_TRUE)); shader->stop_using(); } - printf("PartPlate::render_icons END\n"); } void PartPlate::render_only_numbers(bool bottom) @@ -1340,7 +1333,6 @@ static void register_model_for_picking(GLCanvas3D &canvas, PickingModel &model, void PartPlate::register_raycasters_for_picking(GLCanvas3D &canvas) { - printf("PartPlate::register_raycasters_for_picking START\n"); register_model_for_picking(canvas, m_triangles, picking_id_component(0)); register_model_for_picking(canvas, m_del_icon, picking_id_component(1)); register_model_for_picking(canvas, m_duplicate_icon, picking_id_component(2)); @@ -1352,17 +1344,11 @@ void PartPlate::register_raycasters_for_picking(GLCanvas3D &canvas) canvas.remove_raycasters_for_picking(SceneRaycaster::EType::Bed, picking_id_component(7)); register_model_for_picking(canvas, m_plate_name_edit_icon, picking_id_component(7)); - printf("PartPlate::register_raycasters_for_picking END\n"); } int PartPlate::picking_id_component(int idx) const { - printf("----\n"); - printf("PartPlate::picking_id_component START\n"); unsigned int id = PLATE_BASE_ID - this->m_plate_index * GRABBER_COUNT - idx; - printf("PartPlate::picking_id_component idx: %i\n", idx); - printf("PartPlate::picking_id_component id: %u\n", id); - printf("PartPlate::picking_id_component END\n"); return id; } @@ -1933,9 +1919,9 @@ void PartPlate::generate_plate_name_texture() BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << "Unable to generate geometry buffers for icons\n"; auto canvas = this->m_partplate_list->m_plater->get_view3D_canvas3D(); - canvas->remove_raycasters_for_picking(SceneRaycaster::EType::Bed, picking_id_component(6)); + canvas->remove_raycasters_for_picking(SceneRaycaster::EType::Bed, picking_id_component(7)); calc_vertex_for_plate_name_edit_icon(&m_name_texture, 0, m_plate_name_edit_icon); - register_model_for_picking(*canvas, m_plate_name_edit_icon, picking_id_component(6)); + register_model_for_picking(*canvas, m_plate_name_edit_icon, picking_id_component(7)); } void PartPlate::set_plate_name(const std::string& name) { @@ -2669,8 +2655,6 @@ void PartPlate::generate_exclude_polygon(ExPolygon &exclude_polygon) bool PartPlate::set_shape(const Pointfs& shape, const Pointfs& exclude_areas, Vec2d position, float height_to_lid, float height_to_rod) { - printf("PartPlate::set_shape START;\n"); - Pointfs new_shape, new_exclude_areas; m_raw_shape = shape; for (const Vec2d& p : shape) { @@ -2683,7 +2667,6 @@ bool PartPlate::set_shape(const Pointfs& shape, const Pointfs& exclude_areas, Ve if ((m_shape == new_shape)&&(m_exclude_area == new_exclude_areas) &&(m_height_to_lid == height_to_lid)&&(m_height_to_rod == height_to_rod)) { BOOST_LOG_TRIVIAL(info) << "PartPlate same shape, skip directly"; - printf("PartPlate::set_shape END 1;\n"); return false; } @@ -2732,27 +2715,22 @@ bool PartPlate::set_shape(const Pointfs& shape, const Pointfs& exclude_areas, Ve //calc_vertex_for_icons_background(5, m_del_and_background_icon); //calc_vertex_for_icons(4, m_del_icon); - printf("BEFORE calc_vertex_for_icons calls;\n"); calc_vertex_for_icons(0, m_del_icon); - printf("BEFORE calc_vertex_for_icons(1, m_duplicate_icon);\n"); - calc_vertex_for_icons(1, m_duplicate_icon); - printf("AFTER calc_vertex_for_icons(1, m_duplicate_icon);\n"); - calc_vertex_for_icons(2, m_orient_icon); - calc_vertex_for_icons(3, m_arrange_icon); - calc_vertex_for_icons(4, m_lock_icon); - calc_vertex_for_icons(5, m_plate_settings_icon); + calc_vertex_for_icons(1, m_duplicate_icon); + calc_vertex_for_icons(2, m_orient_icon); + calc_vertex_for_icons(3, m_arrange_icon); + calc_vertex_for_icons(4, m_lock_icon); + calc_vertex_for_icons(5, m_plate_settings_icon); //calc_vertex_for_number(0, (m_plate_index < 9), m_plate_idx_icon); calc_vertex_for_number(0, false, m_plate_idx_icon); - printf("AFTER calc_vertex_for_icons calls;\n"); if (m_plater) { // calc vertex for plate name - generate_plate_name_texture(); + generate_plate_name_texture(); } } calc_height_limit(); - printf("PartPlate::set_shape END 2;\n"); return true; } @@ -3292,7 +3270,6 @@ Vec2d PartPlateList::compute_shape_position(int index, int cols) //generate icon textures void PartPlateList::generate_icon_textures() { - printf("PartPlateList::generate_icon_textures START\n"); // use higher resolution images if graphic card and opengl version allow GLint max_tex_size = OpenGLManager::get_gl_info().get_max_tex_size(), icon_size = max_tex_size / 8; std::string path = resources_dir() + "/images/"; @@ -3317,23 +3294,17 @@ void PartPlateList::generate_icon_textures() } //if (m_duplicate_texture.get_id() == 0) - printf("BEFORE loading SVG for m_duplicate_texture\n"); { file_name = path + (m_is_dark ? "plate_duplicate_dark.svg" : "plate_duplicate.svg"); - // file_name = path + (m_is_dark ? "plate_close_dark.svg" : "plate_close.svg"); if (!m_duplicate_texture.load_from_svg_file(file_name, true, false, false, icon_size)) { - printf(":load file %s failed\n", file_name.c_str()); BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(":load file %1% failed") % file_name; } } - printf("AFTER loading SVG for m_duplicate_hovered_texture\n"); //if (m_duplicate_hovered_texture.get_id() == 0) { file_name = path + (m_is_dark ? "plate_duplicate_hover_dark.svg" : "plate_duplicate_hover.svg"); - // file_name = path + (m_is_dark ? "plate_close_hover_dark.svg" : "plate_close_hover.svg"); if (!m_duplicate_hovered_texture.load_from_svg_file(file_name, true, false, false, icon_size)) { - printf(":load file %s failed\n", file_name.c_str()); BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(":load file %1% failed") % file_name; } } @@ -3466,21 +3437,15 @@ void PartPlateList::generate_icon_textures() } } } - printf("PartPlateList::generate_icon_textures END\n"); } void PartPlateList::release_icon_textures() { - printf("PartPlateList::release_icon_textures START\n"); m_logo_texture.reset(); m_del_texture.reset(); m_del_hovered_texture.reset(); - printf("PartPlateList::release_icon_textures before m_duplicate_texture.reset()\n"); - m_duplicate_texture.reset(); - printf("PartPlateList::release_icon_textures after m_duplicate_texture.reset()\n"); - printf("PartPlateList::release_icon_textures before m_duplicate_hovered_texture.reset()\n"); - m_duplicate_hovered_texture.reset(); - printf("PartPlateList::release_icon_textures after m_duplicate_hovered_texture.reset()\n"); + m_duplicate_texture.reset(); + m_duplicate_hovered_texture.reset(); m_arrange_texture.reset(); m_arrange_hovered_texture.reset(); m_orient_texture.reset(); @@ -3512,7 +3477,6 @@ void PartPlateList::release_icon_textures() } } } - printf("PartPlateList::release_icon_textures END\n"); } void PartPlateList::set_default_wipe_tower_pos_for_plate(int plate_idx) @@ -3720,7 +3684,6 @@ int PartPlateList::create_plate(bool adjust_position) int PartPlateList::duplicate_plate(int index) { - printf("PartPlateList::duplicate_plate START\n"); // create a new plate int new_plate_index = create_plate(true); PartPlate* old_plate = NULL; @@ -3735,7 +3698,6 @@ int PartPlateList::duplicate_plate(int index) // model_object_copy->name = } - printf("PartPlateList::duplicate_plate END\n"); return new_plate_index; } @@ -4853,7 +4815,6 @@ void PartPlateList::postprocess_arrange_polygon(arrangement::ArrangePolygon& arr //render void PartPlateList::render(const Transform3d& view_matrix, const Transform3d& projection_matrix, bool bottom, bool only_current, bool only_body, int hover_id, bool render_cali) { - printf("PartPlateList::render START\n"); const std::lock_guard local_lock(m_plates_mutex); std::vector::iterator it = m_plate_list.begin(); @@ -4863,8 +4824,6 @@ void PartPlateList::render(const Transform3d& view_matrix, const Transform3d& pr plate_hover_index = hover_id / PartPlate::GRABBER_COUNT; plate_hover_action = hover_id % PartPlate::GRABBER_COUNT; } - printf("plate_hover_index : %i\n", plate_hover_index); - printf("plate_hover_action: %i\n", plate_hover_action); static bool last_dark_mode_status = m_is_dark; if (m_is_dark != last_dark_mode_status) { @@ -4890,7 +4849,6 @@ void PartPlateList::render(const Transform3d& view_matrix, const Transform3d& pr (*it)->render(view_matrix, projection_matrix, bottom, only_body, false, PartPlate::HEIGHT_LIMIT_NONE, -1, render_cali); } } - printf("PartPlateList::render END\n"); } /*int PartPlateList::select_plate_by_hover_id(int hover_id) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 0105210f5f5..9a4a7018a18 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -7084,12 +7084,10 @@ void Plater::priv::on_action_del_plate(SimpleEvent&) //BBS: duplicate plate from toolbar void Plater::priv::on_action_duplicate_plate(SimpleEvent&) { - printf("Plater::priv::on_action_duplicate_plate START\n"); if (q != nullptr) { // without a plate index this will duplicate the current plate only q->duplicate_plate(); } - printf("Plater::priv::on_action_duplicate_plate END\n"); } //BBS: GUI refactor: GLToolbar @@ -13835,7 +13833,6 @@ void Plater::open_platesettings_dialog(wxCommandEvent& evt) { //BBS: select Plate by hover_id int Plater::select_plate_by_hover_id(int hover_id, bool right_click, bool isModidyPlateName) { - printf("Plater::select_plate_by_hover_id START\n"); int ret; int action, plate_index; @@ -13930,10 +13927,8 @@ int Plater::select_plate_by_hover_id(int hover_id, bool right_click, bool isModi } else if ((action == 2)&&(!right_click)) { - printf("before duplicate_plate call in Plater::select_plate_by_hover_id\n"); // duplicate plate ret = duplicate_plate(plate_index); - printf("after duplicate_plate call in Plater::select_plate_by_hover_id\n"); } else if ((action == 3)&&(!right_click)) { @@ -14018,13 +14013,11 @@ int Plater::select_plate_by_hover_id(int hover_id, bool right_click, bool isModi } BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(" %1%: return %2%")%__LINE__ % ret; - printf("Plater::select_plate_by_hover_id END\n"); return ret; } int Plater::duplicate_plate(int plate_index) { - printf("Plater::duplicate_plate START\n"); int index = plate_index, ret; if (plate_index == -1) index = p->partplate_list.get_curr_plate_index(); @@ -14033,7 +14026,6 @@ int Plater::duplicate_plate(int plate_index) //need to call update update(); - printf("Plater::duplicate_plate END\n"); return ret; } From 9d68b6b9f391453f34ac0dab4046931cb47bdf89 Mon Sep 17 00:00:00 2001 From: Erkan Ozgur Yilmaz Date: Fri, 31 May 2024 10:43:26 +0100 Subject: [PATCH 03/14] [#2025] Plate duplication is now fully implemented. --- src/slic3r/GUI/PartPlate.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/slic3r/GUI/PartPlate.cpp b/src/slic3r/GUI/PartPlate.cpp index ee5d9469893..c433d04286e 100644 --- a/src/slic3r/GUI/PartPlate.cpp +++ b/src/slic3r/GUI/PartPlate.cpp @@ -3691,13 +3691,24 @@ int PartPlateList::duplicate_plate(int index) old_plate = get_plate(index); new_plate = get_plate(new_plate_index); - // copy the object from the original plate - for(int obj_id = 0; obj_id < old_plate->m_model->objects.size(); obj_id++){ - ModelObject* model_object = old_plate->m_model->objects[obj_id]; - ModelObject* model_object_copy = m_model->add_object(*model_object); - // model_object_copy->name = + // get the offset between plate centers + Vec3d plate_to_plate_offset = new_plate->m_origin - old_plate->m_origin; + + // iterate over all the objects in this plate + ModelObjectPtrs obj_ptrs = old_plate->get_objects_on_this_plate(); + for (ModelObject* object : obj_ptrs){ + // copy and move the object to the same relative position in the new plate + ModelObject* object_copy = m_model->add_object(*object); + object_copy->translate(plate_to_plate_offset); + int new_obj_id = new_plate->m_model->objects.size() - 1; + // go over the instances and pair with the object + for (size_t new_instance_id = 0; new_instance_id < object_copy->instances.size(); new_instance_id++){ + new_plate->obj_to_instance_set.emplace(std::pair(new_obj_id, new_instance_id)); + BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": duplicate object into plate: index_pair [%1%,%2%], obj_id %3%") % new_obj_id % new_instance_id % object_copy->id().id; + } } - + // update the plates + wxGetApp().obj_list()->reload_all_plates(); return new_plate_index; } From b7169e937c24b455ce41c249fee83fc5cde29aa9 Mon Sep 17 00:00:00 2001 From: Erkan Ozgur Yilmaz Date: Fri, 31 May 2024 10:43:45 +0100 Subject: [PATCH 04/14] [#2025] Updated icons for plate duplicate funcctionality. --- resources/images/plate_duplicate.svg | 17 ++++++++++++++++- resources/images/plate_duplicate_dark.svg | 18 ++++++++++++------ resources/images/plate_duplicate_hover.svg | 17 ++++++++++++++++- .../images/plate_duplicate_hover_dark.svg | 18 ++++++++++++------ 4 files changed, 56 insertions(+), 14 deletions(-) diff --git a/resources/images/plate_duplicate.svg b/resources/images/plate_duplicate.svg index caa52e8d768..9a38bd892cc 100644 --- a/resources/images/plate_duplicate.svg +++ b/resources/images/plate_duplicate.svg @@ -1 +1,16 @@ - \ No newline at end of file + + + + + + + \ No newline at end of file diff --git a/resources/images/plate_duplicate_dark.svg b/resources/images/plate_duplicate_dark.svg index 1de72192085..9c489044bee 100644 --- a/resources/images/plate_duplicate_dark.svg +++ b/resources/images/plate_duplicate_dark.svg @@ -1,10 +1,16 @@ - - - + + + - \ No newline at end of file diff --git a/resources/images/plate_duplicate_hover.svg b/resources/images/plate_duplicate_hover.svg index 78154b649e8..679683ac6ec 100644 --- a/resources/images/plate_duplicate_hover.svg +++ b/resources/images/plate_duplicate_hover.svg @@ -1 +1,16 @@ - \ No newline at end of file + + + + + + + \ No newline at end of file diff --git a/resources/images/plate_duplicate_hover_dark.svg b/resources/images/plate_duplicate_hover_dark.svg index 04c5953c64d..26e4ce7e12d 100644 --- a/resources/images/plate_duplicate_hover_dark.svg +++ b/resources/images/plate_duplicate_hover_dark.svg @@ -1,10 +1,16 @@ - - - + - + + \ No newline at end of file From 77b4a628741fd518a4555e10deafa67078be6794 Mon Sep 17 00:00:00 2001 From: Erkan Ozgur Yilmaz Date: Fri, 31 May 2024 13:25:10 +0100 Subject: [PATCH 05/14] [#2025] Added toolbar icon fro "Duplicate Current Plate" action. --- resources/images/toolbar_add_plate_dark.svg | 15 ++++++++++++++- resources/images/toolbar_duplicate_plate.svg | 14 ++++++++++++++ resources/images/toolbar_duplicate_plate_dark.svg | 14 ++++++++++++++ src/slic3r/GUI/GLCanvas3D.cpp | 14 +++++++++++++- src/slic3r/GUI/GLCanvas3D.hpp | 2 +- src/slic3r/GUI/GLToolbar.cpp | 1 + src/slic3r/GUI/GLToolbar.hpp | 1 + src/slic3r/GUI/Plater.cpp | 12 ++++++++---- 8 files changed, 66 insertions(+), 7 deletions(-) create mode 100644 resources/images/toolbar_duplicate_plate.svg create mode 100644 resources/images/toolbar_duplicate_plate_dark.svg diff --git a/resources/images/toolbar_add_plate_dark.svg b/resources/images/toolbar_add_plate_dark.svg index a361368a181..f7aebca4f4b 100644 --- a/resources/images/toolbar_add_plate_dark.svg +++ b/resources/images/toolbar_add_plate_dark.svg @@ -1 +1,14 @@ - \ No newline at end of file + + + + + + \ No newline at end of file diff --git a/resources/images/toolbar_duplicate_plate.svg b/resources/images/toolbar_duplicate_plate.svg new file mode 100644 index 00000000000..9df643fe4bf --- /dev/null +++ b/resources/images/toolbar_duplicate_plate.svg @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/resources/images/toolbar_duplicate_plate_dark.svg b/resources/images/toolbar_duplicate_plate_dark.svg new file mode 100644 index 00000000000..d8f81a52daf --- /dev/null +++ b/resources/images/toolbar_duplicate_plate_dark.svg @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 0d2398f8ae3..31ac27def95 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -992,7 +992,7 @@ wxDEFINE_EVENT(EVT_GLCANVAS_PLATE_RIGHT_CLICK, RBtnPlateEvent); wxDEFINE_EVENT(EVT_GLCANVAS_REMOVE_OBJECT, SimpleEvent); wxDEFINE_EVENT(EVT_GLCANVAS_ARRANGE, SimpleEvent); //BBS: add arrange and orient event -// wxDEFINE_EVENT(EVT_GLCANVAS_DUPLICATE_PLATE, SimpleEvent); +wxDEFINE_EVENT(EVT_GLCANVAS_DUPLICATE_PLATE, SimpleEvent); wxDEFINE_EVENT(EVT_GLCANVAS_ARRANGE_PARTPLATE, SimpleEvent); wxDEFINE_EVENT(EVT_GLCANVAS_ORIENT, SimpleEvent); wxDEFINE_EVENT(EVT_GLCANVAS_ORIENT_PARTPLATE, SimpleEvent); @@ -6242,6 +6242,9 @@ void GLCanvas3D::_switch_toolbars_icon_filename() item = m_main_toolbar.get_item("addplate"); item->set_icon_filename(m_is_dark ? "toolbar_add_plate_dark.svg" : "toolbar_add_plate.svg"); + item = m_main_toolbar.get_item("duplicateplate"); + item->set_icon_filename(m_is_dark ? "toolbar_duplicate_plate_dark.svg" : "toolbar_duplicate_plate.svg"); + item = m_main_toolbar.get_item("orient"); item->set_icon_filename(m_is_dark ? "toolbar_orient_dark.svg" : "toolbar_orient.svg"); @@ -6354,6 +6357,15 @@ bool GLCanvas3D::_init_main_toolbar() if (!m_main_toolbar.add_item(item)) return false; + item.name = "duplicateplate"; + item.icon_filename = m_is_dark ? "toolbar_duplicate_plate_dark.svg" : "toolbar_duplicate_plate.svg"; + item.tooltip = _utf8(L("Duplicate current plate")); + item.sprite_id++; + item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_DUPLICATE_PLATE)); }; + item.enabling_callback = []()->bool {return wxGetApp().plater()->can_add_plate(); }; // we can use can_add_plate here... + if (!m_main_toolbar.add_item(item)) + return false; + item.name = "orient"; item.icon_filename = m_is_dark ? "toolbar_orient_dark.svg" : "toolbar_orient.svg"; item.tooltip = _utf8(L("Auto orient")); diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index 4bb996f7ae3..a4456390f8d 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -159,7 +159,7 @@ wxDECLARE_EVENT(EVT_GLCANVAS_PLATE_RIGHT_CLICK, RBtnPlateEvent); wxDECLARE_EVENT(EVT_GLCANVAS_REMOVE_OBJECT, SimpleEvent); wxDECLARE_EVENT(EVT_GLCANVAS_ARRANGE, SimpleEvent); //BBS: add arrange and orient event -// wxDECLARE_EVENT(EVT_GLCANVAS_DUPLICATE_PLATE, SimpleEvent); +wxDECLARE_EVENT(EVT_GLCANVAS_DUPLICATE_PLATE, SimpleEvent); wxDECLARE_EVENT(EVT_GLCANVAS_ARRANGE_PARTPLATE, SimpleEvent); wxDECLARE_EVENT(EVT_GLCANVAS_ORIENT, SimpleEvent); wxDECLARE_EVENT(EVT_GLCANVAS_ORIENT_PARTPLATE, SimpleEvent); diff --git a/src/slic3r/GUI/GLToolbar.cpp b/src/slic3r/GUI/GLToolbar.cpp index be97e52e84a..354f76c88bc 100644 --- a/src/slic3r/GUI/GLToolbar.cpp +++ b/src/slic3r/GUI/GLToolbar.cpp @@ -39,6 +39,7 @@ wxDEFINE_EVENT(EVT_GLTOOLBAR_DELETE, SimpleEvent); wxDEFINE_EVENT(EVT_GLTOOLBAR_DELETE_ALL, SimpleEvent); wxDEFINE_EVENT(EVT_GLTOOLBAR_ADD_PLATE, SimpleEvent); wxDEFINE_EVENT(EVT_GLTOOLBAR_DEL_PLATE, SimpleEvent); +wxDEFINE_EVENT(EVT_GLTOOLBAR_DUPLICATE_PLATE, SimpleEvent); wxDEFINE_EVENT(EVT_GLTOOLBAR_ORIENT, SimpleEvent); wxDEFINE_EVENT(EVT_GLTOOLBAR_ARRANGE, SimpleEvent); wxDEFINE_EVENT(EVT_GLTOOLBAR_CUT, SimpleEvent); diff --git a/src/slic3r/GUI/GLToolbar.hpp b/src/slic3r/GUI/GLToolbar.hpp index 85413edc66d..c6acddb5610 100644 --- a/src/slic3r/GUI/GLToolbar.hpp +++ b/src/slic3r/GUI/GLToolbar.hpp @@ -39,6 +39,7 @@ wxDECLARE_EVENT(EVT_GLTOOLBAR_DELETE, SimpleEvent); wxDECLARE_EVENT(EVT_GLTOOLBAR_DELETE_ALL, SimpleEvent); wxDECLARE_EVENT(EVT_GLTOOLBAR_ADD_PLATE, SimpleEvent); wxDECLARE_EVENT(EVT_GLTOOLBAR_DEL_PLATE, SimpleEvent); +wxDECLARE_EVENT(EVT_GLTOOLBAR_DUPLICATE_PLATE, SimpleEvent); wxDECLARE_EVENT(EVT_GLTOOLBAR_ORIENT, SimpleEvent); wxDECLARE_EVENT(EVT_GLTOOLBAR_ARRANGE, SimpleEvent); wxDECLARE_EVENT(EVT_GLTOOLBAR_CUT, SimpleEvent); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 9a4a7018a18..bc1585bc029 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2949,10 +2949,10 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) view3D_canvas->Bind(EVT_GLCANVAS_OBJECT_SELECT, &priv::on_object_select, this); view3D_canvas->Bind(EVT_GLCANVAS_RIGHT_CLICK, &priv::on_right_click, this); //BBS: add part plate related logic - // view3D_canvas->Bind(EVT_GLCANVAS_DUPLICATE_PLATE, [this](SimpleEvent& evt){ - // this->q->set_prepare_state(Job::PREPARE_STATE_DEFAULT); - // this->q->duplicate_plate(); - // }); + view3D_canvas->Bind(EVT_GLCANVAS_DUPLICATE_PLATE, [this](SimpleEvent& evt){ + this->q->set_prepare_state(Job::PREPARE_STATE_DEFAULT); + this->q->duplicate_plate(); + }); view3D_canvas->Bind(EVT_GLCANVAS_PLATE_RIGHT_CLICK, &priv::on_plate_right_click, this); view3D_canvas->Bind(EVT_GLCANVAS_REMOVE_OBJECT, [q](SimpleEvent&) { q->remove_selected(); }); view3D_canvas->Bind(EVT_GLCANVAS_ARRANGE, [this](SimpleEvent& evt) { @@ -3006,6 +3006,10 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) view3D_canvas->Bind(EVT_GLTOOLBAR_ADD_PLATE, &priv::on_action_add_plate, this); view3D_canvas->Bind(EVT_GLTOOLBAR_DEL_PLATE, &priv::on_action_del_plate, this); + view3D_canvas->Bind(EVT_GLTOOLBAR_DUPLICATE_PLATE, [this](SimpleEvent& evt){ + this->q->set_prepare_state(Job::PREPARE_STATE_DEFAULT); + this->q->duplicate_plate(); + }); view3D_canvas->Bind(EVT_GLTOOLBAR_ORIENT, [this](SimpleEvent&) { //BBS arrage from EVT set default state. this->q->set_prepare_state(Job::PREPARE_STATE_DEFAULT); From 5f51b99819f2b013aed9ecabe258e948b1ca0a7e Mon Sep 17 00:00:00 2001 From: Erkan Ozgur Yilmaz Date: Fri, 31 May 2024 13:42:35 +0100 Subject: [PATCH 06/14] [#2025] Revert changes for `toolbar_add_plate_dark.svg`. --- resources/images/toolbar_add_plate_dark.svg | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/resources/images/toolbar_add_plate_dark.svg b/resources/images/toolbar_add_plate_dark.svg index f7aebca4f4b..a361368a181 100644 --- a/resources/images/toolbar_add_plate_dark.svg +++ b/resources/images/toolbar_add_plate_dark.svg @@ -1,14 +1 @@ - - - - - - \ No newline at end of file + \ No newline at end of file From 5d2b9e0b8c69d15e0abaf12d07a8080e4e6e6d40 Mon Sep 17 00:00:00 2001 From: Erkan Ozgur Yilmaz Date: Fri, 31 May 2024 13:47:31 +0100 Subject: [PATCH 07/14] [#2025] Removed the `BBS` label in the code that is not written by BBS. --- src/slic3r/GUI/Plater.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index bc1585bc029..06feea7fe55 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -7085,7 +7085,7 @@ void Plater::priv::on_action_del_plate(SimpleEvent&) } } -//BBS: duplicate plate from toolbar +// duplicate plate from toolbar void Plater::priv::on_action_duplicate_plate(SimpleEvent&) { if (q != nullptr) { From f007369444015f48d363f47dd272744a5e84db68 Mon Sep 17 00:00:00 2001 From: Erkan Ozgur Yilmaz Date: Sat, 1 Jun 2024 01:11:30 +0100 Subject: [PATCH 08/14] [#2025] Updated `.gitignore` to ignore VSCode workspace file. --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 8ba5bbc4ffa..3f66a360fde 100644 --- a/.gitignore +++ b/.gitignore @@ -34,4 +34,4 @@ src/OrcaSlicer-doc/ /deps/DL_CACHE **/.flatpak-builder/ resources/profiles/user/default -OrcaSlicer.code-workspace +*.code-workspace From 4e74f4f00dbb3316928e531417e883ff4f9ffb51 Mon Sep 17 00:00:00 2001 From: Erkan Ozgur Yilmaz Date: Sat, 1 Jun 2024 01:12:29 +0100 Subject: [PATCH 09/14] [#2025] Fixed the instances not transforming in global space when the plate is duplicated. --- src/slic3r/GUI/PartPlate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/slic3r/GUI/PartPlate.cpp b/src/slic3r/GUI/PartPlate.cpp index c433d04286e..e1700681eb1 100644 --- a/src/slic3r/GUI/PartPlate.cpp +++ b/src/slic3r/GUI/PartPlate.cpp @@ -3699,7 +3699,6 @@ int PartPlateList::duplicate_plate(int index) for (ModelObject* object : obj_ptrs){ // copy and move the object to the same relative position in the new plate ModelObject* object_copy = m_model->add_object(*object); - object_copy->translate(plate_to_plate_offset); int new_obj_id = new_plate->m_model->objects.size() - 1; // go over the instances and pair with the object for (size_t new_instance_id = 0; new_instance_id < object_copy->instances.size(); new_instance_id++){ @@ -3707,6 +3706,7 @@ int PartPlateList::duplicate_plate(int index) BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(": duplicate object into plate: index_pair [%1%,%2%], obj_id %3%") % new_obj_id % new_instance_id % object_copy->id().id; } } + new_plate->translate_all_instance(plate_to_plate_offset); // update the plates wxGetApp().obj_list()->reload_all_plates(); return new_plate_index; From 0f9a228a833bbb107ed380098a40ea28ba1edfac Mon Sep 17 00:00:00 2001 From: Erkan Ozgur Yilmaz Date: Sun, 8 Sep 2024 20:16:02 +0100 Subject: [PATCH 10/14] [#2025] Removed the Duplicate Plate action from the plate actions and the toolbar. --- src/slic3r/GUI/GLCanvas3D.cpp | 18 +++++------ src/slic3r/GUI/GLCanvas3D.hpp | 2 +- src/slic3r/GUI/GLToolbar.cpp | 2 +- src/slic3r/GUI/GLToolbar.hpp | 2 +- src/slic3r/GUI/PartPlate.cpp | 59 ++++++++++------------------------- src/slic3r/GUI/PartPlate.hpp | 7 ++--- src/slic3r/GUI/Plater.cpp | 31 +++--------------- 7 files changed, 34 insertions(+), 87 deletions(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 31ac27def95..364c91982c5 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -992,7 +992,7 @@ wxDEFINE_EVENT(EVT_GLCANVAS_PLATE_RIGHT_CLICK, RBtnPlateEvent); wxDEFINE_EVENT(EVT_GLCANVAS_REMOVE_OBJECT, SimpleEvent); wxDEFINE_EVENT(EVT_GLCANVAS_ARRANGE, SimpleEvent); //BBS: add arrange and orient event -wxDEFINE_EVENT(EVT_GLCANVAS_DUPLICATE_PLATE, SimpleEvent); +// wxDEFINE_EVENT(EVT_GLCANVAS_DUPLICATE_PLATE, SimpleEvent); wxDEFINE_EVENT(EVT_GLCANVAS_ARRANGE_PARTPLATE, SimpleEvent); wxDEFINE_EVENT(EVT_GLCANVAS_ORIENT, SimpleEvent); wxDEFINE_EVENT(EVT_GLCANVAS_ORIENT_PARTPLATE, SimpleEvent); @@ -6357,14 +6357,14 @@ bool GLCanvas3D::_init_main_toolbar() if (!m_main_toolbar.add_item(item)) return false; - item.name = "duplicateplate"; - item.icon_filename = m_is_dark ? "toolbar_duplicate_plate_dark.svg" : "toolbar_duplicate_plate.svg"; - item.tooltip = _utf8(L("Duplicate current plate")); - item.sprite_id++; - item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_DUPLICATE_PLATE)); }; - item.enabling_callback = []()->bool {return wxGetApp().plater()->can_add_plate(); }; // we can use can_add_plate here... - if (!m_main_toolbar.add_item(item)) - return false; + // item.name = "duplicateplate"; + // item.icon_filename = m_is_dark ? "toolbar_duplicate_plate_dark.svg" : "toolbar_duplicate_plate.svg"; + // item.tooltip = _utf8(L("Duplicate current plate")); + // item.sprite_id++; + // item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_DUPLICATE_PLATE)); }; + // item.enabling_callback = []()->bool {return wxGetApp().plater()->can_add_plate(); }; // we can use can_add_plate here... + // if (!m_main_toolbar.add_item(item)) + // return false; item.name = "orient"; item.icon_filename = m_is_dark ? "toolbar_orient_dark.svg" : "toolbar_orient.svg"; diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index a4456390f8d..4bb996f7ae3 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -159,7 +159,7 @@ wxDECLARE_EVENT(EVT_GLCANVAS_PLATE_RIGHT_CLICK, RBtnPlateEvent); wxDECLARE_EVENT(EVT_GLCANVAS_REMOVE_OBJECT, SimpleEvent); wxDECLARE_EVENT(EVT_GLCANVAS_ARRANGE, SimpleEvent); //BBS: add arrange and orient event -wxDECLARE_EVENT(EVT_GLCANVAS_DUPLICATE_PLATE, SimpleEvent); +// wxDECLARE_EVENT(EVT_GLCANVAS_DUPLICATE_PLATE, SimpleEvent); wxDECLARE_EVENT(EVT_GLCANVAS_ARRANGE_PARTPLATE, SimpleEvent); wxDECLARE_EVENT(EVT_GLCANVAS_ORIENT, SimpleEvent); wxDECLARE_EVENT(EVT_GLCANVAS_ORIENT_PARTPLATE, SimpleEvent); diff --git a/src/slic3r/GUI/GLToolbar.cpp b/src/slic3r/GUI/GLToolbar.cpp index 354f76c88bc..6703c2c6931 100644 --- a/src/slic3r/GUI/GLToolbar.cpp +++ b/src/slic3r/GUI/GLToolbar.cpp @@ -39,7 +39,7 @@ wxDEFINE_EVENT(EVT_GLTOOLBAR_DELETE, SimpleEvent); wxDEFINE_EVENT(EVT_GLTOOLBAR_DELETE_ALL, SimpleEvent); wxDEFINE_EVENT(EVT_GLTOOLBAR_ADD_PLATE, SimpleEvent); wxDEFINE_EVENT(EVT_GLTOOLBAR_DEL_PLATE, SimpleEvent); -wxDEFINE_EVENT(EVT_GLTOOLBAR_DUPLICATE_PLATE, SimpleEvent); +// wxDEFINE_EVENT(EVT_GLTOOLBAR_DUPLICATE_PLATE, SimpleEvent); wxDEFINE_EVENT(EVT_GLTOOLBAR_ORIENT, SimpleEvent); wxDEFINE_EVENT(EVT_GLTOOLBAR_ARRANGE, SimpleEvent); wxDEFINE_EVENT(EVT_GLTOOLBAR_CUT, SimpleEvent); diff --git a/src/slic3r/GUI/GLToolbar.hpp b/src/slic3r/GUI/GLToolbar.hpp index c6acddb5610..44528f88c33 100644 --- a/src/slic3r/GUI/GLToolbar.hpp +++ b/src/slic3r/GUI/GLToolbar.hpp @@ -39,7 +39,7 @@ wxDECLARE_EVENT(EVT_GLTOOLBAR_DELETE, SimpleEvent); wxDECLARE_EVENT(EVT_GLTOOLBAR_DELETE_ALL, SimpleEvent); wxDECLARE_EVENT(EVT_GLTOOLBAR_ADD_PLATE, SimpleEvent); wxDECLARE_EVENT(EVT_GLTOOLBAR_DEL_PLATE, SimpleEvent); -wxDECLARE_EVENT(EVT_GLTOOLBAR_DUPLICATE_PLATE, SimpleEvent); +// wxDECLARE_EVENT(EVT_GLTOOLBAR_DUPLICATE_PLATE, SimpleEvent); wxDECLARE_EVENT(EVT_GLTOOLBAR_ORIENT, SimpleEvent); wxDECLARE_EVENT(EVT_GLTOOLBAR_ARRANGE, SimpleEvent); wxDECLARE_EVENT(EVT_GLTOOLBAR_CUT, SimpleEvent); diff --git a/src/slic3r/GUI/PartPlate.cpp b/src/slic3r/GUI/PartPlate.cpp index e1700681eb1..c8c4d0b6c7b 100644 --- a/src/slic3r/GUI/PartPlate.cpp +++ b/src/slic3r/GUI/PartPlate.cpp @@ -997,27 +997,20 @@ void PartPlate::render_icons(bool bottom, bool only_name, int hover_id) render_icon_texture(m_del_icon.model, m_partplate_list->m_del_texture); if (hover_id == 2) { - render_icon_texture(m_duplicate_icon.model, m_partplate_list->m_duplicate_hovered_texture); - show_tooltip(_u8L("Duplicate current plate with objects")); - } - else - render_icon_texture(m_duplicate_icon.model, m_partplate_list->m_duplicate_texture); - - if (hover_id == 3) { render_icon_texture(m_orient_icon.model, m_partplate_list->m_orient_hovered_texture); show_tooltip(_u8L("Auto orient objects on current plate")); } else render_icon_texture(m_orient_icon.model, m_partplate_list->m_orient_texture); - if (hover_id == 4) { + if (hover_id == 3) { render_icon_texture(m_arrange_icon.model, m_partplate_list->m_arrange_hovered_texture); show_tooltip(_u8L("Arrange objects on current plate")); } else render_icon_texture(m_arrange_icon.model, m_partplate_list->m_arrange_texture); - if (hover_id == 5) { + if (hover_id == 4) { if (this->is_locked()) { render_icon_texture(m_lock_icon.model, m_partplate_list->m_locked_hovered_texture); @@ -1035,7 +1028,7 @@ void PartPlate::render_icons(bool bottom, bool only_name, int hover_id) render_icon_texture(m_lock_icon.model, m_partplate_list->m_lockopen_texture); } - if (hover_id == 7) { + if (hover_id == 6) { render_icon_texture(m_plate_name_edit_icon.model, m_partplate_list->m_plate_name_edit_hovered_texture); show_tooltip(_u8L("Edit current plate name")); } @@ -1044,7 +1037,7 @@ void PartPlate::render_icons(bool bottom, bool only_name, int hover_id) if (m_partplate_list->render_plate_settings) { bool has_plate_settings = get_bed_type() != BedType::btDefault || get_print_seq() != PrintSequence::ByDefault || !get_first_layer_print_sequence().empty() || !get_other_layers_print_sequence().empty() || has_spiral_mode_config(); - if (hover_id == 6) { + if (hover_id == 5) { if (!has_plate_settings) render_icon_texture(m_plate_settings_icon.model, m_partplate_list->m_plate_settings_hovered_texture); else @@ -1335,15 +1328,14 @@ void PartPlate::register_raycasters_for_picking(GLCanvas3D &canvas) { register_model_for_picking(canvas, m_triangles, picking_id_component(0)); register_model_for_picking(canvas, m_del_icon, picking_id_component(1)); - register_model_for_picking(canvas, m_duplicate_icon, picking_id_component(2)); - register_model_for_picking(canvas, m_orient_icon, picking_id_component(3)); - register_model_for_picking(canvas, m_arrange_icon, picking_id_component(4)); - register_model_for_picking(canvas, m_lock_icon, picking_id_component(5)); + register_model_for_picking(canvas, m_orient_icon, picking_id_component(2)); + register_model_for_picking(canvas, m_arrange_icon, picking_id_component(3)); + register_model_for_picking(canvas, m_lock_icon, picking_id_component(4)); if (m_partplate_list->render_plate_settings) - register_model_for_picking(canvas, m_plate_settings_icon, picking_id_component(6)); + register_model_for_picking(canvas, m_plate_settings_icon, picking_id_component(5)); - canvas.remove_raycasters_for_picking(SceneRaycaster::EType::Bed, picking_id_component(7)); - register_model_for_picking(canvas, m_plate_name_edit_icon, picking_id_component(7)); + canvas.remove_raycasters_for_picking(SceneRaycaster::EType::Bed, picking_id_component(6)); + register_model_for_picking(canvas, m_plate_name_edit_icon, picking_id_component(6)); } int PartPlate::picking_id_component(int idx) const @@ -1919,9 +1911,9 @@ void PartPlate::generate_plate_name_texture() BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << "Unable to generate geometry buffers for icons\n"; auto canvas = this->m_partplate_list->m_plater->get_view3D_canvas3D(); - canvas->remove_raycasters_for_picking(SceneRaycaster::EType::Bed, picking_id_component(7)); + canvas->remove_raycasters_for_picking(SceneRaycaster::EType::Bed, picking_id_component(6)); calc_vertex_for_plate_name_edit_icon(&m_name_texture, 0, m_plate_name_edit_icon); - register_model_for_picking(*canvas, m_plate_name_edit_icon, picking_id_component(7)); + register_model_for_picking(*canvas, m_plate_name_edit_icon, picking_id_component(6)); } void PartPlate::set_plate_name(const std::string& name) { @@ -2716,11 +2708,10 @@ bool PartPlate::set_shape(const Pointfs& shape, const Pointfs& exclude_areas, Ve //calc_vertex_for_icons_background(5, m_del_and_background_icon); //calc_vertex_for_icons(4, m_del_icon); calc_vertex_for_icons(0, m_del_icon); - calc_vertex_for_icons(1, m_duplicate_icon); - calc_vertex_for_icons(2, m_orient_icon); - calc_vertex_for_icons(3, m_arrange_icon); - calc_vertex_for_icons(4, m_lock_icon); - calc_vertex_for_icons(5, m_plate_settings_icon); + calc_vertex_for_icons(1, m_orient_icon); + calc_vertex_for_icons(2, m_arrange_icon); + calc_vertex_for_icons(3, m_lock_icon); + calc_vertex_for_icons(4, m_plate_settings_icon); //calc_vertex_for_number(0, (m_plate_index < 9), m_plate_idx_icon); calc_vertex_for_number(0, false, m_plate_idx_icon); if (m_plater) { @@ -3293,22 +3284,6 @@ void PartPlateList::generate_icon_textures() } } - //if (m_duplicate_texture.get_id() == 0) - { - file_name = path + (m_is_dark ? "plate_duplicate_dark.svg" : "plate_duplicate.svg"); - if (!m_duplicate_texture.load_from_svg_file(file_name, true, false, false, icon_size)) { - BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(":load file %1% failed") % file_name; - } - } - - //if (m_duplicate_hovered_texture.get_id() == 0) - { - file_name = path + (m_is_dark ? "plate_duplicate_hover_dark.svg" : "plate_duplicate_hover.svg"); - if (!m_duplicate_hovered_texture.load_from_svg_file(file_name, true, false, false, icon_size)) { - BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << boost::format(":load file %1% failed") % file_name; - } - } - //if (m_arrange_texture.get_id() == 0) { file_name = path + (m_is_dark ? "plate_arrange_dark.svg" : "plate_arrange.svg"); @@ -3444,8 +3419,6 @@ void PartPlateList::release_icon_textures() m_logo_texture.reset(); m_del_texture.reset(); m_del_hovered_texture.reset(); - m_duplicate_texture.reset(); - m_duplicate_hovered_texture.reset(); m_arrange_texture.reset(); m_arrange_hovered_texture.reset(); m_orient_texture.reset(); diff --git a/src/slic3r/GUI/PartPlate.hpp b/src/slic3r/GUI/PartPlate.hpp index 4ca38d7eb47..0f2a5f241d2 100644 --- a/src/slic3r/GUI/PartPlate.hpp +++ b/src/slic3r/GUI/PartPlate.hpp @@ -136,7 +136,6 @@ class PartPlate : public ObjectBase GLModel m_height_limit_bottom; GLModel m_height_limit_top; PickingModel m_del_icon; - PickingModel m_duplicate_icon; PickingModel m_arrange_icon; PickingModel m_orient_icon; PickingModel m_lock_icon; @@ -199,8 +198,8 @@ class PartPlate : public ObjectBase public: static const unsigned int PLATE_BASE_ID = 255 * 255 * 253; - static const unsigned int PLATE_NAME_HOVER_ID = 7; - static const unsigned int GRABBER_COUNT = 8; + static const unsigned int PLATE_NAME_HOVER_ID = 6; + static const unsigned int GRABBER_COUNT = 7; static ColorRGBA SELECT_COLOR; static ColorRGBA UNSELECT_COLOR; @@ -547,8 +546,6 @@ class PartPlateList : public ObjectBase GLTexture m_logo_texture; GLTexture m_del_texture; GLTexture m_del_hovered_texture; - GLTexture m_duplicate_texture; - GLTexture m_duplicate_hovered_texture; GLTexture m_arrange_texture; GLTexture m_arrange_hovered_texture; GLTexture m_orient_texture; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 06feea7fe55..16f6f364816 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2558,7 +2558,6 @@ struct Plater::priv void on_action_add(SimpleEvent&); void on_action_add_plate(SimpleEvent&); void on_action_del_plate(SimpleEvent&); - void on_action_duplicate_plate(SimpleEvent&); void on_action_split_objects(SimpleEvent&); void on_action_split_volumes(SimpleEvent&); void on_action_layersediting(SimpleEvent&); @@ -2949,10 +2948,6 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) view3D_canvas->Bind(EVT_GLCANVAS_OBJECT_SELECT, &priv::on_object_select, this); view3D_canvas->Bind(EVT_GLCANVAS_RIGHT_CLICK, &priv::on_right_click, this); //BBS: add part plate related logic - view3D_canvas->Bind(EVT_GLCANVAS_DUPLICATE_PLATE, [this](SimpleEvent& evt){ - this->q->set_prepare_state(Job::PREPARE_STATE_DEFAULT); - this->q->duplicate_plate(); - }); view3D_canvas->Bind(EVT_GLCANVAS_PLATE_RIGHT_CLICK, &priv::on_plate_right_click, this); view3D_canvas->Bind(EVT_GLCANVAS_REMOVE_OBJECT, [q](SimpleEvent&) { q->remove_selected(); }); view3D_canvas->Bind(EVT_GLCANVAS_ARRANGE, [this](SimpleEvent& evt) { @@ -3006,10 +3001,6 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) view3D_canvas->Bind(EVT_GLTOOLBAR_ADD_PLATE, &priv::on_action_add_plate, this); view3D_canvas->Bind(EVT_GLTOOLBAR_DEL_PLATE, &priv::on_action_del_plate, this); - view3D_canvas->Bind(EVT_GLTOOLBAR_DUPLICATE_PLATE, [this](SimpleEvent& evt){ - this->q->set_prepare_state(Job::PREPARE_STATE_DEFAULT); - this->q->duplicate_plate(); - }); view3D_canvas->Bind(EVT_GLTOOLBAR_ORIENT, [this](SimpleEvent&) { //BBS arrage from EVT set default state. this->q->set_prepare_state(Job::PREPARE_STATE_DEFAULT); @@ -7085,15 +7076,6 @@ void Plater::priv::on_action_del_plate(SimpleEvent&) } } -// duplicate plate from toolbar -void Plater::priv::on_action_duplicate_plate(SimpleEvent&) -{ - if (q != nullptr) { - // without a plate index this will duplicate the current plate only - q->duplicate_plate(); - } -} - //BBS: GUI refactor: GLToolbar void Plater::priv::on_action_open_project(SimpleEvent&) { @@ -13930,11 +13912,6 @@ int Plater::select_plate_by_hover_id(int hover_id, bool right_click, bool isModi ret = delete_plate(plate_index); } else if ((action == 2)&&(!right_click)) - { - // duplicate plate - ret = duplicate_plate(plate_index); - } - else if ((action == 3)&&(!right_click)) { //arrange the plate //take_snapshot("select_orient partplate"); @@ -13950,7 +13927,7 @@ int Plater::select_plate_by_hover_id(int hover_id, bool right_click, bool isModi ret = -1; } } - else if ((action == 4)&&(!right_click)) + else if ((action == 3)&&(!right_click)) { //arrange the plate //take_snapshot("select_arrange partplate"); @@ -13968,13 +13945,13 @@ int Plater::select_plate_by_hover_id(int hover_id, bool right_click, bool isModi ret = -1; } } - else if ((action == 5)&&(!right_click)) + else if ((action == 4)&&(!right_click)) { //lock the plate take_snapshot("lock partplate"); ret = p->partplate_list.lock_plate(plate_index, !p->partplate_list.is_locked(plate_index)); } - else if ((action == 6)&&(!right_click)) + else if ((action == 5)&&(!right_click)) { // set the plate type ret = select_plate(plate_index); @@ -13990,7 +13967,7 @@ int Plater::select_plate_by_hover_id(int hover_id, bool right_click, bool isModi ret = -1; } } - else if ((action == 7) && (!right_click)) { + else if ((action == 6) && (!right_click)) { // set the plate type ret = select_plate(plate_index); if (!ret) { From 9b6b3f4cf5393cb71722128dba612bbe02eec925 Mon Sep 17 00:00:00 2001 From: Erkan Ozgur Yilmaz Date: Sun, 8 Sep 2024 20:16:08 +0100 Subject: [PATCH 11/14] [#2025] Added the `Duplicate Current Plate` functionality to the `Edit` menu. --- src/slic3r/GUI/MainFrame.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 38c9deb295f..26a96ec9b4e 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -2433,6 +2433,12 @@ void MainFrame::init_menubar_as_editor() }, "menu_remove", nullptr, [this](){return can_clone(); }, this); editMenu->AppendSeparator(); + append_menu_item(editMenu, wxID_ANY, _L("Duplicate Current Plate"), + _L("Duplicate the current plate"),[this](wxCommandEvent&) { + m_plater->duplicate_plate(); + }, + "menu_remove", nullptr, [this](){return true;}, this); + editMenu->AppendSeparator(); #else // BBS undo append_menu_item(editMenu, wxID_ANY, _L("Undo") + "\t" + ctrl + "Z", @@ -2530,6 +2536,13 @@ void MainFrame::init_menubar_as_editor() }, "", nullptr, [this](){return can_clone(); }, this); editMenu->AppendSeparator(); + append_menu_item(editMenu, wxID_ANY, _L("Duplicate Current Plate"), + _L("Duplicate the current plate"),[this, handle_key_event](wxCommandEvent&) { + m_plater->duplicate_plate(); + }, + "", nullptr, [this](){return true;}, this); + editMenu->AppendSeparator(); + #endif // BBS Select All From f26f4d60b22a0f9d149b83197364f2052db40815 Mon Sep 17 00:00:00 2001 From: Erkan Ozgur Yilmaz Date: Tue, 10 Sep 2024 16:15:59 +0100 Subject: [PATCH 12/14] [#2025] Addressed review comments. --- src/slic3r/GUI/GLCanvas3D.cpp | 13 ------------- src/slic3r/GUI/GLCanvas3D.hpp | 1 - src/slic3r/GUI/Plater.cpp | 4 ++-- 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 364c91982c5..be6c8d8289e 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -992,7 +992,6 @@ wxDEFINE_EVENT(EVT_GLCANVAS_PLATE_RIGHT_CLICK, RBtnPlateEvent); wxDEFINE_EVENT(EVT_GLCANVAS_REMOVE_OBJECT, SimpleEvent); wxDEFINE_EVENT(EVT_GLCANVAS_ARRANGE, SimpleEvent); //BBS: add arrange and orient event -// wxDEFINE_EVENT(EVT_GLCANVAS_DUPLICATE_PLATE, SimpleEvent); wxDEFINE_EVENT(EVT_GLCANVAS_ARRANGE_PARTPLATE, SimpleEvent); wxDEFINE_EVENT(EVT_GLCANVAS_ORIENT, SimpleEvent); wxDEFINE_EVENT(EVT_GLCANVAS_ORIENT_PARTPLATE, SimpleEvent); @@ -6242,9 +6241,6 @@ void GLCanvas3D::_switch_toolbars_icon_filename() item = m_main_toolbar.get_item("addplate"); item->set_icon_filename(m_is_dark ? "toolbar_add_plate_dark.svg" : "toolbar_add_plate.svg"); - item = m_main_toolbar.get_item("duplicateplate"); - item->set_icon_filename(m_is_dark ? "toolbar_duplicate_plate_dark.svg" : "toolbar_duplicate_plate.svg"); - item = m_main_toolbar.get_item("orient"); item->set_icon_filename(m_is_dark ? "toolbar_orient_dark.svg" : "toolbar_orient.svg"); @@ -6357,15 +6353,6 @@ bool GLCanvas3D::_init_main_toolbar() if (!m_main_toolbar.add_item(item)) return false; - // item.name = "duplicateplate"; - // item.icon_filename = m_is_dark ? "toolbar_duplicate_plate_dark.svg" : "toolbar_duplicate_plate.svg"; - // item.tooltip = _utf8(L("Duplicate current plate")); - // item.sprite_id++; - // item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_DUPLICATE_PLATE)); }; - // item.enabling_callback = []()->bool {return wxGetApp().plater()->can_add_plate(); }; // we can use can_add_plate here... - // if (!m_main_toolbar.add_item(item)) - // return false; - item.name = "orient"; item.icon_filename = m_is_dark ? "toolbar_orient_dark.svg" : "toolbar_orient.svg"; item.tooltip = _utf8(L("Auto orient")); diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index 4bb996f7ae3..2d67401d5f8 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -159,7 +159,6 @@ wxDECLARE_EVENT(EVT_GLCANVAS_PLATE_RIGHT_CLICK, RBtnPlateEvent); wxDECLARE_EVENT(EVT_GLCANVAS_REMOVE_OBJECT, SimpleEvent); wxDECLARE_EVENT(EVT_GLCANVAS_ARRANGE, SimpleEvent); //BBS: add arrange and orient event -// wxDECLARE_EVENT(EVT_GLCANVAS_DUPLICATE_PLATE, SimpleEvent); wxDECLARE_EVENT(EVT_GLCANVAS_ARRANGE_PARTPLATE, SimpleEvent); wxDECLARE_EVENT(EVT_GLCANVAS_ORIENT, SimpleEvent); wxDECLARE_EVENT(EVT_GLCANVAS_ORIENT_PARTPLATE, SimpleEvent); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 16f6f364816..203ba175af9 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -3002,11 +3002,11 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) view3D_canvas->Bind(EVT_GLTOOLBAR_ADD_PLATE, &priv::on_action_add_plate, this); view3D_canvas->Bind(EVT_GLTOOLBAR_DEL_PLATE, &priv::on_action_del_plate, this); view3D_canvas->Bind(EVT_GLTOOLBAR_ORIENT, [this](SimpleEvent&) { - //BBS arrage from EVT set default state. + //BBS arrange from EVT set default state. this->q->set_prepare_state(Job::PREPARE_STATE_DEFAULT); this->q->orient(); }); view3D_canvas->Bind(EVT_GLTOOLBAR_ARRANGE, [this](SimpleEvent&) { - //BBS arrage from EVT set default state. + //BBS arrange from EVT set default state. this->q->set_prepare_state(Job::PREPARE_STATE_DEFAULT); this->q->arrange(); }); From 33d75cbcdf80de1cb49dce83d0ad6b6a67581c1d Mon Sep 17 00:00:00 2001 From: Erkan Ozgur Yilmaz Date: Tue, 10 Sep 2024 16:34:14 +0100 Subject: [PATCH 13/14] [#2025] Addressed review comments. --- src/slic3r/GUI/GLToolbar.cpp | 1 - src/slic3r/GUI/GLToolbar.hpp | 1 - 2 files changed, 2 deletions(-) diff --git a/src/slic3r/GUI/GLToolbar.cpp b/src/slic3r/GUI/GLToolbar.cpp index 6703c2c6931..be97e52e84a 100644 --- a/src/slic3r/GUI/GLToolbar.cpp +++ b/src/slic3r/GUI/GLToolbar.cpp @@ -39,7 +39,6 @@ wxDEFINE_EVENT(EVT_GLTOOLBAR_DELETE, SimpleEvent); wxDEFINE_EVENT(EVT_GLTOOLBAR_DELETE_ALL, SimpleEvent); wxDEFINE_EVENT(EVT_GLTOOLBAR_ADD_PLATE, SimpleEvent); wxDEFINE_EVENT(EVT_GLTOOLBAR_DEL_PLATE, SimpleEvent); -// wxDEFINE_EVENT(EVT_GLTOOLBAR_DUPLICATE_PLATE, SimpleEvent); wxDEFINE_EVENT(EVT_GLTOOLBAR_ORIENT, SimpleEvent); wxDEFINE_EVENT(EVT_GLTOOLBAR_ARRANGE, SimpleEvent); wxDEFINE_EVENT(EVT_GLTOOLBAR_CUT, SimpleEvent); diff --git a/src/slic3r/GUI/GLToolbar.hpp b/src/slic3r/GUI/GLToolbar.hpp index 44528f88c33..85413edc66d 100644 --- a/src/slic3r/GUI/GLToolbar.hpp +++ b/src/slic3r/GUI/GLToolbar.hpp @@ -39,7 +39,6 @@ wxDECLARE_EVENT(EVT_GLTOOLBAR_DELETE, SimpleEvent); wxDECLARE_EVENT(EVT_GLTOOLBAR_DELETE_ALL, SimpleEvent); wxDECLARE_EVENT(EVT_GLTOOLBAR_ADD_PLATE, SimpleEvent); wxDECLARE_EVENT(EVT_GLTOOLBAR_DEL_PLATE, SimpleEvent); -// wxDECLARE_EVENT(EVT_GLTOOLBAR_DUPLICATE_PLATE, SimpleEvent); wxDECLARE_EVENT(EVT_GLTOOLBAR_ORIENT, SimpleEvent); wxDECLARE_EVENT(EVT_GLTOOLBAR_ARRANGE, SimpleEvent); wxDECLARE_EVENT(EVT_GLTOOLBAR_CUT, SimpleEvent); From 3ab0497e869d86bee5b043dcb8733a3914bfa4d2 Mon Sep 17 00:00:00 2001 From: Erkan Ozgur Yilmaz Date: Tue, 10 Sep 2024 16:38:24 +0100 Subject: [PATCH 14/14] [#2025] Removed unused icons related to the previously introduced "Duplicate Plate" functionality. --- resources/images/plate_duplicate.svg | 16 ---------------- resources/images/plate_duplicate_dark.svg | 16 ---------------- resources/images/plate_duplicate_hover.svg | 16 ---------------- resources/images/plate_duplicate_hover_dark.svg | 16 ---------------- resources/images/toolbar_duplicate_plate.svg | 14 -------------- .../images/toolbar_duplicate_plate_dark.svg | 14 -------------- 6 files changed, 92 deletions(-) delete mode 100644 resources/images/plate_duplicate.svg delete mode 100644 resources/images/plate_duplicate_dark.svg delete mode 100644 resources/images/plate_duplicate_hover.svg delete mode 100644 resources/images/plate_duplicate_hover_dark.svg delete mode 100644 resources/images/toolbar_duplicate_plate.svg delete mode 100644 resources/images/toolbar_duplicate_plate_dark.svg diff --git a/resources/images/plate_duplicate.svg b/resources/images/plate_duplicate.svg deleted file mode 100644 index 9a38bd892cc..00000000000 --- a/resources/images/plate_duplicate.svg +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/resources/images/plate_duplicate_dark.svg b/resources/images/plate_duplicate_dark.svg deleted file mode 100644 index 9c489044bee..00000000000 --- a/resources/images/plate_duplicate_dark.svg +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/resources/images/plate_duplicate_hover.svg b/resources/images/plate_duplicate_hover.svg deleted file mode 100644 index 679683ac6ec..00000000000 --- a/resources/images/plate_duplicate_hover.svg +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/resources/images/plate_duplicate_hover_dark.svg b/resources/images/plate_duplicate_hover_dark.svg deleted file mode 100644 index 26e4ce7e12d..00000000000 --- a/resources/images/plate_duplicate_hover_dark.svg +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/resources/images/toolbar_duplicate_plate.svg b/resources/images/toolbar_duplicate_plate.svg deleted file mode 100644 index 9df643fe4bf..00000000000 --- a/resources/images/toolbar_duplicate_plate.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/resources/images/toolbar_duplicate_plate_dark.svg b/resources/images/toolbar_duplicate_plate_dark.svg deleted file mode 100644 index d8f81a52daf..00000000000 --- a/resources/images/toolbar_duplicate_plate_dark.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - \ No newline at end of file