BUGFIX: .mdc is incomplete after 'archive footprint'
This commit is contained in:
parent
94cf5b0d28
commit
f64b282778
File diff suppressed because it is too large
Load Diff
|
@ -21,9 +21,9 @@
|
||||||
* $EndLIBRARY
|
* $EndLIBRARY
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define OLD_EXT wxT( ".bak" )
|
#define OLD_EXT wxT( ".bak" )
|
||||||
#define FILETMP_EXT wxT( ".$$$" )
|
#define FILETMP_EXT wxT( ".$$$" )
|
||||||
#define EXPORT_IMPORT_LASTPATH_KEY wxT("import_last_path")
|
#define EXPORT_IMPORT_LASTPATH_KEY wxT( "import_last_path" )
|
||||||
|
|
||||||
/* Fonctions locales */
|
/* Fonctions locales */
|
||||||
static bool CreateDocLibrary( const wxString& LibName );
|
static bool CreateDocLibrary( const wxString& LibName );
|
||||||
|
@ -43,28 +43,29 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC )
|
||||||
* @param DC = Current Device Context (can be NULL)
|
* @param DC = Current Device Context (can be NULL)
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
int NbLine = 0;
|
int NbLine = 0;
|
||||||
char Line[1024];
|
char Line[1024];
|
||||||
wxString CmpFullFileName;
|
wxString CmpFullFileName;
|
||||||
FILE* dest;
|
FILE* dest;
|
||||||
MODULE* module = NULL;
|
MODULE* module = NULL;
|
||||||
bool Footprint_Is_GPCB_Format = false;
|
bool Footprint_Is_GPCB_Format = false;
|
||||||
wxString mask = wxT("*.*;"); mask += EXT_CMP_MASK;
|
wxString mask = wxT( "*.*;" ); mask += EXT_CMP_MASK;
|
||||||
wxString LastOpenedPathForLoading;
|
|
||||||
wxConfig* Config = wxGetApp().m_EDA_Config;
|
wxString LastOpenedPathForLoading;
|
||||||
|
wxConfig* Config = wxGetApp().m_EDA_Config;
|
||||||
|
|
||||||
if( Config )
|
if( Config )
|
||||||
Config->Read( EXPORT_IMPORT_LASTPATH_KEY, &LastOpenedPathForLoading );
|
Config->Read( EXPORT_IMPORT_LASTPATH_KEY, &LastOpenedPathForLoading );
|
||||||
|
|
||||||
/* Lecture Fichier module */
|
/* Lecture Fichier module */
|
||||||
CmpFullFileName = EDA_FileSelector( _( "Import Module:" ),
|
CmpFullFileName = EDA_FileSelector( _( "Import Module:" ),
|
||||||
LastOpenedPathForLoading, /* Chemin par defaut */
|
LastOpenedPathForLoading, /* Chemin par defaut */
|
||||||
wxEmptyString, /* nom fichier par defaut */
|
wxEmptyString, /* nom fichier par defaut */
|
||||||
wxEmptyString, /* extension par defaut */
|
wxEmptyString, /* extension par defaut */
|
||||||
mask, /* Masque d'affichage */
|
mask, /* Masque d'affichage */
|
||||||
this,
|
this,
|
||||||
wxFD_OPEN,
|
wxFD_OPEN,
|
||||||
TRUE
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
if( CmpFullFileName == wxEmptyString )
|
if( CmpFullFileName == wxEmptyString )
|
||||||
|
@ -78,7 +79,7 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC )
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( Config ) // Save file path
|
if( Config ) // Save file path
|
||||||
{
|
{
|
||||||
LastOpenedPathForLoading = wxPathOnly( CmpFullFileName );
|
LastOpenedPathForLoading = wxPathOnly( CmpFullFileName );
|
||||||
Config->Write( EXPORT_IMPORT_LASTPATH_KEY, LastOpenedPathForLoading );
|
Config->Write( EXPORT_IMPORT_LASTPATH_KEY, LastOpenedPathForLoading );
|
||||||
|
@ -99,7 +100,7 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC )
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read file: Search the description starting line (skip lib header)*/
|
/* Read file: Search the description starting line (skip lib header)*/
|
||||||
if ( ! Footprint_Is_GPCB_Format )
|
if( !Footprint_Is_GPCB_Format )
|
||||||
{
|
{
|
||||||
while( GetLine( dest, Line, &NbLine ) != NULL )
|
while( GetLine( dest, Line, &NbLine ) != NULL )
|
||||||
{
|
{
|
||||||
|
@ -110,10 +111,10 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC )
|
||||||
|
|
||||||
module = new MODULE( GetBoard() );
|
module = new MODULE( GetBoard() );
|
||||||
|
|
||||||
if ( Footprint_Is_GPCB_Format )
|
if( Footprint_Is_GPCB_Format )
|
||||||
{
|
{
|
||||||
fclose( dest );
|
fclose( dest );
|
||||||
module->Read_GPCB_Descr(CmpFullFileName);
|
module->Read_GPCB_Descr( CmpFullFileName );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -137,6 +138,7 @@ MODULE* WinEDA_ModuleEditFrame::Import_Module( wxDC* DC )
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
void WinEDA_ModuleEditFrame::Export_Module( MODULE* ptmod, bool createlib )
|
void WinEDA_ModuleEditFrame::Export_Module( MODULE* ptmod, bool createlib )
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Export_Module
|
* Function Export_Module
|
||||||
* Create a file containing only one footprint.
|
* Create a file containing only one footprint.
|
||||||
|
@ -149,11 +151,11 @@ void WinEDA_ModuleEditFrame::Export_Module( MODULE* ptmod, bool createlib )
|
||||||
* false = use current path or last used path to export footprint
|
* false = use current path or last used path to export footprint
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
wxString FullFileName, Mask( wxT( "*" ) );
|
wxString FullFileName, Mask( wxT( "*" ) );
|
||||||
char Line[1025];
|
char Line[1025];
|
||||||
FILE* dest;
|
FILE* dest;
|
||||||
wxString msg, path;
|
wxString msg, path;
|
||||||
wxConfig* Config = wxGetApp().m_EDA_Config;
|
wxConfig* Config = wxGetApp().m_EDA_Config;
|
||||||
|
|
||||||
if( ptmod == NULL )
|
if( ptmod == NULL )
|
||||||
return;
|
return;
|
||||||
|
@ -176,7 +178,7 @@ void WinEDA_ModuleEditFrame::Export_Module( MODULE* ptmod, bool createlib )
|
||||||
Mask, /* Masque d'affichage */
|
Mask, /* Masque d'affichage */
|
||||||
this,
|
this,
|
||||||
wxFD_SAVE,
|
wxFD_SAVE,
|
||||||
TRUE
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
if( FullFileName.IsEmpty() )
|
if( FullFileName.IsEmpty() )
|
||||||
|
@ -198,7 +200,7 @@ void WinEDA_ModuleEditFrame::Export_Module( MODULE* ptmod, bool createlib )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ! createlib && Config ) // Save file path
|
if( !createlib && Config ) // Save file path
|
||||||
{
|
{
|
||||||
path = wxPathOnly( FullFileName );
|
path = wxPathOnly( FullFileName );
|
||||||
Config->Write( EXPORT_IMPORT_LASTPATH_KEY, path );
|
Config->Write( EXPORT_IMPORT_LASTPATH_KEY, path );
|
||||||
|
@ -395,7 +397,7 @@ void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName,
|
||||||
/*
|
/*
|
||||||
* Sauve en Librairie:
|
* Sauve en Librairie:
|
||||||
* tous les nouveaux modules ( c.a.d. les modules
|
* tous les nouveaux modules ( c.a.d. les modules
|
||||||
* n'existant pas deja (si NewModulesOnly == TRUE)
|
* n'existant pas deja (si NewModulesOnly == true)
|
||||||
* tous les modules (si NewModulesOnly == FALSE)
|
* tous les modules (si NewModulesOnly == FALSE)
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
|
@ -420,7 +422,7 @@ void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName,
|
||||||
Mask, /* Masque d'affichage */
|
Mask, /* Masque d'affichage */
|
||||||
this,
|
this,
|
||||||
wxFD_SAVE,
|
wxFD_SAVE,
|
||||||
TRUE
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
if( FullFileName.IsEmpty() )
|
if( FullFileName.IsEmpty() )
|
||||||
|
@ -448,7 +450,7 @@ void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName,
|
||||||
DisplayError( this, msg );
|
DisplayError( this, msg );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
char Line[256];
|
char Line[256];
|
||||||
fprintf( lib_module, "%s %s\n", ENTETE_LIBRAIRIE, DateAndTime( Line ) );
|
fprintf( lib_module, "%s %s\n", ENTETE_LIBRAIRIE, DateAndTime( Line ) );
|
||||||
fputs( "$INDEX\n", lib_module );
|
fputs( "$INDEX\n", lib_module );
|
||||||
fputs( "$EndINDEX\n", lib_module );
|
fputs( "$EndINDEX\n", lib_module );
|
||||||
|
@ -467,31 +469,33 @@ void WinEDA_BasePcbFrame::Archive_Modules( const wxString& LibName,
|
||||||
Module = (MODULE*) GetBoard()->m_Modules;
|
Module = (MODULE*) GetBoard()->m_Modules;
|
||||||
for( ii = 1; Module != NULL; ii++, Module = (MODULE*) Module->Next() )
|
for( ii = 1; Module != NULL; ii++, Module = (MODULE*) Module->Next() )
|
||||||
{
|
{
|
||||||
if( Save_1_Module( FullFileName, Module,
|
if( Save_Module_In_Library( FullFileName, Module,
|
||||||
NewModulesOnly ? FALSE : TRUE, FALSE ) == 0 )
|
NewModulesOnly ? FALSE : true, FALSE, false ) == 0 )
|
||||||
break;
|
break;
|
||||||
DisplayActivity( (int) ( ii * Pas), wxEmptyString );
|
DisplayActivity( (int) ( ii * Pas ), wxEmptyString );
|
||||||
/* Tst demande d'arret de sauvegarde ( key ESCAPE actionnee ) */
|
/* Tst demande d'arret de sauvegarde ( key ESCAPE actionnee ) */
|
||||||
if( DrawPanel->m_AbortRequest )
|
if( DrawPanel->m_AbortRequest )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateDocLibrary( LibName );
|
CreateDocLibrary( FullFileName );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************/
|
/*****************************************************************/
|
||||||
int WinEDA_BasePcbFrame::Save_1_Module( const wxString& LibName,
|
int WinEDA_BasePcbFrame::Save_Module_In_Library( const wxString& aLibName,
|
||||||
MODULE* Module, bool Overwrite, bool DisplayDialog )
|
MODULE* aModule, bool aOverwrite,
|
||||||
|
bool aDisplayDialog, bool aCreateDocFile )
|
||||||
/*****************************************************************/
|
/*****************************************************************/
|
||||||
|
|
||||||
/*
|
/** Function Save_Module_In_Library
|
||||||
* sauve en Librairie le module Module:
|
* Save in an existing library a given footprint
|
||||||
* si no_replace == TRUE, s'il est nouveau.
|
* @param aLibName = name of the library to use
|
||||||
*
|
* @param aModule = the given footprint
|
||||||
* retourne
|
* @param aOverwrite = true to overwrite an existing footprint, false to abort an existing footprint is found
|
||||||
* 1 si OK
|
* @param aDisplayDialog = true to display a dialog to enter or confirm the footprint name
|
||||||
* 0 si abort ou probleme
|
* @param aCreateDocFile = true to creates the associated doc file
|
||||||
|
* @return : 1 if OK, 0 if abort
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
int newmodule, end;
|
int newmodule, end;
|
||||||
|
@ -500,49 +504,49 @@ int WinEDA_BasePcbFrame::Save_1_Module( const wxString& LibName,
|
||||||
wxString Name_Cmp;
|
wxString Name_Cmp;
|
||||||
wxString NewLib, OldLib, msg;
|
wxString NewLib, OldLib, msg;
|
||||||
FILE* lib_module, * dest;
|
FILE* lib_module, * dest;
|
||||||
bool added = TRUE;
|
bool added = true;
|
||||||
|
|
||||||
Module->Display_Infos( this );
|
aModule->Display_Infos( this );
|
||||||
|
|
||||||
if( !wxFileExists( LibName ) )
|
if( !wxFileExists( aLibName ) )
|
||||||
{
|
{
|
||||||
msg.Printf( _( "Library %s not found" ), LibName.GetData() );
|
msg.Printf( _( "Library %s not found" ), aLibName.GetData() );
|
||||||
DisplayError( this, msg );
|
DisplayError( this, msg );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Demande du nom du composant en librairie */
|
/* Ask for the footprint name in lib */
|
||||||
Name_Cmp = Module->m_LibRef;
|
Name_Cmp = aModule->m_LibRef;
|
||||||
|
|
||||||
if( DisplayDialog )
|
if( aDisplayDialog )
|
||||||
{
|
{
|
||||||
Get_Message( _( "Name:" ), _("Save module"), Name_Cmp, this );
|
Get_Message( _( "Name:" ), _( "Save module" ), Name_Cmp, this );
|
||||||
if( Name_Cmp.IsEmpty() )
|
if( Name_Cmp.IsEmpty() )
|
||||||
return 0;
|
return 0;
|
||||||
Name_Cmp.Trim( TRUE );
|
Name_Cmp.Trim( true );
|
||||||
Name_Cmp.Trim( FALSE );
|
Name_Cmp.Trim( FALSE );
|
||||||
Module->m_LibRef = Name_Cmp;
|
aModule->m_LibRef = Name_Cmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ( lib_module = wxFopen( LibName, wxT( "rt" ) ) ) == NULL )
|
if( ( lib_module = wxFopen( aLibName, wxT( "rt" ) ) ) == NULL )
|
||||||
{
|
{
|
||||||
msg.Printf( _( "Unable to open %s" ), LibName.GetData() );
|
msg.Printf( _( "Unable to open %s" ), aLibName.GetData() );
|
||||||
DisplayError( this, msg );
|
DisplayError( this, msg );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* lecture entete : ENTETE_LIBRAIRIE */
|
/* lRead library file : library header */
|
||||||
GetLine( lib_module, Line, &LineNum );
|
GetLine( lib_module, Line, &LineNum );
|
||||||
if( strnicmp( Line, ENTETE_LIBRAIRIE, L_ENTETE_LIB ) != 0 )
|
if( strnicmp( Line, ENTETE_LIBRAIRIE, L_ENTETE_LIB ) != 0 )
|
||||||
{
|
{
|
||||||
fclose( lib_module );
|
fclose( lib_module );
|
||||||
msg.Printf( _( "File %s is not a eeschema library" ), LibName.GetData() );
|
msg.Printf( _( "File %s is not a eeschema library" ), aLibName.GetData() );
|
||||||
DisplayError( this, msg );
|
DisplayError( this, msg );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* lecture des noms des composants - verif si le module est deja existant */
|
/* Reaf footprints in lib: - search for an existing footprint */
|
||||||
newmodule = 1; end = 0;
|
newmodule = 1; end = 0;
|
||||||
while( !end && GetLine( lib_module, Line, &LineNum ) )
|
while( !end && GetLine( lib_module, Line, &LineNum ) )
|
||||||
{
|
{
|
||||||
|
@ -560,17 +564,17 @@ int WinEDA_BasePcbFrame::Save_1_Module( const wxString& LibName,
|
||||||
|
|
||||||
StrPurge( Line );
|
StrPurge( Line );
|
||||||
msg = CONV_FROM_UTF8( Line );
|
msg = CONV_FROM_UTF8( Line );
|
||||||
if( Name_Cmp.CmpNoCase( msg ) == 0 ) /* composant trouve */
|
if( Name_Cmp.CmpNoCase( msg ) == 0 ) /* an existing footprint is found */
|
||||||
{
|
{
|
||||||
added = FALSE;
|
added = FALSE;
|
||||||
newmodule = 0;
|
newmodule = 0;
|
||||||
if( DisplayDialog )
|
if( aDisplayDialog )
|
||||||
{
|
{
|
||||||
msg = _( "Module exists\n Line: " );
|
msg = _( "Module exists\n Line: " );
|
||||||
msg << LineNum;
|
msg << LineNum;
|
||||||
Affiche_Message( msg );
|
Affiche_Message( msg );
|
||||||
}
|
}
|
||||||
if( !Overwrite ) /* le module n'est pas a sauver car deja existant */
|
if( !aOverwrite ) /* lDo not save the given footprint: an old one exists */
|
||||||
{
|
{
|
||||||
fclose( lib_module ); return 1;
|
fclose( lib_module ); return 1;
|
||||||
}
|
}
|
||||||
|
@ -581,15 +585,15 @@ int WinEDA_BasePcbFrame::Save_1_Module( const wxString& LibName,
|
||||||
|
|
||||||
fclose( lib_module );
|
fclose( lib_module );
|
||||||
|
|
||||||
/* Creation de la nouvelle librairie */
|
/* Creates the new library */
|
||||||
|
|
||||||
if( ( lib_module = wxFopen( LibName, wxT( "rt" ) ) ) == NULL )
|
if( ( lib_module = wxFopen( aLibName, wxT( "rt" ) ) ) == NULL )
|
||||||
{
|
{
|
||||||
DisplayError( this, wxT( "Librairi.cpp: Error oldlib not found" ) );
|
DisplayError( this, wxT( "Librairi.cpp: Error oldlib not found" ) );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
NewLib = LibName;
|
NewLib = aLibName;
|
||||||
ChangeFileNameExt( NewLib, FILETMP_EXT );
|
ChangeFileNameExt( NewLib, FILETMP_EXT );
|
||||||
if( ( dest = wxFopen( NewLib, wxT( "w+t" ) ) ) == NULL )
|
if( ( dest = wxFopen( NewLib, wxT( "w+t" ) ) ) == NULL )
|
||||||
{
|
{
|
||||||
|
@ -601,7 +605,7 @@ int WinEDA_BasePcbFrame::Save_1_Module( const wxString& LibName,
|
||||||
|
|
||||||
wxBeginBusyCursor();
|
wxBeginBusyCursor();
|
||||||
|
|
||||||
/* Creation de l'entete avec nouvelle date */
|
/* Create the library header with a new date */
|
||||||
fprintf( dest, ENTETE_LIBRAIRIE );
|
fprintf( dest, ENTETE_LIBRAIRIE );
|
||||||
fprintf( dest, " %s\n$INDEX\n", DateAndTime( Line ) );
|
fprintf( dest, " %s\n$INDEX\n", DateAndTime( Line ) );
|
||||||
|
|
||||||
|
@ -629,7 +633,7 @@ int WinEDA_BasePcbFrame::Save_1_Module( const wxString& LibName,
|
||||||
|
|
||||||
fprintf( dest, "$EndINDEX\n" );
|
fprintf( dest, "$EndINDEX\n" );
|
||||||
|
|
||||||
/* Copie des modules, jusqu'au module a supprimer */
|
/* Copy footprints, until the old footprint to delete */
|
||||||
while( GetLine( lib_module, Line, &LineNum ) )
|
while( GetLine( lib_module, Line, &LineNum ) )
|
||||||
{
|
{
|
||||||
StrPurge( Line );
|
StrPurge( Line );
|
||||||
|
@ -641,7 +645,7 @@ int WinEDA_BasePcbFrame::Save_1_Module( const wxString& LibName,
|
||||||
msg = CONV_FROM_UTF8( Name );
|
msg = CONV_FROM_UTF8( Name );
|
||||||
if( msg.CmpNoCase( Name_Cmp ) == 0 )
|
if( msg.CmpNoCase( Name_Cmp ) == 0 )
|
||||||
{
|
{
|
||||||
/* suppression ancien module */
|
/* skip old footprint descr (delete from the lib)*/
|
||||||
while( GetLine( lib_module, Line, &LineNum ) )
|
while( GetLine( lib_module, Line, &LineNum ) )
|
||||||
{
|
{
|
||||||
if( strnicmp( Line, "$EndMODULE", 9 ) == 0 )
|
if( strnicmp( Line, "$EndMODULE", 9 ) == 0 )
|
||||||
|
@ -654,40 +658,42 @@ int WinEDA_BasePcbFrame::Save_1_Module( const wxString& LibName,
|
||||||
fprintf( dest, "%s\n", Line );
|
fprintf( dest, "%s\n", Line );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ecriture du module ( en fin de librairie ) */
|
/* Write the new footprint ( append it to the list of footprint ) */
|
||||||
tmp = Module->m_TimeStamp; Module->m_TimeStamp = 0;
|
tmp = aModule->m_TimeStamp; aModule->m_TimeStamp = 0;
|
||||||
Module->Save( dest );
|
aModule->Save( dest );
|
||||||
fprintf( dest, "$EndLIBRARY\n" );
|
fprintf( dest, "$EndLIBRARY\n" );
|
||||||
Module->m_TimeStamp = tmp;
|
aModule->m_TimeStamp = tmp;
|
||||||
|
|
||||||
fclose( dest ); fclose( lib_module );
|
fclose( dest ); fclose( lib_module );
|
||||||
|
|
||||||
wxEndBusyCursor();
|
wxEndBusyCursor();
|
||||||
|
|
||||||
/* L'ancien fichier librairie est renomme en .bak */
|
/* The old library file is renamed .bak */
|
||||||
OldLib = LibName;
|
OldLib = aLibName;
|
||||||
ChangeFileNameExt( OldLib, OLD_EXT );
|
ChangeFileNameExt( OldLib, OLD_EXT );
|
||||||
|
|
||||||
if( wxFileExists( OldLib ) )
|
if( wxFileExists( OldLib ) )
|
||||||
wxRemoveFile( OldLib );
|
wxRemoveFile( OldLib );
|
||||||
|
|
||||||
if( !wxRenameFile( LibName, OldLib ) )
|
if( !wxRenameFile( aLibName, OldLib ) )
|
||||||
DisplayError( this, wxT( "Librairi.cpp: rename .bak err" ) );
|
DisplayError( this, wxT( "Librairi.cpp: rename .bak err" ) );
|
||||||
|
|
||||||
/* Le nouveau fichier librairie est renomme */
|
/* The new library file is renamed */
|
||||||
if( !wxRenameFile( NewLib, LibName ) )
|
if( !wxRenameFile( NewLib, aLibName ) )
|
||||||
{
|
{
|
||||||
DisplayError( this, wxT( "Librairi.cpp: rename NewLib err" ) );
|
DisplayError( this, wxT( "Librairi.cpp: rename NewLib err" ) );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateDocLibrary( OldLib );
|
/* creates the new .dcm doc file corresponding to the new library */
|
||||||
|
if ( aCreateDocFile )
|
||||||
|
CreateDocLibrary( aLibName );
|
||||||
|
|
||||||
if( DisplayDialog )
|
if( aDisplayDialog )
|
||||||
{
|
{
|
||||||
msg = _( "Component " ); msg += Name_Cmp;
|
msg = _( "Component " ); msg += Name_Cmp;
|
||||||
msg += added ? _( " added in " ) : _( " replaced in " );
|
msg += added ? _( " added in " ) : _( " replaced in " );
|
||||||
msg += LibName;
|
msg += aLibName;
|
||||||
Affiche_Message( msg );
|
Affiche_Message( msg );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -713,15 +719,15 @@ MODULE* WinEDA_BasePcbFrame::Create_1_Module( wxDC* DC, const wxString& module_n
|
||||||
/* Ask fo the new module reference */
|
/* Ask fo the new module reference */
|
||||||
if( module_name.IsEmpty() )
|
if( module_name.IsEmpty() )
|
||||||
{
|
{
|
||||||
if( Get_Message( _( "Module Reference:" ), _("Module Creation:"), Line, this ) != 0 )
|
if( Get_Message( _( "Module Reference:" ), _( "Module Creation:" ), Line, this ) != 0 )
|
||||||
{
|
{
|
||||||
DisplayInfo(this, _("No reference, aborted"));
|
DisplayInfo( this, _( "No reference, aborted" ) );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Line = module_name;
|
Line = module_name;
|
||||||
Line.Trim( TRUE );
|
Line.Trim( true );
|
||||||
Line.Trim( FALSE );
|
Line.Trim( FALSE );
|
||||||
|
|
||||||
// Creates the new module and add it to the head of the linked list of modules
|
// Creates the new module and add it to the head of the linked list of modules
|
||||||
|
@ -747,7 +753,7 @@ MODULE* WinEDA_BasePcbFrame::Create_1_Module( wxDC* DC, const wxString& module_n
|
||||||
Module->m_Value->SetWidth( ModuleTextWidth );
|
Module->m_Value->SetWidth( ModuleTextWidth );
|
||||||
Module->m_Value->m_Size = ModuleTextSize;
|
Module->m_Value->m_Size = ModuleTextSize;
|
||||||
|
|
||||||
Module->SetPosition( wxPoint(0, 0) );
|
Module->SetPosition( wxPoint( 0, 0 ) );
|
||||||
|
|
||||||
Module->Display_Infos( this );
|
Module->Display_Infos( this );
|
||||||
return Module;
|
return Module;
|
||||||
|
@ -762,7 +768,8 @@ void WinEDA_ModuleEditFrame::Select_Active_Library()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
WinEDAListBox* LibListBox = new WinEDAListBox( this, _( "Active Lib:" ),
|
WinEDAListBox* LibListBox = new WinEDAListBox( this, _( "Active Lib:" ),
|
||||||
NULL, m_CurrentLib, NULL, wxColour( 200, 200, 255 ) );
|
NULL, m_CurrentLib, NULL,
|
||||||
|
wxColour( 200, 200, 255 ) );
|
||||||
|
|
||||||
LibListBox->InsertItems( g_LibName_List );
|
LibListBox->InsertItems( g_LibName_List );
|
||||||
|
|
||||||
|
@ -783,7 +790,7 @@ int WinEDA_ModuleEditFrame::Create_Librairie( const wxString& LibName )
|
||||||
{
|
{
|
||||||
FILE* lib_module;
|
FILE* lib_module;
|
||||||
wxString msg;
|
wxString msg;
|
||||||
char cbuf[256];
|
char cbuf[256];
|
||||||
|
|
||||||
if( wxFileExists( LibName ) )
|
if( wxFileExists( LibName ) )
|
||||||
{
|
{
|
||||||
|
@ -887,7 +894,7 @@ static bool CreateDocLibrary( const wxString& LibName )
|
||||||
Doc = CONV_FROM_UTF8( StrPurge( Line + 3 ) );
|
Doc = CONV_FROM_UTF8( StrPurge( Line + 3 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( (Name != wxEmptyString) && ( (Doc != wxEmptyString) || (KeyWord != wxEmptyString) ) )/* Generation de la doc du composant */
|
if( (Name != wxEmptyString) && ( (Doc != wxEmptyString) || (KeyWord != wxEmptyString) ) ) /* Generation de la doc du composant */
|
||||||
{
|
{
|
||||||
fprintf( LibDoc, "#\n$MODULE %s\n", CONV_TO_UTF8( Name ) );
|
fprintf( LibDoc, "#\n$MODULE %s\n", CONV_TO_UTF8( Name ) );
|
||||||
fprintf( LibDoc, "Li %s\n", CONV_TO_UTF8( Name ) );
|
fprintf( LibDoc, "Li %s\n", CONV_TO_UTF8( Name ) );
|
||||||
|
@ -919,5 +926,5 @@ static bool CreateDocLibrary( const wxString& LibName )
|
||||||
fclose( LibMod );
|
fclose( LibMod );
|
||||||
fprintf( LibDoc, "#\n$EndLIBDOC\n" );
|
fprintf( LibDoc, "#\n$EndLIBDOC\n" );
|
||||||
fclose( LibDoc );
|
fclose( LibDoc );
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,7 +192,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
|
||||||
switch( id ) // Traitement des commandes
|
switch( id ) // Traitement des commandes
|
||||||
{
|
{
|
||||||
case ID_EXIT:
|
case ID_EXIT:
|
||||||
Close( TRUE );
|
Close( true );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_LIBEDIT_SELECT_CURRENT_LIB:
|
case ID_LIBEDIT_SELECT_CURRENT_LIB:
|
||||||
|
@ -209,7 +209,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
|
||||||
|
|
||||||
case ID_MODEDIT_NEW_MODULE:
|
case ID_MODEDIT_NEW_MODULE:
|
||||||
{
|
{
|
||||||
Clear_Pcb( TRUE );
|
Clear_Pcb( true );
|
||||||
GetScreen()->ClearUndoRedoList();
|
GetScreen()->ClearUndoRedoList();
|
||||||
SetCurItem( NULL );
|
SetCurItem( NULL );
|
||||||
GetScreen()->m_Curseur = wxPoint( 0, 0 );
|
GetScreen()->m_Curseur = wxPoint( 0, 0 );
|
||||||
|
@ -220,7 +220,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
|
||||||
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 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -229,7 +229,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
wxString Line;
|
wxString Line;
|
||||||
Line = MakeFileName( g_RealLibDirBuffer, m_CurrentLib.GetData(), LibExtBuffer );
|
Line = MakeFileName( g_RealLibDirBuffer, m_CurrentLib.GetData(), LibExtBuffer );
|
||||||
Save_1_Module( Line, GetBoard()->m_Modules, TRUE, TRUE );
|
Save_Module_In_Library( Line, GetBoard()->m_Modules, true, true, true );
|
||||||
GetScreen()->ClrModify();
|
GetScreen()->ClrModify();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -315,13 +315,13 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
|
||||||
case ID_LIBEDIT_IMPORT_PART:
|
case ID_LIBEDIT_IMPORT_PART:
|
||||||
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 );
|
||||||
Import_Module( &dc );
|
Import_Module( &dc );
|
||||||
if( GetBoard()->m_Modules )
|
if( GetBoard()->m_Modules )
|
||||||
GetBoard()->m_Modules->m_Flags = 0;
|
GetBoard()->m_Modules->m_Flags = 0;
|
||||||
GetScreen()->ClrModify();
|
GetScreen()->ClrModify();
|
||||||
Zoom_Automatique( TRUE );
|
Zoom_Automatique( true );
|
||||||
if( m_Draw3DFrame )
|
if( m_Draw3DFrame )
|
||||||
m_Draw3DFrame->NewDisplay();
|
m_Draw3DFrame->NewDisplay();
|
||||||
break;
|
break;
|
||||||
|
@ -333,7 +333,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
|
||||||
|
|
||||||
case ID_LIBEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART:
|
case ID_LIBEDIT_CREATE_NEW_LIB_AND_SAVE_CURRENT_PART:
|
||||||
if( GetBoard()->m_Modules )
|
if( GetBoard()->m_Modules )
|
||||||
Export_Module( GetBoard()->m_Modules, TRUE );
|
Export_Module( GetBoard()->m_Modules, true );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_MODEDIT_SHEET_SET:
|
case ID_MODEDIT_SHEET_SET:
|
||||||
|
@ -342,7 +342,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
|
||||||
case ID_MODEDIT_LOAD_MODULE:
|
case ID_MODEDIT_LOAD_MODULE:
|
||||||
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( m_CurrentLib, &dc );
|
||||||
if( GetBoard()->m_Modules )
|
if( GetBoard()->m_Modules )
|
||||||
|
@ -365,7 +365,7 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GetScreen()->ClrModify();
|
GetScreen()->ClrModify();
|
||||||
Zoom_Automatique( TRUE );
|
Zoom_Automatique( true );
|
||||||
if( m_Draw3DFrame )
|
if( m_Draw3DFrame )
|
||||||
m_Draw3DFrame->NewDisplay();
|
m_Draw3DFrame->NewDisplay();
|
||||||
break;
|
break;
|
||||||
|
@ -425,12 +425,12 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
|
||||||
|
|
||||||
case ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE:
|
case ID_POPUP_PCB_ROTATE_MODULE_COUNTERCLOCKWISE:
|
||||||
DrawPanel->MouseToCursorSchema();
|
DrawPanel->MouseToCursorSchema();
|
||||||
Rotate_Module( &dc, (MODULE*) GetScreen()->GetCurItem(), 900, TRUE );
|
Rotate_Module( &dc, (MODULE*) GetScreen()->GetCurItem(), 900, true );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE:
|
case ID_POPUP_PCB_ROTATE_MODULE_CLOCKWISE:
|
||||||
DrawPanel->MouseToCursorSchema();
|
DrawPanel->MouseToCursorSchema();
|
||||||
Rotate_Module( &dc, (MODULE*) GetScreen()->GetCurItem(), -900, TRUE );
|
Rotate_Module( &dc, (MODULE*) GetScreen()->GetCurItem(), -900, true );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_POPUP_PCB_EDIT_MODULE:
|
case ID_POPUP_PCB_EDIT_MODULE:
|
||||||
|
@ -587,12 +587,12 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
|
||||||
|
|
||||||
case ID_MODEDIT_UNDO:
|
case ID_MODEDIT_UNDO:
|
||||||
GetComponentFromUndoList();
|
GetComponentFromUndoList();
|
||||||
DrawPanel->Refresh( TRUE );
|
DrawPanel->Refresh( true );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_MODEDIT_REDO:
|
case ID_MODEDIT_REDO:
|
||||||
GetComponentFromRedoList();
|
GetComponentFromRedoList();
|
||||||
DrawPanel->Refresh( TRUE );
|
DrawPanel->Refresh( true );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ID_POPUP_PLACE_BLOCK:
|
case ID_POPUP_PLACE_BLOCK:
|
||||||
|
|
Loading…
Reference in New Issue