Browse Source

Keep selection order in SCH->PCB cross-selection.

7.0
Alex 3 years ago
committed by Mike Williams
parent
commit
f75266d130
  1. 14
      eeschema/cross-probing.cpp
  2. 4
      eeschema/sch_edit_frame.h
  3. 2
      eeschema/tools/sch_editor_control.cpp
  4. 25
      pcbnew/cross-probing.cpp

14
eeschema/cross-probing.cpp

@ -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 ) 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(); 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; 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(); wxString full_path = GetCurrentSheet().PathAsString() + item->m_Uuid.AsString();
parts.emplace( wxT( "S" ) + full_path );
parts.push_back( wxT( "S" ) + full_path );
break; break;
} }
@ -312,8 +312,8 @@ void SCH_EDIT_FRAME::SendSelectItemsToPcb( const std::deque<EDA_ITEM*>& aItems,
wxString ref = symbol->GetField( REFERENCE_FIELD )->GetText(); 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; 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 // we have existing interpreter of the selection packet on the other
// side in place, we use that here. // side in place, we use that here.
Kiway().ExpressMail( FRAME_PCB_EDITOR, aForce ? MAIL_SELECTION_FORCE : MAIL_SELECTION, Kiway().ExpressMail( FRAME_PCB_EDITOR, aForce ? MAIL_SELECTION_FORCE : MAIL_SELECTION,
command, this );
command, this );
} }
} }

4
eeschema/sch_edit_frame.h

@ -263,11 +263,11 @@ public:
/** /**
* Sends items to Pcbnew for selection * 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 * @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 * 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 * Sends a net name to Pcbnew for highlighting

2
eeschema/tools/sch_editor_control.cpp

@ -739,7 +739,7 @@ void SCH_EDITOR_CONTROL::doCrossProbeSchToPcb( const TOOL_EVENT& aEvent, bool aF
EE_SELECTION& selection = aForce ? selTool->RequestSelection() : selTool->GetSelection(); EE_SELECTION& selection = aForce ? selTool->RequestSelection() : selTool->GetSelection();
m_frame->SendSelectItemsToPcb( selection.GetItems(), aForce );
m_frame->SendSelectItemsToPcb( selection.GetItemsSortedBySelectionOrder(), aForce );
} }

25
pcbnew/cross-probing.cpp

@ -432,7 +432,7 @@ std::vector<BOARD_ITEM*> PCB_EDIT_FRAME::FindItemsFromSyncSelection( std::string
{ {
wxArrayString syncArray = wxStringTokenize( syncStr, "," ); wxArrayString syncArray = wxStringTokenize( syncStr, "," );
std::vector<BOARD_ITEM*> items;
std::vector<std::pair<int, BOARD_ITEM*>> orderPairs;
for( FOOTPRINT* footprint : GetBoard()->Footprints() ) 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 ); 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() ) if( syncEntry.empty() )
continue; continue;
@ -462,13 +464,13 @@ std::vector<BOARD_ITEM*> PCB_EDIT_FRAME::FindItemsFromSyncSelection( std::string
case 'S': // Select sheet with subsheets: S<Sheet path> case 'S': // Select sheet with subsheets: S<Sheet path>
if( fpSheetPath.StartsWith( syncData ) ) if( fpSheetPath.StartsWith( syncData ) )
{ {
items.push_back( footprint );
orderPairs.emplace_back( index, footprint );
} }
break; break;
case 'F': // Select footprint: F<Reference> case 'F': // Select footprint: F<Reference>
if( syncData == fpRefEscaped ) if( syncData == fpRefEscaped )
{ {
items.push_back( footprint );
orderPairs.emplace_back( index, footprint );
} }
break; break;
case 'P': // Select pad: P<Footprint reference>/<Pad number> 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() ) 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; return items;
} }

Loading…
Cancel
Save