Browse Source

Support custom padstacks in footprint checker

pcb_db
Jon Evans 1 year ago
parent
commit
26247b0d27
  1. 13
      pcbnew/footprint.cpp
  2. 20
      pcbnew/padstack.cpp
  3. 7
      pcbnew/padstack.h

13
pcbnew/footprint.cpp

@ -3142,12 +3142,15 @@ void FOOTPRINT::CheckShortingPads( const std::function<void( const PAD*, const P
if( pad->GetBoundingBox().Intersects( other->GetBoundingBox() ) )
{
VECTOR2I pos;
// TODO(JE) padstacks - need to check complex against complex
SHAPE* padShape = pad->GetEffectiveShape( PADSTACK::ALL_LAYERS ).get();
SHAPE* otherShape = other->GetEffectiveShape( PADSTACK::ALL_LAYERS ).get();
if( padShape->Collide( otherShape, 0, nullptr, &pos ) )
aErrorHandler( pad, other, DRCE_SHORTING_ITEMS, pos );
for( PCB_LAYER_ID l : pad->Padstack().RelevantShapeLayers( other->Padstack() ) )
{
SHAPE* padShape = pad->GetEffectiveShape( l ).get();
SHAPE* otherShape = other->GetEffectiveShape( l ).get();
if( padShape->Collide( otherShape, 0, nullptr, &pos ) )
aErrorHandler( pad, other, DRCE_SHORTING_ITEMS, pos );
}
}
}
}

20
pcbnew/padstack.cpp

@ -922,6 +922,26 @@ PCB_LAYER_ID PADSTACK::EffectiveLayerFor( PCB_LAYER_ID aLayer ) const
}
LSET PADSTACK::RelevantShapeLayers( const PADSTACK& aOther ) const
{
LSET ret;
#ifdef DEBUG
if( m_parent && aOther.m_parent
&& ( m_mode == MODE::CUSTOM || aOther.m_mode == MODE::CUSTOM ) )
{
wxASSERT_MSG( m_parent->BoardCopperLayerCount() == aOther.m_parent->BoardCopperLayerCount(),
wxT( "Expected both padstacks to have the same board copper layer count" ) );
}
#endif
ForEachUniqueLayer( [&]( PCB_LAYER_ID aLayer ) { ret.set( aLayer ); } );
aOther.ForEachUniqueLayer( [&]( PCB_LAYER_ID aLayer ) { ret.set( aLayer ); } );
return ret;
}
PADSTACK::COPPER_LAYER_PROPS& PADSTACK::CopperLayer( PCB_LAYER_ID aLayer )
{
PCB_LAYER_ID layer = EffectiveLayerFor( aLayer );

7
pcbnew/padstack.h

@ -345,6 +345,13 @@ public:
*/
PCB_LAYER_ID EffectiveLayerFor( PCB_LAYER_ID aLayer ) const;
/**
* Returns the set of layers that must be considered if checking one padstack against another.
* For example, two normal padstacks will just return a set with ALL_LAYERS, but if one of them
* is FRONT_INNER_BACK, there are three layers to check.
*/
LSET RelevantShapeLayers( const PADSTACK& aOther ) const;
// The following section has convenience getters for the padstack properties on a given layer.
PAD_SHAPE Shape( PCB_LAYER_ID aLayer ) const;

Loading…
Cancel
Save