Footprints: upgrade Sheetpath and Sheetfile to tagged items in file

Rather than loose kv properties.
This commit is contained in:
Mike Williams 2023-06-19 09:26:33 -04:00
parent 993bb84240
commit 636db607c1
5 changed files with 89 additions and 4 deletions

View File

@ -268,6 +268,8 @@ scale
segment
segment_width
setup
sheetfile
sheetname
silk_line_width
silk_text_dims
size

View File

@ -232,6 +232,12 @@ public:
const KIID_PATH& GetPath() const { return m_path; }
void SetPath( const KIID_PATH& aPath ) { m_path = aPath; }
wxString GetSheetname() const { return m_sheetname; }
void SetSheetname( const wxString& aSheetname ) { m_sheetname = aSheetname; }
wxString GetSheetfile() const { return m_sheetfile; }
void SetSheetfile( const wxString& aSheetfile ) { m_sheetfile = aSheetfile; }
int GetLocalSolderMaskMargin() const { return m_localSolderMaskMargin; }
void SetLocalSolderMaskMargin( int aMargin ) { m_localSolderMaskMargin = aMargin; }
@ -959,6 +965,8 @@ private:
wxString m_doc; // File name and path for documentation file.
wxString m_keywords; // Search keywords to find footprint in library.
KIID_PATH m_path; // Path to associated symbol ([sheetUUID, .., symbolUUID]).
wxString m_sheetname; // Name of the sheet containing the symbol for this footprint
wxString m_sheetfile; // File of the sheet containing the symbol for this footprint
timestamp_t m_lastEditTime;
int m_arflag; // Use to trace ratsnest and auto routing.
KIID m_link; // Temporary logical link used during editing

View File

@ -382,6 +382,45 @@ bool BOARD_NETLIST_UPDATER::updateFootprintParameters( FOOTPRINT* aPcbFootprint,
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
}
wxString sheetname;
wxString sheetfile;
if( aNetlistComponent->GetProperties().count( wxT( "Sheetname" ) ) > 0 )
sheetname = aNetlistComponent->GetProperties().at( wxT( "Sheetname" ) );
if( aNetlistComponent->GetProperties().count( wxT( "Sheetfile" ) ) > 0 )
sheetfile = aNetlistComponent->GetProperties().at( wxT( "Sheetfile" ) );
if( sheetname != aPcbFootprint->GetSheetname() )
{
if( m_isDryRun )
msg.Printf( _( "Update %s sheetname to '%s'." ), aPcbFootprint->GetReference(),
sheetname );
else
{
aPcbFootprint->SetSheetname( sheetname );
msg.Printf( _( "Updated %s sheetname to '%s'." ), aPcbFootprint->GetReference(),
sheetname );
}
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
}
if( sheetfile != aPcbFootprint->GetSheetfile() )
{
if( m_isDryRun )
msg.Printf( _( "Update %s sheetfile to '%s'." ), aPcbFootprint->GetReference(),
sheetfile );
else
{
aPcbFootprint->SetSheetfile( sheetfile );
msg.Printf( _( "Updated %s sheetfile to '%s'." ), aPcbFootprint->GetReference(),
sheetfile );
}
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
}
if( ( aNetlistComponent->GetProperties().count( wxT( "exclude_from_bom" ) ) > 0 )
!= ( ( aPcbFootprint->GetAttributes() & FP_EXCLUDE_FROM_BOM ) > 0 ) )
{

View File

@ -3816,15 +3816,27 @@ FOOTPRINT* PCB_PARSER::parseFOOTPRINT_unchecked( wxArrayString* aInitialComments
wxString pValue = FromUTF8();
// Skip non-field properties that should be hidden
if( pName == "ki_description" ||
pName == "ki_keywords" ||
pName == "Sheetfile" ||
pName == "Sheetname" )
if( pName == "ki_description" || pName == "ki_keywords" )
{
NeedRIGHT();
break;
}
// Sheet file and name used to be stored as properties invisible to the user
if( pName == "Sheetfile" || pName == "Sheet file" )
{
footprint->SetSheetfile( pValue );
NeedRIGHT();
break;
}
if( pName == "Sheetname" || pName == "Sheet name" )
{
footprint->SetSheetname( pValue );
NeedRIGHT();
break;
}
PCB_FIELD* field = nullptr;
if( footprint->HasFieldByName( pName ) )
@ -3855,6 +3867,18 @@ FOOTPRINT* PCB_PARSER::parseFOOTPRINT_unchecked( wxArrayString* aInitialComments
NeedRIGHT();
break;
case T_sheetname:
NeedSYMBOL();
footprint->SetSheetname( FromUTF8() );
NeedRIGHT();
break;
case T_sheetfile:
NeedSYMBOL();
footprint->SetSheetfile( FromUTF8() );
NeedRIGHT();
break;
case T_autoplace_cost90:
case T_autoplace_cost180:
parseInt( "legacy auto-place cost" );

View File

@ -1139,6 +1139,18 @@ void PCB_PLUGIN::format( const FOOTPRINT* aFootprint, int aNestLevel ) const
m_out->Quotew( aFootprint->GetPath().AsString() ).c_str() );
}
if( !aFootprint->GetSheetname().empty() )
{
m_out->Print( aNestLevel + 1, "(sheetname %s)\n",
m_out->Quotew( aFootprint->GetSheetname() ).c_str() );
}
if( !aFootprint->GetSheetfile().empty() )
{
m_out->Print( aNestLevel + 1, "(sheetfile %s)\n",
m_out->Quotew( aFootprint->GetSheetfile() ).c_str() );
}
if( aFootprint->GetLocalSolderMaskMargin() != 0 )
{
m_out->Print( aNestLevel+1, "(solder_mask_margin %s)\n",