From 519abec88bc5712632ca511bc9623018db6faff9 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 20 Jan 2025 17:15:49 +0100 Subject: [PATCH] 3D Viewer: fix incorrect render of plated copper of texts. Previously, with option "Use bare copper color for unplated copper", the plated area of texts were drawn using their bounding box. (cherry picked from commit becaba531b08b8dd7f9d24b36bb9039ffdd34b96 and from commit ca5f867957f7252f1b7043446a5d3183548ca594) --- 3d-viewer/3d_canvas/create_layer_items.cpp | 33 ++++++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/3d-viewer/3d_canvas/create_layer_items.cpp b/3d-viewer/3d_canvas/create_layer_items.cpp index d923967959..f7d4b1f62b 100644 --- a/3d-viewer/3d_canvas/create_layer_items.cpp +++ b/3d-viewer/3d_canvas/create_layer_items.cpp @@ -643,12 +643,33 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) // add also this shape to the plated copper polygon list if required if( cfg.differentiate_plated_copper ) { - if( layer == F_Cu ) - item->TransformShapeToPolygon( *m_frontPlatedCopperPolys, F_Cu, - 0, maxError, ERROR_INSIDE ); - else if( layer == B_Cu ) - item->TransformShapeToPolygon( *m_backPlatedCopperPolys, B_Cu, - 0, maxError, ERROR_INSIDE ); + // Note: for TEXT and TEXTBOX, TransformShapeToPolygon returns the bounding + // box shape, not the exact text shape. So it is not used for these items + if( layer == F_Cu || layer == B_Cu ) + { + SHAPE_POLY_SET* platedCopperPolys = layer == F_Cu + ? m_frontPlatedCopperPolys + : m_backPlatedCopperPolys; + + if( item->Type() == PCB_TEXTBOX_T ) + { + PCB_TEXTBOX* text_box = static_cast( item ); + text_box->TransformTextToPolySet( *platedCopperPolys, + 0, maxError, ERROR_INSIDE ); + // Add box outlines + text_box->PCB_SHAPE::TransformShapeToPolygon( *platedCopperPolys, layer, + 0, maxError, ERROR_INSIDE ); + } + else if( item->Type() == PCB_TEXT_T ) + { + static_cast( item )->TransformTextToPolySet( + *platedCopperPolys, + 0, maxError, ERROR_INSIDE ); + } + else + item->TransformShapeToPolygon( *platedCopperPolys, layer, + 0, maxError, ERROR_INSIDE ); + } } } }