Feature/move plate to the front (#6262)

* WIP:only works after saving and then reloading

* working version of move plate to the front

* added icons for move to front

* removed a commented line

* fixed the move to front function to behave correctly with undo/redo actions

* Merge branch 'main' into feature/move_plate_to_the_front
This commit is contained in:
Azi 2024-09-25 04:27:45 -07:00 committed by GitHub
parent 473c7fb3ef
commit 8d9ec11fe9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 349 additions and 1 deletions

View file

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
width="43"
height="43"
viewBox="0 0 43 43"
version="1.1"
id="svg2"
sodipodi:docname="plate_move_front.svg"
inkscape:version="1.3.2 (091e20e, 2023-11-25, custom)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs2" />
<sodipodi:namedview
id="namedview2"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:zoom="22.627417"
inkscape:cx="25.168582"
inkscape:cy="21.588854"
inkscape:window-width="1610"
inkscape:window-height="1237"
inkscape:window-x="33"
inkscape:window-y="721"
inkscape:window-maximized="0"
inkscape:current-layer="svg2" />
<rect
x="1.5"
y="1.5"
width="40"
height="40"
rx="3.5"
style="fill:#e9e9e9;fill-opacity:1"
id="rect1" />
<path
d="M38,2a3,3,0,0,1,3,3V38a3,3,0,0,1-3,3H5a3,3,0,0,1-3-3V5A3,3,0,0,1,5,2H38m0-1H5A4,4,0,0,0,1,5V38a4,4,0,0,0,4,4H38a4,4,0,0,0,4-4V5a4,4,0,0,0-4-4Z"
style="fill:#545454"
id="path1" />
<line
x1="33.471352"
y1="6.9334393"
x2="9.9450846"
y2="6.9334393"
style="fill:none;stroke:#545454;stroke-width:0.850459;stroke-linecap:round;stroke-linejoin:round"
id="line1" />
<line
x1="32.300442"
y1="18.26045"
x2="21.987902"
y2="8.080493"
style="fill:none;stroke:#545454;stroke-width:0.714338;stroke-linecap:round;stroke-linejoin:round"
id="line1-1" />
<line
x1="11.504755"
y1="18.329735"
x2="21.855713"
y2="8.0229683"
style="fill:none;stroke:#545454;stroke-width:0.720111;stroke-linecap:round;stroke-linejoin:round"
id="line1-1-1" />
<line
x1="21.938486"
y1="36.433311"
x2="21.938484"
y2="8.6247864"
style="fill:none;stroke:#545454;stroke-width:0.623622;stroke-linecap:round;stroke-linejoin:round"
id="line1-1-1-2" />
</svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

View file

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
width="43"
height="43"
viewBox="0 0 43 43"
version="1.1"
id="svg2"
sodipodi:docname="plate_close_dark.svg"
inkscape:version="1.3.2 (091e20e, 2023-11-25, custom)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs2" />
<sodipodi:namedview
id="namedview2"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:zoom="27.27907"
inkscape:cx="21.5"
inkscape:cy="21.5"
inkscape:window-width="2560"
inkscape:window-height="1369"
inkscape:window-x="-8"
inkscape:window-y="658"
inkscape:window-maximized="1"
inkscape:current-layer="svg2" />
<rect
x="1.5"
y="1.5"
width="40"
height="40"
rx="3.5"
style="fill:#54545a"
id="rect1" />
<path
d="M38,2a3,3,0,0,1,3,3V38a3,3,0,0,1-3,3H5a3,3,0,0,1-3-3V5A3,3,0,0,1,5,2H38m0-1H5A4,4,0,0,0,1,5V38a4,4,0,0,0,4,4H38a4,4,0,0,0,4-4V5a4,4,0,0,0-4-4Z"
style="fill:#b3b3b3"
id="path1" />
<line
x1="9.7239828"
y1="6.5068207"
x2="34.155807"
y2="6.5068207"
style="fill:none;stroke:#c4c4c4;stroke-width:0.866675;stroke-linecap:round;stroke-linejoin:round"
id="line1" />
<line
x1="22.228071"
y1="7.6491632"
x2="22.228073"
y2="31.964647"
style="fill:none;stroke:#c4c4c4;stroke-linecap:round;stroke-linejoin:round"
id="line1-2" />
<line
x1="22.195042"
y1="7.4747553"
x2="10.588115"
y2="19.081686"
style="fill:none;stroke:#c4c4c4;stroke-width:0.675072;stroke-linecap:round;stroke-linejoin:round"
id="line1-2-2" />
<line
x1="33.868591"
y1="19.080866"
x2="22.261658"
y2="7.4739408"
style="fill:none;stroke:#c4c4c4;stroke-width:0.675072;stroke-linecap:round;stroke-linejoin:round"
id="line1-2-2-7" />
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

View file

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
width="43"
height="43"
viewBox="0 0 43 43"
version="1.1"
id="svg2"
sodipodi:docname="plate_close.svg"
inkscape:version="1.3.2 (091e20e, 2023-11-25, custom)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs2" />
<sodipodi:namedview
id="namedview2"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:zoom="22.627417"
inkscape:cx="25.168582"
inkscape:cy="21.588854"
inkscape:window-width="1610"
inkscape:window-height="1237"
inkscape:window-x="1460"
inkscape:window-y="754"
inkscape:window-maximized="0"
inkscape:current-layer="svg2" />
<rect
x="1.5"
y="1.5"
width="40"
height="40"
rx="3.5"
style="fill:#e9e9e9;fill-opacity:1"
id="rect1" />
<path
d="M38,2a3,3,0,0,1,3,3V38a3,3,0,0,1-3,3H5a3,3,0,0,1-3-3V5A3,3,0,0,1,5,2H38m0-1H5A4,4,0,0,0,1,5V38a4,4,0,0,0,4,4H38a4,4,0,0,0,4-4V5a4,4,0,0,0-4-4Z"
style="fill:#009688"
id="path1" />
<line
x1="33.471352"
y1="6.9334393"
x2="9.9450846"
y2="6.9334393"
style="fill:none;stroke:#009688;stroke-width:0.850459;stroke-linecap:round;stroke-linejoin:round"
id="line1" />
<line
x1="32.300442"
y1="18.26045"
x2="21.987902"
y2="8.080493"
style="fill:none;stroke:#009688;stroke-width:0.714338;stroke-linecap:round;stroke-linejoin:round"
id="line1-1" />
<line
x1="11.504755"
y1="18.329735"
x2="21.855713"
y2="8.0229683"
style="fill:none;stroke:#009688;stroke-width:0.720111;stroke-linecap:round;stroke-linejoin:round"
id="line1-1-1" />
<line
x1="21.938486"
y1="36.433311"
x2="21.938484"
y2="8.6247864"
style="fill:none;stroke:#009688;stroke-width:0.623622;stroke-linecap:round;stroke-linejoin:round"
id="line1-1-1-2" />
</svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

View file

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
width="43"
height="43"
viewBox="0 0 43 43"
version="1.1"
id="svg2"
sodipodi:docname="plate_move_front_hover_dark.svg"
inkscape:version="1.3.2 (091e20e, 2023-11-25, custom)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs2" />
<sodipodi:namedview
id="namedview2"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:zoom="19.289215"
inkscape:cx="20.555528"
inkscape:cy="24.85845"
inkscape:window-width="1350"
inkscape:window-height="1237"
inkscape:window-x="36"
inkscape:window-y="759"
inkscape:window-maximized="0"
inkscape:current-layer="svg2" />
<rect
x="1.5"
y="1.5"
width="40"
height="40"
rx="3.5"
style="fill:#54545a"
id="rect1" />
<path
d="M38,2a3,3,0,0,1,3,3V38a3,3,0,0,1-3,3H5a3,3,0,0,1-3-3V5A3,3,0,0,1,5,2H38m0-1H5A4,4,0,0,0,1,5V38a4,4,0,0,0,4,4H38a4,4,0,0,0,4-4V5a4,4,0,0,0-4-4Z"
style="fill:#009688"
id="path1" />
<line
x1="9.7239828"
y1="6.5068207"
x2="34.155807"
y2="6.5068207"
style="fill:none;stroke:#009688;stroke-width:0.866675;stroke-linecap:round;stroke-linejoin:round"
id="line1" />
<line
x1="22.228071"
y1="7.6491632"
x2="22.228073"
y2="31.964647"
style="fill:none;stroke:#009688;stroke-linecap:round;stroke-linejoin:round"
id="line1-2" />
<line
x1="22.195042"
y1="7.4747553"
x2="10.588115"
y2="19.081686"
style="fill:none;stroke:#009688;stroke-width:0.675072;stroke-linecap:round;stroke-linejoin:round"
id="line1-2-2" />
<line
x1="33.868591"
y1="19.080866"
x2="22.261658"
y2="7.4739408"
style="fill:none;stroke:#009688;stroke-width:0.675072;stroke-linecap:round;stroke-linejoin:round"
id="line1-2-2-7" />
</svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

View file

@ -1035,6 +1035,13 @@ void PartPlate::render_icons(bool bottom, bool only_name, int hover_id)
else else
render_icon_texture(m_plate_name_edit_icon.model, m_partplate_list->m_plate_name_edit_texture); render_icon_texture(m_plate_name_edit_icon.model, m_partplate_list->m_plate_name_edit_texture);
if (hover_id == 7) {
render_icon_texture(m_move_front_icon.model, m_partplate_list->m_move_front_hovered_texture);
show_tooltip("Move plate to the front");
} else
render_icon_texture(m_move_front_icon.model, m_partplate_list->m_move_front_texture);
if (m_partplate_list->render_plate_settings) { 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(); 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 == 5) {
@ -1336,6 +1343,7 @@ void PartPlate::register_raycasters_for_picking(GLCanvas3D &canvas)
canvas.remove_raycasters_for_picking(SceneRaycaster::EType::Bed, 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)); register_model_for_picking(canvas, m_plate_name_edit_icon, picking_id_component(6));
register_model_for_picking(canvas, m_move_front_icon, picking_id_component(7));
} }
int PartPlate::picking_id_component(int idx) const int PartPlate::picking_id_component(int idx) const
@ -2712,6 +2720,7 @@ bool PartPlate::set_shape(const Pointfs& shape, const Pointfs& exclude_areas, Ve
calc_vertex_for_icons(2, m_arrange_icon); calc_vertex_for_icons(2, m_arrange_icon);
calc_vertex_for_icons(3, m_lock_icon); calc_vertex_for_icons(3, m_lock_icon);
calc_vertex_for_icons(4, m_plate_settings_icon); calc_vertex_for_icons(4, m_plate_settings_icon);
calc_vertex_for_icons(5, m_move_front_icon);
//calc_vertex_for_number(0, (m_plate_index < 9), m_plate_idx_icon); //calc_vertex_for_number(0, (m_plate_index < 9), m_plate_idx_icon);
calc_vertex_for_number(0, false, m_plate_idx_icon); calc_vertex_for_number(0, false, m_plate_idx_icon);
if (m_plater) { if (m_plater) {
@ -3284,6 +3293,23 @@ void PartPlateList::generate_icon_textures()
} }
} }
// if (m_move_front_texture.get_id() == 0)
{
file_name = path + (m_is_dark ? "plate_move_front_dark.svg" : "plate_move_front.svg");
if (!m_move_front_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_move_front_hovered_texture.get_id() == 0)
{
file_name = path + (m_is_dark ? "plate_move_front_hover_dark.svg" : "plate_move_front_hover.svg");
if (!m_move_front_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) //if (m_arrange_texture.get_id() == 0)
{ {
file_name = path + (m_is_dark ? "plate_arrange_dark.svg" : "plate_arrange.svg"); file_name = path + (m_is_dark ? "plate_arrange_dark.svg" : "plate_arrange.svg");
@ -3419,6 +3445,8 @@ void PartPlateList::release_icon_textures()
m_logo_texture.reset(); m_logo_texture.reset();
m_del_texture.reset(); m_del_texture.reset();
m_del_hovered_texture.reset(); m_del_hovered_texture.reset();
m_move_front_hovered_texture.reset();
m_move_front_texture.reset();
m_arrange_texture.reset(); m_arrange_texture.reset();
m_arrange_hovered_texture.reset(); m_arrange_hovered_texture.reset();
m_orient_texture.reset(); m_orient_texture.reset();
@ -3580,6 +3608,13 @@ void PartPlateList::reinit()
/*basic plate operations*/ /*basic plate operations*/
//create an empty plate, and return its index //create an empty plate, and return its index
//these model instances which are not in any plates should not be affected also //these model instances which are not in any plates should not be affected also
void PartPlateList::update_plates()
{
update_all_plates_pos_and_size(true, false);
set_shapes(m_shape, m_exclude_areas, m_logo_texture_filename, m_height_to_lid, m_height_to_rod);
}
int PartPlateList::create_plate(bool adjust_position) int PartPlateList::create_plate(bool adjust_position)
{ {
PartPlate* plate = NULL; PartPlate* plate = NULL;

View file

@ -141,6 +141,7 @@ private:
PickingModel m_lock_icon; PickingModel m_lock_icon;
PickingModel m_plate_settings_icon; PickingModel m_plate_settings_icon;
PickingModel m_plate_name_edit_icon; PickingModel m_plate_name_edit_icon;
PickingModel m_move_front_icon;
GLModel m_plate_idx_icon; GLModel m_plate_idx_icon;
GLTexture m_texture; GLTexture m_texture;
@ -199,7 +200,7 @@ private:
public: public:
static const unsigned int PLATE_BASE_ID = 255 * 255 * 253; static const unsigned int PLATE_BASE_ID = 255 * 255 * 253;
static const unsigned int PLATE_NAME_HOVER_ID = 6; static const unsigned int PLATE_NAME_HOVER_ID = 6;
static const unsigned int GRABBER_COUNT = 7; static const unsigned int GRABBER_COUNT = 8;
static ColorRGBA SELECT_COLOR; static ColorRGBA SELECT_COLOR;
static ColorRGBA UNSELECT_COLOR; static ColorRGBA UNSELECT_COLOR;
@ -546,6 +547,8 @@ class PartPlateList : public ObjectBase
GLTexture m_logo_texture; GLTexture m_logo_texture;
GLTexture m_del_texture; GLTexture m_del_texture;
GLTexture m_del_hovered_texture; GLTexture m_del_hovered_texture;
GLTexture m_move_front_hovered_texture;
GLTexture m_move_front_texture;
GLTexture m_arrange_texture; GLTexture m_arrange_texture;
GLTexture m_arrange_hovered_texture; GLTexture m_arrange_hovered_texture;
GLTexture m_orient_texture; GLTexture m_orient_texture;
@ -656,6 +659,9 @@ public:
height = m_plate_height; height = m_plate_height;
} }
// Pantheon: update plates after moving plate to the front
void update_plates();
/*basic plate operations*/ /*basic plate operations*/
//create an empty plate and return its index //create an empty plate and return its index
int create_plate(bool adjust_position = true); int create_plate(bool adjust_position = true);

View file

@ -14001,7 +14001,18 @@ int Plater::select_plate_by_hover_id(int hover_id, bool right_click, bool isModi
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << "can not select plate %1%" << plate_index; BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << "can not select plate %1%" << plate_index;
ret = -1; ret = -1;
} }
} else if ((action == 7) && (!right_click)) {
// move plate to the front
take_snapshot("move plate to the front");
ret = p->partplate_list.move_plate_to_index(plate_index,0);
p->partplate_list.update_slice_context_to_current_plate(p->background_process);
p->preview->update_gcode_result(p->partplate_list.get_current_slice_result());
p->sidebar->obj_list()->reload_all_plates();
p->partplate_list.update_plates();
update();
p->partplate_list.select_plate(0);
} }
else else
{ {
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << "invalid action %1%, with right_click=%2%" << action << right_click; BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << "invalid action %1%, with right_click=%2%" << action << right_click;