From a85a2b9cbc7fbb39f0e895c5f75cdf0337ec4ba3 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 12 Jul 2023 18:27:11 +0100 Subject: [PATCH] Add via solder mask to 3D viewer rendering. (Of course, only when vias are not tented.) Fixes https://gitlab.com/kicad/code/kicad/-/issues/15164 --- 3d-viewer/3d_canvas/board_adapter.h | 3 ++ .../3d_canvas/create_3Dgraphic_brd_items.cpp | 15 +++++++++- 3d-viewer/3d_canvas/create_layer_items.cpp | 29 +++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/3d-viewer/3d_canvas/board_adapter.h b/3d-viewer/3d_canvas/board_adapter.h index 1204a504a1..d47dc7b7a9 100644 --- a/3d-viewer/3d_canvas/board_adapter.h +++ b/3d-viewer/3d_canvas/board_adapter.h @@ -334,6 +334,9 @@ private: void destroyLayers(); // Helper functions to create the board + void createViaWithMargin( const PCB_TRACK* aTrack, CONTAINER_2D_BASE* aDstContainer, + int aMargin ); + void createTrack( const PCB_TRACK* aTrack, CONTAINER_2D_BASE* aDstContainer ); void createPadWithMargin( const PAD *aPad, CONTAINER_2D_BASE* aDstContainer, diff --git a/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp b/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp index e616f25a34..6cd84cd1e2 100644 --- a/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp +++ b/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp @@ -229,6 +229,19 @@ void BOARD_ADAPTER::addFootprintShapes( const FOOTPRINT* aFootprint, CONTAINER_2 } +void BOARD_ADAPTER::createViaWithMargin( const PCB_TRACK* aTrack, CONTAINER_2D_BASE* aDstContainer, + int aMargin ) +{ + SFVEC2F start3DU = TO_SFVEC2F( aTrack->GetStart() ); + SFVEC2F end3DU = TO_SFVEC2F( aTrack->GetEnd() ); + + const float radius3DU = TO_3DU( ( aTrack->GetWidth() / 2 ) + aMargin ); + + if( radius3DU > 0.0 ) + aDstContainer->Add( new FILLED_CIRCLE_2D( start3DU, radius3DU, *aTrack ) ); +} + + void BOARD_ADAPTER::createTrack( const PCB_TRACK* aTrack, CONTAINER_2D_BASE* aDstContainer ) { SFVEC2F start3DU = TO_SFVEC2F( aTrack->GetStart() ); @@ -238,7 +251,7 @@ void BOARD_ADAPTER::createTrack( const PCB_TRACK* aTrack, CONTAINER_2D_BASE* aDs { case PCB_VIA_T: { - const float radius3DU = TO_3DU( aTrack->GetWidth() / 2 ); + const float radius3DU = TO_3DU( aTrack->GetWidth() / 2 ); if( radius3DU > 0.0 ) aDstContainer->Add( new FILLED_CIRCLE_2D( start3DU, radius3DU, *aTrack ) ); diff --git a/3d-viewer/3d_canvas/create_layer_items.cpp b/3d-viewer/3d_canvas/create_layer_items.cpp index 7231d98f52..9a5b813e70 100644 --- a/3d-viewer/3d_canvas/create_layer_items.cpp +++ b/3d-viewer/3d_canvas/create_layer_items.cpp @@ -978,6 +978,35 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter ) } } + // Add via tech layers + if( ( layer == F_Mask || layer == B_Mask ) && !m_board->GetTentVias() ) + { + int maskExpansion = GetBoard()->GetDesignSettings().m_SolderMaskExpansion; + + for( PCB_TRACK* track : m_board->Tracks() ) + { + if( track->Type() == PCB_VIA_T + && static_cast( track )->FlashLayer( layer ) ) + { + createViaWithMargin( track, layerContainer, maskExpansion ); + } + } + + // Add via tech layers - contours (vertical walls) + if( buildVerticalWallsForTechLayers ) + { + for( PCB_TRACK* track : m_board->Tracks() ) + { + if( track->Type() == PCB_VIA_T + && static_cast( track )->FlashLayer( layer ) ) + { + track->TransformShapeToPolygon( *layerPoly, layer, maskExpansion, maxError, + ERROR_INSIDE ); + } + } + } + } + // Add footprints tech layers - objects for( FOOTPRINT* footprint : m_board->Footprints() ) {