From 48ab1d1a937e159b4ae5b1039265d6458d8c93ef Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sat, 23 May 2020 23:57:10 -0400 Subject: [PATCH] Set sheet pins to bus color if they are a bus in the child sheet As a visual aid, we can peek into the child to see if a pin represents a bus in the child (in the case of aliases etc we might not be able to tell by the name of the pin). Only do this if there isn't anything else driving a connection onto the sheet pin in the parent sheet. Fixes https://gitlab.com/kicad/code/kicad/-/issues/2619 --- eeschema/connection_graph.cpp | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/eeschema/connection_graph.cpp b/eeschema/connection_graph.cpp index a868a187b2..78fb165ede 100644 --- a/eeschema/connection_graph.cpp +++ b/eeschema/connection_graph.cpp @@ -1429,7 +1429,46 @@ void CONNECTION_GRAPH::buildConnectionGraph() } if( subgraph->m_driver_connection->IsBus() ) + { + // No other processing to do on buses continue; + } + else + { + // As a visual aid, we can check sheet pins that are driven by themselves to see + // if they should be promoted to buses + + if( subgraph->m_driver->Type() == SCH_SHEET_PIN_T ) + { + SCH_SHEET_PIN* pin = static_cast( subgraph->m_driver ); + + if( SCH_SHEET* sheet = pin->GetParent() ) + { + wxString pinText = pin->GetText(); + + for( auto item : sheet->GetScreen()->Items().OfType( SCH_HIER_LABEL_T ) ) + { + auto label = static_cast( item ); + + if( label->GetText() == pinText ) + { + SCH_SHEET_PATH path = subgraph->m_sheet; + path.push_back( sheet ); + + SCH_CONNECTION* parent_conn = label->Connection( path ); + + if( parent_conn && parent_conn->IsBus() ) + subgraph->m_driver_connection->SetType( CONNECTION_TYPE::BUS ); + + break; + } + } + + if( subgraph->m_driver_connection->IsBus() ) + continue; + } + } + } auto key = std::make_pair( subgraph->GetNetName(), subgraph->m_driver_connection->NetCode() );