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;
|
*token = wxEmptyString;
|
||||||
|
|
||||||
if( connection )
|
if( connection )
|
||||||
{
|
*token = GetEffectiveNetClass()->GetName();
|
||||||
PROJECT_FILE& projectFile = Schematic()->Prj().GetProjectFile();
|
|
||||||
std::shared_ptr<NET_SETTINGS>& netSettings = projectFile.NetSettings();
|
|
||||||
|
|
||||||
*token = UnescapeString( netSettings->GetEffectiveNetClass( connection->Name() )->GetName() );
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -528,6 +523,11 @@ bool SCH_LABEL_BASE::ResolveTextVar( wxString* token, int aDepth ) const
|
||||||
if( sheet->ResolveTextVar( token, aDepth ) )
|
if( sheet->ResolveTextVar( token, aDepth ) )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if( SCH_SHEET* sheet = Schematic()->CurrentSheet().Last() )
|
||||||
|
{
|
||||||
|
if( sheet->ResolveTextVar( token, aDepth ) )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -914,34 +914,29 @@ void SCH_LABEL_BASE::Plot( PLOTTER* aPlotter, bool aBackground ) const
|
||||||
for( const SCH_FIELD& field : m_fields )
|
for( const SCH_FIELD& field : m_fields )
|
||||||
field.Plot( aPlotter, aBackground );
|
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 )
|
properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
|
||||||
{
|
_( "Resolved netclass" ),
|
||||||
auto& netSettings = schematic->Prj().GetProjectFile().m_NetSettings;
|
GetEffectiveNetClass()->GetName() ) );
|
||||||
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 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 );
|
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;
|
if( SCH_CONNECTION* connection = Connection() )
|
||||||
BOX2I bbox = GetBoundingBox();
|
|
||||||
bbox.Inflate( GetPenWidth() * 3 );
|
|
||||||
|
|
||||||
if( GetLayer() == LAYER_WIRE )
|
|
||||||
{
|
{
|
||||||
if( SCH_CONNECTION* connection = Connection() )
|
properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
|
||||||
{
|
_( "Net" ),
|
||||||
auto& netSettings = schematic->Prj().GetProjectFile().m_NetSettings;
|
connection->Name() ) );
|
||||||
wxString netName = connection->Name();
|
|
||||||
wxString className = netSettings->GetEffectiveNetClass( netName )->GetName();
|
|
||||||
|
|
||||||
properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
|
properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
|
||||||
_( "Net" ),
|
_( "Resolved netclass" ),
|
||||||
UnescapeString( netName ) ) );
|
GetEffectiveNetClass()->GetName() ) );
|
||||||
|
|
||||||
properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
|
|
||||||
_( "Resolved netclass" ),
|
|
||||||
UnescapeString( className ) ) );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
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 );
|
field.Plot( aPlotter, local_background );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Plot attributes to a hypertext menu
|
||||||
std::vector<wxString> properties;
|
std::vector<wxString> properties;
|
||||||
|
|
||||||
for( const SCH_FIELD& field : GetFields() )
|
for( const SCH_FIELD& field : GetFields() )
|
||||||
|
|
Loading…
Reference in New Issue