Example #1
0
bool DIALOG_EXCHANGE_MODULE::change_1_Module( MODULE*            aModule,
                                              const LIB_ID&      aNewFootprintFPID,
                                              bool               aShowError )
{
    MODULE* newModule;
    wxString line;

    if( aModule == NULL )
        return false;

    wxBusyCursor dummy;

    // Copy parameters from the old module.
    LIB_ID oldFootprintFPID = aModule->GetFPID();

    // Load module.
    line.Printf( _( "Change footprint '%s' (from '%s') to '%s'" ),
                 GetChars( aModule->GetReference() ),
                 oldFootprintFPID.Format().c_str(),
                 aNewFootprintFPID.Format().c_str() );
    m_WinMessages->AppendText( line );

    newModule = m_parent->LoadFootprint( aNewFootprintFPID );

    if( newModule == NULL )  // New module not found, redraw the old one.
    {
        m_WinMessages->AppendText( wxT( " No\n" ) );
        return false;
    }

    m_parent->Exchange_Module( aModule, newModule, m_commit );

    if( aModule == m_currentModule )
        m_currentModule = newModule;

    m_WinMessages->AppendText( wxT( " OK\n" ) );

    return true;
}