Schematic: correctly resolve label nets using sheet variables

This commit is contained in:
Mike Williams 2023-03-08 10:31:24 -05:00
parent c8fdac7abe
commit bf59f1246b
3 changed files with 17 additions and 4 deletions

View File

@ -292,7 +292,8 @@ wxString CONNECTION_SUBGRAPH::driverName( SCH_ITEM* aItem ) const
case SCH_HIER_LABEL_T:
case SCH_SHEET_PIN_T:
{
return EscapeString( static_cast<SCH_TEXT*>( aItem )->GetShownText(), CTX_NETNAME );
return EscapeString( static_cast<SCH_TEXT*>( aItem )->GetShownText( &m_sheet ),
CTX_NETNAME );
break;
}

View File

@ -339,12 +339,19 @@ const BOX2I SCH_TEXT::GetBoundingBox() const
}
wxString SCH_TEXT::GetShownText( int aDepth, bool aAllowExtraText ) const
wxString SCH_TEXT::GetShownText( const SCH_SHEET_PATH* aPath, int aDepth, bool aAllowExtraText ) const
{
SCH_SHEET* sheet = nullptr;
if( aPath )
sheet = aPath->Last();
else if( Schematic() )
sheet = Schematic()->CurrentSheet().Last();
std::function<bool( wxString* )> textResolver =
[&]( wxString* token ) -> bool
{
if( SCH_SHEET* sheet = Schematic()->CurrentSheet().Last() )
if( sheet )
{
if( sheet->ResolveTextVar( token, aDepth + 1 ) )
return true;

View File

@ -128,7 +128,12 @@ public:
return wxT( "SCH_TEXT" );
}
wxString GetShownText( int aDepth = 0, bool aAllowExtraText = true ) const override;
wxString GetShownText( const SCH_SHEET_PATH* aPath, int aDepth = 0,
bool aAllowExtraText = true ) const;
wxString GetShownText( int aDepth = 0, bool aAllowExtraText = true ) const override
{
return GetShownText( nullptr, aDepth, aAllowExtraText );
}
bool IsHypertext() const override
{