2009-11-05 19:26:52 +00:00
|
|
|
/*************/
|
|
|
|
/** cfg.cpp **/
|
|
|
|
/*************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <appl_wxstruct.h>
|
|
|
|
#include <id.h>
|
|
|
|
#include <common.h>
|
|
|
|
#include <gestfich.h>
|
|
|
|
#include <param_config.h>
|
|
|
|
#include <cvpcb.h>
|
|
|
|
#include <cvpcb_mainframe.h>
|
2012-02-16 20:03:33 +00:00
|
|
|
#include <wildcards_and_files_ext.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
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-24 19:44:05 +00:00
|
|
|
void CVPCB_MAINFRAME::LoadProjectFile( const wxString& aFileName )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-08-24 19:44:05 +00:00
|
|
|
wxFileName fn = aFileName;
|
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
|
|
|
|
2011-08-24 19:44:05 +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-08-24 19:44:05 +00:00
|
|
|
void CVPCB_MAINFRAME::SaveProjectFile( wxCommandEvent& aEvent )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-08-24 19:44:05 +00:00
|
|
|
wxFileName fn = m_NetlistFileName;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-08-24 19:44:05 +00:00
|
|
|
fn.SetExt( ProjectFileExtension );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2011-08-24 19:44:05 +00:00
|
|
|
if( aEvent.GetId() == ID_SAVE_PROJECT_AS || !m_NetlistFileName.IsOk() )
|
|
|
|
{
|
|
|
|
wxFileDialog dlg( this, _( "Save Project File" ), fn.GetPath(),
|
|
|
|
wxEmptyString, ProjectFileWildcard, wxFD_SAVE );
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2011-08-24 19:44:05 +00:00
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
fn = dlg.GetPath();
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2011-08-24 19:44:05 +00:00
|
|
|
if( !fn.HasExt() )
|
|
|
|
fn.SetExt( ProjectFileExtension );
|
|
|
|
}
|
2008-03-04 04:22:27 +00:00
|
|
|
|
2011-08-24 19:44:05 +00:00
|
|
|
if( !IsWritable( fn ) )
|
2008-03-04 04:22:27 +00:00
|
|
|
return;
|
|
|
|
|
2011-08-24 19:44:05 +00:00
|
|
|
wxGetApp().WriteProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParameters() );
|
2008-03-04 04:22:27 +00:00
|
|
|
}
|