7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-20 00:21:31 +00:00

pcb: merge RunOnChildren/Descendants into one function with a mode

This commit is contained in:
Mike Williams 2025-03-27 10:43:44 -04:00
parent 7cf699bc9d
commit a90b8ec57a
34 changed files with 195 additions and 194 deletions

View File

@ -85,12 +85,13 @@ void FOOTPRINT_DIFF_WIDGET::DisplayDiff( FOOTPRINT* aBoardFootprint,
m_boardItemCopy->ClearSelected();
m_boardItemCopy->ClearBrightened();
m_boardItemCopy->RunOnDescendants(
m_boardItemCopy->RunOnChildren(
[&]( BOARD_ITEM* item )
{
item->ClearSelected();
item->ClearBrightened();
} );
},
RECURSE_MODE::RECURSE );
m_boardItemCopy->Move( -m_boardItemCopy->GetPosition() );
@ -138,11 +139,12 @@ void FOOTPRINT_DIFF_WIDGET::onSlider( wxScrollEvent& aEvent )
m_boardItemCopy->SetForcedTransparency( val );
m_boardItemCopy->RunOnDescendants(
m_boardItemCopy->RunOnChildren(
[&]( BOARD_ITEM* item )
{
item->SetForcedTransparency( val );
} );
},
RECURSE_MODE::RECURSE );
}
if( m_libraryItem )
@ -156,11 +158,12 @@ void FOOTPRINT_DIFF_WIDGET::onSlider( wxScrollEvent& aEvent )
m_libraryItem->SetForcedTransparency( val );
m_libraryItem->RunOnDescendants(
m_libraryItem->RunOnChildren(
[&]( BOARD_ITEM* item )
{
item->SetForcedTransparency( val );
} );
},
RECURSE_MODE::RECURSE );
}
RefreshAll();

View File

@ -69,6 +69,11 @@ enum ZONE_LAYER_OVERRIDE
ZLO_FORCE_NO_ZONE_CONNECTION
};
enum RECURSE_MODE
{
RECURSE,
NO_RECURSE,
};
/**
* A base class for any item which can be embedded within the #BOARD container class, and
@ -207,15 +212,7 @@ public:
*
* @note This function should not add or remove items to the parent.
*/
virtual void RunOnChildren( const std::function<void ( BOARD_ITEM* )>& aFunction ) const { }
/**
* Invoke a function on all descendants.
*
* @note This function should not add or remove items.
*/
virtual void RunOnDescendants( const std::function<void ( BOARD_ITEM* )>& aFunction,
int aDepth = 0 ) const { }
virtual void RunOnChildren( const std::function<void( BOARD_ITEM* )>& aFunction, RECURSE_MODE aMode ) const {}
BOARD_ITEM_CONTAINER* GetParent() const { return (BOARD_ITEM_CONTAINER*) m_parent; }

View File

