Commit 34909473 authored by charras's avatar charras

eeschema: code cleaning

parent bf688ea1
......@@ -87,14 +87,12 @@ public:
}
/**
* Function SaveLibrary
* writes the data structures for this object out to 2 FILE in "*.lib" and ".dcm" format.
* the main file (.lib) is the library content (set of components)
* the second file (.dcm)is the auxiliary file that contents the keywords and description for components)
* @param FullFileName the new full filename (*.lib).
* Function SaveDoc
* writes the doc info out to a FILE in "*.dcm" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool SaveLibrary( const wxString& FullFileName );
bool SaveDoc( FILE* aFile );
};
......@@ -131,6 +129,14 @@ public:
~EDA_LibComponentStruct();
void SortDrawItems();
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.lib" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
bool Save( FILE* aFile );
};
......
......@@ -18,8 +18,17 @@ void LibDrawPin::Draw( WinEDA_DrawPanel* aPanel, wxDC* aDC, const wxPoint& aOffs
int aDrawMode, void* aData, int aTransformMatrix[2][2] )
/**********************************************************************************************/
{
if( ( m_Attributs & PINNOTDRAW ) && !g_ShowAllPins )
// Invisibles pins are only drawn on request.
// But in libedit they are drawn in g_InvisibleItemColor because we must see them
if( ( m_Attributs & PINNOTDRAW ) )
{
if ( g_EDA_Appl->m_LibeditFrame && g_EDA_Appl->m_LibeditFrame->IsActive() )
aColor = g_InvisibleItemColor;
else if( !g_ShowAllPins )
return;
}
EDA_LibComponentStruct* Entry = ( (DrawPinPrms*) aData )->m_Entry;
bool DrawPinText = ( (DrawPinPrms*) aData )->m_DrawPinText;
......
......@@ -13,11 +13,7 @@
#include "trigo.h"
#include "protos.h"
#define UNVISIBLE_COLOR DARKGRAY
//#define DRAW_ARC_WITH_ANGLE // Used to draw arcs
//#define DRAW_ARC_WITH_ANGLE // Used to select function to draw arcs
/* Local functions */
......@@ -129,7 +125,7 @@ void DrawLibEntry( WinEDA_DrawPanel* panel, wxDC* DC,
if( Color >= 0 )
color = Color;
else
color = UNVISIBLE_COLOR;
color = g_InvisibleItemColor;
}
else color = Color;
......@@ -146,7 +142,7 @@ void DrawLibEntry( WinEDA_DrawPanel* panel, wxDC* DC,
if( Color >= 0 )
color = Color;
else
color = UNVISIBLE_COLOR;
color = g_InvisibleItemColor;
}
else color = Color;
......@@ -164,7 +160,7 @@ void DrawLibEntry( WinEDA_DrawPanel* panel, wxDC* DC,
if( Color >= 0 )
color = Color;
else
color = UNVISIBLE_COLOR;
color = g_InvisibleItemColor;
}
else color = Color;
Field->Draw( panel, DC, aOffset, color, DrawMode, NULL, TransMat );
......
/***************************************/
/* GENERAL.H : declarations communes */
/***************************************/
/***************************************/
/* GENERAL.H : declarations communes */
/***************************************/
#ifndef _GENERAL_H_
#define _GENERAL_H_
......@@ -23,7 +23,7 @@
#define MAX_PIN_INFO 10
#define TXTMARGE 10 /* Decalage (en 1/1000") des textes places
sur fils ( labels, num pins ) */
* sur fils ( labels, num pins ) */
#define HIGHLIGHT_COLOR WHITE
......@@ -43,7 +43,7 @@
extern wxString g_Main_Title;
eda_global wxString g_DefaultSchematicFileName
#ifdef MAIN
(wxT("noname.sch"))
( wxT( "noname.sch" ) )
#endif
;
......@@ -65,9 +65,9 @@ eda_global wxString g_DefaultSchematicFileName
#define EXCLUDE_WIRE_BUS_ENDPOINTS 0x4000
#define WIRE_BUS_ENDPOINTS_ONLY 0x8000
#define SEARCHALL LIBITEM|WIREITEM|BUSITEM|RACCORDITEM|JUNCTIONITEM\
|DRAWITEM|TEXTITEM|LABELITEM|SHEETITEM|MARKERITEM\
|NOCONNECTITEM|SEARCH_PINITEM|SHEETLABELITEM
#define SEARCHALL LIBITEM | WIREITEM | BUSITEM | RACCORDITEM | JUNCTIONITEM \
| DRAWITEM | TEXTITEM | LABELITEM | SHEETITEM | MARKERITEM \
| NOCONNECTITEM | SEARCH_PINITEM | SHEETLABELITEM
/* Numero des couches de travail */
typedef enum {
......@@ -97,7 +97,7 @@ typedef enum {
LAYER_DEVICE_BACKGROUND,
MAX_LAYER /* Nombre de couches */
} LayerNumber;
} LayerNumber;
typedef enum {
FILE_SAVE_AS,
......@@ -106,43 +106,45 @@ typedef enum {
eda_global wxSize g_GridList[]
#ifdef MAIN
= {
wxSize(50,50), wxSize(20,20), wxSize(10,10),
wxSize(-1,-1), wxSize(0,0)
= {
wxSize( 50, 50 ), wxSize( 20, 20 ), wxSize( 10, 10 ),
wxSize( -1, -1 ), wxSize( 0, 0 )
}
#endif
;
/* variables generales */
eda_global wxArrayString g_LibName_List; // library list (short filenames) to load
eda_global LibraryStruct *g_LibraryList; // All part libs are saved here.
eda_global LibraryStruct* g_LibraryList; // All part libs are saved here.
eda_global int g_NetFormat; /* Numero de reference du type de netliste */
eda_global int g_OptNetListUseNames; /* TRUE pour utiliser les noms de net plutot que
les numeros (netlist PSPICE seulement) */
* les numeros (netlist PSPICE seulement) */
eda_global int g_BGColor; /* couleur fond d'ecran (normalement blanc) */
eda_global SCH_ITEM * g_ItemToRepeat; /* pointeur sur la derniere structure
dessinee pouvant etre dupliquee par la commande
Repeat ( NULL si aucune struct existe ) */
eda_global SCH_ITEM* g_ItemToRepeat; /* pointeur sur la derniere structure
* dessinee pouvant etre dupliquee par la commande
* Repeat ( NULL si aucune struct existe ) */
eda_global wxSize g_RepeatStep;
eda_global int g_RepeatDeltaLabel;
eda_global SCH_ITEM * g_ItemToUndoCopy; /* copy of last modified schematic item
before it is modified (used for undo managing to restore old values ) */
eda_global SCH_ITEM* g_ItemToUndoCopy; /* copy of last modified schematic item
* before it is modified (used for undo managing to restore old values ) */
eda_global bool g_LastSearchIsMarker; // True if last seach is a marker serach
// False for a schematic item search
// Used for hotkey next search
/* Block operation (copy, paste) */
eda_global SCH_ITEM * g_BlockSaveDataList; // List of items to paste (Created by Block Save)
eda_global SCH_ITEM* g_BlockSaveDataList; // List of items to paste (Created by Block Save)
// Gestion d'options
eda_global int g_ShowAllPins;
eda_global int g_ShowGrid; // Bool: display grid
#ifdef MAIN
wxSize g_User_Grid(50,50);
wxSize g_User_Grid( 50, 50 );
int g_HVLines = 1; // Bool: force H or V directions (Wires, Bus ..)
#else
extern wxSize g_User_Grid;
......@@ -152,7 +154,7 @@ extern int g_HVLines;
eda_global int g_PlotPSColorOpt; // True = plot postcript color (see plotps.cpp)
// Gestion de diverses variables, options... devant etre m�moris�es mais
// Gestion de diverses variables, options... devant etre memorisees mais
// Remises a 0 lors d'un rechargement de projetc
struct EESchemaVariables
{
......@@ -166,7 +168,7 @@ eda_global struct EESchemaVariables g_EESchemaVar;
eda_global wxString g_CurrentViewLibraryName; /* nom de la librairie en cours d'examen */
eda_global wxString g_CurrentViewComponentName; /* nom du le composant en cours d'examen */
eda_global int g_ViewConvert; /* Vue normal / convert */
eda_global int g_ViewUnit; /* unit� a afficher (A, B ..) */
eda_global int g_ViewUnit; /* part a afficher (A, B ..) */
/* Variables globales pour Schematic Edit */
eda_global int g_DefaultTextLabelSize
......@@ -198,18 +200,17 @@ eda_global bool g_FlDrawSpecificConvert
#endif
;
/********************************************************/
/* Description des structures des parametres principaux */
/********************************************************/
/********************************************************/
/* Description des structures des parametres principaux */
/********************************************************/
/* Gestion des trace sur table tracante */
/* Gestion des trace sur table tracante */
eda_global int g_PlotFormat; /* flag = TYPE_HPGL, TYPE_PS... */
eda_global int g_PlotMargin; /* Marge pour traces du cartouche */
eda_global float g_PlotScaleX, g_PlotScaleY; /* coeff d'echelle de trace en unites table tracante */
/* For HPGL plotting: Pen caract : */
struct HPGL_Pen_Descr_Struct
{
......@@ -220,16 +221,17 @@ struct HPGL_Pen_Descr_Struct
eda_global HPGL_Pen_Descr_Struct g_HPGL_Pen_Descr;
/* Ecrans usuels */
//eda_global SCH_SCREEN * ScreenSch;
eda_global DrawSheetStruct* g_RootSheet;
eda_global SCH_SCREEN * ScreenLib;
eda_global SCH_SCREEN* g_ScreenLib;
/*************************************/
/* Gestion de recherche des elements */
/*************************************/
/*************************************/
/* Gestion de recherche des elements */
/*************************************/
/* valeur de flag indicant si le pointeur de reference pour une localisation
est le curseur sur grille ou le curseur a deplacement fin hors grille */
* est le curseur sur grille ou le curseur a deplacement fin hors grille */
#define CURSEUR_ON_GRILLE 0
#define CURSEUR_OFF_GRILLE 1
......@@ -237,11 +239,11 @@ est le curseur sur grille ou le curseur a deplacement fin hors grille */
eda_global wxString g_NetNameBuffer;
#ifdef MAIN
wxString g_NetCmpExtBuffer( wxT(".cmp") );
wxString g_SymbolExtBuffer( wxT(".sym") );
wxString g_NetExtBuffer( wxT(".net") );
wxString g_SchExtBuffer( wxT(".sch") );
wxString g_LibExtBuffer( wxT(".lib") );
wxString g_NetCmpExtBuffer( wxT( ".cmp" ) );
wxString g_SymbolExtBuffer( wxT( ".sym" ) );
wxString g_NetExtBuffer( wxT( ".net" ) );
wxString g_SchExtBuffer( wxT( ".sch" ) );
wxString g_LibExtBuffer( wxT( ".lib" ) );
#else
eda_global wxString g_NetCmpExtBuffer;
eda_global wxString g_SymbolExtBuffer;
......@@ -257,7 +259,7 @@ eda_global LayerStruct g_LayerDescr; /* couleurs des couches */
eda_global bool g_EditPinByPinIsOn /* bool: TRUE si edition des pins pin a pin au lieu */
#ifdef MAIN /* de l'edition simultanee des pins de meme coordonnees */
= FALSE
= FALSE
#endif
;
......@@ -267,13 +269,18 @@ eda_global int g_PlotPSMinimunLineWidth; /* Minimum line (in EESCHEMA units) wid
eda_global int g_ItemSelectetColor // Color to draw selected items
#ifdef MAIN
= BROWN
= BROWN
#endif
;
eda_global int g_InvisibleItemColor // Color to draw items flagged invisible, in libedit (they are insisible in eeschema
#ifdef MAIN
= DARKGRAY
#endif
;
/* Config keys */
#define MINI_DRAW_LINE_WIDTH_KEY wxT("MinimunDrawLineWidth")
#define MINI_PLOTPS_LINE_WIDTH_KEY wxT("MinimunPlotPSLineWidth")
#define MINI_DRAW_LINE_WIDTH_KEY wxT( "MinimunDrawLineWidth" )
#define MINI_PLOTPS_LINE_WIDTH_KEY wxT( "MinimunPlotPSLineWidth" )
#endif // _GENERAL_H_
......@@ -60,7 +60,7 @@ const wxChar * Text;
{
Text = List[ii].m_Comp->m_ChipName.GetData();
Entry = FindLibPart(Text, wxEmptyString, FIND_ROOT);
ListEntry[ii] = Entry; // = NULL si Composant non trouv� en librairie
ListEntry[ii] = Entry; // = NULL component not found
}
MyFree(List);
......@@ -90,21 +90,22 @@ const wxChar * Text;
if( DocFile)
fprintf(DocFile,"%s %s\n", DOCFILE_IDENT, DateAndTime(Line));
/* Generation des elements */
/* Save components in file */
for ( ii = 0; ii < NbItems; ii++ )
{
if ( ListEntry[ii] == NULL ) // Composant non trouv� en librairie
if ( ListEntry[ii] == NULL ) // Not found in lib
{
continue;
}
if ( (ii == 0) || ( ListEntry[ii-1] != ListEntry[ii] ) )
{
WriteOneLibEntry(ArchiveFile, ListEntry[ii]);
if( DocFile ) WriteOneDocLibEntry(DocFile, ListEntry[ii]);
if ( ListEntry[ii]->Type == ROOT) // Must be always true, but just in case
ListEntry[ii]->Save(ArchiveFile);
if( DocFile )
ListEntry[ii]->SaveDoc(DocFile);
}
}
/* Generation fin de fichier */
fprintf(ArchiveFile,"#\n#EndLibrary\n");
fclose(ArchiveFile);
......
......@@ -85,7 +85,7 @@ wxString msg;
wxString CmpName;
EDA_LibComponentStruct *LibEntry = NULL;
if( ScreenLib->IsModify() )
if( g_ScreenLib->IsModify() )
{
if( ! IsOK(this, _("Current Part not saved.\nContinue?") ) ) return FALSE;
}
......@@ -96,7 +96,7 @@ EDA_LibComponentStruct *LibEntry = NULL;
i = GetNameOfPartToLoad(this, CurrentLib, CmpName);
if( i == 0) return FALSE;
ScreenLib->ClrModify();
g_ScreenLib->ClrModify();
CurrentDrawItem = NULL;
// Effacement ancien composant affich�
if( CurrentLibEntry)
......@@ -166,7 +166,7 @@ const wxChar * CmpName, *RootName = NULL;
BuildAliasData(Library, CurrentLibEntry);
ScreenLib->ClrModify();
g_ScreenLib->ClrModify();
g_AsDeMorgan = 0;
if( LookForConvertPart(CurrentLibEntry) > 1 ) g_AsDeMorgan = 1;
......@@ -564,7 +564,7 @@ bool NewCmp = TRUE;
}
CurrentLib->m_Modified = 1;
ScreenLib->ClrModify();
g_ScreenLib->ClrModify();
PQCompFunc((PQCompFuncType) LibraryEntryCompare);
......
......@@ -71,7 +71,7 @@ WinEDA_LibeditFrame::WinEDA_LibeditFrame( wxWindow* father,
// Give an icon
SetIcon( wxIcon( libedit_xpm ) );
SetBaseScreen( ScreenLib );
SetBaseScreen( g_ScreenLib );
GetSettings();
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
if( DrawPanel )
......
......@@ -59,10 +59,6 @@ void DrawLibraryDrawStruct(WinEDA_DrawPanel * aPanel, wxDC * aDC,
bool MapAngles(int *Angle1, int *Angle2, int TransMat[2][2]);
/**************/
/* EELIBS_DRAW_COMPONENTS.CPP */
/**************/
EDA_LibComponentStruct * Read_Component_Definition(WinEDA_DrawFrame * frame, char * Line,
FILE *f, int *LineNum);
/* Routine to Read a DEF/ENDDEF part entry from given open file. */
......@@ -229,22 +225,12 @@ LibEDA_BaseStruct * CopyDrawEntryStruct( wxWindow * frame, LibEDA_BaseStruct * D
Retourne:
Pointeur sur la structure creee (ou NULL si impossible) */
int WriteOneLibEntry( FILE * ExportFile, EDA_LibComponentStruct * LibEntry);
/* Routine d'ecriture du composant pointe par LibEntry
dans le fichier ExportFile( qui doit etre deja ouvert)
return: FALSE si Ok, TRUE si err write */
EDA_LibComponentStruct * CopyLibEntryStruct (wxWindow * frame, EDA_LibComponentStruct * OldEntry);
/* Routine de copie d'une partlib
Parametres d'entree: pointeur sur la structure de depart
Parametres de sortie: pointeur sur la structure creee */
int WriteOneDocLibEntry(FILE * ExportFile, EDA_LibComponentStruct * LibEntry);
/* Routine d'ecriture de la doc du composant pointe par LibEntry
dans le fichier ExportFile( qui doit etre deja ouvert)
return: 0 si Ok
1 si err write */
/***************/
/* SYMBEDIT.CPP */
......@@ -254,11 +240,6 @@ void SuppressDuplicateDrawItem(EDA_LibComponentStruct * LibEntry);
frequente lorsque l'on charge des symboles predessines plusieurs fois
pour definir un composant */
/***************/
/* SYMBTEXT.CPP */
/***************/
/**************/
/* NETLIST.CPP */
/**************/
......
......@@ -2,7 +2,7 @@
/* EESchema - eesavlib.cpp */
/****************************/
/* Write Routines to save schematic libraries and library components (::Save() members)
/* Functions to save schematic libraries and library components (::Save() members)
*/
#include "fctsys.h"
......@@ -350,137 +350,132 @@ EDA_LibComponentStruct* CopyLibEntryStruct( wxWindow* frame, EDA_LibComponentStr
return NewStruct;
}
/*************************************************************************/
int WriteOneLibEntry( FILE* ExportFile, EDA_LibComponentStruct* LibEntry )
/*************************************************************************/
/* Routine d'ecriture du composant pointe par LibEntry
* dans le fichier ExportFile( qui doit etre deja ouvert)
* return: 0 si Ok
* -1 si err write
* 1 si composant non ecrit ( type ALIAS )
/************************************************/
bool EDA_LibComponentStruct::Save( FILE* aFile )
/***********************************************/
/**
* Function Save
* writes the data structures for this object out to a FILE in "*.brd" format.
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
#define UNUSED 0
{
LibEDA_BaseStruct* DrawEntry;
LibDrawField* Field;
if( LibEntry->Type != ROOT )
return 1;
if( Type != ROOT ) // should not happen, but just in case
return false;
/* Creation du commentaire donnant le nom du composant */
fprintf( ExportFile, "#\n# %s\n#\n", CONV_TO_UTF8( LibEntry->m_Name.m_Text ) );
/* First line: it s a comment (component name for readers) */
fprintf( aFile, "#\n# %s\n#\n", CONV_TO_UTF8( m_Name.m_Text ) );
/* Generation des lignes utiles */
fprintf( ExportFile, "DEF" );
if( (LibEntry->m_Name.m_Attributs & TEXT_NO_VISIBLE) == 0 )
fprintf( ExportFile, " %s", CONV_TO_UTF8( LibEntry->m_Name.m_Text ) );
/* Save data */
fprintf( aFile, "DEF" );
if( (m_Name.m_Attributs & TEXT_NO_VISIBLE) == 0 )
fprintf( aFile, " %s", CONV_TO_UTF8( m_Name.m_Text ) );
else
fprintf( ExportFile, " ~%s", CONV_TO_UTF8( LibEntry->m_Name.m_Text ) );
fprintf( aFile, " ~%s", CONV_TO_UTF8( m_Name.m_Text ) );
if( !LibEntry->m_Prefix.m_Text.IsEmpty() )
fprintf( ExportFile, " %s", CONV_TO_UTF8( LibEntry->m_Prefix.m_Text ) );
if( !m_Prefix.m_Text.IsEmpty() )
fprintf( aFile, " %s", CONV_TO_UTF8( m_Prefix.m_Text ) );
else
fprintf( ExportFile, " ~" );
fprintf( ExportFile, " %d %d %c %c %d %c %c\n",
UNUSED, LibEntry->m_TextInside,
LibEntry->m_DrawPinNum ? 'Y' : 'N',
LibEntry->m_DrawPinName ? 'Y' : 'N',
LibEntry->m_UnitCount, LibEntry->m_UnitSelectionLocked ? 'L' : 'F',
LibEntry->m_Options == ENTRY_POWER ? 'P' : 'N' );
fprintf( aFile, " ~" );
fprintf( aFile, " %d %d %c %c %d %c %c\n",
UNUSED, m_TextInside,
m_DrawPinNum ? 'Y' : 'N',
m_DrawPinName ? 'Y' : 'N',
m_UnitCount, m_UnitSelectionLocked ? 'L' : 'F',
m_Options == ENTRY_POWER ? 'P' : 'N' );
WriteLibEntryDateAndTime( ExportFile, LibEntry );
WriteLibEntryDateAndTime( aFile, this );
/* Position / orientation / visibilite des champs */
LibEntry->m_Prefix.Save( ExportFile );
LibEntry->m_Name.Save( ExportFile );
/* Save fields */
m_Prefix.Save( aFile );
m_Name.Save( aFile );
for( Field = LibEntry->Fields; Field!= NULL;
for( Field = Fields; Field!= NULL;
Field = (LibDrawField*) Field->Pnext )
{
if( Field->m_Text.IsEmpty() && Field->m_Name.IsEmpty() )
continue;
Field->Save( ExportFile );
Field->Save( aFile );
}
/* Sauvegarde de la ligne "ALIAS" */
if( LibEntry->m_AliasList.GetCount() != 0 )
/* Save the alias list: a line starting by "ALIAS" */
if( m_AliasList.GetCount() != 0 )
{
fprintf( ExportFile, "ALIAS" );
fprintf( aFile, "ALIAS" );
unsigned ii;
for( ii = 0; ii < LibEntry->m_AliasList.GetCount(); ii++ )
fprintf( ExportFile, " %s", CONV_TO_UTF8( LibEntry->m_AliasList[ii] ) );
for( ii = 0; ii < m_AliasList.GetCount(); ii++ )
fprintf( aFile, " %s", CONV_TO_UTF8( m_AliasList[ii] ) );
fprintf( ExportFile, "\n" );
fprintf( aFile, "\n" );
}
/* Write the footprint filter list */
if( LibEntry->m_FootprintList.GetCount() != 0 )
if( m_FootprintList.GetCount() != 0 )
{
fprintf( ExportFile, "$FPLIST\n" );
fprintf( aFile, "$FPLIST\n" );
unsigned ii;
for( ii = 0; ii < LibEntry->m_FootprintList.GetCount(); ii++ )
fprintf( ExportFile, " %s\n", CONV_TO_UTF8( LibEntry->m_FootprintList[ii] ) );
for( ii = 0; ii < m_FootprintList.GetCount(); ii++ )
fprintf( aFile, " %s\n", CONV_TO_UTF8( m_FootprintList[ii] ) );
fprintf( ExportFile, "$ENDFPLIST\n" );
fprintf( aFile, "$ENDFPLIST\n" );
}
/* Sauvegarde des elements de trace */
DrawEntry = LibEntry->m_Drawings;
if( LibEntry->m_Drawings )
/* Save graphics items (including pins) */
if( m_Drawings )
{
/* we sort the draw items, in order to have an edition more easy,
* when a file editing "by hand" is made */
LibEntry->SortDrawItems();
SortDrawItems();
fprintf( ExportFile, "DRAW\n" );
DrawEntry = LibEntry->m_Drawings;
fprintf( aFile, "DRAW\n" );
DrawEntry = m_Drawings;
while( DrawEntry )
{
DrawEntry->Save( ExportFile );
DrawEntry->Save( aFile );
DrawEntry = DrawEntry->Next();
}
fprintf( ExportFile, "ENDDRAW\n" );
fprintf( aFile, "ENDDRAW\n" );
}
fprintf( ExportFile, "ENDDEF\n" );
fprintf( aFile, "ENDDEF\n" );
return 0;
return true;
}
/*************************************************************************/
int WriteOneDocLibEntry( FILE* ExportFile, EDA_LibComponentStruct* LibEntry )
/*************************************************************************/
/* Routine d'ecriture de la doc du composant pointe par LibEntry
* dans le fichier ExportFile( qui doit etre deja ouvert)
* return: 0 si Ok
* 1 si err write
* Cependant, si i tous les Pointeurs sur textes sont nulls ( pas de Doc )
* rien ne sera ecrit.
/***************************************/
bool LibCmpEntry::SaveDoc( FILE* aFile )
/***************************************/
/**
* Function SaveDoc
* writes the doc info out to a FILE in "*.dcm" format.
* Only non empty fields are written.
* If all fielsd are empty, does not write anything
* @param aFile The FILE to write to.
* @return bool - true if success writing else false.
*/
{
if( ( LibEntry->m_Doc.IsEmpty() )
&& ( LibEntry->m_KeyWord.IsEmpty() )
&& ( LibEntry->m_DocFile.IsEmpty() ) )
return 0;
if( m_Doc.IsEmpty() && m_KeyWord.IsEmpty() && m_DocFile.IsEmpty() )
return true;
/* Generation des lignes utiles */
fprintf( ExportFile, "#\n$CMP %s\n", CONV_TO_UTF8( LibEntry->m_Name.m_Text ) );
fprintf( aFile, "#\n$CMP %s\n", CONV_TO_UTF8( m_Name.m_Text ) );
if( !LibEntry->m_Doc.IsEmpty() )
fprintf( ExportFile, "D %s\n", CONV_TO_UTF8( LibEntry->m_Doc ) );
if( ! m_Doc.IsEmpty() )
fprintf( aFile, "D %s\n", CONV_TO_UTF8( m_Doc ) );
if( !LibEntry->m_KeyWord.IsEmpty() )
fprintf( ExportFile, "K %s\n", CONV_TO_UTF8( LibEntry->m_KeyWord ) );
if( ! m_KeyWord.IsEmpty() )
fprintf( aFile, "K %s\n", CONV_TO_UTF8( m_KeyWord ) );
if( !LibEntry->m_DocFile.IsEmpty() )
fprintf( ExportFile, "F %s\n", CONV_TO_UTF8( LibEntry->m_DocFile ) );
if( ! m_DocFile.IsEmpty() )
fprintf( aFile, "F %s\n", CONV_TO_UTF8( m_DocFile ) );
fprintf( ExportFile, "$ENDCMP\n" );
return 0;
fprintf( aFile, "$ENDCMP\n" );
return true;
}
......@@ -560,11 +555,16 @@ bool LibraryStruct::SaveLibrary( const wxString& FullFileName )
bool success = true;
while( LibEntry )
{
if ( WriteOneLibEntry( libfile, LibEntry ) != 0 )
if ( LibEntry->Type == ROOT )
{
if ( ! LibEntry->Save( libfile ) )
success = false;
}
if ( docfile )
if ( WriteOneDocLibEntry( docfile, LibEntry ) != 0 )
{
if ( ! LibEntry->SaveDoc( docfile ) )
success = false;
}
LibEntry = (EDA_LibComponentStruct*)
PQNext( m_Entries, LibEntry, NULL );
......
......@@ -275,10 +275,10 @@ void WinEDA_SchematicFrame::CreateScreens()
m_CurrentSheet->Clear();
m_CurrentSheet->Push( g_RootSheet );
if( ScreenLib == NULL )
ScreenLib = new SCH_SCREEN( LIBEDITOR_FRAME );
ScreenLib->SetZoom( 4 );
ScreenLib->m_UndoRedoCountMax = 10;
if( g_ScreenLib == NULL )
g_ScreenLib = new SCH_SCREEN( LIBEDITOR_FRAME );
g_ScreenLib->SetZoom( 4 );
g_ScreenLib->m_UndoRedoCountMax = 10;
}
......@@ -356,9 +356,7 @@ void WinEDA_SchematicFrame::OnCloseWindow( wxCloseEvent& Event )
/*****************************************************************************
*
* Enable or disable some tools according to current conditions
*
*****************************************************************************/
void WinEDA_SchematicFrame::SetToolbars()
{
......@@ -451,21 +449,27 @@ int WinEDA_SchematicFrame::BestZoom()
return bestzoom;
}
/**************************************************************/
void WinEDA_SchematicFrame::OnAnnotate( wxCommandEvent& event )
/**************************************************************/
{
WinEDA_AnnotateFrame* dlg = new WinEDA_AnnotateFrame( this );
dlg->ShowModal();
dlg->Destroy();
}
/*********************************************************/
void WinEDA_SchematicFrame::OnErc( wxCommandEvent& event )
/*********************************************************/
{
WinEDA_ErcFrame* dlg = new WinEDA_ErcFrame( this );
dlg->ShowModal();
dlg->Destroy();
}
/*******************************************************************/
void WinEDA_SchematicFrame::OnCreateNetlist( wxCommandEvent& event )
/*******************************************************************/
{
int i;
......@@ -481,14 +485,18 @@ void WinEDA_SchematicFrame::OnCreateNetlist( wxCommandEvent& event )
// If a plugin is removed or added, rebuild and reopen the new dialog
}
/**********************************************************************/
void WinEDA_SchematicFrame::OnCreateBillOfMaterials( wxCommandEvent & )
/**********************************************************************/
{
WinEDA_Build_BOM_Frame* dlg = new WinEDA_Build_BOM_Frame( this );
dlg->ShowModal();
dlg->Destroy();
}
/*******************************************************************/
void WinEDA_SchematicFrame::OnFindItems( wxCommandEvent& event )
/*******************************************************************/
{
this->DrawPanel->m_IgnoreMouseEvents = TRUE;
WinEDA_FindFrame* dlg = new WinEDA_FindFrame( this );
......@@ -497,7 +505,9 @@ void WinEDA_SchematicFrame::OnFindItems( wxCommandEvent& event )
this->DrawPanel->m_IgnoreMouseEvents = FALSE;
}
/***************************************************************/
void WinEDA_SchematicFrame::OnLoadFile( wxCommandEvent& event )
/***************************************************************/
{
int i = event.GetId() - ID_LOAD_FILE_1;
......@@ -505,23 +515,31 @@ void WinEDA_SchematicFrame::OnLoadFile( wxCommandEvent& event )
SetToolbars();
}
/*******************************************************************/
void WinEDA_SchematicFrame::OnLoadStuffFile( wxCommandEvent& event )
/*******************************************************************/
{
ReadInputStuffFile( );
DrawPanel->Refresh();
}
/****************************************************************/
void WinEDA_SchematicFrame::OnNewProject( wxCommandEvent& event )
/****************************************************************/
{
LoadOneEEProject( wxEmptyString, true );
}
/*****************************************************************/
void WinEDA_SchematicFrame::OnLoadProject( wxCommandEvent& event )
/*****************************************************************/
{
LoadOneEEProject( wxEmptyString, false );
}
/****************************************************************/
void WinEDA_SchematicFrame::OnOpenPcbnew( wxCommandEvent& event )
/****************************************************************/
{
wxString Line = g_RootSheet->m_AssociatedScreen->m_FileName;
......@@ -535,7 +553,9 @@ void WinEDA_SchematicFrame::OnOpenPcbnew( wxCommandEvent& event )
ExecuteFile( this, PCBNEW_EXE );
}
/***************************************************************/
void WinEDA_SchematicFrame::OnOpenCvpcb( wxCommandEvent& event )
/***************************************************************/
{
wxString Line = g_RootSheet->m_AssociatedScreen->m_FileName;
......@@ -549,7 +569,9 @@ void WinEDA_SchematicFrame::OnOpenCvpcb( wxCommandEvent& event )
ExecuteFile( this, CVPCB_EXE );
}
/*************************************************************************/
void WinEDA_SchematicFrame::OnOpenLibraryViewer( wxCommandEvent& event )
/*************************************************************************/
{
if( m_Parent->m_ViewlibFrame )
{
......@@ -564,7 +586,9 @@ void WinEDA_SchematicFrame::OnOpenLibraryViewer( wxCommandEvent& event )
}
}
/*************************************************************************/
void WinEDA_SchematicFrame::OnOpenLibraryEditor( wxCommandEvent& event )
/*************************************************************************/
{
if( m_Parent->m_LibeditFrame )
{
......@@ -578,7 +602,7 @@ void WinEDA_SchematicFrame::OnOpenLibraryEditor( wxCommandEvent& event )
wxT( "Library Editor" ),
wxPoint( -1, -1 ),
wxSize( 600, 400 ) );
ActiveScreen = ScreenLib;
ActiveScreen = g_ScreenLib;
m_Parent->m_LibeditFrame->AdjustScrollBars();
}
}
......
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