Schematic: correctly resolve global power nets using sheet variables
Fixes: https://gitlab.com/kicad/code/kicad/-/issues/7445
This commit is contained in:
parent
e4ec74e1ac
commit
c8fdac7abe
|
@ -552,17 +552,20 @@ void CONNECTION_GRAPH::updateItemConnectivity( const SCH_SHEET_PATH& aSheet,
|
|||
|
||||
for( SCH_PIN* pin : symbol->GetPins( &aSheet ) )
|
||||
{
|
||||
pin->InitializeConnection( aSheet, this );
|
||||
SCH_CONNECTION* conn = pin->InitializeConnection( aSheet, this );
|
||||
|
||||
VECTOR2I pos = pin->GetPosition();
|
||||
|
||||
// because calling the first time is not thread-safe
|
||||
pin->GetDefaultNetName( aSheet );
|
||||
wxString name = pin->GetDefaultNetName( aSheet );
|
||||
pin->ConnectedItems( aSheet ).clear();
|
||||
|
||||
// power symbol pins need to be post-processed later
|
||||
if( pin->IsGlobalPower() )
|
||||
{
|
||||
conn->SetName( name );
|
||||
m_global_power_pins.emplace_back( std::make_pair( aSheet, pin ) );
|
||||
}
|
||||
|
||||
connection_map[ pos ].push_back( pin );
|
||||
m_items.emplace_back( pin );
|
||||
|
@ -1000,7 +1003,7 @@ void CONNECTION_GRAPH::generateGlobalPowerPinSubGraphs()
|
|||
// in the symbol, but we support legacy non-power symbols with global
|
||||
// power connections based on invisible, power-in, pin's names.
|
||||
if( pin->GetLibPin()->GetParent()->IsPower() )
|
||||
connection->SetName( pin->GetParentSymbol()->GetValueFieldText( true ) );
|
||||
connection->SetName( pin->GetParentSymbol()->GetValueFieldText( true, &sheet ) );
|
||||
else
|
||||
connection->SetName( pin->GetShownName() );
|
||||
|
||||
|
|
|
@ -172,12 +172,13 @@ void SCH_FIELD::SetId( int aId )
|
|||
}
|
||||
|
||||
|
||||
wxString SCH_FIELD::GetShownText( int aDepth, bool aAllowExtraText ) const
|
||||
wxString SCH_FIELD::GetShownText( const SCH_SHEET_PATH* aPath, int aDepth,
|
||||
bool aAllowExtraText ) const
|
||||
{
|
||||
std::function<bool( wxString* )> symbolResolver =
|
||||
[&]( wxString* token ) -> bool
|
||||
{
|
||||
return static_cast<SCH_SYMBOL*>( m_parent )->ResolveTextVar( token, aDepth + 1 );
|
||||
return static_cast<SCH_SYMBOL*>( m_parent )->ResolveTextVar( token, aDepth + 1, aPath );
|
||||
};
|
||||
|
||||
std::function<bool( wxString* )> sheetResolver =
|
||||
|
|
|
@ -126,7 +126,12 @@ public:
|
|||
|
||||
void SetId( int aId );
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
COLOR4D GetFieldColor() const;
|
||||
|
||||
|
|
|
@ -274,7 +274,8 @@ wxString SCH_PIN::GetDefaultNetName( const SCH_SHEET_PATH& aPath, bool aForceNoC
|
|||
if( IsGlobalPower() )
|
||||
{
|
||||
if( GetLibPin()->GetParent()->IsPower() )
|
||||
return EscapeString( GetParentSymbol()->GetValueFieldText( true ), CTX_NETNAME );
|
||||
return EscapeString( GetParentSymbol()->GetValueFieldText( true, &aPath ),
|
||||
CTX_NETNAME );
|
||||
else
|
||||
return EscapeString( m_libPin->GetName(), CTX_NETNAME );
|
||||
}
|
||||
|
|
|
@ -832,10 +832,10 @@ void SCH_SYMBOL::SetUnitSelection( int aUnitSelection )
|
|||
}
|
||||
|
||||
|
||||
const wxString SCH_SYMBOL::GetValueFieldText( bool aResolve ) const
|
||||
const wxString SCH_SYMBOL::GetValueFieldText( bool aResolve, const SCH_SHEET_PATH* aPath ) const
|
||||
{
|
||||
if( aResolve )
|
||||
return GetField( VALUE_FIELD )->GetShownText();
|
||||
return GetField( VALUE_FIELD )->GetShownText( aPath );
|
||||
|
||||
return GetField( VALUE_FIELD )->GetText();
|
||||
}
|
||||
|
@ -1153,7 +1153,7 @@ void SCH_SYMBOL::GetContextualTextVars( wxArrayString* aVars ) const
|
|||
}
|
||||
|
||||
|
||||
bool SCH_SYMBOL::ResolveTextVar( wxString* token, int aDepth ) const
|
||||
bool SCH_SYMBOL::ResolveTextVar( wxString* token, int aDepth, const SCH_SHEET_PATH* aPath ) const
|
||||
{
|
||||
static wxRegEx operatingPoint( wxT( "^"
|
||||
"OP"
|
||||
|
@ -1167,6 +1167,8 @@ bool SCH_SYMBOL::ResolveTextVar( wxString* token, int aDepth ) const
|
|||
if( !schematic )
|
||||
return false;
|
||||
|
||||
SCH_SHEET* sheet = aPath ? aPath->Last() : schematic->CurrentSheet().Last();
|
||||
|
||||
if( operatingPoint.Matches( *token ) )
|
||||
{
|
||||
wxString port( operatingPoint.GetMatch( *token, 1 ) );
|
||||
|
@ -1309,7 +1311,7 @@ bool SCH_SYMBOL::ResolveTextVar( wxString* token, int aDepth ) const
|
|||
|
||||
// See if parent can resolve it (this will recurse to ancestors)
|
||||
|
||||
if( SCH_SHEET* sheet = schematic->CurrentSheet().Last() )
|
||||
if( sheet )
|
||||
{
|
||||
if( sheet->ResolveTextVar( token, aDepth + 1 ) )
|
||||
return true;
|
||||
|
|
|
@ -327,7 +327,8 @@ public:
|
|||
*
|
||||
* @param aDepth a counter to limit recursion and circular references.
|
||||
*/
|
||||
bool ResolveTextVar( wxString* token, int aDepth = 0 ) const;
|
||||
bool ResolveTextVar( wxString* token, int aDepth = 0,
|
||||
const SCH_SHEET_PATH* aPath = nullptr ) const;
|
||||
|
||||
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
|
||||
|
||||
|
@ -461,7 +462,7 @@ public:
|
|||
m_fields = aFields; // vector copying, length is changed possibly
|
||||
}
|
||||
|
||||
const wxString GetValueFieldText( bool aResolve ) const;
|
||||
const wxString GetValueFieldText( bool aResolve, const SCH_SHEET_PATH* aPath = nullptr ) const;
|
||||
void SetValueFieldText( const wxString& aValue );
|
||||
|
||||
const wxString GetFootprintFieldText( bool aResolve ) const;
|
||||
|
|
Loading…
Reference in New Issue