@ -523,8 +523,7 @@ void BOARD::Move( const VECTOR2I& aMoveVector ) // overload
}
void BOARD::RunOnDescendants( const std::function<void ( BOARD_ITEM* )>& aFunction,
int aDepth ) const
void BOARD::RunOnChildren( const std::function<void( BOARD_ITEM* )>& aFunction, RECURSE_MODE aMode ) const
{
try
{
@ -543,18 +542,22 @@ void BOARD::RunOnDescendants( const std::function<void ( BOARD_ITEM* )>& aFuncti
for( FOOTPRINT* footprint : m_footprints )
{
aFunction( footprint );
footprint->RunOnDescendants( aFunction, aDepth + 1 );
if( aMode == RECURSE_MODE::RECURSE )
footprint->RunOnChildren( aFunction, RECURSE_MODE::RECURSE );
}
for( BOARD_ITEM* drawing : m_drawings )
{
aFunction( drawing );
drawing->RunOnDescendants( aFunction, aDepth + 1 );
if( aMode == RECURSE_MODE::RECURSE )
drawing->RunOnChildren( aFunction, RECURSE_MODE::RECURSE );
}
}
catch( std::bad_function_call& )
{
wxFAIL_MSG( wxT( "Error running BOARD::RunOnDescendants" ) );
wxFAIL_MSG( wxT( "Error running BOARD::RunOnChildren" ) );
}
}
@ -1121,7 +1124,8 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, ADD_MODE aMode, bool aSkipConnectivity
footprint->RunOnChildren( [&]( BOARD_ITEM* aChild )
{
m_itemByIdCache.insert( { aChild->m_Uuid, aChild } );
} );
},
RECURSE_MODE::NO_RECURSE );
break;
}
@ -1150,7 +1154,8 @@ void BOARD::Add( BOARD_ITEM* aBoardItem, ADD_MODE aMode, bool aSkipConnectivity
table->RunOnChildren( [&]( BOARD_ITEM* aChild )
{
m_itemByIdCache.insert( { aChild->m_Uuid, aChild } );
} );
},
RECURSE_MODE::NO_RECURSE );
}
break;
@ -1254,7 +1259,8 @@ void BOARD::Remove( BOARD_ITEM* aBoardItem, REMOVE_MODE aRemoveMode )
footprint->RunOnChildren( [&]( BOARD_ITEM* aChild )
{
m_itemByIdCache.erase( aChild->m_Uuid );
} );
},
RECURSE_MODE::NO_RECURSE );
break;
}
@ -1287,7 +1293,8 @@ void BOARD::Remove( BOARD_ITEM* aBoardItem, REMOVE_MODE aRemoveMode )
table->RunOnChildren( [&]( BOARD_ITEM* aChild )
{
m_itemByIdCache.erase( aChild->m_Uuid );
} );
},
RECURSE_MODE::NO_RECURSE );
}
break;

View File

@ -396,8 +396,7 @@ public:
void Move( const VECTOR2I& aMoveVector ) override;
void RunOnDescendants( const std::function<void ( BOARD_ITEM* )>& aFunction,
int aDepth = 0 ) const override;
void RunOnChildren( const std::function<void( BOARD_ITEM* )>& aFunction, RECURSE_MODE aMode ) const override;
void SetFileFormatVersionAtLoad( int aVersion ) { m_fileFormatVersionAtLoad = aVersion; }
int GetFileFormatVersionAtLoad() const { return m_fileFormatVersionAtLoad; }

View File

@ -106,7 +106,8 @@ COMMIT& BOARD_COMMIT::Stage( EDA_ITEM* aItem, CHANGE_TYPE aChangeType, BASE_SCRE
[&]( BOARD_ITEM* child )
{
Stage( child, aChangeType );
} );
},
RECURSE_MODE::NO_RECURSE );
}
}
@ -136,8 +137,9 @@ void BOARD_COMMIT::propagateDamage( BOARD_ITEM* aChangedItem, std::vector<ZONE*>
if( aStaleZones && aChangedItem->Type() == PCB_ZONE_T )
aStaleZones->push_back( static_cast<ZONE*>( aChangedItem ) );
aChangedItem->RunOnChildren( std::bind( &BOARD_COMMIT::propagateDamage, this, _1, aStaleZones,
aStaleHatchedShapes ) );
aChangedItem->RunOnChildren(
std::bind( &BOARD_COMMIT::propagateDamage, this, _1, aStaleZones, aStaleHatchedShapes ),
RECURSE_MODE::NO_RECURSE );
BOARD* board = static_cast<BOARD*>( m_toolMgr->GetModel() );
BOX2I damageBBox = aChangedItem->GetBoundingBox();
@ -202,11 +204,12 @@ void BOARD_COMMIT::propagateDamage( BOARD_ITEM* aChangedItem, std::vector<ZONE*>
for( FOOTPRINT* footprint : board->Footprints() )
{
footprint->RunOnDescendants(
footprint->RunOnChildren(
[&]( BOARD_ITEM* child )
{
checkItem( child );
} );
},
RECURSE_MODE::RECURSE );
}
for( BOARD_ITEM* item : board->Drawings() )
@ -542,11 +545,12 @@ void BOARD_COMMIT::Push( const wxString& aMessage, int aCommitFlags )
}
boardItem->ClearEditFlags();
boardItem->RunOnDescendants(
boardItem->RunOnChildren(
[&]( BOARD_ITEM* item )
{
item->ClearEditFlags();
} );
},
RECURSE_MODE::RECURSE );
} // ... and regenerate them.
// Invalidate component classes
@ -813,7 +817,8 @@ void BOARD_COMMIT::Revert()
[&]( BOARD_ITEM* child )
{
child->SetParentGroup( group );
} );
},
RECURSE_MODE::NO_RECURSE );
}
view->Add( boardItem );

