Commit 51291b09 authored by jean-pierre charras's avatar jean-pierre charras

Fix many issues in config functions, mainly a rounding issue when a double is...

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.
parents 45fc0125 d0724de1
......@@ -52,14 +52,9 @@ wxString g_ProductName = wxT( "KiCad E.D.A. " );
bool g_ShowPageLimits = true;
wxString g_UserLibDirBuffer;
wxString g_Prj_Default_Config_FullFilename;
wxString g_Prj_Config_LocalFilename;
EDA_UNITS_T g_UserUnit;
EDA_COLOR_T g_GhostColor;
#if defined(KICAD_GOST)
static const bool s_gost = true;
#else
......
This diff is collapsed.
......@@ -120,7 +120,7 @@ public:
* @return true if the application can be started.
*/
bool OnInit(); // should this be virtual
wxHtmlHelpController* GetHtmlHelpController() { return m_HtmlCtrl; }
void SetHtmlHelpController( wxHtmlHelpController* aController );
......@@ -248,10 +248,6 @@ public:
* saved parameters are parameters that have the .m_Setup member set to false
* 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,
const wxString& GroupName,
const PARAM_CFG_ARRAY& params );
......@@ -263,7 +259,6 @@ public:
* true.
* @param aList = array of PARAM_CFG_BASE pointers
*/
void SaveCurrentSetupValues( PARAM_CFG_BASE** aList );
void SaveCurrentSetupValues( const PARAM_CFG_ARRAY& List );
/**
......@@ -273,7 +268,6 @@ public:
* true.
* @param aList = array of PARAM_CFG_BASE pointers
*/
void ReadCurrentSetupValues( PARAM_CFG_BASE** aList );
void ReadCurrentSetupValues( const PARAM_CFG_ARRAY& List );
/**
......
......@@ -457,12 +457,6 @@ extern wxString g_UserLibDirBuffer;
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
/// Draw color for moving objects.
......
......@@ -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 */
enum paramcfg_id {
PARAM_INT,
......
......@@ -40,7 +40,6 @@
#include <macros.h>
#include <kicad.h>
#include <prjconfig.h>
static const wxString ZipFileExtension( wxT( "zip" ) );
static const wxString ZipFileWildcard( wxT( "Zip file (*.zip) | *.zip" ) );
......
......@@ -32,7 +32,7 @@
#include <confirm.h>
#include <gestfich.h>
#include <kicad.h>
#include <prjconfig.h>
#include <param_config.h>
#include <project_template.h>
#include <tree_project_frame.h>
#include <wildcards_and_files_ext.h>
......@@ -47,11 +47,12 @@
#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" ) );
/* KiCad project file entry names. */
static const wxString SchematicRootNameEntry( wxT( "RootSch" ) );
static const wxString BoardFileNameEntry( wxT( "BoardNm" ) );
PARAM_CFG_ARRAY s_KicadManagerParams;
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 ) )
{
wxString kicadEnv;
wxGetEnv( wxT( "KICAD"), &kicadEnv );
wxGetEnv( wxT( "KICAD"), &kicadEnv );
templatePath = kicadEnv + SEP() + wxT("template")+SEP();
}
else
......@@ -152,7 +153,8 @@ void KICAD_MANAGER_FRAME::CreateNewProject( const wxString aPrjFullFileName, boo
m_ProjectFileName = newProjectName;
// 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() );
wxGetApp().ReadProjectConfig( m_ProjectFileName.GetFullPath(),
GeneralGroupName, NULL, false );
GeneralGroupName, s_KicadManagerParams, false );
title = wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() +
wxT( " " ) + m_ProjectFileName.GetFullPath();
......@@ -269,5 +271,6 @@ void KICAD_MANAGER_FRAME::OnSaveProject( wxCommandEvent& event )
if( !IsWritable( m_ProjectFileName ) )
return;
wxGetApp().WriteProjectConfig( m_ProjectFileName.GetFullPath(), GeneralGroupName, NULL );
wxGetApp().WriteProjectConfig( m_ProjectFileName.GetFullPath(),
GeneralGroupName, s_KicadManagerParams );
}
/**********************************************************/
/* prjconfig.h : configuration: definition des structures */
/**********************************************************/
#include <param_config.h>
extern PARAM_CFG_BASE* CfgParamList[];
......@@ -176,12 +176,21 @@ void D_PAD::Flip( int aTranslationY )
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" ),
&m_Drill.x,
Millimeter2iu( 0.6 ),
Millimeter2iu( 0.1 ), Millimeter2iu( 10.0 ),
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" ),
&m_Size.x,
Millimeter2iu( 1.4 ),
......@@ -427,7 +436,7 @@ int D_PAD::GetSolderMaskMargin()
* value is
* 1 - the local value
* 2 - if null, the parent footprint value
* 1 - if null, the global value
* 3 - if null, the global value
*/
wxSize D_PAD::GetSolderPasteMargin()
{
......
......@@ -415,21 +415,20 @@ bool DIALOG_COPPER_ZONE::AcceptOptions( bool aPromptForErrors, bool aUseExportab
m_settings.m_Zone_45_Only = true;
m_settings.m_ThermalReliefGap = ReturnValueFromTextCtrl( *m_AntipadSizeValue );
m_settings.m_ThermalReliefCopperBridge = ReturnValueFromTextCtrl( *m_CopperWidthValue );
if( m_Config )
{
m_Config->Write( ZONE_CLEARANCE_WIDTH_STRING_KEY,
(double) m_settings.m_ZoneClearance / IU_PER_MILS );
ConfigBaseWriteDouble( m_Config, ZONE_CLEARANCE_WIDTH_STRING_KEY,
(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 );
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 );
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 );
}
......
......@@ -7,9 +7,10 @@
/*
* 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) 2012 Dick Hollenbeck, dick@softplc.com
* Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2013 Dick Hollenbeck, dick@softplc.com
* 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
* modify it under the terms of the GNU General Public License
......
/////////////////////////////////////////////////////////////////////////////
// Name: dialog_edit_module_text.cpp
// Author: jean-pierre Charras
// Licence: GPL
/////////////////////////////////////////////////////////////////////////////
/**
* @file dialog_edit_module_text.cpp.
* @brief dialog editor for texts (fields) in footprints
*/
/*
* 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>
......
This diff is collapsed.
......@@ -627,7 +627,7 @@ void DIALOG_PLOT::applyPlotSettings()
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
msg = m_fineAdjustYscaleOpt->GetValue();
......@@ -641,7 +641,7 @@ void DIALOG_PLOT::applyPlotSettings()
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
msg = m_PSFineAdjustWidthOpt->GetValue();
......@@ -661,7 +661,8 @@ void DIALOG_PLOT::applyPlotSettings()
}
// 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() );
......
......@@ -314,8 +314,10 @@ void DIALOG_PRINT_USING_PRINTER::OnCloseWindow( wxCloseEvent& event )
if( m_config )
{
m_config->Write( OPTKEY_PRINT_X_FINESCALE_ADJ, s_Parameters.m_XScaleAdjust );
m_config->Write( OPTKEY_PRINT_Y_FINESCALE_ADJ, s_Parameters.m_YScaleAdjust );
ConfigBaseWriteDouble( m_config, OPTKEY_PRINT_X_FINESCALE_ADJ,
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_PAGE_FRAME, s_Parameters.m_Print_Sheet_Ref);
m_config->Write( OPTKEY_PRINT_MONOCHROME_MODE, s_Parameters.m_Print_Black_and_White);
......
......@@ -61,11 +61,11 @@
// Keys used in read/write config
#define OPTKEY_DEFAULT_LINEWIDTH_VALUE wxT( "PlotLineWidth_mm" )
#define PCB_SHOW_FULL_RATSNET_OPT wxT( "PcbFulRatsnest" )
#define PCB_MAGNETIC_PADS_OPT wxT( "PcbMagPadOpt" )
#define PCB_MAGNETIC_TRACKS_OPT wxT( "PcbMagTrackOpt" )
#define SHOW_MICROWAVE_TOOLS wxT( "ShowMicrowaveTools" )
#define SHOW_LAYER_MANAGER_TOOLS wxT( "ShowLayerManagerTools" )
#define PCB_SHOW_FULL_RATSNET_OPT wxT( "PcbFullRatsnest" )
#define PCB_MAGNETIC_PADS_OPT wxT( "PcbMagPadOpt" )
#define PCB_MAGNETIC_TRACKS_OPT wxT( "PcbMagTrackOpt" )
#define SHOW_MICROWAVE_TOOLS wxT( "ShowMicrowaveTools" )
#define SHOW_LAYER_MANAGER_TOOLS wxT( "ShowLayerManagerTools" )
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_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;
icon.CopyFromBitmap( KiBitmap( icon_pcbnew_xpm ) );
SetIcon( icon );
......@@ -333,6 +325,16 @@ PCB_EDIT_FRAME::PCB_EDIT_FRAME( wxWindow* parent, const wxString& title,
// LoadSettings() *after* creating m_LayersManager, because LoadSettings()
// initialize parameters in m_LayersManager
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 );
GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER );
......@@ -592,6 +594,7 @@ void PCB_EDIT_FRAME::LoadSettings()
long tmp;
config->Read( PCB_SHOW_FULL_RATSNET_OPT, &tmp );
GetBoard()->SetElementVisibility(RATSNEST_VISIBLE, tmp);
config->Read( PCB_MAGNETIC_PADS_OPT, &g_MagneticPadOption );
config->Read( PCB_MAGNETIC_TRACKS_OPT, &g_MagneticTrackOption );
config->Read( SHOW_MICROWAVE_TOOLS, &m_show_microwave_tools );
......
......@@ -51,7 +51,6 @@
#include <pcbnew.h>
#include <pcbnew_id.h>
#include <hotkeys.h>
#include <protos.h>
#include <pcbnew_config.h>
#include <dialog_mask_clearance.h>
......@@ -348,6 +347,8 @@ PARAM_CFG_ARRAY& PCB_EDIT_FRAME::GetConfigurationSettings()
&DisplayOpt.DisplayModText, FILLED, 0, 2 ) );
m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "PcbAffT" ),
&DisplayOpt.DisplayDrawItems, FILLED, 0, 2 ) );
m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "PcbShowZonesMode" ),
&DisplayOpt.DisplayZonesMode, 0, 0, 2 ) );
// Colors:
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColLay0" ), LOC_COLOR( 0 ),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment