7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 00:21:25 +00:00

pcbnew: parse also the human readable hierarchical sheet paths for footprints when reading the netlist

We've had so far the chain of UUIDs, but for the ease of use in the DRC language (i.e. memberOfSheet),
a human-readable path is also useful. No file format changes.
This commit is contained in:
Tomasz Wlostowski 2023-12-31 13:24:10 +01:00
parent 46b54da139
commit e35f64c3cf
3 changed files with 27 additions and 5 deletions

View File

@ -508,7 +508,11 @@ bool BOARD_NETLIST_UPDATER::updateFootprintParameters( FOOTPRINT* aPcbFootprint,
wxString sheetfile;
wxString fpFilters;
if( aNetlistComponent->GetProperties().count( wxT( "Sheetname" ) ) > 0 )
wxString humanSheetPath = aNetlistComponent->GetHumanReadablePath();
if( !humanSheetPath.empty() )
sheetname = humanSheetPath;
else if( aNetlistComponent->GetProperties().count( wxT( "Sheetname" ) ) > 0 )
sheetname = aNetlistComponent->GetProperties().at( wxT( "Sheetname" ) );
if( aNetlistComponent->GetProperties().count( wxT( "Sheetfile" ) ) > 0 )

View File

@ -299,6 +299,7 @@ void KICAD_NETLIST_PARSER::parseComponent()
wxString value;
wxString library;
wxString name;
wxString humanSheetPath;
KIID_PATH path;
std::vector<KIID> uuids;
@ -438,14 +439,24 @@ void KICAD_NETLIST_PARSER::parseComponent()
case T_sheetpath:
while( ( token = NextTok() ) != T_EOF )
{
if( token == T_names )
{
NeedSYMBOLorNUMBER();
humanSheetPath = From_UTF8( CurText() );
printf("SPath '%s'\n", humanSheetPath.c_str().AsChar() );
NeedRIGHT();
}
if( token == T_tstamps )
{
NeedSYMBOLorNUMBER();
path = KIID_PATH( From_UTF8( CurText() ) );
NeedRIGHT();
break;
}
}
NeedSYMBOLorNUMBER();
path = KIID_PATH( From_UTF8( CurText() ) );
NeedRIGHT();
NeedRIGHT();
break;
case T_tstamps:
@ -469,7 +480,7 @@ void KICAD_NETLIST_PARSER::parseComponent()
if( !footprint.IsEmpty() && fpid.Parse( footprint, true ) >= 0 )
{
wxString error;
error.Printf( _( "Invalid footprint ID in\nfile: '%s'\nline: %d\noffset: %d" ),
error.Printf( _( "Invalid footprint ID in\nfile: '%s'\nline: %d\nofff: %d" ),
CurSource(), CurLineNumber(), CurOffset() );
THROW_IO_ERROR( error );
@ -480,6 +491,7 @@ void KICAD_NETLIST_PARSER::parseComponent()
component->SetLibrary( library );
component->SetProperties( properties );
component->SetFields( fields );
component->SetHumanReadablePath( humanSheetPath );
m_netlist->AddComponent( component );
}

View File

@ -172,6 +172,9 @@ public:
void Format( OUTPUTFORMATTER* aOut, int aNestLevel, int aCtl );
void SetHumanReadablePath( const wxString& aPath ) { m_humanReadablePath = aPath; }
const wxString& GetHumanReadablePath() const { return m_humanReadablePath; }
private:
std::vector<COMPONENT_NET> m_nets; ///< list of nets shared by the component pins
@ -180,6 +183,9 @@ private:
wxString m_reference;
wxString m_value;
// human-readable hierarchical sheet path (e.g. /root/block0/sheet1)
wxString m_humanReadablePath;
/// A fully specified path to the component (but not the component: [ sheetUUID, sheetUUID, .. ]
KIID_PATH m_path;