Fix many issues in config functions, mainly a rounding issue when a double is stored in wxConfig file (was stored only using 4 digits in mantissa)

Remove dead or obsolete code.
This commit is contained in:
jean-pierre charras 2013-03-30 10:28:59 +01:00
commit 51291b0965
17 changed files with 226 additions and 352 deletions

View File

@ -52,14 +52,9 @@ wxString g_ProductName = wxT( "KiCad E.D.A. " );
bool g_ShowPageLimits = true; bool g_ShowPageLimits = true;
wxString g_UserLibDirBuffer; wxString g_UserLibDirBuffer;
wxString g_Prj_Default_Config_FullFilename;
wxString g_Prj_Config_LocalFilename;
EDA_UNITS_T g_UserUnit; EDA_UNITS_T g_UserUnit;
EDA_COLOR_T g_GhostColor; EDA_COLOR_T g_GhostColor;
#if defined(KICAD_GOST) #if defined(KICAD_GOST)
static const bool s_gost = true; static const bool s_gost = true;
#else #else

View File

@ -20,7 +20,6 @@
#define CONFIG_VERSION 1 #define CONFIG_VERSION 1
#define FORCE_LOCAL_CONFIG true #define FORCE_LOCAL_CONFIG true
@ -29,7 +28,6 @@ bool EDA_APP::ReCreatePrjConfig( const wxString& fileName,
bool ForceUseLocalConfig ) bool ForceUseLocalConfig )
{ {
wxFileName fn = fileName; wxFileName fn = fileName;
wxString defaultFileName;
// Free old config file. // Free old config file.
if( m_projectSettings ) if( m_projectSettings )
@ -38,9 +36,9 @@ bool EDA_APP::ReCreatePrjConfig( const wxString& fileName,
m_projectSettings = NULL; m_projectSettings = NULL;
} }
/* Check the file name does not a KiCad project extension. /* Force the file extension.
* This allows the user to enter a filename without extension * This allows the user to enter a filename without extension
* or use an existing name to create te project file * or use an existing name to create the project file
*/ */
if( fn.GetExt() != ProjectFileExtension ) if( fn.GetExt() != ProjectFileExtension )
{ {
@ -58,8 +56,9 @@ bool EDA_APP::ReCreatePrjConfig( const wxString& fileName,
// Init local config filename // Init local config filename
if( ForceUseLocalConfig || fn.FileExists() ) if( ForceUseLocalConfig || fn.FileExists() )
{ {
m_CurrentOptionFile = fn.GetFullPath();
m_projectSettings = new wxFileConfig( wxEmptyString, wxEmptyString, m_projectSettings = new wxFileConfig( wxEmptyString, wxEmptyString,
fn.GetFullPath(), wxEmptyString ); m_CurrentOptionFile, wxEmptyString );
m_projectSettings->DontCreateOnDemand(); m_projectSettings->DontCreateOnDemand();
if( ForceUseLocalConfig ) if( ForceUseLocalConfig )
@ -90,9 +89,10 @@ bool EDA_APP::ReCreatePrjConfig( const wxString& fileName,
} }
} }
wxString defaultFileName;
defaultFileName = m_libSearchPaths.FindValidPath( wxT( "kicad.pro" ) ); defaultFileName = m_libSearchPaths.FindValidPath( wxT( "kicad.pro" ) );
if( !defaultFileName ) if( defaultFileName.IsEmpty() )
{ {
wxLogDebug( wxT( "Template file <kicad.pro> not found." ) ); wxLogDebug( wxT( "Template file <kicad.pro> not found." ) );
fn = wxFileName( GetTraits()->GetStandardPaths().GetDocumentsDir(), fn = wxFileName( GetTraits()->GetStandardPaths().GetDocumentsDir(),
@ -104,6 +104,7 @@ bool EDA_APP::ReCreatePrjConfig( const wxString& fileName,
} }
// Create new project file using the default name. // Create new project file using the default name.
m_CurrentOptionFile = fn.GetFullPath();
m_projectSettings = new wxFileConfig( wxEmptyString, wxEmptyString, m_projectSettings = new wxFileConfig( wxEmptyString, wxEmptyString,
wxEmptyString, fn.GetFullPath() ); wxEmptyString, fn.GetFullPath() );
m_projectSettings->DontCreateOnDemand(); m_projectSettings->DontCreateOnDemand();
@ -112,63 +113,6 @@ bool EDA_APP::ReCreatePrjConfig( const wxString& fileName,
} }
void EDA_APP::WriteProjectConfig( const wxString& fileName,
const wxString& GroupName,
PARAM_CFG_BASE** List )
{
PARAM_CFG_BASE* pt_cfg;
wxString msg;
ReCreatePrjConfig( fileName, GroupName, FORCE_LOCAL_CONFIG );
/* Write time (especially to avoid bug wxFileConfig that writes the
* wrong item if declaration [xx] in first line (If empty group)
*/
m_projectSettings->SetPath( wxCONFIG_PATH_SEPARATOR );
msg = DateAndTime();
m_projectSettings->Write( wxT( "update" ), msg );
msg = GetAppName();
m_projectSettings->Write( wxT( "last_client" ), msg );
/* Save parameters */
m_projectSettings->DeleteGroup( GroupName ); // Erase all data
m_projectSettings->Flush();
m_projectSettings->SetPath( GroupName );
m_projectSettings->Write( wxT( "version" ), CONFIG_VERSION );
m_projectSettings->SetPath( wxCONFIG_PATH_SEPARATOR );
for( ; List != NULL && *List != NULL; List++ )
{
pt_cfg = *List;
if( pt_cfg->m_Group )
m_projectSettings->SetPath( pt_cfg->m_Group );
else
m_projectSettings->SetPath( GroupName );
if( pt_cfg->m_Setup )
continue;
if ( pt_cfg->m_Type == PARAM_COMMAND_ERASE ) // Erase all data
{
if( pt_cfg->m_Ident )
m_projectSettings->DeleteGroup( pt_cfg->m_Ident );
}
else
{
pt_cfg->SaveParam( m_projectSettings );
}
}
m_projectSettings->SetPath( UNIX_STRING_DIR_SEP );
delete m_projectSettings;
m_projectSettings = NULL;
}
void EDA_APP::WriteProjectConfig( const wxString& fileName, void EDA_APP::WriteProjectConfig( const wxString& fileName,
const wxString& GroupName, const wxString& GroupName,
const PARAM_CFG_ARRAY& params ) const PARAM_CFG_ARRAY& params )
@ -213,44 +157,18 @@ void EDA_APP::WriteProjectConfig( const wxString& fileName,
} }
m_projectSettings->SetPath( UNIX_STRING_DIR_SEP ); m_projectSettings->SetPath( UNIX_STRING_DIR_SEP );
delete m_projectSettings; delete m_projectSettings;
m_projectSettings = NULL; m_projectSettings = NULL;
} }
void EDA_APP::SaveCurrentSetupValues( PARAM_CFG_BASE** aList )
{
PARAM_CFG_BASE* pt_cfg;
if( m_settings == NULL )
return;
for( ; *aList != NULL; aList++ )
{
pt_cfg = *aList;
if( pt_cfg->m_Setup == false )
continue;
if ( pt_cfg->m_Type == PARAM_COMMAND_ERASE ) // Erase all data
{
if( pt_cfg->m_Ident )
m_settings->DeleteGroup( pt_cfg->m_Ident );
}
else
{
pt_cfg->SaveParam( m_settings );
}
}
}
void EDA_APP::SaveCurrentSetupValues( const PARAM_CFG_ARRAY& List ) void EDA_APP::SaveCurrentSetupValues( const PARAM_CFG_ARRAY& List )
{ {
if( m_settings == NULL ) if( m_settings == NULL )
return; return;
unsigned count = List.size(); unsigned count = List.size();
for( unsigned i=0; i<count; ++i ) for( unsigned i=0; i<count; ++i )
{ {
const PARAM_CFG_BASE& param = List[i]; const PARAM_CFG_BASE& param = List[i];
@ -269,74 +187,15 @@ void EDA_APP::SaveCurrentSetupValues( const PARAM_CFG_ARRAY& List )
} }
} }
bool EDA_APP::ReadProjectConfig( const wxString& local_config_filename,
const wxString& GroupName,
PARAM_CFG_BASE** List,
bool Load_Only_if_New )
{
PARAM_CFG_BASE* pt_cfg;
wxString timestamp;
ReCreatePrjConfig( local_config_filename, GroupName, false );
m_projectSettings->SetPath( wxCONFIG_PATH_SEPARATOR );
timestamp = m_projectSettings->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() + wxFileName::GetPathSeparator()
+ g_Prj_Config_LocalFilename;
else
m_CurrentOptionFile = g_Prj_Config_LocalFilename;
}
for( ; List != NULL && *List != NULL; List++ )
{
pt_cfg = *List;
if( pt_cfg->m_Group )
m_projectSettings->SetPath( pt_cfg->m_Group );
else
m_projectSettings->SetPath( GroupName );
if( pt_cfg->m_Setup )
continue;
pt_cfg->ReadParam( m_projectSettings );
}
delete m_projectSettings;
m_projectSettings = NULL;
return true;
}
bool EDA_APP::ReadProjectConfig( const wxString& local_config_filename, bool EDA_APP::ReadProjectConfig( const wxString& local_config_filename,
const wxString& GroupName, const wxString& GroupName,
const PARAM_CFG_ARRAY& params, const PARAM_CFG_ARRAY& params,
bool Load_Only_if_New ) bool Load_Only_if_New )
{ {
wxString timestamp;
ReCreatePrjConfig( local_config_filename, GroupName, false ); ReCreatePrjConfig( local_config_filename, GroupName, false );
m_projectSettings->SetPath( wxCONFIG_PATH_SEPARATOR ); m_projectSettings->SetPath( wxCONFIG_PATH_SEPARATOR );
timestamp = m_projectSettings->Read( wxT( "update" ) ); wxString timestamp = m_projectSettings->Read( wxT( "update" ) );
if( Load_Only_if_New && ( !timestamp.IsEmpty() ) if( Load_Only_if_New && ( !timestamp.IsEmpty() )
&& (timestamp == m_CurrentOptionFileDateAndTime) ) && (timestamp == m_CurrentOptionFileDateAndTime) )
@ -346,19 +205,6 @@ bool EDA_APP::ReadProjectConfig( const wxString& local_config_filename,
m_CurrentOptionFileDateAndTime = timestamp; 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() + wxFileName::GetPathSeparator()
+ g_Prj_Config_LocalFilename;
else
m_CurrentOptionFile = g_Prj_Config_LocalFilename;
}
BOOST_FOREACH( const PARAM_CFG_BASE& param, params ) BOOST_FOREACH( const PARAM_CFG_BASE& param, params )
{ {
if( param.m_Group ) if( param.m_Group )
@ -379,22 +225,6 @@ bool EDA_APP::ReadProjectConfig( const wxString& local_config_filename,
} }
void EDA_APP::ReadCurrentSetupValues( PARAM_CFG_BASE** aList )
{
PARAM_CFG_BASE* pt_cfg;
for( ; *aList != NULL; aList++ )
{
pt_cfg = *aList;
if( pt_cfg->m_Setup == false )
continue;
pt_cfg->ReadParam( m_settings );
}
}
void EDA_APP::ReadCurrentSetupValues( const PARAM_CFG_ARRAY& List ) void EDA_APP::ReadCurrentSetupValues( const PARAM_CFG_ARRAY& List )
{ {
BOOST_FOREACH( const PARAM_CFG_BASE& param, List ) BOOST_FOREACH( const PARAM_CFG_BASE& param, List )
@ -491,8 +321,8 @@ void PARAM_CFG_INT_WITH_SCALE::ReadParam( wxConfigBase* aConfig ) const
if( m_Pt_param == NULL || aConfig == NULL ) if( m_Pt_param == NULL || aConfig == NULL )
return; return;
double default_value = m_Default * m_BIU_to_cfgunit; double dtmp = (double) m_Default * m_BIU_to_cfgunit;
double dtmp = aConfig->Read( m_Ident, default_value ); aConfig->Read( m_Ident, &dtmp );
int itmp = KiROUND( dtmp / m_BIU_to_cfgunit ); int itmp = KiROUND( dtmp / m_BIU_to_cfgunit );
@ -508,7 +338,11 @@ void PARAM_CFG_INT_WITH_SCALE::SaveParam( wxConfigBase* aConfig ) const
if( m_Pt_param == NULL || aConfig == NULL ) if( m_Pt_param == NULL || aConfig == NULL )
return; return;
aConfig->Write( m_Ident, *m_Pt_param * m_BIU_to_cfgunit ); // We cannot use aConfig->Write for a double, because
// this function uses a format with very few digits in mantissa,
// and truncature issues are frequent.
// We uses our function.
ConfigBaseWriteDouble( aConfig, m_Ident, *m_Pt_param * m_BIU_to_cfgunit );
} }
@ -592,23 +426,13 @@ void PARAM_CFG_DOUBLE::ReadParam( wxConfigBase* aConfig ) const
if( m_Pt_param == NULL || aConfig == NULL ) if( m_Pt_param == NULL || aConfig == NULL )
return; return;
double ftmp = 0; double dtmp = m_Default;
wxString msg; aConfig->Read( m_Ident, &dtmp );
msg = aConfig->Read( m_Ident, wxT( "" ) );
if( msg.IsEmpty() ) if( (dtmp < m_Min) || (dtmp > m_Max) )
{ dtmp = m_Default;
ftmp = m_Default;
}
else
{
msg.ToDouble( &ftmp );
if( (ftmp < m_Min) || (ftmp > m_Max) ) *m_Pt_param = dtmp;
ftmp = m_Default;
}
*m_Pt_param = ftmp;
} }
@ -617,7 +441,11 @@ void PARAM_CFG_DOUBLE::SaveParam( wxConfigBase* aConfig ) const
if( m_Pt_param == NULL || aConfig == NULL ) if( m_Pt_param == NULL || aConfig == NULL )
return; return;
aConfig->Write( m_Ident, *m_Pt_param ); // We cannot use aConfig->Write for a double, because
// this function uses a format with very few digits in mantissa,
// and truncature issues are frequent.
// We uses our function.
ConfigBaseWriteDouble( aConfig, m_Ident, *m_Pt_param );
} }
@ -715,8 +543,9 @@ void PARAM_CFG_FILENAME::ReadParam( wxConfigBase* aConfig ) const
{ {
if( m_Pt_param == NULL || aConfig == NULL ) if( m_Pt_param == NULL || aConfig == NULL )
return; return;
wxString prm = aConfig->Read( m_Ident ); wxString prm = aConfig->Read( m_Ident );
// filesnames are stored using Unix notation // file names are stored using Unix notation
// under Window we must use \ instead of / // under Window we must use \ instead of /
// mainly if there is a server name in path (something like \\server\kicad) // mainly if there is a server name in path (something like \\server\kicad)
#ifdef __WINDOWS__ #ifdef __WINDOWS__
@ -765,13 +594,13 @@ void PARAM_CFG_LIBNAME_LIST::ReadParam( wxConfigBase* aConfig ) const
libname = aConfig->Read( id_lib, wxT( "" ) ); libname = aConfig->Read( id_lib, wxT( "" ) );
if( libname.IsEmpty() ) if( libname.IsEmpty() )
break; break;
// filesnames are stored using Unix notation // file names are stored using Unix notation
// under Window we must use \ instead of / // under Window we must use \ instead of /
// mainly if there is a server name in path (something like \\server\kicad) // mainly if there is a server name in path (something like \\server\kicad)
#ifdef __WINDOWS__ #ifdef __WINDOWS__
libname.Replace(wxT("/"), wxT("\\")); libname.Replace(wxT("/"), wxT("\\"));
#endif #endif
libname_list->Add( libname ); libname_list->Add( libname );
} }
} }

