2009-11-23 15:16:50 +00:00
|
|
|
/*********************/
|
|
|
|
/* projet_config.cpp */
|
|
|
|
/*********************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <gr_basic.h>
|
|
|
|
#include <appl_wxstruct.h>
|
|
|
|
#include <common.h>
|
|
|
|
#include <kicad_string.h>
|
|
|
|
#include <gestfich.h>
|
|
|
|
#include <wxstruct.h>
|
|
|
|
#include <param_config.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-06 18:54:57 +00:00
|
|
|
#include <wx/apptrait.h>
|
|
|
|
#include <wx/stdpaths.h>
|
|
|
|
|
2012-02-16 20:03:33 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
|
|
|
|
2009-05-21 17:42:42 +00:00
|
|
|
#include <boost/foreach.hpp>
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#define CONFIG_VERSION 1
|
|
|
|
|
2009-03-28 20:02:34 +00:00
|
|
|
#define FORCE_LOCAL_CONFIG true
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2011-09-06 14:09:40 +00:00
|
|
|
bool EDA_APP::ReCreatePrjConfig( const wxString& fileName,
|
|
|
|
const wxString& GroupName,
|
|
|
|
bool ForceUseLocalConfig )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
wxFileName fn = fileName;
|
|
|
|
wxString defaultFileName;
|
2008-02-19 00:35:45 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
// Free old config file.
|
2011-12-16 20:12:49 +00:00
|
|
|
if( m_projectSettings )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2011-12-16 20:12:49 +00:00
|
|
|
delete m_projectSettings;
|
|
|
|
m_projectSettings = NULL;
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
2008-02-19 00:35:45 +00:00
|
|
|
|
2011-09-30 18:15:37 +00:00
|
|
|
/* Check the file name does not a KiCad project extension.
|
2009-06-11 18:30:03 +00:00
|
|
|
* This allows the user to enter a filename without extension
|
|
|
|
* or use an existing name to create te project file
|
2009-11-23 15:16:50 +00:00
|
|
|
*/
|
2009-04-05 20:49:15 +00:00
|
|
|
if( fn.GetExt() != ProjectFileExtension )
|
|
|
|
{
|
|
|
|
fn.SetExt( ProjectFileExtension );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update the library search path list if a new project file is loaded. */
|
|
|
|
if( m_projectFileName != fn )
|
2008-02-19 00:35:45 +00:00
|
|
|
{
|
2009-04-09 18:39:39 +00:00
|
|
|
RemoveLibraryPath( m_projectFileName.GetPath() );
|
|
|
|
InsertLibraryPath( fn.GetPath(), 0 );
|
2009-04-05 20:49:15 +00:00
|
|
|
m_projectFileName = fn;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Init local config filename
|
|
|
|
if( ForceUseLocalConfig || fn.FileExists() )
|
|
|
|
{
|
2011-12-16 20:12:49 +00:00
|
|
|
m_projectSettings = new wxFileConfig( wxEmptyString, wxEmptyString,
|
|
|
|
fn.GetFullPath(), wxEmptyString );
|
|
|
|
m_projectSettings->DontCreateOnDemand();
|
2008-02-19 00:35:45 +00:00
|
|
|
|
|
|
|
if( ForceUseLocalConfig )
|
2009-03-28 20:02:34 +00:00
|
|
|
return true;
|
2008-02-19 00:35:45 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
/* Check the application version against the version saved in the
|
|
|
|
* project file.
|
|
|
|
*
|
|
|
|
* TODO: Push the version test up the stack so that when one of the
|
2011-09-30 18:15:37 +00:00
|
|
|
* KiCad application version changes, the other applications
|
2009-04-05 20:49:15 +00:00
|
|
|
* settings do not get updated. Practically, this can go away.
|
|
|
|
* It isn't used anywhere as far as I know (WLS).
|
|
|
|
*/
|
|
|
|
int version = -1;
|
|
|
|
int def_version = 0;
|
|
|
|
|
2011-12-16 20:12:49 +00:00
|
|
|
m_projectSettings->SetPath( GroupName );
|
|
|
|
version = m_projectSettings->Read( wxT( "version" ), def_version );
|
|
|
|
m_projectSettings->SetPath( wxCONFIG_PATH_SEPARATOR );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2008-02-19 00:35:45 +00:00
|
|
|
if( version > 0 )
|
2011-09-06 14:09:40 +00:00
|
|
|
{
|
2009-03-28 20:02:34 +00:00
|
|
|
return true;
|
2011-09-06 14:09:40 +00:00
|
|
|
}
|
2008-02-19 00:35:45 +00:00
|
|
|
else
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2011-12-16 20:12:49 +00:00
|
|
|
delete m_projectSettings; // Version incorrect
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
2008-02-19 00:35:45 +00:00
|
|
|
}
|
|
|
|
|
2009-04-06 18:54:57 +00:00
|
|
|
defaultFileName = m_libSearchPaths.FindValidPath( wxT( "kicad.pro" ) );
|
2008-02-19 00:35:45 +00:00
|
|
|
|
2009-04-06 18:54:57 +00:00
|
|
|
if( !defaultFileName )
|
|
|
|
{
|
|
|
|
wxLogDebug( wxT( "Template file <kicad.pro> not found." ) );
|
|
|
|
fn = wxFileName( GetTraits()->GetStandardPaths().GetDocumentsDir(),
|
|
|
|
wxT( "kicad" ), ProjectFileExtension );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fn = defaultFileName;
|
|
|
|
}
|
2008-02-19 00:35:45 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
// Create new project file using the default name.
|
2011-12-16 20:12:49 +00:00
|
|
|
m_projectSettings = new wxFileConfig( wxEmptyString, wxEmptyString,
|
|
|
|
wxEmptyString, fn.GetFullPath() );
|
|
|
|
m_projectSettings->DontCreateOnDemand();
|
2008-02-19 00:35:45 +00:00
|
|
|
|
2009-03-28 20:02:34 +00:00
|
|
|
return false;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-06 14:09:40 +00:00
|
|
|
void EDA_APP::WriteProjectConfig( const wxString& fileName,
|
|
|
|
const wxString& GroupName,
|
|
|
|
PARAM_CFG_BASE** List )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-03-28 20:02:34 +00:00
|
|
|
PARAM_CFG_BASE* pt_cfg;
|
|
|
|
wxString msg;
|
2008-02-19 00:35:45 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
ReCreatePrjConfig( fileName, GroupName, FORCE_LOCAL_CONFIG );
|
2008-02-19 00:35:45 +00:00
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
/* Write time (especially to avoid bug wxFileConfig that writes the
|
|
|
|
* wrong item if declaration [xx] in first line (If empty group)
|
|
|
|
*/
|
2011-12-16 20:12:49 +00:00
|
|
|
m_projectSettings->SetPath( wxCONFIG_PATH_SEPARATOR );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2008-02-19 00:35:45 +00:00
|
|
|
msg = DateAndTime();
|
2011-12-16 20:12:49 +00:00
|
|
|
m_projectSettings->Write( wxT( "update" ), msg );
|
2008-02-19 00:35:45 +00:00
|
|
|
|
|
|
|
msg = GetAppName();
|
2011-12-16 20:12:49 +00:00
|
|
|
m_projectSettings->Write( wxT( "last_client" ), msg );
|
2008-02-19 00:35:45 +00:00
|
|
|
|
2009-03-28 20:02:34 +00:00
|
|
|
/* Save parameters */
|
2011-12-16 20:12:49 +00:00
|
|
|
m_projectSettings->DeleteGroup( GroupName ); // Erase all data
|
|
|
|
m_projectSettings->Flush();
|
2008-02-19 00:35:45 +00:00
|
|
|
|
2011-12-16 20:12:49 +00:00
|
|
|
m_projectSettings->SetPath( GroupName );
|
|
|
|
m_projectSettings->Write( wxT( "version" ), CONFIG_VERSION );
|
|
|
|
m_projectSettings->SetPath( wxCONFIG_PATH_SEPARATOR );
|
2008-02-19 00:35:45 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
for( ; List != NULL && *List != NULL; List++ )
|
2008-02-19 00:35:45 +00:00
|
|
|
{
|
|
|
|
pt_cfg = *List;
|
2011-09-06 14:09:40 +00:00
|
|
|
|
2008-02-19 00:35:45 +00:00
|
|
|
if( pt_cfg->m_Group )
|
2011-12-16 20:12:49 +00:00
|
|
|
m_projectSettings->SetPath( pt_cfg->m_Group );
|
2008-02-19 00:35:45 +00:00
|
|
|
else
|
2011-12-16 20:12:49 +00:00
|
|
|
m_projectSettings->SetPath( GroupName );
|
2008-02-19 00:35:45 +00:00
|
|
|
|
2009-03-28 20:02:34 +00:00
|
|
|
if( pt_cfg->m_Setup )
|
|
|
|
continue;
|
2008-02-19 00:35:45 +00:00
|
|
|
|
2009-03-28 20:02:34 +00:00
|
|
|
if ( pt_cfg->m_Type == PARAM_COMMAND_ERASE ) // Erase all data
|
|
|
|
{
|
|
|
|
if( pt_cfg->m_Ident )
|
2011-12-16 20:12:49 +00:00
|
|
|
m_projectSettings->DeleteGroup( pt_cfg->m_Ident );
|
2009-03-28 20:02:34 +00:00
|
|
|
}
|
|
|
|
else
|
2011-09-06 14:09:40 +00:00
|
|
|
{
|
2011-12-16 20:12:49 +00:00
|
|
|
pt_cfg->SaveParam( m_projectSettings );
|
2011-09-06 14:09:40 +00:00
|
|
|
}
|
2009-03-28 20:02:34 +00:00
|
|
|
}
|
2008-02-19 00:35:45 +00:00
|
|
|
|
2011-12-16 20:12:49 +00:00
|
|
|
m_projectSettings->SetPath( UNIX_STRING_DIR_SEP );
|
|
|
|
delete m_projectSettings;
|
|
|
|
m_projectSettings = NULL;
|
2009-03-28 20:02:34 +00:00
|
|
|
}
|
2008-02-19 00:35:45 +00:00
|
|
|
|
2009-04-23 15:02:18 +00:00
|
|
|
|
2011-09-06 14:09:40 +00:00
|
|
|
void EDA_APP::WriteProjectConfig( const wxString& fileName,
|
|
|
|
const wxString& GroupName,
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
const PARAM_CFG_ARRAY& params )
|
2009-04-23 15:02:18 +00:00
|
|
|
{
|
|
|
|
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) */
|
2011-12-16 20:12:49 +00:00
|
|
|
m_projectSettings->SetPath( wxCONFIG_PATH_SEPARATOR );
|
2009-04-23 15:02:18 +00:00
|
|
|
|
2011-12-16 20:12:49 +00:00
|
|
|
m_projectSettings->Write( wxT( "update" ), DateAndTime() );
|
|
|
|
m_projectSettings->Write( wxT( "last_client" ), GetAppName() );
|
2009-04-23 15:02:18 +00:00
|
|
|
|
|
|
|
/* Save parameters */
|
2011-12-16 20:12:49 +00:00
|
|
|
m_projectSettings->DeleteGroup( GroupName ); // Erase all data
|
|
|
|
m_projectSettings->Flush();
|
2009-04-23 15:02:18 +00:00
|
|
|
|
2011-12-16 20:12:49 +00:00
|
|
|
m_projectSettings->SetPath( GroupName );
|
|
|
|
m_projectSettings->Write( wxT( "version" ), CONFIG_VERSION );
|
|
|
|
m_projectSettings->SetPath( wxCONFIG_PATH_SEPARATOR );
|
2009-04-23 15:02:18 +00:00
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
BOOST_FOREACH( const PARAM_CFG_BASE& param, params )
|
2009-04-23 15:02:18 +00:00
|
|
|
{
|
2009-05-21 17:42:42 +00:00
|
|
|
if( param.m_Group )
|
2011-12-16 20:12:49 +00:00
|
|
|
m_projectSettings->SetPath( param.m_Group );
|
2009-04-23 15:02:18 +00:00
|
|
|
else
|
2011-12-16 20:12:49 +00:00
|
|
|
m_projectSettings->SetPath( GroupName );
|
2009-04-23 15:02:18 +00:00
|
|
|
|
2009-05-21 17:42:42 +00:00
|
|
|
if( param.m_Setup )
|
2009-04-23 15:02:18 +00:00
|
|
|
continue;
|
|
|
|
|
2009-05-21 17:42:42 +00:00
|
|
|
if ( param.m_Type == PARAM_COMMAND_ERASE ) // Erase all data
|
2009-04-23 15:02:18 +00:00
|
|
|
{
|
2009-05-21 17:42:42 +00:00
|
|
|
if( param.m_Ident )
|
2011-12-16 20:12:49 +00:00
|
|
|
m_projectSettings->DeleteGroup( param.m_Ident );
|
2009-04-23 15:02:18 +00:00
|
|
|
}
|
|
|
|
else
|
2011-09-06 14:09:40 +00:00
|
|
|
{
|
2011-12-16 20:12:49 +00:00
|
|
|
param.SaveParam( m_projectSettings );
|
2011-09-06 14:09:40 +00:00
|
|
|
}
|
2009-04-23 15:02:18 +00:00
|
|
|
}
|
|
|
|
|
2011-12-16 20:12:49 +00:00
|
|
|
m_projectSettings->SetPath( UNIX_STRING_DIR_SEP );
|
|
|
|
delete m_projectSettings;
|
|
|
|
m_projectSettings = NULL;
|
2009-04-23 15:02:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-06 14:09:40 +00:00
|
|
|
void EDA_APP::SaveCurrentSetupValues( PARAM_CFG_BASE** aList )
|
2009-03-28 20:02:34 +00:00
|
|
|
{
|
|
|
|
PARAM_CFG_BASE* pt_cfg;
|
2008-02-19 00:35:45 +00:00
|
|
|
|
2011-12-16 20:12:49 +00:00
|
|
|
if( m_settings == NULL )
|
2009-03-28 20:02:34 +00:00
|
|
|
return;
|
2008-02-19 00:35:45 +00:00
|
|
|
|
2009-03-28 20:02:34 +00:00
|
|
|
for( ; *aList != NULL; aList++ )
|
|
|
|
{
|
|
|
|
pt_cfg = *aList;
|
|
|
|
if( pt_cfg->m_Setup == false )
|
|
|
|
continue;
|
2008-02-19 00:35:45 +00:00
|
|
|
|
2009-03-28 20:02:34 +00:00
|
|
|
if ( pt_cfg->m_Type == PARAM_COMMAND_ERASE ) // Erase all data
|
2008-02-19 00:35:45 +00:00
|
|
|
{
|
|
|
|
if( pt_cfg->m_Ident )
|
2011-12-16 20:12:49 +00:00
|
|
|
m_settings->DeleteGroup( pt_cfg->m_Ident );
|
2008-02-19 00:35:45 +00:00
|
|
|
}
|
2009-03-28 20:02:34 +00:00
|
|
|
else
|
2011-09-06 14:09:40 +00:00
|
|
|
{
|
2011-12-16 20:12:49 +00:00
|
|
|
pt_cfg->SaveParam( m_settings );
|
2011-09-06 14:09:40 +00:00
|
|
|
}
|
2008-02-19 00:35:45 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
void EDA_APP::SaveCurrentSetupValues( const PARAM_CFG_ARRAY& List )
|
2009-04-29 17:09:00 +00:00
|
|
|
{
|
2011-12-16 20:12:49 +00:00
|
|
|
if( m_settings == NULL )
|
2009-04-29 17:09:00 +00:00
|
|
|
return;
|
|
|
|
|
2011-12-31 05:44:00 +00:00
|
|
|
unsigned count = List.size();
|
|
|
|
for( unsigned i=0; i<count; ++i )
|
2009-04-29 17:09:00 +00:00
|
|
|
{
|
2011-12-31 05:44:00 +00:00
|
|
|
const PARAM_CFG_BASE& param = List[i];
|
|
|
|
|
2009-05-21 17:42:42 +00:00
|
|
|
if( param.m_Setup == false )
|
2009-04-29 17:09:00 +00:00
|
|
|
continue;
|
|
|
|
|
2011-12-31 05:44:00 +00:00
|
|
|
if( param.m_Type == PARAM_COMMAND_ERASE ) // Erase all data
|
2009-04-29 17:09:00 +00:00
|
|
|
{
|
2009-05-21 17:42:42 +00:00
|
|
|
if( param.m_Ident )
|
2011-12-16 20:12:49 +00:00
|
|
|
m_settings->DeleteGroup( param.m_Ident );
|
2009-04-29 17:09:00 +00:00
|
|
|
}
|
|
|
|
else
|
2011-12-16 20:12:49 +00:00
|
|
|
{
|
|
|
|
param.SaveParam( m_settings );
|
|
|
|
}
|
2009-04-29 17:09:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-06 14:09:40 +00:00
|
|
|
bool EDA_APP::ReadProjectConfig( const wxString& local_config_filename,
|
|
|
|
const wxString& GroupName,
|
|
|
|
PARAM_CFG_BASE** List,
|
|
|
|
bool Load_Only_if_New )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-03-28 20:02:34 +00:00
|
|
|
PARAM_CFG_BASE* pt_cfg;
|
|
|
|
wxString timestamp;
|
2008-02-19 00:35:45 +00:00
|
|
|
|
2009-03-28 20:02:34 +00:00
|
|
|
ReCreatePrjConfig( local_config_filename, GroupName, false );
|
2008-02-19 00:35:45 +00:00
|
|
|
|
2011-12-16 20:12:49 +00:00
|
|
|
m_projectSettings->SetPath( wxCONFIG_PATH_SEPARATOR );
|
|
|
|
timestamp = m_projectSettings->Read( wxT( "update" ) );
|
2011-09-06 14:09:40 +00:00
|
|
|
|
2008-02-19 00:35:45 +00:00
|
|
|
if( Load_Only_if_New && ( !timestamp.IsEmpty() )
|
2009-04-05 20:49:15 +00:00
|
|
|
&& (timestamp == m_CurrentOptionFileDateAndTime) )
|
2008-02-19 00:35:45 +00:00
|
|
|
{
|
2009-03-28 20:02:34 +00:00
|
|
|
return false;
|
2008-02-19 00:35:45 +00:00
|
|
|
}
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
m_CurrentOptionFileDateAndTime = timestamp;
|
2008-02-19 00:35:45 +00:00
|
|
|
|
|
|
|
if( !g_Prj_Default_Config_FullFilename.IsEmpty() )
|
2011-09-06 14:09:40 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
m_CurrentOptionFile = g_Prj_Default_Config_FullFilename;
|
2011-09-06 14:09:40 +00:00
|
|
|
}
|
2008-02-19 00:35:45 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if( wxPathOnly( g_Prj_Config_LocalFilename ).IsEmpty() )
|
2011-09-06 14:09:40 +00:00
|
|
|
m_CurrentOptionFile = wxGetCwd() + STRING_DIR_SEP + g_Prj_Config_LocalFilename;
|
2008-02-19 00:35:45 +00:00
|
|
|
else
|
2009-04-05 20:49:15 +00:00
|
|
|
m_CurrentOptionFile = g_Prj_Config_LocalFilename;
|
2008-02-19 00:35:45 +00:00
|
|
|
}
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
for( ; List != NULL && *List != NULL; List++ )
|
2008-02-19 00:35:45 +00:00
|
|
|
{
|
|
|
|
pt_cfg = *List;
|
2011-09-06 14:09:40 +00:00
|
|
|
|
2008-02-19 00:35:45 +00:00
|
|
|
if( pt_cfg->m_Group )
|
2011-12-16 20:12:49 +00:00
|
|
|
m_projectSettings->SetPath( pt_cfg->m_Group );
|
2008-02-19 00:35:45 +00:00
|
|
|
else
|
2011-12-16 20:12:49 +00:00
|
|
|
m_projectSettings->SetPath( GroupName );
|
2008-02-19 00:35:45 +00:00
|
|
|
|
2009-03-28 20:02:34 +00:00
|
|
|
if( pt_cfg->m_Setup )
|
|
|
|
continue;
|
2008-02-19 00:35:45 +00:00
|
|
|
|
2011-12-16 20:12:49 +00:00
|
|
|
pt_cfg->ReadParam( m_projectSettings );
|
2009-03-28 20:02:34 +00:00
|
|
|
}
|
2008-02-19 00:35:45 +00:00
|
|
|
|
2011-12-16 20:12:49 +00:00
|
|
|
delete m_projectSettings;
|
|
|
|
m_projectSettings = NULL;
|
2008-02-19 00:35:45 +00:00
|
|
|
|
2009-03-28 20:02:34 +00:00
|
|
|
return true;
|
|
|
|
}
|
2008-02-19 00:35:45 +00:00
|
|
|
|
|
|
|
|
2011-09-06 14:09:40 +00:00
|
|
|
bool EDA_APP::ReadProjectConfig( const wxString& local_config_filename,
|
|
|
|
const wxString& GroupName,
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
const PARAM_CFG_ARRAY& params,
|
2011-09-06 14:09:40 +00:00
|
|
|
bool Load_Only_if_New )
|
2009-04-23 15:02:18 +00:00
|
|
|
{
|
|
|
|
wxString timestamp;
|
|
|
|
|
|
|
|
ReCreatePrjConfig( local_config_filename, GroupName, false );
|
|
|
|
|
2011-12-16 20:12:49 +00:00
|
|
|
m_projectSettings->SetPath( wxCONFIG_PATH_SEPARATOR );
|
|
|
|
timestamp = m_projectSettings->Read( wxT( "update" ) );
|
2011-09-06 14:09:40 +00:00
|
|
|
|
2009-04-23 15:02:18 +00:00
|
|
|
if( Load_Only_if_New && ( !timestamp.IsEmpty() )
|
|
|
|
&& (timestamp == m_CurrentOptionFileDateAndTime) )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_CurrentOptionFileDateAndTime = timestamp;
|
|
|
|
|
|
|
|
if( !g_Prj_Default_Config_FullFilename.IsEmpty() )
|
2011-09-06 14:09:40 +00:00
|
|
|
{
|
2009-04-23 15:02:18 +00:00
|
|
|
m_CurrentOptionFile = g_Prj_Default_Config_FullFilename;
|
2011-09-06 14:09:40 +00:00
|
|
|
}
|
2009-04-23 15:02:18 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if( wxPathOnly( g_Prj_Config_LocalFilename ).IsEmpty() )
|
2011-09-06 14:09:40 +00:00
|
|
|
m_CurrentOptionFile = wxGetCwd() + STRING_DIR_SEP + g_Prj_Config_LocalFilename;
|
2009-04-23 15:02:18 +00:00
|
|
|
else
|
|
|
|
m_CurrentOptionFile = g_Prj_Config_LocalFilename;
|
|
|
|
}
|
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
BOOST_FOREACH( const PARAM_CFG_BASE& param, params )
|
2009-04-23 15:02:18 +00:00
|
|
|
{
|
2009-05-21 17:42:42 +00:00
|
|
|
if( param.m_Group )
|
2011-12-16 20:12:49 +00:00
|
|
|
m_projectSettings->SetPath( param.m_Group );
|
2009-04-23 15:02:18 +00:00
|
|
|
else
|
2011-12-16 20:12:49 +00:00
|
|
|
m_projectSettings->SetPath( GroupName );
|
2009-04-23 15:02:18 +00:00
|
|
|
|
2009-05-21 17:42:42 +00:00
|
|
|
if( param.m_Setup )
|
2009-04-23 15:02:18 +00:00
|
|
|
continue;
|
|
|
|
|
2011-12-16 20:12:49 +00:00
|
|
|
param.ReadParam( m_projectSettings );
|
2009-04-23 15:02:18 +00:00
|
|
|
}
|
|
|
|
|
2011-12-16 20:12:49 +00:00
|
|
|
delete m_projectSettings;
|
|
|
|
m_projectSettings = NULL;
|
2009-04-23 15:02:18 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-06 14:09:40 +00:00
|
|
|
void EDA_APP::ReadCurrentSetupValues( PARAM_CFG_BASE** aList )
|
2009-03-28 20:02:34 +00:00
|
|
|
{
|
|
|
|
PARAM_CFG_BASE* pt_cfg;
|
2008-02-19 00:35:45 +00:00
|
|
|
|
2009-03-28 20:02:34 +00:00
|
|
|
for( ; *aList != NULL; aList++ )
|
|
|
|
{
|
|
|
|
pt_cfg = *aList;
|
2011-09-06 14:09:40 +00:00
|
|
|
|
2009-03-28 20:02:34 +00:00
|
|
|
if( pt_cfg->m_Setup == false )
|
|
|
|
continue;
|
2008-02-19 00:35:45 +00:00
|
|
|
|
2011-12-16 20:12:49 +00:00
|
|
|
pt_cfg->ReadParam( m_settings );
|
2009-03-28 20:02:34 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
void EDA_APP::ReadCurrentSetupValues( const PARAM_CFG_ARRAY& List )
|
2009-04-29 17:09:00 +00:00
|
|
|
{
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
BOOST_FOREACH( const PARAM_CFG_BASE& param, List )
|
2009-04-29 17:09:00 +00:00
|
|
|
{
|
2009-05-21 17:42:42 +00:00
|
|
|
if( param.m_Setup == false )
|
2009-04-29 17:09:00 +00:00
|
|
|
continue;
|
|
|
|
|
2011-12-16 20:12:49 +00:00
|
|
|
param.ReadParam( m_settings );
|
2009-04-29 17:09:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-19 00:35:45 +00:00
|
|
|
PARAM_CFG_BASE::PARAM_CFG_BASE( const wxChar* ident, const paramcfg_id type,
|
|
|
|
const wxChar* group )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-02-19 00:35:45 +00:00
|
|
|
m_Ident = ident;
|
|
|
|
m_Type = type;
|
|
|
|
m_Group = group;
|
2009-03-28 20:02:34 +00:00
|
|
|
m_Setup = false;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-19 00:35:45 +00:00
|
|
|
PARAM_CFG_INT::PARAM_CFG_INT( const wxChar* ident, int* ptparam,
|
|
|
|
int default_val, int min, int max,
|
|
|
|
const wxChar* group ) :
|
|
|
|
PARAM_CFG_BASE( ident, PARAM_INT, group )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-02-19 00:35:45 +00:00
|
|
|
m_Pt_param = ptparam;
|
|
|
|
m_Default = default_val;
|
|
|
|
m_Min = min;
|
|
|
|
m_Max = max;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-02-19 00:35:45 +00:00
|
|
|
|
|
|
|
PARAM_CFG_INT::PARAM_CFG_INT( bool Insetup, const wxChar* ident, int* ptparam,
|
|
|
|
int default_val, int min, int max,
|
|
|
|
const wxChar* group ) :
|
|
|
|
PARAM_CFG_BASE( ident, PARAM_INT, group )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-02-19 00:35:45 +00:00
|
|
|
m_Pt_param = ptparam;
|
|
|
|
m_Default = default_val;
|
|
|
|
m_Min = min;
|
|
|
|
m_Max = max;
|
|
|
|
m_Setup = Insetup;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-02-19 00:35:45 +00:00
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
void PARAM_CFG_INT::ReadParam( wxConfigBase* aConfig ) const
|
2009-03-28 20:02:34 +00:00
|
|
|
{
|
|
|
|
if( m_Pt_param == NULL || aConfig == NULL )
|
|
|
|
return;
|
2011-09-06 14:09:40 +00:00
|
|
|
|
2009-03-28 20:02:34 +00:00
|
|
|
int itmp = aConfig->Read( m_Ident, m_Default );
|
|
|
|
|
|
|
|
if( (itmp < m_Min) || (itmp > m_Max) )
|
|
|
|
itmp = m_Default;
|
|
|
|
|
|
|
|
*m_Pt_param = itmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
void PARAM_CFG_INT::SaveParam( wxConfigBase* aConfig ) const
|
2009-03-28 20:02:34 +00:00
|
|
|
{
|
|
|
|
if( m_Pt_param == NULL || aConfig == NULL )
|
|
|
|
return;
|
2011-09-06 14:09:40 +00:00
|
|
|
|
2009-03-28 20:02:34 +00:00
|
|
|
aConfig->Write( m_Ident, *m_Pt_param );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-19 00:35:45 +00:00
|
|
|
PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( const wxChar* ident, int* ptparam,
|
2008-12-08 15:27:13 +00:00
|
|
|
int default_val,
|
|
|
|
const wxChar* group ) :
|
2008-02-19 00:35:45 +00:00
|
|
|
PARAM_CFG_BASE( ident, PARAM_SETCOLOR, group )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-02-19 00:35:45 +00:00
|
|
|
m_Pt_param = ptparam;
|
|
|
|
m_Default = default_val;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-02-19 00:35:45 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( bool Insetup,
|
|
|
|
const wxChar* ident,
|
|
|
|
int* ptparam,
|
|
|
|
int default_val,
|
|
|
|
const wxChar* group ) :
|
2008-02-19 00:35:45 +00:00
|
|
|
PARAM_CFG_BASE( ident, PARAM_SETCOLOR, group )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-02-19 00:35:45 +00:00
|
|
|
m_Pt_param = ptparam;
|
|
|
|
m_Default = default_val;
|
|
|
|
m_Setup = Insetup;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-02-19 00:35:45 +00:00
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
void PARAM_CFG_SETCOLOR::ReadParam( wxConfigBase* aConfig ) const
|
2009-03-28 20:02:34 +00:00
|
|
|
{
|
|
|
|
if( m_Pt_param == NULL || aConfig == NULL )
|
|
|
|
return;
|
|
|
|
int itmp = aConfig->Read( m_Ident, m_Default );
|
|
|
|
|
|
|
|
if( (itmp < 0) || (itmp > MAX_COLOR) )
|
|
|
|
itmp = m_Default;
|
|
|
|
*m_Pt_param = itmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
void PARAM_CFG_SETCOLOR::SaveParam( wxConfigBase* aConfig ) const
|
2009-03-28 20:02:34 +00:00
|
|
|
{
|
|
|
|
if( m_Pt_param == NULL || aConfig == NULL )
|
|
|
|
return;
|
2011-09-06 14:09:40 +00:00
|
|
|
|
2009-03-28 20:02:34 +00:00
|
|
|
aConfig->Write( m_Ident, *m_Pt_param );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-19 00:35:45 +00:00
|
|
|
PARAM_CFG_DOUBLE::PARAM_CFG_DOUBLE( const wxChar* ident, double* ptparam,
|
|
|
|
double default_val, double min, double max,
|
|
|
|
const wxChar* group ) :
|
|
|
|
PARAM_CFG_BASE( ident, PARAM_DOUBLE, group )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-02-19 00:35:45 +00:00
|
|
|
m_Pt_param = ptparam;
|
|
|
|
m_Default = default_val;
|
|
|
|
m_Min = min;
|
|
|
|
m_Max = max;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
2008-02-19 00:35:45 +00:00
|
|
|
|
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
PARAM_CFG_DOUBLE::PARAM_CFG_DOUBLE( bool Insetup,
|
|
|
|
const wxChar* ident,
|
|
|
|
double* ptparam,
|
|
|
|
double default_val,
|
|
|
|
double min,
|
|
|
|
double max,
|
2008-02-19 00:35:45 +00:00
|
|
|
const wxChar* group ) :
|
|
|
|
PARAM_CFG_BASE( ident, PARAM_DOUBLE, group )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-02-19 00:35:45 +00:00
|
|
|
m_Pt_param = ptparam;
|
|
|
|
m_Default = default_val;
|
|
|
|
m_Min = min;
|
|
|
|
m_Max = max;
|
|
|
|
m_Setup = Insetup;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-02-19 00:35:45 +00:00
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
void PARAM_CFG_DOUBLE::ReadParam( wxConfigBase* aConfig ) const
|
2009-03-28 20:02:34 +00:00
|
|
|
{
|
|
|
|
if( m_Pt_param == NULL || aConfig == NULL )
|
|
|
|
return;
|
2011-09-06 14:09:40 +00:00
|
|
|
|
2009-03-28 20:02:34 +00:00
|
|
|
double ftmp = 0;
|
|
|
|
wxString msg;
|
2009-04-05 20:49:15 +00:00
|
|
|
msg = aConfig->Read( m_Ident, wxT( "" ) );
|
2009-03-28 20:02:34 +00:00
|
|
|
|
|
|
|
if( msg.IsEmpty() )
|
2011-09-06 14:09:40 +00:00
|
|
|
{
|
2009-03-28 20:02:34 +00:00
|
|
|
ftmp = m_Default;
|
2011-09-06 14:09:40 +00:00
|
|
|
}
|
2009-03-28 20:02:34 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
msg.ToDouble( &ftmp );
|
2011-09-06 14:09:40 +00:00
|
|
|
|
2009-03-28 20:02:34 +00:00
|
|
|
if( (ftmp < m_Min) || (ftmp > m_Max) )
|
|
|
|
ftmp = m_Default;
|
|
|
|
}
|
2011-09-06 14:09:40 +00:00
|
|
|
|
2009-03-28 20:02:34 +00:00
|
|
|
*m_Pt_param = ftmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
void PARAM_CFG_DOUBLE::SaveParam( wxConfigBase* aConfig ) const
|
2009-03-28 20:02:34 +00:00
|
|
|
{
|
|
|
|
if( m_Pt_param == NULL || aConfig == NULL )
|
|
|
|
return;
|
2011-09-06 14:09:40 +00:00
|
|
|
|
2009-03-28 20:02:34 +00:00
|
|
|
aConfig->Write( m_Ident, *m_Pt_param );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-19 00:35:45 +00:00
|
|
|
PARAM_CFG_BOOL::PARAM_CFG_BOOL( const wxChar* ident, bool* ptparam,
|
|
|
|
int default_val, const wxChar* group ) :
|
|
|
|
PARAM_CFG_BASE( ident, PARAM_BOOL, group )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-02-19 00:35:45 +00:00
|
|
|
m_Pt_param = ptparam;
|
2009-03-28 20:02:34 +00:00
|
|
|
m_Default = default_val ? true : false;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-02-19 00:35:45 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
PARAM_CFG_BOOL::PARAM_CFG_BOOL( bool Insetup,
|
|
|
|
const wxChar* ident,
|
|
|
|
bool* ptparam,
|
|
|
|
int default_val,
|
|
|
|
const wxChar* group ) :
|
2008-02-19 00:35:45 +00:00
|
|
|
PARAM_CFG_BASE( ident, PARAM_BOOL, group )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-02-19 00:35:45 +00:00
|
|
|
m_Pt_param = ptparam;
|
2009-03-28 20:02:34 +00:00
|
|
|
m_Default = default_val ? true : false;
|
2008-02-19 00:35:45 +00:00
|
|
|
m_Setup = Insetup;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-02-19 00:35:45 +00:00
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
void PARAM_CFG_BOOL::ReadParam( wxConfigBase* aConfig ) const
|
2009-03-28 20:02:34 +00:00
|
|
|
{
|
|
|
|
if( m_Pt_param == NULL || aConfig == NULL )
|
|
|
|
return;
|
2011-09-06 14:09:40 +00:00
|
|
|
|
2009-03-28 20:02:34 +00:00
|
|
|
int itmp = aConfig->Read( m_Ident, (int) m_Default );
|
|
|
|
|
|
|
|
*m_Pt_param = itmp ? true : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
void PARAM_CFG_BOOL::SaveParam( wxConfigBase* aConfig ) const
|
2009-03-28 20:02:34 +00:00
|
|
|
{
|
|
|
|
if( m_Pt_param == NULL || aConfig == NULL )
|
|
|
|
return;
|
2011-09-06 14:09:40 +00:00
|
|
|
|
2009-03-28 20:02:34 +00:00
|
|
|
aConfig->Write( m_Ident, *m_Pt_param );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-19 00:35:45 +00:00
|
|
|
PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( const wxChar* ident,
|
2008-12-08 15:27:13 +00:00
|
|
|
wxString* ptparam,
|
|
|
|
const wxChar* group ) :
|
2008-02-19 00:35:45 +00:00
|
|
|
PARAM_CFG_BASE( ident, PARAM_WXSTRING, group )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-02-19 00:35:45 +00:00
|
|
|
m_Pt_param = ptparam;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-02-19 00:35:45 +00:00
|
|
|
|
|
|
|
PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( bool Insetup, const wxChar* ident,
|
2008-12-08 15:27:13 +00:00
|
|
|
wxString* ptparam,
|
2011-03-12 09:50:21 +00:00
|
|
|
const wxString& default_val,
|
2008-12-08 15:27:13 +00:00
|
|
|
const wxChar* group ) :
|
2008-02-19 00:35:45 +00:00
|
|
|
PARAM_CFG_BASE( ident, PARAM_WXSTRING, group )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-02-19 00:35:45 +00:00
|
|
|
m_Pt_param = ptparam;
|
|
|
|
m_Setup = Insetup;
|
2011-03-12 09:50:21 +00:00
|
|
|
m_default = default_val;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-02-19 00:35:45 +00:00
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
void PARAM_CFG_WXSTRING::ReadParam( wxConfigBase* aConfig ) const
|
2009-03-28 20:02:34 +00:00
|
|
|
{
|
|
|
|
if( m_Pt_param == NULL || aConfig == NULL )
|
|
|
|
return;
|
2011-03-12 09:50:21 +00:00
|
|
|
*m_Pt_param = aConfig->Read( m_Ident, m_default );
|
2009-03-28 20:02:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
void PARAM_CFG_WXSTRING::SaveParam( wxConfigBase* aConfig ) const
|
2009-03-28 20:02:34 +00:00
|
|
|
{
|
|
|
|
if( m_Pt_param == NULL || aConfig == NULL )
|
|
|
|
return;
|
2011-09-06 14:09:40 +00:00
|
|
|
|
2009-03-28 20:02:34 +00:00
|
|
|
aConfig->Write( m_Ident, *m_Pt_param );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-26 08:35:22 +00:00
|
|
|
|
|
|
|
PARAM_CFG_FILENAME::PARAM_CFG_FILENAME( const wxChar* ident,
|
|
|
|
wxString* ptparam,
|
|
|
|
const wxChar* group ) :
|
|
|
|
PARAM_CFG_BASE( ident, PARAM_FILENAME, group )
|
|
|
|
{
|
|
|
|
m_Pt_param = ptparam;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
void PARAM_CFG_FILENAME::ReadParam( wxConfigBase* aConfig ) const
|
2011-02-26 08:35:22 +00:00
|
|
|
{
|
|
|
|
if( m_Pt_param == NULL || aConfig == NULL )
|
|
|
|
return;
|
|
|
|
wxString prm = aConfig->Read( m_Ident );
|
|
|
|
// filesnames are stored using Unix notation
|
|
|
|
// under Window we must use \ instead of /
|
|
|
|
// mainly if there is a server name in path (something like \\server\kicad)
|
|
|
|
#ifdef __WINDOWS__
|
|
|
|
prm.Replace(wxT("/"), wxT("\\"));
|
|
|
|
#endif
|
|
|
|
*m_Pt_param = prm;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
void PARAM_CFG_FILENAME::SaveParam( wxConfigBase* aConfig ) const
|
2011-02-26 08:35:22 +00:00
|
|
|
{
|
|
|
|
if( m_Pt_param == NULL || aConfig == NULL )
|
|
|
|
return;
|
2011-09-06 14:09:40 +00:00
|
|
|
|
2011-02-26 08:35:22 +00:00
|
|
|
wxString prm = *m_Pt_param;
|
|
|
|
// filenames are stored using Unix notation
|
|
|
|
prm.Replace(wxT("\\"), wxT("/") );
|
|
|
|
aConfig->Write( m_Ident, prm );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
PARAM_CFG_LIBNAME_LIST::PARAM_CFG_LIBNAME_LIST( const wxChar* ident,
|
|
|
|
wxArrayString* ptparam,
|
|
|
|
const wxChar* group ) :
|
2008-02-19 00:35:45 +00:00
|
|
|
PARAM_CFG_BASE( ident, PARAM_LIBNAME_LIST, group )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-02-19 00:35:45 +00:00
|
|
|
m_Pt_param = ptparam;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
2009-03-28 20:02:34 +00:00
|
|
|
|
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
void PARAM_CFG_LIBNAME_LIST::ReadParam( wxConfigBase* aConfig ) const
|
2009-03-28 20:02:34 +00:00
|
|
|
{
|
|
|
|
if( m_Pt_param == NULL || aConfig == NULL )
|
|
|
|
return;
|
2011-09-06 14:09:40 +00:00
|
|
|
|
2009-11-23 15:16:50 +00:00
|
|
|
int indexlib = 1; // We start indexlib to 1 because first
|
|
|
|
// lib name is LibName1
|
2009-03-28 20:02:34 +00:00
|
|
|
wxString libname, id_lib;
|
|
|
|
wxArrayString* libname_list = m_Pt_param;
|
2011-09-06 14:09:40 +00:00
|
|
|
|
2009-03-28 20:02:34 +00:00
|
|
|
while( 1 )
|
|
|
|
{
|
|
|
|
id_lib = m_Ident;
|
|
|
|
id_lib << indexlib;
|
|
|
|
indexlib++;
|
|
|
|
libname = aConfig->Read( id_lib, wxT( "" ) );
|
|
|
|
if( libname.IsEmpty() )
|
|
|
|
break;
|
2011-02-26 08:35:22 +00:00
|
|
|
// filesnames are stored using Unix notation
|
|
|
|
// under Window we must use \ instead of /
|
|
|
|
// mainly if there is a server name in path (something like \\server\kicad)
|
|
|
|
#ifdef __WINDOWS__
|
|
|
|
libname.Replace(wxT("/"), wxT("\\"));
|
|
|
|
#endif
|
2009-03-28 20:02:34 +00:00
|
|
|
libname_list->Add( libname );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
void PARAM_CFG_LIBNAME_LIST::SaveParam( wxConfigBase* aConfig ) const
|
2009-03-28 20:02:34 +00:00
|
|
|
{
|
|
|
|
if( m_Pt_param == NULL || aConfig == NULL )
|
|
|
|
return;
|
|
|
|
wxArrayString* libname_list = m_Pt_param;
|
|
|
|
|
|
|
|
unsigned indexlib = 0;
|
2010-11-29 15:05:01 +00:00
|
|
|
wxString configkey;
|
2011-02-26 08:35:22 +00:00
|
|
|
wxString libname;
|
2011-09-06 14:09:40 +00:00
|
|
|
|
2009-03-28 20:02:34 +00:00
|
|
|
for( ; indexlib < libname_list->GetCount(); indexlib++ )
|
|
|
|
{
|
2010-11-29 15:05:01 +00:00
|
|
|
configkey = m_Ident;
|
2009-03-28 20:02:34 +00:00
|
|
|
|
|
|
|
// We use indexlib+1 because first lib name is LibName1
|
2010-11-29 15:05:01 +00:00
|
|
|
configkey << (indexlib + 1);
|
2011-02-26 08:35:22 +00:00
|
|
|
libname = libname_list->Item( indexlib );
|
2011-12-31 05:44:00 +00:00
|
|
|
|
2011-02-26 08:35:22 +00:00
|
|
|
// filenames are stored using Unix notation
|
|
|
|
libname.Replace(wxT("\\"), wxT("/") );
|
|
|
|
aConfig->Write( configkey, libname );
|
2009-03-28 20:02:34 +00:00
|
|
|
}
|
|
|
|
}
|