Implement variant processing for text var resolution.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/23355
This commit is contained in:
Jeff Young
2026-03-08 12:26:12 +00:00
parent 3f7b8baff5
commit 92bb000ce6
4 changed files with 19 additions and 14 deletions
+2
View File
@@ -226,7 +226,9 @@ wxString SCH_FIELD::GetShownText( bool aAllowExtraText, int aDepth ) const
return GetShownText( &currentSheet, aAllowExtraText, aDepth, variantName );
}
else
{
return GetShownText( nullptr, aAllowExtraText, aDepth );
}
}
+6 -4
View File
@@ -794,6 +794,8 @@ bool SCH_LABEL_BASE::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* toke
if( !schematic )
return false;
wxString variant = schematic->GetCurrentVariant();
if( operatingPoint.Matches( *token ) )
{
int precision = 3;
@@ -865,7 +867,7 @@ bool SCH_LABEL_BASE::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* toke
for( SCH_RULE_AREA* ruleArea : directive->GetConnectedRuleAreas() )
{
if( ruleArea->GetExcludedFromBOM() )
if( ruleArea->GetExcludedFromBOM( aPath, variant ) )
*token = _( "Excluded from BOM" );
}
@@ -878,7 +880,7 @@ bool SCH_LABEL_BASE::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* toke
for( SCH_RULE_AREA* ruleArea : directive->GetConnectedRuleAreas() )
{
if( ruleArea->GetExcludedFromBoard() )
if( ruleArea->GetExcludedFromBoard( aPath, variant ) )
*token = _( "Excluded from board" );
}
@@ -891,7 +893,7 @@ bool SCH_LABEL_BASE::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* toke
for( SCH_RULE_AREA* ruleArea : directive->GetConnectedRuleAreas() )
{
if( ruleArea->GetExcludedFromSim() )
if( ruleArea->GetExcludedFromSim( aPath, variant ) )
*token = _( "Excluded from simulation" );
}
@@ -904,7 +906,7 @@ bool SCH_LABEL_BASE::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* toke
for( SCH_RULE_AREA* ruleArea : directive->GetConnectedRuleAreas() )
{
if( ruleArea->GetDNP() )
if( ruleArea->GetDNP( aPath, variant ) )
*token = _( "DNP" );
}
+5 -4
View File
@@ -259,6 +259,7 @@ bool SCH_SHEET::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, in
}
PROJECT* project = &schematic->Project();
wxString variant = schematic->GetCurrentVariant();
// We cannot resolve text variables initially on load as we need to first load the screen and
// then parse the hierarchy. So skip the resolution if the screen isn't set yet
@@ -286,7 +287,7 @@ bool SCH_SHEET::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, in
{
*token = wxEmptyString;
if( aPath->GetExcludedFromBOM() || this->ResolveExcludedFromBOM() )
if( aPath->GetExcludedFromBOM( variant ) || this->ResolveExcludedFromBOM( aPath, variant ) )
*token = _( "Excluded from BOM" );
return true;
@@ -295,7 +296,7 @@ bool SCH_SHEET::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, in
{
*token = wxEmptyString;
if( aPath->GetExcludedFromBoard() || this->ResolveExcludedFromBoard() )
if( aPath->GetExcludedFromBoard( variant ) || this->ResolveExcludedFromBoard( aPath, variant ) )
*token = _( "Excluded from board" );
return true;
@@ -304,7 +305,7 @@ bool SCH_SHEET::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, in
{
*token = wxEmptyString;
if( aPath->GetExcludedFromSim() || this->ResolveExcludedFromSim() )
if( aPath->GetExcludedFromSim( variant ) || this->ResolveExcludedFromSim( aPath, variant ) )
*token = _( "Excluded from simulation" );
return true;
@@ -313,7 +314,7 @@ bool SCH_SHEET::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, in
{
*token = wxEmptyString;
if( aPath->GetDNP() || this->ResolveDNP() )
if( aPath->GetDNP( variant ) || this->ResolveDNP( aPath, variant ) )
*token = _( "DNP" );
return true;
+6 -6
View File
@@ -1797,6 +1797,8 @@ bool SCH_SYMBOL::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token,
if( !schematic )
return false;
wxString variant = aVariantName.IsEmpty() ? schematic->GetCurrentVariant() : aVariantName;
if( operatingPoint.Matches( *token ) )
{
wxString pin( operatingPoint.GetMatch( *token, 1 ).Lower() );
@@ -1991,7 +1993,7 @@ bool SCH_SYMBOL::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token,
{
*token = wxEmptyString;
if( aPath->GetExcludedFromBOM() || this->ResolveExcludedFromBOM() )
if( aPath->GetExcludedFromBOM( variant ) || this->ResolveExcludedFromBOM( aPath, variant ) )
*token = _( "Excluded from BOM" );
return true;
@@ -2000,7 +2002,7 @@ bool SCH_SYMBOL::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token,
{
*token = wxEmptyString;
if( aPath->GetExcludedFromBoard() || this->ResolveExcludedFromBoard() )
if( aPath->GetExcludedFromBoard( variant ) || this->ResolveExcludedFromBoard( aPath, variant ) )
*token = _( "Excluded from board" );
return true;
@@ -2009,7 +2011,7 @@ bool SCH_SYMBOL::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token,
{
*token = wxEmptyString;
if( aPath->GetExcludedFromSim() || this->ResolveExcludedFromSim() )
if( aPath->GetExcludedFromSim( variant ) || this->ResolveExcludedFromSim( aPath, variant ) )
*token = _( "Excluded from simulation" );
return true;
@@ -2018,9 +2020,7 @@ bool SCH_SYMBOL::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token,
{
*token = wxEmptyString;
wxString variant = aVariantName.IsEmpty() ? schematic->GetCurrentVariant() : aVariantName;
if( aPath->GetDNP() || this->ResolveDNP( aPath, variant ) )
if( aPath->GetDNP( variant ) || this->ResolveDNP( aPath, variant ) )
*token = _( "DNP" );
return true;