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

View File

@ -1878,3 +1878,17 @@ void SYMBOL_EDIT_FRAME::updateSelectionFilterVisbility()
selectionFilterPane.Show( showFilter );
}
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) 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
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
@ -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();

View File

@ -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
@ -1070,8 +1070,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<SYMBOL_EDIT_FRAME*>( 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<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 ) )
{
collector.Remove( i );