Code formatting (BOARD_NETLIST_UPDATER)

This commit is contained in:
Maciej Suminski 2016-09-02 15:53:51 +02:00
parent 029e275aa0
commit 267f01fa69
3 changed files with 141 additions and 145 deletions

View File

@ -49,35 +49,37 @@
#include <wxPcbStruct.h> #include <wxPcbStruct.h>
BOARD_NETLIST_UPDATER::BOARD_NETLIST_UPDATER ( PCB_EDIT_FRAME *aFrame, BOARD *aBoard ) : BOARD_NETLIST_UPDATER::BOARD_NETLIST_UPDATER( PCB_EDIT_FRAME* aFrame, BOARD* aBoard ) :
m_frame ( aFrame ), m_frame( aFrame ),
m_board( aBoard ) m_board( aBoard )
{ {
m_reporter = &NULL_REPORTER::GetInstance(); m_reporter = &NULL_REPORTER::GetInstance();
m_undoList = new PICKED_ITEMS_LIST; m_undoList = new PICKED_ITEMS_LIST;
m_deleteSinglePadNets = true; m_deleteSinglePadNets = true;
m_deleteUnusedComponents = false; m_deleteUnusedComponents = false;
m_isDryRun = false; m_isDryRun = false;
m_replaceFootprints = true; m_replaceFootprints = true;
m_lookupByTimestamp = false; m_lookupByTimestamp = false;
m_warningCount = 0; m_warningCount = 0;
m_errorCount = 0; m_errorCount = 0;
} }
BOARD_NETLIST_UPDATER::~BOARD_NETLIST_UPDATER ()
BOARD_NETLIST_UPDATER::~BOARD_NETLIST_UPDATER()
{ {
delete m_undoList; delete m_undoList;
} }
void BOARD_NETLIST_UPDATER::pushUndo( BOARD_ITEM* aItem, UNDO_REDO_T aCommandType, BOARD_ITEM* aCopy ) void BOARD_NETLIST_UPDATER::pushUndo( BOARD_ITEM* aItem, UNDO_REDO_T aCommandType, BOARD_ITEM* aCopy )
{ {
ITEM_PICKER picker( aItem, aCommandType ); ITEM_PICKER picker( aItem, aCommandType );
if( aCommandType == UR_CHANGED ) if( aCommandType == UR_CHANGED )
{ {
if( m_undoList->FindItem ( aItem ) >= 0 ) // add only once if( m_undoList->FindItem( aItem ) >= 0 ) // add only once
return; return;
picker.SetLink( aCopy ? aCopy : aItem->Clone() ); picker.SetLink( aCopy ? aCopy : aItem->Clone() );
@ -86,6 +88,7 @@ void BOARD_NETLIST_UPDATER::pushUndo( BOARD_ITEM* aItem, UNDO_REDO_T aCommandTyp
m_undoList->PushItem( picker ); m_undoList->PushItem( picker );
} }
wxPoint BOARD_NETLIST_UPDATER::estimateComponentInsertionPosition() wxPoint BOARD_NETLIST_UPDATER::estimateComponentInsertionPosition()
{ {
wxPoint bestPosition; wxPoint bestPosition;
@ -124,20 +127,18 @@ MODULE* BOARD_NETLIST_UPDATER::addNewComponent( COMPONENT* aComponent )
GetChars( aComponent->GetReference() ), GetChars( aComponent->GetReference() ),
GetChars( aComponent->GetTimeStamp() ), GetChars( aComponent->GetTimeStamp() ),
GetChars( aComponent->GetFPID().Format() ) ); GetChars( aComponent->GetFPID().Format() ) );
m_reporter->Report( msg, REPORTER::RPT_INFO ); m_reporter->Report( msg, REPORTER::RPT_INFO );
msg.Printf( _( "Add component %s, footprint: %s.\n" ), msg.Printf( _( "Add component %s, footprint: %s.\n" ),
GetChars( aComponent->GetReference() ), GetChars( aComponent->GetReference() ),
GetChars( aComponent->GetFPID().Format() ) ); GetChars( aComponent->GetFPID().Format() ) );
m_reporter->Report( msg, REPORTER::RPT_ACTION ); m_reporter->Report( msg, REPORTER::RPT_ACTION );
if( !m_isDryRun ) if( !m_isDryRun )
{ {
// Owned by NETLIST, can only copy it. // Owned by NETLIST, can only copy it.
MODULE *footprint = new MODULE( *aComponent->GetModule() ); MODULE* footprint = new MODULE( *aComponent->GetModule() );
footprint->SetParent( m_board ); footprint->SetParent( m_board );
footprint->SetPosition( estimateComponentInsertionPosition( ) ); footprint->SetPosition( estimateComponentInsertionPosition( ) );
footprint->SetTimeStamp( GetNewTimeStamp() ); footprint->SetTimeStamp( GetNewTimeStamp() );
@ -165,23 +166,22 @@ MODULE* BOARD_NETLIST_UPDATER::addNewComponent( COMPONENT* aComponent )
GetChars( aComponent->GetFPID().Format() ) ); GetChars( aComponent->GetFPID().Format() ) );
m_reporter->Report( msg, REPORTER::RPT_INFO ); m_reporter->Report( msg, REPORTER::RPT_INFO );
++m_errorCount;
m_errorCount ++;
} }
return NULL; return NULL;
} }
MODULE* BOARD_NETLIST_UPDATER::replaceComponent( NETLIST& aNetlist, MODULE *aPcbComponent, COMPONENT* aNewComponent )
MODULE* BOARD_NETLIST_UPDATER::replaceComponent( NETLIST& aNetlist, MODULE* aPcbComponent, COMPONENT* aNewComponent )
{ {
wxString msg; wxString msg;
if( !m_replaceFootprints ) if( !m_replaceFootprints )
return NULL; return NULL;
// Test if the footprint has not changed // Test if the footprint has not changed
if( aNewComponent->GetFPID().empty() || if( aNewComponent->GetFPID().empty() || aPcbComponent->GetFPID() == aNewComponent->GetFPID() )
aPcbComponent->GetFPID() == aNewComponent->GetFPID() )
return NULL; return NULL;
if( aNewComponent->GetModule() != NULL ) if( aNewComponent->GetModule() != NULL )
@ -221,8 +221,9 @@ MODULE* BOARD_NETLIST_UPDATER::replaceComponent( NETLIST& aNetlist, MODULE *aPcb
return newFootprint; return newFootprint;
} }
} else { }
else
{
msg.Printf( _( "Cannot change component %s footprint due to missing " msg.Printf( _( "Cannot change component %s footprint due to missing "
"footprint %s.\n" ), "footprint %s.\n" ),
GetChars( aPcbComponent->GetReference() ), GetChars( aPcbComponent->GetReference() ),
@ -238,13 +239,14 @@ MODULE* BOARD_NETLIST_UPDATER::replaceComponent( NETLIST& aNetlist, MODULE *aPcb
m_reporter->Report( msg, REPORTER::RPT_INFO ); m_reporter->Report( msg, REPORTER::RPT_INFO );
m_errorCount ++; ++m_errorCount;
} }
return NULL; return NULL;
} }
bool BOARD_NETLIST_UPDATER::updateComponentParameters( MODULE *aPcbComponent, COMPONENT* aNewComponent )
bool BOARD_NETLIST_UPDATER::updateComponentParameters( MODULE* aPcbComponent, COMPONENT* aNewComponent )
{ {
wxString msg; wxString msg;
@ -292,9 +294,10 @@ bool BOARD_NETLIST_UPDATER::updateComponentParameters( MODULE *aPcbComponent, CO
GetChars( aPcbComponent->GetPath() ), GetChars( aPcbComponent->GetPath() ),
GetChars( aPcbComponent->GetValue() ), GetChars( aPcbComponent->GetValue() ),
GetChars( aNewComponent->GetValue() ) ); GetChars( aNewComponent->GetValue() ) );
m_reporter->Report( msg, REPORTER::RPT_ACTION ); m_reporter->Report( msg, REPORTER::RPT_ACTION );
if ( !m_isDryRun ) if( !m_isDryRun )
{ {
changed = true; changed = true;
aPcbComponent->SetValue( aNewComponent->GetValue() ); aPcbComponent->SetValue( aNewComponent->GetValue() );
@ -308,6 +311,7 @@ bool BOARD_NETLIST_UPDATER::updateComponentParameters( MODULE *aPcbComponent, CO
GetChars( aPcbComponent->GetReference() ), GetChars( aPcbComponent->GetReference() ),
GetChars( aPcbComponent->GetPath() ), GetChars( aPcbComponent->GetPath() ),
GetChars( aNewComponent->GetTimeStamp() ) ); GetChars( aNewComponent->GetTimeStamp() ) );
m_reporter->Report( msg, REPORTER::RPT_INFO ); m_reporter->Report( msg, REPORTER::RPT_INFO );
if ( !m_isDryRun ) if ( !m_isDryRun )
@ -325,7 +329,8 @@ bool BOARD_NETLIST_UPDATER::updateComponentParameters( MODULE *aPcbComponent, CO
return true; return true;
} }
bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( MODULE *aPcbComponent, COMPONENT* aNewComponent )
bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( MODULE* aPcbComponent, COMPONENT* aNewComponent )
{ {
wxString msg; wxString msg;
@ -333,7 +338,7 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( MODULE *aPcbComponent
MODULE* copy = (MODULE*) aPcbComponent->Clone(); MODULE* copy = (MODULE*) aPcbComponent->Clone();
// At this point, the component footprint is updated. Now update the nets. // At this point, the component footprint is updated. Now update the nets.
for( D_PAD *pad = aPcbComponent->Pads(); pad; pad = pad->Next() ) for( D_PAD* pad = aPcbComponent->Pads(); pad; pad = pad->Next() )
{ {
COMPONENT_NET net = aNewComponent->GetNet( pad->GetPadName() ); COMPONENT_NET net = aNewComponent->GetNet( pad->GetPadName() );
@ -351,7 +356,6 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( MODULE *aPcbComponent
GetChars( aPcbComponent->GetPath() ), GetChars( aPcbComponent->GetPath() ),
GetChars( pad->GetPadName() ) ); GetChars( pad->GetPadName() ) );
m_reporter->Report( msg, REPORTER::RPT_INFO ); m_reporter->Report( msg, REPORTER::RPT_INFO );
} }
if( !m_isDryRun ) if( !m_isDryRun )
@ -377,13 +381,12 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( MODULE *aPcbComponent
pushUndo( netinfo, UR_NEW ); pushUndo( netinfo, UR_NEW );
} }
msg.Printf( _( "Add net %s.\n" ), msg.Printf( _( "Add net %s.\n" ), GetChars( net.GetNetName() ) );
GetChars( net.GetNetName() ) );
m_reporter->Report( msg, REPORTER::RPT_ACTION ); 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"), msg.Printf( _( "Reconnect component %s pin %s from net %s to net %s.\n"),
GetChars( aPcbComponent->GetReference() ), GetChars( aPcbComponent->GetReference() ),
@ -410,7 +413,7 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( MODULE *aPcbComponent
m_reporter->Report( msg, REPORTER::RPT_INFO ); m_reporter->Report( msg, REPORTER::RPT_INFO );
if ( !m_isDryRun ) if( !m_isDryRun )
{ {
changed = true; changed = true;
pad->SetNetCode( netinfo->GetNet() ); pad->SetNetCode( netinfo->GetNet() );
@ -427,6 +430,7 @@ bool BOARD_NETLIST_UPDATER::updateComponentPadConnections( MODULE *aPcbComponent
return true; return true;
} }
bool BOARD_NETLIST_UPDATER::deleteUnusedComponents( NETLIST& aNetlist ) bool BOARD_NETLIST_UPDATER::deleteUnusedComponents( NETLIST& aNetlist )
{ {
wxString msg; wxString msg;
@ -467,6 +471,7 @@ bool BOARD_NETLIST_UPDATER::deleteUnusedComponents( NETLIST& aNetlist )
return true; return true;
} }
bool BOARD_NETLIST_UPDATER::deleteSinglePadNets() bool BOARD_NETLIST_UPDATER::deleteSinglePadNets()
{ {
int count = 0; int count = 0;
@ -520,7 +525,6 @@ bool BOARD_NETLIST_UPDATER::deleteSinglePadNets()
{ {
msg.Printf( _( "Remove single pad net %s." ), msg.Printf( _( "Remove single pad net %s." ),
GetChars( previouspad->GetNetname() ) ); GetChars( previouspad->GetNetname() ) );
m_reporter->Report( msg, REPORTER::RPT_ACTION ); m_reporter->Report( msg, REPORTER::RPT_ACTION );
msg.Printf( _( "Remove single pad net \"%s\" on \"%s\" pad '%s'\n" ), msg.Printf( _( "Remove single pad net \"%s\" on \"%s\" pad '%s'\n" ),
@ -554,6 +558,7 @@ bool BOARD_NETLIST_UPDATER::deleteSinglePadNets()
return true; return true;
} }
bool BOARD_NETLIST_UPDATER::testConnectivity( NETLIST& aNetlist ) bool BOARD_NETLIST_UPDATER::testConnectivity( NETLIST& aNetlist )
{ {
// Last step: Some tests: // Last step: Some tests:
@ -592,7 +597,7 @@ bool BOARD_NETLIST_UPDATER::testConnectivity( NETLIST& aNetlist )
GetChars( padname ), GetChars( padname ),
GetChars( footprint->GetFPID().Format() ) ); GetChars( footprint->GetFPID().Format() ) );
m_reporter->Report( msg, REPORTER::RPT_ERROR ); 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." ), msg.Printf( _( "Copper zone (net name %s): net has no pads connected." ),
GetChars( zone->GetNet()->GetNetname() ) ); GetChars( zone->GetNet()->GetNetname() ) );
m_reporter->Report( msg, REPORTER::RPT_WARNING ); m_reporter->Report( msg, REPORTER::RPT_WARNING );
m_warningCount ++; ++m_warningCount;
} }
} }
return true; return true;
} }
bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist ) bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist )
{ {
wxString msg; wxString msg;
@ -630,17 +636,15 @@ bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist )
m_board->SetStatus( 0 ); m_board->SetStatus( 0 );
} }
for( int i = 0; i < (int) aNetlist.GetCount(); i++ ) for( int i = 0; i < (int) aNetlist.GetCount(); i++ )
{ {
COMPONENT* component = aNetlist.GetComponent( i ); COMPONENT* component = aNetlist.GetComponent( i );
MODULE *footprint = NULL; MODULE* footprint = NULL;
msg.Printf( _( "Processing component \"%s:%s:%s\".\n" ), msg.Printf( _( "Processing component \"%s:%s:%s\".\n" ),
GetChars( component->GetReference() ), GetChars( component->GetReference() ),
GetChars( component->GetTimeStamp() ), GetChars( component->GetTimeStamp() ),
GetChars( component->GetFPID().Format() ) ); GetChars( component->GetFPID().Format() ) );
m_reporter->Report( msg, REPORTER::RPT_INFO ); m_reporter->Report( msg, REPORTER::RPT_INFO );
if( aNetlist.IsFindByTimeStamp() ) if( aNetlist.IsFindByTimeStamp() )
@ -650,8 +654,9 @@ bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist )
if( footprint ) // An existing footprint. if( footprint ) // An existing footprint.
{ {
MODULE *newFootprint = replaceComponent ( aNetlist, footprint, component ); MODULE* newFootprint = replaceComponent( aNetlist, footprint, component );
if ( newFootprint )
if( newFootprint )
footprint = newFootprint; footprint = newFootprint;
} }
else else
@ -666,9 +671,6 @@ bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist )
} }
} }
//aNetlist.GetDeleteExtraFootprints() //aNetlist.GetDeleteExtraFootprints()
if( m_deleteUnusedComponents ) if( m_deleteUnusedComponents )
@ -679,7 +681,7 @@ bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist )
if ( !m_isDryRun ) if ( !m_isDryRun )
{ {
m_frame->SaveCopyInUndoList( *m_undoList, UR_UNSPECIFIED, wxPoint(0, 0) ); m_frame->SaveCopyInUndoList( *m_undoList, UR_UNSPECIFIED, wxPoint( 0, 0 ) );
m_frame->OnModify(); m_frame->OnModify();
m_frame->Compile_Ratsnest( NULL, true ); m_frame->Compile_Ratsnest( NULL, true );
@ -689,35 +691,31 @@ bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist )
} }
// Update the ratsnest // Update the ratsnest
m_reporter->Report( wxT( "" ), REPORTER::RPT_ACTION );
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 );
m_reporter->Report( wxT(""), REPORTER::RPT_ACTION );
msg.Printf( _( "Total warnings: %d, errors: %d." ),
m_warningCount, m_errorCount );
m_reporter->Report( msg, REPORTER::RPT_ACTION ); m_reporter->Report( msg, REPORTER::RPT_ACTION );
if( m_errorCount )
if ( m_errorCount )
{ {
m_reporter->Report( _( "Errors occured during the netlist update. Unless you "
m_reporter->Report( _("Errors occured during the netlist update. Unless you " "fix them, your board will not be consistent with the schematics." ),
"fix them, your board will not be consistent with the schematics." ),
REPORTER::RPT_ERROR ); REPORTER::RPT_ERROR );
return false; return false;
} else { }
m_reporter->Report( _("Netlist update successful!" ), else
REPORTER::RPT_ACTION ); {
m_reporter->Report( _( "Netlist update successful!" ), REPORTER::RPT_ACTION );
} }
return true; return true;
} }
bool BOARD_NETLIST_UPDATER::UpdateNetlist( const wxString& aNetlistFileName, bool BOARD_NETLIST_UPDATER::UpdateNetlist( const wxString& aNetlistFileName,
const wxString& aCmpFileName ) const wxString& aCmpFileName )
{ {
return false; return false;
} }

