From 69e9f4ada221bee8d737ca62e0b3d76dabef6dbe Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 16 Mar 2023 15:31:39 +0100 Subject: [PATCH] DIALOG_LABEL_PROPERTIES, add global label: better filtering of candidates. The list of candidates (names) must be restricted to existing global labels and symbols creating a global net name: power symbols having only one power input pin (a power output does not create net name). Fixes #14319 https://gitlab.com/kicad/code/kicad/issues/14319 --- eeschema/dialogs/dialog_label_properties.cpp | 6 +++++- eeschema/sch_symbol.cpp | 19 +++++++++++++++++++ eeschema/sch_symbol.h | 7 +++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/eeschema/dialogs/dialog_label_properties.cpp b/eeschema/dialogs/dialog_label_properties.cpp index f9fe4928ee..a7ec329154 100644 --- a/eeschema/dialogs/dialog_label_properties.cpp +++ b/eeschema/dialogs/dialog_label_properties.cpp @@ -286,7 +286,11 @@ bool DIALOG_LABEL_PROPERTIES::TransferDataToWindow() for( SCH_ITEM* item : screen->Items().OfType( SCH_SYMBOL_LOCATE_POWER_T ) ) { const SCH_SYMBOL* power = static_cast( item ); - existingLabels.insert( UnescapeString( power->GetValueFieldText( false ) ) ); + + // Ensure the symbol has the Power (i.e. equivalent to a global label + // before adding its value in list + if( power->IsSymbolLikePowerGlobalLabel() ) + existingLabels.insert( UnescapeString( power->GetValueFieldText( false ) ) ); } } diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index 28c01c374c..ae725220a7 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -2279,3 +2279,22 @@ bool SCH_SYMBOL::IsPointClickableAnchor( const VECTOR2I& aPos ) const return false; } + + +bool SCH_SYMBOL::IsSymbolLikePowerGlobalLabel() const +{ + // return true if the symbol is equivalent to a global label: + // It is a Power symbol + // It has only one pin type Power input + + if( !GetLibSymbolRef() || !GetLibSymbolRef()->IsPower() ) + return false; + + std::vector pin_list = GetAllLibPins(); + + if( pin_list.size() != 1 ) + return false; + + return pin_list[0]->GetType() == ELECTRICAL_PINTYPE::PT_POWER_IN; +} + diff --git a/eeschema/sch_symbol.h b/eeschema/sch_symbol.h index 9c5ee0b314..b6b812b4cd 100644 --- a/eeschema/sch_symbol.h +++ b/eeschema/sch_symbol.h @@ -755,6 +755,13 @@ public: bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override; + /** + * @return true if the symbol is equivalent to a global label: + * It is a Power symbol + * It has only one pin type Power input + */ + bool IsSymbolLikePowerGlobalLabel() const; + private: BOX2I doGetBoundingBox( bool aIncludePins, bool aIncludeFields ) const;