Commit 24e66546 authored by dickelbeck's avatar dickelbeck

formatting and comments

parent a55ef8df
/*****************************/ /*****************************/
/* EESchema - lib_export.cpp */ /* EESchema - lib_export.cpp */
/*****************************/ /*****************************/
/* Routines de maintenanace des librariries: /* Routines de maintenanace des librariries:
sauvegarde, modification de librairies. * sauvegarde, modification de librairies.
creation edition suppression de composants * creation edition suppression de composants
*/ */
#include "fctsys.h" #include "fctsys.h"
#include "gr_basic.h" #include "gr_basic.h"
...@@ -20,125 +20,132 @@ ...@@ -20,125 +20,132 @@
#include "id.h" #include "id.h"
/*************************************************/ /*************************************************/
void WinEDA_LibeditFrame::ImportOnePart() void WinEDA_LibeditFrame::ImportOnePart()
/*************************************************/ /*************************************************/
/* Routine de lecture de 1 description. /* Routine de lecture de 1 description.
Le format est celui des librairies, mais on ne charge que 1 composant * Le format est celui des librairies, mais on ne charge que 1 composant
ou le 1er composant s'il y en a plusieurs. * ou le 1er composant s'il y en a plusieurs.
Si le premier composant est un alias, on chargera la racine correspondante * Si le premier composant est un alias, on chargera la racine correspondante
*/ */
{ {
wxString Name, mask; wxString Name, mask;
LibraryStruct * LibTmp; LibraryStruct* LibTmp;
EDA_LibComponentStruct *LibEntry; EDA_LibComponentStruct* LibEntry;
int err = 1; int err = 1;
mask = wxT("*") + g_LibExtBuffer; mask = wxT( "*" ) + g_LibExtBuffer;
Name = EDA_FileSelector( _("Import component:"), Name = EDA_FileSelector( _( "Import component:" ),
wxEmptyString, /* Chemin par defaut */ wxEmptyString, /* Chemin par defaut */
wxEmptyString, /* nom fichier par defaut */ wxEmptyString, /* nom fichier par defaut */
g_LibExtBuffer, /* extension par defaut */ g_LibExtBuffer, /* extension par defaut */
mask, /* Masque d'affichage */ mask, /* Masque d'affichage */
this, this,
0, 0,
TRUE TRUE
); );
if ( Name == wxEmptyString ) return; if( Name == wxEmptyString )
return;
LibTmp = g_LibraryList; g_LibraryList = NULL;
LibTmp = g_LibraryList; g_LibraryList = NULL;
LoadLibraryName(this, Name, wxT("$tmplib$"));
LoadLibraryName( this, Name, wxT( "$tmplib$" ) );
if ( g_LibraryList )
{ if( g_LibraryList )
LibEntry = (EDA_LibComponentStruct *)PQFirst(&g_LibraryList->m_Entries,FALSE); {
LibEntry = (EDA_LibComponentStruct*) PQFirst( &g_LibraryList->m_Entries, FALSE );
if( LibEntry )
err = LoadOneLibraryPartAux(LibEntry, g_LibraryList, 1); if( LibEntry )
FreeCmpLibrary(this, g_LibraryList->m_Name); err = LoadOneLibraryPartAux( LibEntry, g_LibraryList, 1 );
FreeCmpLibrary( this, g_LibraryList->m_Name );
if ( err == 0 )
{ if( err == 0 )
ReCreateHToolbar(); {
DisplayLibInfos(); ReCreateHToolbar();
ReDrawPanel(); DisplayLibInfos();
} ReDrawPanel();
} }
}
g_LibraryList = LibTmp;
if (err) DisplayError(this, _("File is empty"), 30); g_LibraryList = LibTmp;
if( err )
DisplayError( this, _( "File is empty" ), 30 );
} }
/************************************************************/ /************************************************************/
void WinEDA_LibeditFrame::ExportOnePart(bool create_lib) void WinEDA_LibeditFrame::ExportOnePart( bool create_lib )
/************************************************************/ /************************************************************/
/* Routine de creation d'une nouvelle librairie et de sauvegarde du
composant courant dans cette librarie
si create_lib == TRUE sauvegarde dans le repertoire des libr
sinon: sauvegarde sous le nom demande sans modifications.
Le format du fichier cree est dans tous les cas le meme. /* Routine de creation d'une nouvelle librairie et de sauvegarde du
*/ * composant courant dans cette librarie
* si create_lib == TRUE sauvegarde dans le repertoire des libr
* sinon: sauvegarde sous le nom demande sans modifications.
*
* Le format du fichier cree est dans tous les cas le meme.
*/
{ {
wxString Name, mask; wxString Name, mask;
LibraryStruct * NewLib, * LibTmp, * CurLibTmp; LibraryStruct* NewLib, * LibTmp, * CurLibTmp;
int err; int err;
if(CurrentLibEntry == NULL) if( CurrentLibEntry == NULL )
{ {
DisplayError(this, _("No Part to Save"),10); return; DisplayError( this, _( "No Part to Save" ), 10 ); return;
} }
Name = CurrentLibEntry->m_Name.m_Text; Name = CurrentLibEntry->m_Name.m_Text;
Name.MakeLower(); Name.MakeLower();
mask = wxT("*") + g_LibExtBuffer; mask = wxT( "*" ) + g_LibExtBuffer;
wxString def_path; wxString def_path;
if ( create_lib ) def_path = g_RealLibDirBuffer;
Name = EDA_FileSelector( create_lib ? _("New Library") : _("Export component:"), if( create_lib )
def_path, /* Chemin par defaut */ def_path = g_RealLibDirBuffer;
Name, /* nom fichier par defaut */
g_LibExtBuffer, /* extension par defaut */ Name = EDA_FileSelector( create_lib ? _( "New Library" ) : _( "Export component:" ),
mask, /* Masque d'affichage */ def_path, /* Chemin par defaut */
this, Name, /* nom fichier par defaut */
wxFD_SAVE, g_LibExtBuffer, /* extension par defaut */
TRUE mask, /* Masque d'affichage */
); this,
if ( Name == wxEmptyString ) return; wxFD_SAVE,
TRUE
);
/* Creation d'une librairie standard pour sauvegarde */
ChangeFileNameExt(Name, g_LibExtBuffer); if( Name == wxEmptyString )
return;
LibTmp = g_LibraryList;
CurLibTmp = CurrentLib;
/* Creation d'une librairie standard pour sauvegarde */
NewLib = new LibraryStruct(LIBRARY_TYPE_EESCHEMA, wxT("$libTmp$"), Name); ChangeFileNameExt( Name, g_LibExtBuffer );
g_LibraryList = NewLib;
LibTmp = g_LibraryList;
/* Sauvegarde du composant: */ CurLibTmp = CurrentLib;
CurrentLib = NewLib;
SaveOnePartInMemory(); NewLib = new LibraryStruct( LIBRARY_TYPE_EESCHEMA, wxT( "$libTmp$" ), Name );
err = SaveOneLibrary(this, Name, NewLib);
g_LibraryList = NewLib;
/* Suppression de la librarie temporaire */
FreeCmpLibrary(this, NewLib->m_Name ); /* Sauvegarde du composant: */
g_LibraryList = LibTmp; CurrentLib = NewLib;
CurrentLib = CurLibTmp; SaveOnePartInMemory();
err = SaveOneLibrary( this, Name, NewLib );
wxString msg;
if ( create_lib && (err == 0) ) /* Suppression de la librarie temporaire */
{ FreeCmpLibrary( this, NewLib->m_Name );
msg = Name + _("0k"); g_LibraryList = LibTmp;
DisplayInfo(this, CurrentLib = CurLibTmp;
_("Note: this new library will be available only if it is loaded by eeschema.\nModify eeschema config if you want use it.") );
} wxString msg;
else msg = _("Error while create ") + Name; if( create_lib && (err == 0) )
Affiche_Message(msg); {
msg = Name + _( "0k" );
DisplayInfo( this,
_("Note: this new library will be available only if it is loaded by eeschema.\nModify eeschema config if you want use it.") );
}
else
msg = _( "Error while create " ) + Name;
Affiche_Message( msg );
} }
...@@ -97,40 +97,22 @@ bool LibDrawSquare::WriteDescr( FILE* ExportFile ) ...@@ -97,40 +97,22 @@ bool LibDrawSquare::WriteDescr( FILE* ExportFile )
bool LibDrawPin::WriteDescr( FILE* ExportFile ) bool LibDrawPin::WriteDescr( FILE* ExportFile )
/************************************************/ /************************************************/
{ {
int Etype = 'I';
wxString StringPinNum; wxString StringPinNum;
int Etype;
switch( m_PinType ) switch( m_PinType )
{ {
case PIN_INPUT: default:
Etype = 'I'; break; case PIN_INPUT: Etype = 'I'; break;
case PIN_OUTPUT: Etype = 'O'; break;
case PIN_OUTPUT: case PIN_BIDI: Etype = 'B'; break;
Etype = 'O'; break; case PIN_TRISTATE: Etype = 'T'; break;
case PIN_PASSIVE: Etype = 'P'; break;
case PIN_BIDI: case PIN_UNSPECIFIED: Etype = 'U'; break;
Etype = 'B'; break; case PIN_POWER_IN: Etype = 'W'; break;
case PIN_POWER_OUT: Etype = 'w'; break;
case PIN_TRISTATE: case PIN_OPENCOLLECTOR: Etype = 'C'; break;
Etype = 'T'; break; case PIN_OPENEMITTER: Etype = 'E'; break;
case PIN_PASSIVE:
Etype = 'P'; break;
case PIN_UNSPECIFIED:
Etype = 'U'; break;
case PIN_POWER_IN:
Etype = 'W'; break;
case PIN_POWER_OUT:
Etype = 'w'; break;
case PIN_OPENCOLLECTOR:
Etype = 'C'; break;
case PIN_OPENEMITTER:
Etype = 'E'; break;
} }
ReturnPinStringNum( StringPinNum ); ReturnPinStringNum( StringPinNum );
...@@ -234,7 +216,7 @@ LibEDA_BaseStruct* CopyDrawEntryStruct( wxWindow* frame, ...@@ -234,7 +216,7 @@ LibEDA_BaseStruct* CopyDrawEntryStruct( wxWindow* frame,
* the new item is only created, it is not put in the current component linked list * the new item is only created, it is not put in the current component linked list
* @param DrawEntry = DrawLibItem * item to duplicate * @param DrawEntry = DrawLibItem * item to duplicate
* @return a pointer to the new item * @return a pointer to the new item
* A better way to duplicate a DrawLibItem is to have a virtual GenCopy() in LibEDA_BaseStruct class (ToDo). * A better way to duplicate a DrawLibItem is to have a virtual GenCopy() in LibEDA_BaseStruct class (ToDo).
*/ */
{ {
LibEDA_BaseStruct* NewDrawItem = NULL; LibEDA_BaseStruct* NewDrawItem = NULL;
...@@ -331,7 +313,7 @@ EDA_LibComponentStruct* CopyLibEntryStruct( wxWindow* frame, EDA_LibComponentStr ...@@ -331,7 +313,7 @@ EDA_LibComponentStruct* CopyLibEntryStruct( wxWindow* frame, EDA_LibComponentStr
{ {
if( ( OldDrawings->m_Flags & IS_NEW) != 0 ) if( ( OldDrawings->m_Flags & IS_NEW) != 0 )
continue; continue;
NewDrawings = CopyDrawEntryStruct( frame, OldDrawings ); NewDrawings = CopyDrawEntryStruct( frame, OldDrawings );
if( NewDrawings ) if( NewDrawings )
{ {
...@@ -345,7 +327,7 @@ EDA_LibComponentStruct* CopyLibEntryStruct( wxWindow* frame, EDA_LibComponentStr ...@@ -345,7 +327,7 @@ EDA_LibComponentStruct* CopyLibEntryStruct( wxWindow* frame, EDA_LibComponentStr
} }
else // Should nevers occurs, just in case... else // Should nevers occurs, just in case...
{ // CopyDrawEntryStruct() was not able to duplicate the type of OldDrawings { // CopyDrawEntryStruct() was not able to duplicate the type of OldDrawings
// occurs when an unexpected type is encountered // occurs when an unexpected type is encountered
DisplayError( frame, wxT( "CopyLibEntryStruct(): error: aborted" ) ); DisplayError( frame, wxT( "CopyLibEntryStruct(): error: aborted" ) );
break; break;
} }
...@@ -543,10 +525,10 @@ int SaveOneLibrary( wxWindow* frame, const wxString& FullFileName, LibraryStruct ...@@ -543,10 +525,10 @@ int SaveOneLibrary( wxWindow* frame, const wxString& FullFileName, LibraryStruct
* 2 fichiers sont crees * 2 fichiers sont crees
* - La librarie * - La librarie
* - le fichier de documentation * - le fichier de documentation
* *
* une sauvegarde .bak de l'ancien fichier librairie est cree * une sauvegarde .bak de l'ancien fichier librairie est cree
* une sauvegarde .bck de l'ancien fichier documentation est cree * une sauvegarde .bck de l'ancien fichier documentation est cree
* *
* return: * return:
* 0 si OK * 0 si OK
* 1 si erreur * 1 si erreur
...@@ -609,7 +591,7 @@ int SaveOneLibrary( wxWindow* frame, const wxString& FullFileName, LibraryStruct ...@@ -609,7 +591,7 @@ int SaveOneLibrary( wxWindow* frame, const wxString& FullFileName, LibraryStruct
Library->m_Modified = 0; Library->m_Modified = 0;
/* Creation de l'entete de la librairie */ /* Creation de l'entete de la librairie */
Library->m_TimeStamp = GetTimeStamp(); Library->m_TimeStamp = GetTimeStamp();
Library->WriteHeader( SaveFile ); Library->WriteHeader( SaveFile );
fprintf( SaveDocFile, "%s Date: %s\n", DOCFILE_IDENT, fprintf( SaveDocFile, "%s Date: %s\n", DOCFILE_IDENT,
DateAndTime( Line ) ); DateAndTime( Line ) );
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* is a base class for any item which can be embedded within the BOARD * is a base class for any item which can be embedded within the BOARD
* container class, and therefore instances of derived classes should only be * container class, and therefore instances of derived classes should only be
* found in PCBNEW or other programs that use class BOARD and its contents. * found in PCBNEW or other programs that use class BOARD and its contents.
* The corresponding class in EESCHEMA seems to be DrawPartStruct. * The corresponding class in EESCHEMA is SCH_ITEM.
*/ */
class BOARD_ITEM : public EDA_BaseStruct class BOARD_ITEM : public EDA_BaseStruct
{ {
......
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