View File

@ -72,94 +72,91 @@ class PCB_EDIT_FRAME;
class BOARD_NETLIST_UPDATER class BOARD_NETLIST_UPDATER
{ {
public: public:
BOARD_NETLIST_UPDATER( PCB_EDIT_FRAME* aFrame, BOARD* aBoard );
~BOARD_NETLIST_UPDATER();
BOARD_NETLIST_UPDATER( PCB_EDIT_FRAME *aFrame, BOARD *aBoard ); /**
~BOARD_NETLIST_UPDATER(); * Function UpdateNetlist()
*
* Updates the board's components according to the new netlist.
* See BOARD_NETLIST_UPDATER class description for the details of the process.
* @param aNetlist the new netlist
* @return true if process was completed successfully
*/
bool UpdateNetlist( NETLIST& aNetlist );
/** // @todo: implement and move NETLIST::ReadPcbNetlist here
* Function UpdateNetlist() bool UpdateNetlist( const wxString& aNetlistFileName, const wxString& aCmpFileName );
*
* Updates the board's components according to the new netlist.
* See BOARD_NETLIST_UPDATER class description for the details of the process.
* @param aNetlist the new netlist
* @return true if process was completed successfully
*/
bool UpdateNetlist( NETLIST& aNetlist );
// @todo: implement and move NETLIST::ReadPcbNetlist here ///> Sets the reporter object
bool UpdateNetlist( const wxString& aNetlistFileName, void SetReporter( REPORTER* aReporter )
const wxString& aCmpFileName ); {
m_reporter = aReporter;
}
///> Enables "delete single pad nets" option
void SetDeleteSinglePadNets( bool aEnabled )
{
m_deleteSinglePadNets = aEnabled;
}
///> Sets the reporter object ///> Enables dry run mode (just report, no changes to PCB)
void SetReporter ( REPORTER *aReporter ) void SetIsDryRun( bool aEnabled )
{ {
m_reporter = aReporter; m_isDryRun = aEnabled;
} }
///> Enables "delete single pad nets" option ///> Enables replacing footprints with new ones
void SetDeleteSinglePadNets( bool aEnabled ) void SetReplaceFootprints( bool aEnabled )
{ {
m_deleteSinglePadNets = aEnabled; m_replaceFootprints = aEnabled;
} }
///> Enables dry run mode (just report, no changes to PCB) ///> Enables removing unused components
void SetIsDryRun ( bool aEnabled ) void SetDeleteUnusedComponents( bool aEnabled )
{ {
m_isDryRun = aEnabled; m_deleteUnusedComponents = aEnabled;
} }
///> Enables replacing footprints with new ones ///> Enables component lookup by timestamp instead of reference
void SetReplaceFootprints ( bool aEnabled ) void SetLookupByTimestamp( bool aEnabled )
{ {
m_replaceFootprints = aEnabled; m_lookupByTimestamp = aEnabled;
} }
///> Enables removing unused components std::vector<MODULE*> GetAddedComponents() const
void SetDeleteUnusedComponents ( bool aEnabled ) {
{ return m_addedComponents;
m_deleteUnusedComponents = aEnabled; }
}
///> Enables component lookup by timestamp instead of reference
void SetLookupByTimestamp ( bool aEnabled )
{
m_lookupByTimestamp = aEnabled;
}
std::vector<MODULE*> GetAddedComponents() const
{
return m_addedComponents;
}
private: private:
void pushUndo( BOARD_ITEM* aItem, UNDO_REDO_T aCommandType, BOARD_ITEM* aCopy = NULL ); void pushUndo( BOARD_ITEM* aItem, UNDO_REDO_T aCommandType, BOARD_ITEM* aCopy = NULL );
wxPoint estimateComponentInsertionPosition(); wxPoint estimateComponentInsertionPosition();
MODULE* addNewComponent( COMPONENT* aComponent ); MODULE* addNewComponent( COMPONENT* aComponent );
MODULE* replaceComponent( NETLIST& aNetlist, MODULE *aPcbComponent, COMPONENT* aNewComponent ); MODULE* replaceComponent( NETLIST& aNetlist, MODULE* aPcbComponent, COMPONENT* aNewComponent );
bool updateComponentParameters( MODULE *aPcbComponent, COMPONENT* aNewComponent ); bool updateComponentParameters( MODULE* aPcbComponent, COMPONENT* aNewComponent );
bool updateComponentPadConnections( MODULE *aPcbComponent, COMPONENT* aNewComponent ); bool updateComponentPadConnections( MODULE* aPcbComponent, COMPONENT* aNewComponent );
bool deleteUnusedComponents( NETLIST& aNetlist ); bool deleteUnusedComponents( NETLIST& aNetlist );
bool deleteSinglePadNets(); bool deleteSinglePadNets();
bool testConnectivity( NETLIST& aNetlist ); bool testConnectivity( NETLIST& aNetlist );
PICKED_ITEMS_LIST *m_undoList; PICKED_ITEMS_LIST* m_undoList;
PCB_EDIT_FRAME *m_frame; PCB_EDIT_FRAME* m_frame;
BOARD *m_board; BOARD* m_board;
REPORTER *m_reporter; REPORTER* m_reporter;
std::vector<MODULE*> m_addedComponents; std::vector<MODULE*> m_addedComponents;
bool m_deleteSinglePadNets; bool m_deleteSinglePadNets;
bool m_deleteUnusedComponents; bool m_deleteUnusedComponents;
bool m_isDryRun; bool m_isDryRun;
bool m_replaceFootprints; bool m_replaceFootprints;
bool m_lookupByTimestamp; bool m_lookupByTimestamp;
int m_warningCount; int m_warningCount;
int m_errorCount; int m_errorCount;
}; };
#endif #endif