View File

@ -2160,39 +2160,8 @@ EDA_ITEM* FOOTPRINT::Clone() const
}
void FOOTPRINT::RunOnChildren( const std::function<void ( BOARD_ITEM* )>& aFunction ) const
void FOOTPRINT::RunOnChildren( const std::function<void( BOARD_ITEM* )>& aFunction, RECURSE_MODE aMode ) const
{
try
{
for( PCB_FIELD* field : m_fields )
aFunction( field );
for( PAD* pad : m_pads )
aFunction( pad );
for( ZONE* zone : m_zones )
aFunction( zone );
for( PCB_GROUP* group : m_groups )
aFunction( group );
for( BOARD_ITEM* drawing : m_drawings )
aFunction( drawing );
}
catch( std::bad_function_call& )
{
wxFAIL_MSG( wxT( "Error running FOOTPRINT::RunOnChildren" ) );
}
}
void FOOTPRINT::RunOnDescendants( const std::function<void( BOARD_ITEM* )>& aFunction,
int aDepth ) const
{
// Avoid freezes with infinite recursion
if( aDepth > 20 )
return;
try
{
for( PCB_FIELD* field : m_fields )
@ -2210,12 +2179,14 @@ void FOOTPRINT::RunOnDescendants( const std::function<void( BOARD_ITEM* )>& aFun
for( BOARD_ITEM* drawing : m_drawings )
{
aFunction( drawing );
drawing->RunOnDescendants( aFunction, aDepth + 1 );
if( aMode == RECURSE_MODE::RECURSE )
drawing->RunOnChildren( aFunction, RECURSE_MODE::RECURSE );
}
}
catch( std::bad_function_call& )
{
wxFAIL_MSG( wxT( "Error running FOOTPRINT::RunOnDescendants" ) );
wxFAIL_MSG( wxT( "Error running FOOTPRINT::RunOnChildren" ) );
}
}
@ -2575,10 +2546,11 @@ BOARD_ITEM* FOOTPRINT::Duplicate() const
{
FOOTPRINT* dupe = static_cast<FOOTPRINT*>( BOARD_ITEM::Duplicate() );
dupe->RunOnDescendants( [&]( BOARD_ITEM* child )
dupe->RunOnChildren( [&]( BOARD_ITEM* child )
{
const_cast<KIID&>( child->m_Uuid ) = KIID();
});
},
RECURSE_MODE::RECURSE );
return dupe;
}
@ -2683,11 +2655,12 @@ BOARD_ITEM* FOOTPRINT::DuplicateItem( const BOARD_ITEM* aItem, bool aAddToFootpr
if( aAddToFootprint )
{
group->RunOnDescendants(
group->RunOnChildren(
[&]( BOARD_ITEM* aCurrItem )
{
Add( aCurrItem );
} );
},
RECURSE_MODE::RECURSE );
Add( group );
}
@ -3390,12 +3363,13 @@ void FOOTPRINT::CheckNetTies( const std::function<void( const BOARD_ITEM* aItem,
if( item->IsOnCopperLayer() )
copperItems.push_back( item );
item->RunOnDescendants(
item->RunOnChildren(
[&]( BOARD_ITEM* descendent )
{
if( descendent->IsOnCopperLayer() )
copperItems.push_back( descendent );
} );
},
RECURSE_MODE::RECURSE );
}
for( ZONE* zone : m_zones )
@ -3557,13 +3531,15 @@ void FOOTPRINT::swapData( BOARD_ITEM* aImage )
[&]( BOARD_ITEM* child )
{
child->SetParent( this );
} );
},
RECURSE_MODE::NO_RECURSE );
image->RunOnChildren(
[&]( BOARD_ITEM* child )
{
child->SetParent( image );
} );
},
RECURSE_MODE::NO_RECURSE );
}