View File

@ -120,7 +120,7 @@ public:
* @return true if the application can be started. * @return true if the application can be started.
*/ */
bool OnInit(); // should this be virtual bool OnInit(); // should this be virtual
wxHtmlHelpController* GetHtmlHelpController() { return m_HtmlCtrl; } wxHtmlHelpController* GetHtmlHelpController() { return m_HtmlCtrl; }
void SetHtmlHelpController( wxHtmlHelpController* aController ); void SetHtmlHelpController( wxHtmlHelpController* aController );
@ -248,10 +248,6 @@ public:
* saved parameters are parameters that have the .m_Setup member set to false * saved parameters are parameters that have the .m_Setup member set to false
* saving file is the .pro file project * saving file is the .pro file project
*/ */
void WriteProjectConfig( const wxString& local_config_filename,
const wxString& GroupName,
PARAM_CFG_BASE** List );
void WriteProjectConfig( const wxString& fileName, void WriteProjectConfig( const wxString& fileName,
const wxString& GroupName, const wxString& GroupName,
const PARAM_CFG_ARRAY& params ); const PARAM_CFG_ARRAY& params );
@ -263,7 +259,6 @@ public:
* true. * true.
* @param aList = array of PARAM_CFG_BASE pointers * @param aList = array of PARAM_CFG_BASE pointers
*/ */
void SaveCurrentSetupValues( PARAM_CFG_BASE** aList );
void SaveCurrentSetupValues( const PARAM_CFG_ARRAY& List ); void SaveCurrentSetupValues( const PARAM_CFG_ARRAY& List );
/** /**
@ -273,7 +268,6 @@ public:
* true. * true.
* @param aList = array of PARAM_CFG_BASE pointers * @param aList = array of PARAM_CFG_BASE pointers
*/ */
void ReadCurrentSetupValues( PARAM_CFG_BASE** aList );
void ReadCurrentSetupValues( const PARAM_CFG_ARRAY& List ); void ReadCurrentSetupValues( const PARAM_CFG_ARRAY& List );
/** /**

View File

@ -457,12 +457,6 @@ extern wxString g_UserLibDirBuffer;
extern bool g_ShowPageLimits; ///< true to display the page limits extern bool g_ShowPageLimits; ///< true to display the page limits
/// Name of default configuration file. (kicad.pro)
extern wxString g_Prj_Default_Config_FullFilename;
/// Name of local configuration file. (\<curr projet\>.pro)
extern wxString g_Prj_Config_LocalFilename;
extern EDA_UNITS_T g_UserUnit; ///< display units extern EDA_UNITS_T g_UserUnit; ///< display units
/// Draw color for moving objects. /// Draw color for moving objects.

View File

@ -14,6 +14,31 @@
/**
* inline ConfigBaseWriteDouble
* This is a helper funvtion tor write doubles in config
* We cannot use wxConfigBase->Write for a double, because
* this function uses a format with very few digits in mantissa,
* and truncation issues are frequent.
* We use here a better floatting format.
*
* Note: prior to 2.9.1, the separator was localized, and after, uses
* the "C" notation
*/
void inline ConfigBaseWriteDouble( wxConfigBase* aConfig,
const wxString& aKey, double aValue )
{
wxString tnumber;
#if wxCHECK_VERSION(2,9,1)
tnumber = wxString::FromCDouble( aValue, 12 );
#else
tnumber.Printf( wxT("%12f"), aValue );
#endif
aConfig->Write( aKey, tnumber );
}
/** Type of parameter in the configuration file */ /** Type of parameter in the configuration file */
enum paramcfg_id { enum paramcfg_id {
PARAM_INT, PARAM_INT,

View File

@ -40,7 +40,6 @@
#include <macros.h> #include <macros.h>
#include <kicad.h> #include <kicad.h>
#include <prjconfig.h>
static const wxString ZipFileExtension( wxT( "zip" ) ); static const wxString ZipFileExtension( wxT( "zip" ) );
static const wxString ZipFileWildcard( wxT( "Zip file (*.zip) | *.zip" ) ); static const wxString ZipFileWildcard( wxT( "Zip file (*.zip) | *.zip" ) );

View File

@ -32,7 +32,7 @@
#include <confirm.h> #include <confirm.h>
#include <gestfich.h> #include <gestfich.h>
#include <kicad.h> #include <kicad.h>
#include <prjconfig.h> #include <param_config.h>
#include <project_template.h> #include <project_template.h>
#include <tree_project_frame.h> #include <tree_project_frame.h>
#include <wildcards_and_files_ext.h> #include <wildcards_and_files_ext.h>
@ -47,11 +47,12 @@
#define SEP() wxFileName::GetPathSeparator() #define SEP() wxFileName::GetPathSeparator()
// Not really useful, provided to save/restore params in project config file,
// (Add them in s_KicadManagerParams if any)
// Used also to create new .pro files from the kicad.pro template file
// for new projects
static const wxString GeneralGroupName( wxT( "/general" ) ); static const wxString GeneralGroupName( wxT( "/general" ) );
PARAM_CFG_ARRAY s_KicadManagerParams;
/* KiCad project file entry names. */
static const wxString SchematicRootNameEntry( wxT( "RootSch" ) );
static const wxString BoardFileNameEntry( wxT( "BoardNm" ) );
void KICAD_MANAGER_FRAME::CreateNewProject( const wxString aPrjFullFileName, bool aTemplateSelector = false ) void KICAD_MANAGER_FRAME::CreateNewProject( const wxString aPrjFullFileName, bool aTemplateSelector = false )
@ -75,7 +76,7 @@ void KICAD_MANAGER_FRAME::CreateNewProject( const wxString aPrjFullFileName, boo
if( ::wxGetEnv( wxT( "KICAD" ), NULL ) ) if( ::wxGetEnv( wxT( "KICAD" ), NULL ) )
{ {
wxString kicadEnv; wxString kicadEnv;
wxGetEnv( wxT( "KICAD"), &kicadEnv ); wxGetEnv( wxT( "KICAD"), &kicadEnv );
templatePath = kicadEnv + SEP() + wxT("template")+SEP(); templatePath = kicadEnv + SEP() + wxT("template")+SEP();
} }
else else
@ -152,7 +153,8 @@ void KICAD_MANAGER_FRAME::CreateNewProject( const wxString aPrjFullFileName, boo
m_ProjectFileName = newProjectName; m_ProjectFileName = newProjectName;
// Write settings to project file // Write settings to project file
wxGetApp().WriteProjectConfig( aPrjFullFileName, GeneralGroupName, NULL ); wxGetApp().WriteProjectConfig( aPrjFullFileName,
GeneralGroupName, s_KicadManagerParams );
} }
@ -239,7 +241,7 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event )
wxSetWorkingDirectory( m_ProjectFileName.GetPath() ); wxSetWorkingDirectory( m_ProjectFileName.GetPath() );
wxGetApp().ReadProjectConfig( m_ProjectFileName.GetFullPath(), wxGetApp().ReadProjectConfig( m_ProjectFileName.GetFullPath(),
GeneralGroupName, NULL, false ); GeneralGroupName, s_KicadManagerParams, false );
title = wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() + title = wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() +
wxT( " " ) + m_ProjectFileName.GetFullPath(); wxT( " " ) + m_ProjectFileName.GetFullPath();
@ -269,5 +271,6 @@ void KICAD_MANAGER_FRAME::OnSaveProject( wxCommandEvent& event )
if( !IsWritable( m_ProjectFileName ) ) if( !IsWritable( m_ProjectFileName ) )
return; return;
wxGetApp().WriteProjectConfig( m_ProjectFileName.GetFullPath(), GeneralGroupName, NULL ); wxGetApp().WriteProjectConfig( m_ProjectFileName.GetFullPath(),
GeneralGroupName, s_KicadManagerParams );
} }

