Pcbnew: array tool: improve variable locality, use range-for
This commit is contained in:
+29
-31
@@ -122,34 +122,11 @@ void ARRAY_TOOL::onDialogClosed( wxCloseEvent& aEvent )
|
||||
|
||||
wxCHECK( m_selection, /* void */ );
|
||||
|
||||
PCB_SELECTION& selection = *m_selection;
|
||||
|
||||
PCB_SELECTION& selection = *m_selection;
|
||||
PCB_BASE_FRAME* editFrame = getEditFrame<PCB_BASE_FRAME>();
|
||||
BOARD_COMMIT commit( editFrame );
|
||||
|
||||
BOARD_COMMIT commit( editFrame );
|
||||
|
||||
FOOTPRINT* const fp = m_isFootprintEditor ? editFrame->GetBoard()->GetFirstFootprint()
|
||||
: nullptr;
|
||||
|
||||
// Collect a list of pad numbers that will _not_ be counted as "used"
|
||||
// when finding the next pad numbers.
|
||||
// Things that are selected are fair game, as they'll give up their numbers.
|
||||
// Keeps numbers used by both selected and unselected pads as "reserved".
|
||||
std::set<wxString> unchangingPadNumbers;
|
||||
if( fp )
|
||||
{
|
||||
for( PAD* pad : fp->Pads() )
|
||||
{
|
||||
if( !pad->IsSelected() )
|
||||
unchangingPadNumbers.insert( pad->GetNumber() );
|
||||
}
|
||||
}
|
||||
|
||||
ARRAY_PAD_NUMBER_PROVIDER pad_number_provider( unchangingPadNumbers, *m_array_opts );
|
||||
|
||||
EDA_ITEMS all_added_items;
|
||||
|
||||
int arraySize = m_array_opts->GetArraySize();
|
||||
const int arraySize = m_array_opts->GetArraySize();
|
||||
|
||||
if( m_array_opts->ShouldArrangeSelection() )
|
||||
{
|
||||
@@ -221,7 +198,27 @@ void ARRAY_TOOL::onDialogClosed( wxCloseEvent& aEvent )
|
||||
return;
|
||||
}
|
||||
|
||||
FOOTPRINT* const fp = m_isFootprintEditor ? editFrame->GetBoard()->GetFirstFootprint()
|
||||
: nullptr;
|
||||
|
||||
// Collect a list of pad numbers that will _not_ be counted as "used"
|
||||
// when finding the next pad numbers.
|
||||
// Things that are selected are fair game, as they'll give up their numbers.
|
||||
// Keeps numbers used by both selected and unselected pads as "reserved".
|
||||
std::set<wxString> unchangingPadNumbers;
|
||||
if( fp )
|
||||
{
|
||||
for( PAD* pad : fp->Pads() )
|
||||
{
|
||||
if( !pad->IsSelected() )
|
||||
unchangingPadNumbers.insert( pad->GetNumber() );
|
||||
}
|
||||
}
|
||||
|
||||
ARRAY_PAD_NUMBER_PROVIDER pad_number_provider( unchangingPadNumbers, *m_array_opts );
|
||||
|
||||
const bool will_reannotate = !m_isFootprintEditor && m_array_opts->ShouldReannotateFootprints();
|
||||
EDA_ITEMS all_added_items;
|
||||
|
||||
// Iterate in reverse so the original items go last, and we can
|
||||
// use them for the positions of the clones.
|
||||
@@ -230,12 +227,13 @@ void ARRAY_TOOL::onDialogClosed( wxCloseEvent& aEvent )
|
||||
PCB_SELECTION items_for_this_block;
|
||||
std::set<FOOTPRINT*> fpDeDupe;
|
||||
|
||||
for( int i = 0; i < m_selection->Size(); ++i )
|
||||
for( EDA_ITEM* eda_item : selection )
|
||||
|
||||
{
|
||||
if( !selection[i]->IsBOARD_ITEM() )
|
||||
if( !eda_item->IsBOARD_ITEM() )
|
||||
continue;
|
||||
|
||||
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection[i] );
|
||||
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( eda_item );
|
||||
|
||||
FOOTPRINT* parentFootprint = item->GetParentFootprint();
|
||||
|
||||
@@ -387,9 +385,9 @@ void ARRAY_TOOL::onDialogClosed( wxCloseEvent& aEvent )
|
||||
}
|
||||
|
||||
// Make sure original items are selected (e.g. interactive point select may clear it)
|
||||
for( int i = 0; i < m_selection->Size(); ++i )
|
||||
for( EDA_ITEM* eda_item : selection )
|
||||
{
|
||||
all_added_items.push_back( selection[i] );
|
||||
all_added_items.push_back( eda_item );
|
||||
}
|
||||
|
||||
m_toolMgr->RunAction( ACTIONS::selectionClear );
|
||||
|
||||
Reference in New Issue
Block a user