diff --git a/eeschema/sch_label.cpp b/eeschema/sch_label.cpp index e51866cdd8..ef93a52763 100644 --- a/eeschema/sch_label.cpp +++ b/eeschema/sch_label.cpp @@ -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& 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 properties; + + if( connection ) { - std::vector 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 ); } diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index bb8623f639..638d96d3df 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -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 properties; + BOX2I bbox = GetBoundingBox(); + bbox.Inflate( GetPenWidth() * 3 ); + + if( GetLayer() == LAYER_WIRE ) { - std::vector 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& 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& member : connection->Members() ) + properties.emplace_back( wxT( "!" ) + member->Name() ); + } + + } + + if( !properties.empty() ) + aPlotter->HyperlinkMenu( bbox, properties ); } diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index 80707a6e85..3894ed4b46 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -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 properties; for( const SCH_FIELD& field : GetFields() )