View File

@ -1,9 +0,0 @@
/**********************************************************/
/* prjconfig.h : configuration: definition des structures */
/**********************************************************/
#include <param_config.h>
extern PARAM_CFG_BASE* CfgParamList[];

View File

@ -176,12 +176,21 @@ void D_PAD::Flip( int aTranslationY )
void D_PAD::AppendConfigs( PARAM_CFG_ARRAY* aResult ) void D_PAD::AppendConfigs( PARAM_CFG_ARRAY* aResult )
{ {
// Parameters stored in config are only significant parameters
// for a template.
// So not all parameters are stored, just few.
aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "PadDrill" ), aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "PadDrill" ),
&m_Drill.x, &m_Drill.x,
Millimeter2iu( 0.6 ), Millimeter2iu( 0.6 ),
Millimeter2iu( 0.1 ), Millimeter2iu( 10.0 ), Millimeter2iu( 0.1 ), Millimeter2iu( 10.0 ),
NULL, MM_PER_IU ) ); NULL, MM_PER_IU ) );
aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "PadDrillOvalY" ),
&m_Drill.y,
Millimeter2iu( 0.6 ),
Millimeter2iu( 0.1 ), Millimeter2iu( 10.0 ),
NULL, MM_PER_IU ) );
aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "PadSizeH" ), aResult->push_back( new PARAM_CFG_INT_WITH_SCALE( wxT( "PadSizeH" ),
&m_Size.x, &m_Size.x,
Millimeter2iu( 1.4 ), Millimeter2iu( 1.4 ),
@ -427,7 +436,7 @@ int D_PAD::GetSolderMaskMargin()
* value is * value is
* 1 - the local value * 1 - the local value
* 2 - if null, the parent footprint value * 2 - if null, the parent footprint value
* 1 - if null, the global value * 3 - if null, the global value
*/ */
wxSize D_PAD::GetSolderPasteMargin() wxSize D_PAD::GetSolderPasteMargin()
{ {

View File

@ -415,21 +415,20 @@ bool DIALOG_COPPER_ZONE::AcceptOptions( bool aPromptForErrors, bool aUseExportab
m_settings.m_Zone_45_Only = true; m_settings.m_Zone_45_Only = true;
m_settings.m_ThermalReliefGap = ReturnValueFromTextCtrl( *m_AntipadSizeValue ); m_settings.m_ThermalReliefGap = ReturnValueFromTextCtrl( *m_AntipadSizeValue );
m_settings.m_ThermalReliefCopperBridge = ReturnValueFromTextCtrl( *m_CopperWidthValue ); m_settings.m_ThermalReliefCopperBridge = ReturnValueFromTextCtrl( *m_CopperWidthValue );
if( m_Config ) if( m_Config )
{ {
m_Config->Write( ZONE_CLEARANCE_WIDTH_STRING_KEY, ConfigBaseWriteDouble( m_Config, ZONE_CLEARANCE_WIDTH_STRING_KEY,
(double) m_settings.m_ZoneClearance / IU_PER_MILS ); (double) m_settings.m_ZoneClearance / IU_PER_MILS );
m_Config->Write( ZONE_MIN_THICKNESS_WIDTH_STRING_KEY, ConfigBaseWriteDouble( m_Config, ZONE_MIN_THICKNESS_WIDTH_STRING_KEY,
(double) m_settings.m_ZoneMinThickness / IU_PER_MILS ); (double) m_settings.m_ZoneMinThickness / IU_PER_MILS );
m_Config->Write( ZONE_THERMAL_RELIEF_GAP_STRING_KEY, ConfigBaseWriteDouble( m_Config, ZONE_THERMAL_RELIEF_GAP_STRING_KEY,
(double) m_settings.m_ThermalReliefGap / IU_PER_MILS ); (double) m_settings.m_ThermalReliefGap / IU_PER_MILS );
m_Config->Write( ZONE_THERMAL_RELIEF_COPPER_WIDTH_STRING_KEY, ConfigBaseWriteDouble( m_Config, ZONE_THERMAL_RELIEF_COPPER_WIDTH_STRING_KEY,
(double) m_settings.m_ThermalReliefCopperBridge / IU_PER_MILS ); (double) m_settings.m_ThermalReliefCopperBridge / IU_PER_MILS );
} }

View File

@ -7,9 +7,10 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2012 Dick Hollenbeck, dick@softplc.com * Copyright (C) 2013 Dick Hollenbeck, dick@softplc.com
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2004-2013 KiCad Developers, see change_log.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License

View File

@ -1,8 +1,33 @@
///////////////////////////////////////////////////////////////////////////// /**
// Name: dialog_edit_module_text.cpp * @file dialog_edit_module_text.cpp.
// Author: jean-pierre Charras * @brief dialog editor for texts (fields) in footprints
// Licence: GPL */
/////////////////////////////////////////////////////////////////////////////
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 Jean-Pierre Charras
* Copyright (C) 2013 Dick Hollenbeck, dick@softplc.com
* Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <fctsys.h> #include <fctsys.h>

View File

@ -1,13 +1,15 @@
/*******************************************************************/ /**
/* dialog_pad_properties.cpp: Pad editing functions and dialog box */ * @file dialog_pad_properties.cpp.
/* see also dialog_pad_properties_base.xxx (built with wxFormBuilder) */ * @brief Pad editing functions and dialog pad editor
/*******************************************************************/ */
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2012 Jean-Pierre Charras * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2013 Dick Hollenbeck, dick@softplc.com
* Copyright (C) 2008-2013 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -93,15 +95,16 @@ public:
} }
private: private:
PCB_BASE_FRAME* m_Parent; PCB_BASE_FRAME* m_parent;
D_PAD* m_CurrentPad; // pad currently being edited D_PAD* m_currentPad; // pad currently being edited
D_PAD* m_dummyPad; // a working copy used to show changes D_PAD* m_dummyPad; // a working copy used to show changes
BOARD* m_Board; BOARD* m_board;
D_PAD& m_Pad_Master; D_PAD& m_padMaster;
bool m_isFlipped; // true if the parent footprint (therefore pads) is flipped (mirrored) bool m_isFlipped; // true if the parent footprint (therefore pads) is flipped (mirrored)
// in this case, some Y coordinates values must be negated // in this case, some Y coordinates values must be negated
bool m_canUpdate; bool m_canUpdate;
private:
void initValues(); void initValues();
bool padValuesOK(); ///< test if all values are acceptable for the pad bool padValuesOK(); ///< test if all values are acceptable for the pad
@ -143,18 +146,18 @@ DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, D_PAD* aP
// use aParent's parent, which is the original BOARD, not the dummy module editor BOARD, // use aParent's parent, which is the original BOARD, not the dummy module editor BOARD,
// since FOOTPRINT_EDIT_FRAME::GetDesignSettings() is tricked out to use the PCB_EDIT_FRAME's // since FOOTPRINT_EDIT_FRAME::GetDesignSettings() is tricked out to use the PCB_EDIT_FRAME's
// BOARD, not its own BOARD. // BOARD, not its own BOARD.
m_Pad_Master( aParent->GetDesignSettings().m_Pad_Master ) m_padMaster( aParent->GetDesignSettings().m_Pad_Master )
{ {
m_canUpdate = false; m_canUpdate = false;
m_Parent = aParent; m_parent = aParent;
m_CurrentPad = aPad; m_currentPad = aPad;
m_Board = m_Parent->GetBoard(); m_board = m_parent->GetBoard();
m_dummyPad = new D_PAD( (MODULE*) NULL ); m_dummyPad = new D_PAD( (MODULE*) NULL );
if( aPad ) if( aPad )
m_dummyPad->Copy( aPad ); m_dummyPad->Copy( aPad );
else else
m_dummyPad->Copy( &m_Pad_Master ); m_dummyPad->Copy( &m_padMaster );
initValues(); initValues();
@ -175,12 +178,12 @@ void DIALOG_PAD_PROPERTIES::OnPaintShowPanel( wxPaintEvent& event )
if( m_dummyPad->GetLayerMask() & LAYER_FRONT ) if( m_dummyPad->GetLayerMask() & LAYER_FRONT )
{ {
color = m_Board->GetVisibleElementColor( PAD_FR_VISIBLE ); color = m_board->GetVisibleElementColor( PAD_FR_VISIBLE );
} }
if( m_dummyPad->GetLayerMask() & LAYER_BACK ) if( m_dummyPad->GetLayerMask() & LAYER_BACK )
{ {
color = ColorFromInt( color | m_Board->GetVisibleElementColor( PAD_BK_VISIBLE ) ); // XXX EVIL merge color = ColorFromInt( color | m_board->GetVisibleElementColor( PAD_BK_VISIBLE ) ); // XXX EVIL merge
} }
if( color == 0 ) if( color == 0 )
@ -249,26 +252,26 @@ void DIALOG_PAD_PROPERTIES::initValues()
// Setup layers names from board // Setup layers names from board
// Should be made first, before calling m_rbCopperLayersSel->SetSelection() // Should be made first, before calling m_rbCopperLayersSel->SetSelection()
m_rbCopperLayersSel->SetString( 0, m_Board->GetLayerName( LAYER_N_FRONT ) ); m_rbCopperLayersSel->SetString( 0, m_board->GetLayerName( LAYER_N_FRONT ) );
m_rbCopperLayersSel->SetString( 1, m_Board->GetLayerName( LAYER_N_BACK ) ); m_rbCopperLayersSel->SetString( 1, m_board->GetLayerName( LAYER_N_BACK ) );
m_PadLayerAdhCmp->SetLabel( m_Board->GetLayerName( ADHESIVE_N_FRONT ) ); m_PadLayerAdhCmp->SetLabel( m_board->GetLayerName( ADHESIVE_N_FRONT ) );
m_PadLayerAdhCu->SetLabel( m_Board->GetLayerName( ADHESIVE_N_BACK ) ); m_PadLayerAdhCu->SetLabel( m_board->GetLayerName( ADHESIVE_N_BACK ) );
m_PadLayerPateCmp->SetLabel( m_Board->GetLayerName( SOLDERPASTE_N_FRONT ) ); m_PadLayerPateCmp->SetLabel( m_board->GetLayerName( SOLDERPASTE_N_FRONT ) );
m_PadLayerPateCu->SetLabel( m_Board->GetLayerName( SOLDERPASTE_N_BACK ) ); m_PadLayerPateCu->SetLabel( m_board->GetLayerName( SOLDERPASTE_N_BACK ) );
m_PadLayerSilkCmp->SetLabel( m_Board->GetLayerName( SILKSCREEN_N_FRONT ) ); m_PadLayerSilkCmp->SetLabel( m_board->GetLayerName( SILKSCREEN_N_FRONT ) );
m_PadLayerSilkCu->SetLabel( m_Board->GetLayerName( SILKSCREEN_N_BACK ) ); m_PadLayerSilkCu->SetLabel( m_board->GetLayerName( SILKSCREEN_N_BACK ) );
m_PadLayerMaskCmp->SetLabel( m_Board->GetLayerName( SOLDERMASK_N_FRONT ) ); m_PadLayerMaskCmp->SetLabel( m_board->GetLayerName( SOLDERMASK_N_FRONT ) );
m_PadLayerMaskCu->SetLabel( m_Board->GetLayerName( SOLDERMASK_N_BACK ) ); m_PadLayerMaskCu->SetLabel( m_board->GetLayerName( SOLDERMASK_N_BACK ) );
m_PadLayerECO1->SetLabel( m_Board->GetLayerName( ECO1_N ) ); m_PadLayerECO1->SetLabel( m_board->GetLayerName( ECO1_N ) );
m_PadLayerECO2->SetLabel( m_Board->GetLayerName( ECO2_N ) ); m_PadLayerECO2->SetLabel( m_board->GetLayerName( ECO2_N ) );
m_PadLayerDraft->SetLabel( m_Board->GetLayerName( DRAW_N ) ); m_PadLayerDraft->SetLabel( m_board->GetLayerName( DRAW_N ) );
m_isFlipped = false; m_isFlipped = false;
if( m_CurrentPad ) if( m_currentPad )
{ {
MODULE* module = m_CurrentPad->GetParent(); MODULE* module = m_currentPad->GetParent();
if( module->GetLayer() == LAYER_N_BACK ) if( module->GetLayer() == LAYER_N_BACK )
{ {
@ -383,11 +386,11 @@ void DIALOG_PAD_PROPERTIES::initValues()
break; break;
} }
if( m_CurrentPad ) if( m_currentPad )
{ {
MODULE* module = m_CurrentPad->GetParent(); MODULE* module = m_currentPad->GetParent();
angle = m_CurrentPad->GetOrientation() - module->GetOrientation(); angle = m_currentPad->GetOrientation() - module->GetOrientation();
if( m_isFlipped ) if( m_isFlipped )
NEGATE( angle ); NEGATE( angle );
@ -740,109 +743,109 @@ void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event )
bool rastnestIsChanged = false; bool rastnestIsChanged = false;
int isign = m_isFlipped ? -1 : 1; int isign = m_isFlipped ? -1 : 1;
transferDataToPad( &m_Pad_Master ); transferDataToPad( &m_padMaster );
if( m_CurrentPad ) // Set current Pad parameters if( m_currentPad ) // Set current Pad parameters
{ {
wxSize size; wxSize size;
MODULE* module = m_CurrentPad->GetParent(); MODULE* module = m_currentPad->GetParent();
m_Parent->SaveCopyInUndoList( module, UR_CHANGED ); m_parent->SaveCopyInUndoList( module, UR_CHANGED );
module->SetLastEditTime(); module->SetLastEditTime();
// redraw the area where the pad was, without pad (delete pad on screen) // redraw the area where the pad was, without pad (delete pad on screen)
m_CurrentPad->SetFlags( DO_NOT_DRAW ); m_currentPad->SetFlags( DO_NOT_DRAW );
m_Parent->GetCanvas()->RefreshDrawingRect( m_CurrentPad->GetBoundingBox() ); m_parent->GetCanvas()->RefreshDrawingRect( m_currentPad->GetBoundingBox() );
m_CurrentPad->ClearFlags( DO_NOT_DRAW ); m_currentPad->ClearFlags( DO_NOT_DRAW );
// Update values // Update values
m_CurrentPad->SetShape( m_Pad_Master.GetShape() ); m_currentPad->SetShape( m_padMaster.GetShape() );
m_CurrentPad->SetAttribute( m_Pad_Master.GetAttribute() ); m_currentPad->SetAttribute( m_padMaster.GetAttribute() );
if( m_CurrentPad->GetPosition() != m_Pad_Master.GetPosition() ) if( m_currentPad->GetPosition() != m_padMaster.GetPosition() )
{ {
m_CurrentPad->SetPosition( m_Pad_Master.GetPosition() ); m_currentPad->SetPosition( m_padMaster.GetPosition() );
rastnestIsChanged = true; rastnestIsChanged = true;
} }
// compute the pos 0 value, i.e. pad position for module with orientation = 0 // compute the pos 0 value, i.e. pad position for module with orientation = 0
// i.e. relative to module origin (module position) // i.e. relative to module origin (module position)
wxPoint pt = m_CurrentPad->GetPosition() - module->GetPosition(); wxPoint pt = m_currentPad->GetPosition() - module->GetPosition();
RotatePoint( &pt, -module->GetOrientation() ); RotatePoint( &pt, -module->GetOrientation() );
m_CurrentPad->SetPos0( pt ); m_currentPad->SetPos0( pt );
m_CurrentPad->SetOrientation( m_Pad_Master.GetOrientation() * isign + module->GetOrientation() ); m_currentPad->SetOrientation( m_padMaster.GetOrientation() * isign + module->GetOrientation() );
m_CurrentPad->SetSize( m_Pad_Master.GetSize() ); m_currentPad->SetSize( m_padMaster.GetSize() );
size = m_Pad_Master.GetDelta(); size = m_padMaster.GetDelta();
size.y *= isign; size.y *= isign;
m_CurrentPad->SetDelta( size ); m_currentPad->SetDelta( size );
m_CurrentPad->SetDrillSize( m_Pad_Master.GetDrillSize() ); m_currentPad->SetDrillSize( m_padMaster.GetDrillSize() );
m_CurrentPad->SetDrillShape( m_Pad_Master.GetDrillShape() ); m_currentPad->SetDrillShape( m_padMaster.GetDrillShape() );
wxPoint offset = m_Pad_Master.GetOffset(); wxPoint offset = m_padMaster.GetOffset();
offset.y *= isign; offset.y *= isign;
m_CurrentPad->SetOffset( offset ); m_currentPad->SetOffset( offset );
m_CurrentPad->SetPadToDieLength( m_Pad_Master.GetPadToDieLength() ); m_currentPad->SetPadToDieLength( m_padMaster.GetPadToDieLength() );
if( m_CurrentPad->GetLayerMask() != m_Pad_Master.GetLayerMask() ) if( m_currentPad->GetLayerMask() != m_padMaster.GetLayerMask() )
{ {
rastnestIsChanged = true; rastnestIsChanged = true;
m_CurrentPad->SetLayerMask( m_Pad_Master.GetLayerMask() ); m_currentPad->SetLayerMask( m_padMaster.GetLayerMask() );
} }
if( m_isFlipped ) if( m_isFlipped )
m_CurrentPad->SetLayerMask( ChangeSideMaskLayer( m_CurrentPad->GetLayerMask() ) ); m_currentPad->SetLayerMask( ChangeSideMaskLayer( m_currentPad->GetLayerMask() ) );
m_CurrentPad->SetPadName( m_Pad_Master.GetPadName() ); m_currentPad->SetPadName( m_padMaster.GetPadName() );
if( m_CurrentPad->GetNetname() != m_Pad_Master.GetNetname() ) if( m_currentPad->GetNetname() != m_padMaster.GetNetname() )
{ {
if( m_Pad_Master.GetNetname().IsEmpty() ) if( m_padMaster.GetNetname().IsEmpty() )
{ {
rastnestIsChanged = true; rastnestIsChanged = true;
m_CurrentPad->SetNet( 0 ); m_currentPad->SetNet( 0 );
m_CurrentPad->SetNetname( wxEmptyString ); m_currentPad->SetNetname( wxEmptyString );
} }
else else
{ {
const NETINFO_ITEM* net = m_Parent->GetBoard()->FindNet( m_Pad_Master.GetNetname() ); const NETINFO_ITEM* net = m_board->FindNet( m_padMaster.GetNetname() );
if( net ) if( net )
{ {
rastnestIsChanged = true; rastnestIsChanged = true;
m_CurrentPad->SetNetname( m_Pad_Master.GetNetname() ); m_currentPad->SetNetname( m_padMaster.GetNetname() );
m_CurrentPad->SetNet( net->GetNet() ); m_currentPad->SetNet( net->GetNet() );
} }
else else
DisplayError( NULL, _( "Unknown netname, netname not changed" ) ); DisplayError( NULL, _( "Unknown netname, netname not changed" ) );
} }
} }
m_CurrentPad->SetLocalClearance( m_Pad_Master.GetLocalClearance() ); m_currentPad->SetLocalClearance( m_padMaster.GetLocalClearance() );
m_CurrentPad->SetLocalSolderMaskMargin( m_Pad_Master.GetLocalSolderMaskMargin() ); m_currentPad->SetLocalSolderMaskMargin( m_padMaster.GetLocalSolderMaskMargin() );
m_CurrentPad->SetLocalSolderPasteMargin( m_Pad_Master.GetLocalSolderPasteMargin() ); m_currentPad->SetLocalSolderPasteMargin( m_padMaster.GetLocalSolderPasteMargin() );
m_CurrentPad->SetLocalSolderPasteMarginRatio( m_Pad_Master.GetLocalSolderPasteMarginRatio() ); m_currentPad->SetLocalSolderPasteMarginRatio( m_padMaster.GetLocalSolderPasteMarginRatio() );
m_CurrentPad->SetZoneConnection( m_Pad_Master.GetZoneConnection() ); m_currentPad->SetZoneConnection( m_padMaster.GetZoneConnection() );
m_CurrentPad->SetThermalWidth( m_Pad_Master.GetThermalWidth() ); m_currentPad->SetThermalWidth( m_padMaster.GetThermalWidth() );
m_CurrentPad->SetThermalGap( m_Pad_Master.GetThermalGap() ); m_currentPad->SetThermalGap( m_padMaster.GetThermalGap() );
module->CalculateBoundingBox(); module->CalculateBoundingBox();
m_Parent->SetMsgPanel( m_CurrentPad ); m_parent->SetMsgPanel( m_currentPad );
// redraw the area where the pad was // redraw the area where the pad was
m_Parent->GetCanvas()->RefreshDrawingRect( m_CurrentPad->GetBoundingBox() ); m_parent->GetCanvas()->RefreshDrawingRect( m_currentPad->GetBoundingBox() );
m_Parent->OnModify(); m_parent->OnModify();
} }
EndModal( wxID_OK ); EndModal( wxID_OK );
if( rastnestIsChanged ) // The net ratsnest must be recalculated if( rastnestIsChanged ) // The net ratsnest must be recalculated
m_Parent->GetBoard()->m_Status_Pcb = 0; m_board->m_Status_Pcb = 0;
} }

View File

@ -627,7 +627,7 @@ void DIALOG_PLOT::applyPlotSettings()
m_messagesBox->AppendText( msg ); m_messagesBox->AppendText( msg );
} }
m_config->Write( OPTKEY_PLOT_X_FINESCALE_ADJ, m_XScaleAdjust ); ConfigBaseWriteDouble( m_config, OPTKEY_PLOT_X_FINESCALE_ADJ, m_XScaleAdjust );
// Y scale // Y scale
msg = m_fineAdjustYscaleOpt->GetValue(); msg = m_fineAdjustYscaleOpt->GetValue();
@ -641,7 +641,7 @@ void DIALOG_PLOT::applyPlotSettings()
m_messagesBox->AppendText( msg ); m_messagesBox->AppendText( msg );
} }
m_config->Write( OPTKEY_PLOT_Y_FINESCALE_ADJ, m_YScaleAdjust ); ConfigBaseWriteDouble( m_config, OPTKEY_PLOT_Y_FINESCALE_ADJ, m_YScaleAdjust );
// PS Width correction // PS Width correction
msg = m_PSFineAdjustWidthOpt->GetValue(); msg = m_PSFineAdjustWidthOpt->GetValue();
@ -661,7 +661,8 @@ void DIALOG_PLOT::applyPlotSettings()
} }
// Store m_PSWidthAdjust in mm in user config // Store m_PSWidthAdjust in mm in user config
m_config->Write( CONFIG_PS_FINEWIDTH_ADJ, (double)m_PSWidthAdjust / IU_PER_MM ); ConfigBaseWriteDouble( m_config, CONFIG_PS_FINEWIDTH_ADJ,
(double)m_PSWidthAdjust / IU_PER_MM );
tempOptions.SetUseGerberExtensions( m_useGerberExtensions->GetValue() ); tempOptions.SetUseGerberExtensions( m_useGerberExtensions->GetValue() );

