From b718c228fe976ed828b9830e2ada8d7768be415e Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 14 Mar 2024 10:01:58 +0100 Subject: [PATCH] Symbol Editor: do not allow to select fully invisible pins and fields Of course, invisible pins or fields shown by using option Show invisible pins or Show invisible fields can be selected. From master branch --- eeschema/symbol_editor/symbol_edit_frame.cpp | 14 ++++++++++ eeschema/symbol_editor/symbol_edit_frame.h | 5 +++- eeschema/tools/ee_selection_tool.cpp | 29 +++++++++++++++++++- 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/eeschema/symbol_editor/symbol_edit_frame.cpp b/eeschema/symbol_editor/symbol_edit_frame.cpp index 51f1be9e53..299a627938 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.cpp +++ b/eeschema/symbol_editor/symbol_edit_frame.cpp @@ -1846,3 +1846,17 @@ void SYMBOL_EDIT_FRAME::UpdateItem( EDA_ITEM* aItem, bool isAddOrDelete, bool aU eda_text->ClearRenderCache(); } } + + +bool SYMBOL_EDIT_FRAME::GetShowInvisibleFields() +{ + // Returns the current render option for invisible fields + return GetRenderSettings()->m_ShowHiddenLibFields; +} + + +bool SYMBOL_EDIT_FRAME::GetShowInvisiblePins() +{ + // Returns the current render option for invisible pins + return GetRenderSettings()->m_ShowHiddenLibPins; +} diff --git a/eeschema/symbol_editor/symbol_edit_frame.h b/eeschema/symbol_editor/symbol_edit_frame.h index 5668120964..c199ad79f8 100644 --- a/eeschema/symbol_editor/symbol_edit_frame.h +++ b/eeschema/symbol_editor/symbol_edit_frame.h @@ -3,7 +3,7 @@ * * Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2008 Wayne Stambaugh - * Copyright (C) 2004-2023 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2004-2024 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2017 CERN * @author Maciej Suminski * @@ -242,6 +242,9 @@ public: bool GetShowDeMorgan() const { return m_showDeMorgan; } void SetShowDeMorgan( bool show ) { m_showDeMorgan = show; } + bool GetShowInvisibleFields(); + bool GetShowInvisiblePins(); + void ClearMsgPanel() override { UpdateSymbolMsgPanelInfo(); diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index 6b0398a599..4d59a84688 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2019 CERN - * Copyright (C) 2019-2023 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2019-2024 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -1055,8 +1055,35 @@ bool EE_SELECTION_TOOL::CollectHits( EE_COLLECTOR& aCollector, const VECTOR2I& a void EE_SELECTION_TOOL::narrowSelection( EE_COLLECTOR& collector, const VECTOR2I& aWhere, bool aCheckLocked, bool aSelectedOnly ) { + SYMBOL_EDIT_FRAME* symbolEditorFrame = dynamic_cast( m_frame ); + for( int i = collector.GetCount() - 1; i >= 0; --i ) { + if( symbolEditorFrame ) + { + // Do not select invisible items if they are not displayed + EDA_ITEM* item = static_cast( collector[i] ); + + if( item->Type() == LIB_FIELD_T ) + { + if( !static_cast( item )->IsVisible() + && !symbolEditorFrame->GetShowInvisibleFields() ) + { + collector.Remove( i ); + continue; + } + } + else if( item->Type() == LIB_PIN_T ) + { + if( !static_cast( item )->IsVisible() + && !symbolEditorFrame->GetShowInvisiblePins() ) + { + collector.Remove( i ); + continue; + } + } + } + if( !Selectable( collector[i], &aWhere ) ) { collector.Remove( i );