Commit aa51c05d authored by stambaughw's avatar stambaughw

CVPcb code refactoring, global variable elimination, and UI updates.

* Add methods to read and write project file parameters using dynamically defined list.
* Remove all global variables defined in CVPcb code.
* Dynamically define project file settings so class member variables can be used.
* Separate reading and writing application settings from project file settings.
* Make application UI objects and dialogs respect system UI font.
* Remove non-standard widget colors from CVPcb dialogs.
* Changed CVPcb object link list implementation to use wxList.
* Changed project library and path dialog to make OK button save project file instead of confusing "Save Cfg" button.
* Eliminate some duplicate file wildcard and extension definitions.
* The usual code reformatting, commenting, and spelling fixes.
parent bd3b4baa
...@@ -53,6 +53,7 @@ const wxString SchematicFileExtension( wxT( "sch" ) ); ...@@ -53,6 +53,7 @@ const wxString SchematicFileExtension( wxT( "sch" ) );
const wxString BoardFileExtension( wxT( "brd" ) ); const wxString BoardFileExtension( wxT( "brd" ) );
const wxString NetlistFileExtension( wxT( "net" ) ); const wxString NetlistFileExtension( wxT( "net" ) );
const wxString GerberFileExtension( wxT( "pho" ) ); const wxString GerberFileExtension( wxT( "pho" ) );
const wxString PdfFileExtension( wxT( "pdf" ) );
/* Proper wxFileDialog wild card definitions. */ /* Proper wxFileDialog wild card definitions. */
const wxString ProjectFileWildcard( _( "Kicad project files (*.pro)|*.pro" ) ); const wxString ProjectFileWildcard( _( "Kicad project files (*.pro)|*.pro" ) );
...@@ -60,6 +61,7 @@ const wxString BoardFileWildcard( _( "Kicad PCB files (*.brd)|*.brd") ); ...@@ -60,6 +61,7 @@ const wxString BoardFileWildcard( _( "Kicad PCB files (*.brd)|*.brd") );
const wxString SchematicFileWildcard( _( "Kicad schematic files (*.sch)|*.sch" ) ); const wxString SchematicFileWildcard( _( "Kicad schematic files (*.sch)|*.sch" ) );
const wxString NetlistFileWildcard( _( "Kicad netlist files (*.net)|*.net" ) ); const wxString NetlistFileWildcard( _( "Kicad netlist files (*.net)|*.net" ) );
const wxString GerberFileWildcard( _( "Gerber files (*.pho)|*.pho" ) ); const wxString GerberFileWildcard( _( "Gerber files (*.pho)|*.pho" ) );
const wxString PdfFileWildcard( _( "Portable document format files (*.pdf)|*.pdf" ) );
const wxString AllFilesWildcard( _( "All files (*)|*") ); const wxString AllFilesWildcard( _( "All files (*)|*") );
......
...@@ -149,7 +149,7 @@ bool GetAssociatedDocument( wxFrame* aFrame, ...@@ -149,7 +149,7 @@ bool GetAssociatedDocument( wxFrame* aFrame,
if( !wxFileExists( fullfilename ) ) if( !wxFileExists( fullfilename ) )
{ {
msg = _( "Doc File " ); msg = _( "Doc File " );
msg << wxT("\"") << fullfilename << wxT("\"") << _( " not found" ); msg << wxT("\"") << aDocName << wxT("\"") << _( " not found" );
DisplayError( aFrame, msg ); DisplayError( aFrame, msg );
return FALSE; return FALSE;
} }
......
...@@ -179,6 +179,62 @@ void WinEDA_App::WriteProjectConfig( const wxString& fileName, ...@@ -179,6 +179,62 @@ void WinEDA_App::WriteProjectConfig( const wxString& fileName,
m_ProjectConfig = NULL; m_ProjectConfig = NULL;
} }
void WinEDA_App::WriteProjectConfig( const wxString& fileName,
const wxString& GroupName,
const PARAM_CFG_ARRAY& params )
{
PARAM_CFG_BASE* param;
wxString msg;
size_t i;
ReCreatePrjConfig( fileName, GroupName, FORCE_LOCAL_CONFIG );
/* Write date ( surtout pour eviter bug de wxFileConfig
* qui se trompe de rubrique si declaration [xx] en premiere ligne
* (en fait si groupe vide) */
m_ProjectConfig->SetPath( wxCONFIG_PATH_SEPARATOR );
msg = DateAndTime();
m_ProjectConfig->Write( wxT( "update" ), msg );
msg = GetAppName();
m_ProjectConfig->Write( wxT( "last_client" ), msg );
/* Save parameters */
m_ProjectConfig->DeleteGroup( GroupName ); // Erase all datas
m_ProjectConfig->Flush();
m_ProjectConfig->SetPath( GroupName );
m_ProjectConfig->Write( wxT( "version" ), CONFIG_VERSION );
m_ProjectConfig->SetPath( wxCONFIG_PATH_SEPARATOR );
for( i = 0; i < params.GetCount(); i++ )
{
param = &params[i];
if( param->m_Group )
m_ProjectConfig->SetPath( param->m_Group );
else
m_ProjectConfig->SetPath( GroupName );
if( param->m_Setup )
continue;
if ( param->m_Type == PARAM_COMMAND_ERASE ) // Erase all data
{
if( param->m_Ident )
m_ProjectConfig->DeleteGroup( param->m_Ident );
}
else
param->SaveParam( m_ProjectConfig );
}
m_ProjectConfig->SetPath( UNIX_STRING_DIR_SEP );
delete m_ProjectConfig;
m_ProjectConfig = NULL;
}
/*****************************************************************/ /*****************************************************************/
void WinEDA_App::SaveCurrentSetupValues( PARAM_CFG_BASE** aList ) void WinEDA_App::SaveCurrentSetupValues( PARAM_CFG_BASE** aList )
/*****************************************************************/ /*****************************************************************/
...@@ -277,6 +333,60 @@ bool WinEDA_App::ReadProjectConfig( const wxString& local_config_filename, ...@@ -277,6 +333,60 @@ bool WinEDA_App::ReadProjectConfig( const wxString& local_config_filename,
} }
bool WinEDA_App::ReadProjectConfig( const wxString& local_config_filename,
const wxString& GroupName,
const PARAM_CFG_ARRAY& params,
bool Load_Only_if_New )
{
size_t i;
PARAM_CFG_BASE* param;
wxString timestamp;
ReCreatePrjConfig( local_config_filename, GroupName, false );
m_ProjectConfig->SetPath( wxCONFIG_PATH_SEPARATOR );
timestamp = m_ProjectConfig->Read( wxT( "update" ) );
if( Load_Only_if_New && ( !timestamp.IsEmpty() )
&& (timestamp == m_CurrentOptionFileDateAndTime) )
{
return false;
}
m_CurrentOptionFileDateAndTime = timestamp;
if( !g_Prj_Default_Config_FullFilename.IsEmpty() )
m_CurrentOptionFile = g_Prj_Default_Config_FullFilename;
else
{
if( wxPathOnly( g_Prj_Config_LocalFilename ).IsEmpty() )
m_CurrentOptionFile = wxGetCwd() + STRING_DIR_SEP +
g_Prj_Config_LocalFilename;
else
m_CurrentOptionFile = g_Prj_Config_LocalFilename;
}
for( i = 0; i < params.GetCount(); i++ )
{
param = &params[i];
if( param->m_Group )
m_ProjectConfig->SetPath( param->m_Group );
else
m_ProjectConfig->SetPath( GroupName );
if( param->m_Setup )
continue;
param->ReadParam( m_ProjectConfig );
}
delete m_ProjectConfig;
m_ProjectConfig = NULL;
return true;
}
/***************************************************************/ /***************************************************************/
void WinEDA_App::ReadCurrentSetupValues( PARAM_CFG_BASE** aList ) void WinEDA_App::ReadCurrentSetupValues( PARAM_CFG_BASE** aList )
/***************************************************************/ /***************************************************************/
......
...@@ -26,7 +26,6 @@ WinEDA_EnterText::WinEDA_EnterText( wxWindow* parent, ...@@ -26,7 +26,6 @@ WinEDA_EnterText::WinEDA_EnterText( wxWindow* parent,
m_Title = new wxStaticText( parent, -1, Title ); m_Title = new wxStaticText( parent, -1, Title );
m_Title->SetForegroundColour( wxColour( 200, 0, 0 ) );
BoxSizer->Add( m_Title, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, 5 ); BoxSizer->Add( m_Title, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, 5 );
m_FrameText = new wxTextCtrl( parent, -1, TextToEdit, wxDefaultPosition, Size ); m_FrameText = new wxTextCtrl( parent, -1, TextToEdit, wxDefaultPosition, Size );
......
...@@ -21,7 +21,6 @@ set(CVPCB_SRCS ...@@ -21,7 +21,6 @@ set(CVPCB_SRCS
listboxes.cpp listboxes.cpp
listlib.cpp listlib.cpp
loadcmp.cpp loadcmp.cpp
memoire.cpp
menucfg.cpp menucfg.cpp
readschematicnetlist.cpp readschematicnetlist.cpp
savecmp.cpp savecmp.cpp
...@@ -29,17 +28,6 @@ set(CVPCB_SRCS ...@@ -29,17 +28,6 @@ set(CVPCB_SRCS
tool_cvpcb.cpp tool_cvpcb.cpp
writenetlistpcbnew.cpp) writenetlistpcbnew.cpp)
set(CVPCB_EXTRA_SRCS
# ../pcbnew/class_board_item.cpp
# ../pcbnew/class_drawsegment.cpp
# ../pcbnew/class_edge_mod.cpp
# ../pcbnew/class_equipot.cpp
# ../pcbnew/class_module.cpp
# ../pcbnew/class_text_mod.cpp
../pcbnew/ioascii.cpp
# ../pcbnew/tracemod.cpp
)
if(WIN32) if(WIN32)
if(MINGW) if(MINGW)
# CVPCB_RESOURCES variable is set by the macro. # CVPCB_RESOURCES variable is set by the macro.
...@@ -58,7 +46,7 @@ if(APPLE) ...@@ -58,7 +46,7 @@ if(APPLE)
set(MACOSX_BUNDLE_NAME cvpcb) set(MACOSX_BUNDLE_NAME cvpcb)
endif(APPLE) endif(APPLE)
add_executable(cvpcb WIN32 MACOSX_BUNDLE ${CVPCB_SRCS} ${CVPCB_EXTRA_SRCS} ${CVPCB_RESOURCES}) add_executable(cvpcb WIN32 MACOSX_BUNDLE ${CVPCB_SRCS} ${CVPCB_RESOURCES})
target_link_libraries(cvpcb 3d-viewer common pcbcommon polygon bitmaps kbool ${OPENGL_LIBRARIES} ${wxWidgets_LIBRARIES}) target_link_libraries(cvpcb 3d-viewer common pcbcommon polygon bitmaps kbool ${OPENGL_LIBRARIES} ${wxWidgets_LIBRARIES})
......
...@@ -29,40 +29,66 @@ public: ...@@ -29,40 +29,66 @@ public:
}; };
/* routines locales : */ /*
static int auto_select( WinEDA_CvpcbFrame* frame, * read the string between quotes and put it in aTarget
STORECMP* Cmp, * put text in aTarget
AUTOMODULE* BaseListeMod ); * return a pointer to the last read char (the second quote if Ok)
static char * ReadQuotedText(wxString & aTarget, char * aText); */
char * ReadQuotedText(wxString & aTarget, char * aText)
{
// search the first quote:
for( ; *aText != 0; aText++ )
{
if( *aText == QUOTE )
break;
}
if ( *aText == 0 )
return NULL;
aText++;
for(; *aText != 0; aText++ )
{
if( *aText == QUOTE )
break;
aTarget.Append(*aText);
}
return aText;
}
/*************************************************************/
void WinEDA_CvpcbFrame::AssocieModule( wxCommandEvent& event )
/*************************************************************/
/* Called by the automatic association button /*
* Read *.equ files to try to find acorresponding footprint * Called by the automatic association button
* for each component that is not already linked to a footprint ( a "free" component ) * Read *.equ files to try to find corresponding footprint
* for each component that is not already linked to a footprint ( a "free"
* component )
* format of a line: * format of a line:
* 'cmp_ref' 'footprint_name' * 'cmp_ref' 'footprint_name'
*/ */
void WinEDA_CvpcbFrame::AssocieModule( wxCommandEvent& event )
{ {
COMPONENT_LIST::iterator iCmp;
FOOTPRINT_LIST::iterator iFp;
wxFileName fn; wxFileName fn;
wxString msg, tmp; wxString msg, tmp;
char Line[1024]; char Line[1024];
FILE* file; FILE* file;
AUTOMODULE* ItemModule, * NextMod; AUTOMODULE* ItemModule, * NextMod;
AUTOMODULE* BaseListeMod = NULL; AUTOMODULE* BaseListeMod = NULL;
STORECMP* Component; COMPONENT* Component;
FOOTPRINT* footprint;
size_t ii;
int nb_correspondances = 0; int nb_correspondances = 0;
if( nbcomp <= 0 ) if( m_components.empty() )
return; return;
/* recherche des equivalences a travers les fichiers possibles */ /* recherche des equivalences a travers les fichiers possibles */
for( unsigned ii = 0; ii < g_ListName_Equ.GetCount(); ii++ ) for( ii = 0; ii < m_AliasLibNames.GetCount(); ii++ )
{ {
fn = g_ListName_Equ[ii]; fn = m_AliasLibNames[ii];
fn.SetExt( EquivFileExtension ); fn.SetExt( FootprintAliasFileExtension );
tmp = wxGetApp().FindLibraryPath( fn ); tmp = wxGetApp().FindLibraryPath( fn );
...@@ -110,18 +136,41 @@ void WinEDA_CvpcbFrame::AssocieModule( wxCommandEvent& event ) ...@@ -110,18 +136,41 @@ void WinEDA_CvpcbFrame::AssocieModule( wxCommandEvent& event )
fclose( file ); fclose( file );
} }
/* display some info */ /* display some info */
msg.Printf( _( "%d equivalences" ), nb_correspondances ); msg.Printf( _( "%d equivalences" ), nb_correspondances );
SetStatusText( msg, 0 ); SetStatusText( msg, 0 );
wxMessageBox(msg); wxMessageBox(msg);
Component = g_BaseListeCmp; for( iCmp = m_components.begin(); iCmp != m_components.end(); ++iCmp )
for( unsigned ii = 0; Component != NULL; Component = Component->Pnext, ii++ )
{ {
m_ListCmp->SetSelection( ii, TRUE ); Component = *iCmp;
m_ListCmp->SetSelection( m_components.IndexOf( Component ), TRUE );
if( Component->m_Module.IsEmpty() ) if( Component->m_Module.IsEmpty() )
auto_select( this, Component, BaseListeMod ); {
ItemModule = BaseListeMod;
for( ; ItemModule != NULL; ItemModule = ItemModule->Pnext )
{
if( ItemModule->m_Name.CmpNoCase( Component->m_Valeur ) != 0 )
continue;
for( iFp = m_footprints.begin(); iFp != m_footprints.end(); ++iFp )
{
footprint = *iFp;
if( ItemModule->m_LibName.CmpNoCase( footprint->m_Module ) == 0 )
{
SetNewPkg( footprint->m_Module );
break;
}
}
msg.Printf( _( "Component %s: Footprint %s not found in " \
"libraries" ), Component->m_Valeur.GetData(),
ItemModule->m_LibName.GetData() );
DisplayError( this, msg, 10 );
}
}
} }
/* free memory: */ /* free memory: */
...@@ -133,77 +182,3 @@ void WinEDA_CvpcbFrame::AssocieModule( wxCommandEvent& event ) ...@@ -133,77 +182,3 @@ void WinEDA_CvpcbFrame::AssocieModule( wxCommandEvent& event )
BaseListeMod = NULL; BaseListeMod = NULL;
} }
/***************************************************/
char * ReadQuotedText(wxString & aTarget, char * aText)
/***************************************************/
/** read the string between quotes and put it in aTarget
* put text in aTarget
* return a pointer to the last read char (the second quote if Ok)
*/
{
// search the first quote:
for( ; *aText != 0; aText++ )
{
if( *aText == QUOTE )
break;
}
if ( *aText == 0 )
return NULL;
aText++;
for(; *aText != 0; aText++ )
{
if( *aText == QUOTE )
break;
aTarget.Append(*aText);
}
return aText;
}
/****************************************************************/
int auto_select( WinEDA_CvpcbFrame* frame, STORECMP* Cmp,
AUTOMODULE* BaseListeMod )
/****************************************************************/
/* associe automatiquement composant et Module
* Retourne;
* 0 si OK
* 1 si module specifie non trouve en liste librairie
* 2 si pas de module specifie dans la liste des equivalences
*/
{
AUTOMODULE* ItemModule;
STOREMOD* Module;
wxString msg;
/* examen de la liste des correspondances */
ItemModule = BaseListeMod;
for( ; ItemModule != NULL; ItemModule = ItemModule->Pnext )
{
if( ItemModule->m_Name.CmpNoCase( Cmp->m_Valeur ) != 0 )
continue;
/* Correspondance trouvee, recherche nom module dans la liste des
* modules disponibles en librairie */
Module = g_BaseListePkg;
for( ; Module != NULL; Module = Module->Pnext )
{
if( ItemModule->m_LibName.CmpNoCase( Module->m_Module ) == 0 )
{
frame->SetNewPkg( Module->m_Module );
return 0;
}
}
msg.Printf( _( "Component %s: Footprint %s not found in libraries" ),
Cmp->m_Valeur.GetData(), ItemModule->m_LibName.GetData() );
DisplayError( frame, msg, 10 );
return 2;
}
return 1;
}
...@@ -8,74 +8,105 @@ ...@@ -8,74 +8,105 @@
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
#include "common.h" #include "common.h"
#include "gestfich.h" #include "gestfich.h"
#include "param_config.h"
#include "cvpcb.h" #include "cvpcb.h"
#include "protos.h" #include "protos.h"
#include "cvstruct.h" #include "cvstruct.h"
#include "cfg.h"
/* Routines Locales */
/**/
#define GROUP wxT("/cvpcb")
#define GROUPLIB wxT("/pcbnew/libraries")
#define GROUPEQU wxT("/cvpcb/libraries")
/**************************************************/
void Read_Config( const wxString& FileName )
/**************************************************/
/* lit la configuration /**
* Return project file parameter list for CVPcb.
*
* Populate the project file parameter array specific to CVPcb if it hasn't
* already been populated and return a reference to the array to the caller.
* Creating the parameter list at run time has the advantage of being able
* to define local variables. The old method of statically building the array
* at compile time requiring global variable definitions.
*/
const PARAM_CFG_ARRAY& WinEDA_CvpcbFrame::GetProjectFileParameters( void )
{
if( !m_projectFileParams.IsEmpty() )
return m_projectFileParams;
m_projectFileParams.Add( new PARAM_CFG_BASE( GROUPLIB,
PARAM_COMMAND_ERASE ) );
m_projectFileParams.Add( new PARAM_CFG_LIBNAME_LIST( wxT( "LibName" ),
&m_ModuleLibNames,
GROUPLIB ) );
m_projectFileParams.Add( new PARAM_CFG_LIBNAME_LIST( wxT( "EquName" ),
&m_AliasLibNames,
GROUPEQU ) );
m_projectFileParams.Add( new PARAM_CFG_WXSTRING( wxT( "NetIExt" ),
&m_NetlistFileExtension ) );
m_projectFileParams.Add( new PARAM_CFG_WXSTRING( wxT( "LibDir" ),
&m_UserLibraryPath,
GROUPLIB ) );
return m_projectFileParams;
}
/**
* lit la configuration
* 1 - lit cvpcb.cnf * 1 - lit cvpcb.cnf
* 2 - si non trouve lit <chemin de cvpcb.exe>/cvpcb.cnf * 2 - si non trouve lit <chemin de cvpcb.exe>/cvpcb.cnf
* 3 - si non trouve: init des variables aux valeurs par defaut * 3 - si non trouve: init des variables aux valeurs par defaut
* *
* Remarque: * Remarque:
* le chemin de l'executable cvpcb.exe doit etre dans BinDir * le chemin de l'executable cvpcb.exe doit etre dans BinDir
*
*/ */
void WinEDA_CvpcbFrame::LoadProjectFile( const wxString& FileName )
{ {
wxFileName fn = FileName; wxFileName fn = FileName;
/* Init des valeurs par defaut */ /* Init des valeurs par defaut */
g_LibName_List.Clear(); m_ModuleLibNames.Clear();
g_ListName_Equ.Clear(); m_AliasLibNames.Clear();
if( fn.GetExt() != ProjectFileExtension ) if( fn.GetExt() != ProjectFileExtension )
fn.SetExt( ProjectFileExtension ); fn.SetExt( ProjectFileExtension );
wxGetApp().RemoveLibraryPath( g_UserLibDirBuffer ); wxGetApp().RemoveLibraryPath( m_UserLibraryPath );
wxGetApp().ReadProjectConfig( fn.GetFullPath(), wxGetApp().ReadProjectConfig( fn.GetFullPath(), GROUP,
GROUP, ParamCfgList, FALSE ); GetProjectFileParameters(), FALSE );
if( g_NetlistFileExtension.IsEmpty() ) if( m_NetlistFileExtension.IsEmpty() )
g_NetlistFileExtension = wxT( "net" ); m_NetlistFileExtension = wxT( "net" );
/* User library path takes precedent over default library search paths. */ /* User library path takes precedent over default library search paths. */
wxGetApp().InsertLibraryPath( g_UserLibDirBuffer, 1 ); wxGetApp().InsertLibraryPath( m_UserLibraryPath, 1 );
} }
/************************************************************/
void WinEDA_CvpcbFrame::Update_Config( wxCommandEvent& event )
/************************************************************/
/* fonction relai d'appel a Save_Config, /* fonction relai d'appel a Save_Config,
* la vraie fonction de sauvegarde de la config * la vraie fonction de sauvegarde de la config
*/ */
void WinEDA_CvpcbFrame::Update_Config( wxCommandEvent& event )
{ {
Save_Config( this, m_NetlistFileName.GetFullPath() ); SaveProjectFile( m_NetlistFileName.GetFullPath() );
} }
void Save_Config( wxWindow* parent, const wxString& fileName ) void WinEDA_CvpcbFrame::SaveProjectFile( const wxString& fileName )
{ {
wxFileName fn = fileName; wxFileName fn = fileName;
fn.SetExt( ProjectFileExtension ); fn.SetExt( ProjectFileExtension );
wxFileDialog dlg( parent, _( "Save Project File" ), fn.GetPath(), wxFileDialog dlg( this, _( "Save Project File" ), fn.GetPath(),
fn.GetFullName(), ProjectFileWildcard, wxFD_SAVE ); fn.GetFullName(), ProjectFileWildcard, wxFD_SAVE );
if( dlg.ShowModal() == wxID_CANCEL ) if( dlg.ShowModal() == wxID_CANCEL )
return; return;
/* ecriture de la configuration */ /* ecriture de la configuration */
wxGetApp().WriteProjectConfig( dlg.GetPath(), GROUP, ParamCfgList ); wxGetApp().WriteProjectConfig( dlg.GetPath(), GROUP,
GetProjectFileParameters() );
} }
/*******************************************************/
/** cfg.h : configuration: definition des structures **/
/*******************************************************/
#include "param_config.h"
#define INSETUP TRUE
#define GROUP wxT("/cvpcb")
#define GROUPCOMMON wxT("/common")
#define GROUPLIB wxT("/pcbnew/libraries")
#define GROUPEQU wxT("/cvpcb/libraries")
/* Liste des parametres */
static PARAM_CFG_BASE CommandCfg
(
GROUPLIB, /* identification de groupe */
PARAM_COMMAND_ERASE /* type */
);
static PARAM_CFG_LIBNAME_LIST LibNameBufCfg
(
wxT("LibName"), /* identification */
&g_LibName_List, /* Adresse du parametre */
GROUPLIB
);
static PARAM_CFG_LIBNAME_LIST EquivNameBufCfg
(
wxT("EquName"), /* identification */
&g_ListName_Equ, /* Adresse du parametre */
GROUPEQU
);
static PARAM_CFG_WXSTRING NetInExtBufCfg
(
wxT("NetIExt"), /* identification */
&g_NetlistFileExtension
);
static PARAM_CFG_WXSTRING NetDirBufCfg
(
wxT("NetDir"), /* identification */
&g_UserNetDirBuffer, /* Adresse du parametre */
GROUPCOMMON
);
static PARAM_CFG_WXSTRING UserLibDirBufCfg
(
wxT("LibDir"), /* identification */
&g_UserLibDirBuffer, /* Adresse du parametre */
GROUPLIB
);
static PARAM_CFG_BOOL DisplayPadFillCfg
(
INSETUP,
wxT("DiPadFi"), /* identification */
&DisplayOpt.DisplayPadFill, /* Adresse du parametre */
TRUE /* Valeur par defaut */
);
static PARAM_CFG_BOOL DisplayPadNumCfg
(
INSETUP,
wxT("DiPadNu"), /* identification */
&DisplayOpt.DisplayPadNum, /* Adresse du parametre */
TRUE /* Valeur par defaut */
);
static PARAM_CFG_BOOL DisplayPadNoConnCfg
(
INSETUP,
wxT("DiPadNC"), /* identification */
&DisplayOpt.DisplayPadNoConn, /* Adresse du parametre */
FALSE /* Valeur par defaut */
);
static PARAM_CFG_BOOL DisplayPadIsolCfg
(
INSETUP,
wxT("DiPadMg"), /* identification */
&DisplayOpt.DisplayPadIsol, /* Adresse du parametre */
FALSE /* Valeur par defaut */
);
static PARAM_CFG_INT DisplayModEdgeCfg
(
INSETUP,
wxT("DiModEd"), /* identification */
&DisplayOpt.DisplayModEdge, /* Adresse du parametre */
1, /* Valeur par defaut */
0, 1 /* Valeurs extremes */
);
static PARAM_CFG_INT DisplayModTextCfg
(
INSETUP,
wxT("DiModTx"), /* identification */
&DisplayOpt.DisplayModText, /* Adresse du parametre */
1, /* Valeur par defaut */
0, 1 /* Valeurs extremes */
);
static PARAM_CFG_BOOL DisplayPcbTrackFillCfg
(
INSETUP,
wxT("DiPcbTF"), /* identification */
&DisplayOpt.DisplayPcbTrackFill, /* Adresse du parametre */
TRUE /* Valeur par defaut */
);
static PARAM_CFG_BASE * ParamCfgList[] =
{
& CommandCfg,
& NetInExtBufCfg,
& NetDirBufCfg,
& UserLibDirBufCfg,
& LibNameBufCfg,
& EquivNameBufCfg,
& DisplayPadFillCfg,
& DisplayPadNumCfg,
& DisplayPadNoConnCfg,
& DisplayPadIsolCfg,
& DisplayModEdgeCfg,
& DisplayModTextCfg,
& DisplayPcbTrackFillCfg,
NULL
};
...@@ -2,58 +2,73 @@ ...@@ -2,58 +2,73 @@
/* class_cvpcb.cpp */ /* class_cvpcb.cpp */
/*******************/ /*******************/
// For compilers that support precompilation, includes "wx.h". #include "fctsys.h"
#include "wx/wxprec.h" #include "kicad_string.h"
#ifdef __BORLANDC__ #include "cvpcb.h"
#pragma hdrstop
#endif
// for all others, include the necessary headers (this file is usually all you #include <wx/listimpl.cpp>
// need because it includes almost all "standard" wxWindows headers
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
#include "fctsys.h"
#include "common.h"
#include "cvpcb.h" WX_DEFINE_LIST( PIN_LIST );
STORECMP::STORECMP() PIN::PIN()
{ {
Pnext = Pback = NULL; m_Index = 0; /* variable utilisee selon types de netlistes */
m_Type = STRUCT_COMPONENT; m_PinType = 0; /* code type electrique ( Entree Sortie Passive..) */
m_Pins = NULL;
m_Num = 0;
m_Multi = 0;
} }
STORECMP::~STORECMP() int compare( const PIN** item1, const PIN** item2 )
{ {
STOREPIN * Pin, * NextPin; return StrLenNumICmp( (*item1)->m_PinNum.GetData(),
(*item2)->m_PinNum.GetData(), 4 );
for( Pin = m_Pins; Pin != NULL; Pin = NextPin )
{
NextPin = Pin->Pnext; delete Pin;
}
} }
bool same_pin_number( const PIN* item1, const PIN* item2 )
{
wxASSERT( item1 != NULL && item2 != NULL );
return ( item1->m_PinNum == item2->m_PinNum );
}
STOREMOD::STOREMOD() bool same_pin_net( const PIN* item1, const PIN* item2 )
{ {
Pnext = Pback = NULL; wxASSERT( item1 != NULL && item2 != NULL );
m_Type = STRUCT_MODULE;
m_Num = 0; return ( item1->m_PinNet == item2->m_PinNet );
} }
STOREPIN::STOREPIN() WX_DEFINE_LIST( COMPONENT_LIST );
COMPONENT::COMPONENT()
{
m_Num = 0;
m_Multi = 0;
}
COMPONENT::~COMPONENT()
{ {
m_Type = STRUCT_PIN; /* Type de la structure */ m_Pins.DeleteContents( true );
Pnext = NULL; /* Chainage avant */ m_Pins.Clear();
m_Index = 0; /* variable utilisee selon types de netlistes */
m_PinType = 0; /* code type electrique ( Entree Sortie Passive..) */
} }
int compare( const COMPONENT** item1, const COMPONENT** item2 )
{
return StrNumICmp( (*item1)->m_Reference.GetData(),
(*item2)->m_Reference.GetData() );
}
WX_DEFINE_LIST( FOOTPRINT_LIST );
FOOTPRINT::FOOTPRINT()
{
m_Num = 0;
}
int compare( const FOOTPRINT** item1, const FOOTPRINT** item2 )
{
return StrNumICmp( (*item1)->m_Module.GetData(),
(*item2)->m_Module.GetData() );
}
This diff is collapsed.
...@@ -22,53 +22,20 @@ ...@@ -22,53 +22,20 @@
/* Constant string definitions for CvPcb */ /* Constant string definitions for CvPcb */
const wxString ComponentFileExtension( wxT( "cmp" ) ); const wxString ComponentFileExtension( wxT( "cmp" ) );
const wxString RetroFileExtension( wxT( "stf" ) ); const wxString RetroFileExtension( wxT( "stf" ) );
const wxString EquivFileExtension( wxT( "equ" ) ); const wxString FootprintAliasFileExtension( wxT( "equ" ) );
// Wildcard for footprint libraries filesnames
const wxString g_FootprintLibFileWildcard( wxT( "Kicad footprint library file " \
"(*.mod)|*.mod" ) );
// Wildcard for schematic retroannotation (import footprint names in schematic): // Wildcard for schematic retroannotation (import footprint names in schematic):
const wxString RetroFileWildcard( _( "Kicad component list files (*.stf)|*.stf" ) ); const wxString RetroFileWildcard( _( "Kicad component list files " \
"(*.stf)|*.stf" ) );
// Wildcard for alias footprint files const wxString FootprintAliasFileWildcard( _( "Kicad footprint alias files " \
const wxString EquivFileWildcard( _( "Kicad footprint alias files (*.equ)|*.equ" ) ); "(*.equ)|*.equ" ) );
const wxString titleLibLoadError( _( "Library Load Error" ) ); const wxString titleLibLoadError( _( "Library Load Error" ) );
/* Global variables used in CVPcb. */
int g_FlagEESchema;
int Rjustify;
int modified;
int nbcomp;
int nblib;
int composants_non_affectes;
// Option to keep cvpcb open after saving netlist files
bool g_KeepCvpcbOpen = false;
STOREMOD* g_BaseListePkg = NULL;
STORECMP* g_BaseListeCmp = NULL;
wxString g_UserNetDirBuffer; // Netlist path (void = current working directory)
wxString g_NetlistFileExtension;
wxArrayString g_ListName_Equ; // list of .equ files to load
/* Name of the document footprint list
* usually located in share/modules/footprints_doc
* this is of the responsability to users to create this file
* if they want to have a list of footprints
*/
wxString g_DocModulesFileName = DEFAULT_FOOTPRINTS_LIST_FILENAME;
// Create a new application object // Create a new application object
IMPLEMENT_APP( WinEDA_App ) IMPLEMENT_APP( WinEDA_App )
/* fonctions locales */
/************************************/ /************************************/
/* Called to initialize the program */ /* Called to initialize the program */
...@@ -105,17 +72,10 @@ bool WinEDA_App::OnInit() ...@@ -105,17 +72,10 @@ bool WinEDA_App::OnInit()
wxString Title = GetTitle() + wxT( " " ) + GetBuildVersion(); wxString Title = GetTitle() + wxT( " " ) + GetBuildVersion();
frame = new WinEDA_CvpcbFrame( Title ); frame = new WinEDA_CvpcbFrame( Title );
msg.Printf( wxT( "Modules: %d" ), nblib );
frame->SetStatusText( msg, 2 );
// Show the frame // Show the frame
SetTopWindow( frame ); SetTopWindow( frame );
Read_Config( fn.GetFullPath() ); frame->LoadProjectFile( fn.GetFullPath() );
long tmp;
if ( wxGetApp().m_EDA_CommonConfig->Read( CLOSE_OPTION_KEY, & tmp) )
g_KeepCvpcbOpen = tmp;
frame->Show( TRUE ); frame->Show( TRUE );
frame->BuildFootprintListBox(); frame->BuildFootprintListBox();
...@@ -125,13 +85,13 @@ bool WinEDA_App::OnInit() ...@@ -125,13 +85,13 @@ bool WinEDA_App::OnInit()
if( frame->ReadNetList() ) if( frame->ReadNetList() )
{ {
g_NetlistFileExtension = fn.GetExt(); frame->m_NetlistFileExtension = fn.GetExt();
return true; return true;
} }
} }
listlib(); LoadFootprintFiles( frame->m_ModuleLibNames, frame->m_footprints );
g_NetlistFileExtension = wxT( "net" ); frame->m_NetlistFileExtension = wxT( "net" );
frame->m_NetlistFileName.Clear(); frame->m_NetlistFileName.Clear();
frame->SetTitle( GetTitle() + wxT( " " ) + GetBuildVersion() + frame->SetTitle( GetTitle() + wxT( " " ) + GetBuildVersion() +
wxGetCwd() + wxFileName::GetPathSeparator() + wxGetCwd() + wxFileName::GetPathSeparator() +
......
...@@ -8,12 +8,8 @@ ...@@ -8,12 +8,8 @@
#include "pcbcommon.h" #include "pcbcommon.h"
// config for footprints doc file acces // config for footprints doc file acces
#define DOC_FOOTPRINTS_LIST_KEY wxT( "footprints_doc_file" )
#define DEFAULT_FOOTPRINTS_LIST_FILENAME wxT( "footprints_doc/footprints.pdf" ) #define DEFAULT_FOOTPRINTS_LIST_FILENAME wxT( "footprints_doc/footprints.pdf" )
// option key to close cvpcb after saving files
#define CLOSE_OPTION_KEY wxT( "KeepCvpcbOpen" )
// Define print format to display a schematic component line // Define print format to display a schematic component line
#define CMP_FORMAT wxT( "%3d %8s - %16s : %-.32s" ) #define CMP_FORMAT wxT( "%3d %8s - %16s : %-.32s" )
...@@ -27,38 +23,35 @@ ...@@ -27,38 +23,35 @@
#define TYPE_VIEWLOGIC_NET 4 #define TYPE_VIEWLOGIC_NET 4
enum TypeOfStruct { class PIN
STRUCT_NOT_INIT,
STRUCT_COMPONENT,
STRUCT_PIN,
STRUCT_MODULE,
STRUCT_PSEUDOMODULE
};
class STOREPIN
{ {
public: public:
int m_Type; /* Type de la structure */ int m_Index; /* variable utilisee selon types de netlistes */
STOREPIN* Pnext; /* Chainage avant */ int m_PinType; /* code type electrique ( Entree Sortie Passive..) */
int m_Index; /* variable utilisee selon types de netlistes */ wxString m_PinNet; /* Pointeur sur le texte nom de net */
int m_PinType; /* code type electrique ( Entree Sortie Passive..) */
wxString m_PinNet; /* Pointeur sur le texte nom de net */
wxString m_PinNum; wxString m_PinNum;
wxString m_PinName; wxString m_PinName;
wxString m_Repere; /* utilise selon formats de netliste */ wxString m_Repere; /* utilise selon formats de netliste */
STOREPIN(); PIN();
}; };
class STORECMP WX_DECLARE_LIST( PIN, PIN_LIST );
/* PIN object list sort function. */
extern int compare( const PIN** item1, const PIN** item2 );
/* PIN object comparison functions. */
extern bool same_pin_number( const PIN* item1, const PIN* item2 );
extern bool same_pin_net( const PIN* item1, const PIN* item2 );
class COMPONENT
{ {
public: public:
int m_Type; /* Type de la structure */
STORECMP* Pnext; /* Chainage avant */
STORECMP* Pback; /* Chainage arriere */
int m_Num; /* Numero d'ordre */ int m_Num; /* Numero d'ordre */
int m_Multi; /* Nombre d' unites par boitier */ int m_Multi; /* Nombre d' unites par boitier */
STOREPIN* m_Pins; /* pointeur sur la liste des Pins */ PIN_LIST m_Pins; /* pointeur sur la liste des Pins */
wxString m_Reference; /* U3, R5 ... */ wxString m_Reference; /* U3, R5 ... */
wxString m_Valeur; /* 7400, 47K ... */ wxString m_Valeur; /* 7400, 47K ... */
wxString m_TimeStamp; /* Signature temporelle ("00000000" si absente) */ wxString m_TimeStamp; /* Signature temporelle ("00000000" si absente) */
...@@ -67,71 +60,43 @@ public: ...@@ -67,71 +60,43 @@ public:
wxArrayString m_FootprintFilter; /* List of allowed footprints (wildcart allowed wxArrayString m_FootprintFilter; /* List of allowed footprints (wildcart allowed
* if void: no filtering */ * if void: no filtering */
STORECMP(); COMPONENT();
~STORECMP(); ~COMPONENT();
}; };
class STOREMOD WX_DECLARE_LIST( COMPONENT, COMPONENT_LIST );
/* COMPONENT object list sort function. */
extern int compare( const COMPONENT** item1, const COMPONENT** item2 );
class FOOTPRINT
{ {
public: public:
int m_Type; /* Type de la structure */
STOREMOD* Pnext; /* Chainage avant */
STOREMOD* Pback; /* Chainage arriere */
wxString m_Module; /* Nom du module */ wxString m_Module; /* Nom du module */
wxString m_LibName; /* Nom de la librairie contenant ce module */ wxString m_LibName; /* Nom de la librairie contenant ce module */
int m_Num; /* Numero d'ordre pour affichage sur la liste */ int m_Num; /* Numero d'ordre pour affichage sur la liste */
wxString m_Doc; /* Doc associee */ wxString m_Doc; /* Doc associee */
wxString m_KeyWord; /* Mots cles associes */ wxString m_KeyWord; /* Mots cles associes */
STOREMOD(); FOOTPRINT();
}; };
WX_DECLARE_LIST( FOOTPRINT, FOOTPRINT_LIST );
/* FOOTPRINT object list sort function. */
extern int compare( const FOOTPRINT** item1, const FOOTPRINT** item2 );
/* Gestion des noms des librairies */ /* Gestion des noms des librairies */
extern const wxString EquivFileExtension; extern const wxString FootprintAliasFileExtension;
extern const wxString RetroFileExtension; extern const wxString RetroFileExtension;
extern const wxString ComponentFileExtension; extern const wxString ComponentFileExtension;
extern const wxString RetroFileWildcard; extern const wxString RetroFileWildcard;
extern const wxString EquivFileWildcard; extern const wxString FootprintAliasFileWildcard;
extern const wxString titleLibLoadError; extern const wxString titleLibLoadError;
// Wildcard for footprint libraries filesnames
extern const wxString g_FootprintLibFileWildcard;
// Wildcard for schematic retroannotation (import footprint names in schematic):
extern const wxString g_FootprintEquFileWildcard;
/* Name of the document footprint list
* usually located in share/modules/footprints_doc
* this is of the responsability to users to create this file
* if they want to have a list of footprints
*/
extern wxString g_DocModulesFileName;
/* CvPcb global variable definition references. */
extern STOREMOD* g_BaseListePkg;
extern STORECMP* g_BaseListeCmp;
extern wxString g_NetlistFileExtension;
extern wxString g_UserNetDirBuffer;
extern wxArrayString g_ListName_Equ; // list of .equ files to load
extern int g_FlagEESchema;
extern int Rjustify; /* flag pout troncature des noms de Net:
* = 0: debut de chaine conservee (->ORCADPCB2)
* = 1: fin de chaine conservee (->VIEWLOGIC) */
extern int modified; /* Flag != 0 si modif attribution des module. */
extern int nbcomp; /* nombre de composants trouves */
extern int nblib; /* nombre d'empreintes trouvees */
extern int composants_non_affectes; /* nbre de composants non affectes */
extern bool g_KeepCvpcbOpen; // Option to keep cvpcb open after saving netlist files
void Plume( int state ); void Plume( int state );
#endif /* __CVPCB_H__ */ #endif /* __CVPCB_H__ */
/***********************************************************/ /***********************************************************/
/* wxstruct.h: */ /* cvstruct.h : */
/* descriptions des principales classes derivees utilisees */ /* descriptions des principales classes derivees utilisees */
/***********************************************************/ /***********************************************************/
...@@ -8,12 +8,13 @@ ...@@ -8,12 +8,13 @@
#include "wx/listctrl.h" #include "wx/listctrl.h"
#include <wx/filename.h> #include <wx/filename.h>
#include "param_config.h"
#include "cvpcb.h"
/* Forward declarations of all top-level window classes. */ /* Forward declarations of all top-level window classes. */
class FootprintListBox; class FootprintListBox;
class ListBoxCmp; class ListBoxCmp;
class WinEDA_DisplayFrame; class WinEDA_DisplayFrame;
class STORECMP;
#define LIST_BOX_TYPE wxListView #define LIST_BOX_TYPE wxListView
...@@ -25,11 +26,26 @@ class WinEDA_CvpcbFrame : public WinEDA_BasicFrame ...@@ -25,11 +26,26 @@ class WinEDA_CvpcbFrame : public WinEDA_BasicFrame
{ {
public: public:
bool m_KeepCvpcbOpen;
FootprintListBox* m_FootprintList; FootprintListBox* m_FootprintList;
ListBoxCmp* m_ListCmp; ListBoxCmp* m_ListCmp;
WinEDA_DisplayFrame* DrawFrame; WinEDA_DisplayFrame* DrawFrame;
WinEDA_Toolbar* m_HToolBar; // Toolbar horizontal haut d'ecran WinEDA_Toolbar* m_HToolBar; // Toolbar horizontal haut d'ecran
wxFileName m_NetlistFileName; wxFileName m_NetlistFileName;
wxArrayString m_ModuleLibNames;
wxArrayString m_AliasLibNames;
wxString m_UserLibraryPath;
wxString m_NetlistFileExtension;
wxString m_DocModulesFileName;
FOOTPRINT_LIST m_footprints;
COMPONENT_LIST m_components;
protected:
int m_undefinedComponentCnt;
bool m_modified;
bool m_rightJustify;
bool m_isEESchemaNetlist;
PARAM_CFG_ARRAY m_projectFileParams;
// Constructor and destructor // Constructor and destructor
public: public:
...@@ -49,8 +65,6 @@ public: ...@@ -49,8 +65,6 @@ public:
void ReCreateHToolbar(); void ReCreateHToolbar();
virtual void ReCreateMenuBar(); virtual void ReCreateMenuBar();
void SetLanguage( wxCommandEvent& event ); void SetLanguage( wxCommandEvent& event );
void AddFontSelectionMenu( wxMenu* main_menu );
void ProcessFontPreferences( wxCommandEvent& event );
void ToFirstNA( wxCommandEvent& event ); void ToFirstNA( wxCommandEvent& event );
void ToPreviousNA( wxCommandEvent& event ); void ToPreviousNA( wxCommandEvent& event );
...@@ -58,11 +72,15 @@ public: ...@@ -58,11 +72,15 @@ public:
void SaveQuitCvpcb( wxCommandEvent& event ); void SaveQuitCvpcb( wxCommandEvent& event );
void LoadNetList( wxCommandEvent& event ); void LoadNetList( wxCommandEvent& event );
void ConfigCvpcb( wxCommandEvent& event ); void ConfigCvpcb( wxCommandEvent& event );
void OnKeepOpenOnSave( wxCommandEvent& event );
void DisplayModule( wxCommandEvent& event ); void DisplayModule( wxCommandEvent& event );
void AssocieModule( wxCommandEvent& event ); void AssocieModule( wxCommandEvent& event );
void WriteStuffList( wxCommandEvent& event ); void WriteStuffList( wxCommandEvent& event );
void DisplayDocFile( wxCommandEvent& event ); void DisplayDocFile( wxCommandEvent& event );
void OnSelectFilteringFootprint( wxCommandEvent& event ); void OnSelectFilteringFootprint( wxCommandEvent& event );
void OnUpdateKeepOpenOnSave( wxUpdateUIEvent& event );
void SetNewPkg( const wxString& package ); void SetNewPkg( const wxString& package );
void BuildCmpListBox(); void BuildCmpListBox();
void BuildFootprintListBox(); void BuildFootprintListBox();
...@@ -75,6 +93,12 @@ public: ...@@ -75,6 +93,12 @@ public:
int ReadFootprintFilterList( FILE* f ); int ReadFootprintFilterList( FILE* f );
int ReadViewlogicWirList(); int ReadViewlogicWirList();
int ReadViewlogicNetList(); int ReadViewlogicNetList();
void LoadProjectFile( const wxString& FileName );
void SaveProjectFile( const wxString& fileName );
virtual void LoadSettings();
virtual void SaveSettings();
const PARAM_CFG_ARRAY& GetProjectFileParameters( void );
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
...@@ -91,7 +115,7 @@ public: ...@@ -91,7 +115,7 @@ public:
public: public:
ListBoxBase( WinEDA_CvpcbFrame * parent, wxWindowID id, ListBoxBase( WinEDA_CvpcbFrame * parent, wxWindowID id,
const wxPoint &loc, const wxSize &size ); const wxPoint &loc, const wxSize &size );
~ListBoxBase(); ~ListBoxBase();
...@@ -113,17 +137,18 @@ public: ...@@ -113,17 +137,18 @@ public:
bool m_UseFootprintFullList; bool m_UseFootprintFullList;
public: public:
FootprintListBox( WinEDA_CvpcbFrame * parent, FootprintListBox( WinEDA_CvpcbFrame * parent, wxWindowID id,
wxWindowID id, const wxPoint &loc, const wxSize &size, const wxPoint &loc, const wxSize &size,
int nbitems, wxString choice[] ); int nbitems, wxString choice[] );
~FootprintListBox(); ~FootprintListBox();
int GetCount(); int GetCount();
void SetSelection( unsigned index, bool State = TRUE ); void SetSelection( unsigned index, bool State = TRUE );
void SetString( unsigned linecount, const wxString& text ); void SetString( unsigned linecount, const wxString& text );
void AppendLine( const wxString& text ); void AppendLine( const wxString& text );
void SetFootprintFullList(); void SetFootprintFullList( FOOTPRINT_LIST& list );
void SetFootprintFilteredList( STORECMP* Component ); void SetFootprintFilteredList( COMPONENT* Component,
FOOTPRINT_LIST& list );
void SetActiveFootprintList( bool FullList, bool Redraw = FALSE ); void SetActiveFootprintList( bool FullList, bool Redraw = FALSE );
wxString GetSelectedFootprint(); wxString GetSelectedFootprint();
...@@ -147,8 +172,8 @@ public: ...@@ -147,8 +172,8 @@ public:
public: public:
ListBoxCmp( WinEDA_CvpcbFrame * parent, wxWindowID id, ListBoxCmp( WinEDA_CvpcbFrame * parent, wxWindowID id,
const wxPoint &loc, const wxSize &size, const wxPoint &loc, const wxSize &size,
int nbitems, wxString choice[] ); int nbitems, wxString choice[] );
~ListBoxCmp(); ~ListBoxCmp();
......
...@@ -24,12 +24,14 @@ DIALOG_CVPCB_CONFIG::DIALOG_CVPCB_CONFIG( WinEDA_CvpcbFrame* parent ) : ...@@ -24,12 +24,14 @@ DIALOG_CVPCB_CONFIG::DIALOG_CVPCB_CONFIG( WinEDA_CvpcbFrame* parent ) :
DIALOG_CVPCB_CONFIG_FBP( parent ) DIALOG_CVPCB_CONFIG_FBP( parent )
{ {
wxString title; wxString title;
wxFileName fn = parent->m_NetlistFileName;
fn.SetExt( ProjectFileExtension );
m_Parent = parent; m_Parent = parent;
m_Config = wxGetApp().m_EDA_CommonConfig; m_Config = wxGetApp().m_EDA_CommonConfig;
Init( ); Init( );
title = _( "from " ) + wxGetApp().m_CurrentOptionFile; title = _( "Project file: " ) + fn.GetFullPath();
SetTitle( title ); SetTitle( title );
if( GetSizer() ) if( GetSizer() )
{ {
...@@ -44,35 +46,16 @@ void DIALOG_CVPCB_CONFIG::Init() ...@@ -44,35 +46,16 @@ void DIALOG_CVPCB_CONFIG::Init()
{ {
wxString msg; wxString msg;
SetFont( *g_DialogFont );
SetFocus(); SetFocus();
m_LibListChanged = false; m_LibListChanged = false;
m_LibPathChanged = false; m_LibPathChanged = false;
m_UserLibDirBufferImg = g_UserLibDirBuffer; // Save the original lib path m_UserLibDirBufferImg = m_Parent->m_UserLibraryPath;
// Display current files extension (info)
msg = m_InfoCmpFileExt->GetLabel() + ComponentFileExtension;
m_InfoCmpFileExt->SetLabel( msg );
msg = m_InfoLibFileExt->GetLabel() + ModuleFileExtension;
m_InfoLibFileExt->SetLabel( msg );
msg = m_InfoNetlistFileExt->GetLabel() + g_NetlistFileExtension;
m_InfoNetlistFileExt->SetLabel( msg );
msg = m_InfoEquivFileExt->GetLabel() + EquivFileExtension; m_ListLibr->InsertItems( m_Parent->m_ModuleLibNames, 0 );
m_InfoEquivFileExt->SetLabel( msg ); m_ListEquiv->InsertItems( m_Parent->m_AliasLibNames, 0 );
msg = m_InfoRetroannotFileExt->GetLabel() + RetroFileExtension; m_TextHelpModulesFileName->SetValue( m_Parent->m_DocModulesFileName );
m_InfoRetroannotFileExt->SetLabel( msg );
m_ListLibr->InsertItems( g_LibName_List, 0 );
m_ListEquiv->InsertItems( g_ListName_Equ, 0 );
// Display current modules doc file:
m_Config->Read( DOC_FOOTPRINTS_LIST_KEY, g_DocModulesFileName );
m_TextHelpModulesFileName->SetValue( g_DocModulesFileName );
// Load user libs paths: // Load user libs paths:
wxStringTokenizer Token( m_UserLibDirBufferImg, wxT( ";\n\r" ) ); wxStringTokenizer Token( m_UserLibDirBufferImg, wxT( ";\n\r" ) );
...@@ -93,8 +76,6 @@ void DIALOG_CVPCB_CONFIG::Init() ...@@ -93,8 +76,6 @@ void DIALOG_CVPCB_CONFIG::Init()
// select the first path afer the current path project // select the first path afer the current path project
if( libpaths.GetCount() > 1 ) if( libpaths.GetCount() > 1 )
m_DefaultLibraryPathslistBox->Select( 1 ); m_DefaultLibraryPathslistBox->Select( 1 );
m_radioBoxCloseOpt->SetSelection ( g_KeepCvpcbOpen ? 1 : 0 );
} }
...@@ -108,9 +89,10 @@ void DIALOG_CVPCB_CONFIG::OnCancelClick( wxCommandEvent& event ) ...@@ -108,9 +89,10 @@ void DIALOG_CVPCB_CONFIG::OnCancelClick( wxCommandEvent& event )
for( unsigned ii = 0; ii < m_ListLibr->GetCount(); ii++ ) for( unsigned ii = 0; ii < m_ListLibr->GetCount(); ii++ )
wxGetApp().RemoveLibraryPath( m_listUserPaths->GetString( ii ) ); wxGetApp().RemoveLibraryPath( m_listUserPaths->GetString( ii ) );
wxGetApp().InsertLibraryPath( g_UserLibDirBuffer, 1 ); wxGetApp().InsertLibraryPath( m_Parent->m_UserLibraryPath, 1 );
} }
EndModal( -1 );
EndModal( wxID_CANCEL );
} }
...@@ -118,21 +100,17 @@ void DIALOG_CVPCB_CONFIG::OnCancelClick( wxCommandEvent& event ) ...@@ -118,21 +100,17 @@ void DIALOG_CVPCB_CONFIG::OnCancelClick( wxCommandEvent& event )
void DIALOG_CVPCB_CONFIG::OnOkClick( wxCommandEvent& event ) void DIALOG_CVPCB_CONFIG::OnOkClick( wxCommandEvent& event )
/**************************************************************/ /**************************************************************/
{ {
g_KeepCvpcbOpen = m_radioBoxCloseOpt->GetSelection( ) ? true : false; m_Parent->m_DocModulesFileName = m_TextHelpModulesFileName->GetValue();
m_Config->Write( CLOSE_OPTION_KEY, (long) g_KeepCvpcbOpen );
m_Config->Write( DOC_FOOTPRINTS_LIST_KEY,
m_TextHelpModulesFileName->GetValue() );
// Recreate the user lib path // Recreate the user lib path
if( m_LibPathChanged ) if( m_LibPathChanged )
{ {
g_UserLibDirBuffer.Empty(); m_Parent->m_UserLibraryPath.Empty();
for( unsigned ii = 0; ii < m_listUserPaths->GetCount(); ii++ ) for( unsigned ii = 0; ii < m_listUserPaths->GetCount(); ii++ )
{ {
if( ii > 0 ) if( ii > 0 )
g_UserLibDirBuffer << wxT( ";" ); m_Parent->m_UserLibraryPath << wxT( ";" );
g_UserLibDirBuffer << m_listUserPaths->GetString( ii ); m_Parent->m_UserLibraryPath << m_listUserPaths->GetString( ii );
} }
} }
...@@ -141,20 +119,22 @@ void DIALOG_CVPCB_CONFIG::OnOkClick( wxCommandEvent& event ) ...@@ -141,20 +119,22 @@ void DIALOG_CVPCB_CONFIG::OnOkClick( wxCommandEvent& event )
if( m_LibListChanged || m_LibPathChanged ) if( m_LibListChanged || m_LibPathChanged )
{ {
// Recreate lib list // Recreate lib list
g_LibName_List.Clear(); m_Parent->m_ModuleLibNames.Clear();
for( unsigned ii = 0; ii < m_ListLibr->GetCount(); ii++ ) for( unsigned ii = 0; ii < m_ListLibr->GetCount(); ii++ )
g_LibName_List.Add( m_ListLibr->GetString( ii ) ); m_Parent->m_ModuleLibNames.Add( m_ListLibr->GetString( ii ) );
// Recreate equ list // Recreate equ list
g_ListName_Equ.Clear(); m_Parent->m_AliasLibNames.Clear();
for( unsigned ii = 0; ii < m_ListEquiv->GetCount(); ii++ ) for( unsigned ii = 0; ii < m_ListEquiv->GetCount(); ii++ )
g_ListName_Equ.Add( m_ListEquiv->GetString( ii ) ); m_Parent->m_AliasLibNames.Add( m_ListEquiv->GetString( ii ) );
listlib(); LoadFootprintFiles( m_Parent->m_ModuleLibNames,
m_Parent->m_footprints );
m_Parent->BuildFootprintListBox(); m_Parent->BuildFootprintListBox();
} }
if( event.GetId() != ID_SAVE_CFG )
EndModal( 0 ); m_Parent->SaveProjectFile( m_Parent->m_NetlistFileName.GetFullPath() );
EndModal( wxID_OK );
} }
...@@ -209,12 +189,12 @@ void DIALOG_CVPCB_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event ) ...@@ -209,12 +189,12 @@ void DIALOG_CVPCB_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
if( (event.GetId() == ID_INSERT_EQU) || (event.GetId() == ID_INSERT_LIB) ) if( (event.GetId() == ID_INSERT_EQU) || (event.GetId() == ID_INSERT_LIB) )
insert = true; insert = true;
wildcard = EquivFileWildcard; wildcard = FootprintAliasFileWildcard;
wxListBox * list = m_ListEquiv; wxListBox * list = m_ListEquiv;
if( (event.GetId() == ID_ADD_LIB) || (event.GetId() == ID_INSERT_LIB) ) if( (event.GetId() == ID_ADD_LIB) || (event.GetId() == ID_INSERT_LIB) )
{ {
list = m_ListLibr; list = m_ListLibr;
wildcard = g_FootprintLibFileWildcard; wildcard = ModuleFileWildcard;
} }
ii = list->GetSelection(); ii = list->GetSelection();
...@@ -246,8 +226,8 @@ void DIALOG_CVPCB_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event ) ...@@ -246,8 +226,8 @@ void DIALOG_CVPCB_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
* list, just add the library name to the list. Otherwise, add * list, just add the library name to the list. Otherwise, add
* the library name with the full or relative path. * the library name with the full or relative path.
* the relative path, when possible is preferable, * the relative path, when possible is preferable,
* because it preserve use of default libraries paths, when the path is a sub path of these default paths * because it preserve use of default libraries paths, when the path
* * is a sub path of these default paths
*/ */
if( wxGetApp().GetLibraryPathList().Index( fn.GetPath() ) != wxNOT_FOUND ) // Ok, trivial case if( wxGetApp().GetLibraryPathList().Index( fn.GetPath() ) != wxNOT_FOUND ) // Ok, trivial case
libfilename = fn.GetName(); libfilename = fn.GetName();
...@@ -283,15 +263,6 @@ void DIALOG_CVPCB_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event ) ...@@ -283,15 +263,6 @@ void DIALOG_CVPCB_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
} }
/*******************************************************************/
void DIALOG_CVPCB_CONFIG::OnSaveCfgClick( wxCommandEvent& event )
/*******************************************************************/
{
OnOkClick( event );
Save_Config( this, m_Parent->m_NetlistFileName.GetFullPath() );
}
/***********************************************************************/ /***********************************************************************/
void DIALOG_CVPCB_CONFIG::OnAddOrInsertPath( wxCommandEvent& event ) void DIALOG_CVPCB_CONFIG::OnAddOrInsertPath( wxCommandEvent& event )
/***********************************************************************/ /***********************************************************************/
...@@ -370,16 +341,14 @@ void DIALOG_CVPCB_CONFIG::OnRemoveUserPath( wxCommandEvent& event ) ...@@ -370,16 +341,14 @@ void DIALOG_CVPCB_CONFIG::OnRemoveUserPath( wxCommandEvent& event )
void DIALOG_CVPCB_CONFIG::OnBrowseModDocFile( wxCommandEvent& event ) void DIALOG_CVPCB_CONFIG::OnBrowseModDocFile( wxCommandEvent& event )
/**************************************************************************/ /**************************************************************************/
{ {
wxString FullFileName, mask; wxString FullFileName;
wxString docpath, filename; wxString docpath, filename;
docpath = wxGetApp().ReturnLastVisitedLibraryPath( wxT( "doc" ) ); docpath = wxGetApp().ReturnLastVisitedLibraryPath( wxT( "doc" ) );
mask = wxT( "*.pdf" );
wxFileDialog FilesDialog( this, _( "Footprint document file:" ), docpath, wxFileDialog FilesDialog( this, _( "Footprint document file:" ), docpath,
wxEmptyString, mask, wxEmptyString, PdfFileWildcard,
wxFD_DEFAULT_STYLE ); wxFD_DEFAULT_STYLE | wxFD_FILE_MUST_EXIST );
if( FilesDialog.ShowModal() != wxID_OK ) if( FilesDialog.ShowModal() != wxID_OK )
return; return;
...@@ -390,7 +359,8 @@ void DIALOG_CVPCB_CONFIG::OnBrowseModDocFile( wxCommandEvent& event ) ...@@ -390,7 +359,8 @@ void DIALOG_CVPCB_CONFIG::OnBrowseModDocFile( wxCommandEvent& event )
* list, just add the library name to the list. Otherwise, add * list, just add the library name to the list. Otherwise, add
* the library name with the full or relative path. * the library name with the full or relative path.
* the relative path, when possible is preferable, * the relative path, when possible is preferable,
* because it preserve use of default libraries paths, when the path is a sub path of these default paths * because it preserve use of default libraries paths, when the path is
* a sub path of these default paths
*/ */
wxFileName fn = FullFileName; wxFileName fn = FullFileName;
wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() ); wxGetApp().SaveLastVisitedLibraryPath( fn.GetPath() );
......
...@@ -26,7 +26,6 @@ private: ...@@ -26,7 +26,6 @@ private:
void OnCloseWindow( wxCloseEvent& event ); void OnCloseWindow( wxCloseEvent& event );
void OnOkClick( wxCommandEvent& event ); void OnOkClick( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event ); void OnCancelClick( wxCommandEvent& event );
void OnSaveCfgClick( wxCommandEvent& event );
void OnAddOrInsertLibClick( wxCommandEvent& event ); void OnAddOrInsertLibClick( wxCommandEvent& event );
void OnRemoveLibClick( wxCommandEvent& event ); void OnRemoveLibClick( wxCommandEvent& event );
void OnBrowseModDocFile( wxCommandEvent& event ); void OnBrowseModDocFile( wxCommandEvent& event );
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -11,18 +11,16 @@ ...@@ -11,18 +11,16 @@
#include <wx/intl.h> #include <wx/intl.h>
#include <wx/string.h> #include <wx/string.h>
#include <wx/button.h> #include <wx/listbox.h>
#include <wx/gdicmn.h> #include <wx/gdicmn.h>
#include <wx/font.h> #include <wx/font.h>
#include <wx/colour.h> #include <wx/colour.h>
#include <wx/settings.h> #include <wx/settings.h>
#include <wx/stattext.h> #include <wx/button.h>
#include <wx/sizer.h> #include <wx/sizer.h>
#include <wx/statbox.h> #include <wx/statbox.h>
#include <wx/radiobox.h>
#include <wx/listbox.h>
#include <wx/statline.h>
#include <wx/textctrl.h> #include <wx/textctrl.h>
#include <wx/statline.h>
#include <wx/dialog.h> #include <wx/dialog.h>
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
...@@ -37,8 +35,7 @@ class DIALOG_CVPCB_CONFIG_FBP : public wxDialog ...@@ -37,8 +35,7 @@ class DIALOG_CVPCB_CONFIG_FBP : public wxDialog
protected: protected:
enum enum
{ {
ID_SAVE_CFG = 1000, ID_ADD_LIB = 1000,
ID_ADD_LIB,
ID_INSERT_LIB, ID_INSERT_LIB,
ID_REMOVE_LIB, ID_REMOVE_LIB,
ID_ADD_EQU, ID_ADD_EQU,
...@@ -50,50 +47,39 @@ class DIALOG_CVPCB_CONFIG_FBP : public wxDialog ...@@ -50,50 +47,39 @@ class DIALOG_CVPCB_CONFIG_FBP : public wxDialog
ID_REMOVE_PATH, ID_REMOVE_PATH,
}; };
wxButton* m_buttonOk; wxListBox* m_ListLibr;
wxButton* m_buttonCancel;
wxButton* m_buttonSave;
wxStaticText* m_InfoCmpFileExt;
wxStaticText* m_InfoLibFileExt;
wxStaticText* m_InfoNetlistFileExt;
wxStaticText* m_InfoEquivFileExt;
wxStaticText* m_InfoRetroannotFileExt;
wxRadioBox* m_radioBoxCloseOpt;
wxStaticText* m_staticTextlibList;
wxButton* m_buttonAddLib; wxButton* m_buttonAddLib;
wxButton* m_buttonInsLib; wxButton* m_buttonInsLib;
wxButton* m_buttonRemoveLib; wxButton* m_buttonRemoveLib;
wxListBox* m_ListLibr; wxListBox* m_ListEquiv;
wxStaticText* m_staticTextEquList;
wxButton* m_buttonAddEqu; wxButton* m_buttonAddEqu;
wxButton* m_buttonInsEqu; wxButton* m_buttonInsEqu;
wxButton* m_buttonRemoveEqu; wxButton* m_buttonRemoveEqu;
wxListBox* m_ListEquiv;
wxStaticLine* m_staticline1;
wxTextCtrl* m_TextHelpModulesFileName; wxTextCtrl* m_TextHelpModulesFileName;
wxButton* m_buttonModDoc; wxButton* m_buttonModDoc;
wxListBox* m_listUserPaths; wxListBox* m_listUserPaths;
wxButton* m_buttonAddPath; wxButton* m_buttonAddPath;
wxButton* m_buttonInsPath; wxButton* m_buttonInsPath;
wxButton* m_buttonRemovePath; wxButton* m_buttonRemovePath;
wxStaticText* m_staticTextcurrenpaths;
wxListBox* m_DefaultLibraryPathslistBox; wxListBox* m_DefaultLibraryPathslistBox;
wxStaticLine* m_staticline2;
wxStdDialogButtonSizer* m_sdbSizer2;
wxButton* m_sdbSizer2OK;
wxButton* m_sdbSizer2Cancel;
// Virtual event handlers, overide them in your derived class // Virtual event handlers, overide them in your derived class
virtual void OnCloseWindow( wxCloseEvent& event ){ event.Skip(); } virtual void OnCloseWindow( wxCloseEvent& event ){ event.Skip(); }
virtual void OnOkClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnCancelClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnSaveCfgClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnAddOrInsertLibClick( wxCommandEvent& event ){ event.Skip(); } virtual void OnAddOrInsertLibClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnRemoveLibClick( wxCommandEvent& event ){ event.Skip(); } virtual void OnRemoveLibClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnBrowseModDocFile( wxCommandEvent& event ){ event.Skip(); } virtual void OnBrowseModDocFile( wxCommandEvent& event ){ event.Skip(); }
virtual void OnAddOrInsertPath( wxCommandEvent& event ){ event.Skip(); } virtual void OnAddOrInsertPath( wxCommandEvent& event ){ event.Skip(); }
virtual void OnRemoveUserPath( wxCommandEvent& event ){ event.Skip(); } virtual void OnRemoveUserPath( wxCommandEvent& event ){ event.Skip(); }
virtual void OnCancelClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnOkClick( wxCommandEvent& event ){ event.Skip(); }
public: public:
DIALOG_CVPCB_CONFIG_FBP( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 641,612 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); DIALOG_CVPCB_CONFIG_FBP( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_CVPCB_CONFIG_FBP(); ~DIALOG_CVPCB_CONFIG_FBP();
}; };
......
...@@ -57,8 +57,6 @@ IMPLEMENT_DYNAMIC_CLASS( WinEDA_FootprintDisplayOptionsFrame, wxDialog ) ...@@ -57,8 +57,6 @@ IMPLEMENT_DYNAMIC_CLASS( WinEDA_FootprintDisplayOptionsFrame, wxDialog )
BEGIN_EVENT_TABLE( WinEDA_FootprintDisplayOptionsFrame, wxDialog ) BEGIN_EVENT_TABLE( WinEDA_FootprintDisplayOptionsFrame, wxDialog )
////@begin WinEDA_FootprintDisplayOptionsFrame event table entries ////@begin WinEDA_FootprintDisplayOptionsFrame event table entries
EVT_BUTTON( ID_SAVE_CONFIG, WinEDA_FootprintDisplayOptionsFrame::OnSaveConfigClick )
EVT_BUTTON( wxID_OK, WinEDA_FootprintDisplayOptionsFrame::OnOkClick ) EVT_BUTTON( wxID_OK, WinEDA_FootprintDisplayOptionsFrame::OnOkClick )
EVT_BUTTON( wxID_CANCEL, WinEDA_FootprintDisplayOptionsFrame::OnCancelClick ) EVT_BUTTON( wxID_CANCEL, WinEDA_FootprintDisplayOptionsFrame::OnCancelClick )
...@@ -98,7 +96,6 @@ bool WinEDA_FootprintDisplayOptionsFrame::Create( wxWindow* parent, wxWindowID i ...@@ -98,7 +96,6 @@ bool WinEDA_FootprintDisplayOptionsFrame::Create( wxWindow* parent, wxWindowID i
ColumnBoxSizer = NULL; ColumnBoxSizer = NULL;
m_IsShowPadFill = NULL; m_IsShowPadFill = NULL;
m_IsShowPadNum = NULL; m_IsShowPadNum = NULL;
BottomBoxSizer = NULL;
m_CancelButton = NULL; m_CancelButton = NULL;
////@end WinEDA_FootprintDisplayOptionsFrame member initialisation ////@end WinEDA_FootprintDisplayOptionsFrame member initialisation
...@@ -122,10 +119,8 @@ bool WinEDA_FootprintDisplayOptionsFrame::Create( wxWindow* parent, wxWindowID i ...@@ -122,10 +119,8 @@ bool WinEDA_FootprintDisplayOptionsFrame::Create( wxWindow* parent, wxWindowID i
void WinEDA_FootprintDisplayOptionsFrame::CreateControls() void WinEDA_FootprintDisplayOptionsFrame::CreateControls()
{ {
SetFont(*g_DialogFont);
////@begin WinEDA_FootprintDisplayOptionsFrame content construction ////@begin WinEDA_FootprintDisplayOptionsFrame content construction
// Generated by DialogBlocks, 21/07/2008 15:12:47 (unregistered) // Generated by DialogBlocks, 16/04/2009 14:23:49 (unregistered)
WinEDA_FootprintDisplayOptionsFrame* itemDialog1 = this; WinEDA_FootprintDisplayOptionsFrame* itemDialog1 = this;
...@@ -152,40 +147,34 @@ void WinEDA_FootprintDisplayOptionsFrame::CreateControls() ...@@ -152,40 +147,34 @@ void WinEDA_FootprintDisplayOptionsFrame::CreateControls()
MainBoxSizer->Add(m_TextDisplayOption, 0, wxALIGN_TOP|wxALL, 5); MainBoxSizer->Add(m_TextDisplayOption, 0, wxALIGN_TOP|wxALL, 5);
ColumnBoxSizer = new wxBoxSizer(wxVERTICAL); ColumnBoxSizer = new wxBoxSizer(wxVERTICAL);
MainBoxSizer->Add(ColumnBoxSizer, 1, wxALIGN_TOP|wxLEFT|wxRIGHT|wxTOP, 5); MainBoxSizer->Add(ColumnBoxSizer, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
m_IsShowPadFill = new wxCheckBox( itemDialog1, PADFILL_OPT, _("&Pad Filled"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); m_IsShowPadFill = new wxCheckBox( itemDialog1, PADFILL_OPT, _("Fill &pad"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
m_IsShowPadFill->SetValue(false); m_IsShowPadFill->SetValue(false);
ColumnBoxSizer->Add(m_IsShowPadFill, 1, wxGROW|wxALL, 5); ColumnBoxSizer->Add(m_IsShowPadFill, 1, wxGROW|wxALL, 5);
m_IsShowPadNum = new wxCheckBox( itemDialog1, PADNUM_OPT, _("Display Pad &Num"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE ); m_IsShowPadNum = new wxCheckBox( itemDialog1, PADNUM_OPT, _("Show pad &number"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
m_IsShowPadNum->SetValue(false); m_IsShowPadNum->SetValue(false);
if (WinEDA_FootprintDisplayOptionsFrame::ShowToolTips()) if (WinEDA_FootprintDisplayOptionsFrame::ShowToolTips())
m_IsShowPadNum->SetToolTip(_("Display pad number")); m_IsShowPadNum->SetToolTip(_("Display pad number"));
ColumnBoxSizer->Add(m_IsShowPadNum, 1, wxGROW|wxALL, 5); ColumnBoxSizer->Add(m_IsShowPadNum, 1, wxGROW|wxALL, 5);
ColumnBoxSizer->Add(5, 5, 0, wxGROW|wxTOP, 5); wxStaticLine* itemStaticLine9 = new wxStaticLine( itemDialog1, ID_STATICLINE1, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
OuterBoxSizer->Add(itemStaticLine9, 0, wxGROW|wxALL, 5);
wxButton* itemButton10 = new wxButton( itemDialog1, ID_SAVE_CONFIG, _("Save Cfg"), wxDefaultPosition, wxDefaultSize, 0 );
ColumnBoxSizer->Add(itemButton10, 0, wxALIGN_LEFT|wxALL, 5);
wxStaticLine* itemStaticLine11 = new wxStaticLine( itemDialog1, ID_STATICLINE1, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
OuterBoxSizer->Add(itemStaticLine11, 0, wxGROW|wxALL, 5);
BottomBoxSizer = new wxBoxSizer(wxHORIZONTAL); wxStdDialogButtonSizer* itemStdDialogButtonSizer10 = new wxStdDialogButtonSizer;
OuterBoxSizer->Add(BottomBoxSizer, 0, wxALIGN_RIGHT|wxALL, 5);
wxButton* itemButton13 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 ); OuterBoxSizer->Add(itemStdDialogButtonSizer10, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
itemButton13->SetDefault(); wxButton* itemButton11 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
itemButton13->SetForegroundColour(wxColour(255, 0, 0)); itemStdDialogButtonSizer10->AddButton(itemButton11);
BottomBoxSizer->Add(itemButton13, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
m_CancelButton = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); m_CancelButton = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
m_CancelButton->SetForegroundColour(wxColour(0, 0, 255)); itemStdDialogButtonSizer10->AddButton(m_CancelButton);
BottomBoxSizer->Add(m_CancelButton, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
wxButton* itemButton15 = new wxButton( itemDialog1, wxID_APPLY, _("&Apply"), wxDefaultPosition, wxDefaultSize, 0 ); wxButton* itemButton13 = new wxButton( itemDialog1, wxID_APPLY, _("&Apply"), wxDefaultPosition, wxDefaultSize, 0 );
BottomBoxSizer->Add(itemButton15, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); itemStdDialogButtonSizer10->AddButton(itemButton13);
itemStdDialogButtonSizer10->Realize();
// Set validators // Set validators
m_EdgesDisplayOption->SetValidator( wxGenericValidator(& DisplayOpt.DisplayModEdge) ); m_EdgesDisplayOption->SetValidator( wxGenericValidator(& DisplayOpt.DisplayModEdge) );
...@@ -240,33 +229,14 @@ void WinEDA_FootprintDisplayOptionsFrame::UpdateObjectSettings(void) ...@@ -240,33 +229,14 @@ void WinEDA_FootprintDisplayOptionsFrame::UpdateObjectSettings(void)
{ {
// Update settings // Update settings
////@begin WinEDA_FootprintDisplayOptionsFrame update settings ////@begin WinEDA_FootprintDisplayOptionsFrame update settings
DisplayOpt.DisplayModEdge = m_Parent->m_DisplayModEdge = m_Parent->m_DisplayModEdge = m_EdgesDisplayOption->GetSelection();
m_EdgesDisplayOption->GetSelection(); m_Parent->m_DisplayModText = m_TextDisplayOption->GetSelection();
m_Parent->m_DisplayPadNum = m_IsShowPadNum->GetValue();
DisplayOpt.DisplayModText = m_Parent->m_DisplayModText = m_Parent->m_DisplayPadFill = m_IsShowPadFill->GetValue();
m_TextDisplayOption->GetSelection();
DisplayOpt.DisplayPadNum = m_Parent->m_DisplayPadNum =
m_IsShowPadNum->GetValue();
DisplayOpt.DisplayPadFill = m_Parent->m_DisplayPadFill =
m_IsShowPadFill->GetValue();
m_Parent->DrawPanel->Refresh(); m_Parent->DrawPanel->Refresh();
////@end WinEDA_FootprintDisplayOptionsFrame update settings ////@end WinEDA_FootprintDisplayOptionsFrame update settings
} }
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_SAVE_CONFIG
*/
void WinEDA_FootprintDisplayOptionsFrame::OnSaveConfigClick( wxCommandEvent& event )
{
WinEDA_CvpcbFrame* parent = ( WinEDA_CvpcbFrame* )GetParent();
wxASSERT( parent && parent->IsKindOf( CLASSINFO( WinEDA_CvpcbFrame ) ) );
Save_Config( this, parent->m_NetlistFileName.GetFullPath() );
}
/*! /*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK * wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
*/ */
......
...@@ -45,7 +45,6 @@ class wxBoxSizer; ...@@ -45,7 +45,6 @@ class wxBoxSizer;
#define TEXT_SELECT 10002 #define TEXT_SELECT 10002
#define PADFILL_OPT 10003 #define PADFILL_OPT 10003
#define PADNUM_OPT 10004 #define PADNUM_OPT 10004
#define ID_SAVE_CONFIG 10005
#define ID_STATICLINE1 10006 #define ID_STATICLINE1 10006
#define SYMBOL_WINEDA_FOOTPRINTDISPLAYOPTIONSFRAME_STYLE wxDEFAULT_DIALOG_STYLE|MAYBE_RESIZE_BORDER #define SYMBOL_WINEDA_FOOTPRINTDISPLAYOPTIONSFRAME_STYLE wxDEFAULT_DIALOG_STYLE|MAYBE_RESIZE_BORDER
#define SYMBOL_WINEDA_FOOTPRINTDISPLAYOPTIONSFRAME_TITLE _("Display Options") #define SYMBOL_WINEDA_FOOTPRINTDISPLAYOPTIONSFRAME_TITLE _("Display Options")
...@@ -84,9 +83,6 @@ public: ...@@ -84,9 +83,6 @@ public:
////@begin WinEDA_FootprintDisplayOptionsFrame event handler declarations ////@begin WinEDA_FootprintDisplayOptionsFrame event handler declarations
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_SAVE_CONFIG
void OnSaveConfigClick( wxCommandEvent& event );
/// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
void OnOkClick( wxCommandEvent& event ); void OnOkClick( wxCommandEvent& event );
...@@ -120,7 +116,6 @@ public: ...@@ -120,7 +116,6 @@ public:
wxBoxSizer* ColumnBoxSizer; wxBoxSizer* ColumnBoxSizer;
wxCheckBox* m_IsShowPadFill; wxCheckBox* m_IsShowPadFill;
wxCheckBox* m_IsShowPadNum; wxCheckBox* m_IsShowPadNum;
wxBoxSizer* BottomBoxSizer;
wxButton* m_CancelButton; wxButton* m_CancelButton;
////@end WinEDA_FootprintDisplayOptionsFrame member variables ////@end WinEDA_FootprintDisplayOptionsFrame member variables
......
This diff is collapsed.
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
/* Construction de la table des evenements pour WinEDA_DrawFrame */ /* Construction de la table des evenements pour WinEDA_DrawFrame */
/*****************************************************************/ /*****************************************************************/
BEGIN_EVENT_TABLE( WinEDA_DisplayFrame, WinEDA_DrawFrame ) BEGIN_EVENT_TABLE( WinEDA_DisplayFrame, WinEDA_BasePcbFrame )
EVT_CLOSE( WinEDA_DisplayFrame::OnCloseWindow ) EVT_CLOSE( WinEDA_DisplayFrame::OnCloseWindow )
EVT_SIZE( WinEDA_DrawFrame::OnSize ) EVT_SIZE( WinEDA_DrawFrame::OnSize )
EVT_TOOL_RANGE( ID_ZOOM_IN, ID_ZOOM_PAGE, WinEDA_DisplayFrame::OnZoom ) EVT_TOOL_RANGE( ID_ZOOM_IN, ID_ZOOM_PAGE, WinEDA_DisplayFrame::OnZoom )
......
...@@ -17,12 +17,13 @@ ...@@ -17,12 +17,13 @@
void WinEDA_CvpcbFrame::WriteStuffList( wxCommandEvent& event ) void WinEDA_CvpcbFrame::WriteStuffList( wxCommandEvent& event )
{ {
FILE* FileEquiv; COMPONENT_LIST::iterator i;
STORECMP* Cmp; FILE* FileEquiv;
wxString Line; COMPONENT* Cmp;
wxString Line;
wxFileName fn = m_NetlistFileName; wxFileName fn = m_NetlistFileName;
if( nbcomp <= 0 ) if( m_components.GetCount() <= 0 )
return; return;
/* calcul du nom du fichier */ /* calcul du nom du fichier */
...@@ -45,8 +46,10 @@ void WinEDA_CvpcbFrame::WriteStuffList( wxCommandEvent& event ) ...@@ -45,8 +46,10 @@ void WinEDA_CvpcbFrame::WriteStuffList( wxCommandEvent& event )
} }
/* Generation de la liste */ /* Generation de la liste */
for( Cmp = g_BaseListeCmp; Cmp != NULL; Cmp = Cmp->Pnext ) for( i = m_components.begin(); i != m_components.end(); ++i )
{ {
Cmp = *i;
/* gnration du composant si son empreinte est dfinie */ /* gnration du composant si son empreinte est dfinie */
if( Cmp->m_Module.IsEmpty() ) if( Cmp->m_Module.IsEmpty() )
continue; continue;
......
/***************/ /***************/
/* genorcad() */ /* genorcad() */
/***************/ /***************/
/* /*
Complte la netliste (*.NET) en y placant les ref *.lib FORMAT ORCADPCB * Complte la netliste (*.NET) en y placant les ref *.lib FORMAT ORCADPCB
La valeur (Part Value) est tronquee a 16 lettres * La valeur (Part Value) est tronquee a 16 lettres
*/ */
#include "fctsys.h" #include "fctsys.h"
...@@ -17,185 +17,174 @@ La valeur (Part Value) est tronquee a 16 lettres ...@@ -17,185 +17,174 @@ La valeur (Part Value) est tronquee a 16 lettres
#define MAX_LEN_NETNAME 16 #define MAX_LEN_NETNAME 16
/* Routines locales */ /* Routines locales */
static void TriPinsModule( STORECMP * CurrentCmp ); static void TriPinsModule( COMPONENT* CurrentCmp );
static int PinCompare(const void *cmp1, const void *cmp2); static void ChangePinNet( wxString& PinNet, bool rightJustify );
static void ChangePinNet( wxString & PinNet );
/* Variables Locales */ /* Variables Locales */
int NetNumCode; /* Nombre utilise pour cree des NetNames lors de int NetNumCode; /* Nombre utilise pour cree des NetNames lors de
reaffectation de NetNames */ * reaffectation de NetNames */
int genorcad() int genorcad( bool rightJustify )
{ {
char Line[1024]; char Line[1024];
STOREPIN * Pin; PIN* Pin;
STORECMP * CurrentCmp; COMPONENT* CurrentCmp;
wxString Title = wxGetApp().GetAppName() + wxT(" ") + GetBuildVersion(); wxString Title = wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion();
NetNumCode = 1; DateAndTime(Line); NetNumCode = 1; DateAndTime( Line );
fprintf(dest,"( { Netlist by %s, date = %s }\n", fprintf( dest, "( { Netlist by %s, date = %s }\n",
CONV_TO_UTF8(Title), Line ) ; CONV_TO_UTF8( Title ), Line );
/***********************/ /***********************/
/* Lecture de la liste */ /* Lecture de la liste */
/***********************/ /***********************/
CurrentCmp = BaseListeCmp; CurrentCmp = BaseListeCmp;
for( ; CurrentCmp != NULL; CurrentCmp = CurrentCmp->Pnext) for( ; CurrentCmp != NULL; CurrentCmp = CurrentCmp->Pnext )
{ {
fprintf(dest," ( %s ", CONV_TO_UTF8(CurrentCmp->m_TimeStamp)); fprintf( dest, " ( %s ", CONV_TO_UTF8( CurrentCmp->m_TimeStamp ) );
if( ! CurrentCmp->m_Module.IsEmpty() ) if( !CurrentCmp->m_Module.IsEmpty() )
fprintf(dest, CONV_TO_UTF8(CurrentCmp->m_Module)); fprintf( dest, CONV_TO_UTF8( CurrentCmp->m_Module ) );
else fprintf(dest,"$noname$") ; else
fprintf( dest, "$noname$" );
fprintf(dest," %s ",CONV_TO_UTF8(CurrentCmp->m_Reference)) ;
fprintf( dest, " %s ", CONV_TO_UTF8( CurrentCmp->m_Reference ) );
/* placement de la valeur */
fprintf(dest,"%s\n",CONV_TO_UTF8(CurrentCmp->m_Valeur)) ; /* placement de la valeur */
fprintf( dest, "%s\n", CONV_TO_UTF8( CurrentCmp->m_Valeur ) );
/* Tri des pins */
TriPinsModule( CurrentCmp ); /* Tri des pins */
TriPinsModule( CurrentCmp );
/* Placement de la liste des pins */
Pin = CurrentCmp->m_Pins; /* Placement de la liste des pins */
for( ; Pin != NULL; Pin = Pin->Pnext ) Pin = CurrentCmp->m_Pins;
{ for( ; Pin != NULL; Pin = Pin->Pnext )
if( Pin->m_PinNet.Len() > MAX_LEN_NETNAME) {
ChangePinNet( Pin->m_PinNet ); if( Pin->m_PinNet.Len() > MAX_LEN_NETNAME )
ChangePinNet( Pin->m_PinNet, rightJustify );
if( ! Pin->m_PinNet.IsEmpty() )
fprintf(dest," ( %s %s )\n", if( !Pin->m_PinNet.IsEmpty() )
CONV_TO_UTF8(Pin->m_PinNum), fprintf( dest, " ( %s %s )\n",
CONV_TO_UTF8(Pin->m_PinNet)); CONV_TO_UTF8( Pin->m_PinNum ),
else CONV_TO_UTF8( Pin->m_PinNet ) );
fprintf(dest," ( %s ? )\n", CONV_TO_UTF8(Pin->m_PinNum)); else
} fprintf( dest, " ( %s ? )\n", CONV_TO_UTF8( Pin->m_PinNum ) );
fprintf(dest," )\n"); }
}
fprintf(dest,")\n*\n"); fprintf( dest, " )\n" );
fclose(dest); }
return(0);
fprintf( dest, ")\n*\n" );
fclose( dest );
return 0;
} }
/***********************************************/ /***********************************************/
static void TriPinsModule( STORECMP * CurrentCmp ) static void TriPinsModule( COMPONENT* CurrentCmp )
/***********************************************/ /***********************************************/
/* Tri et controle des pins du module CurrentCmp
*/
{
STOREPIN * Pin, * NextPin, ** BasePin;
int nbpins = 0, ii;
Pin = CurrentCmp->m_Pins;
if( Pin == NULL ) return;
/* comptage des pins */
for( ; Pin != NULL ; Pin = Pin->Pnext ) nbpins++;
/* Tri des pins: etablissement de la liste des pointeurs */
BasePin = (STOREPIN ** )MyZMalloc( nbpins * sizeof(STOREPIN*) );
Pin = CurrentCmp->m_Pins;
for( ii = 0 ; ii < nbpins ; ii++, Pin = Pin->Pnext )
{
BasePin[ii] = Pin;
}
/* Tri des Pins */
qsort( BasePin, nbpins, sizeof( STORECMP*), PinCompare) ;
/* Remise a jour des pointeurs chaines */
for( ii = 0 ; ii < nbpins-1 ; ii++ )
{
BasePin[ii]->Pnext = BasePin[ii+1];
}
BasePin[ii]->Pnext = NULL;
CurrentCmp->m_Pins = BasePin[0];
MyFree(BasePin);
/* Elimination des redondances */
Pin = CurrentCmp->m_Pins;
while( Pin != NULL)
{
NextPin = Pin->Pnext;
if ( NextPin == NULL ) break;
if( Pin->m_PinNum != NextPin->m_PinNum )
{
Pin = Pin->Pnext; continue;
}
/* 2 pins successives ont le meme numero */
if( Pin->m_PinNet != NextPin->m_PinNet )
{
wxString msg;
msg.Printf( _("%s %s pin %s : Different Nets"),
CurrentCmp->m_Reference.GetData(),CurrentCmp->m_Valeur.GetData(),
Pin->m_PinNum.GetData());
DisplayError(NULL, msg, 60 );
}
Pin->Pnext = NextPin->Pnext;
delete NextPin;
}
}
/*******************************************************/ /* Tri et controle des pins du module CurrentCmp
static int PinCompare(const void *cmp1,const void *cmp2) */
/*******************************************************/
/*
routine PinCompare() pour qsort() pour classement alphabetique
pour tri de la liste des Pins
*/
{ {
STOREPIN **pt1 , **pt2 ; PIN* Pin, * NextPin, ** BasePin;
int ii; int nbpins = 0, ii;
pt1 = (STOREPIN**)cmp1; Pin = CurrentCmp->m_Pins;
pt2 = (STOREPIN**)cmp2; if( Pin == NULL )
return;
ii = StrLenNumICmp( (*pt1)->m_PinNum.GetData(), (*pt2)->m_PinNum.GetData(), 4);
return(ii); /* comptage des pins */
for( ; Pin != NULL; Pin = Pin->Pnext )
nbpins++;
/* Tri des pins: etablissement de la liste des pointeurs */
BasePin = (PIN**) MyZMalloc( nbpins * sizeof(PIN*) );
Pin = CurrentCmp->m_Pins;
for( ii = 0; ii < nbpins; ii++, Pin = Pin->Pnext )
{
BasePin[ii] = Pin;
}
/* Tri des Pins */
qsort( BasePin, nbpins, sizeof( COMPONENT*), PinCompare );
/* Remise a jour des pointeurs chaines */
for( ii = 0; ii < nbpins - 1; ii++ )
{
BasePin[ii]->Pnext = BasePin[ii + 1];
}
BasePin[ii]->Pnext = NULL;
CurrentCmp->m_Pins = BasePin[0];
MyFree( BasePin );
/* Elimination des redondances */
Pin = CurrentCmp->m_Pins;
while( Pin != NULL )
{
NextPin = Pin->Pnext;
if( NextPin == NULL )
break;
if( Pin->m_PinNum != NextPin->m_PinNum )
{
Pin = Pin->Pnext; continue;
}
/* 2 pins successives ont le meme numero */
if( Pin->m_PinNet != NextPin->m_PinNet )
{
wxString msg;
msg.Printf( _( "%s %s pin %s : Different Nets" ),
CurrentCmp->m_Reference.GetData(),
CurrentCmp->m_Valeur.GetData(),
Pin->m_PinNum.GetData() );
DisplayError( NULL, msg, 60 );
}
Pin->Pnext = NextPin->Pnext;
delete NextPin;
}
} }
/*******************************************/ /*******************************************/
static void ChangePinNet( wxString & PinNet ) static void ChangePinNet( wxString& PinNet, bool rightJustify )
/*******************************************/ /*******************************************/
/* Change le NetName PinNet par un nom compose des 8 derniers codes de PinNet /* Change le NetName PinNet par un nom compose des 8 derniers codes de PinNet
suivi de _Xnnnnn ou nnnnn est un nom de 0 a 99999 * suivi de _Xnnnnn ou nnnnn est un nom de 0 a 99999
*/ */
{ {
STOREPIN * Pin; PIN* Pin;
STORECMP * CurrentCmp; COMPONENT* CurrentCmp;
int ii; int ii;
wxString OldName; wxString OldName;
wxString NewName; wxString NewName;
OldName = PinNet; OldName = PinNet;
ii = PinNet.Len(); ii = PinNet.Len();
if( Rjustify ) /* On conserve les 8 dernieres lettres du nom */ if( rightJustify ) /* On conserve les 8 dernieres lettres du nom */
{ {
NewName= OldName.Right(8); NewName << NetNumCode; NewName = OldName.Right( 8 ); NewName << NetNumCode;
} }
else /* On conserve les 8 premieres lettres du nom */
else /* On conserve les 8 premieres lettres du nom */ {
{ NewName = OldName.Left( 8 ); NewName << NetNumCode;
NewName = OldName.Left(8); NewName << NetNumCode; }
} NetNumCode++;
NetNumCode ++;
CurrentCmp = BaseListeCmp;
CurrentCmp = BaseListeCmp; for( ; CurrentCmp != NULL; CurrentCmp = CurrentCmp->Pnext )
for( ; CurrentCmp != NULL; CurrentCmp = CurrentCmp->Pnext) {
{ Pin = CurrentCmp->m_Pins;
Pin = CurrentCmp->m_Pins; for( ; Pin != NULL; Pin = Pin->Pnext )
for( ; Pin != NULL; Pin = Pin->Pnext ) {
{ if( Pin->m_PinNet != OldName )
if( Pin->m_PinNet != OldName ) continue; continue;
Pin->m_PinNet = NewName; Pin->m_PinNet = NewName;
} }
} }
} }
...@@ -19,20 +19,19 @@ ...@@ -19,20 +19,19 @@
/* routines locales : */ /* routines locales : */
/**********************************************************/
void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package )
/*********************************************************/
/* /*
* - Affecte un module au composant selectionne * - Affecte un module au composant selectionne
* - Selectionne le composant suivant * - Selectionne le composant suivant
*/ */
void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package )
{ {
STORECMP* Composant; COMPONENT_LIST::iterator i;
int ii, NumCmp, IsNew = 1; COMPONENT* Component;
wxString Line; bool isUndefined = false;
int NumCmp;
wxString Line;
if( g_BaseListeCmp == NULL ) if( m_components.empty() )
return; return;
NumCmp = m_ListCmp->GetSelection(); NumCmp = m_ListCmp->GetSelection();
...@@ -42,26 +41,22 @@ void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package ) ...@@ -42,26 +41,22 @@ void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package )
m_ListCmp->SetSelection( NumCmp, TRUE ); m_ListCmp->SetSelection( NumCmp, TRUE );
} }
Composant = g_BaseListeCmp; Component = m_components[ NumCmp ];
for( ii = 0; Composant != NULL; Composant = Composant->Pnext, ii++ )
{
if( NumCmp == ii )
break;
}
if( Composant == NULL ) if( Component == NULL )
return; return;
if( !Composant->m_Module.IsEmpty() )
IsNew = 0;
Composant->m_Module = package; isUndefined = Component->m_Module.IsEmpty();
Component->m_Module = package;
Line.Printf( CMP_FORMAT, ii + 1, Line.Printf( CMP_FORMAT, NumCmp + 1,
Composant->m_Reference.GetData(), Composant->m_Valeur.GetData(), Component->m_Reference.GetData(), Component->m_Valeur.GetData(),
Composant->m_Module.GetData() ); Component->m_Module.GetData() );
modified = 1; m_modified = true;
if( IsNew )
composants_non_affectes -= 1; if( isUndefined )
m_undefinedComponentCnt -= 1;
m_ListCmp->SetString( NumCmp, Line ); m_ListCmp->SetString( NumCmp, Line );
m_ListCmp->SetSelection( NumCmp, FALSE ); m_ListCmp->SetSelection( NumCmp, FALSE );
...@@ -72,22 +67,21 @@ void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package ) ...@@ -72,22 +67,21 @@ void WinEDA_CvpcbFrame::SetNewPkg( const wxString& package )
m_ListCmp->SetSelection( NumCmp, TRUE ); m_ListCmp->SetSelection( NumCmp, TRUE );
Line.Printf( _( "Components: %d (free: %d)" ), Line.Printf( _( "Components: %d (free: %d)" ),
nbcomp, composants_non_affectes ); m_components.GetCount(), m_undefinedComponentCnt );
SetStatusText( Line, 1 ); SetStatusText( Line, 1 );
} }
/********************************************/
bool WinEDA_CvpcbFrame::ReadNetList()
/*******************************************/
/* Lecture de la netliste selon format, ainsi que du fichier des composants /*
* Lecture de la netliste selon format, ainsi que du fichier des composants
*/ */
bool WinEDA_CvpcbFrame::ReadNetList()
{ {
STORECMP* Composant; COMPONENT_LIST::iterator i;
wxString msg; COMPONENT* Component;
int ii; wxString msg;
int error_level; int error_level;
error_level = ReadSchematicNetlist(); error_level = ReadSchematicNetlist();
...@@ -101,36 +95,35 @@ bool WinEDA_CvpcbFrame::ReadNetList() ...@@ -101,36 +95,35 @@ bool WinEDA_CvpcbFrame::ReadNetList()
} }
/* lecture des correspondances */ /* lecture des correspondances */
loadcmp( m_NetlistFileName.GetFullPath() ); LoadComponentFile( m_NetlistFileName.GetFullPath(), m_components );
if( m_ListCmp == NULL ) if( m_ListCmp == NULL )
return false; return false;
Read_Config( m_NetlistFileName.GetFullPath() ); LoadProjectFile( m_NetlistFileName.GetFullPath() );
LoadFootprintFiles( m_ModuleLibNames, m_footprints );
listlib();
BuildFootprintListBox(); BuildFootprintListBox();
m_ListCmp->Clear(); m_ListCmp->Clear();
Composant = g_BaseListeCmp;
composants_non_affectes = 0; m_undefinedComponentCnt = 0;
for( ii = 1; Composant != NULL; Composant = Composant->Pnext, ii++ ) for( i = m_components.begin(); i != m_components.end(); ++i )
{ {
msg.Printf( CMP_FORMAT, ii, Component = *i;
Composant->m_Reference.GetData(), msg.Printf( CMP_FORMAT, m_ListCmp->GetCount() + 1,
Composant->m_Valeur.GetData(), Component->m_Reference.GetData(),
Composant->m_Module.GetData() ); Component->m_Valeur.GetData(),
Component->m_Module.GetData() );
m_ListCmp->AppendLine( msg ); m_ListCmp->AppendLine( msg );
if( Composant->m_Module.IsEmpty() ) if( Component->m_Module.IsEmpty() )
composants_non_affectes += 1; m_undefinedComponentCnt += 1;
} }
if( g_BaseListeCmp ) if( !m_components.empty() )
m_ListCmp->SetSelection( 0, TRUE ); m_ListCmp->SetSelection( 0, TRUE );
msg.Printf( _( "Components: %d (free: %d)" ), nbcomp, msg.Printf( _( "Components: %d (free: %d)" ), m_components.GetCount(),
composants_non_affectes ); m_undefinedComponentCnt );
SetStatusText( msg, 1 ); SetStatusText( msg, 1 );
/* Mise a jour du titre de la fenetre principale */ /* Mise a jour du titre de la fenetre principale */
...@@ -140,14 +133,12 @@ bool WinEDA_CvpcbFrame::ReadNetList() ...@@ -140,14 +133,12 @@ bool WinEDA_CvpcbFrame::ReadNetList()
} }
/*****************************************************************/ /*
int WinEDA_CvpcbFrame::SaveNetList( const wxString& fileName ) * Sauvegarde des fichiers netliste et cmp
/*****************************************************************/
/* Sauvegarde des fichiers netliste et cmp
* Le nom complet du fichier Netliste doit etre dans FFileName. * Le nom complet du fichier Netliste doit etre dans FFileName.
* Le nom du fichier cmp en est deduit * Le nom du fichier cmp en est deduit
*/ */
int WinEDA_CvpcbFrame::SaveNetList( const wxString& fileName )
{ {
wxFileName fn; wxFileName fn;
...@@ -177,7 +168,8 @@ int WinEDA_CvpcbFrame::SaveNetList( const wxString& fileName ) ...@@ -177,7 +168,8 @@ int WinEDA_CvpcbFrame::SaveNetList( const wxString& fileName )
return 0; return 0;
} }
GenNetlistPcbnew( netlist ); GenNetlistPcbnew( netlist, m_components, m_isEESchemaNetlist,
m_rightJustify );
return 1; return 1;
} }
This diff is collapsed.
...@@ -20,16 +20,11 @@ ...@@ -20,16 +20,11 @@
#include "protos.h" #include "protos.h"
/* routines locales : */ /* routines locales : */
static void ReadDocLib( const wxString& ModLibName ); static void ReadDocLib( const wxString& ModLibName, FOOTPRINT_LIST& list );
static int LibCompare( void* mod1, void* mod2 );
static STOREMOD* TriListeModules( STOREMOD* BaseListe, int nbitems );
/*********************/ /**
bool listlib() * Routine lisant la liste des librairies, et generant la liste chainee
/*********************/
/* Routine lisant la liste des librairies, et generant la liste chainee
* des modules disponibles * des modules disponibles
* *
* Module descr format: * Module descr format:
...@@ -40,22 +35,25 @@ bool listlib() ...@@ -40,22 +35,25 @@ bool listlib()
* $EndMODULE * $EndMODULE
* *
*/ */
bool LoadFootprintFiles( const wxArrayString& libNames,
FOOTPRINT_LIST& list )
{ {
FILE* file; /* pour lecture librairie */ FILE* file; /* pour lecture librairie */
char buffer[1024]; char buffer[1024];
wxFileName fn; wxFileName fn;
int end; int end;
STOREMOD* ItemLib; FOOTPRINT* ItemLib;
unsigned ii; unsigned ii;
wxString tmp, msg; wxString tmp, msg;
if( g_BaseListePkg ) /* Liste Deja existante, a supprimer */ if( !list.empty() )
{ {
FreeMemoryModules(); list.DeleteContents( true );
g_BaseListePkg = NULL; list.Clear();
list.DeleteContents( false );
} }
if( g_LibName_List.GetCount() == 0 ) if( libNames.GetCount() == 0 )
{ {
wxMessageBox( _( "No PCB foot print libraries are listed in the " \ wxMessageBox( _( "No PCB foot print libraries are listed in the " \
"current project file." ), _( "Project File Error" ), "current project file." ), _( "Project File Error" ),
...@@ -63,13 +61,11 @@ bool listlib() ...@@ -63,13 +61,11 @@ bool listlib()
return false; return false;
} }
nblib = 0;
/* Lecture des Librairies */ /* Lecture des Librairies */
for( ii = 0; ii < g_LibName_List.GetCount(); ii++ ) for( ii = 0; ii < libNames.GetCount(); ii++ )
{ {
/* Calcul du nom complet de la librairie */ /* Calcul du nom complet de la librairie */
fn = g_LibName_List[ii]; fn = libNames[ii];
fn.SetExt( ModuleFileExtension ); fn.SetExt( ModuleFileExtension );
tmp = wxGetApp().FindLibraryPath( fn ); tmp = wxGetApp().FindLibraryPath( fn );
...@@ -122,12 +118,10 @@ bool listlib() ...@@ -122,12 +118,10 @@ bool listlib()
break; break;
} }
ItemLib = new STOREMOD(); ItemLib = new FOOTPRINT();
ItemLib->Pnext = g_BaseListePkg; ItemLib->m_Module = CONV_FROM_UTF8( StrPurge( buffer ) );
g_BaseListePkg = ItemLib;
ItemLib->m_Module = CONV_FROM_UTF8( StrPurge( buffer ) );
ItemLib->m_LibName = tmp; ItemLib->m_LibName = tmp;
nblib++; list.push_back( ItemLib );
} }
if( !end ) if( !end )
...@@ -141,104 +135,29 @@ bool listlib() ...@@ -141,104 +135,29 @@ bool listlib()
} }
fclose( file ); fclose( file );
ReadDocLib( tmp ); ReadDocLib( tmp, list );
} }
/* classement alphabetique: */ list.Sort( compare );
if( g_BaseListePkg )
g_BaseListePkg = TriListeModules( g_BaseListePkg, nblib );
return true; return true;
} }
/************************************************/
static int LibCompare( void* mod1, void* mod2 )
/************************************************/
/*
* routine compare() pour qsort() en classement alphabtique des modules
*/
{
int ii;
STOREMOD* pt1, * pt2;
pt1 = *( (STOREMOD**) mod1 );
pt2 = *( (STOREMOD**) mod2 );
ii = StrNumICmp( pt1->m_Module.GetData(), pt2->m_Module.GetData() );
return ii;
}
/********************************************************************/
static STOREMOD* TriListeModules( STOREMOD* BaseListe, int nbitems )
/********************************************************************/
/* Tri la liste des Modules par ordre alphabetique et met a jour
* le nouveau chainage avant/arriere
* retourne un pointeur sur le 1er element de la liste
*/
{
STOREMOD** bufferptr, * Item;
int ii, nb;
if( nbitems <= 0 )
return NULL;
if( BaseListe == NULL )
return NULL;
if( nbitems == 1 )
return BaseListe; // Tri inutile et impossible
bufferptr = (STOREMOD**) MyZMalloc( (nbitems + 3) * sizeof(STOREMOD*) );
for( ii = 1, nb = 0, Item = BaseListe;
Item != NULL;
Item = Item->Pnext, ii++ )
{
nb++;
bufferptr[ii] = Item;
}
/* ici bufferptr[0] = NULL et bufferptr[nbitem+1] = NULL et ces 2 valeurs
* representent le chainage arriere du 1er element ( = NULL),
* et le chainage avant du dernier element ( = NULL ) */
qsort( bufferptr + 1, nb, sizeof(STOREMOD*),
( int( * ) ( const void*, const void* ) )LibCompare );
/* Mise a jour du chainage */
for( ii = 1; ii <= nb; ii++ )
{
Item = bufferptr[ii];
Item->m_Num = ii;
Item->Pnext = bufferptr[ii + 1];
Item->Pback = bufferptr[ii - 1];
}
Item = bufferptr[1];
MyFree( bufferptr );
return Item;
}
/***************************************************/
static void ReadDocLib( const wxString& ModLibName )
/***************************************************/
/* Routine de lecture du fichier Doc associe a la librairie ModLibName. /* Routine de lecture du fichier Doc associe a la librairie ModLibName.
* Cree en memoire la chaine liste des docs pointee par MList * Cree en memoire la chaine liste des docs pointee par MList
* ModLibName = full file Name de la librairie Modules * ModLibName = full file Name de la librairie Modules
*/ */
static void ReadDocLib( const wxString& ModLibName, FOOTPRINT_LIST& list )
{ {
STOREMOD* NewMod; FOOTPRINT* NewMod;
char Line[1024]; FOOTPRINT* tmp;
wxString ModuleName; char Line[1024];
wxString msg; wxString ModuleName;
FILE* LibDoc; wxString msg;
FILE* LibDoc;
wxFileName fn = ModLibName; wxFileName fn = ModLibName;
FOOTPRINT_LIST::iterator i;
fn.SetExt( wxT( "mdc" ) ); fn.SetExt( wxT( "mdc" ) );
...@@ -277,12 +196,15 @@ static void ReadDocLib( const wxString& ModLibName ) ...@@ -277,12 +196,15 @@ static void ReadDocLib( const wxString& ModLibName )
{ {
case 'L': /* LibName */ case 'L': /* LibName */
ModuleName = CONV_FROM_UTF8( StrPurge( Line + 3 ) ); ModuleName = CONV_FROM_UTF8( StrPurge( Line + 3 ) );
NewMod = g_BaseListePkg; for( i = list.begin(); i != list.end(); ++i )
while( NewMod )
{ {
if( ModuleName == NewMod->m_Module ) tmp = *i;
if( ModuleName == tmp->m_Module )
{
NewMod = tmp;
break; break;
NewMod = NewMod->Pnext; }
} }
break; break;
...@@ -293,7 +215,7 @@ static void ReadDocLib( const wxString& ModLibName ) ...@@ -293,7 +215,7 @@ static void ReadDocLib( const wxString& ModLibName )
break; break;
case 'C': /* Doc */ case 'C': /* Doc */
if( NewMod && (!NewMod->m_Doc ) ) if( NewMod && ( !NewMod->m_Doc ) )
NewMod->m_Doc = CONV_FROM_UTF8( StrPurge( Line + 3 ) ); NewMod->m_Doc = CONV_FROM_UTF8( StrPurge( Line + 3 ) );
break; break;
} }
......
...@@ -35,11 +35,12 @@ MODULE* WinEDA_DisplayFrame::Get_Module( const wxString& CmpName ) ...@@ -35,11 +35,12 @@ MODULE* WinEDA_DisplayFrame::Get_Module( const wxString& CmpName )
wxString tmp, msg; wxString tmp, msg;
wxFileName fn; wxFileName fn;
MODULE* Module = NULL; MODULE* Module = NULL;
WinEDA_CvpcbFrame* parent = ( WinEDA_CvpcbFrame* ) GetParent();
for( ii = 0; ii < g_LibName_List.GetCount(); ii++ ) for( ii = 0; ii < parent->m_ModuleLibNames.GetCount(); ii++ )
{ {
/* Calcul du nom complet de la librairie */ /* Calcul du nom complet de la librairie */
fn = g_LibName_List[ii]; fn = parent->m_ModuleLibNames[ii];
fn.SetExt( ModuleFileExtension ); fn.SetExt( ModuleFileExtension );
tmp = wxGetApp().FindLibraryPath( fn ); tmp = wxGetApp().FindLibraryPath( fn );
......
/**********************************************/
/* Routines de gestion de la memoire */
/**********************************************/
/* Fichier memoire.cpp */
#include "fctsys.h"
#include "wxstruct.h"
#include "common.h"
#include "cvpcb.h"
/********************************/
void FreeMemoryModules()
/********************************/
/* Routine de liberation memoire de la liste des modules
- remet a NULL g_BaseListePkg
- remet a 0 nblib;
*/
{
STOREMOD * Module, * NextMod;
if( g_BaseListePkg == NULL) return;
for ( Module = g_BaseListePkg; Module != NULL; Module = NextMod)
{
NextMod = Module->Pnext;
delete Module;
}
nblib = 0;
g_BaseListePkg = NULL;
}
/***********************************/
void FreeMemoryComponents()
/***********************************/
/* Routine de liberation memoire de la liste des composants
- remet a NULL BaseListeMod
- remet a 0 nbcomp
*/
{
STORECMP * Cmp, * NextCmp;
if( g_BaseListeCmp == NULL ) return;
for( Cmp = g_BaseListeCmp; Cmp != NULL; Cmp = NextCmp )
{
NextCmp = Cmp->Pnext;
delete Cmp;
}
nbcomp = 0;
g_BaseListeCmp = NULL;
}
...@@ -62,15 +62,18 @@ void WinEDA_CvpcbFrame::ReCreateMenuBar() ...@@ -62,15 +62,18 @@ void WinEDA_CvpcbFrame::ReCreateMenuBar()
item->SetBitmap( config_xpm ); item->SetBitmap( config_xpm );
configmenu->Append( item ); configmenu->Append( item );
// Font selection and setup
AddFontSelectionMenu( configmenu );
wxGetApp().AddMenuLanguageList( configmenu ); wxGetApp().AddMenuLanguageList( configmenu );
item = new wxMenuItem( configmenu, ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE,
_( "Keep Open On Save" ),
_( "Prevent CVPcb from exiting after saving " \
"netlist file" ),
wxITEM_CHECK );
configmenu->Append( item );
configmenu->AppendSeparator(); configmenu->AppendSeparator();
item = new wxMenuItem( configmenu, ID_CONFIG_SAVE, item = new wxMenuItem( configmenu, ID_CONFIG_SAVE,
_( "&Save config" ), _( "&Save Project File" ),
_( "Save configuration in current dir" ) ); _( "Save changes to the project file" ) );
item->SetBitmap( save_setup_xpm ); item->SetBitmap( save_setup_xpm );
configmenu->Append( item ); configmenu->Append( item );
......
...@@ -5,32 +5,16 @@ ...@@ -5,32 +5,16 @@
#ifndef PROTOS_H #ifndef PROTOS_H
#define PROTOS_H #define PROTOS_H
int GenNetlistPcbnew( FILE* f ) ; extern int GenNetlistPcbnew( FILE* f, COMPONENT_LIST& list,
bool loadcmp( const wxString& fileName ) ; bool isEESchemaNetlist = true,
bool listlib() ; bool rightJustify = false );
extern bool LoadComponentFile( const wxString& fileName,
STOREMOD * GetModuleDescrByName(const wxString & FootprintName); COMPONENT_LIST& list );
extern bool LoadFootprintFiles( const wxArrayString& libNames,
FOOTPRINT_LIST& list );
/***********/
/* CFG.CPP */ FOOTPRINT* GetModuleDescrByName( const wxString& FootprintName,
/***********/ FOOTPRINT_LIST& list );
void Save_Config( wxWindow* parent, const wxString& fileName );
void Read_Config( const wxString & FullFileName ); /* lit la configuration */
/***************/
/* MEMOIRE.CPP */
/***************/
void FreeMemoryComponents();
/* Routine de liberation memoire de la liste des composants
- remet a NULL BaseListeMod
- remet a 0 NbComp */
void FreeMemoryModules();
/* Routine de liberation memoire de la liste des modules
- remet a NULL g_BaseListePkg
- rement a 0 NbLib; */
#endif // PROTOS_H #endif // PROTOS_H
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* readschematicnetlist.cpp */ /* readschematicnetlist.cpp */
/****************************/ /****************************/
/* Read a nelist type Eeschema or OrcadPCB2 and buid the component list /* Read a nelist type Eeschema or OrcadPCB2 and build the component list
* Manages the lines like : * Manages the lines like :
* ( XXXXXX VALEUR|(pin1,pin2,...=newalim) ID VALEUR * ( XXXXXX VALEUR|(pin1,pin2,...=newalim) ID VALEUR
*/ */
...@@ -23,20 +23,16 @@ ...@@ -23,20 +23,16 @@
/* routines locales : */ /* routines locales : */
static int ReadPinConnection( FILE* f, STORECMP* CurrentCmp ); static int ReadPinConnection( FILE* f, COMPONENT* CurrentCmp );
static int CmpCompare( void* cmp1, void* cmp2 ); /* routine pour qsort() de tri de liste des composants */
static STORECMP* TriListeComposants( STORECMP* BaseListe, int nbitems );
/* Tri la liste des composants par ordre alphabetique et met a jour le nouveau chainage avant/arriere /* Tri la liste des composants par ordre alphabetique et met a jour le nouveau
* retourne un pointeur sur le 1er element de la liste */ * chainage avant/arriere retourne un pointeur sur le 1er element de la liste */
#define BUFFER_CHAR_SIZE 1024 // Size of buffers used to store netlist datas #define BUFFER_CHAR_SIZE 1024 // Size of buffers used to store netlist data
/************************************************/
int WinEDA_CvpcbFrame::ReadSchematicNetlist()
/************************************************/
/** Function ReadSchematicNetlist /**
* Function ReadSchematicNetlist
* Read a Eeschema (or OrcadPCB) netlist * Read a Eeschema (or OrcadPCB) netlist
* like: * like:
* # EESchema Netlist Version 1.1 created 15/5/2008-12:09:21 * # EESchema Netlist Version 1.1 created 15/5/2008-12:09:21
...@@ -87,26 +83,30 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist() ...@@ -87,26 +83,30 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()
* $endfootprintlist * $endfootprintlist
* } * }
*/ */
int WinEDA_CvpcbFrame::ReadSchematicNetlist()
{ {
char alim[1024]; char alim[1024];
int i, k, l; int i, k, l;
char* LibName; char* LibName;
char Line[BUFFER_CHAR_SIZE + 1]; char Line[BUFFER_CHAR_SIZE + 1];
wxString component_reference; /* buffer for component reference (U1, R4...) */ wxString component_reference; /* buffer for component reference (U1, R4...) */
wxString schematic_timestamp; /* buffer for component time stamp */ wxString schematic_timestamp; /* buffer for component time stamp */
wxString footprint_name; /* buffer for component footprint field */ wxString footprint_name; /* buffer for component footprint field */
wxString component_value; /* buffer for component values (470K, 22nF ...) */ wxString component_value; /* buffer for component values (470K, 22nF ...) */
char* ptchar; char* ptchar;
STORECMP* Cmp; COMPONENT* Cmp;
FILE* source; FILE* source;
modified = 0; m_modified = false;
Rjustify = 0; m_isEESchemaNetlist = false;
g_FlagEESchema = FALSE;
/* Clear components buffer */ /* Clear components buffer */
if( g_BaseListeCmp ) if( !m_components.empty() )
FreeMemoryComponents(); {
m_components.DeleteContents( true );
m_components.Clear();
m_components.DeleteContents( false );
}
source = wxFopen( m_NetlistFileName.GetFullPath(), wxT( "rt" ) ); source = wxFopen( m_NetlistFileName.GetFullPath(), wxT( "rt" ) );
...@@ -129,7 +129,7 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist() ...@@ -129,7 +129,7 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()
{ {
i = strnicmp( Line, "# EESchema", 7 ); /* net type EESchema */ i = strnicmp( Line, "# EESchema", 7 ); /* net type EESchema */
if( i == 0 ) if( i == 0 )
g_FlagEESchema = TRUE; m_isEESchemaNetlist = TRUE;
} }
if( i != 0 ) if( i != 0 )
...@@ -143,7 +143,7 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist() ...@@ -143,7 +143,7 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()
SetStatusText( _( "Netlist Format: EESchema" ), 0 ); SetStatusText( _( "Netlist Format: EESchema" ), 0 );
/* Read the netlit */ /* Read the netlist */
for( ; ; ) for( ; ; )
{ {
/* Search the beginning of a component description */ /* Search the beginning of a component description */
...@@ -255,13 +255,12 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist() ...@@ -255,13 +255,12 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()
} }
/* Store info for this component */ /* Store info for this component */
Cmp = new STORECMP(); Cmp = new COMPONENT();
Cmp->Pnext = g_BaseListeCmp;
g_BaseListeCmp = Cmp;
Cmp->m_Reference = component_reference; Cmp->m_Reference = component_reference;
Cmp->m_Valeur = component_value; Cmp->m_Valeur = component_value;
m_components.push_back( Cmp );
if( g_FlagEESchema ) /* copy footprint name: */ if( m_isEESchemaNetlist ) /* copy footprint name: */
{ {
if( strnicmp( LibName, "$noname", 7 ) != 0 ) if( strnicmp( LibName, "$noname", 7 ) != 0 )
{ {
...@@ -275,26 +274,22 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist() ...@@ -275,26 +274,22 @@ int WinEDA_CvpcbFrame::ReadSchematicNetlist()
Cmp->m_TimeStamp = schematic_timestamp; Cmp->m_TimeStamp = schematic_timestamp;
ReadPinConnection( source, Cmp ); ReadPinConnection( source, Cmp );
nbcomp++;
} }
fclose( source ); fclose( source );
/* Alpabetic sorting : */ m_components.Sort( compare );
g_BaseListeCmp = TriListeComposants( g_BaseListeCmp, nbcomp );
return 0; return 0;
} }
/********************************************************/
int WinEDA_CvpcbFrame::ReadFootprintFilterList( FILE* f ) int WinEDA_CvpcbFrame::ReadFootprintFilterList( FILE* f )
/********************************************************/
{ {
char Line[BUFFER_CHAR_SIZE + 1]; COMPONENT_LIST::iterator i;
wxString CmpRef; char Line[BUFFER_CHAR_SIZE + 1];
STORECMP* Cmp = NULL; wxString CmpRef;
COMPONENT* Cmp = NULL;
for( ; ; ) for( ; ; )
{ {
...@@ -313,9 +308,12 @@ int WinEDA_CvpcbFrame::ReadFootprintFilterList( FILE* f ) ...@@ -313,9 +308,12 @@ int WinEDA_CvpcbFrame::ReadFootprintFilterList( FILE* f )
CmpRef = CONV_FROM_UTF8( Line + 11 ); CmpRef = CONV_FROM_UTF8( Line + 11 );
CmpRef.Trim( TRUE ); CmpRef.Trim( TRUE );
CmpRef.Trim( FALSE ); CmpRef.Trim( FALSE );
/* Search the new component in list */ /* Search the new component in list */
for( Cmp = g_BaseListeCmp; Cmp != NULL; Cmp = Cmp->Pnext ) for( i = m_components.begin(); i != m_components.end(); ++i )
{ {
Cmp = *i;
if( Cmp->m_Reference == CmpRef ) if( Cmp->m_Reference == CmpRef )
break; break;
} }
...@@ -333,16 +331,13 @@ int WinEDA_CvpcbFrame::ReadFootprintFilterList( FILE* f ) ...@@ -333,16 +331,13 @@ int WinEDA_CvpcbFrame::ReadFootprintFilterList( FILE* f )
} }
/***********************************/ int ReadPinConnection( FILE* f, COMPONENT* Cmp )
int ReadPinConnection( FILE* f, STORECMP* Cmp )
/***********************************/
{ {
int i, jj; int i, jj;
wxString numpin; wxString numpin;
wxString net; wxString net;
char Line[BUFFER_CHAR_SIZE + 1]; char Line[BUFFER_CHAR_SIZE + 1];
STOREPIN* Pin = NULL; PIN* Pin = NULL;
STOREPIN** LastPin = &Cmp->m_Pins;
for( ; ; ) for( ; ; )
{ {
...@@ -392,69 +387,10 @@ int ReadPinConnection( FILE* f, STORECMP* Cmp ) ...@@ -392,69 +387,10 @@ int ReadPinConnection( FILE* f, STORECMP* Cmp )
net.Append( Line[i] ); net.Append( Line[i] );
} }
Pin = new STOREPIN(); Pin = new PIN();
*LastPin = Pin;
LastPin = &Pin->Pnext;
Pin->m_PinNum = numpin; Pin->m_PinNum = numpin;
Pin->m_PinNet = net; Pin->m_PinNet = net;
Cmp->m_Pins.push_back( Pin );
} }
} }
} }
/****************************************************************/
STORECMP* TriListeComposants( STORECMP* BaseListe, int nbitems )
/****************************************************************/
/* Sort the component list( this is a linked list)
* retourn the beginning of the list
*/
{
STORECMP** bufferptr, * Item;
int ii;
if( nbitems <= 0 )
return NULL;
bufferptr = (STORECMP**) MyZMalloc( (nbitems + 2) * sizeof(STORECMP*) );
for( ii = 1, Item = BaseListe; Item != NULL; Item = Item->Pnext, ii++ )
{
bufferptr[ii] = Item;
}
/* Here: bufferptr[0] = NULL and bufferptr[nbitem+1] = NULL.
* These 2 values are the first item back link, and the last item forward link
*/
qsort( bufferptr + 1, nbitems, sizeof(STORECMP*),
( int( * ) ( const void*, const void* ) )CmpCompare );
/* Update linked list */
for( ii = 1; ii <= nbitems; ii++ )
{
Item = bufferptr[ii];
Item->m_Num = ii;
Item->Pnext = bufferptr[ii + 1];
Item->Pback = bufferptr[ii - 1];
}
return bufferptr[1];
}
/****************************************/
int CmpCompare( void* mod1, void* mod2 )
/****************************************/
/*
* Compare function for qsort() : alphabetic sorting, with numbering order
*/
{
int ii;
STORECMP* pt1, * pt2;
pt1 = *( (STORECMP**) mod1 );
pt2 = *( (STORECMP**) mod2 );
ii = StrNumICmp( pt1->m_Reference.GetData(), pt2->m_Reference.GetData() );
return ii;
}
...@@ -24,19 +24,19 @@ char EnteteCmpMod[] = { "Cmp-Mod V01" }; ...@@ -24,19 +24,19 @@ char EnteteCmpMod[] = { "Cmp-Mod V01" };
const wxString titleComponentLibErr( _( "Component Library Error" ) ); const wxString titleComponentLibErr( _( "Component Library Error" ) );
/*****************************************************************************/ /*
/* Routine de sauvegarde du fichier des modules * Routine de sauvegarde du fichier des modules
* Retourne 1 si OK * Retourne 1 si OK
* 0 si ecriture non faite * 0 si ecriture non faite
*/ */
/****************************************************************************/
int WinEDA_CvpcbFrame::SaveComponentList( const wxString& NetlistFullFileName ) int WinEDA_CvpcbFrame::SaveComponentList( const wxString& NetlistFullFileName )
{ {
STORECMP* Cmp; COMPONENT_LIST::iterator i;
FILE* dest; COMPONENT* Cmp;
wxFileName fn( NetlistFullFileName ); FILE* dest;
char Line[1024]; wxFileName fn( NetlistFullFileName );
wxString Title = wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion(); char Line[1024];
wxString Title = wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion();
/* calcul du nom du fichier */ /* calcul du nom du fichier */
fn.SetExt( ComponentFileExtension ); fn.SetExt( ComponentFileExtension );
...@@ -49,8 +49,9 @@ int WinEDA_CvpcbFrame::SaveComponentList( const wxString& NetlistFullFileName ) ...@@ -49,8 +49,9 @@ int WinEDA_CvpcbFrame::SaveComponentList( const wxString& NetlistFullFileName )
fprintf( dest, " Created by %s", CONV_TO_UTF8( Title ) ); fprintf( dest, " Created by %s", CONV_TO_UTF8( Title ) );
fprintf( dest, " date = %s\n", DateAndTime( Line ) ); fprintf( dest, " date = %s\n", DateAndTime( Line ) );
for( Cmp = g_BaseListeCmp; Cmp != NULL; Cmp = Cmp->Pnext ) for( i = m_components.begin(); i != m_components.end(); ++i )
{ {
Cmp = *i;
fprintf( dest, "\nBeginCmp\n" ); fprintf( dest, "\nBeginCmp\n" );
fprintf( dest, "TimeStamp = %s;\n", CONV_TO_UTF8( Cmp->m_TimeStamp ) ); fprintf( dest, "TimeStamp = %s;\n", CONV_TO_UTF8( Cmp->m_TimeStamp ) );
fprintf( dest, "Reference = %s;\n", CONV_TO_UTF8( Cmp->m_Reference ) ); fprintf( dest, "Reference = %s;\n", CONV_TO_UTF8( Cmp->m_Reference ) );
...@@ -61,23 +62,22 @@ int WinEDA_CvpcbFrame::SaveComponentList( const wxString& NetlistFullFileName ) ...@@ -61,23 +62,22 @@ int WinEDA_CvpcbFrame::SaveComponentList( const wxString& NetlistFullFileName )
fprintf( dest, "\nEndListe\n" ); fprintf( dest, "\nEndListe\n" );
fclose( dest ); fclose( dest );
return 1; return 1;
} }
/***************/ /*
/* recupere la liste des associations composants/empreintes * recupere la liste des associations composants/empreintes
*/ */
/****************/ bool LoadComponentFile( const wxString& fileName, COMPONENT_LIST& list )
bool loadcmp( const wxString& fileName )
{ {
wxString timestamp, valeur, ilib, namecmp, msg; COMPONENT_LIST::iterator i;
bool read_cmp_data = FALSE, eof = FALSE; wxString timestamp, valeur, ilib, namecmp, msg;
STORECMP* Cmp; bool read_cmp_data = FALSE, eof = FALSE;
char Line[1024], * ident, * data; COMPONENT* Cmp;
FILE* source; char Line[1024], * ident, * data;
wxFileName fn = fileName; FILE* source;
wxFileName fn = fileName;
/* calcul du nom du fichier */ /* calcul du nom du fichier */
fn.SetExt( ComponentFileExtension ); fn.SetExt( ComponentFileExtension );
...@@ -176,8 +176,10 @@ bool loadcmp( const wxString& fileName ) ...@@ -176,8 +176,10 @@ bool loadcmp( const wxString& fileName )
/* Recherche du composant correspondant en netliste et /* Recherche du composant correspondant en netliste et
* mise a jour de ses parametres */ * mise a jour de ses parametres */
for( Cmp = g_BaseListeCmp; Cmp != NULL; Cmp = Cmp->Pnext ) for( i = list.begin(); i != list.end(); ++i )
{ {
Cmp = *i;
if( namecmp != Cmp->m_Reference ) if( namecmp != Cmp->m_Reference )
continue; continue;
......
...@@ -43,7 +43,7 @@ void WinEDA_CvpcbFrame::CreateScreenCmp() ...@@ -43,7 +43,7 @@ void WinEDA_CvpcbFrame::CreateScreenCmp()
{ {
msg = _( "Footprint: " ) + FootprintName; msg = _( "Footprint: " ) + FootprintName;
DrawFrame->SetTitle( msg ); DrawFrame->SetTitle( msg );
STOREMOD* Module = GetModuleDescrByName( FootprintName ); FOOTPRINT* Module = GetModuleDescrByName( FootprintName, m_footprints );
msg = _( "Lib: " ); msg = _( "Lib: " );
if( Module ) if( Module )
......
This diff is collapsed.
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include <wx/docview.h> #include <wx/docview.h>
#include <wx/config.h> #include <wx/config.h>
#include <wx/filename.h> #include <wx/filename.h>
#include "param_config.h"
enum id_app_type { enum id_app_type {
APP_TYPE_UNKOWN, APP_TYPE_UNKOWN,
...@@ -26,7 +28,6 @@ enum id_app_type { ...@@ -26,7 +28,6 @@ enum id_app_type {
class wxConfigBase; class wxConfigBase;
class wxFileConfig; class wxFileConfig;
class PARAM_CFG_BASE;
class wxSingleInstanceChecker; class wxSingleInstanceChecker;
class wxHtmlHelpController; class wxHtmlHelpController;
...@@ -120,6 +121,9 @@ public: ...@@ -120,6 +121,9 @@ public:
void WriteProjectConfig( const wxString& local_config_filename, void WriteProjectConfig( const wxString& local_config_filename,
const wxString& GroupName, const wxString& GroupName,
PARAM_CFG_BASE** List ); PARAM_CFG_BASE** List );
void WriteProjectConfig( const wxString& fileName,
const wxString& GroupName,
const PARAM_CFG_ARRAY& params );
/** Function SaveCurrentSetupValues() /** Function SaveCurrentSetupValues()
* Save the current setup values in m_EDA_Config * Save the current setup values in m_EDA_Config
...@@ -136,7 +140,12 @@ public: ...@@ -136,7 +140,12 @@ public:
void ReadCurrentSetupValues( PARAM_CFG_BASE** aList ); void ReadCurrentSetupValues( PARAM_CFG_BASE** aList );
bool ReadProjectConfig( const wxString& local_config_filename, bool ReadProjectConfig( const wxString& local_config_filename,
const wxString& GroupName, PARAM_CFG_BASE** List, const wxString& GroupName,
PARAM_CFG_BASE** List,
bool Load_Only_if_New );
bool ReadProjectConfig( const wxString& local_config_filename,
const wxString& GroupName,
const PARAM_CFG_ARRAY& List,
bool Load_Only_if_New ); bool Load_Only_if_New );
bool ReCreatePrjConfig( const wxString& local_config_filename, bool ReCreatePrjConfig( const wxString& local_config_filename,
const wxString& GroupName, const wxString& GroupName,
......
...@@ -171,12 +171,14 @@ extern const wxString SchematicFileExtension; ...@@ -171,12 +171,14 @@ extern const wxString SchematicFileExtension;
extern const wxString BoardFileExtension; extern const wxString BoardFileExtension;
extern const wxString NetlistFileExtension; extern const wxString NetlistFileExtension;
extern const wxString GerberFileExtension; extern const wxString GerberFileExtension;
extern const wxString PdfFileExtension;
extern const wxString ProjectFileWildcard; extern const wxString ProjectFileWildcard;
extern const wxString SchematicFileWildcard; extern const wxString SchematicFileWildcard;
extern const wxString BoardFileWildcard; extern const wxString BoardFileWildcard;
extern const wxString NetlistFileWildcard; extern const wxString NetlistFileWildcard;
extern const wxString GerberFileWildcard; extern const wxString GerberFileWildcard;
extern const wxString PdfFileWildcard;
extern const wxString AllFilesWildcard; extern const wxString AllFilesWildcard;
......
...@@ -461,6 +461,7 @@ enum main_id { ...@@ -461,6 +461,7 @@ enum main_id {
ID_CVPCB_SHOW3D_FRAME, ID_CVPCB_SHOW3D_FRAME,
ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST, ID_CVPCB_FOOTPRINT_DISPLAY_FULL_LIST,
ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST, ID_CVPCB_FOOTPRINT_DISPLAY_FILTERED_LIST,
ID_CVPCB_CONFIG_KEEP_OPEN_ON_SAVE,
ID_CVPCB_UNUSED0, ID_CVPCB_UNUSED0,
ID_CVPCB_UNUSED1, ID_CVPCB_UNUSED1,
ID_CVPCB_UNUSED2, ID_CVPCB_UNUSED2,
......
...@@ -59,12 +59,10 @@ const wxChar* s_AllowedExtensionsToList[] = ...@@ -59,12 +59,10 @@ const wxChar* s_AllowedExtensionsToList[] =
/* File extension definitions. */ /* File extension definitions. */
const wxString PythonFileExtension( wxT( "py" ) ); const wxString PythonFileExtension( wxT( "py" ) );
const wxString PdfFileExtension( wxT( "pdf" ) );
const wxString TextFileExtension( wxT( "txt" ) ); const wxString TextFileExtension( wxT( "txt" ) );
/* File wildcard definitions. */ /* File wildcard definitions. */
const wxString PythonFileWildcard( wxT( "Python files (*.py)|*.py" ) ); const wxString PythonFileWildcard( wxT( "Python files (*.py)|*.py" ) );
const wxString PdfFileWildcard( wxT( "Portable document files (*.pdf)|*.pdf" ) );
const wxString TextFileWildcard( wxT( "Text files (*.txt)|*.txt" ) ); const wxString TextFileWildcard( wxT( "Text files (*.txt)|*.txt" ) );
......
...@@ -25,6 +25,11 @@ ...@@ -25,6 +25,11 @@
static const wxString UserGridSizeXEntry( wxT( "PcbUserGrid_X" ) ); static const wxString UserGridSizeXEntry( wxT( "PcbUserGrid_X" ) );
static const wxString UserGridSizeYEntry( wxT( "PcbUserGrid_Y" ) ); static const wxString UserGridSizeYEntry( wxT( "PcbUserGrid_Y" ) );
static const wxString UserGridUnitsEntry( wxT( "PcbUserGrid_Unit" ) ); static const wxString UserGridUnitsEntry( wxT( "PcbUserGrid_Unit" ) );
static const wxString DisplayPadFillEntry( wxT( "DiPadFi" ) );
static const wxString DisplayPadNumberEntry( wxT( "DiPadNu" ) );
static const wxString DisplayModuleEdgeEntry( wxT( "DiModEd" ) );
static const wxString DisplayModuleTextEntry( wxT( "DiModTx" ) );
/*******************************/ /*******************************/
/* class WinEDA_BasePcbFrame */ /* class WinEDA_BasePcbFrame */
...@@ -392,6 +397,16 @@ void WinEDA_BasePcbFrame::LoadSettings() ...@@ -392,6 +397,16 @@ void WinEDA_BasePcbFrame::LoadSettings()
cfg->Read( m_FrameName + UserGridSizeYEntry, &m_UserGridSize.y, 0.01 ); cfg->Read( m_FrameName + UserGridSizeYEntry, &m_UserGridSize.y, 0.01 );
cfg->Read( m_FrameName + UserGridUnitsEntry, &m_UserGridUnits, cfg->Read( m_FrameName + UserGridUnitsEntry, &m_UserGridUnits,
( long )INCHES ); ( long )INCHES );
cfg->Read( m_FrameName + DisplayPadFillEntry, &m_DisplayPadFill, true );
cfg->Read( m_FrameName + DisplayPadNumberEntry, &m_DisplayPadNum, true );
cfg->Read( m_FrameName + DisplayModuleEdgeEntry, &m_DisplayModEdge,
( long )FILLED );
if( m_DisplayModEdge < FILAIRE || m_DisplayModEdge > SKETCH )
m_DisplayModEdge = FILLED;
cfg->Read( m_FrameName + DisplayModuleTextEntry, &m_DisplayModText,
( long )FILLED );
if( m_DisplayModText < FILAIRE || m_DisplayModText > SKETCH )
m_DisplayModText = FILLED;
} }
...@@ -411,4 +426,8 @@ void WinEDA_BasePcbFrame::SaveSettings() ...@@ -411,4 +426,8 @@ void WinEDA_BasePcbFrame::SaveSettings()
cfg->Write( m_FrameName + UserGridSizeXEntry, m_UserGridSize.x ); cfg->Write( m_FrameName + UserGridSizeXEntry, m_UserGridSize.x );
cfg->Write( m_FrameName + UserGridSizeYEntry, m_UserGridSize.y ); cfg->Write( m_FrameName + UserGridSizeYEntry, m_UserGridSize.y );
cfg->Write( m_FrameName + UserGridUnitsEntry, ( long )m_UserGridUnits ); cfg->Write( m_FrameName + UserGridUnitsEntry, ( long )m_UserGridUnits );
cfg->Write( m_FrameName + DisplayPadFillEntry, m_DisplayPadFill );
cfg->Write( m_FrameName + DisplayPadNumberEntry, m_DisplayPadNum );
cfg->Write( m_FrameName + DisplayModuleEdgeEntry, ( long )m_DisplayModEdge );
cfg->Write( m_FrameName + DisplayModuleTextEntry, ( long )m_DisplayModText );
} }
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