Retire group bbox cache.

It's too hard to maintain when changes to other items (the groups
members) affect it.
This commit is contained in:
Jeff Young 2022-11-11 20:15:02 +00:00
parent 3fc727bb91
commit 138f835672
4 changed files with 9 additions and 43 deletions

View File

@ -241,7 +241,6 @@ void BOARD::IncrementTimeStamp()
m_CopperZoneRTreeCache.clear();
m_CopperItemRTreeCache = std::make_unique<DRC_RTREE>();
m_ZoneBBoxCache.clear();
m_GroupBBoxCache.clear();
}
}

View File

@ -1143,7 +1143,6 @@ public:
std::unordered_map<ZONE*, std::unique_ptr<DRC_RTREE>> m_CopperZoneRTreeCache;
std::unique_ptr<DRC_RTREE> m_CopperItemRTreeCache;
mutable std::unordered_map<const ZONE*, BOX2I> m_ZoneBBoxCache;
mutable std::unordered_map<const PCB_GROUP*, BOX2I> m_GroupBBoxCache;
// ------------ DRC caches -------------
std::vector<ZONE*> m_DRCZones;

View File

@ -234,41 +234,16 @@ const BOX2I PCB_GROUP::GetBoundingBox() const
{
BOX2I bbox;
auto calcBBox =
[this]()
{
BOX2I box;
for( BOARD_ITEM* item : m_items )
{
if( item->Type() == PCB_FOOTPRINT_T )
box.Merge( static_cast<FOOTPRINT*>( item )->GetBoundingBox( true, false ) );
else
box.Merge( item->GetBoundingBox() );
}
box.Inflate( pcbIUScale.mmToIU( 0.25 ) ); // Give a min size to the bbox
return box;
};
if( const BOARD* board = GetBoard() )
for( BOARD_ITEM* item : m_items )
{
std::unordered_map<const PCB_GROUP*, BOX2I>& cache = board->m_GroupBBoxCache;
auto cacheIter = cache.find( this );
if( cacheIter != cache.end() )
return cacheIter->second;
bbox = calcBBox();
std::unique_lock<std::mutex> cacheLock( const_cast<BOARD*>( board )->m_CachesMutex );
cache[ this ] = bbox;
return bbox;
if( item->Type() == PCB_FOOTPRINT_T )
bbox.Merge( static_cast<FOOTPRINT*>( item )->GetBoundingBox( true, false ) );
else
bbox.Merge( item->GetBoundingBox() );
}
bbox.Inflate( pcbIUScale.mmToIU( 0.25 ) ); // Give a min size to the bbox
return bbox;
}
@ -353,14 +328,9 @@ void PCB_GROUP::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
wxString PCB_GROUP::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const
{
if( m_name.empty() )
{
return wxString::Format( _( "Unnamed Group, %zu members" ),
m_items.size() );
}
return wxString::Format( _( "Group '%s', %zu members" ),
m_name,
m_items.size() );
return wxString::Format( _( "Unnamed Group, %zu members" ), m_items.size() );
else
return wxString::Format( _( "Group '%s', %zu members" ), m_name, m_items.size() );
}

View File

@ -452,8 +452,6 @@ int EDIT_TOOL::doMoveSelection( const TOOL_EVENT& aEvent, bool aPickReference )
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
board->m_GroupBBoxCache.clear();
if( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) )
eatFirstMouseUp = false;