Commit 4a9681d5 authored by Wayne Stambaugh's avatar Wayne Stambaugh
Browse files

More post Pcbnew NETLIST_READER change clean up.

* Fix both legacy and s-expression netlist readers when footprints are
  assigned in the netlist.
* Add some helper functions to NETLIST for detecting when footprints are set
  or not set and when they have been changed while loading the .cmp file.
* Rename a few functions to improve their readability.
parent 6b500d60
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -165,7 +165,7 @@ void CVPCB_MAINFRAME::AssocieModule( wxCommandEvent& event )
        bool found = false;
        m_ListCmp->SetSelection( ii++, true );

        if( !component->GetFootprintLibName().IsEmpty() )
        if( !component->GetFootprintName().IsEmpty() )
            continue;

        BOOST_FOREACH( FOOTPRINT_ALIAS& alias, aliases )
+7 −7
Original line number Diff line number Diff line
@@ -344,7 +344,7 @@ void CVPCB_MAINFRAME::ToFirstNA( wxCommandEvent& event )

    for( unsigned jj = 0;  jj < m_netlist.GetCount();  jj++ )
    {
        if( m_netlist.GetComponent( jj )->GetFootprintLibName().IsEmpty() && ii > selection )
        if( m_netlist.GetComponent( jj )->GetFootprintName().IsEmpty() && ii > selection )
        {
            m_ListCmp->SetSelection( ii );
            SendMessageToEESCHEMA();
@@ -374,7 +374,7 @@ void CVPCB_MAINFRAME::ToPreviousNA( wxCommandEvent& event )

    for( unsigned kk = m_netlist.GetCount() - 1;  kk >= 0;  kk-- )
    {
        if( m_netlist.GetComponent( kk )->GetFootprintLibName().IsEmpty() && ii < selection )
        if( m_netlist.GetComponent( kk )->GetFootprintName().IsEmpty() && ii < selection )
        {
            m_ListCmp->SetSelection( ii );
            SendMessageToEESCHEMA();
@@ -414,7 +414,7 @@ void CVPCB_MAINFRAME::DelAssociations( wxCommandEvent& event )

        for( unsigned i = 0;  i < m_netlist.GetCount();  i++ )
        {
            m_netlist.GetComponent( i )->SetFootprintLibName( wxEmptyString );
            m_netlist.GetComponent( i )->SetFootprintName( wxEmptyString );
            SetNewPkg( wxEmptyString );
        }

@@ -568,7 +568,7 @@ void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event )

    if( FindFocus() ==  m_ListCmp )
    {
        wxString module = m_netlist.GetComponent( selection )->GetFootprintLibName();
        wxString module = m_netlist.GetComponent( selection )->GetFootprintName();

        bool found = false;
        for( int ii = 0; ii < m_FootprintList->GetCount(); ii++ )
@@ -788,8 +788,8 @@ int CVPCB_MAINFRAME::ReadSchematicNetlist()
    // not the actual name of the footprint.
    for( unsigned ii = 0; ii < m_netlist.GetCount(); ii++ )
    {
        if( m_netlist.GetComponent( ii )->GetFootprintLibName() == wxT( "$noname" ) )
            m_netlist.GetComponent( ii )->SetFootprintLibName( wxEmptyString );
        if( m_netlist.GetComponent( ii )->GetFootprintName() == wxT( "$noname" ) )
            m_netlist.GetComponent( ii )->SetFootprintName( wxEmptyString );
    }

    // Sort components by reference:
@@ -840,7 +840,7 @@ bool CVPCB_MAINFRAME::WriteComponentLinkFile( const wxString& aFullFileName )
        retval |= fprintf( outputFile, "Reference = %s;\n", TO_UTF8( component->GetReference() ) );
        retval |= fprintf( outputFile, "ValeurCmp = %s;\n", TO_UTF8( component->GetValue() ) );
        retval |= fprintf( outputFile, "IdModule  = %s;\n",
                           TO_UTF8( component->GetFootprintLibName() ) );
                           TO_UTF8( component->GetFootprintName() ) );
        retval |= fprintf( outputFile, "EndCmp\n" );
    }

+1 −1
Original line number Diff line number Diff line
@@ -117,7 +117,7 @@ void CVPCB_MAINFRAME::BuildCmpListBox()
        msg.Printf( CMP_FORMAT, m_ListCmp->GetCount() + 1,
                    GetChars( component->GetReference() ),
                    GetChars( component->GetValue() ),
                    GetChars( component->GetFootprintLibName() ) );
                    GetChars( component->GetFootprintName() ) );
        m_ListCmp->m_ComponentList.Add( msg );
    }

