2008-03-04 04:22:27 +00:00
|
|
|
/***************************************/
|
|
|
|
/** cfg.cpp : configuration de CVPCB **/
|
|
|
|
/***************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
/* lit ou met a jour la configuration de CVPCB */
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "appl_wxstruct.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "gestfich.h"
|
2009-04-23 15:02:18 +00:00
|
|
|
#include "param_config.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "cvpcb.h"
|
|
|
|
#include "protos.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "cvstruct.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2009-04-23 15:02:18 +00:00
|
|
|
#define GROUP wxT("/cvpcb")
|
|
|
|
#define GROUPLIB wxT("/pcbnew/libraries")
|
|
|
|
#define GROUPEQU wxT("/cvpcb/libraries")
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2009-04-23 15:02:18 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2009-05-21 17:42:42 +00:00
|
|
|
PARAM_CFG_ARRAY& WinEDA_CvpcbFrame::GetProjectFileParameters( void )
|
2009-04-23 15:02:18 +00:00
|
|
|
{
|
2009-05-21 17:42:42 +00:00
|
|
|
if( !m_projectFileParams.empty() )
|
2009-04-23 15:02:18 +00:00
|
|
|
return m_projectFileParams;
|
|
|
|
|
2009-05-21 17:42:42 +00:00
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_BASE( GROUPLIB,
|
|
|
|
PARAM_COMMAND_ERASE ) );
|
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_LIBNAME_LIST( wxT( "LibName" ),
|
|
|
|
&m_ModuleLibNames,
|
|
|
|
GROUPLIB ) );
|
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_LIBNAME_LIST( wxT( "EquName" ),
|
|
|
|
&m_AliasLibNames,
|
|
|
|
GROUPEQU ) );
|
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_WXSTRING( wxT( "NetIExt" ),
|
|
|
|
&m_NetlistFileExtension ) );
|
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_WXSTRING( wxT( "LibDir" ),
|
|
|
|
&m_UserLibraryPath,
|
|
|
|
GROUPLIB ) );
|
2009-04-23 15:02:18 +00:00
|
|
|
|
|
|
|
return m_projectFileParams;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* lit la configuration
|
2008-12-08 15:27:13 +00:00
|
|
|
* 1 - lit cvpcb.cnf
|
|
|
|
* 2 - si non trouve lit <chemin de cvpcb.exe>/cvpcb.cnf
|
|
|
|
* 3 - si non trouve: init des variables aux valeurs par defaut
|
2008-03-04 04:22:27 +00:00
|
|
|
*
|
2008-12-08 15:27:13 +00:00
|
|
|
* Remarque:
|
|
|
|
* le chemin de l'executable cvpcb.exe doit etre dans BinDir
|
2009-04-23 15:02:18 +00:00
|
|
|
*
|
2008-03-04 04:22:27 +00:00
|
|
|
*/
|
2009-04-23 15:02:18 +00:00
|
|
|
void WinEDA_CvpcbFrame::LoadProjectFile( const wxString& FileName )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
wxFileName fn = FileName;
|
2008-03-04 04:22:27 +00:00
|
|
|
|
|
|
|
/* Init des valeurs par defaut */
|
2009-04-23 15:02:18 +00:00
|
|
|
m_ModuleLibNames.Clear();
|
|
|
|
m_AliasLibNames.Clear();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
if( fn.GetExt() != ProjectFileExtension )
|
|
|
|
fn.SetExt( ProjectFileExtension );
|
|
|
|
|
2009-04-23 15:02:18 +00:00
|
|
|
wxGetApp().RemoveLibraryPath( m_UserLibraryPath );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-04-23 15:02:18 +00:00
|
|
|
wxGetApp().ReadProjectConfig( fn.GetFullPath(), GROUP,
|
|
|
|
GetProjectFileParameters(), FALSE );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-23 15:02:18 +00:00
|
|
|
if( m_NetlistFileExtension.IsEmpty() )
|
|
|
|
m_NetlistFileExtension = wxT( "net" );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-09 18:39:39 +00:00
|
|
|
/* User library path takes precedent over default library search paths. */
|
2009-04-23 15:02:18 +00:00
|
|
|
wxGetApp().InsertLibraryPath( m_UserLibraryPath, 1 );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* fonction relai d'appel a Save_Config,
|
2008-12-08 15:27:13 +00:00
|
|
|
* la vraie fonction de sauvegarde de la config
|
2008-03-04 04:22:27 +00:00
|
|
|
*/
|
2009-04-23 15:02:18 +00:00
|
|
|
void WinEDA_CvpcbFrame::Update_Config( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-04-23 15:02:18 +00:00
|
|
|
SaveProjectFile( m_NetlistFileName.GetFullPath() );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2009-04-23 15:02:18 +00:00
|
|
|
void WinEDA_CvpcbFrame::SaveProjectFile( const wxString& fileName )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
wxFileName fn = fileName;
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
fn.SetExt( ProjectFileExtension );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2009-04-23 15:02:18 +00:00
|
|
|
wxFileDialog dlg( this, _( "Save Project File" ), fn.GetPath(),
|
2009-04-05 20:49:15 +00:00
|
|
|
fn.GetFullName(), ProjectFileWildcard, wxFD_SAVE );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
2008-03-04 04:22:27 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* ecriture de la configuration */
|
2009-04-23 15:02:18 +00:00
|
|
|
wxGetApp().WriteProjectConfig( dlg.GetPath(), GROUP,
|
|
|
|
GetProjectFileParameters() );
|
2008-03-04 04:22:27 +00:00
|
|
|
}
|