View File

@ -870,11 +870,7 @@ public:
EDA_ITEM* Clone() const override;
///< @copydoc BOARD_ITEM::RunOnChildren
void RunOnChildren( const std::function<void (BOARD_ITEM*)>& aFunction ) const override;
///< @copydoc BOARD_ITEM::RunOnDescendants
void RunOnDescendants( const std::function<void( BOARD_ITEM* )>& aFunction,
int aDepth = 0 ) const override;
void RunOnChildren( const std::function<void( BOARD_ITEM* )>& aFunction, RECURSE_MODE aMode ) const override;
virtual std::vector<int> ViewGetLayers() const override;

View File

@ -539,14 +539,15 @@ void FOOTPRINT_EDIT_FRAME::updateEnabledLayers()
// Don't drop pre-existing user layers
LSET enabledLayers = GetBoard()->GetEnabledLayers();
m_originalFootprintCopy->RunOnDescendants(
m_originalFootprintCopy->RunOnChildren(
[&]( BOARD_ITEM* child )
{
LSET childLayers = child->GetLayerSet() & LSET::UserDefinedLayersMask();
for( PCB_LAYER_ID layer : childLayers )
enabledLayers.set( layer );
} );
},
RECURSE_MODE::RECURSE );
// Enable any layers that the user has gone to the trouble to name
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();

View File

@ -928,16 +928,17 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard( bool aAddNew )
fixUuid( const_cast<KIID&>( newFootprint->m_Uuid ) );
newFootprint->RunOnDescendants(
newFootprint->RunOnChildren(
[&]( BOARD_ITEM* aChild )
{
fixUuid( const_cast<KIID&>( aChild->m_Uuid ) );
} );
},
RECURSE_MODE::RECURSE );
// Right now, we only show the "Unconnected" net in the footprint editor, but this is still
// referenced in the footprint. So we need to update the net pointers in the footprint to
// point to the nets in the main board.
newFootprint->RunOnDescendants(
newFootprint->RunOnChildren(
[&]( BOARD_ITEM* aChild )
{
if( BOARD_CONNECTED_ITEM* conn = dynamic_cast<BOARD_CONNECTED_ITEM*>( aChild ) )
@ -954,7 +955,8 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard( bool aAddNew )
}
}
} );
},
RECURSE_MODE::RECURSE );
BOARD_DESIGN_SETTINGS& bds = m_pcb->GetDesignSettings();
@ -1314,7 +1316,7 @@ FOOTPRINT* PCB_BASE_FRAME::CreateNewFootprint( wxString aFootprintName, const wx
if( footprint->GetValue().IsEmpty() )
footprint->SetValue( aFootprintName );
footprint->RunOnDescendants(
footprint->RunOnChildren(
[&]( BOARD_ITEM* aChild )
{
if( aChild->Type() == PCB_FIELD_T || aChild->Type() == PCB_TEXT_T )
@ -1327,7 +1329,8 @@ FOOTPRINT* PCB_BASE_FRAME::CreateNewFootprint( wxString aFootprintName, const wx
textItem->SetItalic( settings.GetTextItalic( layer ) );
textItem->SetKeepUpright( settings.GetTextUpright( layer ) );
}
} );
},
RECURSE_MODE::RECURSE );
SetMsgPanel( footprint );
return footprint;