+5 −5
Original line number Diff line number Diff line
@@ -71,16 +71,16 @@ void CVPCB_MAINFRAME::SetNewPkg( const wxString& aFootprintName )

        // Check to see if the component has already a footprint set.

        hasFootprint = !(component->GetFootprintLibName().IsEmpty());
        hasFootprint = !(component->GetFootprintName().IsEmpty());

        component->SetFootprintLibName( aFootprintName );
        component->SetFootprintName( aFootprintName );

        // create the new component description

        description.Printf( CMP_FORMAT, componentIndex + 1,
                            GetChars( component->GetReference() ),
                            GetChars( component->GetValue() ),
                            GetChars( component->GetFootprintLibName() ) );
                            GetChars( component->GetFootprintName() ) );

        // If the component hasn't had a footprint associated with it
        // it now has, so we decrement the count of components without
@@ -135,10 +135,10 @@ bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles()
        msg.Printf( CMP_FORMAT, m_ListCmp->GetCount() + 1,
                    GetChars( component->GetReference() ),
                    GetChars( component->GetValue() ),
                    GetChars( component->GetFootprintLibName() ) );
                    GetChars( component->GetFootprintName() ) );
        m_ListCmp->AppendLine( msg );

        if( component->GetFootprintLibName().IsEmpty() )
        if( component->GetFootprintName().IsEmpty() )
            m_undefinedComponentCnt += 1;
    }

+7 −7
Original line number Diff line number Diff line
@@ -2373,7 +2373,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, REPORTER* aReporter )
            msg.Printf( _( "Checking netlist component footprint \"%s:%s:%s\".\n" ),
                        GetChars( component->GetReference() ),
                        GetChars( component->GetTimeStamp() ),
                        GetChars( component->GetFootprintLibName() ) );
                        GetChars( component->GetFootprintName() ) );
            aReporter->Report( msg );
        }

@@ -2390,13 +2390,13 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, REPORTER* aReporter )
                    msg.Printf( _( "Adding new component \"%s:%s\" footprint \"%s\".\n" ),
                                GetChars( component->GetReference() ),
                                GetChars( component->GetTimeStamp() ),
                                GetChars( component->GetFootprintLibName() ) );
                                GetChars( component->GetFootprintName() ) );
                else
                    msg.Printf( _( "Cannot add new component \"%s:%s\" due to missing "
                                   "footprint \"%s\".\n" ),
                                GetChars( component->GetReference() ),
                                GetChars( component->GetTimeStamp() ),
                                GetChars( component->GetFootprintLibName() ) );
                                GetChars( component->GetFootprintName() ) );

                aReporter->Report( msg );
            }
@@ -2414,8 +2414,8 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, REPORTER* aReporter )
        else                           // An existing footprint.
        {
            // Test for footprint change.
            if( !component->GetFootprintLibName().IsEmpty() &&
                footprint->GetLibRef() != component->GetFootprintLibName() )
            if( !component->GetFootprintName().IsEmpty() &&
                footprint->GetLibRef() != component->GetFootprintName() )
            {
                if( aNetlist.GetReplaceFootprints() )
                {
@@ -2427,13 +2427,13 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, REPORTER* aReporter )
                                        GetChars( footprint->GetReference() ),
                                        GetChars( footprint->GetPath() ),
                                        GetChars( footprint->GetLibRef() ),
                                        GetChars( component->GetFootprintLibName() ) );
                                        GetChars( component->GetFootprintName() ) );
                        else
                            msg.Printf( _( "Cannot replace component \"%s:%s\" due to missing "
                                           "footprint \"%s\".\n" ),
                                        GetChars( footprint->GetReference() ),
                                        GetChars( footprint->GetPath() ),
                                        GetChars( component->GetFootprintLibName() ) );
                                        GetChars( component->GetFootprintName() ) );

                        aReporter->Report( msg );
                    }
Loading