add and translate some comments. fixed a problem in modedit (delete module in lib not working)

This commit is contained in:
charras 2009-04-06 16:05:25 +00:00
parent 71ca194b68
commit 9efbf02042
9 changed files with 5322 additions and 4169 deletions

View File

@ -8,7 +8,7 @@
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
#define BUILD_VERSION wxT("(20090325-unstable)") #define BUILD_VERSION wxT("(20090406-unstable)")
wxString g_BuildVersion wxString g_BuildVersion

View File

@ -252,14 +252,32 @@ public:
// loading footprints // loading footprints
MODULE* Get_Librairie_Module( wxWindow* winaff, /** function Get_Librairie_Module
const wxString& library, *
const wxString& ModuleName, * Read active libraries or one library to find and load a given module
bool show_msg_err ); * If found the lodule is linked to the tail of linked list of modules
* @param aLibrary: the full filename of the library to read. If empty, all active libraries are read
* @param aModuleName = module name to load
* @param aDisplayMessageError = true to display an error message if any.
* @return a MODULE * pointer to the new module, or NULL
*
*/
MODULE* Get_Librairie_Module( const wxString& aLibraryFullFilename,
const wxString& aModuleName,
bool aDisplayMessageError );
/** Function Select_1_Module_From_List
* Display a list of modules found in active libraries or a given library
* @param aLibraryFullFilename = library to list (if aLibraryFullFilename == void, list all modules)
* @param aMask = Display filter (wildcart)( Mask = wxEmptyString if not used )
* @param aKeyWord = keyword list, to display a filtered list of module having one (or more) of these keyworks in their keywork list
* ( aKeyWord = wxEmptyString if not used )
*
* @return wxEmptyString if abort or fails, or the selected module name if Ok
*/
wxString Select_1_Module_From_List( wxString Select_1_Module_From_List(
WinEDA_DrawFrame* active_window, const wxString& Library, WinEDA_DrawFrame* active_window, const wxString& aLibraryFullFilename,
const wxString& Mask, const wxString& KeyWord ); const wxString& aMask, const wxString& aKeyWord );
MODULE* Load_Module_From_Library( const wxString& library, wxDC* DC ); MODULE* Load_Module_From_Library( const wxString& library, wxDC* DC );

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -213,7 +213,7 @@ void WinEDA_ModuleEditFrame::Export_Module( MODULE* ptmod, bool createlib )
/**********************************************************/ /**********************************************************/
void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const
wxString& libname ) wxString& aLibname )
/**********************************************************/ /**********************************************************/
{ {
wxFileName newFileName; wxFileName newFileName;
@ -224,17 +224,17 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const
wxString CmpName, msg; wxString CmpName, msg;
/* Demande du nom du composant a supprimer */ /* Demande du nom du composant a supprimer */
CmpName = Select_1_Module_From_List( this, libname, wxEmptyString, wxEmptyString ); CmpName = Select_1_Module_From_List( this, aLibname, wxEmptyString, wxEmptyString );
if( CmpName == wxEmptyString ) if( CmpName == wxEmptyString )
return; return;
/* Confirmation */ /* Confirmation */
msg.Printf( _( "Ok to delete module %s in library %s" ), msg.Printf( _( "Ok to delete module %s in library %s" ),
CmpName.GetData(), libname.GetData() ); CmpName.GetData(), aLibname.GetData() );
if( !IsOK( this, msg ) ) if( !IsOK( this, msg ) )
return; return;
oldFileName = libname; oldFileName = aLibname;
if( ( lib_module = wxFopen( oldFileName.GetFullPath(), if( ( lib_module = wxFopen( oldFileName.GetFullPath(),
wxT( "rt" ) ) ) == NULL ) wxT( "rt" ) ) ) == NULL )

View File

@ -133,7 +133,7 @@ MODULE* WinEDA_BasePcbFrame::Load_Module_From_Library( const wxString& library,
} }
} }
module = Get_Librairie_Module( this, library, ModuleName, FALSE ); module = Get_Librairie_Module( library, ModuleName, FALSE );
if( (module == NULL) && AllowWildSeach ) /* Attemp to search with wildcard */ if( (module == NULL) && AllowWildSeach ) /* Attemp to search with wildcard */
{ {
@ -147,7 +147,7 @@ MODULE* WinEDA_BasePcbFrame::Load_Module_From_Library( const wxString& library,
return NULL; /* annulation de commande */ return NULL; /* annulation de commande */
} }
else else
module = Get_Librairie_Module( this, library, ModuleName, TRUE ); module = Get_Librairie_Module( library, ModuleName, TRUE );
} }
GetScreen()->m_Curseur = curspos; GetScreen()->m_Curseur = curspos;
@ -170,21 +170,19 @@ MODULE* WinEDA_BasePcbFrame::Load_Module_From_Library( const wxString& library,
} }
/***************************************************************************** /** function Get_Librairie_Module
* *
* Analyse les LIBRAIRIES pour trouver le module demande * Read active libraries or one library to find and load a given module
* Si ce module est trouve, le copie en memoire, et le * If found the lodule is linked to the tail of linked list of modules
* chaine en fin de liste des modules * @param aLibrary: the full filename of the library to read. If empty, all active libraries are read
* - Entree: * @param aModuleName = module name to load
* name_cmp = nom du module * @param aDisplayMessageError = true to display an error message if any.
* - Retour: * @return a MODULE * pointer to the new module, or NULL
* Pointeur sur le nouveau module.
* *
*****************************************************************************/ */
MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( wxWindow* winaff, MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( const wxString& aLibraryFullFilename,
const wxString& library, const wxString& aModuleName,
const wxString& ModuleName, bool aDisplayMessageError )
bool show_msg_err )
{ {
int LineNum, Found = 0; int LineNum, Found = 0;
wxFileName fn; wxFileName fn;
@ -194,11 +192,14 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( wxWindow* winaff,
MODULE* NewModule; MODULE* NewModule;
FILE* file = NULL; FILE* file = NULL;
unsigned ii; unsigned ii;
bool one_lib = aLibraryFullFilename.IsEmpty() ? false : true;
for( ii = 0; ii < g_LibName_List.GetCount(); ii++ ) for( ii = 0; ii < g_LibName_List.GetCount(); ii++ )
{ {
fn = wxFileName( wxEmptyString, g_LibName_List[ii], if ( one_lib )
ModuleFileExtension ); fn = aLibraryFullFilename;
else
fn = wxFileName( wxEmptyString, g_LibName_List[ii], ModuleFileExtension );
tmp = wxGetApp().GetLibraryPathList().FindValidPath( fn.GetFullName() ); tmp = wxGetApp().GetLibraryPathList().FindValidPath( fn.GetFullName() );
@ -253,7 +254,7 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( wxWindow* winaff,
break; break;
StrPurge( Line ); StrPurge( Line );
msg = CONV_FROM_UTF8( Line ); msg = CONV_FROM_UTF8( Line );
if( msg.CmpNoCase( ModuleName ) == 0 ) if( msg.CmpNoCase( aModuleName ) == 0 )
{ {
Found = 1; Found = 1;
break; /* Trouve! */ break; /* Trouve! */
@ -274,7 +275,7 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( wxWindow* winaff,
/* Lecture du nom du composant */ /* Lecture du nom du composant */
Name = CONV_FROM_UTF8( Line + 8 ); Name = CONV_FROM_UTF8( Line + 8 );
if( Name.CmpNoCase( ModuleName ) == 0 ) /* composant localise */ if( Name.CmpNoCase( aModuleName ) == 0 ) /* composant localise */
{ {
NewModule = new MODULE( GetBoard() ); NewModule = new MODULE( GetBoard() );
@ -291,12 +292,15 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( wxWindow* winaff,
} }
fclose( file ); fclose( file );
if ( one_lib )
break;
} }
if( show_msg_err ) if( aDisplayMessageError )
{ {
msg.Printf( _( "Module <%s> not found" ), ModuleName.c_str() ); msg.Printf( _( "Module <%s> not found" ), aModuleName.c_str() );
DisplayError( winaff, msg ); DisplayError( NULL, msg );
} }
return NULL; return NULL;
@ -306,19 +310,18 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( wxWindow* winaff,
/***************************************************************/ /***************************************************************/
wxString WinEDA_BasePcbFrame::Select_1_Module_From_List( wxString WinEDA_BasePcbFrame::Select_1_Module_From_List(
WinEDA_DrawFrame* active_window, WinEDA_DrawFrame* active_window,
const wxString& Library, const wxString& aLibraryFullFilename,
const wxString& Mask, const wxString& KeyWord ) const wxString& aMask, const wxString& aKeyWord )
/***************************************************************/ /***************************************************************/
/* /** Function Select_1_Module_From_List
* Affiche la liste des modules des librairies * Display a list of modules found in active libraries or a given library
* Recherche dans la librairie Library ou generale si Library == NULL * @param aLibraryFullFilename = library to list (if aLibraryFullFilename == void, list all modules)
* Mask = Filtre d'affichage( Mask = wxEmptyString pour listage non filtré ) * @param aMask = Display filter (wildcart)( Mask = wxEmptyString if not used )
* KeyWord = Liste de mots cles, Recherche limitee aux composants * @param aKeyWord = keyword list, to display a filtered list of module having one (or more) of these keyworks in their keywork list
* ayant ces mots cles ( KeyWord = wxEmptyString pour listage de tous les modules ) * ( aKeyWord = wxEmptyString if not used )
* *
* retourne wxEmptyString si abort ou probleme * @return wxEmptyString if abort or fails, or the selected module name if Ok
* ou le nom du module
*/ */
{ {
int LineNum; int LineNum;
@ -341,14 +344,13 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List(
for( ii = 0; ii < g_LibName_List.GetCount(); ii++ ) for( ii = 0; ii < g_LibName_List.GetCount(); ii++ )
{ {
/* Calcul du nom complet de la librairie */ /* Calcul du nom complet de la librairie */
if( Library.IsEmpty() ) if( aLibraryFullFilename.IsEmpty() )
{ {
fn = wxFileName( wxEmptyString, g_LibName_List[ii], fn = wxFileName( wxEmptyString, g_LibName_List[ii],
ModuleFileExtension ); ModuleFileExtension );
} }
else else
fn = wxFileName( wxEmptyString, Library, ModuleFileExtension ); fn = aLibraryFullFilename;
tmp = wxGetApp().GetLibraryPathList().FindValidPath( fn.GetFullName() ); tmp = wxGetApp().GetLibraryPathList().FindValidPath( fn.GetFullName() );
@ -363,10 +365,10 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List(
ReadDocLib( tmp ); ReadDocLib( tmp );
if( !KeyWord.IsEmpty() ) /* Inutile de lire la librairie si selection if( !aKeyWord.IsEmpty() ) /* Inutile de lire la librairie si selection
* par mots cles, deja lus */ * par mots cles, deja lus */
{ {
if( !Library.IsEmpty() ) if( !aLibraryFullFilename.IsEmpty() )
break; break;
continue; continue;
} }
@ -375,7 +377,7 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List(
if( file == NULL ) if( file == NULL )
{ {
if( !Library.IsEmpty() ) if( !aLibraryFullFilename.IsEmpty() )
break; break;
continue; continue;
} }
@ -413,12 +415,12 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List(
break; break;
strupper( Line ); strupper( Line );
msg = CONV_FROM_UTF8( StrPurge( Line ) ); msg = CONV_FROM_UTF8( StrPurge( Line ) );
if( Mask.IsEmpty() ) if( aMask.IsEmpty() )
{ {
ListBox->Append( msg ); ListBox->Append( msg );
NbModules++; NbModules++;
} }
else if( WildCompareString( Mask, msg, FALSE ) ) else if( WildCompareString( aMask, msg, FALSE ) )
{ {
ListBox->Append( msg ); ListBox->Append( msg );
NbModules++; NbModules++;
@ -431,17 +433,17 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List(
fclose( file ); fclose( file );
file = NULL; file = NULL;
if( !Library.IsEmpty() ) if( !aLibraryFullFilename.IsEmpty() )
break; break;
} }
/* creation de la liste des modules si recherche par mots-cles */ /* creation de la liste des modules si recherche par mots-cles */
if( !KeyWord.IsEmpty() ) if( !aKeyWord.IsEmpty() )
{ {
ModList* ItemMod = MList; ModList* ItemMod = MList;
while( ItemMod != NULL ) while( ItemMod != NULL )
{ {
if( KeyWordOk( KeyWord, ItemMod->m_KeyWord ) ) if( KeyWordOk( aKeyWord, ItemMod->m_KeyWord ) )
{ {
NbModules++; NbModules++;
ListBox->Append( ItemMod->m_Name ); ListBox->Append( ItemMod->m_Name );

View File

@ -69,20 +69,19 @@ BOARD_ITEM* WinEDA_ModuleEditFrame::ModeditLocateAndDisplay( int aHotKeyCode )
item = (*m_Collector)[0]; item = (*m_Collector)[0];
SetCurItem( item ); SetCurItem( item );
} }
else // we can't figure out which item user wants, do popup menu so user can choose else // we can't figure out which item user wants, do popup menu so user can choose
{ {
wxMenu itemMenu; wxMenu itemMenu;
/* Give a title to the selection menu. This is also a cancel menu item */ /* Give a title to the selection menu. This is also a cancel menu item */
wxMenuItem * item_title = new wxMenuItem(&itemMenu, -1, _( "Selection Clarification" ) ); wxMenuItem* item_title = new wxMenuItem( &itemMenu, -1, _( "Selection Clarification" ) );
#ifdef __WINDOWS__ #ifdef __WINDOWS__
wxFont bold_font(*wxNORMAL_FONT); wxFont bold_font( *wxNORMAL_FONT );
bold_font.SetWeight(wxFONTWEIGHT_BOLD); bold_font.SetWeight( wxFONTWEIGHT_BOLD );
bold_font.SetStyle( wxFONTSTYLE_ITALIC); bold_font.SetStyle( wxFONTSTYLE_ITALIC );
item_title->SetFont(bold_font); item_title->SetFont( bold_font );
#endif #endif
itemMenu.Append(item_title); itemMenu.Append( item_title );
itemMenu.AppendSeparator(); itemMenu.AppendSeparator();
int limit = MIN( MAX_ITEMS_IN_PICKER, m_Collector->GetCount() ); int limit = MIN( MAX_ITEMS_IN_PICKER, m_Collector->GetCount() );
@ -122,7 +121,6 @@ BOARD_ITEM* WinEDA_ModuleEditFrame::ModeditLocateAndDisplay( int aHotKeyCode )
} }
/****************************************************************************/ /****************************************************************************/
void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
/****************************************************************************/ /****************************************************************************/
@ -205,10 +203,10 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
{ {
wxFileName fn = wxFileName( wxEmptyString, m_CurrentLib, wxFileName fn = wxFileName( wxEmptyString, m_CurrentLib,
ModuleFileExtension ); ModuleFileExtension );
wxString tmp = wxString full_libraryfilename =
wxGetApp().GetLibraryPathList().FindValidPath( fn.GetFullName() ); wxGetApp().GetLibraryPathList().FindValidPath( fn.GetFullName() );
if( wxFileName::FileExists( tmp ) ) if( wxFileName::FileExists( full_libraryfilename ) )
Delete_Module_In_Library( tmp ); Delete_Module_In_Library( full_libraryfilename );
break; break;
} }
@ -220,9 +218,9 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
GetScreen()->m_Curseur = wxPoint( 0, 0 ); GetScreen()->m_Curseur = wxPoint( 0, 0 );
MODULE* module = Create_1_Module( &dc, wxEmptyString ); MODULE* module = Create_1_Module( &dc, wxEmptyString );
if ( module ) // i.e. if create module command not aborted if( module ) // i.e. if create module command not aborted
{ {
module->SetPosition( wxPoint(0, 0) ); module->SetPosition( wxPoint( 0, 0 ) );
if( GetBoard()->m_Modules ) if( GetBoard()->m_Modules )
GetBoard()->m_Modules->m_Flags = 0; GetBoard()->m_Modules->m_Flags = 0;
Zoom_Automatique( true ); Zoom_Automatique( true );
@ -346,11 +344,21 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_MODEDIT_LOAD_MODULE: case ID_MODEDIT_LOAD_MODULE:
{
wxString full_libraryfilename;
if( !m_CurrentLib.IsEmpty() )
{
wxFileName fn = wxFileName( wxEmptyString, m_CurrentLib,
ModuleFileExtension );
full_libraryfilename =
wxGetApp().GetLibraryPathList().FindValidPath( fn.GetFullName() );
}
GetScreen()->ClearUndoRedoList(); GetScreen()->ClearUndoRedoList();
SetCurItem( NULL ); SetCurItem( NULL );
Clear_Pcb( true ); Clear_Pcb( true );
GetScreen()->m_Curseur = wxPoint( 0, 0 ); GetScreen()->m_Curseur = wxPoint( 0, 0 );
Load_Module_From_Library( m_CurrentLib, &dc ); Load_Module_From_Library( full_libraryfilename, &dc );
}
if( GetBoard()->m_Modules ) if( GetBoard()->m_Modules )
GetBoard()->m_Modules->m_Flags = 0; GetBoard()->m_Modules->m_Flags = 0;

View File

@ -491,7 +491,7 @@ MODULE* ReadNetModule( WinEDA_PcbFrame* aFrame,
if( aChangeFootprint ) if( aChangeFootprint )
{ {
MODULE* NewModule = MODULE* NewModule =
aFrame->Get_Librairie_Module( NULL, wxEmptyString, NameLibCmp, TRUE ); aFrame->Get_Librairie_Module( wxEmptyString, NameLibCmp, TRUE );
if( NewModule ) /* Nouveau module trouve : changement de module */ if( NewModule ) /* Nouveau module trouve : changement de module */
Module = aFrame->Exchange_Module( NULL, Module, NewModule ); Module = aFrame->Exchange_Module( NULL, Module, NewModule );
} }
@ -1036,7 +1036,7 @@ void LoadListeModules( WinEDA_PcbFrame* aPcbFrame, wxDC* DC )
if( (ii == 0) || ( ref->m_LibName != cmp->m_LibName) ) if( (ii == 0) || ( ref->m_LibName != cmp->m_LibName) )
{ {
/* New footprint : must be loaded from a library */ /* New footprint : must be loaded from a library */
Module = aPcbFrame->Get_Librairie_Module( NULL, wxEmptyString, cmp->m_LibName, FALSE ); Module = aPcbFrame->Get_Librairie_Module( wxEmptyString, cmp->m_LibName, FALSE );
ref = cmp; ref = cmp;
if( Module == NULL ) if( Module == NULL )
{ {

View File

@ -494,7 +494,7 @@ MODULE* WinEDA_ExchangeModuleFrame::Change_1_Module( MODULE* Module,
namecmp.Trim( TRUE ); namecmp.Trim( TRUE );
namecmp.Trim( FALSE ); namecmp.Trim( FALSE );
NewModule = m_Parent->Get_Librairie_Module( this, wxEmptyString, namecmp, ShowError ); NewModule = m_Parent->Get_Librairie_Module( wxEmptyString, namecmp, ShowError );
if( NewModule == NULL ) /* Nouveau module NON trouve, reaffichage de l'ancien */ if( NewModule == NULL ) /* Nouveau module NON trouve, reaffichage de l'ancien */
{ {
m_WinMsg->WriteText( wxT( "No\n" ) ); m_WinMsg->WriteText( wxT( "No\n" ) );