If more than one text matches by text try layer and then position.
Fixes https://gitlab.com/kicad/code/kicad/issues/4187
(cherry picked from commit 8df5f70c4a
)
This commit is contained in:
parent
d22003578e
commit
e37e13e700
|
@ -398,15 +398,49 @@ void processTextItem( const TEXTE_MODULE& aSrc, TEXTE_MODULE& aDest,
|
|||
|
||||
TEXTE_MODULE* getMatchingTextItem( TEXTE_MODULE* aRefItem, MODULE* aModule )
|
||||
{
|
||||
std::vector<TEXTE_MODULE*> candidates;
|
||||
|
||||
for( auto iItem = aModule->GraphicalItemsList().GetFirst(); iItem; iItem = iItem->Next() )
|
||||
{
|
||||
TEXTE_MODULE* candidate = dyn_cast<TEXTE_MODULE*>( iItem );
|
||||
|
||||
if( candidate && candidate->GetText() == aRefItem->GetText() )
|
||||
return candidate;
|
||||
candidates.push_back( candidate );
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
if( candidates.size() == 0 )
|
||||
return nullptr;
|
||||
|
||||
if( candidates.size() == 1 )
|
||||
return candidates[0];
|
||||
|
||||
// Try refining the match by layer
|
||||
std::vector<TEXTE_MODULE*> candidatesOnSameLayer;
|
||||
|
||||
for( TEXTE_MODULE* candidate : candidates )
|
||||
{
|
||||
if( candidate->GetLayer() == aRefItem->GetLayer() )
|
||||
candidatesOnSameLayer.push_back( candidate );
|
||||
}
|
||||
|
||||
if( candidatesOnSameLayer.size() == 1 )
|
||||
return candidatesOnSameLayer[0];
|
||||
|
||||
// Last ditch effort: refine by position
|
||||
std::vector<TEXTE_MODULE*> candidatesAtSamePos;
|
||||
|
||||
for( TEXTE_MODULE* candidate : candidatesOnSameLayer.size() ? candidatesOnSameLayer : candidates )
|
||||
{
|
||||
if( candidate->GetPos0() == aRefItem->GetPos0() )
|
||||
candidatesAtSamePos.push_back( candidate );
|
||||
}
|
||||
|
||||
if( candidatesAtSamePos.size() > 0 )
|
||||
return candidatesAtSamePos[0];
|
||||
else if( candidatesOnSameLayer.size() > 0 )
|
||||
return candidatesOnSameLayer[0];
|
||||
else
|
||||
return candidates[0];
|
||||
}
|
||||
|
||||
|
||||
|
@ -432,7 +466,7 @@ void PCB_EDIT_FRAME::Exchange_Module( MODULE* aSrc, MODULE* aDest, BOARD_COMMIT&
|
|||
|
||||
aDest->SetLocked( aSrc->IsLocked() );
|
||||
|
||||
for( auto pad : aDest->Pads() )
|
||||
for( D_PAD* pad : aDest->Pads() )
|
||||
{
|
||||
D_PAD* oldPad = aSrc->FindPadByName( pad->GetName() );
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Dec 1 2018)
|
||||
// C++ code generated with wxFormBuilder (version Oct 26 2018)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
@ -40,7 +40,7 @@ DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS_BASE::DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS_
|
|||
m_boardGraphics = new wxCheckBox( sbScope->GetStaticBox(), wxID_ANY, _("PCB graphic items"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
fgSizer3->Add( m_boardGraphics, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_otherFields = new wxCheckBox( sbScope->GetStaticBox(), wxID_ANY, _("Other footprint fields"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_otherFields = new wxCheckBox( sbScope->GetStaticBox(), wxID_ANY, _("Other footprint text items"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
fgSizer3->Add( m_otherFields, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
|
||||
|
@ -231,7 +231,7 @@ DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS_BASE::DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS_
|
|||
m_grid = new wxGrid( sbAction->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE );
|
||||
|
||||
// Grid
|
||||
m_grid->CreateGrid( 6, 7 );
|
||||
m_grid->CreateGrid( 7, 7 );
|
||||
m_grid->EnableEditing( false );
|
||||
m_grid->EnableGridLines( true );
|
||||
m_grid->EnableDragGridSize( false );
|
||||
|
|
|
@ -376,7 +376,7 @@
|
|||
<property name="gripper">0</property>
|
||||
<property name="hidden">0</property>
|
||||
<property name="id">wxID_ANY</property>
|
||||
<property name="label">Other footprint fields</property>
|
||||
<property name="label">Other footprint text items</property>
|
||||
<property name="max_size"></property>
|
||||
<property name="maximize_button">0</property>
|
||||
<property name="maximum_size"></property>
|
||||
|
@ -2425,7 +2425,7 @@
|
|||
<property name="row_label_values"></property>
|
||||
<property name="row_label_vert_alignment">wxALIGN_CENTER</property>
|
||||
<property name="row_sizes"></property>
|
||||
<property name="rows">6</property>
|
||||
<property name="rows">7</property>
|
||||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="subclass"></property>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Dec 1 2018)
|
||||
// C++ code generated with wxFormBuilder (version Oct 26 2018)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
|
|
Loading…
Reference in New Issue