7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-11 00:30:01 +00:00

Implement BOARD::RunOnDescendants

Fixes https://gitlab.com/kicad/code/kicad/-/issues/19397
This commit is contained in:
Jon Evans 2024-12-30 20:33:30 -05:00
parent a4ac22f2d6
commit 2dec1dd598
2 changed files with 42 additions and 0 deletions

View File

@ -521,6 +521,45 @@ void BOARD::Move( const VECTOR2I& aMoveVector ) // overload
}
void BOARD::RunOnDescendants( const std::function<void ( BOARD_ITEM* )>& aFunction,
int aDepth ) const
{
try
{
for( PCB_TRACK* track : m_tracks )
aFunction( track );
for( ZONE* zone : m_zones )
aFunction( zone );
for( PCB_MARKER* marker : m_markers )
aFunction( marker );
for( FOOTPRINT* footprint : m_footprints )
{
aFunction( footprint );
footprint->RunOnDescendants( aFunction, aDepth + 1 );
}
for( PCB_GROUP* group : m_groups )
{
aFunction( group );
group->RunOnDescendants( aFunction, aDepth + 1 );
}
for( BOARD_ITEM* drawing : m_drawings )
{
aFunction( drawing );
drawing->RunOnDescendants( aFunction, aDepth + 1 );
}
}
catch( std::bad_function_call& )
{
wxFAIL_MSG( wxT( "Error running FOOTPRINT::RunOnDescendants" ) );
}
}
TRACKS BOARD::TracksInNet( int aNetCode )
{
TRACKS ret;

View File

@ -390,6 +390,9 @@ public:
void Move( const VECTOR2I& aMoveVector ) override;
void RunOnDescendants( const std::function<void ( BOARD_ITEM* )>& aFunction,
int aDepth = 0 ) const override;
void SetFileFormatVersionAtLoad( int aVersion ) { m_fileFormatVersionAtLoad = aVersion; }
int GetFileFormatVersionAtLoad() const { return m_fileFormatVersionAtLoad; }