Commit 53e04ce7 authored by Dick Hollenbeck's avatar Dick Hollenbeck

cvpcb was not filtering on the current library when USE_FP_LIB_TABLE.

<%s> being replaced with '%s' because the former in invisible in html panels.
Cure some compiler warnings.
parent 0ca123d2
......@@ -101,8 +101,8 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintLibNames )
FOOTPRINT_INFO* fpinfo = new FOOTPRINT_INFO();
fpinfo->SetLibraryName( filename.GetName() );
fpinfo->SetLibraryPath( filename.GetFullPath() );
fpinfo->SetNickname( filename.GetName() );
fpinfo->SetLibPath( filename.GetFullPath() );
fpinfo->m_Module = fpnames[i];
fpinfo->m_padCount = m->GetPadCount( MODULE::DO_NOT_INCLUDE_NPTH );
fpinfo->m_KeyWord = m->GetKeywords();
......@@ -168,9 +168,7 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( FP_LIB_TABLE* aTable, const wxString* a
FOOTPRINT_INFO* fpinfo = new FOOTPRINT_INFO();
fpinfo->SetLibraryName( nickname );
//fpinfo->SetLibraryPath( path );
fpinfo->SetNickname( nickname );
fpinfo->m_Module = fpnames[i];
fpinfo->m_padCount = m->GetPadCount( MODULE::DO_NOT_INCLUDE_NPTH );
......@@ -202,13 +200,13 @@ FOOTPRINT_INFO* FOOTPRINT_LIST::GetModuleInfo( const wxString& aFootprintName )
FPID fpid;
wxCHECK_MSG( fpid.Parse( aFootprintName ) < 0, NULL,
wxString::Format( wxT( "<%s> is not a valid FPID." ),
wxString::Format( wxT( "'%s' is not a valid FPID." ),
GetChars( aFootprintName ) ) );
wxString libNickname = FROM_UTF8( fpid.GetLibNickname().c_str() );
wxString footprintName = FROM_UTF8( fpid.GetFootprintName().c_str() );
if( libNickname == footprint.m_libName && footprintName == footprint.m_Module )
if( libNickname == footprint.m_nickname && footprintName == footprint.m_Module )
return &footprint;
#else
if( aFootprintName.CmpNoCase( footprint.m_Module ) == 0 )
......@@ -221,10 +219,14 @@ FOOTPRINT_INFO* FOOTPRINT_LIST::GetModuleInfo( const wxString& aFootprintName )
bool FOOTPRINT_INFO::InLibrary( const wxString& aLibrary ) const
{
#if defined( USE_FP_LIB_TABLE )
return aLibrary == m_nickname;
#else
if( aLibrary.IsEmpty() )
return false;
if( aLibrary == m_libName || aLibrary == m_libPath )
if( aLibrary == m_nickname || aLibrary == m_lib_path )
return true;
wxFileName filename = aLibrary;
......@@ -232,11 +234,12 @@ bool FOOTPRINT_INFO::InLibrary( const wxString& aLibrary ) const
if( filename.GetExt().IsEmpty() )
filename.SetExt( LegacyFootprintLibPathExtension );
if( filename.GetFullPath() == m_libPath )
if( filename.GetFullPath() == m_lib_path )
return true;
if( filename.GetPath().IsEmpty() )
filename = wxGetApp().FindLibraryPath( filename.GetFullName() );
return filename.GetFullPath() == m_libPath;
return filename.GetFullPath() == m_lib_path;
#endif
}
......@@ -118,6 +118,9 @@ void WORKSHEET_VIEWITEM::ViewDraw( int aLayer, GAL* aGal ) const
case WS_DRAW_ITEM_BASE::wsg_text:
draw( static_cast<const WS_DRAW_ITEM_TEXT*>( item ), aGal );
break;
case WS_DRAW_ITEM_BASE::wsg_bitmap:
break;
}
item = drawList.GetNext();
......
......@@ -550,19 +550,22 @@ MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& aFootprintName )
void DISPLAY_FOOTPRINTS_FRAME::InitDisplay()
{
wxString msg;
CVPCB_MAINFRAME * parentframe = (CVPCB_MAINFRAME *) GetParent();
CVPCB_MAINFRAME* parentframe = (CVPCB_MAINFRAME *) GetParent();
wxString footprintName = parentframe->m_FootprintList->GetSelectedFootprint();
if( !footprintName.IsEmpty() )
{
msg.Printf( _( "Footprint: %s" ), GetChars( footprintName ) );
SetTitle( msg );
FOOTPRINT_INFO* module_info = parentframe->m_footprints.GetModuleInfo( footprintName );
const wxChar *libname;
if( module_info )
libname = GetChars( module_info->GetLibraryPath() );
libname = GetChars( module_info->GetNickname() );
else
libname = GetChars( wxT( "???" ) );
......@@ -582,7 +585,6 @@ void DISPLAY_FOOTPRINTS_FRAME::InitDisplay()
GetBoard()->m_Modules.PushBack( module );
Zoom_Automatique( false );
}
else // No footprint to display. Erase old footprint, if any
{
......
......@@ -140,7 +140,7 @@ void FOOTPRINTS_LISTBOX::SetFootprints( FOOTPRINT_LIST& aList, const wxString& a
GetChars( aList.GetItem( ii ).m_Module ) );
#else
msg.Printf( wxT( "%3zu %s:%s" ), newList.GetCount() + 1,
GetChars( aList.GetItem( ii ).GetLibraryName() ),
GetChars( aList.GetItem( ii ).GetNickname() ),
GetChars( aList.GetItem( ii ).m_Module ) );
#endif
newList.Add( msg );
......@@ -164,7 +164,7 @@ void FOOTPRINTS_LISTBOX::SetFootprints( FOOTPRINT_LIST& aList, const wxString& a
aList.GetItem( ii ).m_Module.GetData() );
#else
msg.Printf( wxT( "%3zu %s:%s" ), newList.GetCount() + 1,
GetChars( aList.GetItem( ii ).GetLibraryName() ),
GetChars( aList.GetItem( ii ).GetNickname() ),
GetChars( aList.GetItem( ii ).m_Module ) );
#endif
newList.Add( msg );
......@@ -188,8 +188,9 @@ void FOOTPRINTS_LISTBOX::SetFootprints( FOOTPRINT_LIST& aList, const wxString& a
SetSelection( selection, true );
RefreshItems( 0L, m_footprintList.GetCount()-1 );
#if defined (__WXGTK__ )
#if defined (__WXGTK__ ) //&& wxMINOR_VERSION == 8
// @bug On GTK and wxWidgets 2.8.x, this will assert in debug builds because the
// column parameter is -1. This was the only way to prevent GTK3 from
// ellipsizing long strings down to a few characters. It still doesn't set
// the scroll bars correctly (too short) but it's better than any of the
......
......@@ -128,7 +128,7 @@ void LIBRARY_LISTBOX::SetLibraryList( const wxArrayString& aList )
{
RefreshItems( 0L, m_libraryList.Count()-1 );
#if defined (__WXGTK__ )
#if defined (__WXGTK__ ) // && wxMINOR_VERSION == 8
// @bug On GTK and wxWidgets 2.8.x, this will assert in debug builds because the
// column parameter is -1. This was the only way to prevent GTK3 from
// ellipsizing long strings down to a few characters. It still doesn't set
......
......@@ -47,13 +47,21 @@ class FP_LIB_TABLE;
class FOOTPRINT_INFO
{
public:
wxString m_libName; ///< Name of the library containing this module excluding path and ext.
wxString m_libPath; ///< The full library name and path associated the footprint.
wxString m_Module; ///< Module name.
int m_Num; ///< Order number in the display list.
wxString m_Doc; ///< Footprint description.
wxString m_KeyWord; ///< Footprint key words.
unsigned m_padCount; ///< Number of pads
// friend bool operator<( const FOOTPRINT_INFO& item1, const FOOTPRINT_INFO& item2 );
wxString m_nickname; ///< the library nickname, eventually
#if !defined(USE_FP_LIB_TABLE)
wxString m_lib_path;
#endif
wxString m_Module; ///< Module name.
int m_Num; ///< Order number in the display list.
wxString m_Doc; ///< Footprint description.
wxString m_KeyWord; ///< Footprint key words.
unsigned m_padCount; ///< Number of pads
FOOTPRINT_INFO()
{
......@@ -61,20 +69,22 @@ public:
m_padCount = 0;
}
const wxString& GetFootprintName() const { return m_Module; }
const wxString& GetFootprintName() const { return m_Module; }
void SetLibraryName( const wxString& aLibName ) { m_libName = aLibName; }
const wxString& GetLibraryName() const { return m_libName; }
void SetNickname( const wxString& aLibNickname ) { m_nickname = aLibNickname; }
const wxString& GetNickname() const { return m_nickname; }
void SetLibraryPath( const wxString& aLibPath ) { m_libPath = aLibPath; }
const wxString& GetLibraryPath() const { return m_libPath; }
#if !defined(USE_FP_LIB_TABLE)
void SetLibPath( const wxString& aLibPath ) { m_lib_path = aLibPath; }
const wxString& GetLibPath() const { return m_lib_path; }
#endif
/**
* Function InLibrary
* tests if the #FOOTPRINT_INFO object was loaded from \a aLibrary.
*
* @param aLibrary is the file name or the fully qualified path and file name
* to test.
* @param aLibrary is the nickname of the library to test.
*
* @return true if the #FOOTPRINT_INFO object was loaded from \a aLibrary. Otherwise
* false.
*/
......@@ -82,6 +92,21 @@ public:
};
/// FOOTPRINT object list sort function.
inline bool operator<( const FOOTPRINT_INFO& item1, const FOOTPRINT_INFO& item2 )
{
#if defined( USE_FP_LIB_TABLE )
int retv = StrNumCmp( item1.m_nickname, item2.m_nickname, INT_MAX, true );
if( retv != 0 )
return retv < 0;
#endif
return StrNumCmp( item1.m_Module, item2.m_Module, INT_MAX, true ) < 0;
}
class FOOTPRINT_LIST
{
public:
......@@ -141,18 +166,4 @@ public:
bool ReadFootprintFiles( FP_LIB_TABLE* aTable, const wxString* aNickname = NULL );
};
/// FOOTPRINT object list sort function.
inline bool operator<( const FOOTPRINT_INFO& item1, const FOOTPRINT_INFO& item2 )
{
#if defined( USE_FP_LIB_TABLE )
int retv = StrNumCmp( item1.m_libName, item2.m_libName, INT_MAX, true );
if( retv != 0 )
return retv < 0;
#endif
return StrNumCmp( item1.m_Module, item2.m_Module, INT_MAX, true ) < 0;
}
#endif // FOOTPRINT_INFO_H_
......@@ -108,7 +108,7 @@ bool FP_CACHE_ITEM::IsModified() const
if( !m_file_name.FileExists() )
return false;
wxLogTrace( traceFootprintLibrary, wxT( "File <%s>, m_mod_time %s-%s, file mod time: %s-%s." ),
wxLogTrace( traceFootprintLibrary, wxT( "File '%s', m_mod_time %s-%s, file mod time: %s-%s." ),
GetChars( m_file_name.GetFullPath() ),
GetChars( m_mod_time.FormatDate() ), GetChars( m_mod_time.FormatTime() ),
GetChars( m_file_name.GetModificationTime().FormatDate() ),
......@@ -198,13 +198,13 @@ void FP_CACHE::Save()
{
if( !m_lib_path.DirExists() && !m_lib_path.Mkdir() )
{
THROW_IO_ERROR( wxString::Format( _( "Cannot create footprint library path <%s>" ),
THROW_IO_ERROR( wxString::Format( _( "Cannot create footprint library path '%s'" ),
m_lib_path.GetPath().GetData() ) );
}
if( !m_lib_path.IsDirWritable() )
{
THROW_IO_ERROR( wxString::Format( _( "Footprint library path <%s> is read only" ),
THROW_IO_ERROR( wxString::Format( _( "Footprint library path '%s' is read only" ),
GetChars( m_lib_path.GetPath() ) ) );
}
......@@ -233,9 +233,12 @@ void FP_CACHE::Save()
if( wxRename( tempFileName, fn.GetFullPath() ) )
{
THROW_IO_ERROR( wxString::Format( _( "Cannot rename temporary file <%s> to footprint library file <%s>" ),
tempFileName.GetData(),
fn.GetFullPath().GetData() ) );
wxString msg = wxString::Format(
_( "Cannot rename temporary file '%s' to footprint library file '%s'" ),
GetChars( tempFileName ),
GetChars( fn.GetFullPath() )
);
THROW_IO_ERROR( msg );
}
it->second->UpdateModificationTime();
......@@ -250,8 +253,12 @@ void FP_CACHE::Load()
if( !dir.IsOpened() )
{
THROW_IO_ERROR( wxString::Format( _( "Footprint library path <%s> does not exist" ),
m_lib_path.GetPath().GetData() ) );
wxString msg = wxString::Format(
_( "Footprint library path '%s' does not exist" ),
GetChars( m_lib_path.GetPath() )
);
THROW_IO_ERROR( msg );
}
wxString fpFileName;
......@@ -294,9 +301,12 @@ void FP_CACHE::Remove( const wxString& aFootprintName )
if( it == m_modules.end() )
{
THROW_IO_ERROR( wxString::Format( _( "library <%s> has no footprint '%s' to delete" ),
m_lib_path.GetPath().GetData(),
aFootprintName.GetData() ) );
wxString msg = wxString::Format(
_( "library '%s' has no footprint '%s' to delete" ),
GetChars( m_lib_path.GetPath() ),
GetChars( aFootprintName )
);
THROW_IO_ERROR( msg );
}
// Remove the module from the cache and delete the module file from the library.
......@@ -1733,8 +1743,12 @@ void PCB_IO::FootprintSave( const wxString& aLibraryPath, const MODULE* aFootpri
if( !m_cache->IsWritable() )
{
THROW_IO_ERROR( wxString::Format( _( "Library <%s> is read only" ),
aLibraryPath.GetData() ) );
wxString msg = wxString::Format(
_( "Library '%s' is read only" ),
GetChars( aLibraryPath )
);
THROW_IO_ERROR( msg );
}
std::string footprintName = aFootprint->GetFPID().GetFootprintName();
......@@ -1747,13 +1761,13 @@ void PCB_IO::FootprintSave( const wxString& aLibraryPath, const MODULE* aFootpri
if( !fn.IsOk() )
{
THROW_IO_ERROR( wxString::Format( _( "Footprint file name <%s> is not valid." ),
THROW_IO_ERROR( wxString::Format( _( "Footprint file name '%s' is not valid." ),
GetChars( fn.GetFullPath() ) ) );
}
if( fn.FileExists() && !fn.IsFileWritable() )
{
THROW_IO_ERROR( wxString::Format( _( "user does not have write permission to delete file <%s> " ),
THROW_IO_ERROR( wxString::Format( _( "user does not have write permission to delete file '%s' " ),
GetChars( fn.GetFullPath() ) ) );
}
......@@ -1796,7 +1810,7 @@ void PCB_IO::FootprintDelete( const wxString& aLibraryPath, const wxString& aFoo
if( !m_cache->IsWritable() )
{
THROW_IO_ERROR( wxString::Format( _( "Library <%s> is read only" ),
THROW_IO_ERROR( wxString::Format( _( "Library '%s' is read only" ),
aLibraryPath.GetData() ) );
}
......@@ -1808,7 +1822,7 @@ void PCB_IO::FootprintLibCreate( const wxString& aLibraryPath, const PROPERTIES*
{
if( wxDir::Exists( aLibraryPath ) )
{
THROW_IO_ERROR( wxString::Format( _( "cannot overwrite library path <%s>" ),
THROW_IO_ERROR( wxString::Format( _( "cannot overwrite library path '%s'" ),
aLibraryPath.GetData() ) );
}
......@@ -1833,7 +1847,7 @@ bool PCB_IO::FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES*
if( !fn.IsDirWritable() )
{
THROW_IO_ERROR( wxString::Format( _( "user does not have permission to delete directory <%s>" ),
THROW_IO_ERROR( wxString::Format( _( "user does not have permission to delete directory '%s'" ),
aLibraryPath.GetData() ) );
}
......@@ -1841,7 +1855,7 @@ bool PCB_IO::FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES*
if( dir.HasSubDirs() )
{
THROW_IO_ERROR( wxString::Format( _( "library directory <%s> has unexpected sub-directories" ),
THROW_IO_ERROR( wxString::Format( _( "library directory '%s' has unexpected sub-directories" ),
aLibraryPath.GetData() ) );
}
......@@ -1860,7 +1874,7 @@ bool PCB_IO::FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES*
if( tmp.GetExt() != KiCadFootprintFileExtension )
{
THROW_IO_ERROR( wxString::Format( _( "unexpected file <%s> was found in library path '%s'" ),
THROW_IO_ERROR( wxString::Format( _( "unexpected file '%s' was found in library path '%s'" ),
files[i].GetData(), aLibraryPath.GetData() ) );
}
}
......@@ -1878,7 +1892,7 @@ bool PCB_IO::FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES*
// we don't want that. we want bare metal portability with no UI here.
if( !wxRmdir( aLibraryPath ) )
{
THROW_IO_ERROR( wxString::Format( _( "footprint library <%s> cannot be deleted" ),
THROW_IO_ERROR( wxString::Format( _( "footprint library '%s' cannot be deleted" ),
aLibraryPath.GetData() ) );
}
......
......@@ -516,7 +516,7 @@ wxString PCB_BASE_FRAME::SelectFootprint( EDA_DRAW_FRAME* aWindow,
{
wxArrayString cols;
cols.Add( MList.GetItem( ii ).GetFootprintName() );
cols.Add( MList.GetItem( ii ).GetLibraryName() );
cols.Add( MList.GetItem( ii ).GetNickname() );
rows.push_back( cols );
}
}
......@@ -531,7 +531,7 @@ wxString PCB_BASE_FRAME::SelectFootprint( EDA_DRAW_FRAME* aWindow,
{
wxArrayString cols;
cols.Add( MList.GetItem( ii ).GetFootprintName() );
cols.Add( MList.GetItem( ii ).GetLibraryName() );
cols.Add( MList.GetItem( ii ).GetNickname() );
rows.push_back( cols );
}
}
......@@ -542,7 +542,7 @@ wxString PCB_BASE_FRAME::SelectFootprint( EDA_DRAW_FRAME* aWindow,
{
wxArrayString cols;
cols.Add( MList.GetItem( ii ).GetFootprintName() );
cols.Add( MList.GetItem( ii ).GetLibraryName() );
cols.Add( MList.GetItem( ii ).GetNickname() );
rows.push_back( cols );
}
}
......
......@@ -59,4 +59,6 @@ PNS_ITEM* PNS_SOLID::Clone() const
{
// solids are never cloned as the shove algorithm never moves them
assert( false );
return NULL;
}
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