View File

@ -275,7 +275,7 @@ void CLIPBOARD_IO::SaveSelection( const PCB_SELECTION& aSelected, bool isFootpri
if( copy->Type() == PCB_GROUP_T || copy->Type() == PCB_GENERATOR_T )
{
copy->RunOnDescendants(
copy->RunOnChildren(
[&]( BOARD_ITEM* descendant )
{
// One cannot add an additional mandatory field to a given footprint:
@ -292,7 +292,8 @@ void CLIPBOARD_IO::SaveSelection( const PCB_SELECTION& aSelected, bool isFootpri
partialFootprint.Add( descendant );
else
skipped_items.push_back( descendant );
} );
},
RECURSE_MODE::RECURSE );
}
// locate the reference point at (0, 0) in the copied items
@ -432,12 +433,13 @@ void CLIPBOARD_IO::SaveSelection( const PCB_SELECTION& aSelected, bool isFootpri
if( copy->Type() == PCB_GROUP_T || copy->Type() == PCB_GENERATOR_T )
{
copy->RunOnDescendants(
copy->RunOnChildren(
[&]( BOARD_ITEM* descendant )
{
descendant->SetLocked( false );
Format( descendant );
} );
},
RECURSE_MODE::NO_RECURSE );
}
copy->SetParentGroup( nullptr );

View File

@ -123,7 +123,7 @@ bool FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard( FOOTPRINT* aFootprint )
newFootprint->ClearFlags();
recordAndUpdateUuid( newFootprint );
newFootprint->RunOnDescendants(
newFootprint->RunOnChildren(
[&]( BOARD_ITEM* aItem )
{
if( aItem->Type() == PCB_PAD_T )
@ -131,7 +131,8 @@ bool FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard( FOOTPRINT* aFootprint )
aItem->ClearFlags();
recordAndUpdateUuid( aItem );
} );
},
RECURSE_MODE::RECURSE );
AddFootprintToBoard( newFootprint );

View File

@ -287,11 +287,12 @@ void PCB_BASE_FRAME::FocusOnItems( std::vector<BOARD_ITEM*> aItems, PCB_LAYER_ID
{
lastItem->ClearBrightened();
lastItem->RunOnDescendants(
lastItem->RunOnChildren(
[&]( BOARD_ITEM* child )
{
child->ClearBrightened();
} );
},
RECURSE_MODE::RECURSE );
GetCanvas()->GetView()->Update( lastItem );
lastBrightenedItemID = niluuid;
@ -332,11 +333,12 @@ void PCB_BASE_FRAME::FocusOnItems( std::vector<BOARD_ITEM*> aItems, PCB_LAYER_ID
{
item->SetBrightened();
item->RunOnDescendants(
item->RunOnChildren(
[&]( BOARD_ITEM* child )
{
child->SetBrightened();
});
},
RECURSE_MODE::RECURSE );
GetCanvas()->GetView()->Update( item );
lastBrightenedItemIDs.push_back( item->m_Uuid );

View File

@ -269,7 +269,7 @@ bool PCB_EDIT_FRAME::saveSelectionToDesignBlock( const wxString& aNickname, PCB_
tempBoard->Add( static_cast<BOARD_ITEM*>( copy ), ADD_MODE::APPEND, false );
if( FOOTPRINT* fp = dynamic_cast<FOOTPRINT*>( item ) )
fp->RunOnChildren( addNetIfNeeded );
fp->RunOnChildren( addNetIfNeeded, RECURSE_MODE::NO_RECURSE );
else
addNetIfNeeded( copy );
}

View File

@ -189,7 +189,8 @@ void PCB_GROUP::SetLocked( bool aLockState )
[&]( BOARD_ITEM* child )
{
child->SetLocked( aLockState );
} );
},
RECURSE_MODE::NO_RECURSE );
}
@ -397,40 +398,23 @@ void PCB_GROUP::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_I
}
void PCB_GROUP::RunOnChildren( const std::function<void( BOARD_ITEM* )>& aFunction ) const
void PCB_GROUP::RunOnChildren( const std::function<void( BOARD_ITEM* )>& aFunction, RECURSE_MODE aMode ) const
{
try
{
for( BOARD_ITEM* item : m_items )
aFunction( item );
}
catch( std::bad_function_call& )
{
wxFAIL_MSG( wxT( "Error calling function in PCB_GROUP::RunOnChildren" ) );
}
}
void PCB_GROUP::RunOnDescendants( const std::function<void( BOARD_ITEM* )>& aFunction,
int aDepth ) const
{
// Avoid freezes with infinite recursion
if( aDepth > 20 )
return;
try
{
for( BOARD_ITEM* item : m_items )
{
aFunction( item );
if( item->Type() == PCB_GROUP_T || item->Type() == PCB_GENERATOR_T )
item->RunOnDescendants( aFunction, aDepth + 1 );
if( aMode == RECURSE_MODE::RECURSE && ( item->Type() == PCB_GROUP_T || item->Type() == PCB_GENERATOR_T ) )
{
item->RunOnChildren( aFunction, RECURSE_MODE::RECURSE );
}
}
}
catch( std::bad_function_call& )
{
wxFAIL_MSG( wxT( "Error calling function in PCB_GROUP::RunOnDescendants" ) );
wxFAIL_MSG( wxT( "Error calling function in PCB_GROUP::RunOnChildren" ) );
}
}

