diff --git a/eeschema/sch_rtree.h b/eeschema/sch_rtree.h index ccfdc60e80..dfcdc99ac6 100644 --- a/eeschema/sch_rtree.h +++ b/eeschema/sch_rtree.h @@ -225,6 +225,11 @@ public: { return type_tree->end( m_rect ); } + + bool empty() + { + return type_tree->Count() == 0; + } }; EE_TYPE OfType( KICAD_T aType ) const diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index df083b431f..e1bddd99bf 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -1076,9 +1076,10 @@ void SCH_SCREEN::Print( const RENDER_SETTINGS* aSettings ) void SCH_SCREEN::Plot( PLOTTER* aPlotter ) const { // Ensure links are up to date, even if a library was reloaded for some reason: - std::vector< SCH_ITEM* > junctions; - std::vector< SCH_ITEM* > bitmaps; - std::vector< SCH_ITEM* > other; + std::vector junctions; + std::vector bitmaps; + std::vector symbols; + std::vector other; for( SCH_ITEM* item : Items() ) { @@ -1091,6 +1092,21 @@ void SCH_SCREEN::Plot( PLOTTER* aPlotter ) const bitmaps.push_back( item ); else other.push_back( item ); + + // Where the symbols overlap each other, we need to plot the text items a second + // time to get them on top of the overlapping element. This collection is in addition + // to the symbols already collected in `other` + if( item->Type() == SCH_SYMBOL_T ) + { + for( SCH_ITEM* sym : m_rtree.Overlapping( SCH_SYMBOL_T, item->GetBoundingBox() ) ) + { + if( sym != item ) + { + symbols.push_back( static_cast( item ) ); + break; + } + } + } } /// Sort to ensure plot-order consistency with screen drawing @@ -1127,6 +1143,18 @@ void SCH_SCREEN::Plot( PLOTTER* aPlotter ) const item->Plot( aPlotter, !background ); } + // After plotting the symbols as a group above (in `other`), we need to overplot the pins + // and symbols to ensure that they are always visible + for( const SCH_SYMBOL* sym :symbols ) + { + aPlotter->SetCurrentLineWidth( std::max( sym->GetPenWidth(), defaultPenWidth ) ); + + for( SCH_FIELD field : sym->GetFields() ) + field.Plot( aPlotter, false ); + + sym->PlotPins( aPlotter ); + } + for( const SCH_ITEM* item : junctions ) { aPlotter->SetCurrentLineWidth( std::max( item->GetPenWidth(), defaultPenWidth ) ); diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index 0a6bd3b883..8e3721cefe 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -1946,6 +1946,35 @@ void SCH_SYMBOL::Plot( PLOTTER* aPlotter, bool aBackground ) const } +void SCH_SYMBOL::PlotPins( PLOTTER* aPlotter ) const +{ + if( m_part ) + { + LIB_PINS libPins; + m_part->GetPins( libPins, GetUnit(), GetConvert() ); + + // Copy the source to stay const + LIB_SYMBOL tempSymbol( *m_part ); + LIB_PINS tempPins; + tempSymbol.GetPins( tempPins, GetUnit(), GetConvert() ); + + TRANSFORM transform = GetTransform(); + + // Copy the pin info from the symbol to the temp pins + for( unsigned i = 0; i < tempPins.size(); ++ i ) + { + SCH_PIN* symbolPin = GetPin( libPins[ i ] ); + LIB_PIN* tempPin = tempPins[ i ]; + + tempPin->SetName( symbolPin->GetShownName() ); + tempPin->SetType( symbolPin->GetType() ); + tempPin->SetShape( symbolPin->GetShape() ); + tempPin->Plot( aPlotter, false, m_pos, transform); + } + } +} + + bool SCH_SYMBOL::HasBrightenedPins() { for( const auto& pin : m_pins ) diff --git a/eeschema/sch_symbol.h b/eeschema/sch_symbol.h index fa1ceeccd8..036f37c330 100644 --- a/eeschema/sch_symbol.h +++ b/eeschema/sch_symbol.h @@ -662,6 +662,14 @@ public: void Plot( PLOTTER* aPlotter, bool aBackground ) const override; + /** + * Plot just the symbol pins. This is separated to match the GAL display order. The pins are + * ALSO plotted with the symbol group. This replotting allows us to ensure that they are shown above + * other elements in the schematic + * @param aPlotter + */ + void PlotPins( PLOTTER* aPlotter ) const; + EDA_ITEM* Clone() const override; #if defined(DEBUG)