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"
#define BUILD_VERSION wxT("(20090325-unstable)")
#define BUILD_VERSION wxT("(20090406-unstable)")
wxString g_BuildVersion

View File

@ -252,14 +252,32 @@ public:
// loading footprints
MODULE* Get_Librairie_Module( wxWindow* winaff,
const wxString& library,
const wxString& ModuleName,
bool show_msg_err );
/** function Get_Librairie_Module
*
* Read active libraries or one library to find and load a given module
* 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(
WinEDA_DrawFrame* active_window, const wxString& Library,
const wxString& Mask, const wxString& KeyWord );
WinEDA_DrawFrame* active_window, const wxString& aLibraryFullFilename,
const wxString& aMask, const wxString& aKeyWord );
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
wxString& libname )
wxString& aLibname )
/**********************************************************/
{
wxFileName newFileName;
@ -224,17 +224,17 @@ void WinEDA_ModuleEditFrame::Delete_Module_In_Library( const
wxString CmpName, msg;
/* 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 )
return;
/* Confirmation */
msg.Printf( _( "Ok to delete module %s in library %s" ),
CmpName.GetData(), libname.GetData() );
CmpName.GetData(), aLibname.GetData() );
if( !IsOK( this, msg ) )
return;
oldFileName = libname;
oldFileName = aLibname;
if( ( lib_module = wxFopen( oldFileName.GetFullPath(),
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 */
{
@ -147,7 +147,7 @@ MODULE* WinEDA_BasePcbFrame::Load_Module_From_Library( const wxString& library,
return NULL; /* annulation de commande */
}
else
module = Get_Librairie_Module( this, library, ModuleName, TRUE );
module = Get_Librairie_Module( library, ModuleName, TRUE );
}
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
* Si ce module est trouve, le copie en memoire, et le
* chaine en fin de liste des modules
* - Entree:
* name_cmp = nom du module
* - Retour:
* Pointeur sur le nouveau module.
* Read active libraries or one library to find and load a given module
* 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* WinEDA_BasePcbFrame::Get_Librairie_Module( wxWindow* winaff,
const wxString& library,
const wxString& ModuleName,
bool show_msg_err )
*/
MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( const wxString& aLibraryFullFilename,
const wxString& aModuleName,
bool aDisplayMessageError )
{
int LineNum, Found = 0;
wxFileName fn;
@ -194,11 +192,14 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( wxWindow* winaff,
MODULE* NewModule;
FILE* file = NULL;
unsigned ii;
bool one_lib = aLibraryFullFilename.IsEmpty() ? false : true;
for( ii = 0; ii < g_LibName_List.GetCount(); ii++ )
{
fn = wxFileName( wxEmptyString, g_LibName_List[ii],
ModuleFileExtension );
if ( one_lib )
fn = aLibraryFullFilename;
else
fn = wxFileName( wxEmptyString, g_LibName_List[ii], ModuleFileExtension );
tmp = wxGetApp().GetLibraryPathList().FindValidPath( fn.GetFullName() );
@ -253,7 +254,7 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( wxWindow* winaff,
break;
StrPurge( Line );
msg = CONV_FROM_UTF8( Line );
if( msg.CmpNoCase( ModuleName ) == 0 )
if( msg.CmpNoCase( aModuleName ) == 0 )
{
Found = 1;
break; /* Trouve! */
@ -274,7 +275,7 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( wxWindow* winaff,
/* Lecture du nom du composant */
Name = CONV_FROM_UTF8( Line + 8 );
if( Name.CmpNoCase( ModuleName ) == 0 ) /* composant localise */
if( Name.CmpNoCase( aModuleName ) == 0 ) /* composant localise */
{
NewModule = new MODULE( GetBoard() );
@ -291,12 +292,15 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( wxWindow* winaff,
}
fclose( file );
if ( one_lib )
break;
}
if( show_msg_err )
if( aDisplayMessageError )
{
msg.Printf( _( "Module <%s> not found" ), ModuleName.c_str() );
DisplayError( winaff, msg );
msg.Printf( _( "Module <%s> not found" ), aModuleName.c_str() );
DisplayError( NULL, msg );
}
return NULL;
@ -306,19 +310,18 @@ MODULE* WinEDA_BasePcbFrame::Get_Librairie_Module( wxWindow* winaff,
/***************************************************************/
wxString WinEDA_BasePcbFrame::Select_1_Module_From_List(
WinEDA_DrawFrame* active_window,
const wxString& Library,
const wxString& Mask, const wxString& KeyWord )
const wxString& aLibraryFullFilename,
const wxString& aMask, const wxString& aKeyWord )
/***************************************************************/
/*
* Affiche la liste des modules des librairies
* Recherche dans la librairie Library ou generale si Library == NULL
* Mask = Filtre d'affichage( Mask = wxEmptyString pour listage non filtré )
* KeyWord = Liste de mots cles, Recherche limitee aux composants
* ayant ces mots cles ( KeyWord = wxEmptyString pour listage de tous les modules )
/** 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 )
*
* retourne wxEmptyString si abort ou probleme
* ou le nom du module
* @return wxEmptyString if abort or fails, or the selected module name if Ok
*/
{
int LineNum;
@ -341,14 +344,13 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List(
for( ii = 0; ii < g_LibName_List.GetCount(); ii++ )
{
/* Calcul du nom complet de la librairie */
if( Library.IsEmpty() )
if( aLibraryFullFilename.IsEmpty() )
{
fn = wxFileName( wxEmptyString, g_LibName_List[ii],
ModuleFileExtension );
}
else
fn = wxFileName( wxEmptyString, Library, ModuleFileExtension );
fn = aLibraryFullFilename;
tmp = wxGetApp().GetLibraryPathList().FindValidPath( fn.GetFullName() );
@ -363,10 +365,10 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List(
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 */
{
if( !Library.IsEmpty() )
if( !aLibraryFullFilename.IsEmpty() )
break;
continue;
}
@ -375,7 +377,7 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List(
if( file == NULL )
{
if( !Library.IsEmpty() )
if( !aLibraryFullFilename.IsEmpty() )
break;
continue;
}
@ -413,12 +415,12 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List(
break;
strupper( Line );
msg = CONV_FROM_UTF8( StrPurge( Line ) );
if( Mask.IsEmpty() )
if( aMask.IsEmpty() )
{
ListBox->Append( msg );
NbModules++;
}
else if( WildCompareString( Mask, msg, FALSE ) )
else if( WildCompareString( aMask, msg, FALSE ) )
{
ListBox->Append( msg );
NbModules++;
@ -431,17 +433,17 @@ wxString WinEDA_BasePcbFrame::Select_1_Module_From_List(
fclose( file );
file = NULL;
if( !Library.IsEmpty() )
if( !aLibraryFullFilename.IsEmpty() )
break;
}
/* creation de la liste des modules si recherche par mots-cles */
if( !KeyWord.IsEmpty() )
if( !aKeyWord.IsEmpty() )
{
ModList* ItemMod = MList;
while( ItemMod != NULL )
{
if( KeyWordOk( KeyWord, ItemMod->m_KeyWord ) )
if( KeyWordOk( aKeyWord, ItemMod->m_KeyWord ) )
{
NbModules++;
ListBox->Append( ItemMod->m_Name );

View File

@ -25,7 +25,7 @@
BOARD_ITEM* WinEDA_ModuleEditFrame::ModeditLocateAndDisplay( int aHotKeyCode )
/****************************************************************************/
{
BOARD_ITEM* item = GetCurItem();
BOARD_ITEM* item = GetCurItem();
if( GetBoard()->m_Modules == NULL )
return NULL;
@ -69,20 +69,19 @@ BOARD_ITEM* WinEDA_ModuleEditFrame::ModeditLocateAndDisplay( int aHotKeyCode )
item = (*m_Collector)[0];
SetCurItem( item );
}
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 */
wxMenuItem * item_title = new wxMenuItem(&itemMenu, -1, _( "Selection Clarification" ) );
wxMenuItem* item_title = new wxMenuItem( &itemMenu, -1, _( "Selection Clarification" ) );
#ifdef __WINDOWS__
wxFont bold_font(*wxNORMAL_FONT);
bold_font.SetWeight(wxFONTWEIGHT_BOLD);
bold_font.SetStyle( wxFONTSTYLE_ITALIC);
item_title->SetFont(bold_font);
wxFont bold_font( *wxNORMAL_FONT );
bold_font.SetWeight( wxFONTWEIGHT_BOLD );
bold_font.SetStyle( wxFONTSTYLE_ITALIC );
item_title->SetFont( bold_font );
#endif
itemMenu.Append(item_title);
itemMenu.Append( item_title );
itemMenu.AppendSeparator();
int limit = MIN( MAX_ITEMS_IN_PICKER, m_Collector->GetCount() );
@ -103,7 +102,7 @@ BOARD_ITEM* WinEDA_ModuleEditFrame::ModeditLocateAndDisplay( int aHotKeyCode )
// this menu's handler is void WinEDA_BasePcbFrame::ProcessItemSelection()
// and it calls SetCurItem() which in turn calls Display_Infos() on the item.
DrawPanel->m_AbortRequest = true; // changed in false if an item
PopupMenu( &itemMenu ); // m_AbortRequest = false if an item is selected
PopupMenu( &itemMenu ); // m_AbortRequest = false if an item is selected
DrawPanel->MouseToCursorSchema();
@ -122,7 +121,6 @@ BOARD_ITEM* WinEDA_ModuleEditFrame::ModeditLocateAndDisplay( int aHotKeyCode )
}
/****************************************************************************/
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,
ModuleFileExtension );
wxString tmp =
wxString full_libraryfilename =
wxGetApp().GetLibraryPathList().FindValidPath( fn.GetFullName() );
if( wxFileName::FileExists( tmp ) )
Delete_Module_In_Library( tmp );
if( wxFileName::FileExists( full_libraryfilename ) )
Delete_Module_In_Library( full_libraryfilename );
break;
}
@ -220,9 +218,9 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
GetScreen()->m_Curseur = wxPoint( 0, 0 );
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 )
GetBoard()->m_Modules->m_Flags = 0;
Zoom_Automatique( true );
@ -253,8 +251,8 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
{
// update module in the current board,
// not just add it to the board with total disregard for the netlist...
WinEDA_PcbFrame* pcbframe = (WinEDA_PcbFrame*) GetParent();
BOARD* mainpcb = pcbframe->GetBoard();
WinEDA_PcbFrame* pcbframe = (WinEDA_PcbFrame*) GetParent();
BOARD* mainpcb = pcbframe->GetBoard();
MODULE* source_module = NULL;
MODULE* module_in_edit = GetBoard()->m_Modules;
@ -263,7 +261,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
if( module_in_edit->m_Link ) // this is not a new module ...
{
source_module = mainpcb->m_Modules;
for( ; source_module != NULL; source_module = (MODULE*) source_module->Next() )
for( ; source_module != NULL; source_module = (MODULE*) source_module->Next() )
{
if( module_in_edit->m_Link == source_module->m_TimeStamp )
break;
@ -290,7 +288,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
// Create the "new" module
MODULE* newmodule = new MODULE( mainpcb );
newmodule->Copy( module_in_edit );
newmodule->m_Link = 0;
newmodule->m_Link = 0;
// Put the footprint in the main pcb linked list.
mainpcb->Add( newmodule );
@ -316,7 +314,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
pcbframe->SetCurItem( NULL );
mainpcb->m_Status_Pcb = 0;
}
break;
break;
case ID_MODEDIT_IMPORT_PART:
GetScreen()->ClearUndoRedoList();
@ -346,11 +344,21 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
break;
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();
SetCurItem( NULL );
Clear_Pcb( true );
GetScreen()->m_Curseur = wxPoint( 0, 0 );
Load_Module_From_Library( m_CurrentLib, &dc );
Load_Module_From_Library( full_libraryfilename, &dc );
}
if( GetBoard()->m_Modules )
GetBoard()->m_Modules->m_Flags = 0;
@ -362,10 +370,10 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
TEXTE_MODULE* val = GetBoard()->m_Modules->m_Value;
if( val && ref )
{
ref->m_Type = TEXT_is_REFERENCE; // just in case ...
ref->m_Type = TEXT_is_REFERENCE; // just in case ...
if( ref->m_Text.Length() == 0 )
ref->m_Text = L"Ref**";
val->m_Type = TEXT_is_VALUE; // just in case ...
val->m_Type = TEXT_is_VALUE; // just in case ...
if( val->m_Text.Length() == 0 )
val->m_Text = L"Val**";
}
@ -522,18 +530,18 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_POPUP_PCB_ENTER_EDGE_WIDTH:
{
EDGE_MODULE* edge = NULL;
if( GetScreen()->GetCurItem()
&& ( GetScreen()->GetCurItem()->m_Flags & IS_NEW)
&& (GetScreen()->GetCurItem()->Type() == TYPE_EDGE_MODULE) )
{
EDGE_MODULE* edge = NULL;
if( GetScreen()->GetCurItem()
&& ( GetScreen()->GetCurItem()->m_Flags & IS_NEW)
&& (GetScreen()->GetCurItem()->Type() == TYPE_EDGE_MODULE) )
{
edge = (EDGE_MODULE*) GetScreen()->GetCurItem();
}
Enter_Edge_Width( edge, &dc );
DrawPanel->MouseToCursorSchema();
edge = (EDGE_MODULE*) GetScreen()->GetCurItem();
}
break;
Enter_Edge_Width( edge, &dc );
DrawPanel->MouseToCursorSchema();
}
break;
case ID_POPUP_PCB_EDIT_WIDTH_CURRENT_EDGE:
DrawPanel->MouseToCursorSchema();
@ -576,16 +584,16 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
break;
case ID_PCB_PAD_SETUP:
{
BOARD_ITEM* item = GetCurItem();
if( item )
{
BOARD_ITEM* item = GetCurItem();
if( item )
{
if( item->Type() != TYPE_PAD )
item = NULL;
}
InstallPadOptionsFrame( (D_PAD*) item, &dc, pos );
if( item->Type() != TYPE_PAD )
item = NULL;
}
break;
InstallPadOptionsFrame( (D_PAD*) item, &dc, pos );
}
break;
case ID_PCB_USER_GRID_SETUP:
InstallGridFrame( pos );
@ -662,7 +670,7 @@ void WinEDA_ModuleEditFrame::Transform( MODULE* module, wxDC* DC, int transform
* orientation 0, cot<EFBFBD> composant.
*/
{
D_PAD* pad = module->m_Pads;
D_PAD* pad = module->m_Pads;
EDA_BaseStruct* PtStruct = module->m_Drawings;
TEXTE_MODULE* textmod;
EDGE_MODULE* edgemod;

View File

@ -491,7 +491,7 @@ MODULE* ReadNetModule( WinEDA_PcbFrame* aFrame,
if( aChangeFootprint )
{
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 */
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) )
{
/* 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;
if( Module == NULL )
{

View File

@ -494,7 +494,7 @@ MODULE* WinEDA_ExchangeModuleFrame::Change_1_Module( MODULE* Module,
namecmp.Trim( TRUE );
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 */
{
m_WinMsg->WriteText( wxT( "No\n" ) );