Layer handling for copper sliver exclusions.

Fixes https://gitlab.com/kicad/code/kicad/issues/10147
This commit is contained in:
Jeff Young 2022-01-11 21:01:35 +00:00
parent f063c00bf1
commit 6ccfec0553
3 changed files with 33 additions and 8 deletions

View File

@ -50,9 +50,9 @@ class PCB_GROUP;
class BOARD_ITEM : public EDA_ITEM class BOARD_ITEM : public EDA_ITEM
{ {
public: public:
BOARD_ITEM( BOARD_ITEM* aParent, KICAD_T idtype ) : BOARD_ITEM( BOARD_ITEM* aParent, KICAD_T idtype, PCB_LAYER_ID aLayer = F_Cu ) :
EDA_ITEM( aParent, idtype ), EDA_ITEM( aParent, idtype ),
m_layer( F_Cu ), m_layer( aLayer ),
m_group( nullptr ) m_group( nullptr )
{ {
} }

View File

@ -44,8 +44,9 @@
PCB_MARKER::PCB_MARKER( std::shared_ptr<RC_ITEM> aItem, const VECTOR2I& aPosition ) : PCB_MARKER::PCB_MARKER( std::shared_ptr<RC_ITEM> aItem, const VECTOR2I& aPosition,
BOARD_ITEM( nullptr, PCB_MARKER_T ), // parent set during BOARD::Add() PCB_LAYER_ID aLayer ) :
BOARD_ITEM( nullptr, PCB_MARKER_T, aLayer ), // parent set during BOARD::Add()
MARKER_BASE( SCALING_FACTOR, aItem ) MARKER_BASE( SCALING_FACTOR, aItem )
{ {
if( m_rcItem ) if( m_rcItem )
@ -85,18 +86,26 @@ PCB_MARKER::~PCB_MARKER()
wxString PCB_MARKER::Serialize() const wxString PCB_MARKER::Serialize() const
{ {
wxString lastItem;
if( m_rcItem->GetErrorCode() == DRCE_COPPER_SLIVER )
lastItem = LayerName( m_layer );
else
lastItem = m_rcItem->GetAuxItemID().AsString();
return wxString::Format( wxT( "%s|%d|%d|%s|%s" ), return wxString::Format( wxT( "%s|%d|%d|%s|%s" ),
m_rcItem->GetSettingsKey(), m_rcItem->GetSettingsKey(),
m_Pos.x, m_Pos.x,
m_Pos.y, m_Pos.y,
m_rcItem->GetMainItemID().AsString(), m_rcItem->GetMainItemID().AsString(),
m_rcItem->GetAuxItemID().AsString() ); lastItem );
} }
PCB_MARKER* PCB_MARKER::Deserialize( const wxString& data ) PCB_MARKER* PCB_MARKER::Deserialize( const wxString& data )
{ {
wxArrayString props = wxSplit( data, '|' ); wxArrayString props = wxSplit( data, '|' );
PCB_LAYER_ID markerLayer = F_Cu;
VECTOR2I markerPos( (int) strtol( props[1].c_str(), nullptr, 10 ), VECTOR2I markerPos( (int) strtol( props[1].c_str(), nullptr, 10 ),
(int) strtol( props[2].c_str(), nullptr, 10 ) ); (int) strtol( props[2].c_str(), nullptr, 10 ) );
@ -105,9 +114,25 @@ PCB_MARKER* PCB_MARKER::Deserialize( const wxString& data )
if( !drcItem ) if( !drcItem )
return nullptr; return nullptr;
drcItem->SetItems( KIID( props[3] ), KIID( props[4] ) ); if( drcItem->GetErrorCode() == DRCE_COPPER_SLIVER )
{
drcItem->SetItems( KIID( props[3] ) );
return new PCB_MARKER( drcItem, markerPos ); for( int layer = 0; layer < PCB_LAYER_ID_COUNT; ++layer )
{
if( LayerName( ToLAYER_ID( layer ) ) == props[4] )
{
markerLayer = ToLAYER_ID( layer );
break;
}
}
}
else
{
drcItem->SetItems( KIID( props[3] ), KIID( props[4] ) );
}
return new PCB_MARKER( drcItem, markerPos, markerLayer );
} }

View File

@ -41,7 +41,7 @@ class MSG_PANEL_ITEM;
class PCB_MARKER : public BOARD_ITEM, public MARKER_BASE class PCB_MARKER : public BOARD_ITEM, public MARKER_BASE
{ {
public: public:
PCB_MARKER( std::shared_ptr<RC_ITEM> aItem, const VECTOR2I& aPosition ); PCB_MARKER( std::shared_ptr<RC_ITEM> aItem, const VECTOR2I& aPos, PCB_LAYER_ID aLayer = F_Cu );
~PCB_MARKER(); ~PCB_MARKER();
static inline bool ClassOf( const EDA_ITEM* aItem ) static inline bool ClassOf( const EDA_ITEM* aItem )