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;
}
if( m_isDryRun )
{
msg.Printf( _( "Add %s (footprint \"%s\")." ),
aComponent->GetReference(),
aComponent->GetFPID().Format().wx_str() );
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
delete footprint;
footprint = nullptr;
}
else
{
for( PAD* pad : footprint->Pads() )
{
// Set the pads ratsnest settings to the global settings
@ -172,24 +178,20 @@ FOOTPRINT* BOARD_NETLIST_UPDATER::addNewComponent( COMPONENT* aComponent )
pad->SetNetCode( 0 );
}
m_newFootprintsCount++;
if( !m_isDryRun )
{
footprint->SetParent( m_board );
footprint->SetPosition( estimateComponentInsertionPosition( ) );
m_addedComponents.push_back( footprint );
m_commit.Add( footprint );
return footprint;
}
else
{
delete footprint;
msg.Printf( _( "Added %s (footprint \"%s\")." ),
aComponent->GetReference(),
aComponent->GetFPID().Format().wx_str() );
}
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;
}
msg.Printf( _( "Change %s footprint from \"%s\" to \"%s\"."),
if( m_isDryRun )
{
msg.Printf( _( "Change %s footprint from '%s' to '%s'."),
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 );
return newFootprint;
delete newFootprint;
newFootprint = nullptr;
}
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.
if( aPcbFootprint->GetReference() != aNetlistComponent->GetReference() )
{
if( m_isDryRun )
{
msg.Printf( _( "Change %s reference designator to %s." ),
aPcbFootprint->GetReference(),
aNetlistComponent->GetReference() );
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
if ( !m_isDryRun )
}
else
{
changed = true;
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.
if( aPcbFootprint->GetValue() != aNetlistComponent->GetValue() )
{
if( m_isDryRun )
{
msg.Printf( _( "Change %s value from %s to %s." ),
aPcbFootprint->GetReference(),
aPcbFootprint->GetValue(),
aNetlistComponent->GetValue() );
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
if( !m_isDryRun )
}
else
{
changed = true;
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.
@ -288,58 +309,85 @@ bool BOARD_NETLIST_UPDATER::updateFootprintParameters( FOOTPRINT* aPcbFootprint,
new_path.push_back( aNetlistComponent->GetKIIDs().front() );
if( aPcbFootprint->GetPath() != new_path )
{
if( m_isDryRun )
{
msg.Printf( _( "Update %s symbol association from %s to %s." ),
aPcbFootprint->GetReference(),
aPcbFootprint->GetPath().AsString(),
new_path.AsString() );
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
if( !m_isDryRun )
}
else
{
changed = true;
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( m_isDryRun )
{
msg.Printf( _( "Update %s properties." ),
aPcbFootprint->GetReference() );
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
if( !m_isDryRun )
}
else
{
changed = true;
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 )
!= ( ( 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();
if( aNetlistComponent->GetProperties().count( "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() );
}
else
{
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() );
}
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
if( !m_isDryRun )
{
changed = true;
aPcbFootprint->SetAttributes( attributes );
}
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
}
if( changed && copy )
@ -395,16 +443,26 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( FOOTPRINT* aFootprint
if( !net.IsValid() || !pad->IsOnCopperLayer() )
{
if( !pad->GetNetname().IsEmpty() )
{
if( m_isDryRun )
{
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 );
}
else if( m_warnForNoNetPads && pad->IsOnCopperLayer() && !pad->GetName().IsEmpty() )
{
// 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(),
pad->GetName() );
m_reporter->Report( msg, RPT_SEVERITY_WARNING);
@ -462,6 +520,8 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( FOOTPRINT* aFootprint
{
m_oldToNewNets[ pad->GetNetname() ] = netName;
if( m_isDryRun )
{
msg.Printf( _( "Reconnect %s pin %s from %s to %s."),
aFootprint->GetReference(),
pad->GetName(),
@ -469,12 +529,33 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( FOOTPRINT* aFootprint
UnescapeString( netName ) );
}
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."),
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 );
if( !m_isDryRun )
@ -483,10 +564,12 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( FOOTPRINT* aFootprint
pad->SetNet( netinfo );
}
else
{
cacheNetname( pad, netName );
}
}
}
}
if( changed && copy )
m_commit.Modified( aFootprint, copy );
@ -541,13 +624,16 @@ bool BOARD_NETLIST_UPDATER::updateCopperZoneNets( NETLIST& aNetlist )
}
if( !updatedNetname.IsEmpty() )
{
if( m_isDryRun )
{
msg.Printf( _( "Reconnect via from %s to %s." ),
UnescapeString( via->GetNetname() ),
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 );
@ -558,6 +644,12 @@ bool BOARD_NETLIST_UPDATER::updateCopperZoneNets( NETLIST& aNetlist )
{
m_commit.Modify( via );
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( 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." ),
UnescapeString( zone->GetNetname() ),
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 );
@ -618,13 +723,43 @@ bool BOARD_NETLIST_UPDATER::updateCopperZoneNets( NETLIST& aNetlist )
{
m_commit.Modify( zone );
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
{
msg.Printf( _( "Copper zone (%s) has no pads connected." ),
UnescapeString( zone->GetNetname() ) );
if( !zone->GetZoneName().IsEmpty() )
{
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_warningCount;
}
@ -649,7 +784,8 @@ bool BOARD_NETLIST_UPDATER::deleteSinglePadNets()
std::vector<PAD*> padlist = m_board->GetPads();
// 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 );
} );
@ -683,14 +819,20 @@ bool BOARD_NETLIST_UPDATER::deleteSinglePadNets()
if( count == 1 ) // Really one pad, and nothing else
{
if( m_isDryRun )
{
cacheNetname( previouspad, wxEmptyString );
msg.Printf( _( "Remove single pad net %s." ),
UnescapeString( getNetname( previouspad ) ) );
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
if( !m_isDryRun )
previouspad->SetNetCode( NETINFO_LIST::UNCONNECTED );
}
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( m_isDryRun )
{
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 );
doDelete = false;
}
if( doDelete )
{
if( m_isDryRun )
{
msg.Printf( _( "Remove unused footprint %s." ), footprint->GetReference() );
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
if( !m_isDryRun )
}
else
{
m_commit.Remove( footprint );
msg.Printf( _( "Removed unused footprint %s." ), footprint->GetReference() );
}
m_reporter->Report( msg, RPT_SEVERITY_ACTION );
}
else if( !m_isDryRun )
{
@ -931,7 +1088,7 @@ bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist )
{
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_commit.Removed( net );
}