Keep selection order in SCH->PCB cross-selection.
This commit is contained in:
parent
bb1eb94aa0
commit
f75266d130
|
@ -274,9 +274,9 @@ void SCH_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
|
|||
}
|
||||
|
||||
|
||||
void SCH_EDIT_FRAME::SendSelectItemsToPcb( const std::deque<EDA_ITEM*>& aItems, bool aForce )
|
||||
void SCH_EDIT_FRAME::SendSelectItemsToPcb( const std::vector<EDA_ITEM*>& aItems, bool aForce )
|
||||
{
|
||||
std::set<wxString> parts;
|
||||
std::vector<wxString> parts;
|
||||
|
||||
for( EDA_ITEM* item : aItems )
|
||||
{
|
||||
|
@ -288,7 +288,7 @@ void SCH_EDIT_FRAME::SendSelectItemsToPcb( const std::deque<EDA_ITEM*>& aItems,
|
|||
|
||||
wxString ref = symbol->GetField( REFERENCE_FIELD )->GetText();
|
||||
|
||||
parts.emplace( wxT( "F" ) + EscapeString( ref, CTX_IPC ) );
|
||||
parts.push_back( wxT( "F" ) + EscapeString( ref, CTX_IPC ) );
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -300,7 +300,7 @@ void SCH_EDIT_FRAME::SendSelectItemsToPcb( const std::deque<EDA_ITEM*>& aItems,
|
|||
|
||||
wxString full_path = GetCurrentSheet().PathAsString() + item->m_Uuid.AsString();
|
||||
|
||||
parts.emplace( wxT( "S" ) + full_path );
|
||||
parts.push_back( wxT( "S" ) + full_path );
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -312,8 +312,8 @@ void SCH_EDIT_FRAME::SendSelectItemsToPcb( const std::deque<EDA_ITEM*>& aItems,
|
|||
|
||||
wxString ref = symbol->GetField( REFERENCE_FIELD )->GetText();
|
||||
|
||||
parts.insert( wxT( "P" ) + EscapeString( ref, CTX_IPC ) + wxT( "/" )
|
||||
+ EscapeString( pin->GetShownNumber(), CTX_IPC ) );
|
||||
parts.push_back( wxT( "P" ) + EscapeString( ref, CTX_IPC ) + wxT( "/" )
|
||||
+ EscapeString( pin->GetShownNumber(), CTX_IPC ) );
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -347,7 +347,7 @@ void SCH_EDIT_FRAME::SendSelectItemsToPcb( const std::deque<EDA_ITEM*>& aItems,
|
|||
// we have existing interpreter of the selection packet on the other
|
||||
// side in place, we use that here.
|
||||
Kiway().ExpressMail( FRAME_PCB_EDITOR, aForce ? MAIL_SELECTION_FORCE : MAIL_SELECTION,
|
||||
command, this );
|
||||
command, this );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -263,11 +263,11 @@ public:
|
|||
/**
|
||||
* Sends items to Pcbnew for selection
|
||||
*
|
||||
* @param aElements are the items to select
|
||||
* @param aItems are the items to select
|
||||
* @param aForce select the element in pcbnew whether or not the user has the select option chosen
|
||||
* This is used for when the eeschema user is using the cross-probe tool
|
||||
*/
|
||||
void SendSelectItemsToPcb( const std::deque<EDA_ITEM*>& aElements, bool aForce );
|
||||
void SendSelectItemsToPcb( const std::vector<EDA_ITEM*>& aItems, bool aForce );
|
||||
|
||||
/**
|
||||
* Sends a net name to Pcbnew for highlighting
|
||||
|
|
|
@ -739,7 +739,7 @@ void SCH_EDITOR_CONTROL::doCrossProbeSchToPcb( const TOOL_EVENT& aEvent, bool aF
|
|||
|
||||
EE_SELECTION& selection = aForce ? selTool->RequestSelection() : selTool->GetSelection();
|
||||
|
||||
m_frame->SendSelectItemsToPcb( selection.GetItems(), aForce );
|
||||
m_frame->SendSelectItemsToPcb( selection.GetItemsSortedBySelectionOrder(), aForce );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -432,7 +432,7 @@ std::vector<BOARD_ITEM*> PCB_EDIT_FRAME::FindItemsFromSyncSelection( std::string
|
|||
{
|
||||
wxArrayString syncArray = wxStringTokenize( syncStr, "," );
|
||||
|
||||
std::vector<BOARD_ITEM*> items;
|
||||
std::vector<std::pair<int, BOARD_ITEM*>> orderPairs;
|
||||
|
||||
for( FOOTPRINT* footprint : GetBoard()->Footprints() )
|
||||
{
|
||||
|
@ -450,8 +450,10 @@ std::vector<BOARD_ITEM*> PCB_EDIT_FRAME::FindItemsFromSyncSelection( std::string
|
|||
|
||||
wxString fpRefEscaped = EscapeString( footprint->GetReference(), CTX_IPC );
|
||||
|
||||
for( wxString syncEntry : syncArray )
|
||||
for( unsigned index = 0; index < syncArray.size(); ++index )
|
||||
{
|
||||
wxString syncEntry = syncArray[index];
|
||||
|
||||
if( syncEntry.empty() )
|
||||
continue;
|
||||
|
||||
|
@ -462,13 +464,13 @@ std::vector<BOARD_ITEM*> PCB_EDIT_FRAME::FindItemsFromSyncSelection( std::string
|
|||
case 'S': // Select sheet with subsheets: S<Sheet path>
|
||||
if( fpSheetPath.StartsWith( syncData ) )
|
||||
{
|
||||
items.push_back( footprint );
|
||||
orderPairs.emplace_back( index, footprint );
|
||||
}
|
||||
break;
|
||||
case 'F': // Select footprint: F<Reference>
|
||||
if( syncData == fpRefEscaped )
|
||||
{
|
||||
items.push_back( footprint );
|
||||
orderPairs.emplace_back( index, footprint );
|
||||
}
|
||||
break;
|
||||
case 'P': // Select pad: P<Footprint reference>/<Pad number>
|
||||
|
@ -484,7 +486,7 @@ std::vector<BOARD_ITEM*> PCB_EDIT_FRAME::FindItemsFromSyncSelection( std::string
|
|||
{
|
||||
if( selectPadNumber == pad->GetNumber() )
|
||||
{
|
||||
items.push_back( pad );
|
||||
orderPairs.emplace_back( index, pad );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -495,6 +497,19 @@ std::vector<BOARD_ITEM*> PCB_EDIT_FRAME::FindItemsFromSyncSelection( std::string
|
|||
}
|
||||
}
|
||||
|
||||
std::sort(
|
||||
orderPairs.begin(), orderPairs.end(),
|
||||
[]( const std::pair<int, BOARD_ITEM*>& a, const std::pair<int, BOARD_ITEM*>& b ) -> bool
|
||||
{
|
||||
return a.first < b.first;
|
||||
} );
|
||||
|
||||
std::vector<BOARD_ITEM*> items;
|
||||
items.reserve( orderPairs.size() );
|
||||
|
||||
for( const std::pair<int, BOARD_ITEM*>& pair : orderPairs )
|
||||
items.push_back( pair.second );
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue