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,39 +157,41 @@ FOOTPRINT* BOARD_NETLIST_UPDATER::addNewComponent( COMPONENT* aComponent )
return nullptr; return nullptr;
} }
msg.Printf( _( "Add %s (footprint \"%s\")." ), if( m_isDryRun )
aComponent->GetReference(),
aComponent->GetFPID().Format().wx_str() );
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
for( PAD* pad : footprint->Pads() )
{ {
// Set the pads ratsnest settings to the global settings msg.Printf( _( "Add %s (footprint \"%s\")." ),
pad->SetLocalRatsnestVisible( m_frame->GetDisplayOptions().m_ShowGlobalRatsnest ); aComponent->GetReference(),
pad->SetLocked( !m_frame->Settings().m_AddUnlockedPads ); aComponent->GetFPID().Format().wx_str() );
// Pads in the library all have orphaned nets. Replace with Default. delete footprint;
pad->SetNetCode( 0 ); footprint = nullptr;
} }
else
m_newFootprintsCount++;
if( !m_isDryRun )
{ {
for( PAD* pad : footprint->Pads() )
{
// Set the pads ratsnest settings to the global settings
pad->SetLocalRatsnestVisible( m_frame->GetDisplayOptions().m_ShowGlobalRatsnest );
pad->SetLocked( !m_frame->Settings().m_AddUnlockedPads );
// Pads in the library all have orphaned nets. Replace with Default.
pad->SetNetCode( 0 );
}
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 )
aPcbComponent->GetReference(),
aPcbComponent->GetFPID().Format().wx_str(),
aNewComponent->GetFPID().Format().wx_str() );
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
m_newFootprintsCount++;
if( !m_isDryRun )
{ {
m_frame->ExchangeFootprint( aPcbComponent, newFootprint, m_commit ); msg.Printf( _( "Change %s footprint from '%s' to '%s'."),
return newFootprint; aPcbComponent->GetReference(),
aPcbComponent->GetFPID().Format().wx_str(),
aNewComponent->GetFPID().Format().wx_str() );
delete newFootprint;
newFootprint = nullptr;
} }
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;
} }
@ -255,32 +261,47 @@ 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() )
{ {
msg.Printf( _( "Change %s reference designator to %s." ), if( m_isDryRun )
aPcbFootprint->GetReference(), {
aNetlistComponent->GetReference() ); msg.Printf( _( "Change %s reference designator to %s." ),
m_reporter->Report( msg, RPT_SEVERITY_ACTION ); aPcbFootprint->GetReference(),
aNetlistComponent->GetReference() );
if ( !m_isDryRun ) }
else
{ {
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() )
{ {
msg.Printf( _( "Change %s value from %s to %s." ), if( m_isDryRun )
aPcbFootprint->GetReference(), {
aPcbFootprint->GetValue(), msg.Printf( _( "Change %s value from %s to %s." ),
aNetlistComponent->GetValue() ); aPcbFootprint->GetReference(),
m_reporter->Report( msg, RPT_SEVERITY_ACTION ); aPcbFootprint->GetValue(),
aNetlistComponent->GetValue() );
if( !m_isDryRun ) }
else
{ {
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.
@ -289,57 +310,84 @@ bool BOARD_NETLIST_UPDATER::updateFootprintParameters( FOOTPRINT* aPcbFootprint,
if( aPcbFootprint->GetPath() != new_path ) if( aPcbFootprint->GetPath() != new_path )
{ {
msg.Printf( _( "Update %s symbol association from %s to %s." ), if( m_isDryRun )
aPcbFootprint->GetReference(), {
aPcbFootprint->GetPath().AsString(), msg.Printf( _( "Update %s symbol association from %s to %s." ),
new_path.AsString() ); aPcbFootprint->GetReference(),
m_reporter->Report( msg, RPT_SEVERITY_ACTION ); aPcbFootprint->GetPath().AsString(),
new_path.AsString() );
if( !m_isDryRun ) }
else
{ {
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() )
{ {
msg.Printf( _( "Update %s properties." ), if( m_isDryRun )
aPcbFootprint->GetReference() ); {
m_reporter->Report( msg, RPT_SEVERITY_ACTION ); msg.Printf( _( "Update %s properties." ),
aPcbFootprint->GetReference() );
if( !m_isDryRun ) }
else
{ {
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 ) )
{ {
int attributes = aPcbFootprint->GetAttributes(); if( m_isDryRun )
if( aNetlistComponent->GetProperties().count( "exclude_from_bom" ) )
{ {
attributes |= FP_EXCLUDE_FROM_BOM; if( aNetlistComponent->GetProperties().count( "exclude_from_bom" ) )
msg.Printf( _( "Setting %s 'exclude from BOM' fabrication attribute." ), {
aPcbFootprint->GetReference() ); msg.Printf( _( "Set %s 'exclude from BOM' fabrication attribute." ),
aPcbFootprint->GetReference() );
}
else
{
msg.Printf( _( "Remove %s 'exclude from BOM' fabrication attribute." ),
aPcbFootprint->GetReference() );
}
} }
else else
{ {
attributes &= ~FP_EXCLUDE_FROM_BOM; int attributes = aPcbFootprint->GetAttributes();
msg.Printf( _( "Removing %s 'exclude from BOM' fabrication attribute." ),
aPcbFootprint->GetReference() );
}
m_reporter->Report( msg, RPT_SEVERITY_ACTION ); if( aNetlistComponent->GetProperties().count( "exclude_from_bom" ) )
{
attributes |= FP_EXCLUDE_FROM_BOM;
msg.Printf( _( "Set %s 'exclude from BOM' fabrication attribute." ),
aPcbFootprint->GetReference() );
}
else
{
attributes &= ~FP_EXCLUDE_FROM_BOM;
msg.Printf( _( "Removed %s 'exclude from BOM' fabrication attribute." ),
aPcbFootprint->GetReference() );
}
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 )
@ -396,15 +444,25 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( FOOTPRINT* aFootprint
{ {
if( !pad->GetNetname().IsEmpty() ) if( !pad->GetNetname().IsEmpty() )
{ {
msg.Printf( _( "Disconnect %s pin %s." ), if( m_isDryRun )
aFootprint->GetReference(), {
pad->GetName() ); msg.Printf( _( "Disconnect %s pin %s." ),
aFootprint->GetReference(),
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,19 +520,42 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( FOOTPRINT* aFootprint
{ {
m_oldToNewNets[ pad->GetNetname() ] = netName; m_oldToNewNets[ pad->GetNetname() ] = netName;
msg.Printf( _( "Reconnect %s pin %s from %s to %s."), if( m_isDryRun )
aFootprint->GetReference(), {
pad->GetName(), msg.Printf( _( "Reconnect %s pin %s from %s to %s."),
UnescapeString( pad->GetNetname() ), aFootprint->GetReference(),
UnescapeString( netName ) ); pad->GetName(),
UnescapeString( pad->GetNetname() ),
UnescapeString( netName ) );
}
else
{
msg.Printf( _( "Reconnected %s pin %s from %s to %s."),
aFootprint->GetReference(),
pad->GetName(),
UnescapeString( pad->GetNetname() ),
UnescapeString( netName ) );
}
} }
else else
{ {
msg.Printf( _( "Connect %s pin %s to %s."), if( m_isDryRun )
aFootprint->GetReference(), {
pad->GetName(), msg.Printf( _( "Connect %s pin %s to %s."),
UnescapeString( netName ) ); aFootprint->GetReference(),
pad->GetName(),
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,7 +564,9 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( FOOTPRINT* aFootprint
pad->SetNet( netinfo ); pad->SetNet( netinfo );
} }
else else
{
cacheNetname( pad, netName ); cacheNetname( pad, netName );
}
} }
} }
} }
@ -542,12 +625,15 @@ bool BOARD_NETLIST_UPDATER::updateCopperZoneNets( NETLIST& aNetlist )
if( !updatedNetname.IsEmpty() ) if( !updatedNetname.IsEmpty() )
{ {
msg.Printf( _( "Reconnect via from %s to %s." ), if( m_isDryRun )
UnescapeString( via->GetNetname() ), {
UnescapeString( updatedNetname ) ); msg.Printf( _( "Reconnect via from %s to %s." ),
m_reporter->Report( msg, RPT_SEVERITY_ACTION ); UnescapeString( via->GetNetname() ),
UnescapeString( updatedNetname ) );
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 );
} }
} }
} }
@ -602,12 +694,25 @@ bool BOARD_NETLIST_UPDATER::updateCopperZoneNets( NETLIST& aNetlist )
if( !updatedNetname.IsEmpty() ) if( !updatedNetname.IsEmpty() )
{ {
msg.Printf( _( "Reconnect copper zone from %s to %s." ), if( m_isDryRun )
UnescapeString( zone->GetNetname() ), {
UnescapeString( updatedNetname ) ); if( !zone->GetZoneName().IsEmpty() )
m_reporter->Report( msg, RPT_SEVERITY_ACTION ); {
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." ),
UnescapeString( zone->GetNetname() ),
UnescapeString( updatedNetname ) );
}
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,10 +784,11 @@ 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 );
} );
for( PAD* pad : padlist ) for( PAD* pad : padlist )
{ {
@ -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
{ {
msg.Printf( _( "Remove single pad net %s." ), if( m_isDryRun )
UnescapeString( getNetname( previouspad ) ) ); {
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
if( !m_isDryRun )
previouspad->SetNetCode( NETINFO_LIST::UNCONNECTED );
else
cacheNetname( previouspad, wxEmptyString ); cacheNetname( previouspad, wxEmptyString );
msg.Printf( _( "Remove single pad net %s." ),
UnescapeString( getNetname( previouspad ) ) );
}
else
{
previouspad->SetNetCode( NETINFO_LIST::UNCONNECTED );
msg.Printf( _( "Removed single pad net %s." ),
UnescapeString( getNetname( previouspad ) ) );
}
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
} }
} }
@ -894,19 +1036,34 @@ bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist )
if( doDelete && footprint->IsLocked() ) if( doDelete && footprint->IsLocked() )
{ {
msg.Printf( _( "Cannot remove unused footprint %s (locked)." ), if( m_isDryRun )
footprint->GetReference() ); {
msg.Printf( _( "Cannot remove unused footprint %s (locked)." ),
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 )
{ {
msg.Printf( _( "Remove unused footprint %s." ), footprint->GetReference() ); if( m_isDryRun )
m_reporter->Report( msg, RPT_SEVERITY_ACTION ); {
msg.Printf( _( "Remove unused footprint %s." ), footprint->GetReference() );
if( !m_isDryRun ) }
else
{
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 );
} }