Commit 230c5f8f authored by Wayne Stambaugh's avatar Wayne Stambaugh

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