Jettison FP_LIB_TABLE::ConvertFromLegacy() into a static function, where it
was used locally. Then comment it out in favor of a newer strategy for filling in nicknames in cvpcb. Add MODULE* FootprintLoadWithOptionalNickname( const FPID& aFootprintId ) throw( IO_ERROR, PARSE_ERROR ); from code found elsewhere.
This commit is contained in:
parent
d053e5615b
commit
4011953455
|
@ -638,164 +638,41 @@ const wxString FP_LIB_TABLE::ExpandSubstitutions( const wxString& aString )
|
||||||
|
|
||||||
bool FP_LIB_TABLE::IsEmpty( bool aIncludeFallback )
|
bool FP_LIB_TABLE::IsEmpty( bool aIncludeFallback )
|
||||||
{
|
{
|
||||||
if( !aIncludeFallback || (fallBack == NULL) )
|
if( !aIncludeFallback || !fallBack )
|
||||||
return rows.empty();
|
return rows.empty();
|
||||||
|
|
||||||
return fallBack->IsEmpty() && rows.empty();
|
return rows.empty() && fallBack->IsEmpty( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool FP_LIB_TABLE::ConvertFromLegacy( SEARCH_STACK& aSStack, NETLIST& aNetList,
|
MODULE* FP_LIB_TABLE::FootprintLoadWithOptionalNickname( const FPID& aFootprintId )
|
||||||
const wxArrayString& aLibNames, REPORTER* aReporter ) throw( IO_ERROR )
|
throw( IO_ERROR, PARSE_ERROR )
|
||||||
{
|
{
|
||||||
wxString msg;
|
wxString nickname = aFootprintId.GetLibNickname();
|
||||||
FPID lastFPID;
|
wxString fpname = aFootprintId.GetFootprintName();
|
||||||
COMPONENT* component;
|
|
||||||
MODULE* module = 0;
|
|
||||||
bool retv = true;
|
|
||||||
|
|
||||||
if( aNetList.IsEmpty() )
|
if( nickname.size() )
|
||||||
return true;
|
|
||||||
|
|
||||||
aNetList.SortByFPID();
|
|
||||||
|
|
||||||
wxString libPath;
|
|
||||||
|
|
||||||
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
|
|
||||||
|
|
||||||
for( unsigned ii = 0; ii < aNetList.GetCount(); ii++ )
|
|
||||||
{
|
{
|
||||||
component = aNetList.GetComponent( ii );
|
return FootprintLoad( nickname, fpname );
|
||||||
|
|
||||||
// The footprint hasn't been assigned yet so ignore it.
|
|
||||||
if( component->GetFPID().empty() )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if( component->GetFPID() != lastFPID )
|
|
||||||
{
|
|
||||||
module = NULL;
|
|
||||||
|
|
||||||
for( unsigned ii = 0; ii < aLibNames.GetCount(); ii++ )
|
|
||||||
{
|
|
||||||
wxFileName fn( wxEmptyString, aLibNames[ii], LegacyFootprintLibPathExtension );
|
|
||||||
|
|
||||||
libPath = aSStack.FindValidPath( fn.GetFullPath() );
|
|
||||||
|
|
||||||
if( !libPath )
|
|
||||||
{
|
|
||||||
if( aReporter )
|
|
||||||
{
|
|
||||||
msg.Printf( _( "Cannot find footprint library file '%s' in any of the "
|
|
||||||
"KiCad legacy library search paths.\n" ),
|
|
||||||
GetChars( fn.GetFullPath() ) );
|
|
||||||
aReporter->Report( msg );
|
|
||||||
}
|
|
||||||
|
|
||||||
retv = false;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
module = pi->FootprintLoad( libPath, component->GetFPID().GetFootprintName() );
|
|
||||||
|
|
||||||
if( module )
|
|
||||||
{
|
|
||||||
lastFPID = component->GetFPID();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !module )
|
|
||||||
{
|
|
||||||
if( aReporter )
|
|
||||||
{
|
|
||||||
msg.Printf( _( "Component `%s` footprint '%s' was not found in any legacy "
|
|
||||||
"library.\n" ),
|
|
||||||
GetChars( component->GetReference() ),
|
|
||||||
GetChars( component->GetFPID().Format() ) );
|
|
||||||
aReporter->Report( msg );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear the footprint assignment since the old library lookup method is no
|
|
||||||
// longer valid.
|
|
||||||
FPID emptyFPID;
|
|
||||||
|
|
||||||
component->SetFPID( emptyFPID );
|
|
||||||
retv = false;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wxString libNickname;
|
|
||||||
|
|
||||||
FP_LIB_TABLE* cur = this;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
cur->ensureIndex();
|
|
||||||
|
|
||||||
for( unsigned i = 0; i < cur->rows.size(); i++ )
|
|
||||||
{
|
|
||||||
wxString uri = cur->rows[i].GetFullURI( true );
|
|
||||||
|
|
||||||
if( wxFileName::GetPathSeparator() == wxChar( '\\' )
|
|
||||||
&& uri.Find( wxChar( '/' ) ) >= 0 )
|
|
||||||
{
|
|
||||||
uri.Replace( wxT( "/"), wxT( "\\" ) );
|
|
||||||
}
|
|
||||||
#ifdef __WINDOWS__
|
|
||||||
if( uri.CmpNoCase( libPath ) )
|
|
||||||
#else
|
|
||||||
if( uri == libPath )
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
libNickname = cur->rows[i].GetNickName();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} while( ( cur = cur->fallBack ) != 0 && libNickname.IsEmpty() );
|
|
||||||
|
|
||||||
if( libNickname.IsEmpty() )
|
|
||||||
{
|
|
||||||
if( aReporter )
|
|
||||||
{
|
|
||||||
msg.Printf( _( "Component '%s' footprint '%s' legacy library path '%s' "
|
|
||||||
"was not found in the footprint library table.\n" ),
|
|
||||||
GetChars( component->GetReference() ),
|
|
||||||
GetChars( component->GetFPID().Format() ) );
|
|
||||||
aReporter->Report( msg );
|
|
||||||
}
|
|
||||||
|
|
||||||
retv = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FPID newFPID = lastFPID;
|
|
||||||
newFPID.SetLibNickname( libNickname );
|
|
||||||
|
|
||||||
if( !newFPID.IsValid() )
|
|
||||||
{
|
|
||||||
if( aReporter )
|
|
||||||
{
|
|
||||||
msg.Printf( _( "Component '%s' FPID '%s' is not valid.\n" ),
|
|
||||||
GetChars( component->GetReference() ),
|
|
||||||
GetChars( newFPID.Format() ) );
|
|
||||||
aReporter->Report( msg );
|
|
||||||
}
|
|
||||||
|
|
||||||
retv = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// The footprint name should already be set.
|
|
||||||
component->SetFPID( newFPID );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return retv;
|
// nickname is empty, sequentially search (alphabetically) all libs/nicks for first match:
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::vector<wxString> nicks = GetLogicalLibs();
|
||||||
|
|
||||||
|
// Search each library going through libraries alphabetically.
|
||||||
|
for( unsigned i = 0; i<nicks.size(); ++i )
|
||||||
|
{
|
||||||
|
// FootprintLoad() returns NULL on not found, does not throw exception
|
||||||
|
// unless there's an IO_ERROR.
|
||||||
|
MODULE* ret = FootprintLoad( nicks[i], fpname );
|
||||||
|
if( ret )
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -827,17 +704,14 @@ bool FP_LIB_TABLE::LoadGlobalTable( FP_LIB_TABLE& aTable ) throw (IO_ERROR, PARS
|
||||||
// The fallback is to create an empty global footprint table for the user to populate.
|
// The fallback is to create an empty global footprint table for the user to populate.
|
||||||
if( fileName.IsEmpty() || !::wxCopyFile( fileName, fn.GetFullPath(), false ) )
|
if( fileName.IsEmpty() || !::wxCopyFile( fileName, fn.GetFullPath(), false ) )
|
||||||
{
|
{
|
||||||
FP_LIB_TABLE emptyTable;
|
FP_LIB_TABLE emptyTable;
|
||||||
FILE_OUTPUTFORMATTER sf( fn.GetFullPath() );
|
|
||||||
|
|
||||||
emptyTable.Format( &sf, 0 );
|
emptyTable.Save( fn.GetFullPath() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE_LINE_READER reader( fn.GetFullPath() );
|
aTable.Load( fn.GetFullPath() );
|
||||||
FP_LIB_TABLE_LEXER lexer( &reader );
|
|
||||||
|
|
||||||
aTable.Parse( &lexer );
|
|
||||||
return tableExists;
|
return tableExists;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -744,7 +744,7 @@ void WORKSHEET_LAYOUT::SetDefaultLayout()
|
||||||
{
|
{
|
||||||
lp_parser.Parse( this );
|
lp_parser.Parse( this );
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
wxLogMessage( ioe.errorText );
|
wxLogMessage( ioe.errorText );
|
||||||
}
|
}
|
||||||
|
@ -765,7 +765,7 @@ void WORKSHEET_LAYOUT::SetPageLayout( const char* aPageLayout, bool Append )
|
||||||
{
|
{
|
||||||
lp_parser.Parse( this );
|
lp_parser.Parse( this );
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
wxLogMessage( ioe.errorText );
|
wxLogMessage( ioe.errorText );
|
||||||
}
|
}
|
||||||
|
@ -828,7 +828,7 @@ void WORKSHEET_LAYOUT::SetPageLayout( const wxString& aFullFileName, bool Append
|
||||||
{
|
{
|
||||||
lp_parser.Parse( this );
|
lp_parser.Parse( this );
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
wxLogMessage( ioe.errorText );
|
wxLogMessage( ioe.errorText );
|
||||||
}
|
}
|
||||||
|
|
|
@ -490,7 +490,7 @@ MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& aFootprintName )
|
||||||
|
|
||||||
footprint = FootprintLibs()->FootprintLoad( FROM_UTF8( nickname.c_str() ), FROM_UTF8( fpname.c_str() ) );
|
footprint = FootprintLibs()->FootprintLoad( FROM_UTF8( nickname.c_str() ), FROM_UTF8( fpname.c_str() ) );
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
DisplayError( this, ioe.errorText );
|
DisplayError( this, ioe.errorText );
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -846,7 +846,7 @@ int CVPCB_MAINFRAME::ReadSchematicNetlist()
|
||||||
else
|
else
|
||||||
wxMessageBox( _( "Unknown netlist format." ), wxEmptyString, wxOK | wxICON_ERROR );
|
wxMessageBox( _( "Unknown netlist format." ), wxEmptyString, wxOK | wxICON_ERROR );
|
||||||
}
|
}
|
||||||
catch( IO_ERROR& ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
msg = wxString::Format( _( "Error loading netlist.\n%s" ), ioe.errorText.GetData() );
|
msg = wxString::Format( _( "Error loading netlist.\n%s" ), ioe.errorText.GetData() );
|
||||||
wxMessageBox( msg, _( "Netlist Load Error" ), wxOK | wxICON_ERROR );
|
wxMessageBox( msg, _( "Netlist Load Error" ), wxOK | wxICON_ERROR );
|
||||||
|
|
|
@ -171,6 +171,164 @@ static bool missingLegacyLibs( FP_LIB_TABLE* aTbl, SEARCH_STACK& aSStack,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
This code block was based on two major assumptions that are no longer true:
|
||||||
|
1) Footprint library basenames would remain the same.
|
||||||
|
(But no, basenames have been renamed in the github repo.)
|
||||||
|
2) *.mod files would still be around and merely reside in the FP_LIB_TABLE.
|
||||||
|
(But no, they have been converted to *.pretty.)
|
||||||
|
|
||||||
|
There is a newer replacement code block in the #else region.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function convertFromLegacy
|
||||||
|
* converts the footprint names in \a aNetList from the legacy format to the #FPID format.
|
||||||
|
*
|
||||||
|
* @param aNetList is the #NETLIST object to convert.
|
||||||
|
* @param aLibNames is the list of legacy footprint library names from the currently loaded
|
||||||
|
* project.
|
||||||
|
* @param aReporter is the #REPORTER object to dump messages into.
|
||||||
|
* @return true if all footprint names were successfully converted to a valid FPID.
|
||||||
|
*/
|
||||||
|
static bool convertFromLegacy( FP_LIB_TABLE* aTbl, SEARCH_STACK& aSStack, NETLIST& aNetList,
|
||||||
|
const wxArrayString& aLibNames, REPORTER* aReporter = NULL ) throw( IO_ERROR )
|
||||||
|
{
|
||||||
|
wxString msg;
|
||||||
|
FPID lastFPID;
|
||||||
|
COMPONENT* component;
|
||||||
|
MODULE* module = 0;
|
||||||
|
bool retv = true;
|
||||||
|
|
||||||
|
if( aNetList.IsEmpty() )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
aNetList.SortByFPID();
|
||||||
|
|
||||||
|
wxString libPath;
|
||||||
|
|
||||||
|
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
|
||||||
|
|
||||||
|
for( unsigned ii = 0; ii < aNetList.GetCount(); ii++ )
|
||||||
|
{
|
||||||
|
component = aNetList.GetComponent( ii );
|
||||||
|
|
||||||
|
// The footprint hasn't been assigned yet so ignore it.
|
||||||
|
if( component->GetFPID().empty() )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if( component->GetFPID() != lastFPID )
|
||||||
|
{
|
||||||
|
module = NULL;
|
||||||
|
|
||||||
|
for( unsigned ii = 0; ii < aLibNames.GetCount(); ii++ )
|
||||||
|
{
|
||||||
|
wxFileName fn( wxEmptyString, aLibNames[ii], LegacyFootprintLibPathExtension );
|
||||||
|
|
||||||
|
libPath = aSStack.FindValidPath( fn.GetFullPath() );
|
||||||
|
|
||||||
|
if( !libPath )
|
||||||
|
{
|
||||||
|
if( aReporter )
|
||||||
|
{
|
||||||
|
msg.Printf( _( "Cannot find footprint library file '%s' in any of the "
|
||||||
|
"KiCad legacy library search paths.\n" ),
|
||||||
|
GetChars( fn.GetFullPath() ) );
|
||||||
|
aReporter->Report( msg );
|
||||||
|
}
|
||||||
|
|
||||||
|
retv = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
module = pi->FootprintLoad( libPath, component->GetFPID().GetFootprintName() );
|
||||||
|
|
||||||
|
if( module )
|
||||||
|
{
|
||||||
|
lastFPID = component->GetFPID();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !module )
|
||||||
|
{
|
||||||
|
if( aReporter )
|
||||||
|
{
|
||||||
|
msg.Printf( _( "Component '%s' footprint '%s' was not found in any legacy "
|
||||||
|
"library.\n" ),
|
||||||
|
GetChars( component->GetReference() ),
|
||||||
|
GetChars( component->GetFPID().Format() ) );
|
||||||
|
aReporter->Report( msg );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear the footprint assignment since the old library lookup method is no
|
||||||
|
// longer valid.
|
||||||
|
FPID emptyFPID;
|
||||||
|
|
||||||
|
component->SetFPID( emptyFPID );
|
||||||
|
retv = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxString libNickname;
|
||||||
|
|
||||||
|
const FP_LIB_TABLE::ROW* row;
|
||||||
|
|
||||||
|
if( ( row = aTbl->FindRowByURI( libPath ) ) != NULL )
|
||||||
|
libNickname = row->GetNickName();
|
||||||
|
|
||||||
|
if( libNickname.IsEmpty() )
|
||||||
|
{
|
||||||
|
if( aReporter )
|
||||||
|
{
|
||||||
|
msg.Printf( _( "Component '%s' with footprint '%s' and legacy library path '%s' "
|
||||||
|
"was not found in the footprint library table.\n" ),
|
||||||
|
GetChars( component->GetReference() ),
|
||||||
|
GetChars( component->GetFPID().Format() ),
|
||||||
|
GetChars( libPath )
|
||||||
|
);
|
||||||
|
aReporter->Report( msg );
|
||||||
|
}
|
||||||
|
|
||||||
|
retv = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FPID newFPID = lastFPID;
|
||||||
|
newFPID.SetLibNickname( libNickname );
|
||||||
|
|
||||||
|
if( !newFPID.IsValid() )
|
||||||
|
{
|
||||||
|
if( aReporter )
|
||||||
|
{
|
||||||
|
msg.Printf( _( "Component '%s' FPID '%s' is not valid.\n" ),
|
||||||
|
GetChars( component->GetReference() ),
|
||||||
|
GetChars( newFPID.Format() ) );
|
||||||
|
aReporter->Report( msg );
|
||||||
|
}
|
||||||
|
|
||||||
|
retv = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// The footprint name should already be set.
|
||||||
|
component->SetFPID( newFPID );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return retv;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles()
|
bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles()
|
||||||
{
|
{
|
||||||
COMPONENT* component;
|
COMPONENT* component;
|
||||||
|
@ -242,7 +400,7 @@ bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles()
|
||||||
|
|
||||||
SEARCH_STACK& search = Prj().SchSearchS();
|
SEARCH_STACK& search = Prj().SchSearchS();
|
||||||
|
|
||||||
if( !FootprintLibs()->ConvertFromLegacy( search, m_netlist, m_ModuleLibNames, &reporter ) )
|
if( !convertFromLegacy( FootprintLibs(), search, m_netlist, m_ModuleLibNames, &reporter ) )
|
||||||
{
|
{
|
||||||
HTML_MESSAGE_BOX dlg( this, wxEmptyString );
|
HTML_MESSAGE_BOX dlg( this, wxEmptyString );
|
||||||
|
|
||||||
|
@ -300,6 +458,193 @@ bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else // new strategy
|
||||||
|
|
||||||
|
|
||||||
|
/// Return true if the resultant FPID has a certain nickname. The guess
|
||||||
|
/// is only made if this footprint resides in only one library.
|
||||||
|
/// @return int - 0 on success, 1 on not found, 2 on ambiguous i.e. multiple matches
|
||||||
|
static int guessNickname( FP_LIB_TABLE* aTbl, FPID* aFootprintId )
|
||||||
|
{
|
||||||
|
if( aFootprintId->GetLibNickname().size() )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
wxString nick;
|
||||||
|
wxString fpname = aFootprintId->GetFootprintName();
|
||||||
|
|
||||||
|
std::vector<wxString> nicks = aTbl->GetLogicalLibs();
|
||||||
|
|
||||||
|
// Search each library going through libraries alphabetically.
|
||||||
|
for( unsigned libNdx = 0; libNdx<nicks.size(); ++libNdx )
|
||||||
|
{
|
||||||
|
wxArrayString fpnames = aTbl->FootprintEnumerate( nicks[libNdx] );
|
||||||
|
|
||||||
|
for( unsigned nameNdx = 0; nameNdx<fpnames.size(); ++nameNdx )
|
||||||
|
{
|
||||||
|
if( fpname == fpnames[nameNdx] )
|
||||||
|
{
|
||||||
|
if( !nick )
|
||||||
|
nick = nicks[libNdx];
|
||||||
|
else
|
||||||
|
return 2; // duplicate, the guess would not be certain
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( nick.size() )
|
||||||
|
{
|
||||||
|
aFootprintId->SetLibNickname( nick );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool CVPCB_MAINFRAME::ReadNetListAndLinkFiles()
|
||||||
|
{
|
||||||
|
wxString msg;
|
||||||
|
bool hasMissingNicks = false;
|
||||||
|
FP_LIB_TABLE* tbl = FootprintLibs();
|
||||||
|
|
||||||
|
ReadSchematicNetlist();
|
||||||
|
|
||||||
|
if( m_ListCmp == NULL )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
LoadProjectFile( m_NetlistFileName.GetFullPath() );
|
||||||
|
LoadFootprintFiles();
|
||||||
|
BuildFOOTPRINTS_LISTBOX();
|
||||||
|
BuildLIBRARY_LISTBOX();
|
||||||
|
|
||||||
|
m_ListCmp->Clear();
|
||||||
|
m_undefinedComponentCnt = 0;
|
||||||
|
|
||||||
|
if( m_netlist.AnyFootprintsLinked() )
|
||||||
|
{
|
||||||
|
for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
COMPONENT* component = m_netlist.GetComponent( i );
|
||||||
|
|
||||||
|
if( component->GetFPID().empty() )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if( component->GetFPID().IsLegacy() )
|
||||||
|
hasMissingNicks = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if footprint links were generated before the footprint library table was implemented.
|
||||||
|
if( hasMissingNicks )
|
||||||
|
{
|
||||||
|
msg = wxT(
|
||||||
|
"Some of the assigned footprints are legacy entries (are missing lib nicknames). "
|
||||||
|
"Would you like CvPcb to attempt to convert them to the new required FPID format? "
|
||||||
|
"(If you answer no, then these assignments will be cleared out and you will "
|
||||||
|
"have to re-assign these footprints yourself.)"
|
||||||
|
);
|
||||||
|
|
||||||
|
if( IsOK( this, msg ) )
|
||||||
|
{
|
||||||
|
msg.Clear();
|
||||||
|
|
||||||
|
for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
COMPONENT* component = m_netlist.GetComponent( i );
|
||||||
|
|
||||||
|
if( component->GetFPID().IsLegacy() )
|
||||||
|
{
|
||||||
|
int guess = guessNickname( tbl, (FPID*) &component->GetFPID() );
|
||||||
|
|
||||||
|
switch( guess )
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
DBG(printf("%s: guessed OK ref:%s fpid:%s\n", __func__,
|
||||||
|
TO_UTF8( component->GetReference() ), component->GetFPID().Format().c_str() );)
|
||||||
|
m_modified = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
msg += wxString::Format( _(
|
||||||
|
"Component '%s' footprint '%s' was <b>not found</b> in any library.\n" ),
|
||||||
|
GetChars( component->GetReference() ),
|
||||||
|
GetChars( component->GetFPID().GetFootprintName() )
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
msg += wxString::Format( _(
|
||||||
|
"Component '%s' footprint '%s' was found in <b>multiple</b> libraries.\n" ),
|
||||||
|
GetChars( component->GetReference() ),
|
||||||
|
GetChars( component->GetFPID().GetFootprintName() )
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( msg.size() )
|
||||||
|
{
|
||||||
|
HTML_MESSAGE_BOX dlg( this, wxEmptyString );
|
||||||
|
|
||||||
|
dlg.MessageSet( wxT( "The following errors occurred attempting to convert the "
|
||||||
|
"footprint assignments:\n\n" ) );
|
||||||
|
dlg.ListSet( msg );
|
||||||
|
dlg.MessageSet( wxT( "\nYou will need to reassign them manually if you want them "
|
||||||
|
"to be updated correctly the next time you import the "
|
||||||
|
"netlist in Pcbnew." ) );
|
||||||
|
dlg.ShowModal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Clear the legacy footprint assignments.
|
||||||
|
for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
COMPONENT* component = m_netlist.GetComponent( i );
|
||||||
|
|
||||||
|
if( component->GetFPID().IsLegacy() )
|
||||||
|
{
|
||||||
|
component->SetFPID( FPID() /* empty */ );
|
||||||
|
m_modified = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
COMPONENT* component = m_netlist.GetComponent( i );
|
||||||
|
|
||||||
|
msg.Printf( CMP_FORMAT, m_ListCmp->GetCount() + 1,
|
||||||
|
GetChars( component->GetReference() ),
|
||||||
|
GetChars( component->GetValue() ),
|
||||||
|
GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) );
|
||||||
|
|
||||||
|
m_ListCmp->AppendLine( msg );
|
||||||
|
|
||||||
|
if( component->GetFPID().empty() )
|
||||||
|
{
|
||||||
|
m_undefinedComponentCnt += 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !m_netlist.IsEmpty() )
|
||||||
|
m_ListCmp->SetSelection( 0, true );
|
||||||
|
|
||||||
|
DisplayStatus();
|
||||||
|
|
||||||
|
UpdateTitle();
|
||||||
|
|
||||||
|
UpdateFileHistory( m_NetlistFileName.GetFullPath() );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int CVPCB_MAINFRAME::SaveCmpLinkFile( const wxString& aFullFileName )
|
int CVPCB_MAINFRAME::SaveCmpLinkFile( const wxString& aFullFileName )
|
||||||
{
|
{
|
||||||
|
|
|
@ -136,7 +136,7 @@ bool LIB_ALIAS::SaveDoc( OUTPUTFORMATTER& aFormatter )
|
||||||
|
|
||||||
aFormatter.Print( 0, "$ENDCMP\n" );
|
aFormatter.Print( 0, "$ENDCMP\n" );
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -731,7 +731,7 @@ bool CMP_LIBRARY::Save( OUTPUTFORMATTER& aFormatter )
|
||||||
|
|
||||||
aFormatter.Print( 0, "#\n#End Library\n" );
|
aFormatter.Print( 0, "#\n#End Library\n" );
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
|
@ -756,7 +756,7 @@ bool CMP_LIBRARY::SaveDocs( OUTPUTFORMATTER& aFormatter )
|
||||||
|
|
||||||
aFormatter.Print( 0, "#\n#End Doc Library\n" );
|
aFormatter.Print( 0, "#\n#End Doc Library\n" );
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -249,7 +249,7 @@ void DIALOG_BOM::installPluginsList()
|
||||||
{
|
{
|
||||||
cfg_parser.Parse();
|
cfg_parser.Parse();
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
// wxLogMessage( ioe.errorText );
|
// wxLogMessage( ioe.errorText );
|
||||||
}
|
}
|
||||||
|
|
|
@ -668,7 +668,7 @@ void SCH_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg )
|
||||||
{
|
{
|
||||||
m_TemplateFieldNames.Parse( &lexer );
|
m_TemplateFieldNames.Parse( &lexer );
|
||||||
}
|
}
|
||||||
catch( IO_ERROR& e )
|
catch( const IO_ERROR& e )
|
||||||
{
|
{
|
||||||
// @todo show error msg
|
// @todo show error msg
|
||||||
DBG( printf( "templatefieldnames parsing error: '%s'\n",
|
DBG( printf( "templatefieldnames parsing error: '%s'\n",
|
||||||
|
|
|
@ -1049,7 +1049,7 @@ bool NETLIST_EXPORT_TOOL::WriteKiCadNetList( const wxString& aOutFileName )
|
||||||
|
|
||||||
xroot->Format( &formatter, 0 );
|
xroot->Format( &formatter, 0 );
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
DisplayError( NULL, ioe.errorText );
|
DisplayError( NULL, ioe.errorText );
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -225,14 +225,14 @@ void LIB_EDIT_FRAME::SaveOneSymbol()
|
||||||
formatter.Print( 0, "ENDDRAW\n" );
|
formatter.Print( 0, "ENDDRAW\n" );
|
||||||
formatter.Print( 0, "ENDDEF\n" );
|
formatter.Print( 0, "ENDDEF\n" );
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
msg.Printf( _( "An error occurred attempting to save symbol file '%s'" ),
|
msg.Printf( _( "An error occurred attempting to save symbol file '%s'" ),
|
||||||
GetChars( fn.GetFullPath() ) );
|
GetChars( fn.GetFullPath() ) );
|
||||||
DisplayError( this, msg );
|
DisplayError( this, msg );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
DisplayError( this, ioe.errorText );
|
DisplayError( this, ioe.errorText );
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -38,6 +38,7 @@ class wxFileName;
|
||||||
class OUTPUTFORMATTER;
|
class OUTPUTFORMATTER;
|
||||||
class MODULE;
|
class MODULE;
|
||||||
class FP_LIB_TABLE_LEXER;
|
class FP_LIB_TABLE_LEXER;
|
||||||
|
class FPID;
|
||||||
class NETLIST;
|
class NETLIST;
|
||||||
class REPORTER;
|
class REPORTER;
|
||||||
class SEARCH_STACK;
|
class SEARCH_STACK;
|
||||||
|
@ -455,6 +456,21 @@ public:
|
||||||
|
|
||||||
//-----</PLUGIN API SUBSET, REBASED ON aNickname>---------------------------
|
//-----</PLUGIN API SUBSET, REBASED ON aNickname>---------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function FootprintLoadWithOptionalNickname
|
||||||
|
* loads a footprint having @a aFootprintId with possibly an empty nickname.
|
||||||
|
*
|
||||||
|
* @param aFootprintId the [nickname] & fooprint name of the footprint to load.
|
||||||
|
*
|
||||||
|
* @return MODULE* - if found caller owns it, else NULL if not found.
|
||||||
|
*
|
||||||
|
* @throw IO_ERROR if the library cannot be found or read. No exception
|
||||||
|
* is thrown in the case where aFootprintName cannot be found.
|
||||||
|
* @throw PARSE_ERROR if @a aFootprintId is not parsed OK.
|
||||||
|
*/
|
||||||
|
MODULE* FootprintLoadWithOptionalNickname( const FPID& aFootprintId )
|
||||||
|
throw( IO_ERROR, PARSE_ERROR );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetDescription
|
* Function GetDescription
|
||||||
* returns the library desicription from @a aNickname, or an empty string
|
* returns the library desicription from @a aNickname, or an empty string
|
||||||
|
@ -499,19 +515,6 @@ public:
|
||||||
*/
|
*/
|
||||||
bool IsEmpty( bool aIncludeFallback = true );
|
bool IsEmpty( bool aIncludeFallback = true );
|
||||||
|
|
||||||
/**
|
|
||||||
* Function ConvertFromLegacy
|
|
||||||
* converts the footprint names in \a aNetList from the legacy format to the #FPID format.
|
|
||||||
*
|
|
||||||
* @param aNetList is the #NETLIST object to convert.
|
|
||||||
* @param aLibNames is the list of legacy footprint library names from the currently loaded
|
|
||||||
* project.
|
|
||||||
* @param aReporter is the #REPORTER object to dump messages into.
|
|
||||||
* @return true if all footprint names were successfully converted to a valid FPID.
|
|
||||||
*/
|
|
||||||
bool ConvertFromLegacy( SEARCH_STACK& aSStack, NETLIST& aNetList,
|
|
||||||
const wxArrayString& aLibNames, REPORTER* aReporter = NULL ) throw( IO_ERROR );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function ExpandSubstitutions
|
* Function ExpandSubstitutions
|
||||||
* replaces any environment variable references with their values and is
|
* replaces any environment variable references with their values and is
|
||||||
|
|
|
@ -153,7 +153,6 @@ public:
|
||||||
*/
|
*/
|
||||||
bool IsValid() const { return !nickname.empty() && !footprint.empty(); }
|
bool IsValid() const { return !nickname.empty() && !footprint.empty(); }
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function IsLegacy
|
* Function IsLegacy
|
||||||
* @return true if the #FPID only has the #footprint name defined.
|
* @return true if the #FPID only has the #footprint name defined.
|
||||||
|
|
|
@ -78,7 +78,7 @@ typedef const PTREE CPTREE;
|
||||||
* PTREE doc;
|
* PTREE doc;
|
||||||
* Scan( &doc, &lexer );
|
* Scan( &doc, &lexer );
|
||||||
* }
|
* }
|
||||||
* catch( IO_ERROR ioe )
|
* catch( const IO_ERROR& ioe )
|
||||||
* {
|
* {
|
||||||
* fprintf( stderr, "%s\n", TO_UTF8( ioe.errorText ) );
|
* fprintf( stderr, "%s\n", TO_UTF8( ioe.errorText ) );
|
||||||
* }
|
* }
|
||||||
|
|
|
@ -716,7 +716,7 @@ void DIR_LIB_SOURCE::Test( int argc, char** argv )
|
||||||
printf( "std::exception\n" );
|
printf( "std::exception\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
catch( IO_ERROR& ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
printf( "exception: %s\n", (const char*) ioe.errorText.ToUTF8() ) );
|
printf( "exception: %s\n", (const char*) ioe.errorText.ToUTF8() ) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,7 @@ int main( int argc, char** argv )
|
||||||
|
|
||||||
printf( "%*s^\n", ioe.byteIndex>=1 ? ioe.byteIndex-1 : 0, "" );
|
printf( "%*s^\n", ioe.byteIndex>=1 ? ioe.byteIndex-1 : 0, "" );
|
||||||
}
|
}
|
||||||
catch( IO_ERROR& ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
printf( "%s\n", (const char*) ioe.errorText.ToUTF8() );
|
printf( "%s\n", (const char*) ioe.errorText.ToUTF8() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,7 @@ public:
|
||||||
m_fileout = new FILE_OUTPUTFORMATTER( aFilename );
|
m_fileout = new FILE_OUTPUTFORMATTER( aFilename );
|
||||||
m_out = m_fileout;
|
m_out = m_fileout;
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
wxMessageBox( ioe.errorText, _("Error writing page layout descr file" ) );
|
wxMessageBox( ioe.errorText, _("Error writing page layout descr file" ) );
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ public:
|
||||||
m_writer = new STRING_FORMATTER();
|
m_writer = new STRING_FORMATTER();
|
||||||
m_out = m_writer;
|
m_out = m_writer;
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
wxMessageBox( ioe.errorText, _("Error writing page layout descr file" ) );
|
wxMessageBox( ioe.errorText, _("Error writing page layout descr file" ) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,13 +66,16 @@ bool PCB_CALCULATOR_FRAME::ReadDataFile()
|
||||||
{
|
{
|
||||||
datafile_parser.Parse( datafile );
|
datafile_parser.Parse( datafile );
|
||||||
}
|
}
|
||||||
catch( IO_ERROR& ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
delete datafile;
|
delete datafile;
|
||||||
ioe.errorText += '\n';
|
|
||||||
ioe.errorText += _("Data file error.");
|
|
||||||
|
|
||||||
wxMessageBox( ioe.errorText );
|
wxString msg = ioe.errorText;
|
||||||
|
|
||||||
|
msg += wxChar('\n');
|
||||||
|
msg += _("Data file error.");
|
||||||
|
|
||||||
|
wxMessageBox( msg );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +102,7 @@ bool PCB_CALCULATOR_FRAME::WriteDataFile()
|
||||||
while( nestlevel-- )
|
while( nestlevel-- )
|
||||||
formatter.Print( nestlevel, ")\n" );
|
formatter.Print( nestlevel, ")\n" );
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -426,7 +426,7 @@ bool DIALOG_NETLIST::verifyFootprints( const wxString& aNetlistFilename,
|
||||||
std::auto_ptr< NETLIST_READER > nlr( netlistReader );
|
std::auto_ptr< NETLIST_READER > nlr( netlistReader );
|
||||||
netlistReader->LoadNetlist();
|
netlistReader->LoadNetlist();
|
||||||
}
|
}
|
||||||
catch( IO_ERROR& ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
msg.Printf( _( "Error loading netlist file:\n%s" ), ioe.errorText.GetData() );
|
msg.Printf( _( "Error loading netlist file:\n%s" ), ioe.errorText.GetData() );
|
||||||
wxMessageBox( msg, _( "Netlist Load Error" ), wxOK | wxICON_ERROR );
|
wxMessageBox( msg, _( "Netlist Load Error" ), wxOK | wxICON_ERROR );
|
||||||
|
|
|
@ -403,7 +403,7 @@ bool Export_IDF3( BOARD* aPcb, const wxString& aFullFileName, double aUseThou )
|
||||||
|
|
||||||
idfBoard.Finish();
|
idfBoard.Finish();
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
wxLogDebug( wxT( "An error occurred attemping export to IDFv3.\n\nError: %s" ),
|
wxLogDebug( wxT( "An error occurred attemping export to IDFv3.\n\nError: %s" ),
|
||||||
GetChars( ioe.errorText ) );
|
GetChars( ioe.errorText ) );
|
||||||
|
|
|
@ -713,7 +713,7 @@ bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool
|
||||||
fprintf( rptfile, "$EndMODULE %s\n\n", TO_UTF8 (Module->GetReference() ) );
|
fprintf( rptfile, "$EndMODULE %s\n\n", TO_UTF8 (Module->GetReference() ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
DisplayError( NULL, ioe.errorText );
|
DisplayError( NULL, ioe.errorText );
|
||||||
}
|
}
|
||||||
|
|
|
@ -404,7 +404,7 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
||||||
SetBoard( loadedBoard );
|
SetBoard( loadedBoard );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
wxString msg = wxString::Format( _( "Error loading board.\n%s" ),
|
wxString msg = wxString::Format( _( "Error loading board.\n%s" ),
|
||||||
ioe.errorText.GetData() );
|
ioe.errorText.GetData() );
|
||||||
|
@ -692,7 +692,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
|
||||||
|
|
||||||
pi->Save( pcbFileName.GetFullPath(), GetBoard(), NULL );
|
pi->Save( pcbFileName.GetFullPath(), GetBoard(), NULL );
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
wxString msg = wxString::Format( _( "Error saving board.\n%s" ),
|
wxString msg = wxString::Format( _( "Error saving board.\n%s" ),
|
||||||
ioe.errorText.GetData() );
|
ioe.errorText.GetData() );
|
||||||
|
|
|
@ -570,7 +570,7 @@ int main( int argc, char** argv )
|
||||||
printf("[%d]:%s\n", i, TO_UTF8( fps[i] ) );
|
printf("[%d]:%s\n", i, TO_UTF8( fps[i] ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
printf( "%s\n", TO_UTF8(ioe.errorText) );
|
printf( "%s\n", TO_UTF8(ioe.errorText) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -204,7 +204,7 @@ public:
|
||||||
* or
|
* or
|
||||||
* IO_MGR::Save(...);
|
* IO_MGR::Save(...);
|
||||||
* }
|
* }
|
||||||
* catch( IO_ERROR ioe )
|
* catch( const IO_ERROR& ioe )
|
||||||
* {
|
* {
|
||||||
* // grab text from ioe, show in error window.
|
* // grab text from ioe, show in error window.
|
||||||
* }
|
* }
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -199,7 +199,7 @@ MODULE* FOOTPRINT_EDIT_FRAME::Import_Module()
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
DisplayError( this, ioe.errorText );
|
DisplayError( this, ioe.errorText );
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -222,7 +222,7 @@ MODULE* FOOTPRINT_EDIT_FRAME::Import_Module()
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
DisplayError( this, ioe.errorText );
|
DisplayError( this, ioe.errorText );
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -259,7 +259,7 @@ MODULE* FOOTPRINT_EDIT_FRAME::Import_Module()
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
DisplayError( this, ioe.errorText );
|
DisplayError( this, ioe.errorText );
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -334,7 +334,7 @@ void FOOTPRINT_EDIT_FRAME::Export_Module( MODULE* aModule )
|
||||||
fprintf( fp, "%s", pcb_io.GetStringOutput( false ).c_str() );
|
fprintf( fp, "%s", pcb_io.GetStringOutput( false ).c_str() );
|
||||||
fclose( fp );
|
fclose( fp );
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
DisplayError( this, ioe.errorText );
|
DisplayError( this, ioe.errorText );
|
||||||
return;
|
return;
|
||||||
|
@ -357,7 +357,7 @@ bool FOOTPRINT_EDIT_FRAME::SaveCurrentModule( const wxString* aLibPath )
|
||||||
|
|
||||||
pi->FootprintSave( libPath, GetBoard()->m_Modules );
|
pi->FootprintSave( libPath, GetBoard()->m_Modules );
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
DisplayError( this, ioe.errorText );
|
DisplayError( this, ioe.errorText );
|
||||||
return false;
|
return false;
|
||||||
|
@ -429,7 +429,7 @@ wxString FOOTPRINT_EDIT_FRAME::CreateNewLibrary()
|
||||||
writable = pi->IsFootprintLibWritable( libPath );
|
writable = pi->IsFootprintLibWritable( libPath );
|
||||||
exists = true; // no exception was thrown, lib must exist.
|
exists = true; // no exception was thrown, lib must exist.
|
||||||
}
|
}
|
||||||
catch( IO_ERROR )
|
catch( const IO_ERROR& )
|
||||||
{
|
{
|
||||||
// ignore, original values of 'writable' and 'exists' are accurate.
|
// ignore, original values of 'writable' and 'exists' are accurate.
|
||||||
}
|
}
|
||||||
|
@ -455,7 +455,7 @@ wxString FOOTPRINT_EDIT_FRAME::CreateNewLibrary()
|
||||||
|
|
||||||
pi->FootprintLibCreate( libPath );
|
pi->FootprintLibCreate( libPath );
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
DisplayError( this, ioe.errorText );
|
DisplayError( this, ioe.errorText );
|
||||||
return wxEmptyString;
|
return wxEmptyString;
|
||||||
|
@ -499,7 +499,7 @@ bool FOOTPRINT_EDIT_FRAME::DeleteModuleFromCurrentLibrary()
|
||||||
{
|
{
|
||||||
FootprintLibs()->FootprintDelete( nickname, fpname );
|
FootprintLibs()->FootprintDelete( nickname, fpname );
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
DisplayError( this, ioe.errorText );
|
DisplayError( this, ioe.errorText );
|
||||||
return false;
|
return false;
|
||||||
|
@ -568,7 +568,7 @@ void PCB_EDIT_FRAME::ArchiveModulesOnBoard( bool aNewModulesOnly )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
DisplayError( this, ioe.errorText );
|
DisplayError( this, ioe.errorText );
|
||||||
}
|
}
|
||||||
|
@ -655,7 +655,7 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibrary,
|
||||||
// own if the library or footprint is not writable.
|
// own if the library or footprint is not writable.
|
||||||
FootprintLibs()->FootprintSave( aLibrary, aModule );
|
FootprintLibs()->FootprintSave( aLibrary, aModule );
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
DisplayError( this, ioe.errorText );
|
DisplayError( this, ioe.errorText );
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -220,7 +220,7 @@ MODULE* PCB_BASE_FRAME::LoadModuleFromLibrary( const wxString& aLibrary,
|
||||||
{
|
{
|
||||||
module = loadFootprint( fpid );
|
module = loadFootprint( fpid );
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
wxLogDebug( wxT( "An error occurred attemping to load footprint '%s'.\n\nError: %s" ),
|
wxLogDebug( wxT( "An error occurred attemping to load footprint '%s'.\n\nError: %s" ),
|
||||||
fpid.Format().c_str(), GetChars( ioe.errorText ) );
|
fpid.Format().c_str(), GetChars( ioe.errorText ) );
|
||||||
|
@ -252,7 +252,7 @@ MODULE* PCB_BASE_FRAME::LoadModuleFromLibrary( const wxString& aLibrary,
|
||||||
{
|
{
|
||||||
module = loadFootprint( fpid );
|
module = loadFootprint( fpid );
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
wxLogDebug( wxT( "An error occurred attemping to load footprint '%s'.\n\nError: %s" ),
|
wxLogDebug( wxT( "An error occurred attemping to load footprint '%s'.\n\nError: %s" ),
|
||||||
fpid.Format().c_str(), GetChars( ioe.errorText ) );
|
fpid.Format().c_str(), GetChars( ioe.errorText ) );
|
||||||
|
@ -304,7 +304,7 @@ MODULE* PCB_BASE_FRAME::LoadFootprint( const FPID& aFootprintId )
|
||||||
{
|
{
|
||||||
module = loadFootprint( aFootprintId );
|
module = loadFootprint( aFootprintId );
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
wxLogDebug( wxT( "An error occurred attemping to load footprint '%s'.\n\nError: %s" ),
|
wxLogDebug( wxT( "An error occurred attemping to load footprint '%s'.\n\nError: %s" ),
|
||||||
aFootprintId.Format().c_str(), GetChars( ioe.errorText ) );
|
aFootprintId.Format().c_str(), GetChars( ioe.errorText ) );
|
||||||
|
@ -321,31 +321,7 @@ MODULE* PCB_BASE_FRAME::loadFootprint( const FPID& aFootprintId )
|
||||||
|
|
||||||
wxCHECK_MSG( fptbl, NULL, wxT( "Cannot look up FPID in NULL FP_LIB_TABLE." ) );
|
wxCHECK_MSG( fptbl, NULL, wxT( "Cannot look up FPID in NULL FP_LIB_TABLE." ) );
|
||||||
|
|
||||||
wxString nickname = aFootprintId.GetLibNickname();
|
return fptbl->FootprintLoadWithOptionalNickname( aFootprintId );
|
||||||
wxString fpname = aFootprintId.GetFootprintName();
|
|
||||||
|
|
||||||
if( nickname.size() )
|
|
||||||
{
|
|
||||||
return fptbl->FootprintLoad( nickname, fpname );
|
|
||||||
}
|
|
||||||
|
|
||||||
// user did not enter a nickname, just a footprint name, help him out a little:
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::vector<wxString> nicks = fptbl->GetLogicalLibs();
|
|
||||||
|
|
||||||
// Search each library going through libraries alphabetically.
|
|
||||||
for( unsigned i = 0; i<nicks.size(); ++i )
|
|
||||||
{
|
|
||||||
// FootprintLoad() returns NULL on not found, does not throw exception
|
|
||||||
// unless there's an IO_ERROR.
|
|
||||||
MODULE* ret = fptbl->FootprintLoad( nicks[i], fpname );
|
|
||||||
if( ret )
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -557,7 +533,7 @@ void FOOTPRINT_EDIT_FRAME::OnSaveLibraryAs( wxCommandEvent& aEvent )
|
||||||
// m is deleted here by auto_ptr.
|
// m is deleted here by auto_ptr.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
DisplayError( this, ioe.errorText );
|
DisplayError( this, ioe.errorText );
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -279,7 +279,7 @@ wxString FOOTPRINT_EDIT_FRAME::getLibPath()
|
||||||
|
|
||||||
return row->GetFullURI( true );
|
return row->GetFullURI( true );
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
return wxEmptyString;
|
return wxEmptyString;
|
||||||
}
|
}
|
||||||
|
@ -639,7 +639,7 @@ void FOOTPRINT_EDIT_FRAME::updateTitle()
|
||||||
if( !writable )
|
if( !writable )
|
||||||
title += _( " [Read Only]" );
|
title += _( " [Read Only]" );
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
// user may be bewildered as to why after selecting a library it is not showing up
|
// user may be bewildered as to why after selecting a library it is not showing up
|
||||||
// in the title, we could show an error message, but that should have been done at time
|
// in the title, we could show an error message, but that should have been done at time
|
||||||
|
|
|
@ -82,7 +82,7 @@ void PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFileName,
|
||||||
netlistReader->LoadNetlist();
|
netlistReader->LoadNetlist();
|
||||||
loadFootprints( netlist, aReporter );
|
loadFootprints( netlist, aReporter );
|
||||||
}
|
}
|
||||||
catch( IO_ERROR& ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
msg.Printf( _( "Error loading netlist.\n%s" ), ioe.errorText.GetData() );
|
msg.Printf( _( "Error loading netlist.\n%s" ), ioe.errorText.GetData() );
|
||||||
wxMessageBox( msg, _( "Netlist Load Error" ), wxOK | wxICON_ERROR );
|
wxMessageBox( msg, _( "Netlist Load Error" ), wxOK | wxICON_ERROR );
|
||||||
|
|
|
@ -162,7 +162,7 @@ bool PCB_EDIT_FRAME::ExportSpecctraFile( const wxString& aFullFilename )
|
||||||
// if an exception is thrown by FromBOARD or ExportPCB(), then
|
// if an exception is thrown by FromBOARD or ExportPCB(), then
|
||||||
// ~SPECCTRA_DB() will close the file.
|
// ~SPECCTRA_DB() will close the file.
|
||||||
}
|
}
|
||||||
catch( IO_ERROR& ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
ok = false;
|
ok = false;
|
||||||
|
|
||||||
|
@ -1322,7 +1322,7 @@ bool SPECCTRA_DB::GetBoardPolygonOutlines( BOARD* aBoard,
|
||||||
aHoles.CloseLastContour();
|
aHoles.CloseLastContour();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
// Creates a valid polygon outline is not possible.
|
// Creates a valid polygon outline is not possible.
|
||||||
// So uses the board edge cuts bounding box to create a
|
// So uses the board edge cuts bounding box to create a
|
||||||
|
|
|
@ -102,14 +102,15 @@ void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event )
|
||||||
db.LoadSESSION( fullFileName );
|
db.LoadSESSION( fullFileName );
|
||||||
db.FromSESSION( GetBoard() );
|
db.FromSESSION( GetBoard() );
|
||||||
}
|
}
|
||||||
catch( IO_ERROR& ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
ioe.errorText += '\n';
|
wxString msg = ioe.errorText;
|
||||||
ioe.errorText += _("BOARD may be corrupted, do not save it.");
|
msg += '\n';
|
||||||
ioe.errorText += '\n';
|
msg += _("BOARD may be corrupted, do not save it.");
|
||||||
ioe.errorText += _("Fix problem and try again.");
|
msg += '\n';
|
||||||
|
msg += _("Fix problem and try again.");
|
||||||
|
|
||||||
DisplayError( this, ioe.errorText );
|
DisplayError( this, msg );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ int main( int argc, char** argv )
|
||||||
// db.LoadPCB( filename );
|
// db.LoadPCB( filename );
|
||||||
db.LoadSESSION( filename );
|
db.LoadSESSION( filename );
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
fprintf( stderr, "%s\n", TO_UTF8(ioe.errorText) );
|
fprintf( stderr, "%s\n", TO_UTF8(ioe.errorText) );
|
||||||
failed = true;
|
failed = true;
|
||||||
|
|
|
@ -83,7 +83,7 @@ int main( int argc, char** argv )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
fprintf( stderr, "%s\n", TO_UTF8( ioe.errorText ) );
|
fprintf( stderr, "%s\n", TO_UTF8( ioe.errorText ) );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue