2009-11-05 19:26:52 +00:00
|
|
|
/*************/
|
|
|
|
/** cfg.cpp **/
|
|
|
|
/*************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#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"
|
2011-02-05 16:15:48 +00:00
|
|
|
#include "cvpcb_mainframe.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.
|
|
|
|
*/
|
2011-02-05 16:15:48 +00:00
|
|
|
PARAM_CFG_ARRAY& CVPCB_MAINFRAME::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 ) );
|
2011-02-26 08:35:22 +00:00
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "LibDir" ),
|
2009-05-21 17:42:42 +00:00
|
|
|
&m_UserLibraryPath,
|
|
|
|
GROUPLIB ) );
|
2009-04-23 15:02:18 +00:00
|
|
|
|
|
|
|
return m_projectFileParams;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2009-11-05 19:26:52 +00:00
|
|
|
* Reads the configuration
|
|
|
|
* 1 - bed cvpcb.cnf
|
|
|
|
* 2 - if not in path of <cvpcb.exe> / cvpcb.cnf
|
|
|
|
* 3 - If not found: init variables to default values
|
2008-03-04 04:22:27 +00:00
|
|
|
*
|
2009-11-05 19:26:52 +00:00
|
|
|
* Note:
|
|
|
|
* The path of the executable must be in cvpcb.exe.
|
2009-04-23 15:02:18 +00:00
|
|
|
*
|
2008-03-04 04:22:27 +00:00
|
|
|
*/
|
2011-02-05 16:15:48 +00:00
|
|
|
void CVPCB_MAINFRAME::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
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-05 16:15:48 +00:00
|
|
|
void CVPCB_MAINFRAME::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
|
|
|
|
2011-02-05 16:15:48 +00:00
|
|
|
void CVPCB_MAINFRAME::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;
|
|
|
|
|
2009-04-23 15:02:18 +00:00
|
|
|
wxGetApp().WriteProjectConfig( dlg.GetPath(), GROUP,
|
|
|
|
GetProjectFileParameters() );
|
2008-03-04 04:22:27 +00:00
|
|
|
}
|