Commit 5560cb54 authored by Wayne Stambaugh's avatar Wayne Stambaugh
Browse files

More Pcbnew footprint library table work in progress.

* Add footprint library table loading to footprint editor.
* Overload FOOTPRINT_INFO::ReadFootprintFiles() to read footprints from the
  footprint library tables.
* Fix a bug in FP_LIB_TABLE::IsEmpty() when the table has a fallback table.
* Add code to FOOTPRINT_EDIT_FRAME to use footprint library tables.
* Add an optional build time version of PCB_EDIT_FRAME::loadFootprints() to
  populate netlist footprints from footprint library table.
* Remove adding footprints to board whenever GetModuleLibrary() is called and
  move loading locally as required.
* Add missing source file license comments and coding policy fixes.
parent 4e94d8e7
Loading
Loading
Loading
Loading
+56 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@
#include <wildcards_and_files_ext.h>
#include <footprint_info.h>
#include <io_mgr.h>
#include <fp_lib_table.h>

#include <class_module.h>

@@ -124,3 +125,58 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames )

    return true;
}


bool FOOTPRINT_LIST::ReadFootprintFiles( FP_LIB_TABLE& aTable )
{
    // Clear data before reading files
    m_filesNotFound.Empty();
    m_filesInvalid.Empty();
    m_List.clear();

    std::vector< wxString > libNickNames = aTable.GetLogicalLibs();

    // Parse Libraries Listed
    for( unsigned ii = 0; ii < libNickNames.size(); ii++ )
    {
        const FP_LIB_TABLE::ROW* row = aTable.FindRow( libNickNames[ii] );

        wxCHECK2_MSG( row != NULL, continue,
                      wxString::Format( wxT( "No library name <%s> found in footprint library "
                                             "table." ), GetChars( libNickNames[ii] ) ) );
        try
        {
            PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::EnumFromStr( row->GetType() ) ) );

            wxString      path = FP_LIB_TABLE::ExpandSubstitutions( row->GetFullURI() );
            wxArrayString fpnames = pi->FootprintEnumerate( path );

            for( unsigned i=0;  i<fpnames.GetCount();  ++i )
            {
                std::auto_ptr<MODULE> m( pi->FootprintLoad( path, fpnames[i] ) );

                // we're loading what we enumerated, all must be there.
                wxASSERT( m.get() );

                FOOTPRINT_INFO* fpinfo = new FOOTPRINT_INFO();

                fpinfo->SetLibraryName( libNickNames[ii] );
                fpinfo->SetLibraryPath( path );
                fpinfo->m_Module   = fpnames[i];
                fpinfo->m_padCount = m->GetPadCount();
                fpinfo->m_KeyWord  = m->GetKeywords();
                fpinfo->m_Doc      = m->GetDescription();

                AddItem( fpinfo );
            }
        }
        catch( IO_ERROR ioe )
        {
            m_filesInvalid << ioe.errorText << wxT( "\n" );
        }
    }

    m_List.sort();

    return true;
}
+9 −0
Original line number Diff line number Diff line
@@ -310,6 +310,15 @@ const wxString FP_LIB_TABLE::ExpandSubstitutions( const wxString aString )
}


bool FP_LIB_TABLE::IsEmpty() const
{
    if( fallBack == NULL )
        return rows.empty();

    return fallBack->IsEmpty() && rows.empty();
}


void FP_LIB_TABLE::LoadGlobalTable( FP_LIB_TABLE& aTable ) throw (IO_ERROR, PARSE_ERROR )
{
    wxFileName fn = GetGlobalTableFileName();
+1 −1
Original line number Diff line number Diff line
/**
 * @file title_block_shape.cpp
 * @file title_block_shapes.cpp
 * @brief description of graphic items and texts to build a title block
 */

+1 −1
Original line number Diff line number Diff line
/**
 * @file title_block_shape_gost.h
 * @file title_block_shapes_gost.cpp
 * @brief description of graphic items and texts to build a title block
 * using GOST standard
 */
+7 −1
Original line number Diff line number Diff line
@@ -34,6 +34,10 @@

#include <kicad_string.h>


class FP_LIB_TABLE;


/*
 * Class FOOTPRINT_INFO
 * is a helper class to handle the list of footprints available in libraries. It stores
@@ -137,6 +141,8 @@ public:
     * @param aFootprintsLibNames = an array string giving the list of libraries to load
     */
    bool ReadFootprintFiles( wxArrayString& aFootprintsLibNames );

    bool ReadFootprintFiles( FP_LIB_TABLE& aTable );
};

/// FOOTPRINT object list sort function.
Loading