2013-05-26 04:36:44 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2011 Jean-Pierre Charras, <jp.charras@wanadoo.fr>
|
|
|
|
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @file footprint_info.h
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FOOTPRINT_INFO_H_
|
|
|
|
#define FOOTPRINT_INFO_H_
|
|
|
|
|
2013-06-07 12:15:32 +00:00
|
|
|
|
2013-05-26 04:36:44 +00:00
|
|
|
#include <boost/ptr_container/ptr_vector.hpp>
|
|
|
|
#include <boost/foreach.hpp>
|
|
|
|
|
|
|
|
#include <kicad_string.h>
|
|
|
|
|
2013-05-28 16:54:59 +00:00
|
|
|
|
|
|
|
class FP_LIB_TABLE;
|
|
|
|
|
|
|
|
|
2013-05-26 04:36:44 +00:00
|
|
|
/*
|
|
|
|
* Class FOOTPRINT_INFO
|
|
|
|
* is a helper class to handle the list of footprints available in libraries. It stores
|
|
|
|
* footprint names, doc and keywords
|
|
|
|
*/
|
|
|
|
class FOOTPRINT_INFO
|
|
|
|
{
|
2013-05-31 17:33:46 +00:00
|
|
|
public:
|
2013-10-31 21:30:57 +00:00
|
|
|
|
|
|
|
// friend bool operator<( const FOOTPRINT_INFO& item1, const FOOTPRINT_INFO& item2 );
|
|
|
|
|
|
|
|
wxString m_nickname; ///< the library nickname, eventually
|
|
|
|
|
|
|
|
#if !defined(USE_FP_LIB_TABLE)
|
|
|
|
wxString m_lib_path;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
wxString m_Module; ///< Module name.
|
|
|
|
int m_Num; ///< Order number in the display list.
|
|
|
|
wxString m_Doc; ///< Footprint description.
|
|
|
|
wxString m_KeyWord; ///< Footprint key words.
|
|
|
|
unsigned m_padCount; ///< Number of pads
|
2013-05-26 04:36:44 +00:00
|
|
|
|
|
|
|
FOOTPRINT_INFO()
|
|
|
|
{
|
|
|
|
m_Num = 0;
|
|
|
|
m_padCount = 0;
|
|
|
|
}
|
|
|
|
|
2013-10-31 21:30:57 +00:00
|
|
|
const wxString& GetFootprintName() const { return m_Module; }
|
2013-05-26 04:36:44 +00:00
|
|
|
|
2013-10-31 21:30:57 +00:00
|
|
|
void SetNickname( const wxString& aLibNickname ) { m_nickname = aLibNickname; }
|
|
|
|
const wxString& GetNickname() const { return m_nickname; }
|
2013-05-26 04:36:44 +00:00
|
|
|
|
2013-10-31 21:30:57 +00:00
|
|
|
#if !defined(USE_FP_LIB_TABLE)
|
|
|
|
void SetLibPath( const wxString& aLibPath ) { m_lib_path = aLibPath; }
|
|
|
|
const wxString& GetLibPath() const { return m_lib_path; }
|
|
|
|
#endif
|
2013-06-07 12:15:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function InLibrary
|
|
|
|
* tests if the #FOOTPRINT_INFO object was loaded from \a aLibrary.
|
|
|
|
*
|
2013-10-31 21:30:57 +00:00
|
|
|
* @param aLibrary is the nickname of the library to test.
|
|
|
|
*
|
2013-06-07 12:15:32 +00:00
|
|
|
* @return true if the #FOOTPRINT_INFO object was loaded from \a aLibrary. Otherwise
|
|
|
|
* false.
|
|
|
|
*/
|
|
|
|
bool InLibrary( const wxString& aLibrary ) const;
|
2013-05-26 04:36:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-10-31 21:30:57 +00:00
|
|
|
/// FOOTPRINT object list sort function.
|
|
|
|
inline bool operator<( const FOOTPRINT_INFO& item1, const FOOTPRINT_INFO& item2 )
|
|
|
|
{
|
|
|
|
#if defined( USE_FP_LIB_TABLE )
|
|
|
|
int retv = StrNumCmp( item1.m_nickname, item2.m_nickname, INT_MAX, true );
|
|
|
|
|
|
|
|
if( retv != 0 )
|
|
|
|
return retv < 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return StrNumCmp( item1.m_Module, item2.m_Module, INT_MAX, true ) < 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-05-26 04:36:44 +00:00
|
|
|
class FOOTPRINT_LIST
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
boost::ptr_vector< FOOTPRINT_INFO > m_List;
|
|
|
|
wxString m_filesNotFound;
|
|
|
|
wxString m_filesInvalid;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetCount
|
|
|
|
* @return the number of items stored in list
|
|
|
|
*/
|
|
|
|
unsigned GetCount() const { return m_List.size(); }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetModuleInfo
|
|
|
|
* @return the item stored in list if found
|
|
|
|
* @param aFootprintName = the name of item
|
|
|
|
*/
|
2013-09-14 20:33:22 +00:00
|
|
|
FOOTPRINT_INFO* GetModuleInfo( const wxString & aFootprintName );
|
2013-05-26 04:36:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetItem
|
|
|
|
* @return the aIdx item in list
|
|
|
|
* @param aIdx = index of the given item
|
|
|
|
*/
|
|
|
|
FOOTPRINT_INFO & GetItem( unsigned aIdx )
|
|
|
|
{
|
|
|
|
return m_List[aIdx];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function AddItem
|
|
|
|
* add aItem in list
|
|
|
|
* @param aItem = item to add
|
|
|
|
*/
|
|
|
|
void AddItem( FOOTPRINT_INFO* aItem )
|
|
|
|
{
|
|
|
|
m_List.push_back( aItem );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function ReadFootprintFiles
|
|
|
|
*
|
|
|
|
* @param aFootprintsLibNames = an array string giving the list of libraries to load
|
|
|
|
*/
|
2013-05-28 16:54:59 +00:00
|
|
|
bool ReadFootprintFiles( wxArrayString& aFootprintsLibNames );
|
|
|
|
|
2013-10-13 21:33:58 +00:00
|
|
|
/**
|
|
|
|
* Function ReadFootprintFiles
|
|
|
|
* reads all the footprints provided by the combination of aTable and aNickname.
|
|
|
|
* @param aTable defines all the libraries.
|
|
|
|
* @param aNickname is the library to read from, or if NULL means read all
|
|
|
|
* footprints from all known libraries.
|
|
|
|
*/
|
|
|
|
bool ReadFootprintFiles( FP_LIB_TABLE* aTable, const wxString* aNickname = NULL );
|
2013-05-26 04:36:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // FOOTPRINT_INFO_H_
|