Ignore hidden text fields when cross-probing

Zoom-to-selection should only show the elements that we can see, so
avoiding hidden fields in footprints keeps the zoom window appropriately
sized

Fixes https://gitlab.com/kicad/code/kicad/-/issues/15245
This commit is contained in:
Seth Hillbrand 2024-05-02 10:56:13 -07:00
parent 1882445b40
commit 416033e8e5
7 changed files with 30 additions and 6 deletions

View File

@ -130,7 +130,7 @@ VECTOR2I SELECTION::GetCenter() const
}
BOX2I SELECTION::GetBoundingBox() const
BOX2I SELECTION::GetBoundingBox( bool aOnlyVisible ) const
{
BOX2I bbox;

View File

@ -82,7 +82,7 @@ EDA_ITEM* EE_SELECTION::GetTopLeftItem( bool onlyModules ) const
}
BOX2I EE_SELECTION::GetBoundingBox() const
BOX2I EE_SELECTION::GetBoundingBox( bool aOnlyVisible ) const
{
BOX2I bbox;

View File

@ -46,7 +46,7 @@ public:
EDA_ITEM* GetTopLeftItem( bool onlyModules = false ) const override;
BOX2I GetBoundingBox() const override;
BOX2I GetBoundingBox( bool aOnlyVisible = false ) const override;
void SetScreen( SCH_SCREEN* aScreen ) { m_screen = aScreen; }
SCH_SCREEN* GetScreen() { return m_screen; }

View File

@ -154,7 +154,7 @@ public:
return GetBoundingBox().GetPosition();
}
virtual BOX2I GetBoundingBox() const;
virtual BOX2I GetBoundingBox( bool aOnlyVisible = false ) const;
virtual EDA_ITEM* GetTopLeftItem( bool onlyModules = false ) const
{

View File

@ -105,3 +105,25 @@ const std::vector<KIGFX::VIEW_ITEM*> PCB_SELECTION::updateDrawList() const
return items;
}
BOX2I PCB_SELECTION::GetBoundingBox( bool aOnlyVisible ) const
{
BOX2I bbox;
for( EDA_ITEM* item : m_items )
{
if( item->Type() == PCB_FOOTPRINT_T )
{
FOOTPRINT* footprint = static_cast<FOOTPRINT*>( item );
bbox.Merge( footprint->GetBoundingBox( true, !aOnlyVisible ) );
}
else
{
bbox.Merge( item->GetBoundingBox() );
}
}
return bbox;
}

View File

@ -33,6 +33,8 @@ class PCB_SELECTION : public SELECTION
public:
EDA_ITEM* GetTopLeftItem( bool aFootprintsOnly = false ) const override;
BOX2I GetBoundingBox( bool aOnlyVisible = false ) const override;
const std::vector<KIGFX::VIEW_ITEM*> updateDrawList() const override;
};

View File

@ -2109,7 +2109,7 @@ void PCB_SELECTION_TOOL::doSyncSelection( const std::vector<BOARD_ITEM*>& aItems
if( aWithNets )
selectConnections( aItems );
BOX2I bbox = m_selection.GetBoundingBox();
BOX2I bbox = m_selection.GetBoundingBox( true );
if( bbox.GetWidth() != 0 && bbox.GetHeight() != 0 )
{