From cd33a33f583f8db328eef81ac5c2cec42ecbf56f Mon Sep 17 00:00:00 2001 From: yw4z Date: Tue, 26 Aug 2025 21:20:57 +0300 Subject: [PATCH 1/3] init --- src/slic3r/GUI/PartPlate.cpp | 33 ++++++++++++++++++++++++++++++++- src/slic3r/GUI/PartPlate.hpp | 3 +++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/PartPlate.cpp b/src/slic3r/GUI/PartPlate.cpp index 5818d0a449..90e2bed2a0 100644 --- a/src/slic3r/GUI/PartPlate.cpp +++ b/src/slic3r/GUI/PartPlate.cpp @@ -471,15 +471,33 @@ static void init_raycaster_from_model(PickingModel& model) void PartPlate::calc_gridlines(const ExPolygon& poly, const BoundingBox& pp_bbox) { m_gridlines.reset(); m_gridlines_bolder.reset(); + m_plate_axis_x.reset(); + m_plate_axis_y.reset(); // calculate and generate grid int step = Bed_2D::calculate_grid_step(pp_bbox, scale_(1.00)); - Vec2d scaled_origin = Vec2d(scale_(m_origin.x()),scale_(m_origin.x())); + Vec2d scaled_origin = Vec2d(scale_(m_origin.x()),scale_(m_origin.y())); auto grid_lines = Bed_2D::generate_grid(poly, pp_bbox, scaled_origin, scale_(step), SCALED_EPSILON); Lines lines_thin = to_lines(grid_lines[0]); Lines lines_bold = to_lines(grid_lines[1]); + // add axis lines + Point o_pt = Point(scaled_origin.x(), scaled_origin.y()); + m_axis_on_plate = pp_bbox.contains(o_pt); + coord_t axis_end_x = m_axis_on_plate ? pp_bbox.max(0) : (o_pt.x() + scale_(step * 2)); + coord_t axis_end_y = m_axis_on_plate ? pp_bbox.max(1) : (o_pt.y() + scale_(step * 2)); + + Polylines axis_pl_x = { Polyline(o_pt, Point(axis_end_x, o_pt.y())) }; + Polylines axis_pl_y = { Polyline(o_pt, Point(o_pt.x(), axis_end_y)) }; + if(m_axis_on_plate){ // reqired for custom / circular plates to prevent overflow + axis_pl_x = intersection_pl(axis_pl_x, offset(poly, SCALED_EPSILON)); + axis_pl_y = intersection_pl(axis_pl_y, offset(poly, SCALED_EPSILON)); + } // else its IDEX with clone or mirror mode. dont use clipping to show axis outside + + Lines lines_axis_x = to_lines(axis_pl_x); + Lines lines_axis_y = to_lines(axis_pl_y); + // append bed contours Lines contour_lines = to_lines(poly); std::copy(contour_lines.begin(), contour_lines.end(), std::back_inserter(lines_thin)); @@ -489,6 +507,12 @@ void PartPlate::calc_gridlines(const ExPolygon& poly, const BoundingBox& pp_bbox if (!init_model_from_lines(m_gridlines_bolder, lines_bold, GROUND_Z_GRIDLINE)) BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << "Unable to create bed grid lines\n"; + + if (!init_model_from_lines(m_plate_axis_x, lines_axis_x, GROUND_Z_GRIDLINE + 0.01)) + BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << "Unable to create bed grid x axis\n"; + + if (!init_model_from_lines(m_plate_axis_y, lines_axis_y, GROUND_Z_GRIDLINE + 0.01)) + BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << "Unable to create bed grid y axis\n"; } void PartPlate::calc_height_limit() { @@ -892,6 +916,13 @@ void PartPlate::render_grid(bool bottom) { glsafe(::glLineWidth(2.0f * m_scale_factor)); m_gridlines_bolder.set_color(color); m_gridlines_bolder.render(); + if (m_selected){ + float opacity = m_axis_on_plate ? .15f : .5f; + m_plate_axis_x.set_color({ ColorRGB::X().r(), ColorRGB::X().g(), ColorRGB::X().b(), opacity }); + m_plate_axis_x.render(); + m_plate_axis_y.set_color({ ColorRGB::Y().r(), ColorRGB::Y().g(), ColorRGB::Y().b(), opacity }); + m_plate_axis_y.render(); + } } void PartPlate::render_height_limit(PartPlate::HeightLimitMode mode) diff --git a/src/slic3r/GUI/PartPlate.hpp b/src/slic3r/GUI/PartPlate.hpp index bbe1cbae46..9bf51c1f7c 100644 --- a/src/slic3r/GUI/PartPlate.hpp +++ b/src/slic3r/GUI/PartPlate.hpp @@ -131,6 +131,9 @@ private: GLModel m_logo_triangles; GLModel m_gridlines; GLModel m_gridlines_bolder; + GLModel m_plate_axis_x; + GLModel m_plate_axis_y; + bool m_axis_on_plate; GLModel m_height_limit_common; GLModel m_height_limit_bottom; GLModel m_height_limit_top; From 15200864c2e1f5c327f876ff36d66a1a8d64eed1 Mon Sep 17 00:00:00 2001 From: yw4z Date: Tue, 26 Aug 2025 21:56:33 +0300 Subject: [PATCH 2/3] fix light mode --- src/slic3r/GUI/PartPlate.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/PartPlate.cpp b/src/slic3r/GUI/PartPlate.cpp index 90e2bed2a0..1fcebeeee0 100644 --- a/src/slic3r/GUI/PartPlate.cpp +++ b/src/slic3r/GUI/PartPlate.cpp @@ -81,7 +81,7 @@ ColorRGBA PartPlate::UNSELECT_DARK_COLOR = { 0.384f, 0.384f, 0.412f, 1.0f }; ColorRGBA PartPlate::DEFAULT_COLOR = { 0.5f, 0.5f, 0.5f, 1.0f }; ColorRGBA PartPlate::LINE_TOP_COLOR = { 0.89f, 0.89f, 0.89f, 1.0f }; ColorRGBA PartPlate::LINE_TOP_DARK_COLOR = { 0.431f, 0.431f, 0.463f, 1.0f }; -ColorRGBA PartPlate::LINE_TOP_SEL_COLOR = { 0.5294f, 0.5451, 0.5333f, 1.0f}; +ColorRGBA PartPlate::LINE_TOP_SEL_COLOR = { 0.4294f, 0.4451, 0.4333f, 1.0f}; ColorRGBA PartPlate::LINE_TOP_SEL_DARK_COLOR = { 0.298f, 0.298f, 0.3333f, 1.0f}; ColorRGBA PartPlate::LINE_BOTTOM_COLOR = { 0.8f, 0.8f, 0.8f, 0.4f }; ColorRGBA PartPlate::HEIGHT_LIMIT_TOP_COLOR = { 0.6f, 0.6f, 1.0f, 1.0f }; @@ -917,7 +917,8 @@ void PartPlate::render_grid(bool bottom) { m_gridlines_bolder.set_color(color); m_gridlines_bolder.render(); if (m_selected){ - float opacity = m_axis_on_plate ? .15f : .5f; + float opacity = m_partplate_list->m_is_dark ? (m_axis_on_plate ? .15f : .5f) + : (m_axis_on_plate ? .20f : .5f); m_plate_axis_x.set_color({ ColorRGB::X().r(), ColorRGB::X().g(), ColorRGB::X().b(), opacity }); m_plate_axis_x.render(); m_plate_axis_y.set_color({ ColorRGB::Y().r(), ColorRGB::Y().g(), ColorRGB::Y().b(), opacity }); From fcbb7fee9897912d00f4f012afcdd2847517cd93 Mon Sep 17 00:00:00 2001 From: yw4z Date: Tue, 26 Aug 2025 23:28:16 +0300 Subject: [PATCH 3/3] update --- src/slic3r/GUI/PartPlate.cpp | 6 +++++- src/slic3r/GUI/PartPlate.hpp | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/PartPlate.cpp b/src/slic3r/GUI/PartPlate.cpp index 1fcebeeee0..18527d037b 100644 --- a/src/slic3r/GUI/PartPlate.cpp +++ b/src/slic3r/GUI/PartPlate.cpp @@ -485,6 +485,7 @@ void PartPlate::calc_gridlines(const ExPolygon& poly, const BoundingBox& pp_bbox // add axis lines Point o_pt = Point(scaled_origin.x(), scaled_origin.y()); m_axis_on_plate = pp_bbox.contains(o_pt); + //m_axis_on_plate_min = pp_bbox.min == o_pt; coord_t axis_end_x = m_axis_on_plate ? pp_bbox.max(0) : (o_pt.x() + scale_(step * 2)); coord_t axis_end_y = m_axis_on_plate ? pp_bbox.max(1) : (o_pt.y() + scale_(step * 2)); @@ -916,9 +917,12 @@ void PartPlate::render_grid(bool bottom) { glsafe(::glLineWidth(2.0f * m_scale_factor)); m_gridlines_bolder.set_color(color); m_gridlines_bolder.render(); + if (m_selected){ + //if(m_axis_on_plate_min) // use 2x width if lines on edge because half of it clipping + // glsafe(::glLineWidth(2.0f * m_scale_factor)); float opacity = m_partplate_list->m_is_dark ? (m_axis_on_plate ? .15f : .5f) - : (m_axis_on_plate ? .20f : .5f); + : (m_axis_on_plate ? .21f : .5f); m_plate_axis_x.set_color({ ColorRGB::X().r(), ColorRGB::X().g(), ColorRGB::X().b(), opacity }); m_plate_axis_x.render(); m_plate_axis_y.set_color({ ColorRGB::Y().r(), ColorRGB::Y().g(), ColorRGB::Y().b(), opacity }); diff --git a/src/slic3r/GUI/PartPlate.hpp b/src/slic3r/GUI/PartPlate.hpp index 9bf51c1f7c..26b06ceffe 100644 --- a/src/slic3r/GUI/PartPlate.hpp +++ b/src/slic3r/GUI/PartPlate.hpp @@ -134,6 +134,7 @@ private: GLModel m_plate_axis_x; GLModel m_plate_axis_y; bool m_axis_on_plate; + //bool m_axis_on_plate_min; GLModel m_height_limit_common; GLModel m_height_limit_bottom; GLModel m_height_limit_top;