30#include <wx/filedlg.h>
36 m_selectionTool( nullptr ),
53 m_frame = getEditFrame<PCB_EDIT_FRAME>();
76 const std::vector<EDA_ITEM*>& aAdditionalFootprints )
78 if( aSelectionToReannotate.
Empty() )
83 std::multimap<wxString, KIID> usedDesignatorsMap;
85 for(
EDA_ITEM* item : aAdditionalFootprints )
88 fpOnBoard.push_back(
static_cast<FOOTPRINT*
>( item ) );
94 group->RunOnDescendants(
98 fpOnBoard.push_back(
static_cast<FOOTPRINT*
>( aGroupItem ) );
104 usedDesignatorsMap.insert( { fp->GetReference(), fp->m_Uuid } );
107 FOOTPRINTS fpInSelection;
109 for(
EDA_ITEM* item : aSelectionToReannotate )
112 fpInSelection.push_back(
static_cast<FOOTPRINT*
>( item ) );
118 group->RunOnDescendants(
122 fpInSelection.push_back(
static_cast<FOOTPRINT*
>( aGroupItem ) );
127 std::sort( fpInSelection.begin(), fpInSelection.end(),
130 int ii = StrNumCmp( aA->GetReference(), aB->GetReference(), true );
135 if( aA->GetPosition().y == aB->GetPosition().y )
137 if( aA->GetPosition().x == aB->GetPosition().x )
138 return aA->m_Uuid < aB->m_Uuid;
140 return aA->GetPosition().x < aB->GetPosition().x;
144 return aA->GetPosition().y > aB->GetPosition().y;
158 while( usedDesignatorsMap.find( fp->GetReference() ) != usedDesignatorsMap.end() )
160 auto result = usedDesignatorsMap.equal_range( fp->GetReference() );
162 for(
auto& it = result.first; it != result.second; it++ )
164 if( it->second != fp->m_Uuid )
179 fp->SetReference( stem + std::to_string( value ) );
183 usedDesignatorsMap.insert( { fp->GetReference(), fp->m_Uuid } );
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
const FOOTPRINTS & Footprints() const
A base class for most all the KiCad significant classes used in schematics and boards.
KICAD_T Type() const
Returns the type of object.
static TOOL_ACTION boardReannotate
A set of BOARD_ITEMs (i.e., without duplicates).
bool Empty() const
Checks if there is anything selected.
wxString GetRefDesPrefix(const wxString &aRefDes)
Get the (non-numeric) prefix from a refdes - e.g.
int GetRefDesNumber(const wxString &aRefDes)
Get the numeric suffix from a refdes - e.g.
Class to handle a set of BOARD_ITEMs.
Collection of utility functions for component reference designators (refdes)
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint