2012-10-15 01:38:32 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2015-02-28 20:50:35 +00:00
|
|
|
* Copyright (C) 2010-2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
2017-03-27 23:21:12 +00:00
|
|
|
* Copyright (C) 2012-2017 Wayne Stambaugh <stambaughw@verizon.net>
|
2017-03-23 00:59:25 +00:00
|
|
|
* Copyright (C) 2012-2017 KiCad Developers, see AUTHORS.txt for contributors.
|
2012-10-15 01:38:32 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2012-10-17 15:12:17 +00:00
|
|
|
#ifndef FP_LIB_TABLE_H_
|
|
|
|
#define FP_LIB_TABLE_H_
|
2012-10-15 01:38:32 +00:00
|
|
|
|
2016-11-20 02:22:58 +00:00
|
|
|
#include <lib_table_base.h>
|
2012-10-17 15:12:17 +00:00
|
|
|
#include <io_mgr.h>
|
2016-11-19 22:15:34 +00:00
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
class FOOTPRINT;
|
2017-03-27 23:21:12 +00:00
|
|
|
class FP_LIB_TABLE_GRID;
|
|
|
|
|
2016-10-28 13:11:23 +00:00
|
|
|
|
2016-11-19 22:15:34 +00:00
|
|
|
/**
|
2020-01-10 14:31:00 +00:00
|
|
|
* FP_LIB_TABLE_ROW
|
2016-11-19 22:15:34 +00:00
|
|
|
*
|
|
|
|
* holds a record identifying a library accessed by the appropriate footprint library #PLUGIN
|
2016-11-20 02:22:58 +00:00
|
|
|
* object in the #FP_LIB_TABLE.
|
2016-11-19 22:15:34 +00:00
|
|
|
*/
|
2016-10-28 13:11:23 +00:00
|
|
|
class FP_LIB_TABLE_ROW : public LIB_TABLE_ROW
|
|
|
|
{
|
|
|
|
friend class FP_LIB_TABLE;
|
|
|
|
|
|
|
|
public:
|
|
|
|
typedef IO_MGR::PCB_FILE_T LIB_T;
|
|
|
|
|
|
|
|
FP_LIB_TABLE_ROW( const wxString& aNick, const wxString& aURI, const wxString& aType,
|
|
|
|
const wxString& aOptions, const wxString& aDescr = wxEmptyString ) :
|
|
|
|
LIB_TABLE_ROW( aNick, aURI, aOptions, aDescr )
|
|
|
|
{
|
|
|
|
SetType( aType );
|
|
|
|
}
|
|
|
|
|
|
|
|
FP_LIB_TABLE_ROW() :
|
2017-10-03 10:23:52 +00:00
|
|
|
type( IO_MGR::KICAD_SEXP )
|
2016-10-28 13:11:23 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==( const FP_LIB_TABLE_ROW& aRow ) const;
|
|
|
|
|
|
|
|
bool operator!=( const FP_LIB_TABLE_ROW& aRow ) const { return !( *this == aRow ); }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetType
|
2016-11-19 22:15:34 +00:00
|
|
|
*
|
|
|
|
* returns the type of footprint library table represented by this row.
|
2016-10-28 13:11:23 +00:00
|
|
|
*/
|
|
|
|
const wxString GetType() const override { return IO_MGR::ShowType( type ); }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function SetType
|
2016-11-19 22:15:34 +00:00
|
|
|
*
|
2016-10-28 13:11:23 +00:00
|
|
|
* changes the type represented by this row.
|
|
|
|
*/
|
|
|
|
void SetType( const wxString& aType ) override;
|
|
|
|
|
2016-11-19 22:15:34 +00:00
|
|
|
protected:
|
|
|
|
FP_LIB_TABLE_ROW( const FP_LIB_TABLE_ROW& aRow ) :
|
|
|
|
LIB_TABLE_ROW( aRow ),
|
|
|
|
type( aRow.type )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-10-28 13:11:23 +00:00
|
|
|
private:
|
2016-11-19 22:15:34 +00:00
|
|
|
|
|
|
|
virtual LIB_TABLE_ROW* do_clone() const override
|
|
|
|
{
|
|
|
|
return new FP_LIB_TABLE_ROW( *this );
|
|
|
|
}
|
|
|
|
|
2016-10-28 13:11:23 +00:00
|
|
|
void setPlugin( PLUGIN* aPlugin )
|
|
|
|
{
|
|
|
|
plugin.set( aPlugin );
|
|
|
|
}
|
|
|
|
|
|
|
|
PLUGIN::RELEASER plugin;
|
|
|
|
LIB_T type;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-11-19 22:15:34 +00:00
|
|
|
class FP_LIB_TABLE : public LIB_TABLE
|
|
|
|
{
|
2017-03-27 23:21:12 +00:00
|
|
|
friend class FP_LIB_TABLE_GRID;
|
|
|
|
|
2016-11-19 22:15:34 +00:00
|
|
|
public:
|
2018-09-15 11:05:54 +00:00
|
|
|
KICAD_T Type() override { return FP_LIB_TABLE_T; }
|
2016-11-19 22:15:34 +00:00
|
|
|
|
2017-03-14 22:54:40 +00:00
|
|
|
virtual void Parse( LIB_TABLE_LEXER* aLexer ) override;
|
2016-11-19 22:15:34 +00:00
|
|
|
|
2017-03-14 22:54:40 +00:00
|
|
|
virtual void Format( OUTPUTFORMATTER* aOutput, int aIndentLevel ) const override;
|
2016-11-19 22:15:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor FP_LIB_TABLE
|
|
|
|
*
|
|
|
|
* builds a footprint library table by pre-pending this table fragment in front of
|
|
|
|
* @a aFallBackTable. Loading of this table fragment is done by using Parse().
|
|
|
|
*
|
|
|
|
* @param aFallBackTable is another FP_LIB_TABLE which is searched only when
|
|
|
|
* a row is not found in this table. No ownership is
|
|
|
|
* taken of aFallBackTable.
|
|
|
|
*/
|
|
|
|
FP_LIB_TABLE( FP_LIB_TABLE* aFallBackTable = NULL );
|
|
|
|
|
2017-06-30 14:03:01 +00:00
|
|
|
|
|
|
|
bool operator==( const FP_LIB_TABLE& aFpTable ) const;
|
|
|
|
|
|
|
|
bool operator!=( const FP_LIB_TABLE& r ) const { return !( *this == r ); }
|
|
|
|
|
2016-11-19 22:15:34 +00:00
|
|
|
/**
|
|
|
|
* Function FindRow
|
|
|
|
*
|
|
|
|
* returns an FP_LIB_TABLE_ROW if \a aNickName is found in this table or in any chained
|
|
|
|
* fallBack table fragment. The #PLUGIN is loaded and attached to the "plugin" field
|
|
|
|
* of the #FP_LIB_TABLE_ROW if not already loaded.
|
|
|
|
*
|
|
|
|
* @throw IO_ERROR if \a aNickName cannot be found.
|
|
|
|
*/
|
2017-06-08 21:47:21 +00:00
|
|
|
const FP_LIB_TABLE_ROW* FindRow( const wxString& aNickName );
|
2012-10-15 16:19:42 +00:00
|
|
|
|
2013-10-05 04:53:15 +00:00
|
|
|
//-----<PLUGIN API SUBSET, REBASED ON aNickname>---------------------------
|
2013-10-04 19:09:10 +00:00
|
|
|
|
2012-10-15 01:38:32 +00:00
|
|
|
/**
|
2017-06-13 23:47:05 +00:00
|
|
|
* Return a list of footprint names contained within the library given by @a aNickname.
|
2013-10-04 19:09:10 +00:00
|
|
|
*
|
2017-06-13 23:47:05 +00:00
|
|
|
* @param aFootprintNames is the list to fill with the footprint names found in \a aNickname
|
2013-10-04 19:09:10 +00:00
|
|
|
*
|
2017-06-13 23:47:05 +00:00
|
|
|
* @param aNickname is a locator for the "library", it is a "name" in LIB_TABLE_ROW.
|
2019-08-31 14:18:27 +00:00
|
|
|
* @param aBestEfforts if true, don't throw on errors
|
2013-10-04 19:09:10 +00:00
|
|
|
*
|
|
|
|
* @throw IO_ERROR if the library cannot be found, or footprint cannot be loaded.
|
2012-10-15 01:38:32 +00:00
|
|
|
*/
|
2019-08-31 14:18:27 +00:00
|
|
|
void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aNickname,
|
|
|
|
bool aBestEfforts );
|
2012-10-15 01:38:32 +00:00
|
|
|
|
2018-02-05 20:55:00 +00:00
|
|
|
/**
|
2018-02-23 12:21:06 +00:00
|
|
|
* Generate a hashed timestamp representing the last-mod-times of the library indicated
|
|
|
|
* by \a aNickname, or all libraries if \a aNickname is NULL.
|
2018-02-05 20:55:00 +00:00
|
|
|
*/
|
2018-02-23 12:21:06 +00:00
|
|
|
long long GenerateTimestamp( const wxString* aNickname );
|
2018-02-05 20:55:00 +00:00
|
|
|
|
2017-03-23 00:59:25 +00:00
|
|
|
/**
|
|
|
|
* Function PrefetchLib
|
|
|
|
* If possible, prefetches the specified library (e.g. performing downloads). Does not parse.
|
|
|
|
* Threadsafe.
|
|
|
|
*
|
|
|
|
* This is a no-op for libraries that cannot be prefetched.
|
|
|
|
*
|
|
|
|
* @param aNickname is a locator for the library; it is a name in LIB_TABLE_ROW.
|
|
|
|
*
|
|
|
|
* @throw IO_ERROR if there is an error prefetching the library.
|
|
|
|
*/
|
|
|
|
void PrefetchLib( const wxString& aNickname );
|
|
|
|
|
2012-10-15 01:38:32 +00:00
|
|
|
/**
|
2013-10-04 19:09:10 +00:00
|
|
|
* Function FootprintLoad
|
2016-11-19 22:15:34 +00:00
|
|
|
*
|
2013-10-04 19:09:10 +00:00
|
|
|
* loads a footprint having @a aFootprintName from the library given by @a aNickname.
|
|
|
|
*
|
2016-11-19 22:15:34 +00:00
|
|
|
* @param aNickname is a locator for the "library", it is a "name" in #LIB_TABLE_ROW
|
2013-10-04 19:09:10 +00:00
|
|
|
*
|
|
|
|
* @param aFootprintName is the name of the footprint to load.
|
|
|
|
*
|
2020-11-13 15:15:52 +00:00
|
|
|
* @return FOOTPRINT* - if found caller owns it, else NULL if not found.
|
2013-10-04 19:09:10 +00:00
|
|
|
*
|
|
|
|
* @throw IO_ERROR if the library cannot be found or read. No exception
|
|
|
|
* is thrown in the case where aFootprintName cannot be found.
|
2012-10-15 01:38:32 +00:00
|
|
|
*/
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT* FootprintLoad( const wxString& aNickname, const wxString& aFootprintName );
|
2012-10-15 01:38:32 +00:00
|
|
|
|
2018-10-03 21:44:17 +00:00
|
|
|
/**
|
|
|
|
* Function FootprintExists
|
|
|
|
*
|
|
|
|
* indicates whether or not the given footprint already exists in the given library.
|
|
|
|
*/
|
|
|
|
bool FootprintExists( const wxString& aNickname, const wxString& aFootprintName );
|
|
|
|
|
2018-02-23 12:21:06 +00:00
|
|
|
/**
|
2018-07-30 13:18:37 +00:00
|
|
|
* Function GetEnumeratedFootprint
|
2018-02-23 12:21:06 +00:00
|
|
|
*
|
|
|
|
* a version of FootprintLoad() for use after FootprintEnumerate() for more efficient
|
2018-07-30 13:18:37 +00:00
|
|
|
* cache management. Return value is const to allow it to return a reference to a cached
|
|
|
|
* item.
|
2018-02-23 12:21:06 +00:00
|
|
|
*/
|
2020-11-13 15:15:52 +00:00
|
|
|
const FOOTPRINT* GetEnumeratedFootprint( const wxString& aNickname,
|
|
|
|
const wxString& aFootprintName );
|
2013-11-27 06:04:04 +00:00
|
|
|
/**
|
|
|
|
* Enum SAVE_T
|
|
|
|
* is the set of return values from FootprintSave() below.
|
|
|
|
*/
|
|
|
|
enum SAVE_T
|
|
|
|
{
|
|
|
|
SAVE_OK,
|
|
|
|
SAVE_SKIPPED,
|
|
|
|
};
|
|
|
|
|
2012-10-15 01:38:32 +00:00
|
|
|
/**
|
2013-10-04 19:09:10 +00:00
|
|
|
* Function FootprintSave
|
2016-11-19 22:15:34 +00:00
|
|
|
*
|
2013-10-04 19:09:10 +00:00
|
|
|
* will write @a aFootprint to an existing library given by @a aNickname.
|
|
|
|
* If a footprint by the same name already exists, it is replaced.
|
|
|
|
*
|
2016-11-19 22:15:34 +00:00
|
|
|
* @param aNickname is a locator for the "library", it is a "name" in LIB_TABLE_ROW
|
2013-10-04 19:09:10 +00:00
|
|
|
*
|
2016-11-19 22:15:34 +00:00
|
|
|
* @param aFootprint is what to store in the library. The caller continues to own the
|
|
|
|
* footprint after this call.
|
2013-10-04 19:09:10 +00:00
|
|
|
*
|
2016-11-19 22:15:34 +00:00
|
|
|
* @param aOverwrite when true means overwrite any existing footprint by the same name,
|
|
|
|
* else if false means skip the write and return SAVE_SKIPPED.
|
2013-11-27 06:04:04 +00:00
|
|
|
*
|
|
|
|
* @return SAVE_T - SAVE_OK or SAVE_SKIPPED. If error saving, then IO_ERROR is thrown.
|
|
|
|
*
|
2013-10-04 19:09:10 +00:00
|
|
|
* @throw IO_ERROR if there is a problem saving.
|
2012-10-15 01:38:32 +00:00
|
|
|
*/
|
2020-11-13 15:15:52 +00:00
|
|
|
SAVE_T FootprintSave( const wxString& aNickname, const FOOTPRINT* aFootprint,
|
2016-11-19 22:15:34 +00:00
|
|
|
bool aOverwrite = true );
|
2013-10-04 19:09:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function FootprintDelete
|
2016-11-19 22:15:34 +00:00
|
|
|
*
|
2013-10-04 19:09:10 +00:00
|
|
|
* deletes the @a aFootprintName from the library given by @a aNickname.
|
|
|
|
*
|
2016-11-19 22:15:34 +00:00
|
|
|
* @param aNickname is a locator for the "library", it is a "name" in LIB_TABLE_ROW.
|
2013-10-04 19:09:10 +00:00
|
|
|
*
|
|
|
|
* @param aFootprintName is the name of a footprint to delete from the specified library.
|
|
|
|
*
|
|
|
|
* @throw IO_ERROR if there is a problem finding the footprint or the library, or deleting it.
|
|
|
|
*/
|
|
|
|
void FootprintDelete( const wxString& aNickname, const wxString& aFootprintName );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function IsFootprintLibWritable
|
2016-11-19 22:15:34 +00:00
|
|
|
*
|
|
|
|
* returns true if the library given by @a aNickname is writable. (Often
|
2013-10-04 19:09:10 +00:00
|
|
|
* system libraries are read only because of where they are installed.)
|
|
|
|
*
|
|
|
|
* @throw IO_ERROR if no library at aLibraryPath exists.
|
|
|
|
*/
|
|
|
|
bool IsFootprintLibWritable( const wxString& aNickname );
|
|
|
|
|
2013-11-27 06:04:04 +00:00
|
|
|
void FootprintLibDelete( const wxString& aNickname );
|
|
|
|
|
|
|
|
void FootprintLibCreate( const wxString& aNickname );
|
|
|
|
|
2013-10-05 04:53:15 +00:00
|
|
|
//-----</PLUGIN API SUBSET, REBASED ON aNickname>---------------------------
|
|
|
|
|
2014-04-09 13:33:04 +00:00
|
|
|
/**
|
|
|
|
* Function FootprintLoadWithOptionalNickname
|
|
|
|
* loads a footprint having @a aFootprintId with possibly an empty nickname.
|
|
|
|
*
|
2016-11-19 22:15:34 +00:00
|
|
|
* @param aFootprintId the [nickname] & footprint name of the footprint to load.
|
2014-04-09 13:33:04 +00:00
|
|
|
*
|
2020-11-13 15:15:52 +00:00
|
|
|
* @return FOOTPRINT* - if found caller owns it, else NULL if not found.
|
2014-04-09 13:33:04 +00:00
|
|
|
*
|
|
|
|
* @throw IO_ERROR if the library cannot be found or read. No exception
|
|
|
|
* is thrown in the case where aFootprintName cannot be found.
|
|
|
|
* @throw PARSE_ERROR if @a aFootprintId is not parsed OK.
|
|
|
|
*/
|
2020-11-13 15:15:52 +00:00
|
|
|
FOOTPRINT* FootprintLoadWithOptionalNickname( const LIB_ID& aFootprintId );
|
2014-04-09 13:33:04 +00:00
|
|
|
|
2013-05-08 20:47:23 +00:00
|
|
|
/**
|
2013-05-20 14:49:20 +00:00
|
|
|
* Function LoadGlobalTable
|
|
|
|
* loads the global footprint library table into \a aTable.
|
|
|
|
*
|
|
|
|
* This probably should be move into the application object when KiCad is changed
|
|
|
|
* to a single process application. This is the least painful solution for the
|
|
|
|
* time being.
|
|
|
|
*
|
|
|
|
* @param aTable the #FP_LIB_TABLE object to load.
|
2013-09-06 12:17:33 +00:00
|
|
|
* @return true if the global library table exists and is loaded properly.
|
|
|
|
* @throw IO_ERROR if an error occurs attempting to load the footprint library
|
|
|
|
* table.
|
2013-05-08 20:47:23 +00:00
|
|
|
*/
|
2017-06-08 21:47:21 +00:00
|
|
|
static bool LoadGlobalTable( FP_LIB_TABLE& aTable );
|
2013-05-20 14:49:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function GetGlobalTableFileName
|
2016-11-19 22:15:34 +00:00
|
|
|
*
|
2013-05-20 14:49:20 +00:00
|
|
|
* @return the platform specific global footprint library path and file name.
|
|
|
|
*/
|
|
|
|
static wxString GetGlobalTableFileName();
|
|
|
|
|
2013-11-15 14:36:11 +00:00
|
|
|
/**
|
|
|
|
* Function GlobalPathEnvVarVariableName
|
2016-11-19 22:15:34 +00:00
|
|
|
*
|
2013-11-15 14:36:11 +00:00
|
|
|
* returns the name of the environment variable used to hold the directory of
|
|
|
|
* locally installed "KiCad sponsored" system footprint libraries. These can
|
|
|
|
* be either legacy or pretty format. The only thing special about this
|
|
|
|
* particular environment variable is that it is set automatically by
|
2016-11-19 22:15:34 +00:00
|
|
|
* KiCad on program start up, <b>if</b> it is not set already in the environment.
|
2013-11-15 14:36:11 +00:00
|
|
|
*/
|
|
|
|
static const wxString GlobalPathEnvVariableName();
|
2012-10-17 01:00:25 +00:00
|
|
|
};
|
|
|
|
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
|
|
|
|
extern FP_LIB_TABLE GFootprintTable; // KIFACE scope.
|
|
|
|
|
2012-10-17 15:12:17 +00:00
|
|
|
#endif // FP_LIB_TABLE_H_
|