Code formatting (BOARD_NETLIST_UPDATER)
This commit is contained in:
parent
029e275aa0
commit
267f01fa69
|
@ -66,11 +66,13 @@ BOARD_NETLIST_UPDATER::BOARD_NETLIST_UPDATER ( PCB_EDIT_FRAME *aFrame, BOARD *aB
|
|||
m_errorCount = 0;
|
||||
}
|
||||
|
||||
|
||||
BOARD_NETLIST_UPDATER::~BOARD_NETLIST_UPDATER()
|
||||
{
|
||||
delete m_undoList;
|
||||
}
|
||||
|
||||
|
||||
void BOARD_NETLIST_UPDATER::pushUndo( BOARD_ITEM* aItem, UNDO_REDO_T aCommandType, BOARD_ITEM* aCopy )
|
||||
{
|
||||
ITEM_PICKER picker( aItem, aCommandType );
|
||||
|
@ -86,6 +88,7 @@ void BOARD_NETLIST_UPDATER::pushUndo( BOARD_ITEM* aItem, UNDO_REDO_T aCommandTyp
|
|||
m_undoList->PushItem( picker );
|
||||
}
|
||||
|
||||
|
||||
wxPoint BOARD_NETLIST_UPDATER::estimateComponentInsertionPosition()
|
||||
{
|
||||
wxPoint bestPosition;
|
||||
|
@ -124,13 +127,11 @@ MODULE* BOARD_NETLIST_UPDATER::addNewComponent( COMPONENT* aComponent )
|
|||
GetChars( aComponent->GetReference() ),
|
||||
GetChars( aComponent->GetTimeStamp() ),
|
||||
GetChars( aComponent->GetFPID().Format() ) );
|
||||
|
||||
m_reporter->Report( msg, REPORTER::RPT_INFO );
|
||||
|
||||
msg.Printf( _( "Add component %s, footprint: %s.\n" ),
|
||||
GetChars( aComponent->GetReference() ),
|
||||
GetChars( aComponent->GetFPID().Format() ) );
|
||||
|
||||
m_reporter->Report( msg, REPORTER::RPT_ACTION );
|
||||
|
||||
|
||||
|
@ -165,13 +166,13 @@ MODULE* BOARD_NETLIST_UPDATER::addNewComponent( COMPONENT* aComponent )
|
|||
GetChars( aComponent->GetFPID().Format() ) );
|
||||
|
||||
m_reporter->Report( msg, REPORTER::RPT_INFO );
|
||||
|
||||
m_errorCount ++;
|
||||
++m_errorCount;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
MODULE* BOARD_NETLIST_UPDATER::replaceComponent( NETLIST& aNetlist, MODULE* aPcbComponent, COMPONENT* aNewComponent )
|
||||
{
|
||||
wxString msg;
|
||||
|
@ -180,8 +181,7 @@ MODULE* BOARD_NETLIST_UPDATER::replaceComponent( NETLIST& aNetlist, MODULE *aPcb
|
|||
return NULL;
|
||||
|
||||
// Test if the footprint has not changed
|
||||
if( aNewComponent->GetFPID().empty() ||
|
||||
aPcbComponent->GetFPID() == aNewComponent->GetFPID() )
|
||||
if( aNewComponent->GetFPID().empty() || aPcbComponent->GetFPID() == aNewComponent->GetFPID() )
|
||||
return NULL;
|
||||
|
||||
if( aNewComponent->GetModule() != NULL )
|
||||
|
@ -221,8 +221,9 @@ MODULE* BOARD_NETLIST_UPDATER::replaceComponent( NETLIST& aNetlist, MODULE *aPcb
|
|||
|
||||
return newFootprint;
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
msg.Printf( _( "Cannot change component %s footprint due to missing "
|
||||
"footprint %s.\n" ),
|
||||
GetChars( aPcbComponent->GetReference() ),
|
||||
|
@ -238,12 +239,13 @@ MODULE* BOARD_NETLIST_UPDATER::replaceComponent( NETLIST& aNetlist, MODULE *aPcb
|
|||
|
||||
m_reporter->Report( msg, REPORTER::RPT_INFO );
|
||||
|
||||
m_errorCount ++;
|
||||
++m_errorCount;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
bool BOARD_NETLIST_UPDATER::updateComponentParameters( MODULE* aPcbComponent, COMPONENT* aNewComponent )
|
||||
{
|
||||
wxString msg;
|
||||
|
@ -292,6 +294,7 @@ bool BOARD_NETLIST_UPDATER::updateComponentParameters( MODULE *aPcbComponent, CO
|
|||
GetChars( aPcbComponent->GetPath() ),
|
||||
GetChars( aPcbComponent->GetValue() ),
|
||||
GetChars( aNewComponent->GetValue() ) );
|
||||
|
||||
m_reporter->Report( msg, REPORTER::RPT_ACTION );
|
||||
|
||||
if( !m_isDryRun )
|
||||
|
@ -308,6 +311,7 @@ bool BOARD_NETLIST_UPDATER::updateComponentParameters( MODULE *aPcbComponent, CO
|
|||
GetChars( aPcbComponent->GetReference() ),
|
||||
GetChars( aPcbComponent->GetPath() ),
|
||||
GetChars( aNewComponent->GetTimeStamp() ) );
|
||||
|
||||
m_reporter->Report( msg, REPORTER::RPT_INFO );
|
||||
|
||||
if ( !m_isDryRun )
|
||||
|
@ -325,6 +329,7 @@ bool BOARD_NETLIST_UPDATER::updateComponentParameters( MODULE *aPcbComponent, CO
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( MODULE* aPcbComponent, COMPONENT* aNewComponent )
|
||||
{
|
||||
wxString msg;
|
||||
|
@ -351,7 +356,6 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( MODULE *aPcbComponent
|
|||
GetChars( aPcbComponent->GetPath() ),
|
||||
GetChars( pad->GetPadName() ) );
|
||||
m_reporter->Report( msg, REPORTER::RPT_INFO );
|
||||
|
||||
}
|
||||
|
||||
if( !m_isDryRun )
|
||||
|
@ -377,13 +381,12 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( MODULE *aPcbComponent
|
|||
pushUndo( netinfo, UR_NEW );
|
||||
}
|
||||
|
||||
msg.Printf( _( "Add net %s.\n" ),
|
||||
GetChars( net.GetNetName() ) );
|
||||
msg.Printf( _( "Add net %s.\n" ), GetChars( net.GetNetName() ) );
|
||||
|
||||
m_reporter->Report( msg, REPORTER::RPT_ACTION );
|
||||
}
|
||||
|
||||
if( pad->GetNetname() != wxString("") )
|
||||
if( !pad->GetNetname().IsEmpty() )
|
||||
{
|
||||
msg.Printf( _( "Reconnect component %s pin %s from net %s to net %s.\n"),
|
||||
GetChars( aPcbComponent->GetReference() ),
|
||||
|
@ -427,6 +430,7 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( MODULE *aPcbComponent
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool BOARD_NETLIST_UPDATER::deleteUnusedComponents( NETLIST& aNetlist )
|
||||
{
|
||||
wxString msg;
|
||||
|
@ -467,6 +471,7 @@ bool BOARD_NETLIST_UPDATER::deleteUnusedComponents( NETLIST& aNetlist )
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool BOARD_NETLIST_UPDATER::deleteSinglePadNets()
|
||||
{
|
||||
int count = 0;
|
||||
|
@ -520,7 +525,6 @@ bool BOARD_NETLIST_UPDATER::deleteSinglePadNets()
|
|||
{
|
||||
msg.Printf( _( "Remove single pad net %s." ),
|
||||
GetChars( previouspad->GetNetname() ) );
|
||||
|
||||
m_reporter->Report( msg, REPORTER::RPT_ACTION );
|
||||
|
||||
msg.Printf( _( "Remove single pad net \"%s\" on \"%s\" pad '%s'\n" ),
|
||||
|
@ -554,6 +558,7 @@ bool BOARD_NETLIST_UPDATER::deleteSinglePadNets()
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool BOARD_NETLIST_UPDATER::testConnectivity( NETLIST& aNetlist )
|
||||
{
|
||||
// Last step: Some tests:
|
||||
|
@ -592,7 +597,7 @@ bool BOARD_NETLIST_UPDATER::testConnectivity( NETLIST& aNetlist )
|
|||
GetChars( padname ),
|
||||
GetChars( footprint->GetFPID().Format() ) );
|
||||
m_reporter->Report( msg, REPORTER::RPT_ERROR );
|
||||
m_errorCount ++;
|
||||
++m_errorCount;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -611,13 +616,14 @@ bool BOARD_NETLIST_UPDATER::testConnectivity( NETLIST& aNetlist )
|
|||
msg.Printf( _( "Copper zone (net name %s): net has no pads connected." ),
|
||||
GetChars( zone->GetNet()->GetNetname() ) );
|
||||
m_reporter->Report( msg, REPORTER::RPT_WARNING );
|
||||
m_warningCount ++;
|
||||
++m_warningCount;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist )
|
||||
{
|
||||
wxString msg;
|
||||
|
@ -630,7 +636,6 @@ bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist )
|
|||
m_board->SetStatus( 0 );
|
||||
}
|
||||
|
||||
|
||||
for( int i = 0; i < (int) aNetlist.GetCount(); i++ )
|
||||
{
|
||||
COMPONENT* component = aNetlist.GetComponent( i );
|
||||
|
@ -640,7 +645,6 @@ bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist )
|
|||
GetChars( component->GetReference() ),
|
||||
GetChars( component->GetTimeStamp() ),
|
||||
GetChars( component->GetFPID().Format() ) );
|
||||
|
||||
m_reporter->Report( msg, REPORTER::RPT_INFO );
|
||||
|
||||
if( aNetlist.IsFindByTimeStamp() )
|
||||
|
@ -651,6 +655,7 @@ bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist )
|
|||
if( footprint ) // An existing footprint.
|
||||
{
|
||||
MODULE* newFootprint = replaceComponent( aNetlist, footprint, component );
|
||||
|
||||
if( newFootprint )
|
||||
footprint = newFootprint;
|
||||
}
|
||||
|
@ -666,9 +671,6 @@ bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist )
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//aNetlist.GetDeleteExtraFootprints()
|
||||
|
||||
if( m_deleteUnusedComponents )
|
||||
|
@ -689,33 +691,29 @@ bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist )
|
|||
}
|
||||
|
||||
// Update the ratsnest
|
||||
|
||||
m_reporter->Report( wxT( "" ), REPORTER::RPT_ACTION );
|
||||
m_reporter->Report( wxT( "" ), REPORTER::RPT_ACTION );
|
||||
|
||||
msg.Printf( _( "Total warnings: %d, errors: %d." ),
|
||||
m_warningCount, m_errorCount );
|
||||
|
||||
msg.Printf( _( "Total warnings: %d, errors: %d." ), m_warningCount, m_errorCount );
|
||||
m_reporter->Report( msg, REPORTER::RPT_ACTION );
|
||||
|
||||
|
||||
if( m_errorCount )
|
||||
{
|
||||
|
||||
m_reporter->Report( _( "Errors occured during the netlist update. Unless you "
|
||||
"fix them, your board will not be consistent with the schematics." ),
|
||||
REPORTER::RPT_ERROR );
|
||||
|
||||
return false;
|
||||
} else {
|
||||
m_reporter->Report( _("Netlist update successful!" ),
|
||||
REPORTER::RPT_ACTION );
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
m_reporter->Report( _( "Netlist update successful!" ), REPORTER::RPT_ACTION );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool BOARD_NETLIST_UPDATER::UpdateNetlist( const wxString& aNetlistFileName,
|
||||
const wxString& aCmpFileName )
|
||||
{
|
||||
|
|
|
@ -72,7 +72,6 @@ class PCB_EDIT_FRAME;
|
|||
class BOARD_NETLIST_UPDATER
|
||||
{
|
||||
public:
|
||||
|
||||
BOARD_NETLIST_UPDATER( PCB_EDIT_FRAME* aFrame, BOARD* aBoard );
|
||||
~BOARD_NETLIST_UPDATER();
|
||||
|
||||
|
@ -87,9 +86,7 @@ public:
|
|||
bool UpdateNetlist( NETLIST& aNetlist );
|
||||
|
||||
// @todo: implement and move NETLIST::ReadPcbNetlist here
|
||||
bool UpdateNetlist( const wxString& aNetlistFileName,
|
||||
const wxString& aCmpFileName );
|
||||
|
||||
bool UpdateNetlist( const wxString& aNetlistFileName, const wxString& aCmpFileName );
|
||||
|
||||
///> Sets the reporter object
|
||||
void SetReporter( REPORTER* aReporter )
|
||||
|
|
|
@ -26,11 +26,12 @@ DIALOG_UPDATE_PCB::DIALOG_UPDATE_PCB( PCB_EDIT_FRAME* aParent, NETLIST *aNetlist
|
|||
m_messagePanel->SetVisibleSeverities( REPORTER::RPT_WARNING | REPORTER::RPT_ERROR | REPORTER::RPT_ACTION );
|
||||
}
|
||||
|
||||
|
||||
DIALOG_UPDATE_PCB::~DIALOG_UPDATE_PCB()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_UPDATE_PCB::PerformUpdate( bool aDryRun )
|
||||
{
|
||||
m_messagePanel->Clear();
|
||||
|
@ -57,7 +58,8 @@ void DIALOG_UPDATE_PCB::PerformUpdate( bool aDryRun )
|
|||
m_netlist->SetFindByTimeStamp( m_matchByTimestamp->GetValue() );
|
||||
m_netlist->SetReplaceFootprints( true );
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
m_frame->LoadFootprints( *m_netlist, &reporter );
|
||||
}
|
||||
catch( IO_ERROR &error )
|
||||
|
@ -70,14 +72,12 @@ void DIALOG_UPDATE_PCB::PerformUpdate( bool aDryRun )
|
|||
}
|
||||
|
||||
BOARD_NETLIST_UPDATER updater( m_frame, m_frame->GetBoard() );
|
||||
|
||||
updater.SetReporter ( &reporter );
|
||||
updater.SetIsDryRun( aDryRun);
|
||||
updater.SetLookupByTimestamp( m_matchByTimestamp->GetValue() );
|
||||
updater.SetDeleteUnusedComponents ( true );
|
||||
updater.SetReplaceFootprints( true );
|
||||
updater.SetDeleteSinglePadNets( false );
|
||||
|
||||
updater.UpdateNetlist( *m_netlist );
|
||||
|
||||
m_messagePanel->Flush();
|
||||
|
@ -103,10 +103,8 @@ void DIALOG_UPDATE_PCB::PerformUpdate( bool aDryRun )
|
|||
board->GetRatsnest()->ProcessBoard();
|
||||
|
||||
m_frame->Compile_Ratsnest( NULL, true );
|
||||
|
||||
m_frame->SetMsgPanel( board );
|
||||
|
||||
|
||||
if( m_frame->IsGalCanvasActive() )
|
||||
{
|
||||
m_frame->SpreadFootprints( &newFootprints, false, false, m_frame->GetCrossHairPosition() );
|
||||
|
@ -117,27 +115,30 @@ void DIALOG_UPDATE_PCB::PerformUpdate( bool aDryRun )
|
|||
{
|
||||
toolManager->RunAction( COMMON_ACTIONS::selectItem, true, footprint );
|
||||
}
|
||||
|
||||
toolManager->InvokeTool( "pcbnew.InteractiveEdit" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
m_btnPerformUpdate->Enable( false );
|
||||
m_btnPerformUpdate->SetLabel( _( "Update complete" ) );
|
||||
m_btnCancel->SetLabel( _("Close") );
|
||||
m_btnCancel->SetFocus();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_UPDATE_PCB::OnMatchChange( wxCommandEvent& event )
|
||||
{
|
||||
PerformUpdate( true );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_UPDATE_PCB::OnCancelClick( wxCommandEvent& event )
|
||||
{
|
||||
EndModal( wxID_CANCEL );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_UPDATE_PCB::OnUpdateClick( wxCommandEvent& event )
|
||||
{
|
||||
m_messagePanel->SetLabel( _( "Changes applied to the PCB:" ) );
|
||||
|
|
Loading…
Reference in New Issue