From 59dc6c8e45fdaef447385a9608733e2486d37940 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 6 Sep 2022 00:21:19 +0100 Subject: [PATCH] Add wire and bus popups for PDF export. Fixes https://gitlab.com/kicad/code/kicad/issues/12157 --- eeschema/sch_line.cpp | 37 +++++++++++++++++++++++++++++++++++++ eeschema/sch_symbol.cpp | 9 +++++++-- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index 47b440df8f..f55060d58c 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -838,6 +838,43 @@ void SCH_LINE::Plot( PLOTTER* aPlotter, bool aBackground ) const aPlotter->FinishTo( m_end ); aPlotter->SetDash( penWidth, PLOT_DASH_TYPE::SOLID ); + + if( SCHEMATIC* schematic = Schematic() ) + { + std::vector properties; + BOX2I bbox = GetBoundingBox(); + bbox.Inflate( GetPenWidth() * 3 ); + + if( GetLayer() == LAYER_WIRE ) + { + 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" ), + UnescapeString( netName ) ) ); + + properties.emplace_back( wxString::Format( wxT( "!%s = %s" ), + _( "Net class" ), + UnescapeString( className ) ) ); + } + } + 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 ); + } } diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index 35180b9d0b..80707a6e85 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -2015,8 +2015,13 @@ void SCH_SYMBOL::Plot( PLOTTER* aPlotter, bool aBackground ) const field.GetShownText() ) ); } - properties.emplace_back( _( "!Description = " ) + m_part->GetDescription() ); - properties.emplace_back( _( "!Keywords = " ) + m_part->GetKeyWords() ); + properties.emplace_back( wxString::Format( wxT( "!%s = %s" ), + _( "Description" ), + m_part->GetDescription() ) ); + + properties.emplace_back( wxString::Format( wxT( "!%s = %s" ), + _( "Keywords" ), + m_part->GetKeyWords() ) ); aPlotter->HyperlinkMenu( GetBoundingBox(), properties );