Allow the current sheet a chance to resolve text variables.
Fixes https://gitlab.com/kicad/code/kicad/issues/8692
This commit is contained in:
parent
a619ef9d53
commit
9bed145475
|
@ -502,12 +502,7 @@ bool SCH_LABEL_BASE::ResolveTextVar( wxString* token, int aDepth ) const
|
|||
*token = wxEmptyString;
|
||||
|
||||
if( connection )
|
||||
{
|
||||
PROJECT_FILE& projectFile = Schematic()->Prj().GetProjectFile();
|
||||
std::shared_ptr<NET_SETTINGS>& netSettings = projectFile.NetSettings();
|
||||
|
||||
*token = UnescapeString( netSettings->GetEffectiveNetClass( connection->Name() )->GetName() );
|
||||
}
|
||||
*token = GetEffectiveNetClass()->GetName();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -528,6 +523,11 @@ bool SCH_LABEL_BASE::ResolveTextVar( wxString* token, int aDepth ) const
|
|||
if( sheet->ResolveTextVar( token, aDepth ) )
|
||||
return true;
|
||||
}
|
||||
else if( SCH_SHEET* sheet = Schematic()->CurrentSheet().Last() )
|
||||
{
|
||||
if( sheet->ResolveTextVar( token, aDepth ) )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -914,34 +914,29 @@ void SCH_LABEL_BASE::Plot( PLOTTER* aPlotter, bool aBackground ) const
|
|||
for( const SCH_FIELD& field : m_fields )
|
||||
field.Plot( aPlotter, aBackground );
|
||||
|
||||
if( !m_fields.empty() )
|
||||
// Plot attributes to a hypertext menu
|
||||
std::vector<wxString> properties;
|
||||
|
||||
if( connection )
|
||||
{
|
||||
std::vector<wxString> properties;
|
||||
properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
|
||||
_( "Net" ),
|
||||
connection->Name() ) );
|
||||
|
||||
if( schematic && connection )
|
||||
{
|
||||
auto& netSettings = schematic->Prj().GetProjectFile().m_NetSettings;
|
||||
wxString netName = connection->Name();
|
||||
wxString className = netSettings->GetEffectiveNetClass( netName )->GetName();
|
||||
|
||||
properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
|
||||
_( "Net" ),
|
||||
UnescapeString( netName ) ) );
|
||||
|
||||
properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
|
||||
_( "Resolved netclass" ),
|
||||
UnescapeString( className ) ) );
|
||||
}
|
||||
|
||||
for( const SCH_FIELD& field : GetFields() )
|
||||
{
|
||||
properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
|
||||
field.GetName(),
|
||||
field.GetShownText() ) );
|
||||
}
|
||||
|
||||
aPlotter->HyperlinkMenu( GetBodyBoundingBox(), properties );
|
||||
properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
|
||||
_( "Resolved netclass" ),
|
||||
GetEffectiveNetClass()->GetName() ) );
|
||||
}
|
||||
|
||||
for( const SCH_FIELD& field : GetFields() )
|
||||
{
|
||||
properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
|
||||
field.GetName(),
|
||||
field.GetShownText() ) );
|
||||
}
|
||||
|
||||
if( !properties.empty() )
|
||||
aPlotter->HyperlinkMenu( GetBodyBoundingBox(), properties );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -839,42 +839,36 @@ void SCH_LINE::Plot( PLOTTER* aPlotter, bool aBackground ) const
|
|||
|
||||
aPlotter->SetDash( penWidth, PLOT_DASH_TYPE::SOLID );
|
||||
|
||||
if( SCHEMATIC* schematic = Schematic() )
|
||||
// Plot attributes to a hypertext menu
|
||||
std::vector<wxString> properties;
|
||||
BOX2I bbox = GetBoundingBox();
|
||||
bbox.Inflate( GetPenWidth() * 3 );
|
||||
|
||||
if( GetLayer() == LAYER_WIRE )
|
||||
{
|
||||
std::vector<wxString> properties;
|
||||
BOX2I bbox = GetBoundingBox();
|
||||
bbox.Inflate( GetPenWidth() * 3 );
|
||||
|
||||
if( GetLayer() == LAYER_WIRE )
|
||||
if( SCH_CONNECTION* connection = Connection() )
|
||||
{
|
||||
if( SCH_CONNECTION* connection = Connection() )
|
||||
{
|
||||
auto& netSettings = schematic->Prj().GetProjectFile().m_NetSettings;
|
||||
wxString netName = connection->Name();
|
||||
wxString className = netSettings->GetEffectiveNetClass( netName )->GetName();
|
||||
properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
|
||||
_( "Net" ),
|
||||
connection->Name() ) );
|
||||
|
||||
properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
|
||||
_( "Net" ),
|
||||
UnescapeString( netName ) ) );
|
||||
|
||||
properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
|
||||
_( "Resolved netclass" ),
|
||||
UnescapeString( className ) ) );
|
||||
}
|
||||
properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
|
||||
_( "Resolved netclass" ),
|
||||
GetEffectiveNetClass()->GetName() ) );
|
||||
}
|
||||
else if( GetLayer() == LAYER_BUS )
|
||||
{
|
||||
if( SCH_CONNECTION* connection = Connection() )
|
||||
{
|
||||
for( std::shared_ptr<SCH_CONNECTION>& member : connection->Members() )
|
||||
properties.emplace_back( wxT( "!" ) + UnescapeString( member->Name() ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if( !properties.empty() )
|
||||
aPlotter->HyperlinkMenu( bbox, properties );
|
||||
}
|
||||
else if( GetLayer() == LAYER_BUS )
|
||||
{
|
||||
if( SCH_CONNECTION* connection = Connection() )
|
||||
{
|
||||
for( std::shared_ptr<SCH_CONNECTION>& member : connection->Members() )
|
||||
properties.emplace_back( wxT( "!" ) + member->Name() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if( !properties.empty() )
|
||||
aPlotter->HyperlinkMenu( bbox, properties );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2006,6 +2006,7 @@ void SCH_SYMBOL::Plot( PLOTTER* aPlotter, bool aBackground ) const
|
|||
field.Plot( aPlotter, local_background );
|
||||
}
|
||||
|
||||
// Plot attributes to a hypertext menu
|
||||
std::vector<wxString> properties;
|
||||
|
||||
for( const SCH_FIELD& field : GetFields() )
|
||||
|
|
Loading…
Reference in New Issue