Browse Source

When updating footprints indicate which were changed.

Fixes https://gitlab.com/kicad/code/kicad/issues/4203
7.0
Jeff Young 4 years ago
parent
commit
fcb013e5d7
  1. 52
      pcbnew/dialogs/dialog_exchange_footprints.cpp
  2. 4
      pcbnew/dialogs/dialog_exchange_footprints.h
  3. 2
      pcbnew/pcb_edit_frame.h

52
pcbnew/dialogs/dialog_exchange_footprints.cpp

@ -307,11 +307,10 @@ void DIALOG_EXCHANGE_FOOTPRINTS::OnOKClicked( wxCommandEvent& event )
m_MessageWindow->Clear(); m_MessageWindow->Clear();
m_MessageWindow->Flush( false ); m_MessageWindow->Flush( false );
if( processMatchingFootprints() )
{
processMatchingFootprints();
m_parent->Compile_Ratsnest( true ); m_parent->Compile_Ratsnest( true );
m_parent->GetCanvas()->Refresh(); m_parent->GetCanvas()->Refresh();
}
m_MessageWindow->Flush( false ); m_MessageWindow->Flush( false );
@ -319,21 +318,20 @@ void DIALOG_EXCHANGE_FOOTPRINTS::OnOKClicked( wxCommandEvent& event )
} }
bool DIALOG_EXCHANGE_FOOTPRINTS::processMatchingFootprints()
void DIALOG_EXCHANGE_FOOTPRINTS::processMatchingFootprints()
{ {
bool change = false;
LIB_ID newFPID; LIB_ID newFPID;
wxString value; wxString value;
if( m_parent->GetBoard()->Footprints().empty() ) if( m_parent->GetBoard()->Footprints().empty() )
return false;
return;
if( !m_updateMode ) if( !m_updateMode )
{ {
newFPID.Parse( m_newID->GetValue() ); newFPID.Parse( m_newID->GetValue() );
if( !newFPID.IsValid() ) if( !newFPID.IsValid() )
return false;
return;
} }
/* /*
@ -349,22 +347,14 @@ bool DIALOG_EXCHANGE_FOOTPRINTS::processMatchingFootprints()
continue; continue;
if( m_updateMode ) if( m_updateMode )
{
if( processFootprint( footprint, footprint->GetFPID() ) )
change = true;
}
processFootprint( footprint, footprint->GetFPID() );
else else
{
if( processFootprint( footprint, newFPID ) )
change = true;
}
processFootprint( footprint, newFPID );
} }
return change;
} }
bool DIALOG_EXCHANGE_FOOTPRINTS::processFootprint( FOOTPRINT* aFootprint, const LIB_ID& aNewFPID )
void DIALOG_EXCHANGE_FOOTPRINTS::processFootprint( FOOTPRINT* aFootprint, const LIB_ID& aNewFPID )
{ {
LIB_ID oldFPID = aFootprint->GetFPID(); LIB_ID oldFPID = aFootprint->GetFPID();
wxString msg; wxString msg;
@ -372,14 +362,13 @@ bool DIALOG_EXCHANGE_FOOTPRINTS::processFootprint( FOOTPRINT* aFootprint, const
// Load new footprint. // Load new footprint.
if( m_updateMode ) if( m_updateMode )
{ {
msg.Printf( _( "Update footprint %s from '%s' to '%s'" ),
msg.Printf( _( "Updated footprint %s (%s)" ) + wxS( ": " ),
aFootprint->GetReference(), aFootprint->GetReference(),
oldFPID.Format().c_str(),
aNewFPID.Format().c_str() );
oldFPID.Format().c_str() );
} }
else else
{ {
msg.Printf( _( "Change footprint %s from '%s' to '%s'" ),
msg.Printf( _( "Changed footprint %s from '%s' to '%s'" ) + wxS( ": " ),
aFootprint->GetReference(), aFootprint->GetReference(),
oldFPID.Format().c_str(), oldFPID.Format().c_str(),
aNewFPID.Format().c_str() ); aNewFPID.Format().c_str() );
@ -389,11 +378,21 @@ bool DIALOG_EXCHANGE_FOOTPRINTS::processFootprint( FOOTPRINT* aFootprint, const
if( !newFootprint ) if( !newFootprint )
{ {
msg << ": " << _( "*** footprint not found ***" );
msg += _( "*** library footprint not found ***" );
m_MessageWindow->Report( msg, RPT_SEVERITY_ERROR ); m_MessageWindow->Report( msg, RPT_SEVERITY_ERROR );
return false;
return;
} }
if( m_updateMode && !aFootprint->FootprintNeedsUpdate( newFootprint ) )
{
msg += _( ": (no changes)" );
m_MessageWindow->Report( msg, RPT_SEVERITY_INFO );
return;
}
msg += _( ": OK" );
m_MessageWindow->Report( msg, RPT_SEVERITY_ACTION );
m_parent->ExchangeFootprint( aFootprint, newFootprint, m_commit, m_parent->ExchangeFootprint( aFootprint, newFootprint, m_commit,
m_removeExtraBox->GetValue(), m_removeExtraBox->GetValue(),
m_resetTextItemLayers->GetValue(), m_resetTextItemLayers->GetValue(),
@ -404,10 +403,7 @@ bool DIALOG_EXCHANGE_FOOTPRINTS::processFootprint( FOOTPRINT* aFootprint, const
if( aFootprint == m_currentFootprint ) if( aFootprint == m_currentFootprint )
m_currentFootprint = newFootprint; m_currentFootprint = newFootprint;
msg += ": OK";
m_MessageWindow->Report( msg, RPT_SEVERITY_ACTION );
return true;
return;
} }

4
pcbnew/dialogs/dialog_exchange_footprints.h

@ -53,8 +53,8 @@ private:
wxRadioButton* getRadioButtonForMode(); wxRadioButton* getRadioButtonForMode();
bool isMatch( FOOTPRINT* ); bool isMatch( FOOTPRINT* );
bool processMatchingFootprints();
bool processFootprint( FOOTPRINT* aFootprint, const LIB_ID& aNewFPID );
void processMatchingFootprints();
void processFootprint( FOOTPRINT* aFootprint, const LIB_ID& aNewFPID );
BOARD_COMMIT m_commit; BOARD_COMMIT m_commit;
PCB_EDIT_FRAME* m_parent; PCB_EDIT_FRAME* m_parent;

2
pcbnew/pcb_edit_frame.h

@ -537,6 +537,8 @@ public:
bool resetTextEffects = true, bool resetFabricationAttrs = true, bool resetTextEffects = true, bool resetFabricationAttrs = true,
bool reset3DModels = true ); bool reset3DModels = true );
bool FootprintMatchesLibrary();
/** /**
* Install the corresponding dialog editor for the given item. * Install the corresponding dialog editor for the given item.
* *

Loading…
Cancel
Save