From 06ccef3dd4913025d27e4054801a7bcfe5c491ce Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 6 Sep 2020 17:14:47 +0100 Subject: [PATCH] Update all instances in CvPcb when one is changed. --- cvpcb/cvpcb_mainframe.cpp | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/cvpcb/cvpcb_mainframe.cpp b/cvpcb/cvpcb_mainframe.cpp index 86364aea56..b33a6d144c 100644 --- a/cvpcb/cvpcb_mainframe.cpp +++ b/cvpcb/cvpcb_mainframe.cpp @@ -479,22 +479,33 @@ void CVPCB_MAINFRAME::AssociateFootprint( const CVPCB_ASSOCIATION& aAssociation, // Test for validity of the requested footprint if( !fpid.empty() && !fpid.IsValid() ) { - wxString msg = - wxString::Format( _( "\"%s\" is not a valid footprint." ), fpid.Format().wx_str() ); + wxString msg = wxString::Format( _( "\"%s\" is not a valid footprint." ), + fpid.Format().wx_str() ); DisplayErrorMessage( this, msg ); return; } - // Set the new footprint - component->SetFPID( fpid ); + const KIID& id = component->GetPath().back(); - // create the new component description and set it - wxString description = wxString::Format( CMP_FORMAT, - aAssociation.GetComponentIndex() + 1, - component->GetReference(), - component->GetValue(), - component->GetFPID().Format().wx_str() ); - m_compListBox->SetString( aAssociation.GetComponentIndex(), description ); + // Set new footprint to all instances of the selected component + for( unsigned int idx : GetComponentIndices() ) + { + COMPONENT* candidate = m_netlist.GetComponent( idx ); + + if( candidate->GetPath().back() == id ) + { + // Set the new footprint + candidate->SetFPID( fpid ); + + // create the new component description and set it + wxString description = wxString::Format( CMP_FORMAT, + idx + 1, + candidate->GetReference(), + candidate->GetValue(), + candidate->GetFPID().Format().wx_str() ); + m_compListBox->SetString( idx, description ); + } + } // Mark the data as being modified m_modified = true;