Pcb editor and 3d viewer: fix some issues:

- Fix incorrect values of displayed layers of blind/buried vias
- Fix possible incorrect layer order in PCB_VIA::SanitizeLayers()
- fix some display issues in 3D viewer.
- fix issue in LAYER_RANGE::Contains(): sometimes the test was incorrect.
This commit is contained in:
jean-pierre charras 2024-09-14 15:57:56 +02:00
parent 3f4257139e
commit d2cb868829
4 changed files with 43 additions and 4 deletions

View File

@ -186,8 +186,12 @@ void BOARD_ADAPTER::createLayers( REPORTER* aStatusReporter )
for( PCB_TRACK* track : m_board->Tracks() )
{
if( !Is3dLayerEnabled( track->GetLayer(), visibilityFlags ) ) // Skip non enabled layers
// Skip tracks (not vias that are on more than one layer ) on disabled layers
if( !track->Type() == PCB_VIA_T
&& !Is3dLayerEnabled( track->GetLayer(), visibilityFlags ) )
{
continue;
}
// Note: a PCB_TRACK holds normal segment tracks and also vias circles (that have also
// drill values)

View File

@ -121,16 +121,29 @@ public:
}
LAYER_RANGE_ITERATOR begin() const { return LAYER_RANGE_ITERATOR( m_start, m_stop, m_layer_count ); }
LAYER_RANGE_ITERATOR end() const { auto it = LAYER_RANGE_ITERATOR( m_stop, m_stop, m_layer_count ); return ++it; }
LAYER_RANGE_ITERATOR end() const
{
auto it = LAYER_RANGE_ITERATOR( m_stop, m_stop, m_layer_count );
return ++it;
}
static bool Contains( int aStart_layer, int aEnd_layer, int aTest_layer )
{
// B_Cu is the lowest copper layer for Z order copper layers
// F_cu = top, B_Cu = bottom
// So set the distance from top for B_Cu to INT_MAX
if( aTest_layer == B_Cu )
aTest_layer = INT_MAX;
if( aStart_layer == B_Cu )
aStart_layer = INT_MAX;
if( aEnd_layer == B_Cu )
aEnd_layer = INT_MAX;
if( aStart_layer > aEnd_layer )
std::swap( aStart_layer, aEnd_layer );
return aTest_layer >= aStart_layer && aTest_layer <= aEnd_layer;
}

View File

@ -982,8 +982,24 @@ void PCB_PAINTER::draw( const PCB_VIA* aVia, int aLayer )
wxString netname = aVia->GetDisplayNetname();
int topLayer = aVia->TopLayer() + 1;
int bottomLayer = std::min( aVia->BottomLayer() + 1, board->GetCopperLayerCount() );
PCB_LAYER_ID topLayerId = aVia->TopLayer();
PCB_LAYER_ID bottomLayerId = aVia->BottomLayer();
int topLayer; // The via top layer number (from 1 to copper layer count)
int bottomLayer; // The via bottom layer number (from 1 to copper layer count)
switch( topLayerId )
{
case F_Cu: topLayer = 1; break;
case B_Cu: topLayer = board->GetCopperLayerCount(); break;
default: topLayer = (topLayerId - B_Cu)/2 + 1; break;
}
switch( bottomLayerId )
{
case F_Cu: bottomLayer = 1; break;
case B_Cu: bottomLayer = board->GetCopperLayerCount(); break;
default: bottomLayer = (bottomLayerId - B_Cu)/2 + 1; break;
}
wxString layerIds;
#if wxUSE_UNICODE_WCHAR

View File

@ -873,7 +873,9 @@ bool PCB_VIA::IsOnLayer( PCB_LAYER_ID aLayer ) const
#endif
if( IsCopperLayer( aLayer ) &&
LAYER_RANGE::Contains( Padstack().Drill().start, Padstack().Drill().end, aLayer ) )
{
return true;
}
if( aLayer == F_Mask )
return !IsTented( F_Mask );
@ -1013,6 +1015,10 @@ void PCB_VIA::SanitizeLayers()
if( Padstack().Drill().end < Padstack().Drill().start )
std::swap( Padstack().Drill().end, Padstack().Drill().start );
// Ensure B_Cu is never the first layer
if( Padstack().Drill().start == B_Cu )
std::swap( Padstack().Drill().end, Padstack().Drill().start );
}