View File

@ -199,11 +199,7 @@ public:
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
///< @copydoc BOARD_ITEM::RunOnChildren
void RunOnChildren( const std::function<void ( BOARD_ITEM* )>& aFunction ) const override;
///< @copydoc BOARD_ITEM::RunOnDescendants
void RunOnDescendants( const std::function<void( BOARD_ITEM* )>& aFunction,
int aDepth = 0 ) const override;
void RunOnChildren( const std::function<void( BOARD_ITEM* )>& aFunction, RECURSE_MODE aMode ) const override;
/**
* Check if the proposed type can be added to a group

View File

@ -895,12 +895,13 @@ BOARD_ITEM* PCB_IO_KICAD_SEXPR_PARSER::Parse()
const std::vector<wxString>* embeddedFonts = item->GetEmbeddedFiles()->UpdateFontFiles();
item->RunOnDescendants(
item->RunOnChildren(
[&]( BOARD_ITEM* aChild )
{
if( EDA_TEXT* textItem = dynamic_cast<EDA_TEXT*>( aChild ) )
textItem->ResolveFont( embeddedFonts );
} );
},
RECURSE_MODE::RECURSE );
resolveGroups( item );
@ -1285,7 +1286,8 @@ void PCB_IO_KICAD_SEXPR_PARSER::resolveGroups( BOARD_ITEM* aParent )
{
if( child->m_Uuid == aId )
aItem = child;
} );
},
RECURSE_MODE::NO_RECURSE );
}
return aItem;

View File

@ -346,7 +346,7 @@ void PCB_SHAPE::updateHatching() const
holes.Append( footprint->GetCourtyard( layer ) );
// Knockout footprint fields
footprint->RunOnDescendants(
footprint->RunOnChildren(
[&]( BOARD_ITEM* item )
{
if( item->Type() == PCB_FIELD_T
@ -355,7 +355,8 @@ void PCB_SHAPE::updateHatching() const
{
knockoutItem( item );
}
} );
},
RECURSE_MODE::RECURSE );
}
m_hatching.BooleanSubtract( holes );

View File

@ -218,7 +218,7 @@ void PCB_TABLE::Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
}
void PCB_TABLE::RunOnChildren( const std::function<void( BOARD_ITEM* )>& aFunction ) const
void PCB_TABLE::RunOnChildren( const std::function<void( BOARD_ITEM* )>& aFunction, RECURSE_MODE aMode ) const
{
for( PCB_TABLECELL* cell : m_cells )
aFunction( cell );

View File

@ -97,7 +97,7 @@ public:
void SetStrokeRows( bool aDoStroke ) { m_strokeRows = aDoStroke; }
bool StrokeRows() const { return m_strokeRows; }
void RunOnChildren( const std::function<void( BOARD_ITEM* )>& aFunction ) const override;
void RunOnChildren( const std::function<void( BOARD_ITEM* )>& aFunction, RECURSE_MODE aMode ) const override;
void SetPosition( const VECTOR2I& aPos ) override;
VECTOR2I GetPosition() const override;

View File

@ -62,8 +62,8 @@ void PCB_VIEW::Add( KIGFX::VIEW_ITEM* aItem, int aDrawPriority )
if( boardItem->Type() == PCB_FOOTPRINT_T )
{
static_cast<FOOTPRINT*>( boardItem )->RunOnChildren( std::bind( &PCB_VIEW::Add, this,
_1, aDrawPriority ) );
static_cast<FOOTPRINT*>( boardItem )
->RunOnChildren( std::bind( &PCB_VIEW::Add, this, _1, aDrawPriority ), RECURSE_MODE::NO_RECURSE );
}
}
@ -79,8 +79,8 @@ void PCB_VIEW::Remove( KIGFX::VIEW_ITEM* aItem )
if( boardItem->Type() == PCB_FOOTPRINT_T )
{
static_cast<FOOTPRINT*>( boardItem )->RunOnChildren( std::bind( &PCB_VIEW::Remove,
this, _1 ) );
static_cast<FOOTPRINT*>( boardItem )
->RunOnChildren( std::bind( &PCB_VIEW::Remove, this, _1 ), RECURSE_MODE::NO_RECURSE );
}
}
@ -104,7 +104,8 @@ void PCB_VIEW::Update( const KIGFX::VIEW_ITEM* aItem, int aUpdateFlags ) const
[this, aUpdateFlags]( BOARD_ITEM* child )
{
VIEW::Update( child, aUpdateFlags );
} );
},
RECURSE_MODE::NO_RECURSE );
}
}

View File

@ -306,11 +306,12 @@ void ARRAY_TOOL::onDialogClosed( wxCloseEvent& aEvent )
// it this state, reset the selected stated of aItem:
this_item->ClearSelected();
this_item->RunOnDescendants(
this_item->RunOnChildren(
[]( BOARD_ITEM* aItem )
{
aItem->ClearSelected();
} );
},
RECURSE_MODE::RECURSE );
// We're iterating backwards, so the first item is the last in the array
TransformItem( *m_array_opts, arraySize - ptN - 1, *this_item );
@ -318,11 +319,12 @@ void ARRAY_TOOL::onDialogClosed( wxCloseEvent& aEvent )
// If a group is duplicated, add also created members to the board
if( this_item->Type() == PCB_GROUP_T )
{
this_item->RunOnDescendants(
this_item->RunOnChildren(
[&]( BOARD_ITEM* aItem )
{
commit.Add( aItem );
} );
},
RECURSE_MODE::RECURSE );
}
commit.Add( this_item );

View File

@ -2050,10 +2050,11 @@ void BOARD_INSPECTION_TOOL::calculateSelectionRatsnest( const VECTOR2I& aDelta )
}
else if( item->Type() == PCB_GROUP_T || item->Type() == PCB_GENERATOR_T )
{
item->RunOnDescendants( [ &queued_items ]( BOARD_ITEM *aItem )
item->RunOnChildren( [ &queued_items ]( BOARD_ITEM *aItem )
{
queued_items.push_back( aItem );
} );
},
RECURSE_MODE::RECURSE );
}
else if( BOARD_CONNECTED_ITEM* boardItem = dyn_cast<BOARD_CONNECTED_ITEM*>( item ) )
{

View File

@ -91,12 +91,13 @@ int BOARD_REANNOTATE_TOOL::ReannotateDuplicates( const PCB_SELECTION& aSelection
{
PCB_GROUP* group = static_cast<PCB_GROUP*>( item );
group->RunOnDescendants(
group->RunOnChildren(
[&]( BOARD_ITEM* aGroupItem )
{
if( aGroupItem->Type() == PCB_FOOTPRINT_T )
fpOnBoard.push_back( static_cast<FOOTPRINT*>( aGroupItem ) );
} );
},
RECURSE_MODE::RECURSE );
}
}
@ -115,12 +116,13 @@ int BOARD_REANNOTATE_TOOL::ReannotateDuplicates( const PCB_SELECTION& aSelection
{
PCB_GROUP* group = static_cast<PCB_GROUP*>( item );
group->RunOnDescendants(
group->RunOnChildren(
[&]( BOARD_ITEM* aGroupItem )
{
if( aGroupItem->Type() == PCB_FOOTPRINT_T )
fpInSelection.push_back( static_cast<FOOTPRINT*>( aGroupItem ) );
} );
},
RECURSE_MODE::RECURSE );
}
}

View File

@ -641,11 +641,12 @@ int DRAWING_TOOL::InteractivePlaceWithPreview( const TOOL_EVENT& aEvent,
{
item->SetLayer( destLayer );
item->RunOnDescendants(
item->RunOnChildren(
[&]( BOARD_ITEM* descendant )
{
descendant->SetLayer( destLayer );
} );
},
RECURSE_MODE::RECURSE );
}
}
@ -654,11 +655,12 @@ int DRAWING_TOOL::InteractivePlaceWithPreview( const TOOL_EVENT& aEvent,
item->Move( cursorPosition );
commit.Add( item );
item->RunOnDescendants(
item->RunOnChildren(
[&]( BOARD_ITEM* descendant )
{
commit.Add( descendant );
} );
},
RECURSE_MODE::RECURSE );
}
commit.Push( _( "Place Items" ) );

View File

@ -2168,11 +2168,12 @@ int EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
{
if( item->Type() == PCB_GROUP_T )
{
static_cast<PCB_GROUP*>( item )->RunOnDescendants(
static_cast<PCB_GROUP*>( item )->RunOnChildren(
[&]( BOARD_ITEM* descendant )
{
items.push_back( descendant );
} );
},
RECURSE_MODE::RECURSE );
}
else
{
@ -2557,17 +2558,19 @@ void EDIT_TOOL::DeleteItems( const PCB_SELECTION& aItems, bool aIsCut )
break;
case PCB_GROUP_T:
board_item->RunOnDescendants(
board_item->RunOnChildren(
[&commit]( BOARD_ITEM* aItem )
{
commit.Stage( aItem, CHT_UNGROUP );
} );
},
RECURSE_MODE::RECURSE );
board_item->RunOnDescendants(
board_item->RunOnChildren(
[&commit]( BOARD_ITEM* aItem )
{
commit.Remove( aItem );
} );
},
RECURSE_MODE::RECURSE );
commit.Remove( board_item );
itemsDeleted++;
@ -2967,13 +2970,14 @@ int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent )
case PCB_GROUP_T:
dupe_item = static_cast<PCB_GROUP*>( orig_item )->DeepDuplicate();
dupe_item->RunOnDescendants(
dupe_item->RunOnChildren(
[&]( BOARD_ITEM* aItem )
{
aItem->ClearSelected();
new_items.push_back( aItem );
commit.Add( aItem );
} );
},
RECURSE_MODE::RECURSE );
dupe_item->ClearSelected();
new_items.push_back( dupe_item );

Some files were not shown because too many files have changed in this diff Show More