View File

@ -314,8 +314,10 @@ void DIALOG_PRINT_USING_PRINTER::OnCloseWindow( wxCloseEvent& event )
if( m_config ) if( m_config )
{ {
m_config->Write( OPTKEY_PRINT_X_FINESCALE_ADJ, s_Parameters.m_XScaleAdjust ); ConfigBaseWriteDouble( m_config, OPTKEY_PRINT_X_FINESCALE_ADJ,
m_config->Write( OPTKEY_PRINT_Y_FINESCALE_ADJ, s_Parameters.m_YScaleAdjust ); s_Parameters.m_XScaleAdjust );
ConfigBaseWriteDouble( m_config, OPTKEY_PRINT_Y_FINESCALE_ADJ,
s_Parameters.m_YScaleAdjust );
m_config->Write( OPTKEY_PRINT_SCALE, m_ScaleOption->GetSelection() ); m_config->Write( OPTKEY_PRINT_SCALE, m_ScaleOption->GetSelection() );
m_config->Write( OPTKEY_PRINT_PAGE_FRAME, s_Parameters.m_Print_Sheet_Ref); m_config->Write( OPTKEY_PRINT_PAGE_FRAME, s_Parameters.m_Print_Sheet_Ref);
m_config->Write( OPTKEY_PRINT_MONOCHROME_MODE, s_Parameters.m_Print_Black_and_White); m_config->Write( OPTKEY_PRINT_MONOCHROME_MODE, s_Parameters.m_Print_Black_and_White);

View File

@ -61,11 +61,11 @@
// Keys used in read/write config // Keys used in read/write config
#define OPTKEY_DEFAULT_LINEWIDTH_VALUE wxT( "PlotLineWidth_mm" ) #define OPTKEY_DEFAULT_LINEWIDTH_VALUE wxT( "PlotLineWidth_mm" )
#define PCB_SHOW_FULL_RATSNET_OPT wxT( "PcbFulRatsnest" ) #define PCB_SHOW_FULL_RATSNET_OPT wxT( "PcbFullRatsnest" )
#define PCB_MAGNETIC_PADS_OPT wxT( "PcbMagPadOpt" ) #define PCB_MAGNETIC_PADS_OPT wxT( "PcbMagPadOpt" )
#define PCB_MAGNETIC_TRACKS_OPT wxT( "PcbMagTrackOpt" ) #define PCB_MAGNETIC_TRACKS_OPT wxT( "PcbMagTrackOpt" )
#define SHOW_MICROWAVE_TOOLS wxT( "ShowMicrowaveTools" ) #define SHOW_MICROWAVE_TOOLS wxT( "ShowMicrowaveTools" )
#define SHOW_LAYER_MANAGER_TOOLS wxT( "ShowLayerManagerTools" ) #define SHOW_LAYER_MANAGER_TOOLS wxT( "ShowLayerManagerTools" )
BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME ) BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
@ -313,14 +313,6 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title,
m_drc = new DRC( this ); // these 2 objects point to each other m_drc = new DRC( this ); // these 2 objects point to each other
m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill;
m_DisplayPadFill = DisplayOpt.DisplayPadFill;
m_DisplayViaFill = DisplayOpt.DisplayViaFill;
m_DisplayPadNum = DisplayOpt.DisplayPadNum;
m_DisplayModEdge = DisplayOpt.DisplayModEdge;
m_DisplayModText = DisplayOpt.DisplayModText;
wxIcon icon; wxIcon icon;
icon.CopyFromBitmap( KiBitmap( icon_pcbnew_xpm ) ); icon.CopyFromBitmap( KiBitmap( icon_pcbnew_xpm ) );
SetIcon( icon ); SetIcon( icon );
@ -333,6 +325,16 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title,
// LoadSettings() *after* creating m_LayersManager, because LoadSettings() // LoadSettings() *after* creating m_LayersManager, because LoadSettings()
// initialize parameters in m_LayersManager // initialize parameters in m_LayersManager
LoadSettings(); LoadSettings();
// Be sure options are updated
m_DisplayPcbTrackFill = DisplayOpt.DisplayPcbTrackFill;
m_DisplayPadFill = DisplayOpt.DisplayPadFill;
m_DisplayViaFill = DisplayOpt.DisplayViaFill;
m_DisplayPadNum = DisplayOpt.DisplayPadNum;
m_DisplayModEdge = DisplayOpt.DisplayModEdge;
m_DisplayModText = DisplayOpt.DisplayModText;
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER ); GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER );
@ -592,6 +594,7 @@ void PCB_EDIT_FRAME::LoadSettings()
long tmp; long tmp;
config->Read( PCB_SHOW_FULL_RATSNET_OPT, &tmp ); config->Read( PCB_SHOW_FULL_RATSNET_OPT, &tmp );
GetBoard()->SetElementVisibility(RATSNEST_VISIBLE, tmp); GetBoard()->SetElementVisibility(RATSNEST_VISIBLE, tmp);
config->Read( PCB_MAGNETIC_PADS_OPT, &g_MagneticPadOption ); config->Read( PCB_MAGNETIC_PADS_OPT, &g_MagneticPadOption );
config->Read( PCB_MAGNETIC_TRACKS_OPT, &g_MagneticTrackOption ); config->Read( PCB_MAGNETIC_TRACKS_OPT, &g_MagneticTrackOption );
config->Read( SHOW_MICROWAVE_TOOLS, &m_show_microwave_tools ); config->Read( SHOW_MICROWAVE_TOOLS, &m_show_microwave_tools );

View File

@ -51,7 +51,6 @@
#include <pcbnew.h> #include <pcbnew.h>
#include <pcbnew_id.h> #include <pcbnew_id.h>
#include <hotkeys.h> #include <hotkeys.h>
#include <protos.h>
#include <pcbnew_config.h> #include <pcbnew_config.h>
#include <dialog_mask_clearance.h> #include <dialog_mask_clearance.h>
@ -348,6 +347,8 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings()
&DisplayOpt.DisplayModText, FILLED, 0, 2 ) ); &DisplayOpt.DisplayModText, FILLED, 0, 2 ) );
m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "PcbAffT" ), m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "PcbAffT" ),
&DisplayOpt.DisplayDrawItems, FILLED, 0, 2 ) ); &DisplayOpt.DisplayDrawItems, FILLED, 0, 2 ) );
m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "PcbShowZonesMode" ),
&DisplayOpt.DisplayZonesMode, 0, 0, 2 ) );
// Colors: // Colors:
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLay0" ), LOC_COLOR( 0 ), m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLay0" ), LOC_COLOR( 0 ),