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
This commit is contained in:
jean-pierre charras 2024-03-14 10:01:58 +01:00
parent 3d04d78f76
commit b718c228fe
3 changed files with 46 additions and 2 deletions

View File

@ -1846,3 +1846,17 @@ void SYMBOL_EDIT_FRAME::UpdateItem( EDA_ITEM* aItem, bool isAddOrDelete, bool aU
eda_text->ClearRenderCache(); 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;
}

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com> * Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
* 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 * Copyright (C) 2017 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch> * @author Maciej Suminski <maciej.suminski@cern.ch>
* *
@ -242,6 +242,9 @@ public:
bool GetShowDeMorgan() const { return m_showDeMorgan; } bool GetShowDeMorgan() const { return m_showDeMorgan; }
void SetShowDeMorgan( bool show ) { m_showDeMorgan = show; } void SetShowDeMorgan( bool show ) { m_showDeMorgan = show; }
bool GetShowInvisibleFields();
bool GetShowInvisiblePins();
void ClearMsgPanel() override void ClearMsgPanel() override
{ {
UpdateSymbolMsgPanelInfo(); UpdateSymbolMsgPanelInfo();

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2019 CERN * 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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, void EE_SELECTION_TOOL::narrowSelection( EE_COLLECTOR& collector, const VECTOR2I& aWhere,
bool aCheckLocked, bool aSelectedOnly ) bool aCheckLocked, bool aSelectedOnly )
{ {
SYMBOL_EDIT_FRAME* symbolEditorFrame = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_frame );
for( int i = collector.GetCount() - 1; i >= 0; --i ) 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<EDA_ITEM*>( collector[i] );
if( item->Type() == LIB_FIELD_T )
{
if( !static_cast<LIB_FIELD*>( item )->IsVisible()
&& !symbolEditorFrame->GetShowInvisibleFields() )
{
collector.Remove( i );
continue;
}
}
else if( item->Type() == LIB_PIN_T )
{
if( !static_cast<LIB_PIN*>( item )->IsVisible()
&& !symbolEditorFrame->GetShowInvisiblePins() )
{
collector.Remove( i );
continue;
}
}
}
if( !Selectable( collector[i], &aWhere ) ) if( !Selectable( collector[i], &aWhere ) )
{ {
collector.Remove( i ); collector.Remove( i );