Convert footprint definitions from wxString to FPID.
* Use FPID instead of wxString in MODULE object. * Use FPID instead of wxString when loading and saving files. * Use FPID in COMPONENT object. * Add wxString helper functions and comparison operators to FPID. * Add fp_lib token to pcb and netlist file formats. * Add code to load and save FPIDs to pcb file format. * Fix segfault when deleting invalid footprint library tables in Pcbnew in non footprint library table build. * Fix bug when counting the number of mod files in EDA_APP::SetFootprintLibTablePath();
This commit is contained in:
parent
9ab7c18f46
commit
230c5f8f5a
|
@ -619,7 +619,7 @@ void EDA_APP::SetDefaultSearchPaths( void )
|
|||
}
|
||||
}
|
||||
|
||||
#if 1 && defined( DEBUG )
|
||||
#if 0 && defined( DEBUG )
|
||||
wxLogDebug( wxT( "Library search paths:" ) );
|
||||
|
||||
for( unsigned i = 0; i < m_libSearchPaths.GetCount(); i++ )
|
||||
|
@ -1188,7 +1188,7 @@ bool EDA_APP::SetFootprintLibTablePath()
|
|||
for( unsigned i = 0; i < GetLibraryPathList().GetCount(); i++ )
|
||||
{
|
||||
unsigned cnt = wxDir::GetAllFiles( GetLibraryPathList()[i], &tmp, wxT( "*.mod" ),
|
||||
wxDIR_DEFAULT & ~wxDIR_HIDDEN );
|
||||
wxDIR_FILES );
|
||||
|
||||
if( cnt > modFileCount )
|
||||
{
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <memory>
|
||||
#include <wx/wx.h> // _()
|
||||
|
||||
#include <macros.h> // TO_UTF8()
|
||||
#include <fpid.h>
|
||||
|
||||
|
||||
|
@ -185,6 +186,23 @@ FPID::FPID( const std::string& aId ) throw( PARSE_ERROR )
|
|||
}
|
||||
|
||||
|
||||
FPID::FPID( const wxString& aId ) throw( PARSE_ERROR )
|
||||
{
|
||||
std::string id = TO_UTF8( aId );
|
||||
|
||||
int offset = Parse( id );
|
||||
|
||||
if( offset != -1 )
|
||||
{
|
||||
THROW_PARSE_ERROR( _( "Illegal character found in FPID string" ),
|
||||
wxString::FromUTF8( id.c_str() ),
|
||||
id.c_str(),
|
||||
0,
|
||||
offset );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int FPID::SetLibNickname( const std::string& aLogical )
|
||||
{
|
||||
int offset = okLogical( aLogical );
|
||||
|
@ -198,6 +216,12 @@ int FPID::SetLibNickname( const std::string& aLogical )
|
|||
}
|
||||
|
||||
|
||||
int FPID::SetLibNickname( const wxString& aLogical )
|
||||
{
|
||||
return SetLibNickname( std::string( TO_UTF8( aLogical ) ) );
|
||||
}
|
||||
|
||||
|
||||
int FPID::SetFootprintName( const std::string& aFootprintName )
|
||||
{
|
||||
int separation = int( aFootprintName.find_first_of( "/" ) );
|
||||
|
@ -216,6 +240,12 @@ int FPID::SetFootprintName( const std::string& aFootprintName )
|
|||
}
|
||||
|
||||
|
||||
int FPID::SetFootprintName( const wxString& aFootprintName )
|
||||
{
|
||||
return SetFootprintName( std::string( TO_UTF8( aFootprintName ) ) );
|
||||
}
|
||||
|
||||
|
||||
int FPID::SetRevision( const std::string& aRevision )
|
||||
{
|
||||
int offset = okRevision( aRevision );
|
||||
|
|
|
@ -12,6 +12,7 @@ fields
|
|||
footprint
|
||||
footprints
|
||||
fp
|
||||
fp_lib
|
||||
lib
|
||||
libpart
|
||||
libparts
|
||||
|
|
|
@ -72,6 +72,7 @@ font
|
|||
fp_arc
|
||||
fp_circle
|
||||
fp_curve
|
||||
fp_lib
|
||||
fp_line
|
||||
fp_poly
|
||||
fp_text
|
||||
|
|
|
@ -165,7 +165,7 @@ void CVPCB_MAINFRAME::AssocieModule( wxCommandEvent& event )
|
|||
bool found = false;
|
||||
m_ListCmp->SetSelection( ii++, true );
|
||||
|
||||
if( !component->GetFootprintName().IsEmpty() )
|
||||
if( !component->GetFPID().empty() )
|
||||
continue;
|
||||
|
||||
BOOST_FOREACH( FOOTPRINT_ALIAS& alias, aliases )
|
||||
|
|
|
@ -342,7 +342,7 @@ void CVPCB_MAINFRAME::ToFirstNA( wxCommandEvent& event )
|
|||
|
||||
for( unsigned jj = selection+1; jj < m_netlist.GetCount(); jj++ )
|
||||
{
|
||||
if( m_netlist.GetComponent( jj )->GetFootprintName().IsEmpty() )
|
||||
if( m_netlist.GetComponent( jj )->GetFPID().empty() )
|
||||
{
|
||||
m_ListCmp->SetSelection( wxNOT_FOUND, false ); // Remove all selections
|
||||
m_ListCmp->SetSelection( jj );
|
||||
|
@ -368,7 +368,7 @@ void CVPCB_MAINFRAME::ToPreviousNA( wxCommandEvent& event )
|
|||
|
||||
for( int kk = selection-1; kk >= 0; kk-- )
|
||||
{
|
||||
if( m_netlist.GetComponent( kk )->GetFootprintName().IsEmpty() )
|
||||
if( m_netlist.GetComponent( kk )->GetFPID().empty() )
|
||||
{
|
||||
m_ListCmp->SetSelection( wxNOT_FOUND, false ); // Remove all selections
|
||||
m_ListCmp->SetSelection( kk );
|
||||
|
@ -405,7 +405,9 @@ void CVPCB_MAINFRAME::DelAssociations( wxCommandEvent& event )
|
|||
|
||||
for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
|
||||
{
|
||||
m_netlist.GetComponent( i )->SetFootprintName( wxEmptyString );
|
||||
FPID fpid;
|
||||
|
||||
m_netlist.GetComponent( i )->SetFPID( fpid );
|
||||
SetNewPkg( wxEmptyString );
|
||||
}
|
||||
|
||||
|
@ -521,7 +523,7 @@ void CVPCB_MAINFRAME::OnSelectComponent( wxListEvent& event )
|
|||
// selected footprint.
|
||||
if( FindFocus() == m_ListCmp || FindFocus() == m_LibraryList )
|
||||
{
|
||||
wxString module = component->GetFootprintName();
|
||||
wxString module = FROM_UTF8( component->GetFPID().GetFootprintName().c_str() );
|
||||
|
||||
bool found = false;
|
||||
|
||||
|
@ -781,8 +783,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 )->GetFootprintName() == wxT( "$noname" ) )
|
||||
m_netlist.GetComponent( ii )->SetFootprintName( wxEmptyString );
|
||||
if( m_netlist.GetComponent( ii )->GetFPID().GetFootprintName() == std::string( "$noname" ) )
|
||||
m_netlist.GetComponent( ii )->SetFPID( FPID( wxEmptyString ) );
|
||||
}
|
||||
|
||||
// Sort components by reference:
|
||||
|
@ -832,8 +834,7 @@ bool CVPCB_MAINFRAME::WriteComponentLinkFile( const wxString& aFullFileName )
|
|||
retval |= fprintf( outputFile, "TimeStamp = %s;\n", TO_UTF8( component->GetTimeStamp() ) );
|
||||
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->GetFootprintName() ) );
|
||||
retval |= fprintf( outputFile, "IdModule = %s;\n", component->GetFPID().Format().c_str() );
|
||||
retval |= fprintf( outputFile, "EndCmp\n" );
|
||||
}
|
||||
|
||||
|
@ -908,7 +909,7 @@ void CVPCB_MAINFRAME::BuildCmpListBox()
|
|||
msg.Printf( CMP_FORMAT, m_ListCmp->GetCount() + 1,
|
||||
GetChars( component->GetReference() ),
|
||||
GetChars( component->GetValue() ),
|
||||
GetChars( component->GetFootprintName() ) );
|
||||
GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) );
|
||||
m_ListCmp->m_ComponentList.Add( msg );
|
||||
}
|
||||
|
||||
|
|
|
@ -71,16 +71,16 @@ void CVPCB_MAINFRAME::SetNewPkg( const wxString& aFootprintName )
|
|||
|
||||
// Check to see if the component has already a footprint set.
|
||||
|
||||
hasFootprint = !(component->GetFootprintName().IsEmpty());
|
||||
hasFootprint = !component->GetFPID().empty();
|
||||
|
||||
component->SetFootprintName( aFootprintName );
|
||||
component->SetFPID( FPID( aFootprintName ) );
|
||||
|
||||
// create the new component description
|
||||
|
||||
description.Printf( CMP_FORMAT, componentIndex + 1,
|
||||
GetChars( component->GetReference() ),
|
||||
GetChars( component->GetValue() ),
|
||||
GetChars( component->GetFootprintName() ) );
|
||||
GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) );
|
||||
|
||||
// If the component hasn't had a footprint associated with it
|
||||
// it now has, so we decrement the count of components without
|
||||
|
@ -136,10 +136,10 @@ bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles()
|
|||
msg.Printf( CMP_FORMAT, m_ListCmp->GetCount() + 1,
|
||||
GetChars( component->GetReference() ),
|
||||
GetChars( component->GetValue() ),
|
||||
GetChars( component->GetFootprintName() ) );
|
||||
GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) );
|
||||
m_ListCmp->AppendLine( msg );
|
||||
|
||||
if( component->GetFootprintName().IsEmpty() )
|
||||
if( component->GetFPID().empty() )
|
||||
m_undefinedComponentCnt += 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -70,6 +70,8 @@ public:
|
|||
*/
|
||||
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.
|
||||
|
@ -98,6 +100,8 @@ public:
|
|||
*/
|
||||
int SetLibNickname( const std::string& aNickname );
|
||||
|
||||
int SetLibNickname( const wxString& aNickname );
|
||||
|
||||
/**
|
||||
* Function GetFootprintName
|
||||
* returns the footprint name, i.e. footprintName.
|
||||
|
@ -110,6 +114,8 @@ public:
|
|||
*/
|
||||
int SetFootprintName( const std::string& aFootprintName );
|
||||
|
||||
int SetFootprintName( const wxString& aFootprintName );
|
||||
|
||||
int SetRevision( const std::string& aRevision );
|
||||
|
||||
const std::string& GetRevision() const { return revision; }
|
||||
|
@ -175,7 +181,9 @@ public:
|
|||
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();
|
||||
|
|
|
@ -41,7 +41,7 @@ class cmp
|
|||
public:
|
||||
wxString m_Ref;
|
||||
wxString m_Val;
|
||||
wxString m_Pkg;
|
||||
FPID m_fpid;
|
||||
int m_Id;
|
||||
int m_CmpCount;
|
||||
};
|
||||
|
@ -100,6 +100,7 @@ void PCB_EDIT_FRAME::RecreateBOMFileFromBoard( wxCommandEvent& aEvent )
|
|||
cmp* comp = NULL;
|
||||
CmpList::iterator iter;
|
||||
int i = 1;
|
||||
|
||||
while( Module != NULL )
|
||||
{
|
||||
bool valExist = false;
|
||||
|
@ -109,7 +110,7 @@ void PCB_EDIT_FRAME::RecreateBOMFileFromBoard( wxCommandEvent& aEvent )
|
|||
{
|
||||
cmp* current = *iter;
|
||||
|
||||
if( (current->m_Val == Module->GetValue()) && (current->m_Pkg == Module->GetLibRef()) )
|
||||
if( (current->m_Val == Module->GetValue()) && (current->m_fpid == Module->GetFPID()) )
|
||||
{
|
||||
current->m_Ref.Append( wxT( ", " ), 1 );
|
||||
current->m_Ref.Append( Module->GetReference() );
|
||||
|
@ -127,7 +128,7 @@ void PCB_EDIT_FRAME::RecreateBOMFileFromBoard( wxCommandEvent& aEvent )
|
|||
comp->m_Id = i++;
|
||||
comp->m_Val = Module->GetValue();
|
||||
comp->m_Ref = Module->GetReference();
|
||||
comp->m_Pkg = Module->GetLibRef();
|
||||
comp->m_fpid = Module->GetFPID();
|
||||
comp->m_CmpCount = 1;
|
||||
list.Append( comp );
|
||||
}
|
||||
|
@ -145,7 +146,7 @@ void PCB_EDIT_FRAME::RecreateBOMFileFromBoard( wxCommandEvent& aEvent )
|
|||
|
||||
msg << current->m_Id << wxT( ";\"" );
|
||||
msg << current->m_Ref << wxT( "\";\"" );
|
||||
msg << current->m_Pkg << wxT( "\";" );
|
||||
msg << FROM_UTF8( current->m_fpid.Format().c_str() ) << wxT( "\";" );
|
||||
msg << current->m_CmpCount << wxT( ";\"" );
|
||||
msg << current->m_Val << wxT( "\";;;\n" );
|
||||
fprintf( FichBom, "%s", TO_UTF8( msg ) );
|
||||
|
|
|
@ -2374,7 +2374,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets,
|
|||
msg.Printf( _( "Checking netlist component footprint \"%s:%s:%s\".\n" ),
|
||||
GetChars( component->GetReference() ),
|
||||
GetChars( component->GetTimeStamp() ),
|
||||
GetChars( component->GetFootprintName() ) );
|
||||
GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) );
|
||||
aReporter->Report( msg );
|
||||
}
|
||||
|
||||
|
@ -2392,7 +2392,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets,
|
|||
msg.Printf( _( "Adding new component \"%s:%s\" footprint \"%s\".\n" ),
|
||||
GetChars( component->GetReference() ),
|
||||
GetChars( component->GetTimeStamp() ),
|
||||
GetChars( component->GetFootprintName() ) );
|
||||
GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) );
|
||||
|
||||
if( aReporter->ReportWarnings() )
|
||||
aReporter->Report( msg );
|
||||
|
@ -2403,7 +2403,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets,
|
|||
"footprint \"%s\".\n" ),
|
||||
GetChars( component->GetReference() ),
|
||||
GetChars( component->GetTimeStamp() ),
|
||||
GetChars( component->GetFootprintName() ) );
|
||||
GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) );
|
||||
|
||||
if( aReporter->ReportErrors() )
|
||||
aReporter->Report( msg );
|
||||
|
@ -2423,8 +2423,8 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets,
|
|||
else // An existing footprint.
|
||||
{
|
||||
// Test for footprint change.
|
||||
if( !component->GetFootprintName().IsEmpty() &&
|
||||
footprint->GetLibRef() != component->GetFootprintName() )
|
||||
if( !component->GetFPID().empty() &&
|
||||
footprint->GetFPID() != component->GetFPID() )
|
||||
{
|
||||
if( aNetlist.GetReplaceFootprints() )
|
||||
{
|
||||
|
@ -2436,8 +2436,8 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets,
|
|||
"\"%s\".\n" ),
|
||||
GetChars( footprint->GetReference() ),
|
||||
GetChars( footprint->GetPath() ),
|
||||
GetChars( footprint->GetLibRef() ),
|
||||
GetChars( component->GetFootprintName() ) );
|
||||
GetChars( FROM_UTF8( footprint->GetFPID().Format().c_str() ) ),
|
||||
GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) );
|
||||
|
||||
if( aReporter->ReportWarnings() )
|
||||
aReporter->Report( msg );
|
||||
|
@ -2448,7 +2448,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets,
|
|||
"footprint \"%s\".\n" ),
|
||||
GetChars( footprint->GetReference() ),
|
||||
GetChars( footprint->GetPath() ),
|
||||
GetChars( component->GetFootprintName() ) );
|
||||
GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) );
|
||||
|
||||
if( aReporter->ReportErrors() )
|
||||
aReporter->Report( msg );
|
||||
|
@ -2679,7 +2679,7 @@ void BOARD::ReplaceNetlist( NETLIST& aNetlist, bool aDeleteSinglePadNets,
|
|||
msg.Printf( _( "** Error: Component \"%s\" pad <%s> not found in footprint \"%s\" **\n" ),
|
||||
GetChars( component->GetReference() ),
|
||||
GetChars( padname ),
|
||||
GetChars( footprint->GetLibRef() ) );
|
||||
footprint->GetFPID().Format().c_str() );
|
||||
aReporter->Report( msg );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ MODULE::MODULE( const MODULE& aModule ) :
|
|||
BOARD_ITEM( aModule )
|
||||
{
|
||||
m_Pos = aModule.m_Pos;
|
||||
m_LibRef = aModule.m_LibRef;
|
||||
m_fpid = aModule.m_fpid;
|
||||
m_Layer = aModule.m_Layer;
|
||||
m_Attributs = aModule.m_Attributs;
|
||||
m_ModuleStatus = aModule.m_ModuleStatus;
|
||||
|
@ -201,7 +201,7 @@ void MODULE::Copy( MODULE* aModule )
|
|||
{
|
||||
m_Pos = aModule->m_Pos;
|
||||
m_Layer = aModule->m_Layer;
|
||||
m_LibRef = aModule->m_LibRef;
|
||||
m_fpid = aModule->m_fpid;
|
||||
m_Attributs = aModule->m_Attributs;
|
||||
m_ModuleStatus = aModule->m_ModuleStatus;
|
||||
m_Orient = aModule->m_Orient;
|
||||
|
@ -524,7 +524,7 @@ void MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
|
|||
}
|
||||
|
||||
aList.push_back( MSG_PANEL_ITEM( _( "Attrib" ), msg, BROWN ) );
|
||||
aList.push_back( MSG_PANEL_ITEM( _( "Module" ), m_LibRef, BLUE ) );
|
||||
aList.push_back( MSG_PANEL_ITEM( _( "Module" ), FROM_UTF8( m_fpid.Format().c_str() ), BLUE ) );
|
||||
|
||||
msg = _( "No 3D shape" );
|
||||
// Search the first active 3D shape in list
|
||||
|
|
|
@ -35,11 +35,13 @@
|
|||
#include <dlist.h>
|
||||
#include <layers_id_colors_and_visibility.h> // ALL_LAYERS definition.
|
||||
#include <class_board_item.h>
|
||||
#include <fpid.h>
|
||||
|
||||
#include <class_text_mod.h>
|
||||
#include <PolyLine.h>
|
||||
#include "zones.h"
|
||||
|
||||
|
||||
class LINE_READER;
|
||||
class EDA_3D_CANVAS;
|
||||
class S3D_MASTER;
|
||||
|
@ -117,8 +119,8 @@ public:
|
|||
void SetOrientation( double newangle );
|
||||
double GetOrientation() const { return m_Orient; }
|
||||
|
||||
const wxString& GetLibRef() const { return m_LibRef; }
|
||||
void SetLibRef( const wxString& aLibRef ) { m_LibRef = aLibRef; }
|
||||
const FPID& GetFPID() const { return m_fpid; }
|
||||
void SetFPID( const FPID& aFPID ) { m_fpid = aFPID; }
|
||||
|
||||
const wxString& GetDescription() const { return m_Doc; }
|
||||
void SetDescription( const wxString& aDoc ) { m_Doc = aDoc; }
|
||||
|
@ -509,7 +511,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..)
|
||||
wxString m_LibRef; ///< Name of the module in the library.
|
||||
FPID m_fpid; ///< The #FPID 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.
|
||||
|
|
|
@ -114,7 +114,7 @@ void DIALOG_MODULE_MODULE_EDITOR::initModeditProperties()
|
|||
m_ReferenceCtrl->SetValue( m_referenceCopy->GetText() );
|
||||
m_ValueCtrl->SetValue( m_valueCopy->GetText() );
|
||||
m_ValueCtrl->SetValue( m_valueCopy->GetText() );
|
||||
m_FootprintNameCtrl->SetValue( m_currentModule->GetLibRef() );
|
||||
m_FootprintNameCtrl->SetValue( FROM_UTF8( m_currentModule->GetFPID().Format().c_str() ) );
|
||||
|
||||
m_AttributsCtrl->SetItemToolTip( 0, _( "Use this attribute for most non SMD components" ) );
|
||||
m_AttributsCtrl->SetItemToolTip( 1,
|
||||
|
@ -396,7 +396,7 @@ void DIALOG_MODULE_MODULE_EDITOR::OnOkClick( wxCommandEvent& event )
|
|||
|
||||
// Init footprint name in library
|
||||
if( ! footprintName.IsEmpty() )
|
||||
m_currentModule->SetLibRef( footprintName );
|
||||
m_currentModule->SetFPID( FPID( footprintName ) );
|
||||
|
||||
// Init Fields:
|
||||
m_currentModule->Reference().Copy( m_referenceCopy );
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <wxBasePcbFrame.h>
|
||||
#include <base_units.h>
|
||||
#include <kicad_string.h>
|
||||
#include <macros.h>
|
||||
|
||||
#include <pcbnew.h>
|
||||
#include <wxPcbStruct.h>
|
||||
|
@ -156,7 +157,8 @@ void PCB_BASE_FRAME::ResetModuleTextSizes( const wxString & aFilter, bool aRef,
|
|||
|
||||
if( ! aFilter.IsEmpty() )
|
||||
{
|
||||
if( ! WildCompareString( aFilter, module->GetLibRef(), false ) )
|
||||
if( ! WildCompareString( aFilter, FROM_UTF8( module->GetFPID().Format().c_str() ),
|
||||
false ) )
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -1866,7 +1866,7 @@ MODULE* EAGLE_PLUGIN::makeModule( CPTREE& aPackage, const std::string& aPkgName
|
|||
{
|
||||
std::auto_ptr<MODULE> m( new MODULE( NULL ) );
|
||||
|
||||
m->SetLibRef( FROM_UTF8( aPkgName.c_str() ) );
|
||||
m->SetFPID( FPID( aPkgName ) );
|
||||
|
||||
opt_string description = aPackage.get_optional<std::string>( "description" );
|
||||
if( description )
|
||||
|
|
|
@ -861,14 +861,17 @@ static void CreateDevicesSection( FILE* aFile, BOARD* aPcb )
|
|||
{
|
||||
fprintf( aFile, "DEVICE \"%s\"\n", TO_UTF8( module->GetReference() ) );
|
||||
fprintf( aFile, "PART \"%s\"\n", TO_UTF8( module->GetValue() ) );
|
||||
fprintf( aFile, "PACKAGE \"%s\"\n", TO_UTF8( module->GetLibRef() ) );
|
||||
fprintf( aFile, "PACKAGE \"%s\"\n", module->GetFPID().Format().c_str() );
|
||||
|
||||
// The TYPE attribute is almost freeform
|
||||
const char* ty = "TH";
|
||||
|
||||
if( module->GetAttributes() & MOD_CMS )
|
||||
ty = "SMD";
|
||||
|
||||
if( module->GetAttributes() & MOD_VIRTUAL )
|
||||
ty = "VIRTUAL";
|
||||
|
||||
fprintf( aFile, "TYPE %s\n", ty );
|
||||
}
|
||||
|
||||
|
|
|
@ -472,7 +472,7 @@ int PCB_EDIT_FRAME::DoGenFootprintsPositionFile( const wxString& aFullFileName,
|
|||
wxPoint module_pos;
|
||||
const wxString& ref = list[ii].m_Reference;
|
||||
const wxString& val = list[ii].m_Value;
|
||||
const wxString& pkg = list[ii].m_Module->GetLibRef();
|
||||
const wxString& pkg = FROM_UTF8( list[ii].m_Module->GetFPID().Format().c_str() );
|
||||
sprintf( line, "%-8.8s %-16.16s %-16.16s",
|
||||
TO_UTF8( ref ), TO_UTF8( val ), TO_UTF8( pkg ) );
|
||||
|
||||
|
@ -614,7 +614,8 @@ bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool
|
|||
fputs( line, rptfile );
|
||||
sprintf( line, "value %s\n", EscapedUTF8( Module->GetValue() ).c_str() );
|
||||
fputs( line, rptfile );
|
||||
sprintf( line, "footprint %s\n", EscapedUTF8( Module->GetLibRef() ).c_str() );
|
||||
sprintf( line, "footprint %s\n",
|
||||
EscapedUTF8( FROM_UTF8( Module->GetFPID().Format().c_str() ) ).c_str() );
|
||||
fputs( line, rptfile );
|
||||
|
||||
msg = wxT( "attribut" );
|
||||
|
|
|
@ -241,7 +241,7 @@ void PCB_BASE_FRAME::GlobalChange_PadSettings( D_PAD* aPad,
|
|||
if( !aSameFootprints && (module != Module_Ref) )
|
||||
continue;
|
||||
|
||||
if( module->GetLibRef() != Module_Ref->GetLibRef() )
|
||||
if( module->GetFPID() != Module_Ref->GetFPID() )
|
||||
continue;
|
||||
|
||||
bool saveMe = false;
|
||||
|
@ -280,7 +280,7 @@ void PCB_BASE_FRAME::GlobalChange_PadSettings( D_PAD* aPad,
|
|||
if( !aSameFootprints && (module != Module_Ref) )
|
||||
continue;
|
||||
|
||||
if( module->GetLibRef() != Module_Ref->GetLibRef() )
|
||||
if( module->GetFPID() != Module_Ref->GetFPID() )
|
||||
continue;
|
||||
|
||||
// Erase module on screen
|
||||
|
|
|
@ -284,6 +284,7 @@ void KICAD_NETLIST_PARSER::parseComponent() throw( IO_ERROR, PARSE_ERROR )
|
|||
wxString ref;
|
||||
wxString value;
|
||||
wxString footprintName;
|
||||
wxString footprintLib;
|
||||
wxString library;
|
||||
wxString name;
|
||||
wxString pathtimestamp, timestamp;
|
||||
|
@ -314,6 +315,12 @@ void KICAD_NETLIST_PARSER::parseComponent() throw( IO_ERROR, PARSE_ERROR )
|
|||
NeedRIGHT();
|
||||
break;
|
||||
|
||||
case T_fp_lib:
|
||||
NeedSYMBOLorNUMBER();
|
||||
footprintLib = FROM_UTF8( CurText() );
|
||||
NeedRIGHT();
|
||||
break;
|
||||
|
||||
case T_libsource:
|
||||
// Read libsource
|
||||
while( (token = NextTok()) != T_RIGHT )
|
||||
|
@ -361,8 +368,12 @@ void KICAD_NETLIST_PARSER::parseComponent() throw( IO_ERROR, PARSE_ERROR )
|
|||
}
|
||||
}
|
||||
|
||||
FPID fpid;
|
||||
|
||||
fpid.SetFootprintName( footprintName );
|
||||
fpid.SetLibNickname( footprintName );
|
||||
pathtimestamp += timestamp;
|
||||
COMPONENT* component = new COMPONENT( footprintName, ref, value, pathtimestamp );
|
||||
COMPONENT* component = new COMPONENT( fpid, ref, value, pathtimestamp );
|
||||
component->SetName( name );
|
||||
component->SetLibrary( library );
|
||||
m_netlist->AddComponent( component );
|
||||
|
|
|
@ -868,7 +868,8 @@ void PCB_IO::format( MODULE* aModule, int aNestLevel ) const
|
|||
}
|
||||
}
|
||||
|
||||
m_out->Print( aNestLevel, "(module %s", m_out->Quotew( aModule->GetLibRef() ).c_str() );
|
||||
m_out->Print( aNestLevel, "(module %s",
|
||||
m_out->Quotes( aModule->GetFPID().GetFootprintName() ).c_str() );
|
||||
|
||||
if( aModule->IsLocked() )
|
||||
m_out->Print( 0, " locked" );
|
||||
|
@ -876,6 +877,10 @@ void PCB_IO::format( MODULE* aModule, int aNestLevel ) const
|
|||
if( aModule->IsPlaced() )
|
||||
m_out->Print( 0, " placed" );
|
||||
|
||||
if( !aModule->GetFPID().IsLegacy() )
|
||||
m_out->Print( 0, " (fp_lib %s)",
|
||||
m_out->Quotes( aModule->GetFPID().GetLibNickname() ).c_str() );
|
||||
|
||||
formatLayer( aModule );
|
||||
|
||||
if( !( m_ctl & CTL_OMIT_TSTAMPS ) )
|
||||
|
@ -1664,12 +1669,13 @@ void PCB_IO::FootprintSave( const wxString& aLibraryPath, const MODULE* aFootpri
|
|||
aLibraryPath.GetData() ) );
|
||||
}
|
||||
|
||||
std::string footprintName = TO_UTF8( aFootprint->GetLibRef() );
|
||||
std::string footprintName = aFootprint->GetFPID().GetFootprintName();
|
||||
|
||||
MODULE_MAP& mods = m_cache->GetModules();
|
||||
|
||||
// Quietly overwrite module and delete module file from path for any by same name.
|
||||
wxFileName fn( aLibraryPath, aFootprint->GetLibRef(), KiCadFootprintFileExtension );
|
||||
wxFileName fn( aLibraryPath, FROM_UTF8( aFootprint->GetFPID().GetFootprintName().c_str() ),
|
||||
KiCadFootprintFileExtension );
|
||||
|
||||
if( !fn.IsOk() )
|
||||
{
|
||||
|
|
|
@ -165,7 +165,10 @@ COMPONENT* LEGACY_NETLIST_READER::loadComponent( char* aText ) throw( PARSE_ERRO
|
|||
name = FROM_UTF8( text ).AfterFirst( wxChar( '=' ) ).BeforeLast( wxChar( '}' ) );
|
||||
}
|
||||
|
||||
COMPONENT* component = new COMPONENT( footprintName, reference, value, timeStamp );
|
||||
FPID fpid;
|
||||
|
||||
fpid.SetFootprintName( footprintName );
|
||||
COMPONENT* component = new COMPONENT( fpid, reference, value, timeStamp );
|
||||
component->SetName( name );
|
||||
m_netlist->AddComponent( component );
|
||||
return component;
|
||||
|
|
|
@ -278,7 +278,8 @@ void LEGACY_PLUGIN::loadAllSections( bool doAppend )
|
|||
{
|
||||
auto_ptr<MODULE> module( new MODULE( m_board ) );
|
||||
|
||||
module->SetLibRef( FROM_UTF8( StrPurge( line + SZ( "$MODULE" ) ) ) );
|
||||
std::string fpName = StrPurge( line + SZ( "$MODULE" ) );
|
||||
module->SetFPID( FPID( fpName ) );
|
||||
|
||||
LoadMODULE( module.get() );
|
||||
m_board->Add( module.release(), ADD_APPEND );
|
||||
|
@ -1001,7 +1002,7 @@ void LEGACY_PLUGIN::LoadMODULE( MODULE* aModule )
|
|||
{
|
||||
// There can be whitespace in the footprint name on some old libraries.
|
||||
// Grab everything after "Li" up to end of line:
|
||||
//aModule->SetLibRef( FROM_UTF8( StrPurge( line + SZ( "Li" ) ) ) );
|
||||
//aModule->SetFPID( FROM_UTF8( StrPurge( line + SZ( "Li" ) ) ) );
|
||||
}
|
||||
*/
|
||||
|
||||
|
@ -1130,9 +1131,8 @@ void LEGACY_PLUGIN::LoadMODULE( MODULE* aModule )
|
|||
}
|
||||
}
|
||||
|
||||
wxString msg = wxString::Format(
|
||||
wxT( "Missing '$EndMODULE' for MODULE '%s'" ),
|
||||
GetChars( aModule->GetLibRef() ) );
|
||||
wxString msg = wxString::Format( wxT( "Missing '$EndMODULE' for MODULE '%s'" ),
|
||||
aModule->GetFPID().GetFootprintName().c_str() );
|
||||
|
||||
THROW_IO_ERROR( msg );
|
||||
}
|
||||
|
@ -1186,7 +1186,7 @@ void LEGACY_PLUGIN::loadPAD( MODULE* aModule )
|
|||
padchar,
|
||||
padchar,
|
||||
m_reader->LineNumber(),
|
||||
GetChars( aModule->GetLibRef() )
|
||||
aModule->GetFPID().GetFootprintName().c_str()
|
||||
);
|
||||
THROW_IO_ERROR( m_error );
|
||||
}
|
||||
|
@ -1387,7 +1387,7 @@ void LEGACY_PLUGIN::loadMODULE_EDGE( MODULE* aModule )
|
|||
(unsigned char) line[1],
|
||||
(unsigned char) line[1],
|
||||
m_reader->LineNumber(),
|
||||
GetChars( aModule->GetLibRef() )
|
||||
aModule->GetFPID().GetFootprintName().c_str()
|
||||
);
|
||||
THROW_IO_ERROR( m_error );
|
||||
}
|
||||
|
@ -3399,7 +3399,9 @@ void LEGACY_PLUGIN::SaveMODULE( const MODULE* me ) const
|
|||
char statusTxt[3];
|
||||
double orient = me->GetOrientation();
|
||||
|
||||
fprintf( m_fp, "$MODULE %s\n", TO_UTF8( me->GetLibRef() ) );
|
||||
// Do not save full FPID. Only the footprint name. The legacy file format should
|
||||
// never support FPIDs.
|
||||
fprintf( m_fp, "$MODULE %s\n", me->GetFPID().GetFootprintName().c_str() );
|
||||
|
||||
statusTxt[0] = me->IsLocked() ? 'F' : '~';
|
||||
statusTxt[1] = me->IsPlaced() ? 'P' : '~';
|
||||
|
@ -3413,7 +3415,7 @@ void LEGACY_PLUGIN::SaveMODULE( const MODULE* me ) const
|
|||
me->GetTimeStamp(),
|
||||
statusTxt );
|
||||
|
||||
fprintf( m_fp, "Li %s\n", TO_UTF8( me->GetLibRef() ) );
|
||||
fprintf( m_fp, "Li %s\n", me->GetFPID().GetFootprintName().c_str() );
|
||||
|
||||
if( !me->GetDescription().IsEmpty() )
|
||||
{
|
||||
|
@ -3490,7 +3492,7 @@ void LEGACY_PLUGIN::SaveMODULE( const MODULE* me ) const
|
|||
|
||||
SaveModule3D( me );
|
||||
|
||||
fprintf( m_fp, "$EndMODULE %s\n", TO_UTF8( me->GetLibRef() ) );
|
||||
fprintf( m_fp, "$EndMODULE %s\n", me->GetFPID().GetFootprintName().c_str() );
|
||||
|
||||
CHECK_WRITE_ERROR();
|
||||
}
|
||||
|
@ -4037,7 +4039,7 @@ void FPL_CACHE::LoadModules( LINE_READER* aReader )
|
|||
std::string footprintName = StrPurge( line + SZ( "$MODULE" ) );
|
||||
|
||||
// set the footprint name first thing, so exceptions can use name.
|
||||
module->SetLibRef( FROM_UTF8( footprintName.c_str() ) );
|
||||
module->SetFPID( FPID( footprintName ) );
|
||||
|
||||
#if 0 && defined( DEBUG )
|
||||
printf( "%s\n", footprintName.c_str() );
|
||||
|
@ -4052,7 +4054,9 @@ void FPL_CACHE::LoadModules( LINE_READER* aReader )
|
|||
|
||||
MODULE* m = module.release(); // exceptions after this are not expected.
|
||||
|
||||
wxASSERT( footprintName == TO_UTF8( m->GetLibRef() ) );
|
||||
// Not sure why this is asserting on debug builds. The debugger shows the
|
||||
// strings are the same. If it's not really needed maybe it can be removed.
|
||||
// wxASSERT( footprintName == m->GetFPID().GetFootprintName() );
|
||||
|
||||
/*
|
||||
|
||||
|
@ -4099,7 +4103,7 @@ void FPL_CACHE::LoadModules( LINE_READER* aReader )
|
|||
{
|
||||
nameOK = true;
|
||||
|
||||
m->SetLibRef( FROM_UTF8( newName.c_str() ) );
|
||||
m->SetFPID( FPID( newName ) );
|
||||
std::pair<MODULE_ITER, bool> r = m_modules.insert( newName, m );
|
||||
|
||||
wxASSERT_MSG( r.second, wxT( "error doing cache insert using guaranteed unique name" ) );
|
||||
|
@ -4278,7 +4282,7 @@ void LEGACY_PLUGIN::FootprintSave( const wxString& aLibraryPath, const MODULE* a
|
|||
THROW_IO_ERROR( wxString::Format( _( "Library <%s> is read only" ), aLibraryPath.GetData() ) );
|
||||
}
|
||||
|
||||
std::string footprintName = TO_UTF8( aFootprint->GetLibRef() );
|
||||
std::string footprintName = aFootprint->GetFPID().GetFootprintName();
|
||||
|
||||
MODULE_MAP& mods = m_cache->m_modules;
|
||||
|
||||
|
|
|
@ -284,7 +284,7 @@ void FOOTPRINT_EDIT_FRAME::Export_Module( MODULE* aModule )
|
|||
if( aModule == NULL )
|
||||
return;
|
||||
|
||||
fn.SetName( aModule->GetLibRef() );
|
||||
fn.SetName( FROM_UTF8( aModule->GetFPID().GetFootprintName().c_str() ) );
|
||||
|
||||
wxString wildcard = wxGetTranslation( KiCadFootprintLibFileWildcard );
|
||||
|
||||
|
@ -600,7 +600,7 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibPath,
|
|||
SetMsgPanel( aModule );
|
||||
|
||||
// Ask what to use as the footprint name in the library
|
||||
wxString footprintName = aModule->GetLibRef();
|
||||
wxString footprintName = FROM_UTF8( aModule->GetFPID().GetFootprintName().c_str() );
|
||||
|
||||
if( aDisplayDialog )
|
||||
{
|
||||
|
@ -627,14 +627,14 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibPath,
|
|||
return false;
|
||||
}
|
||||
|
||||
aModule->SetLibRef( footprintName );
|
||||
aModule->SetFPID( FPID( footprintName ) );
|
||||
}
|
||||
|
||||
// Ensure this footprint has a libname
|
||||
if( footprintName.IsEmpty() )
|
||||
{
|
||||
footprintName = wxT("noname");
|
||||
aModule->SetLibRef( footprintName );
|
||||
aModule->SetFPID( footprintName );
|
||||
}
|
||||
|
||||
IO_MGR::PCB_FILE_T pluginType = IO_MGR::GuessPluginTypeFromLibPath( aLibPath );
|
||||
|
@ -730,7 +730,7 @@ MODULE* PCB_BASE_FRAME::Create_1_Module( const wxString& aModuleName )
|
|||
module->SetLastEditTime();
|
||||
|
||||
// Update its name in lib
|
||||
module->SetLibRef( moduleName );
|
||||
module->SetFPID( FPID( moduleName ) );
|
||||
|
||||
// Update reference:
|
||||
module->SetReference( moduleName );
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <dialog_helpers.h>
|
||||
#include <3d_viewer.h>
|
||||
#include <pcbcommon.h>
|
||||
#include <macros.h>
|
||||
|
||||
#include <class_board.h>
|
||||
#include <class_module.h>
|
||||
|
@ -160,7 +161,7 @@ void FOOTPRINT_VIEWER_FRAME::SelectCurrentFootprint( wxCommandEvent& event )
|
|||
delete oldmodule;
|
||||
}
|
||||
|
||||
m_footprintName = module->GetLibRef();
|
||||
m_footprintName = FROM_UTF8( module->GetFPID().GetFootprintName().c_str() );
|
||||
module->ClearFlags();
|
||||
SetCurItem( NULL );
|
||||
|
||||
|
|
|
@ -209,8 +209,8 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( PCB_BASE_FRAME* aParent,
|
|||
GetBoard()->Add( footprint, ADD_APPEND );
|
||||
#else
|
||||
FPID id;
|
||||
id.SetLibNickname( TO_UTF8( m_libraryName ) );
|
||||
id.SetFootprintName( TO_UTF8( m_footprintName ) );
|
||||
id.SetLibNickname( m_libraryName );
|
||||
id.SetFootprintName( m_footprintName );
|
||||
GetBoard()->Add( loadFootprint( id ) );
|
||||
#endif
|
||||
}
|
||||
|
@ -504,8 +504,8 @@ void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& event )
|
|||
GetBoard()->Add( footprint, ADD_APPEND );
|
||||
#else
|
||||
FPID id;
|
||||
id.SetLibNickname( TO_UTF8( m_libraryName ) );
|
||||
id.SetFootprintName( TO_UTF8( m_footprintName ) );
|
||||
id.SetLibNickname( m_libraryName );
|
||||
id.SetFootprintName( m_footprintName );
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
@ -235,7 +235,7 @@ MODULE* PCB_EDIT_FRAME::Genere_Self( wxDC* DC )
|
|||
return NULL;
|
||||
|
||||
// here the module is already in the BOARD, Create_1_Module() does that.
|
||||
module->SetLibRef( wxT( "MuSelf" ) );
|
||||
module->SetFPID( FPID( std::string( "MuSelf" ) ) );
|
||||
module->SetAttributes( MOD_VIRTUAL | MOD_CMS );
|
||||
module->ClearFlags();
|
||||
module->SetPosition( Mself.m_End );
|
||||
|
|
|
@ -168,8 +168,8 @@ void PCB_EDIT_FRAME::loadFootprints( NETLIST& aNetlist, REPORTER* aReporter )
|
|||
throw( IO_ERROR, PARSE_ERROR )
|
||||
{
|
||||
wxString msg;
|
||||
wxString lastFootprintLibName;
|
||||
wxArrayString nofoundFootprints; // A list of footprints used in netlist
|
||||
FPID lastFPID;
|
||||
std::vector< FPID > nofoundFootprints; // A list of footprints used in netlist
|
||||
// but not found in any library
|
||||
// to avoid a full search in all libs
|
||||
// each time a non existent footprint is needed
|
||||
|
@ -177,11 +177,10 @@ void PCB_EDIT_FRAME::loadFootprints( NETLIST& aNetlist, REPORTER* aReporter )
|
|||
MODULE* module = 0;
|
||||
MODULE* fpOnBoard;
|
||||
|
||||
|
||||
if( aNetlist.IsEmpty() )
|
||||
return;
|
||||
|
||||
aNetlist.SortByFootprintName();
|
||||
aNetlist.SortByFPID();
|
||||
|
||||
wxString libPath;
|
||||
wxFileName fn;
|
||||
|
@ -192,7 +191,7 @@ void PCB_EDIT_FRAME::loadFootprints( NETLIST& aNetlist, REPORTER* aReporter )
|
|||
{
|
||||
component = aNetlist.GetComponent( ii );
|
||||
|
||||
if( component->GetFootprintName().IsEmpty() )
|
||||
if( component->GetFPID().empty() )
|
||||
{
|
||||
if( aReporter )
|
||||
{
|
||||
|
@ -212,7 +211,7 @@ void PCB_EDIT_FRAME::loadFootprints( NETLIST& aNetlist, REPORTER* aReporter )
|
|||
fpOnBoard = m_Pcb->FindModule( aNetlist.GetComponent( ii )->GetReference() );
|
||||
|
||||
bool footprintMisMatch = fpOnBoard &&
|
||||
fpOnBoard->GetLibRef() != component->GetFootprintName();
|
||||
fpOnBoard->GetFPID() != component->GetFPID();
|
||||
|
||||
if( footprintMisMatch && !aNetlist.GetReplaceFootprints() )
|
||||
{
|
||||
|
@ -220,8 +219,8 @@ void PCB_EDIT_FRAME::loadFootprints( NETLIST& aNetlist, REPORTER* aReporter )
|
|||
{
|
||||
msg.Printf( _( "* Warning: component `%s` has footprint <%s> and should be <%s>\n" ),
|
||||
GetChars( component->GetReference() ),
|
||||
GetChars( fpOnBoard->GetLibRef() ),
|
||||
GetChars( component->GetFootprintName() ) );
|
||||
fpOnBoard->GetFPID().Format().c_str(),
|
||||
component->GetFPID().GetFootprintName().c_str() );
|
||||
aReporter->Report( msg );
|
||||
}
|
||||
|
||||
|
@ -233,7 +232,7 @@ void PCB_EDIT_FRAME::loadFootprints( NETLIST& aNetlist, REPORTER* aReporter )
|
|||
|
||||
bool loadFootprint = (fpOnBoard == NULL) || footprintMisMatch;
|
||||
|
||||
if( loadFootprint && (component->GetFootprintName() != lastFootprintLibName) )
|
||||
if( loadFootprint && (component->GetFPID() != lastFPID) )
|
||||
{
|
||||
module = NULL;
|
||||
|
||||
|
@ -242,9 +241,10 @@ void PCB_EDIT_FRAME::loadFootprints( NETLIST& aNetlist, REPORTER* aReporter )
|
|||
// So it should be made only once.
|
||||
// Therefore search in not found list first:
|
||||
bool alreadySearched = false;
|
||||
for( unsigned ii = 0; ii < nofoundFootprints.GetCount(); ii++ )
|
||||
|
||||
for( unsigned ii = 0; ii < nofoundFootprints.size(); ii++ )
|
||||
{
|
||||
if( component->GetFootprintName() == nofoundFootprints[ii] )
|
||||
if( component->GetFPID() == nofoundFootprints[ii] )
|
||||
{
|
||||
alreadySearched = true;
|
||||
break;
|
||||
|
@ -274,11 +274,12 @@ void PCB_EDIT_FRAME::loadFootprints( NETLIST& aNetlist, REPORTER* aReporter )
|
|||
continue;
|
||||
}
|
||||
|
||||
module = pi->FootprintLoad( libPath, component->GetFootprintName() );
|
||||
module = pi->FootprintLoad( libPath,
|
||||
FROM_UTF8( component->GetFPID().GetFootprintName().c_str() ) );
|
||||
|
||||
if( module )
|
||||
{
|
||||
lastFootprintLibName = component->GetFootprintName();
|
||||
lastFPID = component->GetFPID();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -290,11 +291,11 @@ void PCB_EDIT_FRAME::loadFootprints( NETLIST& aNetlist, REPORTER* aReporter )
|
|||
msg.Printf( _( "*** Warning: component `%s` footprint <%s> was not found in "
|
||||
"any libraries. ***\n" ),
|
||||
GetChars( component->GetReference() ),
|
||||
GetChars( component->GetFootprintName() ) );
|
||||
component->GetFPID().GetFootprintName().c_str() );
|
||||
aReporter->Report( msg );
|
||||
}
|
||||
|
||||
nofoundFootprints.Add( component->GetFootprintName() );
|
||||
nofoundFootprints.push_back( component->GetFPID() );
|
||||
|
||||
continue;
|
||||
}
|
||||
|
@ -319,7 +320,7 @@ void PCB_EDIT_FRAME::loadFootprints( NETLIST& aNetlist, REPORTER* aReporter )
|
|||
throw( IO_ERROR, PARSE_ERROR )
|
||||
{
|
||||
wxString msg;
|
||||
wxString lastFootprintLibName;
|
||||
FPID lastFPID;
|
||||
COMPONENT* component;
|
||||
MODULE* module = 0;
|
||||
MODULE* fpOnBoard;
|
||||
|
@ -327,13 +328,13 @@ void PCB_EDIT_FRAME::loadFootprints( NETLIST& aNetlist, REPORTER* aReporter )
|
|||
if( aNetlist.IsEmpty() || m_footprintLibTable->IsEmpty() )
|
||||
return;
|
||||
|
||||
aNetlist.SortByFootprintName();
|
||||
aNetlist.SortByFPID();
|
||||
|
||||
for( unsigned ii = 0; ii < aNetlist.GetCount(); ii++ )
|
||||
{
|
||||
component = aNetlist.GetComponent( ii );
|
||||
|
||||
if( component->GetFootprintName().IsEmpty() )
|
||||
if( component->GetFPID().empty() )
|
||||
{
|
||||
if( aReporter )
|
||||
{
|
||||
|
@ -353,7 +354,7 @@ void PCB_EDIT_FRAME::loadFootprints( NETLIST& aNetlist, REPORTER* aReporter )
|
|||
fpOnBoard = m_Pcb->FindModule( aNetlist.GetComponent( ii )->GetReference() );
|
||||
|
||||
bool footprintMisMatch = fpOnBoard &&
|
||||
fpOnBoard->GetLibRef() != component->GetFootprintName();
|
||||
fpOnBoard->GetFPID() != component->GetFPID();
|
||||
|
||||
if( footprintMisMatch && !aNetlist.GetReplaceFootprints() )
|
||||
{
|
||||
|
@ -361,8 +362,8 @@ void PCB_EDIT_FRAME::loadFootprints( NETLIST& aNetlist, REPORTER* aReporter )
|
|||
{
|
||||
msg.Printf( _( "* Warning: component `%s` has footprint <%s> and should be <%s>\n" ),
|
||||
GetChars( component->GetReference() ),
|
||||
GetChars( fpOnBoard->GetLibRef() ),
|
||||
GetChars( component->GetFootprintName() ) );
|
||||
fpOnBoard->GetFPID().GetFootprintName().c_str(),
|
||||
component->GetFPID().GetFootprintName().c_str() );
|
||||
aReporter->Report( msg );
|
||||
}
|
||||
|
||||
|
@ -374,31 +375,29 @@ void PCB_EDIT_FRAME::loadFootprints( NETLIST& aNetlist, REPORTER* aReporter )
|
|||
|
||||
bool loadFootprint = (fpOnBoard == NULL) || footprintMisMatch;
|
||||
|
||||
if( loadFootprint && (component->GetFootprintName() != lastFootprintLibName) )
|
||||
if( loadFootprint && (component->GetFPID() != lastFPID) )
|
||||
{
|
||||
module = NULL;
|
||||
|
||||
FPID fpid;
|
||||
|
||||
if( fpid.Parse( TO_UTF8( component->GetFootprintName() ) ) >= 0 )
|
||||
if( !component->GetFPID().IsValid() )
|
||||
{
|
||||
if( aReporter )
|
||||
{
|
||||
msg.Printf( _( "*** Warning: Component \"%s\" footprint ID <%s> is not "
|
||||
"valid. ***\n" ),
|
||||
GetChars( component->GetReference() ),
|
||||
GetChars( component->GetFootprintName() ) );
|
||||
component->GetFPID().GetFootprintName().c_str() );
|
||||
aReporter->Report( msg );
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
module = PCB_BASE_FRAME::loadFootprint( fpid );
|
||||
module = PCB_BASE_FRAME::loadFootprint( component->GetFPID() );
|
||||
|
||||
if( module )
|
||||
{
|
||||
lastFootprintLibName = component->GetFootprintName();
|
||||
lastFPID = component->GetFPID();
|
||||
}
|
||||
|
||||
if( module == NULL )
|
||||
|
@ -409,7 +408,7 @@ void PCB_EDIT_FRAME::loadFootprints( NETLIST& aNetlist, REPORTER* aReporter )
|
|||
msg.Printf( _( "*** Warning: component `%s` footprint <%s> was not found in "
|
||||
"any libraries in the footprint library table. ***\n" ),
|
||||
GetChars( component->GetReference() ),
|
||||
GetChars( component->GetFootprintName() ) );
|
||||
component->GetFPID().GetFootprintName().c_str() );
|
||||
aReporter->Report( msg );
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ void COMPONENT::SetModule( MODULE* aModule )
|
|||
|
||||
aModule->SetReference( m_reference );
|
||||
aModule->SetValue( m_value );
|
||||
aModule->SetLibRef( m_footprintName );
|
||||
aModule->SetFPID( m_fpid );
|
||||
aModule->SetPath( m_timeStamp );
|
||||
}
|
||||
|
||||
|
@ -116,11 +116,11 @@ void COMPONENT::Show( int aNestLevel, REPORTER& aReporter )
|
|||
NestedSpace( aNestLevel, aReporter );
|
||||
aReporter.Report( wxT( "<component>\n" ) );
|
||||
NestedSpace( aNestLevel+1, aReporter );
|
||||
aReporter.Report( wxString::Format( wxT( "<ref=%s value=%s name=%s library=%s footprint=%s "
|
||||
"footprint-lib=%s timestamp=%s>\n" ),
|
||||
aReporter.Report( wxString::Format( wxT( "<ref=%s value=%s name=%s library=%s fpid=%s "
|
||||
" timestamp=%s>\n" ),
|
||||
GetChars( m_reference ), GetChars( m_value ),
|
||||
GetChars( m_name ), GetChars( m_library ),
|
||||
GetChars( m_footprintName ), GetChars( m_footprintLib ),
|
||||
m_fpid.Format().c_str(),
|
||||
GetChars( m_timeStamp ) ) );
|
||||
|
||||
if( !m_footprintFilters.IsEmpty() )
|
||||
|
@ -198,18 +198,18 @@ COMPONENT* NETLIST::GetComponentByTimeStamp( const wxString& aTimeStamp )
|
|||
|
||||
|
||||
/**
|
||||
* Function ByFootprintName
|
||||
* Function ByFPID
|
||||
* is a helper function used to sort the component list used by loadNewModules.
|
||||
*/
|
||||
static bool ByFootprintName( const COMPONENT& ref, const COMPONENT& cmp )
|
||||
static bool ByFPID( const COMPONENT& ref, const COMPONENT& cmp )
|
||||
{
|
||||
return ref.GetFootprintName().CmpNoCase( cmp.GetFootprintName() ) > 0;
|
||||
return ref.GetFPID() > cmp.GetFPID();
|
||||
}
|
||||
|
||||
|
||||
void NETLIST::SortByFootprintName()
|
||||
void NETLIST::SortByFPID()
|
||||
{
|
||||
m_components.sort( ByFootprintName );
|
||||
m_components.sort( ByFPID );
|
||||
}
|
||||
|
||||
|
||||
|
@ -233,7 +233,7 @@ bool NETLIST::AnyFootprintsLinked() const
|
|||
{
|
||||
for( unsigned i = 0; i < m_components.size(); i++ )
|
||||
{
|
||||
if( !m_components[i].GetFootprintName().IsEmpty() )
|
||||
if( !m_components[i].GetFPID().empty() )
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -245,7 +245,7 @@ bool NETLIST::AllFootprintsLinked() const
|
|||
{
|
||||
for( unsigned i = 0; i < m_components.size(); i++ )
|
||||
{
|
||||
if( m_components[i].GetFootprintName().IsEmpty() )
|
||||
if( m_components[i].GetFPID().empty() )
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -452,7 +452,7 @@ bool CMP_READER::Load( NETLIST* aNetlist ) throw( IO_ERROR, PARSE_ERROR )
|
|||
// and still exists in footprint assignment list, before this list is updated
|
||||
// This is an usual case during the life of a design
|
||||
if( component )
|
||||
component->SetFootprintName( footprint );
|
||||
component->SetFPID( FPID( footprint ) );
|
||||
else
|
||||
ok = false; // can be used to display a warning in Pcbnew.
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include <fctsys.h>
|
||||
#include <macros.h>
|
||||
#include <fpid.h>
|
||||
|
||||
#include <netlist_lexer.h> // netlist_lexer is common to Eeschema and Pcbnew
|
||||
|
||||
|
@ -110,20 +111,12 @@ class COMPONENT
|
|||
wxString m_name;
|
||||
|
||||
/**
|
||||
* The name of the component library where #m_name was found. This will be set to
|
||||
* wxEmptyString for legacy netlist files.
|
||||
* The name of the component library where #m_name was found.
|
||||
*/
|
||||
wxString m_library;
|
||||
|
||||
/// The name of the footprint in the footprint library assigned to the component.
|
||||
wxString m_footprintName;
|
||||
|
||||
/**
|
||||
* The name of the footprint library that #m_footprintName is located. This will be
|
||||
* set to wxEmptyString for legacy netlist formats indicating that all libraries need
|
||||
* to be searched.
|
||||
*/
|
||||
wxString m_footprintLib;
|
||||
/// The #FPID of the footprint assigned to the component.
|
||||
FPID m_fpid;
|
||||
|
||||
/// The #MODULE loaded for #m_footprintName found in #m_footprintLib.
|
||||
std::auto_ptr< MODULE > m_footprint;
|
||||
|
@ -135,12 +128,12 @@ class COMPONENT
|
|||
static COMPONENT_NET m_emptyNet;
|
||||
|
||||
public:
|
||||
COMPONENT( const wxString& aFootprintName,
|
||||
COMPONENT( const FPID& aFPID,
|
||||
const wxString& aReference,
|
||||
const wxString& aValue,
|
||||
const wxString& aTimeStamp )
|
||||
{
|
||||
m_footprintName = aFootprintName;
|
||||
m_fpid = aFPID;
|
||||
m_reference = aReference;
|
||||
m_value = aValue;
|
||||
m_timeStamp = aTimeStamp;
|
||||
|
@ -172,21 +165,13 @@ public:
|
|||
|
||||
const wxString& GetValue() const { return m_value; }
|
||||
|
||||
void SetFootprintName( const wxString& aFootprintName )
|
||||
void SetFPID( const FPID& aFPID )
|
||||
{
|
||||
m_footprintChanged = !m_footprintName.IsEmpty() && (m_footprintName != aFootprintName);
|
||||
m_footprintName = aFootprintName;
|
||||
m_footprintChanged = !m_fpid.empty() && (m_fpid != aFPID);
|
||||
m_fpid = aFPID;
|
||||
}
|
||||
|
||||
const wxString& GetFootprintName() const { return m_footprintName; }
|
||||
|
||||
void SetFootprintLib( const wxString& aFootprintLib )
|
||||
{
|
||||
m_footprintChanged = !m_footprintLib.IsEmpty() && (m_footprintLib != aFootprintLib);
|
||||
m_footprintLib = aFootprintLib;
|
||||
}
|
||||
|
||||
const wxString& GetFootprintLib() const { return m_footprintLib; }
|
||||
const FPID& GetFPID() const { return m_fpid; }
|
||||
|
||||
const wxString& GetTimeStamp() const { return m_timeStamp; }
|
||||
|
||||
|
@ -324,7 +309,7 @@ public:
|
|||
*/
|
||||
COMPONENT* GetComponentByTimeStamp( const wxString& aTimeStamp );
|
||||
|
||||
void SortByFootprintName();
|
||||
void SortByFPID();
|
||||
|
||||
void SortByReference();
|
||||
|
||||
|
|
|
@ -511,7 +511,7 @@ void PCB_MODULE::AddToBoard()
|
|||
module->SetTimeStamp( 0 );
|
||||
module->SetLastEditTime( 0 );
|
||||
|
||||
module->SetLibRef( m_compRef );
|
||||
module->SetFPID( FPID( m_compRef ) );
|
||||
|
||||
module->SetAttributes( MOD_DEFAULT | MOD_CMS );
|
||||
|
||||
|
|
|
@ -1542,13 +1542,14 @@ MODULE* PCB_PARSER::parseMODULE( wxArrayString* aInitialComments ) throw( IO_ERR
|
|||
|
||||
wxPoint pt;
|
||||
T token;
|
||||
FPID fpid;
|
||||
|
||||
auto_ptr< MODULE > module( new MODULE( m_board ) );
|
||||
|
||||
module->SetInitialComments( aInitialComments );
|
||||
|
||||
NeedSYMBOLorNUMBER();
|
||||
module->SetLibRef( FromUTF8() );
|
||||
fpid.SetFootprintName( FromUTF8() );
|
||||
|
||||
for( token = NextTok(); token != T_RIGHT; token = NextTok() )
|
||||
{
|
||||
|
@ -1565,6 +1566,11 @@ MODULE* PCB_PARSER::parseMODULE( wxArrayString* aInitialComments ) throw( IO_ERR
|
|||
module->SetIsPlaced( true );
|
||||
break;
|
||||
|
||||
case T_fp_lib:
|
||||
fpid.SetLibNickname( FromUTF8() );
|
||||
NeedRIGHT();
|
||||
break;
|
||||
|
||||
case T_layer:
|
||||
module->SetLayer( parseBoardItemLayer() );
|
||||
NeedRIGHT();
|
||||
|
@ -1747,6 +1753,7 @@ MODULE* PCB_PARSER::parseMODULE( wxArrayString* aInitialComments ) throw( IO_ERR
|
|||
}
|
||||
}
|
||||
|
||||
module->SetFPID( fpid );
|
||||
module->CalculateBoundingBox();
|
||||
|
||||
return module.release();
|
||||
|
|
|
@ -487,8 +487,11 @@ PCB_EDIT_FRAME::~PCB_EDIT_FRAME()
|
|||
m_Macros[i].m_Record.clear();
|
||||
|
||||
delete m_drc;
|
||||
|
||||
#if defined( USE_FP_LIB_TABLE )
|
||||
delete m_footprintLibTable;
|
||||
delete m_globalFootprintTable;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -627,7 +627,7 @@ IMAGE* SPECCTRA_DB::makeIMAGE( BOARD* aBoard, MODULE* aModule )
|
|||
|
||||
IMAGE* image = new IMAGE(0);
|
||||
|
||||
image->image_id = TO_UTF8( aModule->GetLibRef() );
|
||||
image->image_id = aModule->GetFPID().Format().c_str();
|
||||
|
||||
// from the pads, and make an IMAGE using collated padstacks.
|
||||
for( int p=0; p<moduleItems.GetCount(); ++p )
|
||||
|
|
|
@ -67,10 +67,10 @@ private:
|
|||
void Change_Current_Module();
|
||||
void Change_ModuleId( bool aUseValue );
|
||||
void Change_ModuleAll();
|
||||
int Maj_ListeCmp( const wxString& reference, const wxString& old_name,
|
||||
const wxString& new_name, bool ShowError );
|
||||
int Maj_ListeCmp( const wxString& reference, const FPID& old_name,
|
||||
const FPID& new_name, bool ShowError );
|
||||
bool Change_1_Module( MODULE* Module,
|
||||
const wxString& new_module,
|
||||
const FPID& new_module,
|
||||
PICKED_ITEMS_LIST* aUndoPickList,
|
||||
bool ShowError );
|
||||
};
|
||||
|
@ -106,8 +106,8 @@ void DIALOG_EXCHANGE_MODULE::Init()
|
|||
{
|
||||
SetFocus();
|
||||
|
||||
m_OldModule->AppendText( m_CurrentModule->GetLibRef() );
|
||||
m_NewModule->AppendText( m_CurrentModule->GetLibRef() );
|
||||
m_OldModule->AppendText( FROM_UTF8( m_CurrentModule->GetFPID().Format().c_str() ) );
|
||||
m_NewModule->AppendText( FROM_UTF8( m_CurrentModule->GetFPID().Format().c_str() ) );
|
||||
m_OldValue->AppendText( m_CurrentModule->GetValue() );
|
||||
m_Selection->SetSelection( s_SelectionMode );
|
||||
|
||||
|
@ -168,8 +168,8 @@ void DIALOG_EXCHANGE_MODULE::OnSelectionClicked( wxCommandEvent& event )
|
|||
* Return 1 if error
|
||||
*/
|
||||
int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference,
|
||||
const wxString& old_name,
|
||||
const wxString& new_name,
|
||||
const FPID& old_name,
|
||||
const FPID& new_name,
|
||||
bool ShowError )
|
||||
{
|
||||
wxFileName fn;
|
||||
|
@ -241,7 +241,7 @@ int DIALOG_EXCHANGE_MODULE::Maj_ListeCmp( const wxString& reference,
|
|||
|
||||
if( start_descr && strnicmp( line, "IdModule", 8 ) == 0 )
|
||||
{
|
||||
sprintf( line + 8, " = %s;\n", TO_UTF8( new_name ) );
|
||||
sprintf( line + 8, " = %s;\n", new_name.Format().c_str() );
|
||||
|
||||
msg = wxT( " * in <" ) + fn.GetFullPath() + wxT( ">.\n" );
|
||||
m_WinMessages->AppendText( msg );
|
||||
|
@ -306,7 +306,8 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleId( bool aUseValue )
|
|||
MODULE* Module, * PtBack;
|
||||
bool change = false;
|
||||
wxString newmodulename = m_NewModule->GetValue();
|
||||
wxString value, lib_reference;
|
||||
wxString value;
|
||||
FPID lib_reference;
|
||||
bool check_module_value = false;
|
||||
int ShowErr = 3; // Post 3 error messages max.
|
||||
|
||||
|
@ -316,21 +317,21 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleId( bool aUseValue )
|
|||
if( newmodulename == wxEmptyString )
|
||||
return;
|
||||
|
||||
lib_reference = m_CurrentModule->GetLibRef();
|
||||
lib_reference = m_CurrentModule->GetFPID();
|
||||
|
||||
if( aUseValue )
|
||||
{
|
||||
check_module_value = true;
|
||||
value = m_CurrentModule->GetValue();
|
||||
msg.Printf( _( "Change modules %s -> %s (for value = %s)?" ),
|
||||
GetChars( m_CurrentModule->GetLibRef() ),
|
||||
m_CurrentModule->GetFPID().Format().c_str(),
|
||||
GetChars( newmodulename ),
|
||||
GetChars( m_CurrentModule->GetValue() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
msg.Printf( _( "Change modules %s -> %s ?" ),
|
||||
GetChars( lib_reference ), GetChars( newmodulename ) );
|
||||
lib_reference.GetFootprintName().c_str(), GetChars( newmodulename ) );
|
||||
}
|
||||
|
||||
if( !IsOK( this, msg ) )
|
||||
|
@ -350,7 +351,7 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleId( bool aUseValue )
|
|||
{
|
||||
PtBack = Module->Back();
|
||||
|
||||
if( lib_reference.CmpNoCase( Module->GetLibRef() ) != 0 )
|
||||
if( lib_reference != Module->GetFPID() )
|
||||
continue;
|
||||
|
||||
if( check_module_value )
|
||||
|
@ -412,7 +413,7 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleAll()
|
|||
{
|
||||
PtBack = Module->Back();
|
||||
|
||||
if( Change_1_Module( Module, Module->GetLibRef(), &pickList, ShowErr ) )
|
||||
if( Change_1_Module( Module, Module->GetFPID(), &pickList, ShowErr ) )
|
||||
change = true;
|
||||
else if( ShowErr )
|
||||
ShowErr--;
|
||||
|
@ -443,11 +444,11 @@ void DIALOG_EXCHANGE_MODULE::Change_ModuleAll()
|
|||
* Ratsnest must be recalculated after module exchange
|
||||
*/
|
||||
bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* Module,
|
||||
const wxString& new_module,
|
||||
const FPID& new_module,
|
||||
PICKED_ITEMS_LIST* aUndoPickList,
|
||||
bool ShowError )
|
||||
{
|
||||
wxString namecmp, oldnamecmp;
|
||||
FPID namecmp, oldnamecmp;
|
||||
MODULE* NewModule;
|
||||
wxString line;
|
||||
|
||||
|
@ -457,18 +458,18 @@ bool DIALOG_EXCHANGE_MODULE::Change_1_Module( MODULE* Module,
|
|||
wxBusyCursor dummy;
|
||||
|
||||
// Copy parameters from the old module.
|
||||
oldnamecmp = Module->GetLibRef();
|
||||
oldnamecmp = Module->GetFPID();
|
||||
namecmp = new_module;
|
||||
|
||||
// Load module.
|
||||
line.Printf( _( "Change module %s (from %s) " ),
|
||||
GetChars( Module->GetReference() ),
|
||||
GetChars( oldnamecmp ) );
|
||||
oldnamecmp.Format().c_str() );
|
||||
m_WinMessages->AppendText( line );
|
||||
|
||||
namecmp.Trim( true );
|
||||
namecmp.Trim( false );
|
||||
NewModule = m_Parent->GetModuleLibrary( wxEmptyString, namecmp, ShowError );
|
||||
NewModule = m_Parent->GetModuleLibrary( FROM_UTF8( namecmp.GetLibNickname().c_str() ),
|
||||
FROM_UTF8( namecmp.GetFootprintName().c_str() ),
|
||||
ShowError );
|
||||
|
||||
if( NewModule == NULL ) // New module not found, redraw the old one.
|
||||
{
|
||||
|
@ -641,7 +642,7 @@ void PCB_EDIT_FRAME::RecreateCmpFileFromBoard( wxCommandEvent& aEvent )
|
|||
fprintf( FichCmp, "ValeurCmp = %s;\n",
|
||||
!Module->GetValue().IsEmpty() ?
|
||||
TO_UTF8( Module->GetValue() ) : "[NoVal]" );
|
||||
fprintf( FichCmp, "IdModule = %s;\n", TO_UTF8( Module->GetLibRef() ) );
|
||||
fprintf( FichCmp, "IdModule = %s;\n", Module->GetFPID().Format().c_str() );
|
||||
fprintf( FichCmp, "EndCmp\n" );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue