Add uuid r/w for sch pins, text, wires, etc.
Fixes https://gitlab.com/kicad/code/kicad/issues/7269
This commit is contained in:
parent
b576ccef61
commit
3702f2e0a9
|
@ -268,9 +268,12 @@ wxString SCH_COMPONENT::GetDatasheet() const
|
||||||
void SCH_COMPONENT::UpdatePins()
|
void SCH_COMPONENT::UpdatePins()
|
||||||
{
|
{
|
||||||
std::map<wxString, wxString> altPinMap;
|
std::map<wxString, wxString> altPinMap;
|
||||||
|
std::map<wxString, KIID> pinUuidMap;
|
||||||
|
|
||||||
for( const std::unique_ptr<SCH_PIN>& pin : m_pins )
|
for( const std::unique_ptr<SCH_PIN>& pin : m_pins )
|
||||||
{
|
{
|
||||||
|
pinUuidMap[ pin->GetNumber() ] = pin->m_Uuid;
|
||||||
|
|
||||||
if( !pin->GetAlt().IsEmpty() )
|
if( !pin->GetAlt().IsEmpty() )
|
||||||
altPinMap[ pin->GetNumber() ] = pin->GetAlt();
|
altPinMap[ pin->GetNumber() ] = pin->GetAlt();
|
||||||
}
|
}
|
||||||
|
@ -292,10 +295,15 @@ void SCH_COMPONENT::UpdatePins()
|
||||||
|
|
||||||
m_pins.push_back( std::make_unique<SCH_PIN>( libPin, this ) );
|
m_pins.push_back( std::make_unique<SCH_PIN>( libPin, this ) );
|
||||||
|
|
||||||
auto ii = altPinMap.find( libPin->GetNumber() );
|
auto ii = pinUuidMap.find( libPin->GetNumber() );
|
||||||
|
|
||||||
if( ii != altPinMap.end() )
|
if( ii != pinUuidMap.end() )
|
||||||
m_pins.back()->SetAlt( ii->second );
|
const_cast<KIID&>( m_pins.back()->m_Uuid ) = ii->second;
|
||||||
|
|
||||||
|
auto iii = altPinMap.find( libPin->GetNumber() );
|
||||||
|
|
||||||
|
if( iii != altPinMap.end() )
|
||||||
|
m_pins.back()->SetAlt( iii->second );
|
||||||
|
|
||||||
m_pinMap[ libPin ] = i;
|
m_pinMap[ libPin ] = i;
|
||||||
|
|
||||||
|
|
|
@ -58,4 +58,5 @@
|
||||||
//#define SEXPR_SCHEMATIC_FILE_VERSION 20200827 // Remove host tag
|
//#define SEXPR_SCHEMATIC_FILE_VERSION 20200827 // Remove host tag
|
||||||
//#define SEXPR_SCHEMATIC_FILE_VERSION 20200828 // Add footprint to symbol_instances.
|
//#define SEXPR_SCHEMATIC_FILE_VERSION 20200828 // Add footprint to symbol_instances.
|
||||||
//#define SEXPR_SCHEMATIC_FILE_VERSION 20201015 // Add sheet instance properties.
|
//#define SEXPR_SCHEMATIC_FILE_VERSION 20201015 // Add sheet instance properties.
|
||||||
#define SEXPR_SCHEMATIC_FILE_VERSION 20210123 // Rename "unconnected" pintype to "no_connect".
|
//#define SEXPR_SCHEMATIC_FILE_VERSION 20210123 // Rename "unconnected" pintype to "no_connect".
|
||||||
|
#define SEXPR_SCHEMATIC_FILE_VERSION 20210125 // R/W uuids for pins, labels, wires, etc.
|
||||||
|
|
|
@ -1792,8 +1792,14 @@ SCH_SHEET_PIN* SCH_SEXPR_PARSER::parseSchSheetPin( SCH_SHEET* aSheet )
|
||||||
parseEDA_TEXT( static_cast<EDA_TEXT*>( sheetPin.get() ) );
|
parseEDA_TEXT( static_cast<EDA_TEXT*>( sheetPin.get() ) );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case T_uuid:
|
||||||
|
NeedSYMBOL();
|
||||||
|
const_cast<KIID&>( sheetPin->m_Uuid ) = KIID( FromUTF8() );
|
||||||
|
NeedRIGHT();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Expecting( "at or effects" );
|
Expecting( "at, uuid or effects" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2310,35 +2316,42 @@ SCH_COMPONENT* SCH_SEXPR_PARSER::parseSchematicSymbol()
|
||||||
{
|
{
|
||||||
// Read an alternate pin designation
|
// Read an alternate pin designation
|
||||||
wxString number;
|
wxString number;
|
||||||
|
KIID uuid;
|
||||||
wxString alt;
|
wxString alt;
|
||||||
|
|
||||||
NeedSYMBOL();
|
NeedSYMBOL();
|
||||||
number = FromUTF8();
|
number = FromUTF8();
|
||||||
|
|
||||||
token = NextTok();
|
for( token = NextTok(); token != T_RIGHT; token = NextTok() )
|
||||||
|
{
|
||||||
if( token != T_LEFT )
|
if( token != T_LEFT )
|
||||||
Expecting( T_LEFT );
|
Expecting( T_LEFT );
|
||||||
|
|
||||||
token = NextTok();
|
token = NextTok();
|
||||||
|
|
||||||
if( token == T_alternate )
|
switch( token )
|
||||||
{
|
{
|
||||||
|
case T_alternate:
|
||||||
NeedSYMBOL();
|
NeedSYMBOL();
|
||||||
alt = FromUTF8();
|
alt = FromUTF8();
|
||||||
NeedRIGHT();
|
NeedRIGHT();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case T_uuid:
|
||||||
|
NeedSYMBOL();
|
||||||
|
uuid = KIID( FromUTF8() );
|
||||||
|
NeedRIGHT();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
Expecting( "alternate or uuid" );
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
Expecting( "alternate" );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a proxy pin to hold the alternate designation until the parent
|
|
||||||
// component resolves its pins.
|
|
||||||
symbol->GetRawPins().emplace_back( std::make_unique<SCH_PIN>( symbol.get(),
|
symbol->GetRawPins().emplace_back( std::make_unique<SCH_PIN>( symbol.get(),
|
||||||
number, alt ) );
|
number, alt ) );
|
||||||
|
|
||||||
NeedRIGHT();
|
const_cast<KIID&>( symbol->GetRawPins().back()->m_Uuid ) = uuid;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -2388,6 +2401,12 @@ SCH_BITMAP* SCH_SEXPR_PARSER::parseImage()
|
||||||
NeedRIGHT();
|
NeedRIGHT();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case T_uuid:
|
||||||
|
NeedSYMBOL();
|
||||||
|
const_cast<KIID&>( bitmap->m_Uuid ) = KIID( FromUTF8() );
|
||||||
|
NeedRIGHT();
|
||||||
|
break;
|
||||||
|
|
||||||
case T_data:
|
case T_data:
|
||||||
{
|
{
|
||||||
token = NextTok();
|
token = NextTok();
|
||||||
|
@ -2418,7 +2437,7 @@ SCH_BITMAP* SCH_SEXPR_PARSER::parseImage()
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Expecting( "at, scale, or data" );
|
Expecting( "at, scale, uuid or data" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2597,8 +2616,14 @@ SCH_NO_CONNECT* SCH_SEXPR_PARSER::parseNoConnect()
|
||||||
NeedRIGHT();
|
NeedRIGHT();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case T_uuid:
|
||||||
|
NeedSYMBOL();
|
||||||
|
const_cast<KIID&>( no_connect->m_Uuid ) = KIID( FromUTF8() );
|
||||||
|
NeedRIGHT();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Expecting( "at" );
|
Expecting( "at or uuid" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2645,8 +2670,14 @@ SCH_BUS_WIRE_ENTRY* SCH_SEXPR_PARSER::parseBusEntry()
|
||||||
busEntry->SetStroke( stroke );
|
busEntry->SetStroke( stroke );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case T_uuid:
|
||||||
|
NeedSYMBOL();
|
||||||
|
const_cast<KIID&>( busEntry->m_Uuid ) = KIID( FromUTF8() );
|
||||||
|
NeedRIGHT();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Expecting( "at, size, or stroke" );
|
Expecting( "at, size, uuid or stroke" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2704,8 +2735,14 @@ SCH_LINE* SCH_SEXPR_PARSER::parseLine()
|
||||||
line->SetStroke( stroke );
|
line->SetStroke( stroke );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case T_uuid:
|
||||||
|
NeedSYMBOL();
|
||||||
|
const_cast<KIID&>( line->m_Uuid ) = KIID( FromUTF8() );
|
||||||
|
NeedRIGHT();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Expecting( "at or stroke" );
|
Expecting( "at, uuid or stroke" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2796,6 +2833,12 @@ SCH_TEXT* SCH_SEXPR_PARSER::parseSchText()
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case T_uuid:
|
||||||
|
NeedSYMBOL();
|
||||||
|
const_cast<KIID&>( text->m_Uuid ) = KIID( FromUTF8() );
|
||||||
|
NeedRIGHT();
|
||||||
|
break;
|
||||||
|
|
||||||
case T_property:
|
case T_property:
|
||||||
if( text->Type() == SCH_GLOBAL_LABEL_T )
|
if( text->Type() == SCH_GLOBAL_LABEL_T )
|
||||||
{
|
{
|
||||||
|
@ -2810,7 +2853,7 @@ SCH_TEXT* SCH_SEXPR_PARSER::parseSchText()
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Expecting( "at, shape, iref or effects" );
|
Expecting( "at, shape, iref, uuid or effects" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -907,8 +907,10 @@ void SCH_SEXPR_PLUGIN::saveSymbol( SCH_COMPONENT* aSymbol, int aNestLevel )
|
||||||
m_out->Print( aNestLevel, "(symbol" );
|
m_out->Print( aNestLevel, "(symbol" );
|
||||||
|
|
||||||
if( !aSymbol->UseLibIdLookup() )
|
if( !aSymbol->UseLibIdLookup() )
|
||||||
|
{
|
||||||
m_out->Print( 0, " (lib_name %s)",
|
m_out->Print( 0, " (lib_name %s)",
|
||||||
m_out->Quotew( aSymbol->GetSchSymbolLibraryName() ).c_str() );
|
m_out->Quotew( aSymbol->GetSchSymbolLibraryName() ).c_str() );
|
||||||
|
}
|
||||||
|
|
||||||
m_out->Print( 0, " (lib_id %s) (at %s %s %s)",
|
m_out->Print( 0, " (lib_id %s) (at %s %s %s)",
|
||||||
m_out->Quotew( aSymbol->GetLibId().Format().wx_str() ).c_str(),
|
m_out->Quotew( aSymbol->GetLibId().Format().wx_str() ).c_str(),
|
||||||
|
@ -945,9 +947,7 @@ void SCH_SEXPR_PLUGIN::saveSymbol( SCH_COMPONENT* aSymbol, int aNestLevel )
|
||||||
|
|
||||||
m_out->Print( 0, "\n" );
|
m_out->Print( 0, "\n" );
|
||||||
|
|
||||||
// @todo Convert to full UUID if current UUID is a legacy time stamp.
|
m_out->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aSymbol->m_Uuid.AsString() ) );
|
||||||
m_out->Print( aNestLevel + 1, "(uuid %s)\n",
|
|
||||||
m_out->Quotew( aSymbol->m_Uuid.AsString() ).c_str() );
|
|
||||||
|
|
||||||
m_fieldId = MANDATORY_FIELDS;
|
m_fieldId = MANDATORY_FIELDS;
|
||||||
|
|
||||||
|
@ -958,10 +958,17 @@ void SCH_SEXPR_PLUGIN::saveSymbol( SCH_COMPONENT* aSymbol, int aNestLevel )
|
||||||
|
|
||||||
for( const SCH_PIN* pin : aSymbol->GetPins() )
|
for( const SCH_PIN* pin : aSymbol->GetPins() )
|
||||||
{
|
{
|
||||||
if( !pin->GetAlt().IsEmpty() )
|
if( pin->GetAlt().IsEmpty() )
|
||||||
{
|
{
|
||||||
m_out->Print( aNestLevel + 1, "(pin %s (alternate %s))\n",
|
m_out->Print( aNestLevel + 1, "(pin %s (uuid %s))\n",
|
||||||
m_out->Quotew( pin->GetNumber() ).c_str(),
|
m_out->Quotew( pin->GetNumber() ).c_str(),
|
||||||
|
TO_UTF8( aSymbol->m_Uuid.AsString() ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_out->Print( aNestLevel + 1, "(pin %s (uuid %s) (alternate %s))\n",
|
||||||
|
m_out->Quotew( pin->GetNumber() ).c_str(),
|
||||||
|
TO_UTF8( aSymbol->m_Uuid.AsString() ),
|
||||||
m_out->Quotew( pin->GetAlt() ).c_str() );
|
m_out->Quotew( pin->GetAlt() ).c_str() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1033,6 +1040,9 @@ void SCH_SEXPR_PLUGIN::saveBitmap( SCH_BITMAP* aBitmap, int aNestLevel )
|
||||||
m_out->Print( 0, " (scale %g)", aBitmap->GetImage()->GetScale() );
|
m_out->Print( 0, " (scale %g)", aBitmap->GetImage()->GetScale() );
|
||||||
|
|
||||||
m_out->Print( 0, "\n" );
|
m_out->Print( 0, "\n" );
|
||||||
|
|
||||||
|
m_out->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aBitmap->m_Uuid.AsString() ) );
|
||||||
|
|
||||||
m_out->Print( aNestLevel + 1, "(data" );
|
m_out->Print( aNestLevel + 1, "(data" );
|
||||||
|
|
||||||
wxMemoryOutputStream stream;
|
wxMemoryOutputStream stream;
|
||||||
|
@ -1105,7 +1115,10 @@ void SCH_SEXPR_PLUGIN::saveSheet( SCH_SHEET* aSheet, int aNestLevel )
|
||||||
FormatAngle( getSheetPinAngle( pin->GetEdge() ) * 10.0 ).c_str() );
|
FormatAngle( getSheetPinAngle( pin->GetEdge() ) * 10.0 ).c_str() );
|
||||||
|
|
||||||
pin->Format( m_out, aNestLevel + 1, 0 );
|
pin->Format( m_out, aNestLevel + 1, 0 );
|
||||||
m_out->Print( aNestLevel + 1, ")\n" ); // Closes pin token with font effects.
|
|
||||||
|
m_out->Print( aNestLevel + 2, "(uuid %s)\n", TO_UTF8( pin->m_Uuid.AsString() ) );
|
||||||
|
|
||||||
|
m_out->Print( aNestLevel + 1, ")\n" ); // Closes pin token.
|
||||||
}
|
}
|
||||||
|
|
||||||
m_out->Print( aNestLevel, ")\n" ); // Closes sheet token.
|
m_out->Print( aNestLevel, ")\n" ); // Closes sheet token.
|
||||||
|
@ -1131,9 +1144,10 @@ void SCH_SEXPR_PLUGIN::saveNoConnect( SCH_NO_CONNECT* aNoConnect, int aNestLevel
|
||||||
{
|
{
|
||||||
wxCHECK_RET( aNoConnect != nullptr && m_out != nullptr, "" );
|
wxCHECK_RET( aNoConnect != nullptr && m_out != nullptr, "" );
|
||||||
|
|
||||||
m_out->Print( aNestLevel, "(no_connect (at %s %s))\n",
|
m_out->Print( aNestLevel, "(no_connect (at %s %s) (uuid %s))\n",
|
||||||
FormatInternalUnits( aNoConnect->GetPosition().x ).c_str(),
|
FormatInternalUnits( aNoConnect->GetPosition().x ).c_str(),
|
||||||
FormatInternalUnits( aNoConnect->GetPosition().y ).c_str() );
|
FormatInternalUnits( aNoConnect->GetPosition().y ).c_str(),
|
||||||
|
TO_UTF8( aNoConnect->m_Uuid.AsString() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1160,6 +1174,9 @@ void SCH_SEXPR_PLUGIN::saveBusEntry( SCH_BUS_ENTRY_BASE* aBusEntry, int aNestLev
|
||||||
formatStroke( m_out, aNestLevel + 1, aBusEntry->GetStroke() );
|
formatStroke( m_out, aNestLevel + 1, aBusEntry->GetStroke() );
|
||||||
|
|
||||||
m_out->Print( 0, "\n" );
|
m_out->Print( 0, "\n" );
|
||||||
|
|
||||||
|
m_out->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aBusEntry->m_Uuid.AsString() ) );
|
||||||
|
|
||||||
m_out->Print( aNestLevel, ")\n" );
|
m_out->Print( aNestLevel, ")\n" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1198,6 +1215,9 @@ void SCH_SEXPR_PLUGIN::saveLine( SCH_LINE* aLine, int aNestLevel )
|
||||||
|
|
||||||
formatStroke( m_out, aNestLevel + 1, line_stroke );
|
formatStroke( m_out, aNestLevel + 1, line_stroke );
|
||||||
m_out->Print( 0, "\n" );
|
m_out->Print( 0, "\n" );
|
||||||
|
|
||||||
|
m_out->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aLine->m_Uuid.AsString() ) );
|
||||||
|
|
||||||
m_out->Print( aNestLevel, ")\n" );
|
m_out->Print( aNestLevel, ")\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1240,14 +1260,17 @@ void SCH_SEXPR_PLUGIN::saveText( SCH_TEXT* aText, int aNestLevel )
|
||||||
FormatAngle( aText->GetTextAngle() ).c_str() );
|
FormatAngle( aText->GetTextAngle() ).c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_out->Print( 0, "\n" );
|
||||||
|
aText->Format( m_out, aNestLevel, 0 );
|
||||||
|
|
||||||
|
m_out->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aText->m_Uuid.AsString() ) );
|
||||||
|
|
||||||
if( ( aText->Type() == SCH_GLOBAL_LABEL_T ) )
|
if( ( aText->Type() == SCH_GLOBAL_LABEL_T ) )
|
||||||
{
|
{
|
||||||
SCH_GLOBALLABEL* label = static_cast<SCH_GLOBALLABEL*>( aText );
|
SCH_GLOBALLABEL* label = static_cast<SCH_GLOBALLABEL*>( aText );
|
||||||
saveField( label->GetIntersheetRefs(), aNestLevel + 1 );
|
saveField( label->GetIntersheetRefs(), aNestLevel + 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
m_out->Print( 0, "\n" );
|
|
||||||
aText->Format( m_out, aNestLevel, 0 );
|
|
||||||
m_out->Print( aNestLevel, ")\n" ); // Closes text token.
|
m_out->Print( aNestLevel, ")\n" ); // Closes text token.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue