Commit 34909473 authored by charras's avatar charras

eeschema: code cleaning

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