Implement future & past tenses for dry-run vs. changes made report.

Also improves zone reporting to list either the zone name or the layer
and coordinates.

Fixes https://gitlab.com/kicad/code/kicad/issues/7851
This commit is contained in:
Jeff Young 2021-03-11 12:33:06 +00:00
parent ea9c269914
commit 4db10d419d
1 changed files with 272 additions and 115 deletions

View File

@ -157,11 +157,17 @@ FOOTPRINT* BOARD_NETLIST_UPDATER::addNewComponent( COMPONENT* aComponent )
return nullptr; return nullptr;
} }
if( m_isDryRun )
{
msg.Printf( _( "Add %s (footprint \"%s\")." ), msg.Printf( _( "Add %s (footprint \"%s\")." ),
aComponent->GetReference(), aComponent->GetReference(),
aComponent->GetFPID().Format().wx_str() ); aComponent->GetFPID().Format().wx_str() );
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
delete footprint;
footprint = nullptr;
}
else
{
for( PAD* pad : footprint->Pads() ) for( PAD* pad : footprint->Pads() )
{ {
// Set the pads ratsnest settings to the global settings // Set the pads ratsnest settings to the global settings
@ -172,24 +178,20 @@ FOOTPRINT* BOARD_NETLIST_UPDATER::addNewComponent( COMPONENT* aComponent )
pad->SetNetCode( 0 ); pad->SetNetCode( 0 );
} }
m_newFootprintsCount++;
if( !m_isDryRun )
{
footprint->SetParent( m_board ); footprint->SetParent( m_board );
footprint->SetPosition( estimateComponentInsertionPosition( ) ); footprint->SetPosition( estimateComponentInsertionPosition( ) );
m_addedComponents.push_back( footprint ); m_addedComponents.push_back( footprint );
m_commit.Add( footprint ); m_commit.Add( footprint );
return footprint; msg.Printf( _( "Added %s (footprint \"%s\")." ),
} aComponent->GetReference(),
else aComponent->GetFPID().Format().wx_str() );
{
delete footprint;
} }
return NULL; m_reporter->Report( msg, RPT_SEVERITY_ACTION );
m_newFootprintsCount++;
return footprint;
} }
@ -220,25 +222,29 @@ FOOTPRINT* BOARD_NETLIST_UPDATER::replaceComponent( NETLIST& aNetlist, FOOTPRINT
return nullptr; return nullptr;
} }
msg.Printf( _( "Change %s footprint from \"%s\" to \"%s\"."), if( m_isDryRun )
{
msg.Printf( _( "Change %s footprint from '%s' to '%s'."),
aPcbComponent->GetReference(), aPcbComponent->GetReference(),
aPcbComponent->GetFPID().Format().wx_str(), aPcbComponent->GetFPID().Format().wx_str(),
aNewComponent->GetFPID().Format().wx_str() ); aNewComponent->GetFPID().Format().wx_str() );
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
m_newFootprintsCount++; delete newFootprint;
newFootprint = nullptr;
if( !m_isDryRun )
{
m_frame->ExchangeFootprint( aPcbComponent, newFootprint, m_commit );
return newFootprint;
} }
else else
{ {
delete newFootprint; m_frame->ExchangeFootprint( aPcbComponent, newFootprint, m_commit );
msg.Printf( _( "Changed %s footprint from '%s' to '%s'."),
aPcbComponent->GetReference(),
aPcbComponent->GetFPID().Format().wx_str(),
aNewComponent->GetFPID().Format().wx_str() );
} }
return nullptr; m_reporter->Report( msg, RPT_SEVERITY_ACTION );
m_newFootprintsCount++;
return newFootprint;
} }
@ -254,33 +260,48 @@ bool BOARD_NETLIST_UPDATER::updateFootprintParameters( FOOTPRINT* aPcbFootprint,
// Test for reference designator field change. // Test for reference designator field change.
if( aPcbFootprint->GetReference() != aNetlistComponent->GetReference() ) if( aPcbFootprint->GetReference() != aNetlistComponent->GetReference() )
{
if( m_isDryRun )
{ {
msg.Printf( _( "Change %s reference designator to %s." ), msg.Printf( _( "Change %s reference designator to %s." ),
aPcbFootprint->GetReference(), aPcbFootprint->GetReference(),
aNetlistComponent->GetReference() ); aNetlistComponent->GetReference() );
m_reporter->Report( msg, RPT_SEVERITY_ACTION ); }
else
if ( !m_isDryRun )
{ {
changed = true; changed = true;
aPcbFootprint->SetReference( aNetlistComponent->GetReference() ); aPcbFootprint->SetReference( aNetlistComponent->GetReference() );
msg.Printf( _( "Changed %s reference designator to %s." ),
aPcbFootprint->GetReference(),
aNetlistComponent->GetReference() );
} }
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
} }
// Test for value field change. // Test for value field change.
if( aPcbFootprint->GetValue() != aNetlistComponent->GetValue() ) if( aPcbFootprint->GetValue() != aNetlistComponent->GetValue() )
{
if( m_isDryRun )
{ {
msg.Printf( _( "Change %s value from %s to %s." ), msg.Printf( _( "Change %s value from %s to %s." ),
aPcbFootprint->GetReference(), aPcbFootprint->GetReference(),
aPcbFootprint->GetValue(), aPcbFootprint->GetValue(),
aNetlistComponent->GetValue() ); aNetlistComponent->GetValue() );
m_reporter->Report( msg, RPT_SEVERITY_ACTION ); }
else
if( !m_isDryRun )
{ {
changed = true; changed = true;
aPcbFootprint->SetValue( aNetlistComponent->GetValue() ); aPcbFootprint->SetValue( aNetlistComponent->GetValue() );
msg.Printf( _( "Changed %s value from %s to %s." ),
aPcbFootprint->GetReference(),
aPcbFootprint->GetValue(),
aNetlistComponent->GetValue() );
} }
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
} }
// Test for time stamp change. // Test for time stamp change.
@ -288,58 +309,85 @@ bool BOARD_NETLIST_UPDATER::updateFootprintParameters( FOOTPRINT* aPcbFootprint,
new_path.push_back( aNetlistComponent->GetKIIDs().front() ); new_path.push_back( aNetlistComponent->GetKIIDs().front() );
if( aPcbFootprint->GetPath() != new_path ) if( aPcbFootprint->GetPath() != new_path )
{
if( m_isDryRun )
{ {
msg.Printf( _( "Update %s symbol association from %s to %s." ), msg.Printf( _( "Update %s symbol association from %s to %s." ),
aPcbFootprint->GetReference(), aPcbFootprint->GetReference(),
aPcbFootprint->GetPath().AsString(), aPcbFootprint->GetPath().AsString(),
new_path.AsString() ); new_path.AsString() );
m_reporter->Report( msg, RPT_SEVERITY_ACTION ); }
else
if( !m_isDryRun )
{ {
changed = true; changed = true;
aPcbFootprint->SetPath( new_path ); aPcbFootprint->SetPath( new_path );
msg.Printf( _( "Updated %s symbol association from %s to %s." ),
aPcbFootprint->GetReference(),
aPcbFootprint->GetPath().AsString(),
new_path.AsString() );
} }
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
} }
if( aPcbFootprint->GetProperties() != aNetlistComponent->GetProperties() ) if( aPcbFootprint->GetProperties() != aNetlistComponent->GetProperties() )
{
if( m_isDryRun )
{ {
msg.Printf( _( "Update %s properties." ), msg.Printf( _( "Update %s properties." ),
aPcbFootprint->GetReference() ); aPcbFootprint->GetReference() );
m_reporter->Report( msg, RPT_SEVERITY_ACTION ); }
else
if( !m_isDryRun )
{ {
changed = true; changed = true;
aPcbFootprint->SetProperties( aNetlistComponent->GetProperties() ); aPcbFootprint->SetProperties( aNetlistComponent->GetProperties() );
msg.Printf( _( "Updated %s properties." ),
aPcbFootprint->GetReference() );
} }
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
} }
if( ( aNetlistComponent->GetProperties().count( "exclude_from_bom" ) > 0 ) if( ( aNetlistComponent->GetProperties().count( "exclude_from_bom" ) > 0 )
!= ( ( aPcbFootprint->GetAttributes() & FP_EXCLUDE_FROM_BOM ) > 0 ) ) != ( ( aPcbFootprint->GetAttributes() & FP_EXCLUDE_FROM_BOM ) > 0 ) )
{
if( m_isDryRun )
{
if( aNetlistComponent->GetProperties().count( "exclude_from_bom" ) )
{
msg.Printf( _( "Set %s 'exclude from BOM' fabrication attribute." ),
aPcbFootprint->GetReference() );
}
else
{
msg.Printf( _( "Remove %s 'exclude from BOM' fabrication attribute." ),
aPcbFootprint->GetReference() );
}
}
else
{ {
int attributes = aPcbFootprint->GetAttributes(); int attributes = aPcbFootprint->GetAttributes();
if( aNetlistComponent->GetProperties().count( "exclude_from_bom" ) ) if( aNetlistComponent->GetProperties().count( "exclude_from_bom" ) )
{ {
attributes |= FP_EXCLUDE_FROM_BOM; attributes |= FP_EXCLUDE_FROM_BOM;
msg.Printf( _( "Setting %s 'exclude from BOM' fabrication attribute." ), msg.Printf( _( "Set %s 'exclude from BOM' fabrication attribute." ),
aPcbFootprint->GetReference() ); aPcbFootprint->GetReference() );
} }
else else
{ {
attributes &= ~FP_EXCLUDE_FROM_BOM; attributes &= ~FP_EXCLUDE_FROM_BOM;
msg.Printf( _( "Removing %s 'exclude from BOM' fabrication attribute." ), msg.Printf( _( "Removed %s 'exclude from BOM' fabrication attribute." ),
aPcbFootprint->GetReference() ); aPcbFootprint->GetReference() );
} }
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
if( !m_isDryRun )
{
changed = true; changed = true;
aPcbFootprint->SetAttributes( attributes ); aPcbFootprint->SetAttributes( attributes );
} }
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
} }
if( changed && copy ) if( changed && copy )
@ -395,16 +443,26 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( FOOTPRINT* aFootprint
if( !net.IsValid() || !pad->IsOnCopperLayer() ) if( !net.IsValid() || !pad->IsOnCopperLayer() )
{ {
if( !pad->GetNetname().IsEmpty() ) if( !pad->GetNetname().IsEmpty() )
{
if( m_isDryRun )
{ {
msg.Printf( _( "Disconnect %s pin %s." ), msg.Printf( _( "Disconnect %s pin %s." ),
aFootprint->GetReference(), aFootprint->GetReference(),
pad->GetName() ); pad->GetName() );
}
else
{
msg.Printf( _( "Disconnected %s pin %s." ),
aFootprint->GetReference(),
pad->GetName() );
}
m_reporter->Report( msg, RPT_SEVERITY_ACTION ); m_reporter->Report( msg, RPT_SEVERITY_ACTION );
} }
else if( m_warnForNoNetPads && pad->IsOnCopperLayer() && !pad->GetName().IsEmpty() ) else if( m_warnForNoNetPads && pad->IsOnCopperLayer() && !pad->GetName().IsEmpty() )
{ {
// pad is connectable but has no net found in netlist // pad is connectable but has no net found in netlist
msg.Printf( _( "No net for symbol %s pin %s." ), msg.Printf( _( "No net found for symbol %s pin %s." ),
aFootprint->GetReference(), aFootprint->GetReference(),
pad->GetName() ); pad->GetName() );
m_reporter->Report( msg, RPT_SEVERITY_WARNING); m_reporter->Report( msg, RPT_SEVERITY_WARNING);
@ -462,6 +520,8 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( FOOTPRINT* aFootprint
{ {
m_oldToNewNets[ pad->GetNetname() ] = netName; m_oldToNewNets[ pad->GetNetname() ] = netName;
if( m_isDryRun )
{
msg.Printf( _( "Reconnect %s pin %s from %s to %s."), msg.Printf( _( "Reconnect %s pin %s from %s to %s."),
aFootprint->GetReference(), aFootprint->GetReference(),
pad->GetName(), pad->GetName(),
@ -469,12 +529,33 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( FOOTPRINT* aFootprint
UnescapeString( netName ) ); UnescapeString( netName ) );
} }
else else
{
msg.Printf( _( "Reconnected %s pin %s from %s to %s."),
aFootprint->GetReference(),
pad->GetName(),
UnescapeString( pad->GetNetname() ),
UnescapeString( netName ) );
}
}
else
{
if( m_isDryRun )
{ {
msg.Printf( _( "Connect %s pin %s to %s."), msg.Printf( _( "Connect %s pin %s to %s."),
aFootprint->GetReference(), aFootprint->GetReference(),
pad->GetName(), pad->GetName(),
UnescapeString( netName ) ); UnescapeString( netName ) );
} }
else
{
msg.Printf( _( "Connected %s pin %s to %s."),
aFootprint->GetReference(),
pad->GetName(),
UnescapeString( netName ) );
}
}
m_reporter->Report( msg, RPT_SEVERITY_ACTION ); m_reporter->Report( msg, RPT_SEVERITY_ACTION );
if( !m_isDryRun ) if( !m_isDryRun )
@ -483,10 +564,12 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( FOOTPRINT* aFootprint
pad->SetNet( netinfo ); pad->SetNet( netinfo );
} }
else else
{
cacheNetname( pad, netName ); cacheNetname( pad, netName );
} }
} }
} }
}
if( changed && copy ) if( changed && copy )
m_commit.Modified( aFootprint, copy ); m_commit.Modified( aFootprint, copy );
@ -541,13 +624,16 @@ bool BOARD_NETLIST_UPDATER::updateCopperZoneNets( NETLIST& aNetlist )
} }
if( !updatedNetname.IsEmpty() ) if( !updatedNetname.IsEmpty() )
{
if( m_isDryRun )
{ {
msg.Printf( _( "Reconnect via from %s to %s." ), msg.Printf( _( "Reconnect via from %s to %s." ),
UnescapeString( via->GetNetname() ), UnescapeString( via->GetNetname() ),
UnescapeString( updatedNetname ) ); UnescapeString( updatedNetname ) );
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
if( !m_isDryRun ) m_reporter->Report( msg, RPT_SEVERITY_ACTION );
}
else
{ {
NETINFO_ITEM* netinfo = m_board->FindNet( updatedNetname ); NETINFO_ITEM* netinfo = m_board->FindNet( updatedNetname );
@ -558,6 +644,12 @@ bool BOARD_NETLIST_UPDATER::updateCopperZoneNets( NETLIST& aNetlist )
{ {
m_commit.Modify( via ); m_commit.Modify( via );
via->SetNet( netinfo ); via->SetNet( netinfo );
msg.Printf( _( "Reconnected via from %s to %s." ),
UnescapeString( via->GetNetname() ),
UnescapeString( updatedNetname ) );
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
} }
} }
} }
@ -601,13 +693,26 @@ bool BOARD_NETLIST_UPDATER::updateCopperZoneNets( NETLIST& aNetlist )
} }
if( !updatedNetname.IsEmpty() ) if( !updatedNetname.IsEmpty() )
{
if( m_isDryRun )
{
if( !zone->GetZoneName().IsEmpty() )
{
msg.Printf( _( "Reconnect copper zone '%s' from %s to %s." ),
zone->GetZoneName(),
UnescapeString( zone->GetNetname() ),
UnescapeString( updatedNetname ) );
}
else
{ {
msg.Printf( _( "Reconnect copper zone from %s to %s." ), msg.Printf( _( "Reconnect copper zone from %s to %s." ),
UnescapeString( zone->GetNetname() ), UnescapeString( zone->GetNetname() ),
UnescapeString( updatedNetname ) ); UnescapeString( updatedNetname ) );
m_reporter->Report( msg, RPT_SEVERITY_ACTION ); }
if( !m_isDryRun ) m_reporter->Report( msg, RPT_SEVERITY_ACTION );
}
else
{ {
NETINFO_ITEM* netinfo = m_board->FindNet( updatedNetname ); NETINFO_ITEM* netinfo = m_board->FindNet( updatedNetname );
@ -618,13 +723,43 @@ bool BOARD_NETLIST_UPDATER::updateCopperZoneNets( NETLIST& aNetlist )
{ {
m_commit.Modify( zone ); m_commit.Modify( zone );
zone->SetNet( netinfo ); zone->SetNet( netinfo );
if( !zone->GetZoneName().IsEmpty() )
{
msg.Printf( _( "Reconnected copper zone '%s' from %s to %s." ),
zone->GetZoneName(),
UnescapeString( zone->GetNetname() ),
UnescapeString( updatedNetname ) );
}
else
{
msg.Printf( _( "Reconnected copper zone from %s to %s." ),
UnescapeString( zone->GetNetname() ),
UnescapeString( updatedNetname ) );
}
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
} }
} }
} }
else else
{ {
msg.Printf( _( "Copper zone (%s) has no pads connected." ), if( !zone->GetZoneName().IsEmpty() )
UnescapeString( zone->GetNetname() ) ); {
msg.Printf( _( "Copper zone '%s' has no pads connected." ),
zone->GetZoneName() );
}
else
{
PCB_LAYER_ID layer = zone->GetLayer();
wxPoint pos = zone->GetPosition();
msg.Printf( _( "Copper zone on layer %s at (%s, %s) has no pads connected." ),
m_board->GetLayerName( layer ),
MessageTextFromValue( m_frame->GetUserUnits(), pos.x ),
MessageTextFromValue( m_frame->GetUserUnits(), pos.y ) );
}
m_reporter->Report( msg, RPT_SEVERITY_WARNING ); m_reporter->Report( msg, RPT_SEVERITY_WARNING );
++m_warningCount; ++m_warningCount;
} }
@ -649,7 +784,8 @@ bool BOARD_NETLIST_UPDATER::deleteSinglePadNets()
std::vector<PAD*> padlist = m_board->GetPads(); std::vector<PAD*> padlist = m_board->GetPads();
// Sort pads by netlist name // Sort pads by netlist name
std::sort( padlist.begin(), padlist.end(), [ this ]( PAD* a, PAD* b ) -> bool std::sort( padlist.begin(), padlist.end(),
[ this ]( PAD* a, PAD* b ) -> bool
{ {
return getNetname( a ) < getNetname( b ); return getNetname( a ) < getNetname( b );
} ); } );
@ -683,14 +819,20 @@ bool BOARD_NETLIST_UPDATER::deleteSinglePadNets()
if( count == 1 ) // Really one pad, and nothing else if( count == 1 ) // Really one pad, and nothing else
{ {
if( m_isDryRun )
{
cacheNetname( previouspad, wxEmptyString );
msg.Printf( _( "Remove single pad net %s." ), msg.Printf( _( "Remove single pad net %s." ),
UnescapeString( getNetname( previouspad ) ) ); UnescapeString( getNetname( previouspad ) ) );
m_reporter->Report( msg, RPT_SEVERITY_ACTION ); }
if( !m_isDryRun )
previouspad->SetNetCode( NETINFO_LIST::UNCONNECTED );
else else
cacheNetname( previouspad, wxEmptyString ); {
previouspad->SetNetCode( NETINFO_LIST::UNCONNECTED );
msg.Printf( _( "Removed single pad net %s." ),
UnescapeString( getNetname( previouspad ) ) );
}
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
} }
} }
@ -893,20 +1035,35 @@ bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist )
} }
if( doDelete && footprint->IsLocked() ) if( doDelete && footprint->IsLocked() )
{
if( m_isDryRun )
{ {
msg.Printf( _( "Cannot remove unused footprint %s (locked)." ), msg.Printf( _( "Cannot remove unused footprint %s (locked)." ),
footprint->GetReference() ); footprint->GetReference() );
}
else
{
msg.Printf( _( "Could not remove unused footprint %s (locked)." ),
footprint->GetReference() );
}
m_reporter->Report( msg, RPT_SEVERITY_WARNING ); m_reporter->Report( msg, RPT_SEVERITY_WARNING );
doDelete = false; doDelete = false;
} }
if( doDelete ) if( doDelete )
{
if( m_isDryRun )
{ {
msg.Printf( _( "Remove unused footprint %s." ), footprint->GetReference() ); msg.Printf( _( "Remove unused footprint %s." ), footprint->GetReference() );
m_reporter->Report( msg, RPT_SEVERITY_ACTION ); }
else
if( !m_isDryRun ) {
m_commit.Remove( footprint ); m_commit.Remove( footprint );
msg.Printf( _( "Removed unused footprint %s." ), footprint->GetReference() );
}
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
} }
else if( !m_isDryRun ) else if( !m_isDryRun )
{ {
@ -931,7 +1088,7 @@ bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist )
{ {
if( !net->IsCurrent() ) if( !net->IsCurrent() )
{ {
msg.Printf( _( "Remove unused net \"%s\"." ), net->GetNetname() ); msg.Printf( _( "Removed unused net %s." ), net->GetNetname() );
m_reporter->Report( msg, RPT_SEVERITY_ACTION ); m_reporter->Report( msg, RPT_SEVERITY_ACTION );
m_commit.Removed( net ); m_commit.Removed( net );
} }