Loading cvpcb/autosel.cpp +2 −8 Original line number Diff line number Diff line Loading @@ -149,14 +149,8 @@ found in the default search paths." ), if( alias.m_Name.CmpNoCase( component.m_Value ) != 0 ) continue; BOOST_FOREACH( FOOTPRINT_INFO& footprint, m_footprints ) { if( alias.m_FootprintName.CmpNoCase( footprint.m_Module ) == 0 ) { SetNewPkg( footprint.m_Module ); break; } } if( m_footprints.GetModuleInfo( alias.m_FootprintName ) ) SetNewPkg( alias.m_FootprintName ); if( component.m_Module.IsEmpty() ) { Loading cvpcb/class_footprints_listbox.cpp +8 −16 Original line number Diff line number Diff line Loading @@ -12,17 +12,6 @@ #include "cvstruct.h" FOOTPRINT_INFO* GetModuleDescrByName( const wxString& FootprintName, FOOTPRINT_LIST& list ) { BOOST_FOREACH( FOOTPRINT_INFO & footprint, list ) { if( footprint.m_Module == FootprintName ) return &footprint; } return NULL; } /***************************************/ /* ListBox handling the footprint list */ /***************************************/ Loading Loading @@ -127,9 +116,11 @@ void FOOTPRINTS_LISTBOX::SetFootprintFullList( FOOTPRINT_LIST& list ) m_FullFootprintList.Clear(); BOOST_FOREACH( FOOTPRINT_INFO & footprint, list ) { for( unsigned ii = 0; ii < list.GetCount(); ii++ ) { FOOTPRINT_INFO & footprint = list.GetItem(ii); msg.Printf( wxT( "%3d %s" ), m_FullFootprintList.GetCount() + 1, footprint.m_Module.GetData() ); GetChars(footprint.m_Module) ); m_FullFootprintList.Add( msg ); } Loading @@ -145,7 +136,6 @@ void FOOTPRINTS_LISTBOX::SetFootprintFullList( FOOTPRINT_LIST& list ) void FOOTPRINTS_LISTBOX::SetFootprintFilteredList( COMPONENT* Component, FOOTPRINT_LIST& list ) { FOOTPRINT_LIST::iterator i; wxString msg; unsigned jj; int OldSelection = GetSelection(); Loading @@ -153,7 +143,9 @@ void FOOTPRINTS_LISTBOX::SetFootprintFilteredList( COMPONENT* Component, m_FilteredFootprintList.Clear(); BOOST_FOREACH( FOOTPRINT_INFO & footprint, list ) { for( unsigned ii = 0; ii < list.GetCount(); ii++ ) { FOOTPRINT_INFO& footprint = list.GetItem(ii); /* Search for matching footprints */ for( jj = 0; jj < Component->m_FootprintFilter.GetCount(); jj++ ) { Loading Loading @@ -250,7 +242,7 @@ void FOOTPRINTS_LISTBOX::OnLeftClick( wxListEvent& event ) FOOTPRINT_INFO* Module; wxString FootprintName = GetSelectedFootprint(); Module = GetModuleDescrByName( FootprintName, GetParent()->m_footprints ); Module = GetParent()->m_footprints.GetModuleInfo( FootprintName ); wxASSERT(Module); if( GetParent()->DrawFrame ) { Loading cvpcb/cvframe.cpp +45 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ #include "dialog_cvpcb_config.h" #include "class_DisplayFootprintsFrame.h" #include "cvpcb_id.h" #include "dialog_load_error.h" #include "build_version.h" Loading Loading @@ -603,3 +605,46 @@ void CVPCB_MAINFRAME::DisplayStatus() msg.Empty(); SetStatusText( msg, 2 ); } /* * Read the list of libraries (*.mod files) and populates m_footprints * ( list of availaible modules in libs ). * for each module are stored * the module name * documentation string * associated keywords */ bool CVPCB_MAINFRAME::LoadFootprintFiles( ) { /* Check if there are footprint libraries in project file */ if( m_ModuleLibNames.GetCount() == 0 ) { wxMessageBox( _( "No PCB footprint libraries are listed in the current project file." ), _( "Project File Error" ), wxOK | wxICON_ERROR ); return false; } m_footprints.ReadFootprintFiles(m_ModuleLibNames); /* Display error messages, if any */ if( !m_footprints.m_filesNotFound.IsEmpty() || !m_footprints.m_filesInvalid.IsEmpty() ) { DIALOG_LOAD_ERROR dialog(NULL); if( !m_footprints.m_filesNotFound.IsEmpty() ) { wxString message = _("Some files could not be found!"); dialog.MessageSet(message); dialog.ListSet(m_footprints.m_filesNotFound); } /* Display if there are invalid files */ if( !m_footprints.m_filesInvalid.IsEmpty() ) { dialog.MessageSet( _("Some files are invalid!")); dialog.ListSet(m_footprints.m_filesInvalid); } dialog.ShowModal(); } return true; } cvpcb/footprint_info.h +70 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,76 @@ public: } }; typedef boost::ptr_vector< FOOTPRINT_INFO > FOOTPRINT_LIST; class FOOTPRINT_LIST { public: boost::ptr_vector< FOOTPRINT_INFO > m_List; wxString m_filesNotFound; wxString m_filesInvalid; public: /** * Function GetCount * @return the number of items stored in list */ unsigned GetCount() { return m_List.size(); } /** * Function GetModuleInfo * @return the item stored in list if found * @param aFootprintName = the name of item */ FOOTPRINT_INFO * GetModuleInfo( const wxString & aFootprintName ) { BOOST_FOREACH( FOOTPRINT_INFO& footprint, m_List ) { if( aFootprintName.CmpNoCase( footprint.m_Module ) == 0 ) return &footprint; } return NULL; } /** * Function GetItem * @return the aIdx item in list * @param aIdx = index of the given item */ FOOTPRINT_INFO & GetItem( unsigned aIdx ) { return m_List[aIdx]; } /** * Function AddItem * add aItem in list * @param aItem = item to add */ void AddItem( FOOTPRINT_INFO* aItem ) { m_List.push_back( aItem); } /** * Function ReadFootprintFiles * Read the list of libraries (*.mod files) and populates m_List ( list of availaible modules in libs ). * for each module, are stored * the module name * documentation string * associated keywords * library name * Module description format: * $MODULE c64acmd First line of module description * Li c64acmd DIN connector Library reference * Cd Europe 96 AC male vertical documentation string * Kw PAD_CONN DIN associated keywords * ...... other data (pads, outlines ..) * $Endmodule * * @param aFootprintsLibNames = an array string giving the list of libraries to load */ bool ReadFootprintFiles( wxArrayString & aFootprintsLibNames ); }; /* FOOTPRINT object list sort function. */ inline bool operator<( const FOOTPRINT_INFO& item1, const FOOTPRINT_INFO& item2 ) Loading cvpcb/listlib.cpp +16 −46 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ /* * Functions to read footprint libraries and fill m_footprints by availlable footprints names * Functions to read footprint libraries and fill m_footprints by available footprints names * and their documentation (comments and keywords) */ #include "fctsys.h" Loading @@ -20,14 +20,13 @@ #include "filter_reader.h" #include "footprint_info.h" #include "dialog_load_error.h" /* * Read the list of libraries (*.mod files) and populates m_footprints ( list of availaible modules in libs ). /* Read the list of libraries (*.mod files) * for each module are stored * the module name * documentation string * associated keywords * lib name * Module description format: * $MODULE c64acmd First line of module description * Li c64acmd DIN connector Library reference Loading @@ -35,39 +34,29 @@ * Kw PAD_CONN DIN associated keywords * ...... other data (pads, outlines ..) * $Endmodule * */ bool CVPCB_MAINFRAME::LoadFootprintFiles( ) bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString & aFootprintsLibNames ) { FILE* file; wxFileName filename; wxString libname; wxString files_not_found; wxString files_invalid; /* Check if footprint m_footprints is not empty */ if( !m_footprints.empty() ) m_footprints.clear(); /* Check if there are footprint libraries in project file */ if( m_ModuleLibNames.GetCount() == 0 ) { wxMessageBox( _( "No PCB footprint libraries are listed in the current project file." ), _( "Project File Error" ), wxOK | wxICON_ERROR ); return false; } // Clear data before reading files m_filesNotFound.Empty(); m_filesInvalid.Empty(); m_List.clear(); /* Parse Libraries Listed */ for( unsigned ii = 0; ii < m_ModuleLibNames.GetCount(); ii++ ) for( unsigned ii = 0; ii < aFootprintsLibNames.GetCount(); ii++ ) { filename = m_ModuleLibNames[ii]; filename = aFootprintsLibNames[ii]; filename.SetExt( ModuleFileExtension ); libname = wxGetApp().FindLibraryPath( filename ); if( libname.IsEmpty() ) { files_not_found << filename.GetFullName() << wxT("\n"); m_filesNotFound << filename.GetFullName() << wxT("\n"); continue; } Loading @@ -76,7 +65,7 @@ bool CVPCB_MAINFRAME::LoadFootprintFiles( ) if( file == NULL ) { files_invalid << libname << _(" (file cannot be opened)") << wxT("\n"); m_filesInvalid << libname << _(" (file cannot be opened)") << wxT("\n"); continue; } Loading @@ -93,7 +82,7 @@ bool CVPCB_MAINFRAME::LoadFootprintFiles( ) wxString msg; msg.Printf( _( "<%s> is not a valid Kicad PCB footprint library." ), GetChars( libname ) ); files_invalid << msg << wxT("\n"); m_filesInvalid << msg << wxT("\n"); continue; } Loading @@ -115,7 +104,7 @@ bool CVPCB_MAINFRAME::LoadFootprintFiles( ) FOOTPRINT_INFO* ItemLib = new FOOTPRINT_INFO(); ItemLib->m_Module = CONV_FROM_UTF8( StrPurge( line ) ); ItemLib->m_LibName = libname; m_footprints.push_back( ItemLib ); AddItem( ItemLib ); while( reader.ReadLine() ) { Loading Loading @@ -143,30 +132,11 @@ bool CVPCB_MAINFRAME::LoadFootprintFiles( ) if( !end ) { files_invalid << libname << _(" (Unexpected end of file)") << wxT("\n"); m_filesInvalid << libname << _(" (Unexpected end of file)") << wxT("\n"); } } m_footprints.sort(); /* Display error messages, if any */ if( !files_not_found.IsEmpty() || !files_invalid.IsEmpty() ) { DIALOG_LOAD_ERROR dialog(NULL); if( !files_not_found.IsEmpty() ) { wxString message = _("Some files could not be found!"); dialog.MessageSet(message); dialog.ListSet(files_not_found); } /* Display if there are invalid files */ if( !files_invalid.IsEmpty() ) { dialog.MessageSet( _("Some files are invalid!")); dialog.ListSet(files_invalid); } dialog.ShowModal(); } m_List.sort(); return true; } Loading
cvpcb/autosel.cpp +2 −8 Original line number Diff line number Diff line Loading @@ -149,14 +149,8 @@ found in the default search paths." ), if( alias.m_Name.CmpNoCase( component.m_Value ) != 0 ) continue; BOOST_FOREACH( FOOTPRINT_INFO& footprint, m_footprints ) { if( alias.m_FootprintName.CmpNoCase( footprint.m_Module ) == 0 ) { SetNewPkg( footprint.m_Module ); break; } } if( m_footprints.GetModuleInfo( alias.m_FootprintName ) ) SetNewPkg( alias.m_FootprintName ); if( component.m_Module.IsEmpty() ) { Loading
cvpcb/class_footprints_listbox.cpp +8 −16 Original line number Diff line number Diff line Loading @@ -12,17 +12,6 @@ #include "cvstruct.h" FOOTPRINT_INFO* GetModuleDescrByName( const wxString& FootprintName, FOOTPRINT_LIST& list ) { BOOST_FOREACH( FOOTPRINT_INFO & footprint, list ) { if( footprint.m_Module == FootprintName ) return &footprint; } return NULL; } /***************************************/ /* ListBox handling the footprint list */ /***************************************/ Loading Loading @@ -127,9 +116,11 @@ void FOOTPRINTS_LISTBOX::SetFootprintFullList( FOOTPRINT_LIST& list ) m_FullFootprintList.Clear(); BOOST_FOREACH( FOOTPRINT_INFO & footprint, list ) { for( unsigned ii = 0; ii < list.GetCount(); ii++ ) { FOOTPRINT_INFO & footprint = list.GetItem(ii); msg.Printf( wxT( "%3d %s" ), m_FullFootprintList.GetCount() + 1, footprint.m_Module.GetData() ); GetChars(footprint.m_Module) ); m_FullFootprintList.Add( msg ); } Loading @@ -145,7 +136,6 @@ void FOOTPRINTS_LISTBOX::SetFootprintFullList( FOOTPRINT_LIST& list ) void FOOTPRINTS_LISTBOX::SetFootprintFilteredList( COMPONENT* Component, FOOTPRINT_LIST& list ) { FOOTPRINT_LIST::iterator i; wxString msg; unsigned jj; int OldSelection = GetSelection(); Loading @@ -153,7 +143,9 @@ void FOOTPRINTS_LISTBOX::SetFootprintFilteredList( COMPONENT* Component, m_FilteredFootprintList.Clear(); BOOST_FOREACH( FOOTPRINT_INFO & footprint, list ) { for( unsigned ii = 0; ii < list.GetCount(); ii++ ) { FOOTPRINT_INFO& footprint = list.GetItem(ii); /* Search for matching footprints */ for( jj = 0; jj < Component->m_FootprintFilter.GetCount(); jj++ ) { Loading Loading @@ -250,7 +242,7 @@ void FOOTPRINTS_LISTBOX::OnLeftClick( wxListEvent& event ) FOOTPRINT_INFO* Module; wxString FootprintName = GetSelectedFootprint(); Module = GetModuleDescrByName( FootprintName, GetParent()->m_footprints ); Module = GetParent()->m_footprints.GetModuleInfo( FootprintName ); wxASSERT(Module); if( GetParent()->DrawFrame ) { Loading
cvpcb/cvframe.cpp +45 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ #include "dialog_cvpcb_config.h" #include "class_DisplayFootprintsFrame.h" #include "cvpcb_id.h" #include "dialog_load_error.h" #include "build_version.h" Loading Loading @@ -603,3 +605,46 @@ void CVPCB_MAINFRAME::DisplayStatus() msg.Empty(); SetStatusText( msg, 2 ); } /* * Read the list of libraries (*.mod files) and populates m_footprints * ( list of availaible modules in libs ). * for each module are stored * the module name * documentation string * associated keywords */ bool CVPCB_MAINFRAME::LoadFootprintFiles( ) { /* Check if there are footprint libraries in project file */ if( m_ModuleLibNames.GetCount() == 0 ) { wxMessageBox( _( "No PCB footprint libraries are listed in the current project file." ), _( "Project File Error" ), wxOK | wxICON_ERROR ); return false; } m_footprints.ReadFootprintFiles(m_ModuleLibNames); /* Display error messages, if any */ if( !m_footprints.m_filesNotFound.IsEmpty() || !m_footprints.m_filesInvalid.IsEmpty() ) { DIALOG_LOAD_ERROR dialog(NULL); if( !m_footprints.m_filesNotFound.IsEmpty() ) { wxString message = _("Some files could not be found!"); dialog.MessageSet(message); dialog.ListSet(m_footprints.m_filesNotFound); } /* Display if there are invalid files */ if( !m_footprints.m_filesInvalid.IsEmpty() ) { dialog.MessageSet( _("Some files are invalid!")); dialog.ListSet(m_footprints.m_filesInvalid); } dialog.ShowModal(); } return true; }
cvpcb/footprint_info.h +70 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,76 @@ public: } }; typedef boost::ptr_vector< FOOTPRINT_INFO > FOOTPRINT_LIST; class FOOTPRINT_LIST { public: boost::ptr_vector< FOOTPRINT_INFO > m_List; wxString m_filesNotFound; wxString m_filesInvalid; public: /** * Function GetCount * @return the number of items stored in list */ unsigned GetCount() { return m_List.size(); } /** * Function GetModuleInfo * @return the item stored in list if found * @param aFootprintName = the name of item */ FOOTPRINT_INFO * GetModuleInfo( const wxString & aFootprintName ) { BOOST_FOREACH( FOOTPRINT_INFO& footprint, m_List ) { if( aFootprintName.CmpNoCase( footprint.m_Module ) == 0 ) return &footprint; } return NULL; } /** * Function GetItem * @return the aIdx item in list * @param aIdx = index of the given item */ FOOTPRINT_INFO & GetItem( unsigned aIdx ) { return m_List[aIdx]; } /** * Function AddItem * add aItem in list * @param aItem = item to add */ void AddItem( FOOTPRINT_INFO* aItem ) { m_List.push_back( aItem); } /** * Function ReadFootprintFiles * Read the list of libraries (*.mod files) and populates m_List ( list of availaible modules in libs ). * for each module, are stored * the module name * documentation string * associated keywords * library name * Module description format: * $MODULE c64acmd First line of module description * Li c64acmd DIN connector Library reference * Cd Europe 96 AC male vertical documentation string * Kw PAD_CONN DIN associated keywords * ...... other data (pads, outlines ..) * $Endmodule * * @param aFootprintsLibNames = an array string giving the list of libraries to load */ bool ReadFootprintFiles( wxArrayString & aFootprintsLibNames ); }; /* FOOTPRINT object list sort function. */ inline bool operator<( const FOOTPRINT_INFO& item1, const FOOTPRINT_INFO& item2 ) Loading
cvpcb/listlib.cpp +16 −46 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ /* * Functions to read footprint libraries and fill m_footprints by availlable footprints names * Functions to read footprint libraries and fill m_footprints by available footprints names * and their documentation (comments and keywords) */ #include "fctsys.h" Loading @@ -20,14 +20,13 @@ #include "filter_reader.h" #include "footprint_info.h" #include "dialog_load_error.h" /* * Read the list of libraries (*.mod files) and populates m_footprints ( list of availaible modules in libs ). /* Read the list of libraries (*.mod files) * for each module are stored * the module name * documentation string * associated keywords * lib name * Module description format: * $MODULE c64acmd First line of module description * Li c64acmd DIN connector Library reference Loading @@ -35,39 +34,29 @@ * Kw PAD_CONN DIN associated keywords * ...... other data (pads, outlines ..) * $Endmodule * */ bool CVPCB_MAINFRAME::LoadFootprintFiles( ) bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString & aFootprintsLibNames ) { FILE* file; wxFileName filename; wxString libname; wxString files_not_found; wxString files_invalid; /* Check if footprint m_footprints is not empty */ if( !m_footprints.empty() ) m_footprints.clear(); /* Check if there are footprint libraries in project file */ if( m_ModuleLibNames.GetCount() == 0 ) { wxMessageBox( _( "No PCB footprint libraries are listed in the current project file." ), _( "Project File Error" ), wxOK | wxICON_ERROR ); return false; } // Clear data before reading files m_filesNotFound.Empty(); m_filesInvalid.Empty(); m_List.clear(); /* Parse Libraries Listed */ for( unsigned ii = 0; ii < m_ModuleLibNames.GetCount(); ii++ ) for( unsigned ii = 0; ii < aFootprintsLibNames.GetCount(); ii++ ) { filename = m_ModuleLibNames[ii]; filename = aFootprintsLibNames[ii]; filename.SetExt( ModuleFileExtension ); libname = wxGetApp().FindLibraryPath( filename ); if( libname.IsEmpty() ) { files_not_found << filename.GetFullName() << wxT("\n"); m_filesNotFound << filename.GetFullName() << wxT("\n"); continue; } Loading @@ -76,7 +65,7 @@ bool CVPCB_MAINFRAME::LoadFootprintFiles( ) if( file == NULL ) { files_invalid << libname << _(" (file cannot be opened)") << wxT("\n"); m_filesInvalid << libname << _(" (file cannot be opened)") << wxT("\n"); continue; } Loading @@ -93,7 +82,7 @@ bool CVPCB_MAINFRAME::LoadFootprintFiles( ) wxString msg; msg.Printf( _( "<%s> is not a valid Kicad PCB footprint library." ), GetChars( libname ) ); files_invalid << msg << wxT("\n"); m_filesInvalid << msg << wxT("\n"); continue; } Loading @@ -115,7 +104,7 @@ bool CVPCB_MAINFRAME::LoadFootprintFiles( ) FOOTPRINT_INFO* ItemLib = new FOOTPRINT_INFO(); ItemLib->m_Module = CONV_FROM_UTF8( StrPurge( line ) ); ItemLib->m_LibName = libname; m_footprints.push_back( ItemLib ); AddItem( ItemLib ); while( reader.ReadLine() ) { Loading Loading @@ -143,30 +132,11 @@ bool CVPCB_MAINFRAME::LoadFootprintFiles( ) if( !end ) { files_invalid << libname << _(" (Unexpected end of file)") << wxT("\n"); m_filesInvalid << libname << _(" (Unexpected end of file)") << wxT("\n"); } } m_footprints.sort(); /* Display error messages, if any */ if( !files_not_found.IsEmpty() || !files_invalid.IsEmpty() ) { DIALOG_LOAD_ERROR dialog(NULL); if( !files_not_found.IsEmpty() ) { wxString message = _("Some files could not be found!"); dialog.MessageSet(message); dialog.ListSet(files_not_found); } /* Display if there are invalid files */ if( !files_invalid.IsEmpty() ) { dialog.MessageSet( _("Some files are invalid!")); dialog.ListSet(files_invalid); } dialog.ShowModal(); } m_List.sort(); return true; }