View File

@ -19,26 +19,27 @@ DIALOG_UPDATE_PCB::DIALOG_UPDATE_PCB( PCB_EDIT_FRAME* aParent, NETLIST *aNetlist
m_netlist (aNetlist) m_netlist (aNetlist)
{ {
m_messagePanel->SetLabel( _("Changes to be applied:") ); m_messagePanel->SetLabel( _("Changes to be applied:") );
m_messagePanel->SetLazyUpdate ( true ); m_messagePanel->SetLazyUpdate( true );
m_netlist->SortByReference(); m_netlist->SortByReference();
m_btnPerformUpdate->SetFocus(); m_btnPerformUpdate->SetFocus();
m_messagePanel->SetVisibleSeverities( REPORTER::RPT_WARNING | REPORTER::RPT_ERROR | REPORTER::RPT_ACTION ); m_messagePanel->SetVisibleSeverities( REPORTER::RPT_WARNING | REPORTER::RPT_ERROR | REPORTER::RPT_ACTION );
} }
DIALOG_UPDATE_PCB::~DIALOG_UPDATE_PCB() DIALOG_UPDATE_PCB::~DIALOG_UPDATE_PCB()
{ {
} }
void DIALOG_UPDATE_PCB::PerformUpdate( bool aDryRun ) void DIALOG_UPDATE_PCB::PerformUpdate( bool aDryRun )
{ {
m_messagePanel->Clear(); m_messagePanel->Clear();
REPORTER &reporter = m_messagePanel->Reporter(); REPORTER &reporter = m_messagePanel->Reporter();
KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView(); KIGFX::VIEW* view = m_frame->GetGalCanvas()->GetView();
TOOL_MANAGER *toolManager = m_frame->GetToolManager(); TOOL_MANAGER* toolManager = m_frame->GetToolManager();
BOARD *board = m_frame->GetBoard(); BOARD* board = m_frame->GetBoard();
if( !aDryRun ) if( !aDryRun )
{ {
@ -57,7 +58,8 @@ void DIALOG_UPDATE_PCB::PerformUpdate( bool aDryRun )
m_netlist->SetFindByTimeStamp( m_matchByTimestamp->GetValue() ); m_netlist->SetFindByTimeStamp( m_matchByTimestamp->GetValue() );
m_netlist->SetReplaceFootprints( true ); m_netlist->SetReplaceFootprints( true );
try { try
{
m_frame->LoadFootprints( *m_netlist, &reporter ); m_frame->LoadFootprints( *m_netlist, &reporter );
} }
catch( IO_ERROR &error ) catch( IO_ERROR &error )
@ -70,14 +72,12 @@ void DIALOG_UPDATE_PCB::PerformUpdate( bool aDryRun )
} }
BOARD_NETLIST_UPDATER updater( m_frame, m_frame->GetBoard() ); BOARD_NETLIST_UPDATER updater( m_frame, m_frame->GetBoard() );
updater.SetReporter ( &reporter ); updater.SetReporter ( &reporter );
updater.SetIsDryRun( aDryRun); updater.SetIsDryRun( aDryRun);
updater.SetLookupByTimestamp( m_matchByTimestamp->GetValue() ); updater.SetLookupByTimestamp( m_matchByTimestamp->GetValue() );
updater.SetDeleteUnusedComponents ( true ); updater.SetDeleteUnusedComponents ( true );
updater.SetReplaceFootprints( true ); updater.SetReplaceFootprints( true );
updater.SetDeleteSinglePadNets ( false ); updater.SetDeleteSinglePadNets( false );
updater.UpdateNetlist( *m_netlist ); updater.UpdateNetlist( *m_netlist );
m_messagePanel->Flush(); m_messagePanel->Flush();
@ -103,10 +103,8 @@ void DIALOG_UPDATE_PCB::PerformUpdate( bool aDryRun )
board->GetRatsnest()->ProcessBoard(); board->GetRatsnest()->ProcessBoard();
m_frame->Compile_Ratsnest( NULL, true ); m_frame->Compile_Ratsnest( NULL, true );
m_frame->SetMsgPanel( board ); m_frame->SetMsgPanel( board );
if( m_frame->IsGalCanvasActive() ) if( m_frame->IsGalCanvasActive() )
{ {
m_frame->SpreadFootprints( &newFootprints, false, false, m_frame->GetCrossHairPosition() ); m_frame->SpreadFootprints( &newFootprints, false, false, m_frame->GetCrossHairPosition() );
@ -117,30 +115,33 @@ void DIALOG_UPDATE_PCB::PerformUpdate( bool aDryRun )
{ {
toolManager->RunAction( COMMON_ACTIONS::selectItem, true, footprint ); toolManager->RunAction( COMMON_ACTIONS::selectItem, true, footprint );
} }
toolManager->InvokeTool( "pcbnew.InteractiveEdit" ); toolManager->InvokeTool( "pcbnew.InteractiveEdit" );
} }
} }
m_btnPerformUpdate->Enable( false ); m_btnPerformUpdate->Enable( false );
m_btnPerformUpdate->SetLabel( _( "Update complete" ) ); m_btnPerformUpdate->SetLabel( _( "Update complete" ) );
m_btnCancel->SetLabel ( _("Close") ); m_btnCancel->SetLabel( _("Close") );
m_btnCancel->SetFocus(); m_btnCancel->SetFocus();
} }
void DIALOG_UPDATE_PCB::OnMatchChange( wxCommandEvent& event ) void DIALOG_UPDATE_PCB::OnMatchChange( wxCommandEvent& event )
{ {
PerformUpdate( true ); PerformUpdate( true );
} }
void DIALOG_UPDATE_PCB::OnCancelClick( wxCommandEvent& event ) void DIALOG_UPDATE_PCB::OnCancelClick( wxCommandEvent& event )
{ {
EndModal( wxID_CANCEL ); EndModal( wxID_CANCEL );
} }
void DIALOG_UPDATE_PCB::OnUpdateClick( wxCommandEvent& event ) void DIALOG_UPDATE_PCB::OnUpdateClick( wxCommandEvent& event )
{ {
m_messagePanel->SetLabel( _("Changes applied to the PCB:") ); m_messagePanel->SetLabel( _( "Changes applied to the PCB:" ) );
PerformUpdate( false ); PerformUpdate( false );
m_btnCancel->SetFocus( ); m_btnCancel->SetFocus();
} }