mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-11 11:20:09 +00:00
Make footprint ID into a generic library ID.
Rename FPID to LIB_ID as is now used as a generic library identifier and is no longer specific to footprints. Remove all mention of footprint from the new LIB_ID doxygen comments and code. Rename files fpid.h and fpid.cpp to lib_id.h and lib_id.cpp. Rename fp_lib_table.keywords file to lib_table.keywords and adjust CMake build dependencies accordingly. Update all source files effected by the code and file name changes. Update .gitignore for file name changes.
This commit is contained in:
parent
4d018039aa
commit
64c892ee23
.gitignore
common
cvpcb
autosel.cppautosel.hclass_DisplayFootprintsFrame.cppclass_footprints_listbox.cppcvpcb_mainframe.cppcvpcb_mainframe.hreadwrite_dlgs.cpp
eeschema
include
pcbnew
build_BOM_from_board.cppclass_module.h
dialogs
eagle_plugin.cppexporters
github
gpcb_plugin.cppkicad_netlist_reader.cppkicad_plugin.cpplegacy_netlist_reader.cpplegacy_plugin.cpplibrairi.cpploadcmp.cppmodview_frame.cppmuonde.cppnetlist.cppnetlist_reader.cppnetlist_reader.hpcad2kicadpcb_plugin
pcb_netlist.hpcb_parser.cpppcbnew_config.cpppython
swig
xchgmod.cpp
4
.gitignore
vendored
4
.gitignore
vendored
@ -6,9 +6,9 @@ common/netlist_keywords.*
|
||||
common/netlist_lexer.h
|
||||
common/pcb_plot_params_lexer.h
|
||||
common/page_layout/page_layout_reader_keywords.cpp
|
||||
common/fp_lib_table_keywords.*
|
||||
common/lib_table_keywords.*
|
||||
common/gal/opengl/shader_src.h
|
||||
include/fp_lib_table_lexer.h
|
||||
include/lib_table_lexer.h
|
||||
include/netlist_lexer.h
|
||||
include/page_layout_reader_lexer.h
|
||||
eeschema/cmp_library_lexer.h
|
||||
|
@ -229,8 +229,8 @@ set( COMMON_SRCS
|
||||
eda_pattern_match.cpp
|
||||
exceptions.cpp
|
||||
filter_reader.cpp
|
||||
fpid.cpp
|
||||
fp_lib_table_keywords.cpp
|
||||
lib_id.cpp
|
||||
lib_table_keywords.cpp
|
||||
# findkicadhelppath.cpp.notused deprecated, use searchhelpfilefullpath.cpp
|
||||
gbr_metadata.cpp
|
||||
gestfich.cpp
|
||||
@ -470,20 +470,20 @@ add_dependencies( pcbcommon pcb_lexer_source_files )
|
||||
|
||||
# auto-generate s-expression library table code.
|
||||
make_lexer(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/fp_lib_table.keywords
|
||||
${PROJECT_SOURCE_DIR}/include/fp_lib_table_lexer.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/fp_lib_table_keywords.cpp
|
||||
FP_LIB_TABLE_T
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/lib_table.keywords
|
||||
${PROJECT_SOURCE_DIR}/include/lib_table_lexer.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/lib_table_keywords.cpp
|
||||
LIB_TABLE_T
|
||||
)
|
||||
|
||||
add_custom_target(
|
||||
fp_lib_table_lexer_source_files ALL
|
||||
lib_table_lexer_source_files ALL
|
||||
DEPENDS
|
||||
${PROJECT_SOURCE_DIR}/include/fp_lib_table_lexer.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/fp_lib_table_keywords.cpp
|
||||
${PROJECT_SOURCE_DIR}/include/lib_table_lexer.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/lib_table_keywords.cpp
|
||||
)
|
||||
|
||||
add_dependencies( common fp_lib_table_lexer_source_files )
|
||||
add_dependencies( common lib_table_lexer_source_files )
|
||||
|
||||
# auto-generate page layout reader s-expression page_layout_reader_lexer.h
|
||||
# and title_block_reader_keywords.cpp.
|
||||
|
@ -48,7 +48,7 @@
|
||||
#include <footprint_info.h>
|
||||
#include <io_mgr.h>
|
||||
#include <fp_lib_table.h>
|
||||
#include <fpid.h>
|
||||
#include <lib_id.h>
|
||||
#include <class_module.h>
|
||||
#include <thread>
|
||||
#include <html_messagebox.h>
|
||||
@ -268,14 +268,14 @@ FOOTPRINT_INFO* FOOTPRINT_LIST::GetModuleInfo( const wxString& aFootprintName )
|
||||
|
||||
for( FOOTPRINT_INFO& fp : m_list )
|
||||
{
|
||||
FPID fpid;
|
||||
LIB_ID fpid;
|
||||
|
||||
wxCHECK_MSG( fpid.Parse( aFootprintName ) < 0, NULL,
|
||||
wxString::Format( wxT( "'%s' is not a valid FPID." ),
|
||||
wxString::Format( wxT( "'%s' is not a valid LIB_ID." ),
|
||||
GetChars( aFootprintName ) ) );
|
||||
|
||||
wxString libNickname = fpid.GetLibNickname();
|
||||
wxString footprintName = fpid.GetFootprintName();
|
||||
wxString footprintName = fpid.GetLibItemName();
|
||||
|
||||
if( libNickname == fp.GetNickname() && footprintName == fp.GetFootprintName() )
|
||||
return &fp;
|
||||
|
@ -28,14 +28,14 @@
|
||||
#include <common.h>
|
||||
#include <kiface_i.h>
|
||||
#include <footprint_info.h>
|
||||
#include <fpid.h>
|
||||
#include <fp_lib_table_lexer.h>
|
||||
#include <lib_id.h>
|
||||
#include <lib_table_lexer.h>
|
||||
#include <fp_lib_table.h>
|
||||
#include <class_module.h>
|
||||
|
||||
#define OPT_SEP '|' ///< options separator character
|
||||
|
||||
using namespace FP_LIB_TABLE_T;
|
||||
using namespace LIB_TABLE_T;
|
||||
|
||||
|
||||
static const wxChar global_tbl_name[] = wxT( "fp-lib-table" );
|
||||
@ -64,7 +64,7 @@ FP_LIB_TABLE::FP_LIB_TABLE( FP_LIB_TABLE* aFallBackTable ) :
|
||||
}
|
||||
|
||||
|
||||
void FP_LIB_TABLE::Parse( FP_LIB_TABLE_LEXER* in ) throw()
|
||||
void FP_LIB_TABLE::Parse( LIB_TABLE_LEXER* in ) throw()
|
||||
{
|
||||
T tok;
|
||||
|
||||
@ -244,11 +244,11 @@ MODULE* FP_LIB_TABLE::FootprintLoad( const wxString& aNickname, const wxString&
|
||||
if( ret )
|
||||
{
|
||||
// remove "const"-ness, I really do want to set nickname without
|
||||
// having to copy the FPID and its two strings, twice each.
|
||||
FPID& fpid = (FPID&) ret->GetFPID();
|
||||
// having to copy the LIB_ID and its two strings, twice each.
|
||||
LIB_ID& fpid = (LIB_ID&) ret->GetFPID();
|
||||
|
||||
// Catch any misbehaving plugin, which should be setting internal footprint name properly:
|
||||
wxASSERT( aFootprintName == (wxString) fpid.GetFootprintName() );
|
||||
wxASSERT( aFootprintName == (wxString) fpid.GetLibItemName() );
|
||||
|
||||
// and clearing nickname
|
||||
wxASSERT( !fpid.GetLibNickname().size() );
|
||||
@ -271,7 +271,7 @@ FP_LIB_TABLE::SAVE_T FP_LIB_TABLE::FootprintSave( const wxString& aNickname,
|
||||
// Try loading the footprint to see if it already exists, caller wants overwrite
|
||||
// protection, which is atypical, not the default.
|
||||
|
||||
wxString fpname = aFootprint->GetFPID().GetFootprintName();
|
||||
wxString fpname = aFootprint->GetFPID().GetLibItemName();
|
||||
|
||||
std::unique_ptr<MODULE> footprint( row->plugin->FootprintLoad( row->GetFullURI( true ),
|
||||
fpname, row->GetProperties() ) );
|
||||
@ -319,11 +319,11 @@ void FP_LIB_TABLE::FootprintLibCreate( const wxString& aNickname )
|
||||
}
|
||||
|
||||
|
||||
MODULE* FP_LIB_TABLE::FootprintLoadWithOptionalNickname( const FPID& aFootprintId )
|
||||
MODULE* FP_LIB_TABLE::FootprintLoadWithOptionalNickname( const LIB_ID& aFootprintId )
|
||||
throw( IO_ERROR, PARSE_ERROR, boost::interprocess::lock_exception )
|
||||
{
|
||||
wxString nickname = aFootprintId.GetLibNickname();
|
||||
wxString fpname = aFootprintId.GetFootprintName();
|
||||
wxString fpname = aFootprintId.GetLibItemName();
|
||||
|
||||
if( nickname.size() )
|
||||
{
|
||||
|
@ -2,8 +2,8 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2010 KiCad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 2012-2016 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2010-2016 KiCad Developers, see change_log.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
|
||||
@ -28,7 +28,7 @@
|
||||
#include <wx/wx.h> // _()
|
||||
|
||||
#include <macros.h> // TO_UTF8()
|
||||
#include <fpid.h>
|
||||
#include <lib_id.h>
|
||||
#include <kicad_string.h>
|
||||
|
||||
|
||||
@ -111,15 +111,15 @@ static int okRevision( const std::string& aField )
|
||||
//----</Policy and field test functions>-------------------------------------
|
||||
|
||||
|
||||
void FPID::clear()
|
||||
void LIB_ID::clear()
|
||||
{
|
||||
nickname.clear();
|
||||
footprint.clear();
|
||||
item_name.clear();
|
||||
revision.clear();
|
||||
}
|
||||
|
||||
|
||||
int FPID::Parse( const UTF8& aId )
|
||||
int LIB_ID::Parse( const UTF8& aId )
|
||||
{
|
||||
clear();
|
||||
|
||||
@ -130,7 +130,7 @@ int FPID::Parse( const UTF8& aId )
|
||||
int offset;
|
||||
|
||||
//=====<revision>=========================================
|
||||
// in a FPID like discret:R3/rev4
|
||||
// in a LIB_ID like discret:R3/rev4
|
||||
if( rev )
|
||||
{
|
||||
revNdx = rev - buffer;
|
||||
@ -161,28 +161,27 @@ int FPID::Parse( const UTF8& aId )
|
||||
partNdx = 0;
|
||||
}
|
||||
|
||||
//=====<footprint name>====================================
|
||||
//=====<item name>====================================
|
||||
if( partNdx >= revNdx )
|
||||
return partNdx; // Error: no footprint name.
|
||||
return partNdx; // Error: no library item name.
|
||||
|
||||
// Be sure the footprint name is valid.
|
||||
// Some chars can be found in board file (in old board files
|
||||
// or converted files from an other EDA tool
|
||||
// Be sure the item name is valid.
|
||||
// Some chars can be found in legacy files converted files from an other EDA tools.
|
||||
std::string fpname = aId.substr( partNdx, revNdx-partNdx );
|
||||
ReplaceIllegalFileNameChars( &fpname, '_' );
|
||||
SetFootprintName( UTF8( fpname ) );
|
||||
SetLibItemName( UTF8( fpname ) );
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
FPID::FPID( const std::string& aId ) throw( PARSE_ERROR )
|
||||
LIB_ID::LIB_ID( const std::string& aId ) throw( PARSE_ERROR )
|
||||
{
|
||||
int offset = Parse( aId );
|
||||
|
||||
if( offset != -1 )
|
||||
{
|
||||
THROW_PARSE_ERROR( _( "Illegal character found in FPID string" ),
|
||||
THROW_PARSE_ERROR( _( "Illegal character found in LIB_ID string" ),
|
||||
wxString::FromUTF8( aId.c_str() ),
|
||||
aId.c_str(),
|
||||
0,
|
||||
@ -191,7 +190,7 @@ FPID::FPID( const std::string& aId ) throw( PARSE_ERROR )
|
||||
}
|
||||
|
||||
|
||||
FPID::FPID( const wxString& aId ) throw( PARSE_ERROR )
|
||||
LIB_ID::LIB_ID( const wxString& aId ) throw( PARSE_ERROR )
|
||||
{
|
||||
UTF8 id = aId;
|
||||
|
||||
@ -199,7 +198,7 @@ FPID::FPID( const wxString& aId ) throw( PARSE_ERROR )
|
||||
|
||||
if( offset != -1 )
|
||||
{
|
||||
THROW_PARSE_ERROR( _( "Illegal character found in FPID string" ),
|
||||
THROW_PARSE_ERROR( _( "Illegal character found in LIB_ID string" ),
|
||||
aId,
|
||||
id.c_str(),
|
||||
0,
|
||||
@ -208,7 +207,7 @@ FPID::FPID( const wxString& aId ) throw( PARSE_ERROR )
|
||||
}
|
||||
|
||||
|
||||
int FPID::SetLibNickname( const UTF8& aLogical )
|
||||
int LIB_ID::SetLibNickname( const UTF8& aLogical )
|
||||
{
|
||||
int offset = okLogical( aLogical );
|
||||
|
||||
@ -221,25 +220,25 @@ int FPID::SetLibNickname( const UTF8& aLogical )
|
||||
}
|
||||
|
||||
|
||||
int FPID::SetFootprintName( const UTF8& aFootprintName )
|
||||
int LIB_ID::SetLibItemName( const UTF8& aLibItemName )
|
||||
{
|
||||
int separation = int( aFootprintName.find_first_of( "/" ) );
|
||||
int separation = int( aLibItemName.find_first_of( "/" ) );
|
||||
|
||||
if( separation != -1 )
|
||||
{
|
||||
footprint = aFootprintName.substr( 0, separation-1 );
|
||||
item_name = aLibItemName.substr( 0, separation-1 );
|
||||
return separation;
|
||||
}
|
||||
else
|
||||
{
|
||||
footprint = aFootprintName;
|
||||
item_name = aLibItemName;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int FPID::SetRevision( const UTF8& aRevision )
|
||||
int LIB_ID::SetRevision( const UTF8& aRevision )
|
||||
{
|
||||
int offset = okRevision( aRevision );
|
||||
|
||||
@ -252,7 +251,7 @@ int FPID::SetRevision( const UTF8& aRevision )
|
||||
}
|
||||
|
||||
|
||||
UTF8 FPID::Format() const
|
||||
UTF8 LIB_ID::Format() const
|
||||
{
|
||||
UTF8 ret;
|
||||
|
||||
@ -262,7 +261,7 @@ UTF8 FPID::Format() const
|
||||
ret += ':';
|
||||
}
|
||||
|
||||
ret += footprint;
|
||||
ret += item_name;
|
||||
|
||||
if( revision.size() )
|
||||
{
|
||||
@ -274,7 +273,7 @@ UTF8 FPID::Format() const
|
||||
}
|
||||
|
||||
|
||||
UTF8 FPID::GetFootprintNameAndRev() const
|
||||
UTF8 LIB_ID::GetLibItemNameAndRev() const
|
||||
{
|
||||
UTF8 ret;
|
||||
|
||||
@ -288,10 +287,9 @@ UTF8 FPID::GetFootprintNameAndRev() const
|
||||
}
|
||||
|
||||
|
||||
#if 0 // this is broken, it does not output aFootprintName for some reason
|
||||
#if 0 // this is broken, it does not output aLibItemName for some reason
|
||||
|
||||
UTF8 FPID::Format( const UTF8& aLogicalLib, const UTF8& aFootprintName,
|
||||
const UTF8& aRevision )
|
||||
UTF8 LIB_ID::Format( const UTF8& aLogicalLib, const UTF8& aLibItemName, const UTF8& aRevision )
|
||||
throw( PARSE_ERROR )
|
||||
{
|
||||
UTF8 ret;
|
||||
@ -336,23 +334,23 @@ UTF8 FPID::Format( const UTF8& aLogicalLib, const UTF8& aFootprintName,
|
||||
#endif
|
||||
|
||||
|
||||
int FPID::compare( const FPID& aFPID ) const
|
||||
int LIB_ID::compare( const LIB_ID& aLibId ) const
|
||||
{
|
||||
// Don't bother comparing the same object.
|
||||
if( this == &aFPID )
|
||||
if( this == &aLibId )
|
||||
return 0;
|
||||
|
||||
int retv = nickname.compare( aFPID.nickname );
|
||||
int retv = nickname.compare( aLibId.nickname );
|
||||
|
||||
if( retv != 0 )
|
||||
return retv;
|
||||
|
||||
retv = footprint.compare( aFPID.footprint );
|
||||
retv = item_name.compare( aLibId.item_name );
|
||||
|
||||
if( retv != 0 )
|
||||
return retv;
|
||||
|
||||
return revision.compare( aFPID.revision );
|
||||
return revision.compare( aLibId.revision );
|
||||
}
|
||||
|
||||
|
||||
@ -360,7 +358,7 @@ int FPID::compare( const FPID& aFPID ) const
|
||||
|
||||
// build this with Debug CMAKE_BUILD_TYPE
|
||||
|
||||
void FPID::Test()
|
||||
void LIB_ID::Test()
|
||||
{
|
||||
static const char* lpids[] = {
|
||||
"smt:R_0805/rev0",
|
||||
@ -372,14 +370,14 @@ void FPID::Test()
|
||||
{
|
||||
// test some round tripping
|
||||
|
||||
FPID lpid( lpids[i] ); // parse
|
||||
LIB_ID lpid( lpids[i] ); // parse
|
||||
|
||||
// format
|
||||
printf( "input:'%s' full:'%s' nickname: %s footprint:'%s' rev:'%s'\n",
|
||||
printf( "input:'%s' full:'%s' nickname: %s item_name:'%s' rev:'%s'\n",
|
||||
lpids[i],
|
||||
lpid.Format().c_str(),
|
||||
lpid.GetLibNickname().c_str(),
|
||||
lpid.GetFootprintName().c_str(),
|
||||
lpid.GetLibItemName().c_str(),
|
||||
lpid.GetRevision().c_str() );
|
||||
}
|
||||
}
|
||||
@ -387,7 +385,7 @@ void FPID::Test()
|
||||
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
FPID::Test();
|
||||
LIB_ID::Test();
|
||||
|
||||
return 0;
|
||||
}
|
@ -32,14 +32,14 @@
|
||||
#include <common.h>
|
||||
#include <macros.h>
|
||||
#include <kiface_i.h>
|
||||
#include <fp_lib_table_lexer.h>
|
||||
#include <lib_table_lexer.h>
|
||||
#include <lib_table_base.h>
|
||||
|
||||
|
||||
#define OPT_SEP '|' ///< options separator character
|
||||
|
||||
|
||||
using namespace FP_LIB_TABLE_T;
|
||||
using namespace LIB_TABLE_T;
|
||||
|
||||
|
||||
LIB_TABLE_ROW* new_clone( const LIB_TABLE_ROW& aRow )
|
||||
@ -93,7 +93,7 @@ void LIB_TABLE_ROW::Format( OUTPUTFORMATTER* out, int nestLevel ) const
|
||||
}
|
||||
|
||||
|
||||
void LIB_TABLE_ROW::Parse( std::unique_ptr< LIB_TABLE_ROW >& aRow, FP_LIB_TABLE_LEXER* in )
|
||||
void LIB_TABLE_ROW::Parse( std::unique_ptr< LIB_TABLE_ROW >& aRow, LIB_TABLE_LEXER* in )
|
||||
throw( IO_ERROR, PARSE_ERROR )
|
||||
{
|
||||
/*
|
||||
@ -350,7 +350,7 @@ void LIB_TABLE::Load( const wxString& aFileName )
|
||||
if( wxFileName::IsFileReadable( aFileName ) )
|
||||
{
|
||||
FILE_LINE_READER reader( aFileName );
|
||||
FP_LIB_TABLE_LEXER lexer( &reader );
|
||||
LIB_TABLE_LEXER lexer( &reader );
|
||||
|
||||
Parse( &lexer );
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2016 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
|
||||
@ -26,7 +26,7 @@
|
||||
*/
|
||||
|
||||
// This file handle automatic selection of footprints, from .equ files which give
|
||||
// a footprint FPID associated to a component value.
|
||||
// a footprint LIB_ID associated to a component value.
|
||||
// These associations have this form:
|
||||
// 'FT232BL' 'QFP:LQFP-32_7x7mm_Pitch0.8mm'
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2016 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
|
||||
@ -24,7 +24,7 @@
|
||||
#ifndef AUTOSEL_H
|
||||
#define AUTOSEL_H
|
||||
|
||||
// A helper class to handle info read in .equ files, which gives a footprint FPID
|
||||
// A helper class to handle info read in .equ files, which gives a footprint LIB_ID
|
||||
// corresponding to a component value.
|
||||
// Each line is something like:
|
||||
// 'FT232BL' 'QFP:LQFP-32_7x7mm_Pitch0.8mm'
|
||||
@ -35,7 +35,7 @@ class FOOTPRINT_EQUIVALENCE
|
||||
{
|
||||
public:
|
||||
wxString m_ComponentValue; // The value of a component
|
||||
wxString m_FootprintFPID; // the footprint FPID corresponding to this value
|
||||
wxString m_FootprintFPID; // the footprint LIB_ID corresponding to this value
|
||||
|
||||
FOOTPRINT_EQUIVALENCE() {}
|
||||
};
|
||||
|
@ -2,8 +2,8 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2015 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2007-2015 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2015-2016 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2007-2016 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
|
||||
@ -37,7 +37,7 @@
|
||||
#include <bitmaps.h>
|
||||
#include <msgpanel.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
#include <fpid.h>
|
||||
#include <lib_id.h>
|
||||
#include <fp_lib_table.h>
|
||||
#include <pcbcommon.h>
|
||||
|
||||
@ -446,7 +446,7 @@ MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& aFootprintName )
|
||||
|
||||
try
|
||||
{
|
||||
FPID fpid;
|
||||
LIB_ID fpid;
|
||||
|
||||
if( fpid.Parse( aFootprintName ) >= 0 )
|
||||
{
|
||||
@ -456,7 +456,7 @@ MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& aFootprintName )
|
||||
}
|
||||
|
||||
std::string nickname = fpid.GetLibNickname();
|
||||
std::string fpname = fpid.GetFootprintName();
|
||||
std::string fpname = fpid.GetLibItemName();
|
||||
|
||||
wxLogDebug( wxT( "Load footprint <%s> from library <%s>." ),
|
||||
fpname.c_str(), nickname.c_str() );
|
||||
|
@ -162,7 +162,7 @@ void FOOTPRINTS_LISTBOX::SetFootprints( FOOTPRINT_LIST& aList, const wxString& a
|
||||
&& aComponent->GetNetCount() != aList.GetItem( ii ).GetUniquePadCount() )
|
||||
continue;
|
||||
|
||||
// We can search (Using case insensitive search) in full FPID or only
|
||||
// We can search (Using case insensitive search) in full LIB_ID or only
|
||||
// in the fp name itself.
|
||||
// After tests, only in the fp name itself looks better.
|
||||
// However, the code to take in account the nickname is just commented, no removed.
|
||||
|
@ -381,7 +381,7 @@ void CVPCB_MAINFRAME::DelAssociations( wxCommandEvent& event )
|
||||
|
||||
for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
|
||||
{
|
||||
FPID fpid;
|
||||
LIB_ID fpid;
|
||||
|
||||
m_netlist.GetComponent( i )->SetFPID( fpid );
|
||||
SetNewPkg( wxEmptyString );
|
||||
@ -808,8 +808,8 @@ int CVPCB_MAINFRAME::ReadSchematicNetlist( const std::string& aNetlist )
|
||||
// not the actual name of the footprint.
|
||||
for( unsigned ii = 0; ii < m_netlist.GetCount(); ii++ )
|
||||
{
|
||||
if( m_netlist.GetComponent( ii )->GetFPID().GetFootprintName() == std::string( "$noname" ) )
|
||||
m_netlist.GetComponent( ii )->SetFPID( FPID( wxEmptyString ) );
|
||||
if( m_netlist.GetComponent( ii )->GetFPID().GetLibItemName() == std::string( "$noname" ) )
|
||||
m_netlist.GetComponent( ii )->SetFPID( LIB_ID( wxEmptyString ) );
|
||||
}
|
||||
|
||||
// Sort components by reference:
|
||||
@ -956,7 +956,7 @@ DISPLAY_FOOTPRINTS_FRAME* CVPCB_MAINFRAME::GetFootprintViewerFrame()
|
||||
|
||||
const wxString CVPCB_MAINFRAME::GetSelectedFootprint()
|
||||
{
|
||||
// returns the FPID of the selected footprint in footprint listview
|
||||
// returns the LIB_ID of the selected footprint in footprint listview
|
||||
// or a empty string
|
||||
return m_footprintListBox->GetSelectedFootprint();
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ public:
|
||||
COMPONENT* GetSelectedComponent();
|
||||
|
||||
/**
|
||||
* @return the FPID of the selected footprint in footprint listview
|
||||
* @return the LIB_ID of the selected footprint in footprint listview
|
||||
* or a empty string if no selection
|
||||
*/
|
||||
const wxString GetSelectedFootprint();
|
||||
|
@ -6,8 +6,8 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Jean-Pierre Charras, jean-pierre.charras
|
||||
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2011-2016 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 1992-2016 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
|
||||
@ -33,7 +33,7 @@
|
||||
#include <confirm.h>
|
||||
#include <build_version.h>
|
||||
#include <macros.h>
|
||||
#include <fpid.h>
|
||||
#include <lib_id.h>
|
||||
#include <fp_lib_table.h>
|
||||
#include <reporter.h>
|
||||
#include <html_messagebox.h>
|
||||
@ -74,12 +74,12 @@ void CVPCB_MAINFRAME::SetNewPkg( const wxString& aFootprintName )
|
||||
// Check to see if the component has already a footprint set.
|
||||
hasFootprint = !component->GetFPID().empty();
|
||||
|
||||
FPID fpid;
|
||||
LIB_ID fpid;
|
||||
|
||||
if( !aFootprintName.IsEmpty() )
|
||||
{
|
||||
wxCHECK_RET( fpid.Parse( aFootprintName ) < 0,
|
||||
wxString::Format( wxT( "<%s> is not a valid FPID." ),
|
||||
wxString::Format( wxT( "<%s> is not a valid LIB_ID." ),
|
||||
GetChars( aFootprintName ) ) );
|
||||
}
|
||||
|
||||
@ -116,16 +116,16 @@ void CVPCB_MAINFRAME::SetNewPkg( const wxString& aFootprintName )
|
||||
}
|
||||
|
||||
|
||||
/// Return true if the resultant FPID has a certain nickname. The guess
|
||||
/// Return true if the resultant LIB_ID has a certain nickname. The guess
|
||||
/// is only made if this footprint resides in only one library.
|
||||
/// @return int - 0 on success, 1 on not found, 2 on ambiguous i.e. multiple matches
|
||||
static int guessNickname( FP_LIB_TABLE* aTbl, FPID* aFootprintId )
|
||||
static int guessNickname( FP_LIB_TABLE* aTbl, LIB_ID* aFootprintId )
|
||||
{
|
||||
if( aFootprintId->GetLibNickname().size() )
|
||||
return 0;
|
||||
|
||||
wxString nick;
|
||||
wxString fpname = aFootprintId->GetFootprintName();
|
||||
wxString fpname = aFootprintId->GetLibItemName();
|
||||
|
||||
std::vector<wxString> nicks = aTbl->GetLogicalLibs();
|
||||
|
||||
@ -194,7 +194,7 @@ bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles( const std::string& aNetlist )
|
||||
{
|
||||
msg = _(
|
||||
"Some of the assigned footprints are legacy entries (are missing lib nicknames). "
|
||||
"Would you like CvPcb to attempt to convert them to the new required FPID format? "
|
||||
"Would you like CvPcb to attempt to convert them to the new required LIB_ID format? "
|
||||
"(If you answer no, then these assignments will be cleared out and you will "
|
||||
"have to re-assign these footprints yourself.)"
|
||||
);
|
||||
@ -214,7 +214,7 @@ bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles( const std::string& aNetlist )
|
||||
// get this first here, it's possibly obsoleted if we get it too soon.
|
||||
FP_LIB_TABLE* tbl = Prj().PcbFootprintLibs();
|
||||
|
||||
int guess = guessNickname( tbl, (FPID*) &component->GetFPID() );
|
||||
int guess = guessNickname( tbl, (LIB_ID*) &component->GetFPID() );
|
||||
|
||||
switch( guess )
|
||||
{
|
||||
@ -228,7 +228,7 @@ bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles( const std::string& aNetlist )
|
||||
msg += wxString::Format( _(
|
||||
"Component '%s' footprint '%s' was <b>not found</b> in any library.\n" ),
|
||||
GetChars( component->GetReference() ),
|
||||
GetChars( component->GetFPID().GetFootprintName() )
|
||||
GetChars( component->GetFPID().GetLibItemName() )
|
||||
);
|
||||
break;
|
||||
|
||||
@ -236,7 +236,7 @@ bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles( const std::string& aNetlist )
|
||||
msg += wxString::Format( _(
|
||||
"Component '%s' footprint '%s' was found in <b>multiple</b> libraries.\n" ),
|
||||
GetChars( component->GetReference() ),
|
||||
GetChars( component->GetFPID().GetFootprintName() )
|
||||
GetChars( component->GetFPID().GetLibItemName() )
|
||||
);
|
||||
break;
|
||||
}
|
||||
@ -281,7 +281,7 @@ bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles( const std::string& aNetlist )
|
||||
|
||||
if( component->GetFPID().IsLegacy() )
|
||||
{
|
||||
component->SetFPID( FPID() /* empty */ );
|
||||
component->SetFPID( LIB_ID() /* empty */ );
|
||||
m_modified = true;
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@
|
||||
#define CLASS_LIBENTRY_H
|
||||
|
||||
#include <general.h>
|
||||
#include <fpid.h>
|
||||
#include <lib_id.h>
|
||||
#include <lib_draw_item.h>
|
||||
#include <lib_field.h>
|
||||
#include <vector>
|
||||
@ -189,7 +189,7 @@ class LIB_PART : public EDA_ITEM
|
||||
|
||||
PART_SPTR m_me; ///< http://www.boost.org/doc/libs/1_55_0/libs/smart_ptr/sp_techniques.html#weak_without_shared
|
||||
wxString m_name;
|
||||
FPID m_libId;
|
||||
LIB_ID m_libId;
|
||||
int m_pinNameOffset; ///< The offset in mils to draw the pin name. Set to 0
|
||||
///< to draw the pin name above the pin.
|
||||
bool m_unitsLocked; ///< True if part has multiple units and changing
|
||||
@ -239,8 +239,8 @@ public:
|
||||
|
||||
const wxString& GetName() { return m_name; }
|
||||
|
||||
const FPID& GetFPID() const { return m_libId; }
|
||||
void SetFPID( const FPID& aFPID ) { m_libId = aFPID; }
|
||||
const LIB_ID& GetLibId() const { return m_libId; }
|
||||
void SetLibId( const LIB_ID& aLibId ) { m_libId = aLibId; }
|
||||
|
||||
const wxString GetLibraryName();
|
||||
|
||||
|
@ -27,14 +27,14 @@
|
||||
#include <common.h>
|
||||
#include <kiface_i.h>
|
||||
#include <macros.h>
|
||||
#include <fpid.h>
|
||||
#include <fp_lib_table_lexer.h>
|
||||
#include <lib_id.h>
|
||||
#include <lib_table_lexer.h>
|
||||
#include <symbol_lib_table.h>
|
||||
#include <class_libentry.h>
|
||||
|
||||
#define OPT_SEP '|' ///< options separator character
|
||||
|
||||
using namespace FP_LIB_TABLE_T;
|
||||
using namespace LIB_TABLE_T;
|
||||
|
||||
|
||||
static const wxChar global_tbl_name[] = wxT( "sym-lib-table" );
|
||||
@ -63,7 +63,7 @@ SYMBOL_LIB_TABLE::SYMBOL_LIB_TABLE( SYMBOL_LIB_TABLE* aFallBackTable ) :
|
||||
}
|
||||
|
||||
|
||||
void SYMBOL_LIB_TABLE::Parse( FP_LIB_TABLE_LEXER* in ) throw()
|
||||
void SYMBOL_LIB_TABLE::Parse( LIB_TABLE_LEXER* in ) throw()
|
||||
{
|
||||
T tok;
|
||||
|
||||
@ -243,16 +243,16 @@ LIB_ALIAS* SYMBOL_LIB_TABLE::LoadSymbol( const wxString& aNickname, const wxStri
|
||||
if( ret )
|
||||
{
|
||||
// remove "const"-ness, I really do want to set nickname without
|
||||
// having to copy the FPID and its two strings, twice each.
|
||||
FPID& fpid = (FPID&) ret->GetPart()->GetFPID();
|
||||
// having to copy the LIB_ID and its two strings, twice each.
|
||||
LIB_ID& id = (LIB_ID&) ret->GetPart()->GetLibId();
|
||||
|
||||
// Catch any misbehaving plugin, which should be setting internal alias name properly:
|
||||
wxASSERT( aAliasName == (wxString) fpid.GetFootprintName() );
|
||||
wxASSERT( aAliasName == (wxString) id.GetLibItemName() );
|
||||
|
||||
// and clearing nickname
|
||||
wxASSERT( !fpid.GetLibNickname().size() );
|
||||
wxASSERT( !id.GetLibNickname().size() );
|
||||
|
||||
fpid.SetLibNickname( row->GetNickName() );
|
||||
id.SetLibNickname( row->GetNickName() );
|
||||
}
|
||||
|
||||
return ret;
|
||||
@ -270,7 +270,7 @@ SYMBOL_LIB_TABLE::SAVE_T SYMBOL_LIB_TABLE::SaveSymbol( const wxString& aNickname
|
||||
// Try loading the footprint to see if it already exists, caller wants overwrite
|
||||
// protection, which is atypical, not the default.
|
||||
|
||||
wxString name = aSymbol->GetFPID().GetFootprintName();
|
||||
wxString name = aSymbol->GetLibId().GetLibItemName();
|
||||
|
||||
std::unique_ptr< LIB_ALIAS > symbol( row->plugin->LoadSymbol( row->GetFullURI( true ),
|
||||
name,
|
||||
@ -328,11 +328,11 @@ void SYMBOL_LIB_TABLE::CreateSymbolLib( const wxString& aNickname )
|
||||
}
|
||||
|
||||
|
||||
LIB_ALIAS* SYMBOL_LIB_TABLE::LoadSymbolWithOptionalNickname( const FPID& aFootprintId )
|
||||
LIB_ALIAS* SYMBOL_LIB_TABLE::LoadSymbolWithOptionalNickname( const LIB_ID& aLibId )
|
||||
throw( IO_ERROR, PARSE_ERROR, boost::interprocess::lock_exception )
|
||||
{
|
||||
wxString nickname = aFootprintId.GetLibNickname();
|
||||
wxString name = aFootprintId.GetFootprintName();
|
||||
wxString nickname = aLibId.GetLibNickname();
|
||||
wxString name = aLibId.GetLibItemName();
|
||||
|
||||
if( nickname.size() )
|
||||
{
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include <sch_io_mgr.h>
|
||||
|
||||
class LIB_PART;
|
||||
class IO_ERROR;
|
||||
|
||||
/**
|
||||
* Class SYMBOL_LIB_TABLE_ROW
|
||||
@ -102,7 +101,7 @@ class SYMBOL_LIB_TABLE : public LIB_TABLE
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void Parse( FP_LIB_TABLE_LEXER* aLexer ) throw() override;
|
||||
virtual void Parse( LIB_TABLE_LEXER* aLexer ) throw() override;
|
||||
|
||||
virtual void Format( OUTPUTFORMATTER* out, int nestLevel ) const throw() override;
|
||||
|
||||
@ -254,7 +253,7 @@ public:
|
||||
* is thrown in the case where aId cannot be found.
|
||||
* @throw PARSE_ERROR if @a atId is not parsed OK.
|
||||
*/
|
||||
LIB_ALIAS* LoadSymbolWithOptionalNickname( const FPID& aId )
|
||||
LIB_ALIAS* LoadSymbolWithOptionalNickname( const LIB_ID& aId )
|
||||
throw( IO_ERROR, PARSE_ERROR, boost::interprocess::lock_exception );
|
||||
|
||||
/**
|
||||
|
@ -31,7 +31,6 @@
|
||||
|
||||
class MODULE;
|
||||
class FP_TBL_MODEL;
|
||||
class IO_ERROR;
|
||||
|
||||
/**
|
||||
* Class FP_LIB_TABLE_ROW
|
||||
@ -104,7 +103,7 @@ class FP_LIB_TABLE : public LIB_TABLE
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void Parse( FP_LIB_TABLE_LEXER* aLexer ) throw() override;
|
||||
virtual void Parse( LIB_TABLE_LEXER* aLexer ) throw() override;
|
||||
|
||||
virtual void Format( OUTPUTFORMATTER* out, int nestLevel ) const throw() override;
|
||||
|
||||
@ -234,7 +233,7 @@ public:
|
||||
* is thrown in the case where aFootprintName cannot be found.
|
||||
* @throw PARSE_ERROR if @a aFootprintId is not parsed OK.
|
||||
*/
|
||||
MODULE* FootprintLoadWithOptionalNickname( const FPID& aFootprintId )
|
||||
MODULE* FootprintLoadWithOptionalNickname( const LIB_ID& aFootprintId )
|
||||
throw( IO_ERROR, PARSE_ERROR, boost::interprocess::lock_exception );
|
||||
|
||||
/**
|
||||
|
198
include/fpid.h
198
include/fpid.h
@ -1,198 +0,0 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2010-2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2010 KiCad Developers, see change_log.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
|
||||
*/
|
||||
|
||||
#ifndef _FPID_H_
|
||||
#define _FPID_H_
|
||||
|
||||
#include <richio.h>
|
||||
#include <utf8.h>
|
||||
|
||||
/**
|
||||
* Class FPID
|
||||
* is a Logical Footprint ID and consists of various portions much like a URI.
|
||||
* It is a container for the separated portions of a logical footprint id so they
|
||||
* can be accessed individually. The various portions of an FPID are:
|
||||
* logicalLibraryName (nick name), footprint name, and revision. The logical library
|
||||
* name and the footprint name are mandatory. The revision is optional and currently is
|
||||
* not used.
|
||||
*
|
||||
* Example FPID string:
|
||||
* "smt:R_0805/rev0".
|
||||
*
|
||||
* <p>
|
||||
* <ul>
|
||||
* <li> "smt" is the logical library name used to look up library information saved in the
|
||||
* #FP_LIB_TABLE.
|
||||
* <li> "R" is the name of the footprint within the library.
|
||||
* <li> "rev0" is the revision, which is optional. If missing then its
|
||||
* / delimiter should also not be present. A revision must begin with
|
||||
* "rev" and be followed by at least one or more decimal digits.
|
||||
* </ul>
|
||||
*
|
||||
* @author Dick Hollenbeck
|
||||
*/
|
||||
class FPID
|
||||
{
|
||||
public:
|
||||
|
||||
FPID() {}
|
||||
|
||||
/**
|
||||
* Constructor FPID
|
||||
* takes \a aId string and parses it. A typical FPID string consists of a
|
||||
* library nickname followed by a footprint name.
|
||||
* e.g.: "smt:R_0805", or
|
||||
* e.g.: "mylib:R_0805"
|
||||
*
|
||||
* @param aId is a string to be parsed into the FPID object.
|
||||
*/
|
||||
FPID( const std::string& aId ) throw( PARSE_ERROR );
|
||||
|
||||
FPID( const wxString& aId ) throw( PARSE_ERROR );
|
||||
|
||||
/**
|
||||
* Function Parse
|
||||
* [re-]stuffs this FPID with the information from @a aId.
|
||||
*
|
||||
* @param aId is the string to populate the #FPID object.
|
||||
* @return int - minus 1 (i.e. -1) means success, >= 0 indicates the character offset into
|
||||
* aId at which an error was detected.
|
||||
*/
|
||||
int Parse( const UTF8& aId );
|
||||
|
||||
|
||||
/**
|
||||
* Function GetLibNickname
|
||||
* returns the logical library name portion of a FPID.
|
||||
*/
|
||||
const UTF8& GetLibNickname() const
|
||||
{
|
||||
return nickname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function SetLibNickname
|
||||
* overrides the logical footprint library name portion of the FPID to @a aNickname.
|
||||
* @return int - minus 1 (i.e. -1) means success, >= 0 indicates the character offset
|
||||
* into the parameter at which an error was detected, usually because it
|
||||
* contained '/' or ':'.
|
||||
*/
|
||||
int SetLibNickname( const UTF8& aNickname );
|
||||
|
||||
/**
|
||||
* Function GetFootprintName
|
||||
* returns the footprint name, i.e. footprintName.
|
||||
*/
|
||||
const UTF8& GetFootprintName() const { return footprint; }
|
||||
|
||||
/**
|
||||
* Function SetFootprintName
|
||||
* overrides the footprint name portion of the FPID to @a aFootprintName
|
||||
* @return int - minus 1 (i.e. -1) means success, >= 0 indicates the character offset
|
||||
* into the parameter at which an error was detected, usually because it
|
||||
* contained '/'.
|
||||
*/
|
||||
int SetFootprintName( const UTF8& aFootprintName );
|
||||
|
||||
int SetRevision( const UTF8& aRevision );
|
||||
|
||||
const UTF8& GetRevision() const { return revision; }
|
||||
|
||||
UTF8 GetFootprintNameAndRev() const;
|
||||
|
||||
/**
|
||||
* Function Format
|
||||
* returns the fully formatted text of the FPID.
|
||||
*/
|
||||
UTF8 Format() const;
|
||||
|
||||
/**
|
||||
* Function Format
|
||||
* returns a wxString in the proper format as an FPID for a combination of
|
||||
* aLibNickname, aFootprintName, and aRevision.
|
||||
*
|
||||
* @throw PARSE_ERROR if any of the pieces are illegal.
|
||||
static UTF8 Format( const UTF8& aLibNickname, const UTF8& aFootprintName,
|
||||
const UTF8& aRevision = "" )
|
||||
throw( PARSE_ERROR );
|
||||
*/
|
||||
|
||||
/**
|
||||
* Function IsValid
|
||||
* @return true is the #FPID is valid.
|
||||
*
|
||||
* A valid #FPID must have both the footprint library nickname and the footprint name
|
||||
* defined. The revision field is optional.
|
||||
*
|
||||
* @note A return value of true does not indicated that the #FPID is a valid #FP_LIB_TABLE
|
||||
* entry.
|
||||
*/
|
||||
bool IsValid() const { return !nickname.empty() && !footprint.empty(); }
|
||||
|
||||
/**
|
||||
* Function IsLegacy
|
||||
* @return true if the #FPID only has the #footprint name defined.
|
||||
*/
|
||||
bool IsLegacy() const { return nickname.empty() && !footprint.empty() && revision.empty(); }
|
||||
|
||||
/**
|
||||
* Function clear
|
||||
* clears the contents of the library nickname, footprint name, and revision strings.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* Function empty
|
||||
* @return a boolean true value if the FPID is empty. Otherwise return false.
|
||||
*/
|
||||
bool empty() const { return nickname.empty() && footprint.empty() && revision.empty(); }
|
||||
|
||||
/**
|
||||
* Function Compare
|
||||
* compares the contents of FPID objects by performing a std::string comparison of the
|
||||
* library nickname, footprint name, and revision strings respectively.
|
||||
*
|
||||
* @param aFPID is the FPID to compare against.
|
||||
* @return -1 if less than \a aFPID, 1 if greater than \a aFPID, and 0 if equal to \a aFPID.
|
||||
*/
|
||||
int compare( const FPID& aFPID ) const;
|
||||
|
||||
bool operator < ( const FPID& aFPID ) const { return this->compare( aFPID ) < 0; }
|
||||
bool operator > ( const FPID& aFPID ) const { return this->compare( aFPID ) > 0; }
|
||||
bool operator ==( const FPID& aFPID ) const { return this->compare( aFPID ) == 0; }
|
||||
bool operator !=( const FPID& aFPID ) const { return !(*this == aFPID); }
|
||||
|
||||
#if defined(DEBUG)
|
||||
static void Test();
|
||||
#endif
|
||||
|
||||
protected:
|
||||
UTF8 nickname; ///< The nickname of the footprint library or empty.
|
||||
UTF8 footprint; ///< The name of the footprint in the logical library.
|
||||
UTF8 revision; ///< The footprint revision.
|
||||
};
|
||||
|
||||
|
||||
#endif // _FPID_H_
|
216
include/lib_id.h
Normal file
216
include/lib_id.h
Normal file
@ -0,0 +1,216 @@
|
||||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2010-2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2012-2016 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2010-2016 KiCad Developers, see change_log.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
|
||||
*/
|
||||
|
||||
#ifndef _LIB_ID_H_
|
||||
#define _LIB_ID_H_
|
||||
|
||||
#include <richio.h>
|
||||
#include <utf8.h>
|
||||
|
||||
/**
|
||||
* Class LIB_ID
|
||||
*
|
||||
* is a logical library item identifier and consists of various portions much like a URI.
|
||||
* It consists of of triad of the library nickname, the name of the item in the library,
|
||||
* and an optional revision of the item. This is a generic library identifier that can be
|
||||
* used for any type of library that contains multiple named items such as footprint or
|
||||
* symbol libraries.
|
||||
*
|
||||
* Example LIB_ID string:
|
||||
* "smt:R_0805/rev0".
|
||||
*
|
||||
* <p>
|
||||
* <ul>
|
||||
* <li> "smt" is the logical library name used to look up library information saved in the
|
||||
* #LIB_TABLE.
|
||||
* <li> "R" is the name of the item within the library.
|
||||
* <li> "rev0" is the revision, which is optional. If missing then its
|
||||
* / delimiter should also not be present. A revision must begin with
|
||||
* "rev" and be followed by at least one or more decimal digits.
|
||||
* </ul>
|
||||
*
|
||||
* @author Dick Hollenbeck
|
||||
*/
|
||||
class LIB_ID
|
||||
{
|
||||
public:
|
||||
|
||||
LIB_ID() {}
|
||||
|
||||
/**
|
||||
* Constructor LIB_ID
|
||||
*
|
||||
* takes \a aId string and parses it. A typical LIB_ID string consists of a
|
||||
* library nickname followed by a library item name.
|
||||
* e.g.: "smt:R_0805", or
|
||||
* e.g.: "mylib:R_0805", or
|
||||
* e.g.: "ttl:7400"
|
||||
*
|
||||
* @param aId is a string to be parsed into the LIB_ID object.
|
||||
*/
|
||||
LIB_ID( const std::string& aId ) throw( PARSE_ERROR );
|
||||
|
||||
LIB_ID( const wxString& aId ) throw( PARSE_ERROR );
|
||||
|
||||
/**
|
||||
* Function Parse
|
||||
*
|
||||
* [re-]stuffs this LIB_ID with the information from @a aId.
|
||||
*
|
||||
* @param aId is the string to populate the #LIB_ID object.
|
||||
*
|
||||
* @return int - minus 1 (i.e. -1) means success, >= 0 indicates the character offset into
|
||||
* aId at which an error was detected.
|
||||
*/
|
||||
int Parse( const UTF8& aId );
|
||||
|
||||
|
||||
/**
|
||||
* Function GetLibNickname
|
||||
*
|
||||
* returns the logical library name portion of a LIB_ID.
|
||||
*/
|
||||
const UTF8& GetLibNickname() const
|
||||
{
|
||||
return nickname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function SetLibNickname
|
||||
*
|
||||
* overrides the logical library name portion of the LIB_ID to @a aNickname.
|
||||
*
|
||||
* @return int - minus 1 (i.e. -1) means success, >= 0 indicates the character offset
|
||||
* into the parameter at which an error was detected, usually because it
|
||||
* contained '/' or ':'.
|
||||
*/
|
||||
int SetLibNickname( const UTF8& aNickname );
|
||||
|
||||
/**
|
||||
* Function GetLibItemName
|
||||
*
|
||||
* @return the library item name, i.e. footprintName.
|
||||
*/
|
||||
const UTF8& GetLibItemName() const { return item_name; }
|
||||
|
||||
/**
|
||||
* Function SetLibItemName
|
||||
*
|
||||
* overrides the library item name portion of the LIB_ID to @a aLibItemName
|
||||
*
|
||||
* @return int - minus 1 (i.e. -1) means success, >= 0 indicates the character offset
|
||||
* into the parameter at which an error was detected, usually because it
|
||||
* contained '/'.
|
||||
*/
|
||||
int SetLibItemName( const UTF8& aLibItemName );
|
||||
|
||||
int SetRevision( const UTF8& aRevision );
|
||||
|
||||
const UTF8& GetRevision() const { return revision; }
|
||||
|
||||
UTF8 GetLibItemNameAndRev() const;
|
||||
|
||||
/**
|
||||
* Function Format
|
||||
*
|
||||
* @return the fully formatted text of the LIB_ID.
|
||||
*/
|
||||
UTF8 Format() const;
|
||||
|
||||
/**
|
||||
* Function Format
|
||||
*
|
||||
* @return a string in the proper format as an LIB_ID for a combination of
|
||||
* aLibNickname, aLibItemName, and aRevision.
|
||||
*
|
||||
* @throw PARSE_ERROR if any of the pieces are illegal.
|
||||
static UTF8 Format( const UTF8& aLibNickname, const UTF8& aLibItemName,
|
||||
const UTF8& aRevision = "" )
|
||||
throw( PARSE_ERROR );
|
||||
*/
|
||||
|
||||
/**
|
||||
* Function IsValid
|
||||
*
|
||||
* @return true is the #LIB_ID is valid.
|
||||
*
|
||||
* A valid #LIB_ID must have both the library nickname and the library item name defined.
|
||||
* The revision field is optional.
|
||||
*
|
||||
* @note A return value of true does not indicated that the #LIB_ID is a valid #LIB_TABLE
|
||||
* entry.
|
||||
*/
|
||||
bool IsValid() const { return !nickname.empty() && !item_name.empty(); }
|
||||
|
||||
/**
|
||||
* Function IsLegacy
|
||||
*
|
||||
* @return true if the #LIB_ID only has the #item_name name defined.
|
||||
*/
|
||||
bool IsLegacy() const { return nickname.empty() && !item_name.empty() && revision.empty(); }
|
||||
|
||||
/**
|
||||
* Function clear
|
||||
*
|
||||
* clears the contents of the library nickname, library entry name, and revision strings.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* Function empty
|
||||
*
|
||||
* @return a boolean true value if the LIB_ID is empty. Otherwise return false.
|
||||
*/
|
||||
bool empty() const { return nickname.empty() && item_name.empty() && revision.empty(); }
|
||||
|
||||
/**
|
||||
* Function Compare
|
||||
*
|
||||
* compares the contents of LIB_ID objects by performing a std::string comparison of the
|
||||
* library nickname, library entry name, and revision strings respectively.
|
||||
*
|
||||
* @param aLibId is the LIB_ID to compare against.
|
||||
*
|
||||
* @return -1 if less than \a aLibId, 1 if greater than \a aLibId, and 0 if equal to \a aLibId.
|
||||
*/
|
||||
int compare( const LIB_ID& aLIB_ID ) const;
|
||||
|
||||
bool operator < ( const LIB_ID& aLibId ) const { return this->compare( aLibId ) < 0; }
|
||||
bool operator > ( const LIB_ID& aLibId ) const { return this->compare( aLibId ) > 0; }
|
||||
bool operator ==( const LIB_ID& aLibId ) const { return this->compare( aLibId ) == 0; }
|
||||
bool operator !=( const LIB_ID& aLibId ) const { return !(*this == aLibId); }
|
||||
|
||||
#if defined(DEBUG)
|
||||
static void Test();
|
||||
#endif
|
||||
|
||||
protected:
|
||||
UTF8 nickname; ///< The nickname of the library or empty.
|
||||
UTF8 item_name; ///< The name of the entry in the logical library.
|
||||
UTF8 revision; ///< The revision of the entry.
|
||||
};
|
||||
|
||||
|
||||
#endif // _LIB_ID_H_
|
@ -40,8 +40,8 @@
|
||||
#define FP_LATE_ENVVAR 1 ///< late=1/early=0 environment variable expansion
|
||||
|
||||
class OUTPUTFORMATTER;
|
||||
class FP_LIB_TABLE_LEXER;
|
||||
class FPID;
|
||||
class LIB_TABLE_LEXER;
|
||||
class LIB_ID;
|
||||
class LIB_TABLE_ROW;
|
||||
class IO_ERROR;
|
||||
|
||||
@ -181,7 +181,7 @@ public:
|
||||
void Format( OUTPUTFORMATTER* out, int nestLevel ) const
|
||||
throw( IO_ERROR, boost::interprocess::lock_exception );
|
||||
|
||||
static void Parse( std::unique_ptr< LIB_TABLE_ROW >& aRow, FP_LIB_TABLE_LEXER* in )
|
||||
static void Parse( std::unique_ptr< LIB_TABLE_ROW >& aRow, LIB_TABLE_LEXER* in )
|
||||
throw( IO_ERROR, PARSE_ERROR );
|
||||
|
||||
LIB_TABLE_ROW* clone() const
|
||||
@ -279,7 +279,7 @@ class LIB_TABLE : public PROJECT::_ELEM
|
||||
|
||||
public:
|
||||
|
||||
virtual void Parse( FP_LIB_TABLE_LEXER* aLexer ) throw() = 0;
|
||||
virtual void Parse( LIB_TABLE_LEXER* aLexer ) throw() = 0;
|
||||
|
||||
virtual void Format( OUTPUTFORMATTER* out, int nestLevel ) const throw() = 0;
|
||||
|
||||
|
@ -2,8 +2,8 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2008-2011 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2008-2016 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 1992-2016 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
|
||||
@ -57,7 +57,7 @@ class BOARD_DESIGN_SETTINGS;
|
||||
class ZONE_SETTINGS;
|
||||
class PCB_PLOT_PARAMS;
|
||||
class FP_LIB_TABLE;
|
||||
class FPID;
|
||||
class LIB_ID;
|
||||
|
||||
/**
|
||||
* class PCB_BASE_FRAME
|
||||
@ -89,13 +89,13 @@ protected:
|
||||
* Function loadFootprint
|
||||
* attempts to load \a aFootprintId from the footprint library table.
|
||||
*
|
||||
* @param aFootprintId is the #FPID of component footprint to load.
|
||||
* @param aFootprintId is the #LIB_ID of component footprint to load.
|
||||
* @return the #MODULE if found or NULL if \a aFootprintId not found in any of the
|
||||
* libraries in the table returned from #Prj().PcbFootprintLibs().
|
||||
* @throw IO_ERROR if an I/O error occurs or a #PARSE_ERROR if a file parsing error
|
||||
* occurs while reading footprint library files.
|
||||
*/
|
||||
MODULE* loadFootprint( const FPID& aFootprintId )
|
||||
MODULE* loadFootprint( const LIB_ID& aFootprintId )
|
||||
throw( IO_ERROR, PARSE_ERROR, boost::interprocess::lock_exception );
|
||||
|
||||
public:
|
||||
@ -114,11 +114,11 @@ public:
|
||||
* Function LoadFootprint
|
||||
* attempts to load \a aFootprintId from the footprint library table.
|
||||
*
|
||||
* @param aFootprintId is the #FPID of component footprint to load.
|
||||
* @param aFootprintId is the #LIB_ID of component footprint to load.
|
||||
* @return the #MODULE if found or NULL if \a aFootprintId not found in any of the
|
||||
* libraries in table returned from #Prj().PcbFootprintLibs().
|
||||
*/
|
||||
MODULE* LoadFootprint( const FPID& aFootprintId );
|
||||
MODULE* LoadFootprint( const LIB_ID& aFootprintId );
|
||||
|
||||
/**
|
||||
* Function GetBoardBoundingBox
|
||||
|
@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2009-2014 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
|
||||
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2016 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
|
||||
@ -66,7 +66,7 @@ class cmp
|
||||
public:
|
||||
wxString m_Ref;
|
||||
wxString m_Val;
|
||||
FPID m_fpid;
|
||||
LIB_ID m_fpid;
|
||||
int m_Id;
|
||||
int m_CmpCount;
|
||||
};
|
||||
@ -173,7 +173,7 @@ void PCB_EDIT_FRAME::RecreateBOMFileFromBoard( wxCommandEvent& aEvent )
|
||||
|
||||
msg << current->m_Id << wxT( ";\"" );
|
||||
msg << current->m_Ref << wxT( "\";\"" );
|
||||
msg << FROM_UTF8( current->m_fpid.GetFootprintName().c_str() ) << wxT( "\";" );
|
||||
msg << FROM_UTF8( current->m_fpid.GetLibItemName().c_str() ) << wxT( "\";" );
|
||||
msg << current->m_CmpCount << wxT( ";\"" );
|
||||
msg << current->m_Val << wxT( "\";;;\n" );
|
||||
fprintf( fp_bom, "%s", TO_UTF8( msg ) );
|
||||
|
@ -2,7 +2,7 @@
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2016 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
|
||||
@ -37,7 +37,7 @@
|
||||
#include <layers_id_colors_and_visibility.h> // ALL_LAYERS definition.
|
||||
#include <class_board_item.h>
|
||||
#include <board_item_container.h>
|
||||
#include <fpid.h>
|
||||
#include <lib_id.h>
|
||||
|
||||
#include <class_text_mod.h>
|
||||
#include <PolyLine.h>
|
||||
@ -144,8 +144,8 @@ public:
|
||||
double GetOrientationDegrees() const { return m_Orient/10.0; }
|
||||
double GetOrientationRadians() const { return m_Orient*M_PI/1800; }
|
||||
|
||||
const FPID& GetFPID() const { return m_fpid; }
|
||||
void SetFPID( const FPID& aFPID ) { m_fpid = aFPID; }
|
||||
const LIB_ID& GetFPID() const { return m_fpid; }
|
||||
void SetFPID( const LIB_ID& aFPID ) { m_fpid = aFPID; }
|
||||
|
||||
const wxString& GetDescription() const { return m_Doc; }
|
||||
void SetDescription( const wxString& aDoc ) { m_Doc = aDoc; }
|
||||
@ -650,7 +650,7 @@ private:
|
||||
wxPoint m_Pos; ///< Position of module on the board in internal units.
|
||||
TEXTE_MODULE* m_Reference; ///< Component reference designator value (U34, R18..)
|
||||
TEXTE_MODULE* m_Value; ///< Component value (74LS00, 22K..)
|
||||
FPID m_fpid; ///< The #FPID of the MODULE.
|
||||
LIB_ID m_fpid; ///< The #LIB_ID of the MODULE.
|
||||
int m_Attributs; ///< Flag bits ( see Mod_Attribut )
|
||||
int m_ModuleStatus; ///< For autoplace: flags (LOCKED, AUTOPLACED)
|
||||
EDA_RECT m_BoundaryBox; ///< Bounding box : coordinates on board, real orientation.
|
||||
|
@ -9,7 +9,7 @@
|
||||
*
|
||||
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
||||
* Copyright (C) 2015 Dick Hollenbeck, dick@softplc.com
|
||||
* Copyright (C) 2008-2015 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2008-2016 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2004-2016 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@ -493,7 +493,7 @@ void DIALOG_MODULE_MODULE_EDITOR::OnOkClick( wxCommandEvent& event )
|
||||
|
||||
// Init footprint name in library
|
||||
if( ! footprintName.IsEmpty() )
|
||||
m_currentModule->SetFPID( FPID( footprintName ) );
|
||||
m_currentModule->SetFPID( LIB_ID( footprintName ) );
|
||||
|
||||
// Init Fields:
|
||||
TEXTE_MODULE& reference = m_currentModule->Reference();
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user